Skip to content

Commit

Permalink
Use core Action to apply the injection range action
Browse files Browse the repository at this point in the history
Signed-off-by: Pauline Jean-Marie <[email protected]>
  • Loading branch information
Pauline Jean-Marie committed Jun 7, 2024
1 parent 2ff578f commit 932a510
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package com.powsybl.openrao.data.cracimpl;

import com.powsybl.action.GeneratorActionBuilder;
import com.powsybl.action.LoadActionBuilder;
import com.powsybl.openrao.commons.OpenRaoException;
import com.powsybl.openrao.data.cracapi.NetworkElement;
import com.powsybl.openrao.data.cracapi.range.StandardRange;
Expand Down Expand Up @@ -76,14 +78,29 @@ public void apply(Network network, double targetSetpoint) {
private void applyInjection(Network network, String injectionId, double targetSetpoint) {
Generator generator = network.getGenerator(injectionId);
if (generator != null) {
generator.setTargetP(targetSetpoint);
new GeneratorActionBuilder()
.withId("id")
.withGeneratorId(injectionId)
.withActivePowerRelativeValue(false)
.withActivePowerValue(targetSetpoint)
.build()
.toModification()
.apply(network);
return;
}

Load load = network.getLoad(injectionId);
if (load != null) {
load.setP0(-targetSetpoint);
new LoadActionBuilder()
.withId("id")
.withLoadId(injectionId)
.withRelativeValue(false)
.withActivePowerValue(-targetSetpoint)
.build()
.toModification()
.apply(network);
return;

}

if (network.getIdentifiable(injectionId) == null) {
Expand Down

0 comments on commit 932a510

Please sign in to comment.