Skip to content

Commit

Permalink
Merge branch 'main' into criteria_parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Lisrte authored Sep 19, 2024
2 parents 8b0265a + cf20f8f commit d1faab5
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 239 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Javadocs](https://www.javadoc.io/badge/com.powsybl/powsybl-dynawo.svg?color=blue)](https://www.javadoc.io/doc/com.powsybl/powsybl-dynawo)
[![Slack](https://img.shields.io/badge/slack-powsybl-blueviolet.svg?logo=slack)](https://join.slack.com/t/powsybl/shared_invite/zt-rzvbuzjk-nxi0boim1RKPS5PjieI0rA)

[Dynawo](https://dynawo.github.io) is an hybrid C++/Modelica open source suite of simulation tools for power systems. This integration module allows to use [DynaFlow](https://dynawo.github.io/about/dynaflow) for [power flow simulations](https://www.powsybl.org/pages/documentation/simulation/powerflow) and [Dynawo](https://dynawo.github.io) for [time domain simulations](https://www.powsybl.org/pages/documentation/simulation/timedomain).
[Dynawo](https://dynawo.github.io) is an hybrid C++/Modelica open source suite of simulation tools for power systems. This integration module allows to use [DynaFlow](https://dynawo.github.io/about/dynaflow) for [power flow simulations](https://powsybl.readthedocs.io/projects/powsybl-core/en/stable/simulation/loadflow/index.html) and [Dynawo](https://dynawo.github.io) for [time domain simulations](https://powsybl.readthedocs.io/projects/powsybl-core/en/stable/simulation/dynamic/index.html).

## DynaFlow

Expand All @@ -19,7 +19,7 @@ LoadFlowParameters parameters = LoadFlowParameters.load();
LoadFlow.find("DynaFlow").run(network, parameters);
```

To learn more about the usage of DynaFlow, read the [dedicated page](https://www.powsybl.org/pages/documentation/simulation/powerflow/dynaflow.html) on our website.
To learn more about the usage of DynaFlow, read the [dedicated page](https://powsybl.readthedocs.io/projects/powsybl-dynawo/en/latest/load_flow/index.html) on our website.

## Dynawo

Expand Down Expand Up @@ -62,7 +62,7 @@ System.out.println("Timeline:");
result.getTimeLine().forEach(tl -> System.out.printf("[%.8f] %s (on %s)%n", tl.time(), tl.message(), tl.modelName()));
```

To learn more about the usage of Dynawo, read the [dedicated page](https://www.powsybl.org/pages/documentation/simulation/timedomain/dynawo) on our website.
To learn more about the usage of Dynawo, read the [dedicated page](https://powsybl.readthedocs.io/projects/powsybl-dynawo/en/latest/dynamic_simulation/index.html) on our website.

### Examples

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
import com.powsybl.dynawo.models.buses.StandardBus;
import com.powsybl.dynawo.models.generators.*;
import com.powsybl.dynawo.models.loads.*;
import com.powsybl.dynawo.models.hvdc.HvdcP;
import com.powsybl.dynawo.models.hvdc.HvdcPDangling;
import com.powsybl.dynawo.models.hvdc.HvdcVsc;
import com.powsybl.dynawo.models.hvdc.HvdcVscDangling;
import com.powsybl.dynawo.models.hvdc.BaseHvdc;
import com.powsybl.dynawo.models.hvdc.HvdcDangling;
import com.powsybl.dynawo.models.lines.StandardLine;
import com.powsybl.dynawo.models.svarcs.BaseStaticVarCompensator;
import com.powsybl.dynawo.models.transformers.TransformerFixedRatio;
Expand Down Expand Up @@ -118,10 +116,10 @@ void assertPureDynamicBlackBoxModel(BlackBoxModel bbm, String dynamicId, String
private static Stream<Arguments> provideEquipmentModelData() {
return Stream.of(
Arguments.of("/dynamicModels/bus.groovy", StandardBus.class, EurostagTutorialExample1Factory.create(), "NGEN", "BBM_NGEN", "SB", "Bus"),
Arguments.of("/dynamicModels/hvdcP.groovy", HvdcP.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPV"),
Arguments.of("/dynamicModels/hvdcVsc.groovy", HvdcVsc.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSC"),
Arguments.of("/dynamicModels/hvdcPDangling.groovy", HvdcPDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPVDanglingDiagramPQ"),
Arguments.of("/dynamicModels/hvdcVscDangling.groovy", HvdcVscDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSCDanglingUdc"),
Arguments.of("/dynamicModels/hvdcP.groovy", BaseHvdc.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPV"),
Arguments.of("/dynamicModels/hvdcVsc.groovy", BaseHvdc.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSC"),
Arguments.of("/dynamicModels/hvdcPDangling.groovy", HvdcDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcPVDanglingDiagramPQ"),
Arguments.of("/dynamicModels/hvdcVscDangling.groovy", HvdcDangling.class, HvdcTestNetwork.createVsc(), "L", "BBM_HVDC_L", "HVDC", "HvdcVSCDanglingUdc"),
Arguments.of("/dynamicModels/loadAB.groovy", BaseLoad.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LAB", "LoadAlphaBetaRestorative"),
Arguments.of("/dynamicModels/loadABControllable.groovy", BaseLoadControllable.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LAB", "LoadAlphaBeta"),
Arguments.of("/dynamicModels/loadTransformer.groovy", LoadOneTransformer.class, EurostagTutorialExample1Factory.create(), "LOAD", "LOAD", "LOT", "LoadOneTransformer"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@
import com.powsybl.dynawo.builders.BuilderReports;
import com.powsybl.iidm.network.*;

import java.util.function.Function;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public abstract class AbstractHvdcBuilder<R extends AbstractEquipmentModelBuilder<HvdcLine, R>> extends AbstractEquipmentModelBuilder<HvdcLine, R> {

protected TwoSides danglingSide;
private final Function<TwoSides, String> eventVarNameSupplier;

protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, IdentifiableType identifiableType, ReportNode reportNode) {
protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, IdentifiableType identifiableType,
ReportNode reportNode, Function<TwoSides, String> eventVarNameSupplier) {
super(network, modelConfig, identifiableType, reportNode);
this.eventVarNameSupplier = eventVarNameSupplier;
}

protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, String equipmentType, ReportNode reportNode) {
protected AbstractHvdcBuilder(Network network, ModelConfig modelConfig, String equipmentType, ReportNode reportNode,
Function<TwoSides, String> eventVarNameSupplier) {
super(network, modelConfig, equipmentType, reportNode);
this.eventVarNameSupplier = eventVarNameSupplier;
}

public R dangling(TwoSides danglingSide) {
Expand All @@ -45,4 +52,16 @@ protected void checkData() {
isInstantiable = false;
}
}

@Override
public BaseHvdc build() {
if (isInstantiable()) {
if (modelConfig.isDangling()) {
return new HvdcDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), eventVarNameSupplier, danglingSide);
} else {
return new BaseHvdc(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), eventVarNameSupplier);
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public abstract class AbstractHvdc extends AbstractEquipmentBlackBoxModel<HvdcLine> implements HvdcModel {
public class BaseHvdc extends AbstractEquipmentBlackBoxModel<HvdcLine> implements HvdcModel {

private static final List<VarMapping> VAR_MAPPING = Arrays.asList(
new VarMapping("hvdc_PInj1Pu", "p1"),
Expand All @@ -36,8 +37,11 @@ public abstract class AbstractHvdc extends AbstractEquipmentBlackBoxModel<HvdcLi

protected static final String TERMINAL_PREFIX = "hvdc_terminal";

protected AbstractHvdc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String lib) {
private final Function<TwoSides, String> eventVarNameSupplier;

protected BaseHvdc(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String lib, Function<TwoSides, String> eventVarNameSupplier) {
super(dynamicModelId, parameterSetId, hvdc, lib);
this.eventVarNameSupplier = eventVarNameSupplier;
}

@Override
Expand Down Expand Up @@ -67,4 +71,9 @@ protected final VarConnection getSimpleVarConnectionWithBus(EquipmentConnectionP
public List<HvdcConverterStation<?>> getConnectedStations() {
return List.of(equipment.getConverterStation1(), equipment.getConverterStation2());
}

@Override
public String getSwitchOffSignalEventVarName(TwoSides side) {
return eventVarNameSupplier.apply(side);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (c) 2023, 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.dynawo.models.hvdc;

import com.powsybl.commons.PowsyblException;
import com.powsybl.dynawo.models.VarConnection;
import com.powsybl.dynawo.models.buses.EquipmentConnectionPoint;
import com.powsybl.dynawo.models.macroconnections.MacroConnectionsAdder;
import com.powsybl.dynawo.models.utils.SideUtils;
import com.powsybl.iidm.network.HvdcConverterStation;
import com.powsybl.iidm.network.HvdcLine;
import com.powsybl.iidm.network.TwoSides;

import java.util.List;
import java.util.function.Function;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
*/
public class HvdcDangling extends BaseHvdc {

private final TwoSides danglingSide;

protected HvdcDangling(String dynamicModelId, HvdcLine hvdc, String parameterSetId, String hvdcLib,
Function<TwoSides, String> eventVarNameSupplier, TwoSides danglingSide) {
super(dynamicModelId, hvdc, parameterSetId, hvdcLib, eventVarNameSupplier);
this.danglingSide = danglingSide;
}

@Override
public void createMacroConnections(MacroConnectionsAdder adder) {
adder.createTerminalMacroConnections(this, equipment, this::getVarConnectionsWithDangling, danglingSide);
adder.createTerminalMacroConnections(this, equipment, this::getVarConnectionsWith, SideUtils.getOppositeSide(danglingSide));
}

@Override
public String getSwitchOffSignalEventVarName(TwoSides side) {
if (danglingSide == side) {
throw new PowsyblException(String.format("Equipment %s side %s is dangling and can't be disconnected with an event", getLib(), side.getNum()));
}
return super.getSwitchOffSignalEventVarName(side);
}

@Override
public List<HvdcConverterStation<?>> getConnectedStations() {
return List.of(danglingSide == TwoSides.ONE ? equipment.getConverterStation2() : equipment.getConverterStation1());
}

private List<VarConnection> getVarConnectionsWithDangling(EquipmentConnectionPoint connected, TwoSides side) {
return List.of(new VarConnection(TERMINAL_PREFIX + side.getNum(), connected.getTerminalVarName(side)));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@

import com.powsybl.commons.report.ReportNode;
import com.powsybl.dynawo.builders.*;
import com.powsybl.dynawo.models.utils.SideUtils;
import com.powsybl.iidm.network.HvdcLine;
import com.powsybl.iidm.network.IdentifiableType;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.TwoSides;

import java.util.Collection;
import java.util.function.Function;

/**
* @author Laurent Issertial {@literal <laurent.issertial at rte-france.com>}
Expand All @@ -22,6 +25,7 @@ public class HvdcPBuilder extends AbstractHvdcBuilder<HvdcPBuilder> {

public static final String CATEGORY = "HVDC_P";
private static final ModelConfigs MODEL_CONFIGS = ModelConfigsHandler.getInstance().getModelConfigs(CATEGORY);
private static final Function<TwoSides, String> EVENT_VAR_NAME_SUPPLIER = ts -> String.format("hvdc_switchOffSignal2%s", SideUtils.getSideSuffix(ts));

public static HvdcPBuilder of(Network network) {
return of(network, ReportNode.NO_OP);
Expand Down Expand Up @@ -49,19 +53,7 @@ public static Collection<ModelInfo> getSupportedModelInfos() {
}

protected HvdcPBuilder(Network network, ModelConfig modelConfig, ReportNode reportNode) {
super(network, modelConfig, IdentifiableType.HVDC_LINE, reportNode);
}

@Override
public HvdcP build() {
if (isInstantiable()) {
if (modelConfig.isDangling()) {
return new HvdcPDangling(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib(), danglingSide);
} else {
return new HvdcP(dynamicModelId, getEquipment(), parameterSetId, modelConfig.lib());
}
}
return null;
super(network, modelConfig, IdentifiableType.HVDC_LINE, reportNode, EVENT_VAR_NAME_SUPPLIER);
}

@Override
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit d1faab5

Please sign in to comment.