diff --git a/CHANGELOG.md b/CHANGELOG.md index 18ce139fd5..bb5b1dff09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Create `CITATION.cff` [#1035](https://github.com/ie3-institute/simona/issues/1035) - Introduce ThermalDemandWrapper [#1049](https://github.com/ie3-institute/simona/issues/1049) - Added Marius Staudt to list of reviewers [#1057](https://github.com/ie3-institute/simona/issues/1057) +- Throw exception if the slack node is not directly conected to a transformer. [#525](https://github.com/ie3-institute/simona/issues/525) - Added support for topologies without transformers and slack grids with multiple nodes [#1099](https://github.com/ie3-institute/simona/issues/1099) ### Changed diff --git a/src/main/scala/edu/ie3/simona/io/grid/GridProvider.scala b/src/main/scala/edu/ie3/simona/io/grid/GridProvider.scala index 3dda241c4d..0b11d732ca 100644 --- a/src/main/scala/edu/ie3/simona/io/grid/GridProvider.scala +++ b/src/main/scala/edu/ie3/simona/io/grid/GridProvider.scala @@ -7,6 +7,7 @@ package edu.ie3.simona.io.grid import com.typesafe.scalalogging.LazyLogging +import edu.ie3.datamodel.exceptions.{InvalidGridException, SourceException} import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.source.csv.{ CsvJointGridContainerSource, @@ -51,6 +52,27 @@ object GridProvider extends LazyLogging { // checks the grid container and throws exception if there is an error ValidationUtils.check(jointGridContainer) + // check slack node location + val slackSubGrid = jointGridContainer.getSubGridTopologyGraph + .vertexSet() + .asScala + .filter(_.getRawGrid.getNodes.asScala.exists(_.isSlack)) + .maxByOption( + _.getPredominantVoltageLevel.getNominalVoltage.getValue + .doubleValue() + ) + .getOrElse( + throw new InvalidGridException( + "There is no slack node present in the grid." + ) + ) + + if (slackSubGrid.getRawGrid.getNodes.size() > 1) { + throw new SourceException( + "There are too many nodes in the slack grid. This is currently not support." + ) + } + jointGridContainer case None => throw new RuntimeException(