Skip to content

Commit

Permalink
Merge branch 'main' into psse_import_update_substation_data_without_c…
Browse files Browse the repository at this point in the history
…onversion
  • Loading branch information
marqueslanauja authored Dec 11, 2024
2 parents eb7fe5d + f0482f1 commit b2f4d71
Showing 270 changed files with 8,735 additions and 1,024 deletions.
2 changes: 1 addition & 1 deletion action-api/pom.xml
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
<parent>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-core</artifactId>
<version>6.6.0-SNAPSHOT</version>
<version>6.7.0-SNAPSHOT</version>
</parent>

<artifactId>powsybl-action-api</artifactId>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.action;

import com.powsybl.iidm.modification.AreaInterchangeTargetModification;
import com.powsybl.iidm.modification.NetworkModification;

import java.util.Objects;

/**
* An action to:
* <ul>
* <li>Change the interchange target of an area by specifying a new interchange target in MW.</li>
* </ul>
* @author Bertrand Rix {@literal <bertrand.rix at artelys.com>}
*/
public class AreaInterchangeTargetAction extends AbstractAction {

public static final String NAME = "AREA_INTERCHANGE_TARGET_ACTION";

private final String areaId;
private final double interchangeTarget;

public AreaInterchangeTargetAction(String id, String areaId, double interchangeTarget) {
super(id);
this.areaId = Objects.requireNonNull(areaId);
this.interchangeTarget = interchangeTarget;
}

public double getInterchangeTarget() {
return interchangeTarget;
}

public String getAreaId() {
return areaId;
}

@Override
public String getType() {
return NAME;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
AreaInterchangeTargetAction that = (AreaInterchangeTargetAction) o;
return Objects.equals(areaId, that.areaId) && (interchangeTarget == that.interchangeTarget || Double.isNaN(interchangeTarget) && Double.isNaN(that.interchangeTarget));
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), interchangeTarget, areaId);
}

@Override
public NetworkModification toModification() {
return new AreaInterchangeTargetModification(areaId, interchangeTarget);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.action;

/**
* @author Bertrand Rix {@literal <bertrand.rix at artelys.com>}
*/
public class AreaInterchangeTargetActionBuilder implements ActionBuilder<AreaInterchangeTargetActionBuilder> {

private String id;

private String areaId;

private double target = Double.NaN;

@Override
public String getType() {
return AreaInterchangeTargetAction.NAME;
}

@Override
public AreaInterchangeTargetActionBuilder withId(String id) {
this.id = id;
return this;
}

@Override
public String getId() {
return id;
}

@Override
public AreaInterchangeTargetActionBuilder withNetworkElementId(String elementId) {
this.areaId = elementId;
return this;
}

public AreaInterchangeTargetActionBuilder withTarget(double target) {
this.target = target;
return this;
}

public AreaInterchangeTargetActionBuilder withAreaId(String areaId) {
this.withNetworkElementId(areaId);
return this;
}

@Override
public AreaInterchangeTargetAction build() {
return new AreaInterchangeTargetAction(id, areaId, target);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.action;

import com.powsybl.iidm.modification.NetworkModification;
import com.powsybl.iidm.modification.PercentChangeLoadModification;

import java.util.Objects;

/**
* An action to:
* <ul>
* <li>change the P0 of a load, by specifying its percentage change (which could be positive or negative).</li>
* <li>describe the impact of this change on the Q0 of a load, by specifying the qModificationStrategy.</li>
* </ul>
* <p>
* This action is useful to specify changes that should be applied on a load when its actual active power is unknown.
* </p>
*
* @author Benoît Chiquet {@literal <benoit.chiquet@rte-france.com>}
*/
public class PercentChangeLoadAction extends AbstractAction {

public static final String NAME = "PCT_LOAD_CHANGE";
private String loadId;
private Double p0PercentChange;
private QModificationStrategy qModificationStrategy;

/**
* @param id the id of the action.
* @param loadId the id of the load on which the action would be applied.
* @param p0PercentChange the percentage that will be added to P0. Negative values describe load reduction.
* @param qModificationStrategy the way this change impacts Q0.
*/
PercentChangeLoadAction(String id, String loadId, Double p0PercentChange, QModificationStrategy qModificationStrategy) {
super(id);
this.loadId = loadId;
this.p0PercentChange = p0PercentChange;
this.qModificationStrategy = qModificationStrategy;
}

public enum QModificationStrategy {
CONSTANT_Q,
CONSTANT_PQ_RATIO
}

@Override
public String getType() {
return NAME;
}

public Double getP0PercentChange() {
return this.p0PercentChange;
}

public String getLoadId() {
return this.loadId;
}

public QModificationStrategy getQModificationStrategy() {
return this.qModificationStrategy;
}

@Override
public NetworkModification toModification() {
double q0PercentChange = switch (qModificationStrategy) {
case CONSTANT_Q -> 0d;
case CONSTANT_PQ_RATIO -> p0PercentChange;
};
return new PercentChangeLoadModification(loadId, p0PercentChange, q0PercentChange);
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
if (!super.equals(o)) {
return false;
}
PercentChangeLoadAction that = (PercentChangeLoadAction) o;
return Objects.equals(loadId, that.loadId) && Objects.equals(p0PercentChange, that.p0PercentChange) && qModificationStrategy == that.qModificationStrategy;
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), loadId, p0PercentChange, qModificationStrategy);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.action;

import com.powsybl.action.PercentChangeLoadAction.QModificationStrategy;

import java.util.Objects;

/**
* @author Benoît Chiquet {@literal <benoit.chiquet@rte-france.com>}
*/
public class PercentChangeLoadActionBuilder implements ActionBuilder<PercentChangeLoadActionBuilder> {
private String id;
private String loadId;
private double p0PercentChange;
private QModificationStrategy qModificationStrategy;

@Override
public String getType() {
return PercentChangeLoadAction.NAME;
}

@Override
public PercentChangeLoadActionBuilder withId(String id) {
this.id = id;
return this;
}

@Override
public String getId() {
return id;
}

@Override
public PercentChangeLoadActionBuilder withNetworkElementId(String elementId) {
this.loadId = elementId;
return this;
}

public PercentChangeLoadActionBuilder withLoadId(String loadId) {
return this.withNetworkElementId(loadId);
}

@Override
public Action build() {
if (p0PercentChange < -100) {
throw new IllegalArgumentException("The active power can't be reduced by more than 100%.");
}
return new PercentChangeLoadAction(Objects.requireNonNull(id), Objects.requireNonNull(loadId), p0PercentChange, Objects.requireNonNull(qModificationStrategy));
}

public PercentChangeLoadActionBuilder withP0PercentChange(double p0PercentChange) {
this.p0PercentChange = p0PercentChange;
return this;
}

public PercentChangeLoadActionBuilder withQModificationStrategy(QModificationStrategy strategy) {
this.qModificationStrategy = strategy;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ TerminalsConnectionAction.NAME, new TerminalsConnectionActionSerializer(),
registerActionBuilderType(RatioTapChangerRegulationAction.class, RatioTapChangerRegulationActionBuilder.class, RatioTapChangerRegulationAction.NAME,
new RatioTapChangerRegulationActionSerializer(), new RatioTapChangerRegulationActionBuilderBuilderDeserializer());
registerActionBuilderType(LoadAction.class, LoadActionBuilder.class, LoadAction.NAME, new LoadActionSerializer(), new LoadActionBuilderBuilderDeserializer());
registerActionBuilderType(PercentChangeLoadAction.class, PercentChangeLoadActionBuilder.class, PercentChangeLoadAction.NAME, new PercentChangeLoadActionSerializer(), new PercentChangeLoadActionBuilderDeserializer());
registerActionBuilderType(DanglingLineAction.class, DanglingLineActionBuilder.class, DanglingLineAction.NAME, new DanglingLineActionSerializer(), new DanglingLineActionBuilderBuilderDeserializer());
registerActionBuilderType(HvdcAction.class, HvdcActionBuilder.class, HvdcAction.NAME, new HvdcActionSerializer(), new HvdcActionBuilderDeserializer());
registerActionBuilderType(GeneratorAction.class, GeneratorActionBuilder.class, GeneratorAction.NAME,
@@ -63,5 +64,7 @@ TerminalsConnectionAction.NAME, new TerminalsConnectionActionSerializer(),
registerActionBuilderType(StaticVarCompensatorAction.class, StaticVarCompensatorActionBuilder.class,
StaticVarCompensatorAction.NAME, new StaticVarCompensatorActionSerializer(),
new StaticVarCompensatorActionBuilderDeserializer());
registerActionBuilderType(AreaInterchangeTargetAction.class, AreaInterchangeTargetActionBuilder.class, AreaInterchangeTargetAction.NAME,
new AreaInterchangeTargetActionSerializer(), new AreaInterchangeTargetActionDeserializer());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2024, Coreso SA (https://www.coreso.eu/) and TSCNET Services GmbH (https://www.tscnet.eu/)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.action.json;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.powsybl.action.AreaInterchangeTargetAction;
import com.powsybl.action.AreaInterchangeTargetActionBuilder;
import com.powsybl.commons.json.JsonUtil;

import java.io.IOException;

/**
* @author Bertrand Rix {@literal <bertrand.rix at artelys.com>}
*/
public class AreaInterchangeTargetActionDeserializer extends StdDeserializer<AreaInterchangeTargetActionBuilder> {

protected AreaInterchangeTargetActionDeserializer() {
super(AreaInterchangeTargetActionBuilder.class);
}

@Override
public AreaInterchangeTargetActionBuilder deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
AreaInterchangeTargetActionBuilder builder = new AreaInterchangeTargetActionBuilder();
JsonUtil.parsePolymorphicObject(jsonParser, name -> {
switch (name) {
case "type":
if (!AreaInterchangeTargetAction.NAME.equals(jsonParser.nextTextValue())) {
throw JsonMappingException.from(jsonParser, "Expected type " + AreaInterchangeTargetAction.NAME);
}
return true;
case "id":
builder.withId(jsonParser.nextTextValue());
return true;
case "areaId":
builder.withAreaId(jsonParser.nextTextValue());
return true;
case "interchangeTarget":
jsonParser.nextToken();
builder.withTarget(jsonParser.getValueAsDouble());
return true;
default:
return false;
}
});
return builder;
}
}
Loading

0 comments on commit b2f4d71

Please sign in to comment.