|
| 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 |
0 commit comments