@@ -19,10 +19,10 @@ namespace GridKit
1919{
2020 namespace PhasorDynamics
2121 {
22- template <class ScalarT , typename IdxT >
22+ template <typename scalar_type , typename index_type >
2323 class BusBase ;
2424
25- template <class ScalarT , typename IdxT >
25+ template <typename scalar_type , typename index_type >
2626 class SignalNode ;
2727 } // namespace PhasorDynamics
2828} // namespace GridKit
@@ -59,44 +59,47 @@ namespace GridKit
5959 MAXIMUM ,
6060 };
6161
62- template <class ScalarT , typename IdxT >
63- class Regca : public Component <ScalarT, IdxT >
62+ template <typename scalar_type , typename index_type >
63+ class Regca : public Component <scalar_type, index_type >
6464 {
65- using Component<ScalarT, IdxT >::gridkit_component_id_;
66- using Component<ScalarT, IdxT >::alpha_;
67- using Component<ScalarT, IdxT >::f_ ;
68- using Component<ScalarT, IdxT >::h_ ;
69- using Component<ScalarT, IdxT >::J_ ;
70- using Component<ScalarT, IdxT >::J_cols_buffer_;
71- using Component<ScalarT, IdxT >::J_rows_buffer_;
72- using Component<ScalarT, IdxT >::J_vals_buffer_;
73- using Component<ScalarT, IdxT >::nnz_;
74- using Component<ScalarT, IdxT >::residual_indices_;
75- using Component<ScalarT, IdxT >::size_;
76- using Component<ScalarT, IdxT >::tag_;
77- using Component<ScalarT, IdxT >::time_;
78- using Component<ScalarT, IdxT >::va_system_base_;
79- using Component<ScalarT, IdxT >::variable_indices_;
80- using Component<ScalarT, IdxT >::wb_;
81- using Component<ScalarT, IdxT >::y_;
82- using Component<ScalarT, IdxT >::yp_;
65+ using Component<scalar_type, index_type >::gridkit_component_id_;
66+ using Component<scalar_type, index_type >::alpha_;
67+ using Component<scalar_type, index_type >::abs_tol_ ;
68+ using Component<scalar_type, index_type >::f_ ;
69+ using Component<scalar_type, index_type >::h_ ;
70+ using Component<scalar_type, index_type >::J_cols_buffer_;
71+ using Component<scalar_type, index_type >::J_rows_buffer_;
72+ using Component<scalar_type, index_type >::J_vals_buffer_;
73+ using Component<scalar_type, index_type >::nnz_;
74+ using Component<scalar_type, index_type >::residual_indices_;
75+ using Component<scalar_type, index_type >::size_;
76+ using Component<scalar_type, index_type >::tag_;
77+ using Component<scalar_type, index_type >::time_;
78+ using Component<scalar_type, index_type >::va_system_base_;
79+ using Component<scalar_type, index_type >::variable_indices_;
80+ using Component<scalar_type, index_type >::wb_;
81+ using Component<scalar_type, index_type >::y_;
82+ using Component<scalar_type, index_type >::yp_;
8383
8484 public:
85- using RealT = typename Component<ScalarT, IdxT>::RealT;
86- using bus_type = BusBase<ScalarT, IdxT>;
87- using signal_type = SignalNode<ScalarT, IdxT>;
88- using model_data_type = RegcaData<RealT, IdxT>;
89- using MonitorT = Model::VariableMonitor<Regca, RegcaData>;
90-
91- Regca (bus_type* bus);
92- Regca (bus_type* bus, const model_data_type& data);
85+ using ScalarT = scalar_type;
86+ using IdxT = index_type;
87+ using RealT = typename Component<ScalarT, IdxT>::RealT;
88+ using BusT = BusBase<ScalarT, IdxT>;
89+ using SignalT = SignalNode<ScalarT, IdxT>;
90+ using ModelDataT = RegcaData<RealT, IdxT>;
91+ using MonitorT = Model::VariableMonitor<Regca, RegcaData>;
92+
93+ Regca (BusT* bus);
94+ Regca (BusT* bus, const ModelDataT& data);
9395 ~Regca ();
9496
9597 int setGridKitComponentID (IdxT) override final ;
9698 int allocate () override final ;
9799 int verify () const override final ;
98100 int initialize () override final ;
99101 int tagDifferentiable () override final ;
102+ int setAbsoluteTolerance (RealT rel_tol) override final ;
100103 int evaluateResidual () override final ;
101104 int evaluateJacobian () override final ;
102105
@@ -112,12 +115,12 @@ namespace GridKit
112115 const Model::VariableMonitorBase* getMonitor () const override ;
113116
114117 __attribute__ ((always_inline)) inline int evaluateInternalResidual (
115- ScalarT*, ScalarT*, ScalarT*, ScalarT*, ScalarT*);
118+ const ScalarT*, const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
116119 __attribute__ ((always_inline)) inline int evaluateBusResidual (
117- ScalarT*, ScalarT*, ScalarT*, ScalarT*);
120+ const ScalarT*, const ScalarT*, const ScalarT*, ScalarT*);
118121
119122 private:
120- void initializeParameters (const model_data_type & data);
123+ void initializeParameters (const ModelDataT & data);
121124 void initializeMonitor ();
122125 void setDerivedParameters ();
123126
@@ -131,8 +134,8 @@ namespace GridKit
131134 return value / toComponentBase (static_cast <ScalarT>(ONE <RealT>));
132135 }
133136
134- ScalarT activeCurrentLowerRateBound (ScalarT ip) const ;
135- ScalarT activeCurrentUpperRateBound (ScalarT ip, ScalarT il) const ;
137+ ScalarT lpTarget (ScalarT ip) const ;
138+ ScalarT upTarget (ScalarT ip, ScalarT il) const ;
136139
137140 ScalarT& Vr ()
138141 {
@@ -154,7 +157,7 @@ namespace GridKit
154157 return bus_->Ii ();
155158 }
156159
157- bus_type * bus_{nullptr };
160+ BusT * bus_{nullptr };
158161
159162 RealT P0_ {0 };
160163 RealT Q0_ {0 };
0 commit comments