Skip to content

Commit

Permalink
Keep constant power factor only if P0 != 0
Browse files Browse the repository at this point in the history
Signed-off-by: vmouradian <valentin.mouradian@artelys.com>
  • Loading branch information
vmouradian committed Feb 9, 2024
1 parent d6c8cfe commit 02d785e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit 02d785e

Please sign in to comment.