IEEEST Stabilizer Improvements/Corrections#460
Conversation
|
@pelesh this fix is also ready to be merged I forgot to make a PR for this one. |
509506c to
e2c07d8
Compare
pelesh
left a comment
There was a problem hiding this comment.
The logic governing changing differential into algebraic equations and vice versa does not seem to be sustainable. This requires more offline discussion.
| f[8] = tag_[4] * (-T2_ * (v5 - x5) + T1_ * (v4 - x5)) + (1 - tag_[4]) * (v4 - v5); | ||
| f[9] = tag_[5] * (-T4_ * (v6 - x6) + T3_ * (v5 - x6)) + (1 - tag_[5]) * (v5 - v6); | ||
| f[10] = tag_[6] * (-T6_ * v7 + Ks_ * T5_ * (v6 - x7)) + (1 - tag_[6]) * (Ks_ * v6 - v7); |
There was a problem hiding this comment.
I am not sure if this is a good idea. We are changing equations based on whether we defined other equations to be differential or algebraic. Furthermore, we rely here on implicit bool-to-integer and integer-to-floating point conversions. This logic needs to be implemented in a different way.
There was a problem hiding this comment.
I am not sure how to implement this without introducing template-y solutions. Do we want to move toward something like this where we define the model conditionally?
template <class ScalarT, typename IdxT, Order order, Block t2, Block t4, Block t6>But there are 31 different permutations, so there would be a lot of duplicate code. I don't know what the general approach should be, so I am open to any suggestions.
| tag_[0] = (a2_ != ZERO<RealT> || a3_ != ZERO<RealT> || a4_ != ZERO<RealT>); | ||
| tag_[1] = tag_[0]; | ||
| tag_[2] = (a3_ != ZERO<RealT> || a4_ != ZERO<RealT>); | ||
| tag_[3] = (a4_ != ZERO<RealT>); | ||
| tag_[4] = (T2_ != ZERO<RealT>); | ||
| tag_[5] = (T4_ != ZERO<RealT>); | ||
| tag_[6] = (T6_ != ZERO<RealT>); |
There was a problem hiding this comment.
The logic implemented this way will break when we add solvers that require DAEs implemented in Hessenberg form.
There was a problem hiding this comment.
Opened an issue #463 where hopefully we can discuss the general approach to take since this impacts almost every model
e2c07d8 to
bab57ad
Compare
8bbbad6 to
090289b
Compare
|
I have rebased and adjusted the formulation to align with #463 . |
755ee20 to
282fc1d
Compare
nkoukpaizan
left a comment
There was a problem hiding this comment.
I have a few comments here. Perhaps worth discussing at our next meeting.
| tag_.resize(size); | ||
| abs_tol_.resize(size); | ||
|
|
||
| f_.assign(size, ScalarT{0}); |
There was a problem hiding this comment.
resize makes more sense to me in the allocate method. Initialization occurs later.
| }; | ||
|
|
||
| std::fill(tag_.begin(), tag_.end(), false); | ||
| tag_[index(IeeestInternalVariables::X1)] = true; |
There was a problem hiding this comment.
This is a lot less readable to me than the previous implementation.
| { | ||
| std::cout << "Non-zero residual at index " << i << ": " << f[i] << "\n"; | ||
| success = false; | ||
| auto test_tol = (i == 11) ? loose_tol : tol_; |
There was a problem hiding this comment.
A comment would be helpful when changing tolerances.
| { | ||
| const auto U = static_cast<size_t>(IeeestExternalVariables::U); | ||
|
|
||
| std::fill(ws_.begin(), ws_.end(), ZERO<RealT>); |
There was a problem hiding this comment.
I would argue std::fill is a overkill here. The size is 1.
| const auto U = static_cast<size_t>(IeeestExternalVariables::U); | ||
|
|
||
| const ScalarT x1 = y[X1]; | ||
| const ScalarT x2 = y[X2]; |
There was a problem hiding this comment.
Same here, the indirection from the enum is less readable to me. We should discuss a sustainable way to use the enums.
| using Variable = typename ModelDataT::MonitorableVariables; | ||
| monitor_->set(Variable::vss, [this] | ||
| { return y_[11]; }); | ||
| auto index = [](IeeestInternalVariables variable) |
There was a problem hiding this comment.
I've seen this pattern a few times. Consider defining once if it is really needed. I would argue it's less readable.
| result += test.constructor(); | ||
| result += test.zeroInitialResidual(); |
There was a problem hiding this comment.
Why remove the constructor and the zeroInitialResidual tests?
| #include <cstddef> | ||
| #include <memory> | ||
| #include <vector> |
There was a problem hiding this comment.
Pretty sure vector should already be included. Could you comment on the need for cstddef and memory?
| Ieeest<scalar_type, index_type>::Ieeest() | ||
| { | ||
| size_ = 12; | ||
| size_ = static_cast<IdxT>(IeeestInternalVariables::MAXIMUM); |
There was a problem hiding this comment.
I prefer the hard-coded size, but that's minor. Perhaps add an assert for the enum.
| const std::vector<ResidualCase> cases = { | ||
| {"baseline", | ||
| [](DataT&) {}, | ||
| {0.19, 0.28, 0.37, 1.0975, 0.25, 0.24, -0.01, -0.42, -0.25, -0.31, 1.15, 0.0}}, |
There was a problem hiding this comment.
This combination of std::vector and lambda functions is not very readable to me. Consider splitting.
282fc1d to
579b3c1
Compare
Description
Fixes and cleans up the
IEEESTstabilizer implementation and documentation.This updates the older initial implementation style so that reduced-order notch filters and zero denominator time constants are handled consistently
Proposed changes
IEEESTfrom the attached input signal instead of forcing all states to zero.Checklist
-Wall -Wpedantic -Wconversion -Wextra.Changelog changes N/A
Further comments
This is cleanup/correction work for the existing
IEEESTmodel, not a new model