power-grid-model
power-grid-model copied to clipboard
[FEATURE] Ideal source handling
Describe the feature request
An ideal source is represented by having infinite short circuit power (sk
). However, the current implementation of the power-grid-model will raise a validation error when sk == inf
:
This ticket is about supporting ideal sources for power flow and state estimation calculation types. (And undefined behavior for short circuit calculations.)
Background
When sk
is extremely large but not infinite (e.g. sk == 10e50
), the power flow and state estimation calculation types are already numerically stable, cfr. #458 . Unfortunately, this value is arbitrarily set. We currently require our users to provide such an arbitrarily large value when they desire an ideal source. Even more so, within the PGM, intermediate calculations may cause an arbitrarily large value to become infinite, e.g.:
-
10e200 * 10e200 = 10e400 > std::numeric_limits<double>::max() (~10e306)
=>10e200 * 10e200
will result ininf
A single such inf
value in the internal calculations will result in NaN
values in the output, i.e. nonsense output.
Desired solution
Cap the sk
to some fixed non-infinite value so that it does not results in NaN
output values but still mimics ideal sources well enough for realistic/practical purposes. This allows users to provide inf
to request an ideal source.
- [ ] In the C++ implementation of the Source component type in https://github.com/PowerGridModel/power-grid-model/blob/main/power_grid_model_c/power_grid_model/include/power_grid_model/component/source.hpp :
- [ ] Create a
static constexpr double ideal_source_sk = 10e50;
constant.- [ ] Note that this is arbitrarily chosen (mention this in a comment)
- [ ] This value is so large that it does not affect numerical stability for practical use cases, while still being small enough to never cause infinities and NaN values in the calculations. (please verify with simple examples)
- [ ] In the constructor of the Source component type, set
sk
to the minimum of the user-specifiedsk
andideal_source_sk
.- [ ] Note that this is only correct for power flow and state estimation
- [ ] For short circuit calculations, the
sk
heavily influences the calculation result, and we consider this to be undefined behavior (UB; see below)
- [ ] Create a
- [ ] Update the validation cases
- [ ] Support
sk == inf
for power flow and state estimation - [ ] Do not support
sk == inf
andsk > 10e50
for short circuit calculations due to deliberately UB
- [ ] Support
- [ ] In the documentation on the Source component type :
- [ ] On the input attributes: https://github.com/PowerGridModel/power-grid-model/blob/main/docs/user_manual/components.md?plain=1#L388
- [ ] Mention that
sk == inf
represents an ideal source
- [ ] Mention that
- [ ] On the electrical model in https://github.com/PowerGridModel/power-grid-model/blob/main/docs/user_manual/components.md?plain=1#L392-L416 :
- [ ] Mention that the
sk
is capped at10e50
- [ ] Mention that unrealistically large
sk
(sk > 10e50
) results in UB for short circuit calculations, because thesk
heavily affects the short circuit calculation results.
- [ ] Mention that the
- [ ] On the input attributes: https://github.com/PowerGridModel/power-grid-model/blob/main/docs/user_manual/components.md?plain=1#L388