Skip to content

Commit 58d9dcf

Browse files
committed
Add ESDC1A Impl and Docs
1 parent 78aec28 commit 58d9dcf

23 files changed

Lines changed: 2051 additions & 1 deletion

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- Added component model developer checklist to a README file.
5353
- Added `IEEEST` Stabilizer Model
5454
- Added `SEXS-PTI` Exciter Model
55+
- Added `ESDC1A` Exciter Model
5556
- Added `GENSAL` Machine Model
5657
- Added 200 Bus Synthetic Illinois Case
5758
- Added node objects to `PowerElectronics` module & updated all examples to make use of them.

GridKit/Model/PhasorDynamics/Component.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ namespace GridKit
112112
return abs_tol_;
113113
}
114114

115+
int setAbsoluteTolerance(RealT rel_tol) override
116+
{
117+
for (IdxT i = 0; i < size_; ++i)
118+
{
119+
abs_tol_[static_cast<size_t>(i)] = rel_tol;
120+
}
121+
return 0;
122+
}
123+
115124
std::vector<ScalarT>& getResidual() override
116125
{
117126
return f_;

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/Exciter/ESDC1A/Esdc1a.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>

GridKit/Model/PhasorDynamics/Exciter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
# - Luke Lowery <lukel@tamu.edu>
44
# ]]
55

6+
add_subdirectory(ESDC1A)
67
add_subdirectory(IEEET1)
78
add_subdirectory(SEXS-PTI)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# [[
2+
# Author(s):
3+
# - Luke Lowery <lukel@tamu.edu>
4+
# ]]
5+
6+
set(_install_headers Esdc1a.hpp Esdc1aData.hpp)
7+
8+
if(GRIDKIT_ENABLE_ENZYME)
9+
gridkit_add_library(
10+
phasor_dynamics_exciter_esdc1a
11+
SOURCES Esdc1aEnzyme.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_exciter_esdc1a
29+
SOURCES Esdc1a.cpp
30+
HEADERS ${_install_headers}
31+
INCLUDE_DIRECTORIES PRIVATE ${GRIDKIT_THIRD_PARTY_DIR}/magic-enum/include
32+
LINK_LIBRARIES GridKit::phasor_dynamics_core GridKit::phasor_dynamics_signal)
33+
endif()
34+
35+
gridkit_add_library(
36+
phasor_dynamics_exciter_esdc1a_dependency_tracking
37+
SOURCES Esdc1aDependencyTracking.cpp
38+
INCLUDE_DIRECTORIES PRIVATE ${GRIDKIT_THIRD_PARTY_DIR}/magic-enum/include
39+
LINK_LIBRARIES GridKit::phasor_dynamics_core GridKit::phasor_dynamics_signal_dependency_tracking)
40+
41+
target_link_libraries(
42+
phasor_dynamics_components
43+
INTERFACE GridKit::phasor_dynamics_exciter_esdc1a)
44+
target_link_libraries(
45+
phasor_dynamics_components_dependency_tracking
46+
INTERFACE GridKit::phasor_dynamics_exciter_esdc1a_dependency_tracking)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file Esdc1a.cpp
3+
* @author Luke Lowery (lukel@tamu.edu)
4+
* @brief Non-Enzyme instantiation for the ESDC1A exciter model.
5+
*/
6+
7+
#include "Esdc1aImpl.hpp"
8+
9+
namespace GridKit
10+
{
11+
namespace PhasorDynamics
12+
{
13+
namespace Exciter
14+
{
15+
template <class ScalarT, typename IdxT>
16+
int Esdc1a<ScalarT, IdxT>::evaluateJacobian()
17+
{
18+
Log::misc() << "Evaluate Jacobian for Esdc1a..." << std::endl;
19+
Log::misc() << "Jacobian evaluation not implemented!" << std::endl;
20+
return 0;
21+
}
22+
23+
template class Esdc1a<double, long int>;
24+
template class Esdc1a<double, size_t>;
25+
} // namespace Exciter
26+
} // namespace PhasorDynamics
27+
} // namespace GridKit
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/**
2+
* @file Esdc1a.hpp
3+
* @author Luke Lowery (lukel@tamu.edu)
4+
* @brief Declaration of the ESDC1A exciter model.
5+
*/
6+
7+
#pragma once
8+
9+
#include <cstddef>
10+
#include <memory>
11+
#include <vector>
12+
13+
#include <GridKit/Model/PhasorDynamics/Component.hpp>
14+
#include <GridKit/Model/PhasorDynamics/ComponentSignals.hpp>
15+
#include <GridKit/Model/PhasorDynamics/Exciter/ESDC1A/Esdc1aData.hpp>
16+
#include <GridKit/Model/VariableMonitor.hpp>
17+
18+
namespace GridKit
19+
{
20+
namespace PhasorDynamics
21+
{
22+
template <class ScalarT, typename IdxT>
23+
class BusBase;
24+
25+
template <class ScalarT, typename IdxT>
26+
class SignalNode;
27+
28+
namespace Exciter
29+
{
30+
/// Internal variables of an `Esdc1a`.
31+
enum class Esdc1aInternalVariables : size_t
32+
{
33+
EFDP, ///< Field-voltage state before optional speed multiplier
34+
VC, ///< Sensed compensated voltage
35+
VR, ///< Voltage-regulator output
36+
VF, ///< Stabilizing feedback output
37+
XLL, ///< Lead-lag state
38+
EV, ///< Voltage-regulator input error
39+
VLL, ///< Lead-lag block output
40+
VHV, ///< High-value gate output
41+
SE, ///< Saturation coefficient
42+
VFE, ///< Exciter feedback signal
43+
EFD, ///< Field-voltage output
44+
MAXIMUM,
45+
};
46+
47+
/// External variables of an `Esdc1a`.
48+
enum class Esdc1aExternalVariables : size_t
49+
{
50+
OMEGA, ///< Machine speed deviation
51+
VS, ///< Stabilizer input signal
52+
VUEL, ///< Under-excitation limiter input
53+
MAXIMUM,
54+
};
55+
56+
template <class ScalarT, typename IdxT>
57+
class Esdc1a : public Component<ScalarT, IdxT>
58+
{
59+
using Component<ScalarT, IdxT>::abs_tol_;
60+
using Component<ScalarT, IdxT>::alpha_;
61+
using Component<ScalarT, IdxT>::f_;
62+
using Component<ScalarT, IdxT>::gridkit_component_id_;
63+
using Component<ScalarT, IdxT>::J_cols_buffer_;
64+
using Component<ScalarT, IdxT>::J_rows_buffer_;
65+
using Component<ScalarT, IdxT>::J_vals_buffer_;
66+
using Component<ScalarT, IdxT>::nnz_;
67+
using Component<ScalarT, IdxT>::residual_indices_;
68+
using Component<ScalarT, IdxT>::size_;
69+
using Component<ScalarT, IdxT>::tag_;
70+
using Component<ScalarT, IdxT>::variable_indices_;
71+
using Component<ScalarT, IdxT>::wb_;
72+
using Component<ScalarT, IdxT>::y_;
73+
using Component<ScalarT, IdxT>::yp_;
74+
75+
public:
76+
using RealT = typename Component<ScalarT, IdxT>::RealT;
77+
using bus_type = BusBase<ScalarT, IdxT>;
78+
using signal_type = SignalNode<ScalarT, IdxT>;
79+
using model_data_type = Esdc1aData<RealT, IdxT>;
80+
using MonitorT = Model::VariableMonitor<Esdc1a, Esdc1aData>;
81+
82+
Esdc1a(bus_type* bus);
83+
Esdc1a(bus_type* bus, const model_data_type& data);
84+
~Esdc1a();
85+
86+
int setGridKitComponentID(IdxT) override final;
87+
int allocate() override final;
88+
int verify() const override final;
89+
int initialize() override final;
90+
int tagDifferentiable() override final;
91+
int setAbsoluteTolerance(RealT rel_tol) override final;
92+
int evaluateResidual() override final;
93+
int evaluateJacobian() override final;
94+
95+
auto getSignals()
96+
-> ComponentSignals<ScalarT,
97+
IdxT,
98+
Esdc1aInternalVariables,
99+
Esdc1aExternalVariables>&
100+
{
101+
return signals_;
102+
}
103+
104+
const Model::VariableMonitorBase* getMonitor() const override;
105+
106+
__attribute__((always_inline)) inline int evaluateInternalResidual(
107+
const ScalarT*, const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
108+
109+
private:
110+
void initModelParams(const model_data_type& data);
111+
void setDerivedParams();
112+
void initializeMonitor();
113+
114+
static constexpr RealT TIME_CONSTANT_MINIMUM = static_cast<RealT>(1.0e-3);
115+
116+
bus_type* bus_{nullptr};
117+
118+
RealT Tr_{0.0};
119+
RealT Ka_{40.0};
120+
RealT Ta_{0.1};
121+
RealT Tb_{0.0};
122+
RealT Tc_{0.0};
123+
RealT Vrmax_{1.0};
124+
RealT Vrmin_{-1.0};
125+
RealT Ke_{0.1};
126+
RealT Te_{0.5};
127+
RealT Kf_{0.05};
128+
RealT Tf1_{0.7};
129+
RealT spdmlt_{0.0};
130+
RealT E1_{2.8};
131+
RealT Se1_{0.08};
132+
RealT E2_{3.7};
133+
RealT Se2_{0.33};
134+
IdxT UEL_{0};
135+
RealT exclim_{1.0};
136+
137+
IdxT parameter_error_count_{0};
138+
139+
RealT sUEL_{0};
140+
RealT sUELoff_{1};
141+
RealT slim_{0};
142+
RealT slim_off_{1};
143+
RealT SA_{0};
144+
RealT SB_{0};
145+
146+
ScalarT vref_{0};
147+
148+
ComponentSignals<ScalarT, IdxT, Esdc1aInternalVariables, Esdc1aExternalVariables> signals_;
149+
std::unique_ptr<MonitorT> monitor_;
150+
151+
std::vector<ScalarT> ws_;
152+
std::vector<IdxT> ws_indices_;
153+
};
154+
} // namespace Exciter
155+
} // namespace PhasorDynamics
156+
} // namespace GridKit
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/**
2+
* @file Esdc1aData.hpp
3+
* @author Luke Lowery (lukel@tamu.edu)
4+
* @brief Modeling data for the ESDC1A exciter model.
5+
*/
6+
7+
#pragma once
8+
9+
#include <GridKit/Model/PhasorDynamics/ComponentData.hpp>
10+
11+
namespace GridKit
12+
{
13+
namespace PhasorDynamics
14+
{
15+
namespace Exciter
16+
{
17+
/// Parameter keys for the ESDC1A exciter model.
18+
enum class Esdc1aParameters
19+
{
20+
Tr, ///< Transducer time constant
21+
Ka, ///< Voltage-regulator gain
22+
Ta, ///< Voltage-regulator time constant
23+
Tb, ///< Lead-lag denominator time constant
24+
Tc, ///< Lead-lag numerator time constant
25+
Vrmax, ///< Maximum voltage-regulator output
26+
Vrmin, ///< Minimum voltage-regulator output
27+
Ke, ///< Exciter field-resistance line-slope margin
28+
Te, ///< Exciter field time constant
29+
Kf, ///< Stabilizing feedback gain
30+
Tf1, ///< Feedback lead time constant
31+
Spdmlt, ///< Speed multiplier flag
32+
E1, ///< First saturation voltage point
33+
Se1, ///< Saturation value at E1
34+
E2, ///< Second saturation voltage point
35+
Se2, ///< Saturation value at E2
36+
UEL, ///< UEL input-location selector
37+
exclim ///< Exciter feedback lower-limit flag
38+
};
39+
40+
/// Ports for the ESDC1A exciter model.
41+
enum class Esdc1aPorts
42+
{
43+
bus, ///< Unique ID of the terminal bus
44+
speed, ///< Unique ID of the generator speed-deviation signal
45+
efd, ///< Unique ID of the output EFD signal
46+
vs, ///< Unique ID of the optional stabilizer input signal
47+
vuel ///< Unique ID of the optional UEL input signal
48+
};
49+
50+
/// Variables available through the monitor interface.
51+
enum class Esdc1aMonitorableVariables
52+
{
53+
efd, ///< Field-voltage output
54+
vc, ///< Sensed compensated voltage
55+
vr, ///< Voltage-regulator output
56+
vf, ///< Stabilizing feedback state
57+
se, ///< Saturation coefficient
58+
vfe ///< Exciter feedback signal
59+
};
60+
61+
template <typename RealT, typename IdxT>
62+
struct Esdc1aData : public ComponentData<RealT,
63+
IdxT,
64+
Esdc1aParameters,
65+
Esdc1aPorts,
66+
Esdc1aMonitorableVariables>
67+
{
68+
Esdc1aData() = default;
69+
70+
using Parameters = Esdc1aParameters;
71+
using Ports = Esdc1aPorts;
72+
using MonitorableVariables = Esdc1aMonitorableVariables;
73+
};
74+
} // namespace Exciter
75+
} // namespace PhasorDynamics
76+
} // namespace GridKit
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @file Esdc1aDependencyTracking.cpp
3+
* @author Luke Lowery (lukel@tamu.edu)
4+
* @brief Dependency-tracking instantiations for the ESDC1A exciter model.
5+
*/
6+
7+
#include "Esdc1aImpl.hpp"
8+
9+
namespace GridKit
10+
{
11+
namespace PhasorDynamics
12+
{
13+
namespace Exciter
14+
{
15+
template <class ScalarT, typename IdxT>
16+
int Esdc1a<ScalarT, IdxT>::evaluateJacobian()
17+
{
18+
Log::misc() << "Evaluate Jacobian for Esdc1a..." << std::endl;
19+
Log::misc() << "Jacobian evaluation not implemented!" << std::endl;
20+
return 0;
21+
}
22+
23+
template class Esdc1a<DependencyTracking::Variable, long int>;
24+
template class Esdc1a<DependencyTracking::Variable, size_t>;
25+
} // namespace Exciter
26+
} // namespace PhasorDynamics
27+
} // namespace GridKit

0 commit comments

Comments
 (0)