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

LoadScalable: Do not apply constant power factor if P0 is zero #2897

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public double scale(Network n, double asked, ScalingParameters parameters) {
LOGGER.info("Change active power setpoint of {} from {} to {} ",
l.getId(), oldP0, l.getP0());

if (parameters.isConstantPowerFactor()) {
if (parameters.isConstantPowerFactor() && oldP0 != 0) {
l.setQ0(l.getP0() * oldQ0 / oldP0);
LOGGER.info("Change reactive power setpoint of {} from {} to {} ",
l.getId(), oldQ0, l.getQ0());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ void testConstantPowerFactor() {
ls1.scale(network, 20, parameters);
assertEquals(60, load.getP0(), 1e-3);
assertEquals(7.5, load.getQ0(), 1e-3);

ls1.reset(network);
assertEquals(0.0, load.getP0(), 1e-3);
assertEquals(7.5, load.getQ0(), 1e-3);
ls1.scale(network, -20, parameters);
assertEquals(20.0, load.getP0(), 1e-3);
assertEquals(7.5, load.getQ0(), 1e-3);
}

@Test
Expand Down