-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add FSV input * Rename curve to outputVariable * Parse Fsv CSV file * Add Fsv handling in integration test Signed-off-by: lisrte <[email protected]>
- Loading branch information
Showing
53 changed files
with
777 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 12 additions & 3 deletions
15
docs/dynamic_simulation/curves-dsl.md → ...ynamic_simulation/output-variables-dsl.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
dynawo-dsl/src/main/groovy/com/powsybl/dynawo/dsl/DynawoCurveGroovyExtension.groovy
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
dynawo-dsl/src/main/groovy/com/powsybl/dynawo/dsl/DynawoOutputVariableGroovyExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) 2020, 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/. | ||
*/ | ||
package com.powsybl.dynawo.dsl | ||
|
||
import com.google.auto.service.AutoService | ||
import com.powsybl.commons.report.ReportNode | ||
import com.powsybl.dynamicsimulation.OutputVariable | ||
import com.powsybl.dynamicsimulation.groovy.OutputVariableGroovyExtension | ||
import com.powsybl.dynawo.DynawoSimulationProvider | ||
import com.powsybl.dynawo.outputvariables.DynawoOutputVariablesBuilder | ||
|
||
import java.util.function.Consumer | ||
/** | ||
* An implementation of {@link OutputVariableGroovyExtension} that adds the <pre>curve</pre> and <pre>fsv</pre> keywords to the DSL | ||
* | ||
* @author Mathieu Bague {@literal <[email protected]>} | ||
*/ | ||
@AutoService(OutputVariableGroovyExtension.class) | ||
class DynawoOutputVariableGroovyExtension implements OutputVariableGroovyExtension { | ||
|
||
@Override | ||
String getName() { | ||
DynawoSimulationProvider.NAME | ||
} | ||
|
||
@Override | ||
void load(Binding binding, Consumer<OutputVariable> consumer, ReportNode reportNode) { | ||
Closure<Void> closure = { Closure<Void> closure, OutputVariable.OutputType type -> | ||
def cloned = closure.clone() | ||
DynawoOutputVariablesBuilder variablesBuilder = new DynawoOutputVariablesBuilder(reportNode).outputType(type) | ||
cloned.delegate = variablesBuilder | ||
cloned() | ||
variablesBuilder.add(consumer) | ||
} | ||
binding.curve = c -> closure(c, OutputVariable.OutputType.CURVE) | ||
binding.fsv = c -> closure(c, OutputVariable.OutputType.FINAL_STATE) | ||
} | ||
} |
83 changes: 0 additions & 83 deletions
83
dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/CurvesSupplierTest.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
dynawo-dsl/src/test/java/com/powsybl/dynawo/dsl/OutputVariablesSupplierTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2020, 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/. | ||
*/ | ||
package com.powsybl.dynawo.dsl; | ||
|
||
import com.google.common.jimfs.Configuration; | ||
import com.google.common.jimfs.Jimfs; | ||
import com.powsybl.dynamicsimulation.OutputVariable; | ||
import com.powsybl.dynamicsimulation.OutputVariablesSupplier; | ||
import com.powsybl.dynamicsimulation.groovy.GroovyExtension; | ||
import com.powsybl.dynamicsimulation.groovy.GroovyOutputVariablesSupplier; | ||
import com.powsybl.dynamicsimulation.groovy.OutputVariableGroovyExtension; | ||
import com.powsybl.dynawo.outputvariables.DynawoOutputVariable; | ||
import com.powsybl.dynawo.DynawoSimulationProvider; | ||
import com.powsybl.iidm.network.Generator; | ||
import com.powsybl.iidm.network.Load; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.FileSystem; | ||
import java.nio.file.Files; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* @author Marcos de Miguel {@literal <demiguelm at aia.es>} | ||
*/ | ||
class OutputVariablesSupplierTest extends AbstractModelSupplierTest { | ||
|
||
private FileSystem fileSystem; | ||
private Network network; | ||
|
||
@BeforeEach | ||
void setup() throws IOException { | ||
fileSystem = Jimfs.newFileSystem(Configuration.unix()); | ||
network = EurostagTutorialExample1Factory.create(); | ||
|
||
Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/outputVariables.groovy")), fileSystem.getPath("/outputVariables.groovy")); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() throws IOException { | ||
fileSystem.close(); | ||
} | ||
|
||
@Test | ||
void test() { | ||
List<OutputVariableGroovyExtension> extensions = validateGroovyExtension(); | ||
OutputVariablesSupplier supplier = new GroovyOutputVariablesSupplier(fileSystem.getPath("/outputVariables.groovy"), extensions); | ||
List<OutputVariable> outputVariables = supplier.get(network); | ||
assertEquals(11, outputVariables.size()); | ||
outputVariables.forEach(this::validateOutputVariable); | ||
} | ||
|
||
private List<OutputVariableGroovyExtension> validateGroovyExtension() { | ||
List<OutputVariableGroovyExtension> extensions = GroovyExtension.find(OutputVariableGroovyExtension.class, DynawoSimulationProvider.NAME); | ||
assertEquals(1, extensions.size()); | ||
assertInstanceOf(DynawoOutputVariableGroovyExtension.class, extensions.get(0)); | ||
return extensions; | ||
} | ||
|
||
private void validateOutputVariable(OutputVariable outputVariable) { | ||
assertEquals(DynawoOutputVariable.class, outputVariable.getClass()); | ||
if (outputVariable.getModelId().equals("NETWORK")) { | ||
assertEquals(OutputVariable.OutputType.CURVE, outputVariable.getOutputType()); | ||
assertTrue(Arrays.asList("NGEN_Upu_value", "NHV1_Upu_value", "NHV2_Upu_value", "NLOAD_Upu_value").contains(outputVariable.getVariableName())); | ||
} else if (network.getIdentifiable(outputVariable.getModelId()) instanceof Generator) { | ||
assertEquals(OutputVariable.OutputType.FINAL_STATE, outputVariable.getOutputType()); | ||
assertTrue(Arrays.asList("generator_omegaPu", "generator_PGen", "generator_UStatorPU", "voltageRegulator_UcEfdP", "voltageRegulator_EfdPu").contains(outputVariable.getVariableName())); | ||
} else if (network.getIdentifiable(outputVariable.getModelId()) instanceof Load) { | ||
assertEquals(OutputVariable.OutputType.CURVE, outputVariable.getOutputType()); | ||
assertTrue(Arrays.asList("load_PPu", "load_QPu").contains(outputVariable.getVariableName())); | ||
} | ||
} | ||
} |
Oops, something went wrong.