Skip to content

Commit 8a6ddd0

Browse files
committed
Try computing and using the exciter Jacobian.
1 parent a20aeeb commit 8a6ddd0

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

GridKit/CommonMath.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ namespace GridKit
2727
__attribute__((always_inline)) inline ScalarT sigmoid(const ScalarT x)
2828
{
2929
using RealT = typename GridKit::ScalarTraits<ScalarT>::RealT;
30-
static constexpr RealT MU = 240.0;
31-
return ONE<RealT> / (ONE<RealT> + std::exp(-MU * x));
30+
static constexpr RealT MU = 40000.0;
31+
return (HALF<RealT> * MU * x) / (ONE<RealT> + std::abs(MU * x)) + HALF<RealT>;
32+
//return ONE<RealT> / (ONE<RealT> + std::exp(-MU * x));
3233
}
3334

3435
/**

GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ namespace GridKit
100100
int evaluateResidual() override;
101101
int evaluateJacobian() override;
102102

103-
bool hasJacobian() override
104-
{
105-
return false;
106-
}
107-
108103
/// Get the `ComponentSignals` from this `Ieeet1`
109104
auto getSignals()
110105
-> ComponentSignals<ScalarT,
@@ -150,7 +145,6 @@ namespace GridKit
150145
ScalarT vUEL_{0};
151146
ScalarT vOEL_{0};
152147
ScalarT vS_{0};
153-
ScalarT Ec_{0}; // "Compensated" terminal measurment
154148

155149
/// Component signal extension
156150
ComponentSignals<ScalarT, IdxT, Ieeet1InternalVariables, Ieeet1ExternalVariables> signals_;

GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Enzyme.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ namespace GridKit
2727
// std::cout << "Evaluate Jacobian for Ieeet1..." << std::endl;
2828
// std::cout << "Jacobian evaluation is experimental!" << std::endl;
2929

30-
// The following will fail to build without a smooth approximation for
31-
// the saturation
32-
#if 0
3330
J_.zeroMatrix();
3431

3532
GridKit::Enzyme::Sparse::InternalJacobianWithSignal<GridKit::PhasorDynamics::Exciter::Ieeet1<ScalarT, IdxT>,
@@ -57,7 +54,7 @@ namespace GridKit
5754
bus_->getVariableIndices(),
5855
y_.data(),
5956
yp_.data(),
60-
wb_.data(),
57+
(bus_->y()).data(),
6158
ws_.data(),
6259
J_);
6360

@@ -74,7 +71,6 @@ namespace GridKit
7471
wb_.data(),
7572
ws_.data(),
7673
J_);
77-
#endif
7874

7975
return 0;
8076
}

GridKit/Model/PhasorDynamics/Exciter/IEEET1/Ieeet1Impl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,18 @@ namespace GridKit
185185
// Terminal Voltage
186186
ScalarT vreal = bus_->Vr();
187187
ScalarT vimag = bus_->Vi();
188-
Ec_ = std::sqrt(vreal * vreal + vimag * vimag);
188+
ScalarT Ec = std::sqrt(vreal * vreal + vimag * vimag);
189189

190190
// Derived from External initial values
191191
ScalarT vr = Ke_ * efd0;
192192
ScalarT vfx = Kf_ / Tf_ * efd0;
193193
ScalarT vtr = Ke_ / Ka_ * efd0;
194194

195195
// Vref (setpoint = terminal + error)
196-
vref_ = Ec_ + vtr;
196+
vref_ = Ec + vtr;
197197

198198
// IVP for Internal Variables
199-
y_[0] = Ec_; // y0 - vts - Sensed term volt
199+
y_[0] = Ec; // y0 - vts - Sensed term volt
200200
y_[1] = vr; // y1 - vr - Voltage reg
201201
y_[2] = efd0; // y2 - efdp - Efd pre mult
202202
y_[3] = vfx; // y3 - vfx - Exciter feedback
@@ -259,7 +259,7 @@ namespace GridKit
259259
// Read E comp (terminal voltage, unless compensation impedance)
260260
ScalarT vreal = wb[0];
261261
ScalarT vimag = wb[1];
262-
Ec_ = std::sqrt(vreal * vreal + vimag * vimag);
262+
ScalarT Ec = std::sqrt(vreal * vreal + vimag * vimag);
263263

264264
// Read Internal Variables
265265
ScalarT vts = y[0]; // y0 - Sensed term volt
@@ -286,13 +286,13 @@ namespace GridKit
286286
ScalarT vr_ind = Math::indicator(Vrmin_, Vrmax_, vr, func);
287287

288288
// Internal Differential Equations
289-
f[0] = -vts_dot + (Ec_ - vts) / Tr_;
289+
f[0] = -vts_dot + (Ec - vts) / Tr_;
290290
f[1] = -vr_dot + vr_ind * func / Ta_;
291291
f[2] = -efdp_dot + (vr - ve - Ke_ * efdp) / Te_;
292292
f[3] = -vfx_dot + vf / Tf_;
293293

294294
// Internal Algebraic Equations
295-
f[4] = -vtr + vref_ + vUEL_ + vOEL_ + vS_ - vf - vts;
295+
f[4] = -vts + vref_ + vUEL_ + vOEL_ + vS_ - vtr - vf;
296296
f[5] = -vf + (efdp * Kf_) / Tf_ - vfx;
297297
f[6] = -ve + ksat * efdp;
298298
f[7] = -efd + efdp + omega * efdp * Ispdlim_;

0 commit comments

Comments
 (0)