Skip to content

Commit 7a4fdbc

Browse files
committed
Add REECB phasor dynamics model
1 parent d0b0c75 commit 7a4fdbc

24 files changed

Lines changed: 2316 additions & 21 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- Added cmake-format hooks, including in pre-commit.
6363
- Added off-nominal tap ratio and phase shift support to the PhasorDynamics `Branch` model.
6464
- Added portable Vector class to GridKit
65+
- Added `REECB` converter model implementation for PhasorDynamics.
6566

6667
## v0.1
6768

GridKit/CommonMath.hpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,31 @@ namespace GridKit
162162
}
163163

164164
/**
165-
* @brief Smooth two-sided deadband function
165+
* @brief Smooth Type 1 no-offset two-sided deadband function
166+
*
167+
* Smooth approximation to a deadband that returns zero inside the band and
168+
* passes the input through unchanged outside the band.
169+
*
170+
* @tparam ScalarT - scalar data type
171+
* @tparam RealT - Real data type (see GridKit::ScalarTraits<ScalarT>::RealT)
172+
*
173+
* @param[in] x - Input signal
174+
* @param[in] lower - Lower breakpoint
175+
* @param[in] upper - Upper breakpoint
176+
* @return Smooth no-offset deadbanded value
177+
*/
178+
template <class ScalarT, typename RealT>
179+
__attribute__((always_inline)) inline ScalarT deadband1(
180+
const ScalarT x,
181+
const RealT lower,
182+
const RealT upper)
183+
{
184+
assert(lower <= upper);
185+
return x * (sigmoid(lower - x) + sigmoid(x - upper));
186+
}
187+
188+
/**
189+
* @brief Smooth Type 2 offset two-sided deadband function
166190
*
167191
* Smooth approximation to x - min(max(x, lower), upper), composed from the
168192
* smooth ramp function.
@@ -173,10 +197,10 @@ namespace GridKit
173197
* @param[in] x - Input signal
174198
* @param[in] lower - Lower breakpoint
175199
* @param[in] upper - Upper breakpoint
176-
* @return Smooth deadbanded value
200+
* @return Smooth offset deadbanded value
177201
*/
178202
template <class ScalarT, typename RealT>
179-
__attribute__((always_inline)) inline ScalarT deadband(
203+
__attribute__((always_inline)) inline ScalarT deadband2(
180204
const ScalarT x,
181205
const RealT lower,
182206
const RealT upper)

GridKit/Model/PhasorDynamics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ add_subdirectory(Branch)
3333
add_subdirectory(Bus)
3434
add_subdirectory(BusFault)
3535
add_subdirectory(BusToSignalAdapter)
36+
add_subdirectory(Converter)
3637
add_subdirectory(Exciter)
3738
add_subdirectory(Governor)
3839
add_subdirectory(Load)

GridKit/Model/PhasorDynamics/ComponentLibrary.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <GridKit/Model/PhasorDynamics/Bus/BusInfinite.hpp>
66
#include <GridKit/Model/PhasorDynamics/BusFault/BusFault.hpp>
77
#include <GridKit/Model/PhasorDynamics/BusToSignalAdapter/BusToSignalAdapter.hpp>
8+
#include <GridKit/Model/PhasorDynamics/Converter/REECB/Reecb.hpp>
89
#include <GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp>
910
#include <GridKit/Model/PhasorDynamics/Exciter/SEXS-PTI/SexsPti.hpp>
1011
#include <GridKit/Model/PhasorDynamics/Governor/Tgov1/Tgov1.hpp>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# [[
2+
# Author(s):
3+
# - Luke Lowery <lukel@tamu.edu>
4+
# ]]
5+
6+
add_subdirectory(REECB)

GridKit/Model/PhasorDynamics/Converter/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ models and the bus equations, typically through commanded active and reactive cu
99

1010
The GridKit converter documentation includes:
1111

12-
- Renewable Energy Generator/Converter Model REGCA (See [REGCA](REGCA/README.md))
1312
- Renewable Energy Generator/Converter Model REGCB (See [REGCB](REGCB/README.md))
1413
- Renewable Energy Electrical Control Model REECA (See [REECA](REECA/README.md))
14+
- Renewable Energy Electrical Control Model REECB (See [REECB](REECB/README.md))
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# [[
2+
# Author(s):
3+
# - Luke Lowery <lukel@tamu.edu>
4+
# ]]
5+
6+
set(_install_headers Reecb.hpp ReecbData.hpp)
7+
8+
if(GRIDKIT_ENABLE_ENZYME)
9+
gridkit_add_library(
10+
phasor_dynamics_converter_reecb
11+
SOURCES ReecbEnzyme.cpp
12+
HEADERS ${_install_headers}
13+
INCLUDE_DIRECTORIES PRIVATE ${GRIDKIT_THIRD_PARTY_DIR}/magic-enum/include
14+
LINK_LIBRARIES
15+
PUBLIC
16+
GridKit::phasor_dynamics_core
17+
PUBLIC
18+
GridKit::phasor_dynamics_signal
19+
PRIVATE
20+
ClangEnzymeFlags
21+
COMPILE_OPTIONS
22+
PRIVATE
23+
-mllvm
24+
-enzyme-auto-sparsity=1
25+
-fno-math-errno)
26+
else()
27+
gridkit_add_library(
28+
phasor_dynamics_converter_reecb
29+
SOURCES Reecb.cpp
30+
HEADERS ${_install_headers}
31+
INCLUDE_DIRECTORIES PRIVATE ${GRIDKIT_THIRD_PARTY_DIR}/magic-enum/include
32+
LINK_LIBRARIES
33+
PUBLIC
34+
GridKit::phasor_dynamics_core
35+
PUBLIC
36+
GridKit::phasor_dynamics_signal)
37+
endif()
38+
39+
gridkit_add_library(
40+
phasor_dynamics_converter_reecb_dependency_tracking
41+
SOURCES ReecbDependencyTracking.cpp
42+
INCLUDE_DIRECTORIES PRIVATE ${GRIDKIT_THIRD_PARTY_DIR}/magic-enum/include
43+
LINK_LIBRARIES
44+
PUBLIC
45+
GridKit::phasor_dynamics_core
46+
PUBLIC
47+
GridKit::phasor_dynamics_signal_dependency_tracking)
48+
49+
target_link_libraries(
50+
phasor_dynamics_components
51+
INTERFACE GridKit::phasor_dynamics_converter_reecb)
52+
target_link_libraries(
53+
phasor_dynamics_components_dependency_tracking
54+
INTERFACE GridKit::phasor_dynamics_converter_reecb_dependency_tracking)

0 commit comments

Comments
 (0)