diff --git a/CHANGELOG.md b/CHANGELOG.md index b0547a2c9..6a5250fcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added Staudt to list of reviewers [#1190](https://github.com/ie3-institute/PowerSystemDataModel/issues/1190) ### Fixed +- Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221) ### Changed - Storage minimum level parameter removed from cylindrical thermal storage [#1123](https://github.com/ie3-institute/PowerSystemDataModel/issues/1123) diff --git a/docs/readthedocs/io/ValidationUtils.md b/docs/readthedocs/io/ValidationUtils.md index 8dc2ce73d..7937ac204 100644 --- a/docs/readthedocs/io/ValidationUtils.md +++ b/docs/readthedocs/io/ValidationUtils.md @@ -11,7 +11,7 @@ The methods in ValidationUtils and subclasses can be used to check that objects The general validation checks: - if assigned values are valid, e.g. lines are not allowed to have negative lengths or the rated power factor of any unit must be between 0 and 1 - furthermore, several connections are checked, e.g. that lines only connect nodes of the same voltage level or that the voltage levels indicated for the transformer sides match the voltage levels of the nodes they are connected to. -- the connectivity of the given grid for all defined operation intervals +- the connectivity of the given grid for all defined operation intervals, if a switch is opened, it is filtered out for the connectivity check The uniqueness validation checks if a collection of given objects are unique in either: - a specific field diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java index 2b0245466..7d9e9b26b 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java @@ -16,9 +16,7 @@ import edu.ie3.datamodel.models.input.AssetInput; import edu.ie3.datamodel.models.input.MeasurementUnitInput; import edu.ie3.datamodel.models.input.NodeInput; -import edu.ie3.datamodel.models.input.connector.ConnectorInput; -import edu.ie3.datamodel.models.input.connector.LineInput; -import edu.ie3.datamodel.models.input.connector.Transformer3WInput; +import edu.ie3.datamodel.models.input.connector.*; import edu.ie3.datamodel.models.input.container.*; import edu.ie3.datamodel.models.input.graphics.GraphicInput; import edu.ie3.datamodel.models.input.system.SystemParticipantInput; @@ -241,6 +239,7 @@ protected static Try checkConnectivity( graph.addEdge(connector.getNodeA().getUuid(), connector.getNodeB().getUuid())); rawGridElements.getSwitches().stream() .filter(isInOperation) + .filter(SwitchInput::isClosed) .forEach( connector -> graph.addEdge(connector.getNodeA().getUuid(), connector.getNodeB().getUuid())); diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/GridContainerValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/GridContainerValidationUtilsTest.groovy index 013bad1a4..3bab7238b 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/GridContainerValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/GridContainerValidationUtilsTest.groovy @@ -103,4 +103,25 @@ class GridContainerValidationUtilsTest extends Specification { GTD.nodeG.uuid ]) } + + def "The GridContainerValidationUtils should return an exception if the grid is not properly connected, because a switch is open"() { + given: + def nodeA = GTD.nodeA.copy().operationTime(OperationTime.notLimited()).build() + def nodeB = GTD.nodeB.copy().operationTime(OperationTime.notLimited()).build() + + def switchAtoB = GTD.switchAtoB.copy() + .nodeA(nodeA) + .nodeB(nodeB) + .operationTime(OperationTime.notLimited()) + .closed(false) + .build() + + def rawGrid = new RawGridElements([nodeA, nodeB] as Set, [] as Set, [] as Set, [] as Set, [switchAtoB] as Set, [] as Set) + + when: + def actual = GridContainerValidationUtils.checkConnectivity(rawGrid, Optional.of(start) as Optional) + + then: + actual.exception.get().message == "The grid contains unconnected elements for time "+start+": [47d29df0-ba2d-4d23-8e75-c82229c5c758]" + } }