Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reactive_power_sigma attribute #409

Merged
merged 44 commits into from Nov 3, 2023
Merged

Conversation

mgovers
Copy link
Member

@mgovers mgovers commented Oct 19, 2023

Related to #237
Related to #369

Changes

  • Add new RealValue attributes p_sigma and q_sigma to power sensor input and update. These are optional attributes.
    • If p_sigma and q_sigma are both NaN, the power_sigma is the apparent power sigma and is required (current behaviour) for state estimation.
    • If p_sigma and q_sigma are both not NaN, p_sigma is the active power sigma and q_sigma is the reactive power sigma.
    • It is not supported to provide only one of p_sigma and q_sigma, just like how it is not supported to only provide 1 of three phases of an asymmetric RealValue. The behavior is undefined in the core. In the validation function in Python side we raise an error.
    • Update data definition
    • Update documentation
  • Create a new struct in calculation_parameters.hpp with PowerSensorCalcParam, VoltageSensorCalcParam, as the calculation parameter output of relevant sensor components. In VoltageSensorCalcParam is the same as old SensorCalcParam. PowerSensorCalcParam should have variance_p and variance_q, these are also RealValue. So it is three phase for asymmetric calculation.
  • Change the sensor component to store power_sigma, p_sigma and q_sigma as member data. Store them as per unit value as it is now. Note: the base power for sym_power_sensor and asym_power_sensor is different. Change the way to generate PowerSensorCalcParam:
    • If p_sigma is NaN: Set variance_p = variance_q = power_sigma**2 / 2
      • For asymmetric calculation (for both sym_power_sensor and asym_power_sensor), variance_p = variance_q = power_sigma**2 / 2 * [1, 1, 1]
    • If p_sigma is not NaN: Set variance_p = p_sigma**2 and variance_q = q_sigma**2
      • For asymmetric calculation of sym_power_sensor, variance_p = p_sigma**2 * [1, 1, 1], same as Q.
      • For symmetric calculation of asym_power_sensor, variance_p = mean(p_sigma**2), same as Q.
    • If either p_sigma is provided and q_sigma is not, or vice versa. The behaviour is undefined. That's why we only check p_sigma in the above two cases.
    • If either p_sigma or q_sigma is inf, set both variance_p and variance_q to inf.
    • If p_sigma is not provided and power_sigma is inf, set both variance_p and variance_q to inf.
  • Change the MeasuredValue logic, to split voltage and power measurement from one single main_value. For power measurement, aggregate and deaggregate P/Q separately based on variance_p and variance_q.
  • For the current iterative linear solver, for a power measurement, the weighting factor is 1/(variance_p + variance_q). For asymmetric calculation, this is a diagonal matrix.

Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@mgovers mgovers force-pushed the feature/reactive-power-sigma branch from 26f9174 to 89a19a4 Compare October 19, 2023 12:51
mgovers and others added 10 commits October 19, 2023 15:01
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <martijn.govers@alliander.com>
@mgovers mgovers self-assigned this Oct 30, 2023
@mgovers mgovers added the feature New feature or request label Oct 30, 2023
mgovers and others added 6 commits October 30, 2023 12:27
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <martijn.govers@alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@mgovers mgovers changed the base branch from main to feature/refactor-test-power-sensor November 1, 2023 10:59
@mgovers
Copy link
Member Author

mgovers commented Nov 1, 2023

@TonyXiang8787 this is ready for review. Remaining sonar cloud code smells are not caused by this PR

Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@mgovers mgovers force-pushed the feature/reactive-power-sigma branch from 216c34a to 6ff436e Compare November 3, 2023 08:56
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@mgovers
Copy link
Member Author

mgovers commented Nov 3, 2023

remaining code smells either already on main or related to equivalent on main (see e.g. https://sonarcloud.io/project/issues?resolved=false&rules=cpp%3AS1709&id=PowerGridModel_power-grid-model&open=AYm75yP7TgVATTPnBGJv )

@mgovers
Copy link
Member Author

mgovers commented Nov 3, 2023

@TonyXiang8787 i think i resolved all comments and it's ready for review again

Copy link

sonarcloud bot commented Nov 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 9 Code Smells

98.7% 98.7% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants