diff --git a/CHANGELOG.md b/CHANGELOG.md index 55898c8d0..e3bea51e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changing from comparing strings to comparing uuids in `EntitySource.findFirstEntityByUuid` [#829](https://github.com/ie3-institute/PowerSystemDataModel/issues/829) - Adding JavaDoc to `EntitySource.safeMapGet` [#828](https://github.com/ie3-institute/PowerSystemDataModel/issues/828) - Abstracting some methods in `ValidationUtils` [#852](https://github.com/ie3-institute/PowerSystemDataModel/issues/852) +- `EmInput` should not be connected to the grid [#955](https://github.com/ie3-institute/PowerSystemDataModel/issues/955) ## [4.1.0] - 2023-11-02 diff --git a/docs/uml/main/input/ModelContainerConcept.puml b/docs/uml/main/input/ModelContainerConcept.puml index e96c699e8..2583a8fc9 100644 --- a/docs/uml/main/input/ModelContainerConcept.puml +++ b/docs/uml/main/input/ModelContainerConcept.puml @@ -42,7 +42,7 @@ package models.input.container { class SystemParticipants { - bmPlants: Set - chpPlants: Set - - evCS: Set + - evcs: Set - evs: Set - fixedFeedIns: Set - heatPumps: Set diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java index f19475f96..3e2e39d60 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java @@ -6,19 +6,17 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.exceptions.ParsingException; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; +import edu.ie3.datamodel.io.factory.input.AssetInputEntityData; +import edu.ie3.datamodel.io.factory.input.AssetInputEntityFactory; import edu.ie3.datamodel.models.ControlStrategy; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.EmInput; -import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class EmInputFactory - extends SystemParticipantInputEntityFactory { +public class EmInputFactory extends AssetInputEntityFactory { private static final Logger logger = LoggerFactory.getLogger(EmInputFactory.class); private static final String CONNECTED_ASSETS = "connectedassets"; @@ -36,11 +34,9 @@ protected String[] getAdditionalFields() { @Override protected EmInput buildModel( - NodeAssetInputEntityData data, + AssetInputEntityData data, UUID uuid, String id, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { ControlStrategy controlStrategy; @@ -58,14 +54,6 @@ protected EmInput buildModel( if (connectedAssets.length == 0) logger.warn("There are no connected assets for energy management system \"{}\".", id); - return new EmInput( - uuid, - id, - operator, - operationTime, - node, - qCharacteristics, - connectedAssets, - controlStrategy); + return new EmInput(uuid, id, operator, operationTime, connectedAssets, controlStrategy); } } diff --git a/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java b/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java index da67f99a0..530818677 100644 --- a/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java +++ b/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java @@ -170,7 +170,7 @@ public void persistJointGrid(JointGridContainer jointGridContainer) { SystemParticipants systemParticipants = jointGridContainer.getSystemParticipants(); Set bmPlants = systemParticipants.getBmPlants(); Set chpPlants = systemParticipants.getChpPlants(); - Set evCS = systemParticipants.getEvCS(); + Set evcs = systemParticipants.getEvcs(); Set evs = systemParticipants.getEvs(); Set fixedFeedIns = systemParticipants.getFixedFeedIns(); Set heatPumps = systemParticipants.getHeatPumps(); @@ -178,7 +178,6 @@ public void persistJointGrid(JointGridContainer jointGridContainer) { Set pvPlants = systemParticipants.getPvPlants(); Set storages = systemParticipants.getStorages(); Set wecPlants = systemParticipants.getWecPlants(); - Set emSystems = systemParticipants.getEmSystems(); // get graphic elements (just for better readability, we could also just get them directly // below) @@ -211,15 +210,14 @@ public void persistJointGrid(JointGridContainer jointGridContainer) { measurementUnits, bmPlants, chpPlants, - evCS, + evcs, evs, fixedFeedIns, heatPumps, loads, pvPlants, storages, - wecPlants, - emSystems) + wecPlants) .flatMap(Collection::stream) .map(Extractor::extractOperator) .flatMap(Optional::stream) diff --git a/src/main/java/edu/ie3/datamodel/io/source/EnergyManagementSource.java b/src/main/java/edu/ie3/datamodel/io/source/EnergyManagementSource.java new file mode 100644 index 000000000..51e120b1f --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/source/EnergyManagementSource.java @@ -0,0 +1,68 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.source; + +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.io.factory.input.participant.EmInputFactory; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.datamodel.models.input.container.EnergyManagementUnits; +import edu.ie3.datamodel.models.input.system.EmInput; +import edu.ie3.datamodel.utils.Try; +import java.util.Set; + +public class EnergyManagementSource extends EntitySource { + + private final TypeSource typeSource; + + private final EmInputFactory emInputFactory; + + public EnergyManagementSource(TypeSource typeSource, DataSource dataSource) { + this.typeSource = typeSource; + this.dataSource = dataSource; + + this.emInputFactory = new EmInputFactory(); + } + + /** + * Returns a unique set of {@link EmInput} instances. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as + * {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}. + * + * @return a set of object and uuid unique {@link EmInput} entities + */ + public EnergyManagementUnits getEmUnits() throws SourceException { + Set operators = typeSource.getOperators(); + return getEmUnits(operators); + } + + /** + * This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as + * {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}. + * + *

In contrast to {@link #getEmUnits()} this method provides the ability to pass in an already + * existing set of {@link OperatorInput} entities, the {@link EmInput} instances depend on. Doing + * so, already loaded nodes can be recycled to improve performance and prevent unnecessary loading + * operations. + * + *

If something fails during the creation process a {@link SourceException} is thrown, else a + * set with all entities that has been able to be build is returned. + * + * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for + * the returning instances + * @return a set of object and uuid unique {@link EmInput} entities + */ + public EnergyManagementUnits getEmUnits(Set operators) throws SourceException { + Set emUnits = + Try.scanCollection( + buildAssetInputEntities(EmInput.class, emInputFactory, operators), EmInput.class) + .transformF(SourceException::new) + .getOrThrow(); + return new EnergyManagementUnits(emUnits); + } +} diff --git a/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java b/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java index d00f4e37a..53b727bd8 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java @@ -50,7 +50,6 @@ public class SystemParticipantSource extends EntitySource { private final StorageInputFactory storageInputFactory; private final WecInputFactory wecInputFactory; private final EvcsInputFactory evcsInputFactory; - private final EmInputFactory emInputFactory; public SystemParticipantSource( TypeSource typeSource, @@ -74,7 +73,6 @@ public SystemParticipantSource( this.storageInputFactory = new StorageInputFactory(); this.wecInputFactory = new WecInputFactory(); this.evcsInputFactory = new EvcsInputFactory(); - this.emInputFactory = new EmInputFactory(); } /** @@ -136,8 +134,6 @@ public SystemParticipants getSystemParticipants() throws SourceException { SourceException.class); Try, SourceException> hpInputs = Try.of(() -> getHeatPumps(nodes, operators, hpTypes, thermalBuses), SourceException.class); - Try, SourceException> emInputs = - Try.of(() -> getEmSystems(nodes, operators), SourceException.class); List exceptions = Try.getExceptions( @@ -151,8 +147,7 @@ public SystemParticipants getSystemParticipants() throws SourceException { evs, evcs, chpInputs, - hpInputs, - emInputs)); + hpInputs)); if (!exceptions.isEmpty()) { throw new SystemParticipantsException( @@ -172,8 +167,7 @@ public SystemParticipants getSystemParticipants() throws SourceException { loads.getOrThrow(), pvInputs.getOrThrow(), storages.getOrThrow(), - wecInputs.getOrThrow(), - emInputs.getOrThrow()); + wecInputs.getOrThrow()); } } @@ -527,46 +521,6 @@ public Set getEvs( .getOrThrow(); } - /** - * Returns a unique set of {@link EmInput} instances. - * - *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link - * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as - * {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}. - * - * @return a set of object and uuid unique {@link EmInput} entities - */ - public Set getEmSystems() throws SourceException { - Set operators = typeSource.getOperators(); - return getEmSystems(rawGridSource.getNodes(operators), operators); - } - - /** - * This set has to be unique in the sense of object uniqueness but also in the sense of {@link - * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as - * {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}. - * - *

In contrast to {@link #getHeatPumps()} this method provides the ability to pass in an - * already existing set of {@link NodeInput} and {@link OperatorInput} entities, the {@link - * EmInput} instances depend on. Doing so, already loaded nodes can be recycled to improve - * performance and prevent unnecessary loading operations. - * - *

If something fails during the creation process a {@link SourceException} is thrown, else a - * set with all entities that has been able to be build is returned. - * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link EmInput} entities - */ - public Set getEmSystems(Set nodes, Set operators) - throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities(EmInput.class, emInputFactory, nodes, operators), EmInput.class) - .transformF(SourceException::new) - .getOrThrow(); - } - public Set getChpPlants() throws SourceException { Set operators = typeSource.getOperators(); Set thermalBuses = thermalSource.getThermalBuses(operators); diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java index 2fa9e0f2a..708d546e6 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java @@ -12,10 +12,7 @@ import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy; import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.source.*; -import edu.ie3.datamodel.models.input.container.GraphicElements; -import edu.ie3.datamodel.models.input.container.JointGridContainer; -import edu.ie3.datamodel.models.input.container.RawGridElements; -import edu.ie3.datamodel.models.input.container.SystemParticipants; +import edu.ie3.datamodel.models.input.container.*; import edu.ie3.datamodel.utils.Try; import java.nio.file.Path; import java.util.List; @@ -50,6 +47,7 @@ public static JointGridContainer read( ThermalSource thermalSource = new ThermalSource(typeSource, dataSource); SystemParticipantSource systemParticipantSource = new SystemParticipantSource(typeSource, thermalSource, rawGridSource, dataSource); + EnergyManagementSource emSource = new EnergyManagementSource(typeSource, dataSource); GraphicSource graphicSource = new GraphicSource(typeSource, rawGridSource, dataSource); /* Loading models */ @@ -57,6 +55,8 @@ public static JointGridContainer read( Try.of(rawGridSource::getGridData, SourceException.class); Try systemParticipants = Try.of(systemParticipantSource::getSystemParticipants, SourceException.class); + Try emUnits = + Try.of(emSource::getEmUnits, SourceException.class); Try graphicElements = Try.of(graphicSource::getGraphicElements, SourceException.class); @@ -73,6 +73,7 @@ public static JointGridContainer read( gridName, rawGridElements.getOrThrow(), systemParticipants.getOrThrow(), + emUnits.getOrThrow(), graphicElements.getOrThrow()); } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/container/EnergyManagementUnits.java b/src/main/java/edu/ie3/datamodel/models/input/container/EnergyManagementUnits.java new file mode 100644 index 000000000..4142a745d --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/input/container/EnergyManagementUnits.java @@ -0,0 +1,100 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.models.input.container; + +import edu.ie3.datamodel.models.input.system.EmInput; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** Represents the accumulation of energy management units */ +public class EnergyManagementUnits implements InputContainer { + + protected final Map emUnits; + + public EnergyManagementUnits(Set emUnits) { + this.emUnits = + emUnits.stream().collect(Collectors.toMap(EmInput::getUuid, Function.identity())); + } + + /** + * Combine different already existing containers + * + * @param emUnits already existing containers + */ + public EnergyManagementUnits(Collection emUnits) { + this.emUnits = + emUnits.stream() + .flatMap(units -> units.emUnits.entrySet().stream()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + public Set getEmUnits() { + return new HashSet<>(emUnits.values()); + } + + @Override + public List allEntitiesAsList() { + return emUnits.values().stream().toList(); + } + + // TODO useful once #957 is implemented + public Map getEmUnitsMap() { + return emUnits; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof EnergyManagementUnits that)) return false; + return Objects.equals(emUnits, that.emUnits); + } + + @Override + public int hashCode() { + return Objects.hash(emUnits); + } + + @Override + public EnergyManagementUnitsCopyBuilder copy() { + return new EnergyManagementUnitsCopyBuilder(this); + } + + /** + * A builder pattern based approach to create copies of {@link EnergyManagementUnits} containers + * with altered field values. For detailed field descriptions refer to java docs of {@link + * EnergyManagementUnits} + */ + public static class EnergyManagementUnitsCopyBuilder + implements InputContainerCopyBuilder { + protected Set emUnits; + + /** + * Constructor for {@link EnergyManagementUnits.EnergyManagementUnitsCopyBuilder} + * + * @param energyManagementUnits instance of {@link EnergyManagementUnits} + */ + protected EnergyManagementUnitsCopyBuilder(EnergyManagementUnits energyManagementUnits) { + this.emUnits = energyManagementUnits.getEmUnits(); + } + + /** + * Method to alter the {@link EmInput}s + * + * @param emUnits set of altered {@link EmInput}s + * @return this instance of {@link EnergyManagementUnits.EnergyManagementUnitsCopyBuilder} + */ + public EnergyManagementUnits.EnergyManagementUnitsCopyBuilder emUnits(Set emUnits) { + this.emUnits = emUnits; + return this; + } + + @Override + public EnergyManagementUnits build() { + return new EnergyManagementUnits(emUnits); + } + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/input/container/GridContainer.java b/src/main/java/edu/ie3/datamodel/models/input/container/GridContainer.java index 3c076cfff..12f5b7c9d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/container/GridContainer.java +++ b/src/main/java/edu/ie3/datamodel/models/input/container/GridContainer.java @@ -15,6 +15,8 @@ public abstract class GridContainer implements InputContainer { protected final RawGridElements rawGrid; /** Accumulated system participant elements */ protected final SystemParticipants systemParticipants; + /** Accumulated energy management units */ + protected final EnergyManagementUnits emUnits; /** Accumulated graphic data entities (node graphics, line graphics) */ protected final GraphicElements graphics; @@ -22,11 +24,13 @@ protected GridContainer( String gridName, RawGridElements rawGrid, SystemParticipants systemParticipants, + EnergyManagementUnits emUnits, GraphicElements graphics) { this.gridName = gridName; this.rawGrid = rawGrid; this.systemParticipants = systemParticipants; + this.emUnits = emUnits; this.graphics = graphics; } @@ -35,6 +39,7 @@ public List allEntitiesAsList() { List allEntities = new LinkedList<>(); allEntities.addAll(rawGrid.allEntitiesAsList()); allEntities.addAll(systemParticipants.allEntitiesAsList()); + allEntities.addAll(emUnits.allEntitiesAsList()); allEntities.addAll(graphics.allEntitiesAsList()); return Collections.unmodifiableList(allEntities); } @@ -55,6 +60,10 @@ public SystemParticipants getSystemParticipants() { return systemParticipants; } + public EnergyManagementUnits getEmUnits() { + return emUnits; + } + public GraphicElements getGraphics() { return graphics; } @@ -66,12 +75,13 @@ public boolean equals(Object o) { return gridName.equals(that.gridName) && rawGrid.equals(that.rawGrid) && systemParticipants.equals(that.systemParticipants) + && emUnits.equals(that.emUnits) && graphics.equals(that.graphics); } @Override public int hashCode() { - return Objects.hash(gridName, rawGrid, systemParticipants, graphics); + return Objects.hash(gridName, rawGrid, systemParticipants, emUnits, graphics); } @Override @@ -91,6 +101,7 @@ protected abstract static class GridContainerCopyBuilder { private final Set bmPlants; private final Set chpPlants; - private final Set evCS; + private final Set evcs; private final Set evs; private final Set fixedFeedIns; private final Set heatPumps; @@ -24,23 +24,21 @@ public class SystemParticipants implements InputContainer pvPlants; private final Set storages; private final Set wecPlants; - private final Set emSystems; public SystemParticipants( Set bmPlants, Set chpPlants, - Set evCS, + Set evcs, Set evs, Set fixedFeedIns, Set heatPumps, Set loads, Set pvPlants, Set storages, - Set wecPlants, - Set emSystems) { + Set wecPlants) { this.bmPlants = bmPlants; this.chpPlants = chpPlants; - this.evCS = evCS; + this.evcs = evcs; this.evs = evs; this.fixedFeedIns = fixedFeedIns; this.heatPumps = heatPumps; @@ -48,7 +46,6 @@ public SystemParticipants( this.pvPlants = pvPlants; this.storages = storages; this.wecPlants = wecPlants; - this.emSystems = emSystems; } /** @@ -65,9 +62,9 @@ public SystemParticipants(Collection systemParticipants) { systemParticipants.stream() .flatMap(participants -> participants.chpPlants.stream()) .collect(Collectors.toSet()); - this.evCS = + this.evcs = systemParticipants.stream() - .flatMap(participants -> participants.evCS.stream()) + .flatMap(participants -> participants.evcs.stream()) .collect(Collectors.toSet()); this.evs = systemParticipants.stream() @@ -97,10 +94,6 @@ public SystemParticipants(Collection systemParticipants) { systemParticipants.stream() .flatMap(participants -> participants.wecPlants.stream()) .collect(Collectors.toSet()); - this.emSystems = - systemParticipants.stream() - .flatMap(participants -> participants.emSystems.stream()) - .collect(Collectors.toSet()); } /** @@ -122,7 +115,7 @@ public SystemParticipants(List systemParticipants) { .filter(ChpInput.class::isInstance) .map(ChpInput.class::cast) .collect(Collectors.toSet()); - this.evCS = + this.evcs = systemParticipants.parallelStream() .filter(EvcsInput.class::isInstance) .map(EvcsInput.class::cast) @@ -162,11 +155,6 @@ public SystemParticipants(List systemParticipants) { .filter(WecInput.class::isInstance) .map(WecInput.class::cast) .collect(Collectors.toSet()); - this.emSystems = - systemParticipants.parallelStream() - .filter(EmInput.class::isInstance) - .map(EmInput.class::cast) - .collect(Collectors.toSet()); } @Override @@ -174,7 +162,7 @@ public final List allEntitiesAsList() { List allEntities = new ArrayList<>(); allEntities.addAll(bmPlants); allEntities.addAll(chpPlants); - allEntities.addAll(evCS); + allEntities.addAll(evcs); allEntities.addAll(evs); allEntities.addAll(fixedFeedIns); allEntities.addAll(heatPumps); @@ -182,7 +170,6 @@ public final List allEntitiesAsList() { allEntities.addAll(pvPlants); allEntities.addAll(storages); allEntities.addAll(wecPlants); - allEntities.addAll(emSystems); return Collections.unmodifiableList(allEntities); } @@ -201,8 +188,8 @@ public Set getChpPlants() { } /** @return unmodifiable Set of all ev charging stations in this grid */ - public Set getEvCS() { - return Collections.unmodifiableSet(evCS); + public Set getEvcs() { + return Collections.unmodifiableSet(evcs); } /** @return unmodifiable Set of all electric vehicles in this grid */ @@ -240,17 +227,13 @@ public Set getWecPlants() { return Collections.unmodifiableSet(wecPlants); } - public Set getEmSystems() { - return Collections.unmodifiableSet(emSystems); - } - @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof SystemParticipants that)) return false; return Objects.equals(bmPlants, that.bmPlants) && Objects.equals(chpPlants, that.chpPlants) - && Objects.equals(evCS, that.evCS) + && Objects.equals(evcs, that.evcs) && Objects.equals(evs, that.evs) && Objects.equals(fixedFeedIns, that.fixedFeedIns) && Objects.equals(heatPumps, that.heatPumps) @@ -265,7 +248,7 @@ public int hashCode() { return Objects.hash( bmPlants, chpPlants, - evCS, + evcs, evs, fixedFeedIns, heatPumps, @@ -287,7 +270,7 @@ public static class SystemParticipantsCopyBuilder implements InputContainerCopyBuilder { private Set bmPlants; private Set chpPlants; - private Set evCS; + private Set evcs; private Set evs; private Set fixedFeedIns; private Set heatPumps; @@ -295,7 +278,6 @@ public static class SystemParticipantsCopyBuilder private Set pvPlants; private Set storages; private Set wecPlants; - private Set emSystems; /** * Constructor for {@link SystemParticipantsCopyBuilder} @@ -305,7 +287,7 @@ public static class SystemParticipantsCopyBuilder protected SystemParticipantsCopyBuilder(SystemParticipants systemParticipants) { this.bmPlants = systemParticipants.bmPlants; this.chpPlants = systemParticipants.chpPlants; - this.evCS = systemParticipants.evCS; + this.evcs = systemParticipants.evcs; this.evs = systemParticipants.evs; this.fixedFeedIns = systemParticipants.fixedFeedIns; this.heatPumps = systemParticipants.heatPumps; @@ -313,7 +295,6 @@ protected SystemParticipantsCopyBuilder(SystemParticipants systemParticipants) { this.pvPlants = systemParticipants.pvPlants; this.storages = systemParticipants.storages; this.wecPlants = systemParticipants.wecPlants; - this.emSystems = systemParticipants.emSystems; } /** @@ -341,11 +322,11 @@ public SystemParticipantsCopyBuilder chpPlants(Set chpPlants) { /** * Method to alter {@link EvcsInput} * - * @param evCS set of altered biomass electric vehicle charging stations + * @param evcs set of altered biomass electric vehicle charging stations * @return this instance of {@link SystemParticipantsCopyBuilder} */ - public SystemParticipantsCopyBuilder evCS(Set evCS) { - this.evCS = evCS; + public SystemParticipantsCopyBuilder evcs(Set evcs) { + this.evcs = evcs; return this; } @@ -426,31 +407,19 @@ public SystemParticipantsCopyBuilder wecPlants(Set wecPlants) { return this; } - /** - * Method to alter {@link EmInput} - * - * @param emSystems set of altered energy management systems - * @return this instance of {@link SystemParticipantsCopyBuilder} - */ - public SystemParticipantsCopyBuilder emSystems(Set emSystems) { - this.emSystems = emSystems; - return this; - } - @Override public SystemParticipants build() { return new SystemParticipants( bmPlants, chpPlants, - evCS, + evcs, evs, fixedFeedIns, heatPumps, loads, pvPlants, storages, - wecPlants, - emSystems); + wecPlants); } } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java index eeac609aa..f9bbbaa9f 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java @@ -8,14 +8,13 @@ import edu.ie3.datamodel.models.ControlStrategy; import edu.ie3.datamodel.models.EmControlStrategy; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.input.NodeInput; +import edu.ie3.datamodel.models.input.AssetInput; import edu.ie3.datamodel.models.input.OperatorInput; -import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; import java.util.Arrays; import java.util.Objects; import java.util.UUID; -public class EmInput extends SystemParticipantInput { +public class EmInput extends AssetInput { /** Reference via UUID to all SystemParticipantInputs connected to this model */ private final UUID[] connectedAssets; @@ -29,8 +28,6 @@ public class EmInput extends SystemParticipantInput { * @param id of the asset * @param operator of the asset * @param operationTime time for which the entity is operated - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic * @param connectedAssets array of all connected assets * @param controlStrategy control strategy used for this model */ @@ -39,11 +36,9 @@ public EmInput( String id, OperatorInput operator, OperationTime operationTime, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, UUID[] connectedAssets, ControlStrategy controlStrategy) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime); this.connectedAssets = connectedAssets; this.controlStrategy = controlStrategy; } @@ -55,8 +50,6 @@ public EmInput( * @param id of the asset * @param operator of the asset * @param operationTime time for which the entity is operated - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic * @param connectedAssets array of all connected assets * @param emControlStrategy {@link edu.ie3.datamodel.models.EmControlStrategy} control strategy * key @@ -66,11 +59,9 @@ public EmInput( String id, OperatorInput operator, OperationTime operationTime, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, UUID[] connectedAssets, String emControlStrategy) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime); this.connectedAssets = connectedAssets; this.controlStrategy = EmControlStrategy.get(emControlStrategy); } @@ -80,19 +71,11 @@ public EmInput( * * @param uuid of the input entity * @param id of the asset - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic * @param connectedAssets array of all connected assets * @param controlStrategy control strategy used for this model */ - public EmInput( - UUID uuid, - String id, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, - UUID[] connectedAssets, - ControlStrategy controlStrategy) { - super(uuid, id, node, qCharacteristics); + public EmInput(UUID uuid, String id, UUID[] connectedAssets, ControlStrategy controlStrategy) { + super(uuid, id); this.connectedAssets = connectedAssets; this.controlStrategy = controlStrategy; } @@ -102,20 +85,12 @@ public EmInput( * * @param uuid of the input entity * @param id of the asset - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic * @param connectedAssets array of all connected assets * @param emControlStrategy {@link edu.ie3.datamodel.models.EmControlStrategy} control strategy * key */ - public EmInput( - UUID uuid, - String id, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, - UUID[] connectedAssets, - String emControlStrategy) { - super(uuid, id, node, qCharacteristics); + public EmInput(UUID uuid, String id, UUID[] connectedAssets, String emControlStrategy) { + super(uuid, id); this.connectedAssets = connectedAssets; this.controlStrategy = EmControlStrategy.get(emControlStrategy); } @@ -158,10 +133,6 @@ public String toString() { + getOperator().getUuid() + ", operationTime=" + getOperationTime() - + ", node=" - + getNode().getUuid() - + ", qCharacteristics='" - + getqCharacteristics() + ", connectedAssets=" + Arrays.toString(connectedAssets) + ", controlStrategy=" @@ -169,8 +140,7 @@ public String toString() { + '}'; } - public static class EmInputCopyBuilder - extends SystemParticipantInputCopyBuilder { + public static class EmInputCopyBuilder extends AssetInputCopyBuilder { private UUID[] connectedAssets; @@ -195,14 +165,7 @@ public EmInputCopyBuilder controlStrategy(ControlStrategy controlStrategy) { @Override public EmInput build() { return new EmInput( - getUuid(), - getId(), - getOperator(), - getOperationTime(), - getNode(), - getqCharacteristics(), - connectedAssets, - controlStrategy); + getUuid(), getId(), getOperator(), getOperationTime(), connectedAssets, controlStrategy); } @Override diff --git a/src/main/java/edu/ie3/datamodel/utils/ContainerNodeUpdateUtil.java b/src/main/java/edu/ie3/datamodel/utils/ContainerNodeUpdateUtil.java index 4778fabea..a482ce658 100644 --- a/src/main/java/edu/ie3/datamodel/utils/ContainerNodeUpdateUtil.java +++ b/src/main/java/edu/ie3/datamodel/utils/ContainerNodeUpdateUtil.java @@ -77,6 +77,7 @@ public static JointGridContainer updateGridWithNodes( grid.getGridName(), updatedEntities.rawGridElements(), updatedEntities.systemParticipants(), + grid.getEmUnits(), updatedEntities.graphicElements()); } @@ -112,6 +113,7 @@ public static SubGridContainer updateGridWithNodes( grid.getSubnet(), updatedEntities.rawGridElements(), updatedEntities.systemParticipants(), + grid.getEmUnits(), updatedEntities.graphicElements()); } diff --git a/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java b/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java index bf1eb0615..d0484a499 100644 --- a/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/ContainerUtils.java @@ -291,7 +291,7 @@ private static ComparableQuantity calcImpedance( /** * Filters all raw grid elements for the provided subnet. For each transformer all nodes (and not - * only the the node of the grid the transformer is located in) are added as well. Two winding + * only the node of the grid the transformer is located in) are added as well. Two winding * transformers are counted, if the low voltage node is in the queried subnet. Three winding * transformers are counted, as long as any of the three nodes is in the queried subnet. * @@ -358,7 +358,7 @@ public static RawGridElements filterForSubnet(RawGridElements input, int subnet) public static SystemParticipants filterForSubnet(SystemParticipants input, int subnet) { Set bmPlants = filterParticipants(input.getBmPlants(), subnet); Set chpPlants = filterParticipants(input.getChpPlants(), subnet); - Set evcsInputs = filterParticipants(input.getEvCS(), subnet); + Set evcsInputs = filterParticipants(input.getEvcs(), subnet); Set evs = filterParticipants(input.getEvs(), subnet); Set fixedFeedIns = filterParticipants(input.getFixedFeedIns(), subnet); Set heatpumps = filterParticipants(input.getHeatPumps(), subnet); @@ -366,7 +366,6 @@ public static SystemParticipants filterForSubnet(SystemParticipants input, int s Set pvs = filterParticipants(input.getPvPlants(), subnet); Set storages = filterParticipants(input.getStorages(), subnet); Set wecPlants = filterParticipants(input.getWecPlants(), subnet); - Set emSystems = filterParticipants(input.getEmSystems(), subnet); return new SystemParticipants( bmPlants, @@ -378,8 +377,7 @@ public static SystemParticipants filterForSubnet(SystemParticipants input, int s loads, pvs, storages, - wecPlants, - emSystems); + wecPlants); } /** @@ -503,6 +501,7 @@ public static SubGridTopologyGraph buildSubGridTopologyGraph( String gridName, RawGridElements rawGrid, SystemParticipants systemParticipants, + EnergyManagementUnits energyManagementUnits, GraphicElements graphics) throws InvalidGridException { /* Collect the different sub nets. Through the validation of lines, it is ensured, that no galvanically connected @@ -511,7 +510,8 @@ public static SubGridTopologyGraph buildSubGridTopologyGraph( /* Build the single sub grid models */ HashMap subgrids = - buildSubGridContainers(gridName, subnetNumbers, rawGrid, systemParticipants, graphics); + buildSubGridContainers( + gridName, subnetNumbers, rawGrid, systemParticipants, energyManagementUnits, graphics); /* Build the graph structure denoting the topology of the grid */ return buildSubGridTopologyGraph(subgrids, rawGrid); @@ -542,6 +542,7 @@ private static HashMap buildSubGridContainers( SortedSet subnetNumbers, RawGridElements rawGrid, SystemParticipants systemParticipants, + EnergyManagementUnits energyManagementUnits, GraphicElements graphics) throws InvalidGridException { HashMap subGrids = new HashMap<>(subnetNumbers.size()); @@ -554,7 +555,12 @@ private static HashMap buildSubGridContainers( subGrids.put( subnetNumber, new SubGridContainer( - gridName, subnetNumber, rawGridElements, systemParticipantElements, graphicElements)); + gridName, + subnetNumber, + rawGridElements, + systemParticipantElements, + energyManagementUnits, // TODO filtering (part of #957) + graphicElements)); } return subGrids; } @@ -806,6 +812,9 @@ public static JointGridContainer combineToJointGrid( GraphicElements graphicElements = new GraphicElements( subGridContainers.stream().map(GridContainer::getGraphics).collect(Collectors.toSet())); + EnergyManagementUnits energyManagementUnits = + new EnergyManagementUnits( + subGridContainers.stream().map(GridContainer::getEmUnits).collect(Collectors.toSet())); Map subGridMapping = subGridContainers.stream() @@ -814,7 +823,12 @@ public static JointGridContainer combineToJointGrid( SubGridTopologyGraph subGridTopologyGraph = buildSubGridTopologyGraph(subGridMapping, rawGrid); return new JointGridContainer( - gridName, rawGrid, systemParticipants, graphicElements, subGridTopologyGraph); + gridName, + rawGrid, + systemParticipants, + energyManagementUnits, + graphicElements, + subGridTopologyGraph); } /** @@ -987,6 +1001,7 @@ public static SubGridContainer withTrafoNodeAsSlack(final SubGridContainer subGr subGridContainer.getRawGrid().getSwitches(), subGridContainer.getRawGrid().getMeasurementUnits()), subGridContainer.getSystemParticipants(), + subGridContainer.getEmUnits(), new GraphicElements(newNodeGraphics, subGridContainer.getGraphics().getLineGraphics())); } } 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 77388c6d4..086cc5387 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java @@ -198,7 +198,7 @@ protected static List> checkRawGridTypeIds exceptions.addAll(checkSystemParticipants(systemParticipants.getBmPlants(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getChpPlants(), nodes)); - exceptions.addAll(checkSystemParticipants(systemParticipants.getEvCS(), nodes)); + exceptions.addAll(checkSystemParticipants(systemParticipants.getEvcs(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getFixedFeedIns(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getHeatPumps(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getLoads(), nodes)); @@ -247,7 +247,7 @@ protected static List> checkSystemParticip List> exceptions = new ArrayList<>(); exceptions.addAll(checkForDuplicates(systemParticipants.getBmPlants(), AssetInput::getId)); exceptions.addAll(checkForDuplicates(systemParticipants.getChpPlants(), AssetInput::getId)); - exceptions.addAll(checkForDuplicates(systemParticipants.getEvCS(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getEvcs(), AssetInput::getId)); exceptions.addAll(checkForDuplicates(systemParticipants.getEvs(), AssetInput::getId)); exceptions.addAll(checkForDuplicates(systemParticipants.getFixedFeedIns(), AssetInput::getId)); exceptions.addAll(checkForDuplicates(systemParticipants.getHeatPumps(), AssetInput::getId)); @@ -255,7 +255,6 @@ protected static List> checkSystemParticip exceptions.addAll(checkForDuplicates(systemParticipants.getPvPlants(), AssetInput::getId)); exceptions.addAll(checkForDuplicates(systemParticipants.getStorages(), AssetInput::getId)); exceptions.addAll(checkForDuplicates(systemParticipants.getWecPlants(), AssetInput::getId)); - exceptions.addAll(checkForDuplicates(systemParticipants.getEmSystems(), AssetInput::getId)); return exceptions; } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy index d3ad3d869..707a71ccd 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy @@ -6,17 +6,13 @@ package edu.ie3.datamodel.io.factory.input.participant import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData +import edu.ie3.datamodel.io.factory.input.AssetInputEntityData import edu.ie3.datamodel.models.ControlStrategy import edu.ie3.datamodel.models.EmControlStrategy -import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.EmInput -import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicPoint import edu.ie3.datamodel.utils.Try -import edu.ie3.util.quantities.PowerSystemUnits import spock.lang.Specification -import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime import javax.measure.quantity.Dimensionless @@ -40,17 +36,15 @@ class EmInputFactoryTest extends Specification { "operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]", "operatesuntil" : "2019-12-31T23:59:00+01:00[Europe/Berlin]", "id" : "TestID", - "qcharacteristics": "cosPhiFixed:{(0.0,1.0)}", "connectedassets" : "4e840ea0-fb72-422e-942f-4111312e9914 a17aa6f0-e663-4186-ac34-a7b68573938b", "controlstrategy" : "self_optimization" ] def inputClass = EmInput - def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new AssetInputEntityData(parameter, inputClass, operatorInput)) then: input.success @@ -63,12 +57,6 @@ class EmInputFactoryTest extends Specification { assert operationTime.endDate.get() == ZonedDateTime.parse(parameter["operatesuntil"]) assert operator == operatorInput assert id == parameter["id"] - assert node == nodeInput - assert qCharacteristics.with { - assert points == Collections.unmodifiableSortedSet([ - new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) - ] as TreeSet) - } assert connectedAssets == [ UUID.fromString("4e840ea0-fb72-422e-942f-4111312e9914"), UUID.fromString("a17aa6f0-e663-4186-ac34-a7b68573938b") @@ -85,17 +73,15 @@ class EmInputFactoryTest extends Specification { "operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]", "operatesuntil" : "2019-12-31T23:59:00+01:00[Europe/Berlin]", "id" : "TestID", - "qcharacteristics": "cosPhiFixed:{(0.0,1.0)}", "connectedassets" : "", "controlstrategy" : "self_optimization" ] def inputClass = EmInput - def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new AssetInputEntityData(parameter, inputClass, operatorInput)) then: input.success @@ -108,12 +94,6 @@ class EmInputFactoryTest extends Specification { assert operationTime.endDate.get() == ZonedDateTime.parse(parameter["operatesuntil"]) assert operator == operatorInput assert id == parameter["id"] - assert node == nodeInput - assert qCharacteristics.with { - assert points == Collections.unmodifiableSortedSet([ - new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) - ] as TreeSet) - } assert connectedAssets == [] as UUID[] assert controlStrategy == EmControlStrategy.SELF_OPTIMIZATION } @@ -125,17 +105,15 @@ class EmInputFactoryTest extends Specification { Map parameter = [ "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", "id" : "TestID", - "qcharacteristics": "cosPhiFixed:{(0.0,1.0)}", "connectedassets" : "4e840ea0-fb72-422e-942f-4111312e9914", "controlstrategy" : " -- invalid --" ] def inputClass = EmInput - def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new AssetInputEntityData(parameter, inputClass, operatorInput)) then: input.success @@ -146,12 +124,6 @@ class EmInputFactoryTest extends Specification { assert operationTime.endDate.empty assert operator == operatorInput assert id == parameter["id"] - assert node == nodeInput - assert qCharacteristics.with { - assert points == Collections.unmodifiableSortedSet([ - new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) - ] as TreeSet) - } assert connectedAssets == [ UUID.fromString("4e840ea0-fb72-422e-942f-4111312e9914") ] as UUID[] diff --git a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy index db803696e..6c98e7b53 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy @@ -45,6 +45,7 @@ import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue import edu.ie3.datamodel.models.value.EnergyPriceValue import edu.ie3.datamodel.models.value.Value +import edu.ie3.test.common.EnergyManagementTestData import edu.ie3.test.common.GridTestData import edu.ie3.test.common.SampleJointGrid import edu.ie3.test.common.SystemParticipantTestData @@ -170,7 +171,7 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { ThermalUnitInputTestData.thermalHouseInput, SystemParticipantTestData.evcsInput, SystemParticipantTestData.loadInput, - SystemParticipantTestData.emInput + EnergyManagementTestData.emInput ]) csvFileSink.shutdown() diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvEnergyManagementSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvEnergyManagementSourceTest.groovy new file mode 100644 index 000000000..8e595a467 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvEnergyManagementSourceTest.groovy @@ -0,0 +1,36 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.source.csv + +import edu.ie3.datamodel.exceptions.SourceException +import edu.ie3.datamodel.io.source.EnergyManagementSource +import edu.ie3.datamodel.io.source.TypeSource +import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.common.EnergyManagementTestData +import spock.lang.Specification + +class CsvEnergyManagementSourceTest extends Specification implements CsvTestDataMeta { + + def "An EnergyManagementSource with csv input should return data from valid em input file as expected"() { + given: + def csvEnergyManagementSource = new EnergyManagementSource( + Mock(TypeSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def emUnits = Try.of(() -> csvEnergyManagementSource.getEmUnits(operators.toSet()), SourceException) + + emUnits.success + emUnits.data.get().emUnits.size() == 1 + emUnits.data.get().emUnits == resultingSet as Set + + where: + operators || resultingSet + [EnergyManagementTestData.emInput.operator] || [EnergyManagementTestData.emInput] + [] || [EnergyManagementTestData.emInput.copy().operator(OperatorInput.NO_OPERATOR_ASSIGNED).build()] + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy index 43b2764a2..4881b9212 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy @@ -35,7 +35,7 @@ import spock.lang.Specification class CsvSystemParticipantSourceTest extends Specification implements CsvTestDataMeta { - def "A CsvSystemParticipantSource should provide an instance of SystemParticipants based on valid input data correctly"() { + def "A SystemParticipantSource with csv input should provide an instance of SystemParticipants based on valid input data correctly"() { given: def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy)) def thermalSource = new ThermalSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) @@ -50,7 +50,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat def systemParticipants = csvSystemParticipantSource.systemParticipants then: - systemParticipants.allEntitiesAsList().size() == 11 + systemParticipants.allEntitiesAsList().size() == 10 systemParticipants.pvPlants.first().uuid == sptd.pvInput.uuid systemParticipants.bmPlants.first().uuid == sptd.bmInput.uuid systemParticipants.chpPlants.first().uuid == sptd.chpInput.uuid @@ -60,11 +60,10 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat systemParticipants.loads.first().uuid == sptd.loadInput.uuid systemParticipants.wecPlants.first().uuid == sptd.wecInput.uuid systemParticipants.storages.first().uuid == sptd.storageInput.uuid - systemParticipants.evCS.first().uuid == sptd.evcsInput.uuid - systemParticipants.emSystems.first().uuid == sptd.emInput.uuid + systemParticipants.evcs.first().uuid == sptd.evcsInput.uuid } - def "A CsvSystemParticipantSource should process invalid input data as expected when requested to provide an instance of SystemParticipants"() { + def "A SystemParticipantSource with csv input should process invalid input data as expected when requested to provide an instance of SystemParticipants"() { given: def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy)) def thermalSource = new ThermalSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) @@ -92,13 +91,13 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Exception ex = systemParticipants.exception.get() ex.class == SystemParticipantsException - ex.message.startsWith("11 error(s) occurred while initializing system participants. " + + ex.message.startsWith("10 error(s) occurred while initializing system participants. " + "edu.ie3.datamodel.exceptions.FailureException: 1 exception(s) occurred within \"FixedFeedInInput\" data, one is: " + "edu.ie3.datamodel.exceptions.FactoryException: edu.ie3.datamodel.exceptions.SourceException: " + "Failure due to: Skipping FixedFeedInInput with uuid ") } - def "A CsvSystemParticipantSource should build typed entity from valid and invalid input data as expected"() { + def "A SystemParticipantSource with csv input should build typed entity from valid and invalid input data as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -126,7 +125,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] | ChpInput || true || new SystemParticipantTypedEntityData<>([:], clazz, operator, node, sptd.chpTypeInput) } - def "A CsvSystemParticipantSource should build hp input entity from valid and invalid input data as expected"() { + def "A SystemParticipantSource with csv input should build hp input entity from valid and invalid input data as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -154,7 +153,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || true || new HpInputEntityData([:], sptd.hpInput.operator, sptd.hpInput.node, sptd.hpTypeInput, sptd.hpInput.thermalBus) } - def "A CsvSystemParticipantSource should build chp input entity from valid and invalid input data as expected"(List thermalStorages, List thermalBuses, Map fieldsToAttributes, boolean resultIsPresent, ChpInputEntityData resultData) { + def "A SystemParticipantSource with csv input should build chp input entity from valid and invalid input data as expected"(List thermalStorages, List thermalBuses, Map fieldsToAttributes, boolean resultIsPresent, ChpInputEntityData resultData) { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -187,7 +186,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat ] as List | [sptd.chpInput.thermalBus] as List | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || true | new ChpInputEntityData([:], sptd.chpInput.operator, sptd.chpInput.node, sptd.chpTypeInput, sptd.chpInput.thermalBus, sptd.chpInput.thermalStorage) } - def "A CsvSystemParticipantSource should return data from a valid heat pump input file as expected"() { + def "A SystemParticipantSource with csv input should return data from a valid heat pump input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -217,7 +216,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from a valid chp input file as expected"() { + def "A SystemParticipantSource with csv input should return data from a valid chp input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -251,7 +250,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.chpInput.node] | [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid ev input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid ev input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -280,7 +279,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [] | [] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid wec input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid wec input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -309,7 +308,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [] | [] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid storage input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid storage input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -338,7 +337,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [] | [] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid bm input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid bm input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -367,7 +366,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [] | [] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid ev charging station input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid ev charging station input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -395,7 +394,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat []| []|| 0 || [] } - def "A CsvSystemParticipantSource should return data from valid load input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid load input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -423,7 +422,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid pv input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid pv input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -451,7 +450,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [] | [] || 0 || [] } - def "A CsvSystemParticipantSource should return data from valid fixedFeedIn input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid fixedFeedIn input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), @@ -482,29 +481,4 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat ] as List || 0 || [] [] | [] as List || 0 || [] } - - def "A CsvSystemParticipantSource should return data from valid em input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEmSystems(nodes as Set, operators as Set), SourceException) - - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } - - where: - nodes | operators || resultingSize || resultingSet - [sptd.emInput.node] | [sptd.emInput.operator] || 1 || [sptd.emInput] - [] | [sptd.pvInput.operator] || 0 || [] - [] | [] || 0 || [] - } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/EnergyManagementUnitsTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/EnergyManagementUnitsTest.groovy new file mode 100644 index 000000000..7bb2e6902 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/EnergyManagementUnitsTest.groovy @@ -0,0 +1,29 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.container + +import edu.ie3.test.common.EnergyManagementTestData +import spock.lang.Specification + +class EnergyManagementUnitsTest extends Specification { + + def "An EnergyManagementUnits' copy method should work as expected"() { + given: + def energyManagementUnits = new EnergyManagementUnits( + Collections.singleton(EnergyManagementTestData.emInput) + ) + + def modifiedEmInput = EnergyManagementTestData.emInput.copy().id("modified").build() + + when: + def modifiedEnergyManagementUnits = energyManagementUnits.copy() + .emUnits(Set.of(modifiedEmInput)) + .build() + + then: + modifiedEnergyManagementUnits.emUnits.first() == modifiedEmInput + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy index 5b8147f20..21bc87957 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy @@ -5,8 +5,10 @@ */ package edu.ie3.datamodel.models.input.container +import static edu.ie3.test.common.EnergyManagementTestData.emptyEnergyManagementUnits import static edu.ie3.test.common.SystemParticipantTestData.emptySystemParticipants +import edu.ie3.test.common.EnergyManagementTestData import edu.ie3.test.common.GridTestData import edu.ie3.test.common.SystemParticipantTestData import spock.lang.Specification @@ -29,7 +31,7 @@ class JointGridContainerTest extends Specification { def "A single subgrid can be used to build a JointGridContainer"() { when: - def jointGridContainer = new JointGridContainer(GRID_NAME, RAW_GRID, emptySystemParticipants, GRAPHIC_ELEMENTS) + def jointGridContainer = new JointGridContainer(GRID_NAME, RAW_GRID, emptySystemParticipants, emptyEnergyManagementUnits, GRAPHIC_ELEMENTS) then: noExceptionThrown() @@ -38,9 +40,10 @@ class JointGridContainerTest extends Specification { def "A JointGridContainer's copy method should work as expected"() { given: - def jointGridContainer = new JointGridContainer(GRID_NAME, RAW_GRID, emptySystemParticipants, GRAPHIC_ELEMENTS) + def jointGridContainer = new JointGridContainer(GRID_NAME, RAW_GRID, emptySystemParticipants, emptyEnergyManagementUnits, GRAPHIC_ELEMENTS) def rawGrid = new RawGridElements(List.of(GridTestData.lineAtoB, GridTestData.transformerAtoBtoC)) def systemParticipants = new SystemParticipants(List.of(SystemParticipantTestData.bmInput)) + def emUnits = new EnergyManagementUnits(Set.of(EnergyManagementTestData.emInput)) def graphics = new GraphicElements(Set.of(GridTestData.nodeGraphicD), Set.of(GridTestData.lineGraphicCtoD)) when: @@ -48,6 +51,7 @@ class JointGridContainerTest extends Specification { .gridName("new grid name") .rawGrid(rawGrid) .systemParticipants(systemParticipants) + .emUnits(emUnits) .graphics(graphics) .build() @@ -55,6 +59,7 @@ class JointGridContainerTest extends Specification { modifiedJointGridContainer.gridName == "new grid name" modifiedJointGridContainer.rawGrid == rawGrid modifiedJointGridContainer.systemParticipants == systemParticipants + modifiedJointGridContainer.emUnits == emUnits modifiedJointGridContainer.graphics == graphics } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy index d24239bbd..612dd50ad 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy @@ -22,8 +22,7 @@ class SystemParticipantsTest extends Specification { Collections.singleton(SystemParticipantTestData.loadInput), Collections.singleton(SystemParticipantTestData.pvInput), Collections.singleton(SystemParticipantTestData.storageInput), - Collections.singleton(SystemParticipantTestData.wecInput), - Collections.singleton(SystemParticipantTestData.emInput) + Collections.singleton(SystemParticipantTestData.wecInput) ) when: @@ -45,8 +44,7 @@ class SystemParticipantsTest extends Specification { Collections.singleton(SystemParticipantTestData.loadInput), Collections.singleton(SystemParticipantTestData.pvInput), Collections.singleton(SystemParticipantTestData.storageInput), - Collections.singleton(SystemParticipantTestData.wecInput), - Collections.singleton(SystemParticipantTestData.emInput) + Collections.singleton(SystemParticipantTestData.wecInput) ) def modifiedBmInput = SystemParticipantTestData.bmInput.copy().id("modified").build() @@ -59,13 +57,12 @@ class SystemParticipantsTest extends Specification { def modifiedPvInput = SystemParticipantTestData.pvInput.copy().id("modified").build() def modifiedStorageInput = SystemParticipantTestData.storageInput.copy().id("modified").build() def modifiedWecInput = SystemParticipantTestData.wecInput.copy().id("modified").build() - def modifiedEmInput = SystemParticipantTestData.emInput.copy().id("modified").build() when: def modifiedSystemParticipants = systemParticipants.copy() .bmPlants(Set.of(modifiedBmInput)) .chpPlants(Set.of(modifiedChpInput)) - .evCS(Set.of(modifiedEvCSInput)) + .evcs(Set.of(modifiedEvCSInput)) .evs(Set.of(modifiedEvInput)) .fixedFeedIn(Set.of(modifiedFixedFeedInInput)) .heatPumps(Set.of(modifiedHpInput)) @@ -73,13 +70,12 @@ class SystemParticipantsTest extends Specification { .pvPlants(Set.of(modifiedPvInput)) .storages(Set.of(modifiedStorageInput)) .wecPlants(Set.of(modifiedWecInput)) - .emSystems(Set.of(modifiedEmInput)) .build() then: modifiedSystemParticipants.bmPlants.first() == modifiedBmInput modifiedSystemParticipants.chpPlants.first() == modifiedChpInput - modifiedSystemParticipants.evCS.first() == modifiedEvCSInput + modifiedSystemParticipants.evcs.first() == modifiedEvCSInput modifiedSystemParticipants.evs.first() == modifiedEvInput modifiedSystemParticipants.fixedFeedIns.first() == modifiedFixedFeedInInput modifiedSystemParticipants.heatPumps.first() == modifiedHpInput @@ -87,6 +83,5 @@ class SystemParticipantsTest extends Specification { modifiedSystemParticipants.pvPlants.first() == modifiedPvInput modifiedSystemParticipants.storages.first() == modifiedStorageInput modifiedSystemParticipants.wecPlants.first() == modifiedWecInput - modifiedSystemParticipants.emSystems.first() == modifiedEmInput } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy index f8ca44650..755699e22 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy @@ -8,10 +8,9 @@ package edu.ie3.datamodel.models.input.system import static edu.ie3.datamodel.models.ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY import edu.ie3.datamodel.models.ControlStrategy -import edu.ie3.test.common.SystemParticipantTestData +import edu.ie3.test.common.EnergyManagementTestData import spock.lang.Specification - class EmInputTest extends Specification { def "The EmInput constructors work as expected"() { @@ -19,66 +18,59 @@ class EmInputTest extends Specification { def emInput = new EmInput( UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"), "test_emInput", - SystemParticipantTestData.participantNode, - SystemParticipantTestData.cosPhiFixed, - SystemParticipantTestData.connectedAssets, - SystemParticipantTestData.emControlStrategy + EnergyManagementTestData.connectedAssets, + EnergyManagementTestData.emControlStrategy ) then: emInput.with { assert uuid == UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792") assert id == "test_emInput" - assert qCharacteristics == SystemParticipantTestData.cosPhiFixed - assert connectedAssets == SystemParticipantTestData.connectedAssets - assert controlStrategy.key == SystemParticipantTestData.emControlStrategy + assert connectedAssets == EnergyManagementTestData.connectedAssets + assert controlStrategy.key == EnergyManagementTestData.emControlStrategy } } def "EmInputs are comparable"() { given: - def emInputA = SystemParticipantTestData.emInput + def emInputA = EnergyManagementTestData.emInput expect: (emInputA == emInputB) == isEqual where: - emInputB || isEqual - SystemParticipantTestData.emInput || true - SystemParticipantTestData.emInput.copy().build() || true - SystemParticipantTestData.emInput.copy().id("otherId").build() || false + emInputB || isEqual + EnergyManagementTestData.emInput || true + EnergyManagementTestData.emInput.copy().build() || true + EnergyManagementTestData.emInput.copy().id("otherId").build() || false } def "The EmInput to String method work as expected"() { given: - def emInputToString = SystemParticipantTestData.emInput.toString() + def emInputToString = EnergyManagementTestData.emInput.toString() expect: emInputToString == "EmInput{" + "uuid=" + - SystemParticipantTestData.emInput.uuid + + EnergyManagementTestData.emInput.uuid + ", id='" + - SystemParticipantTestData.emInput.id + + EnergyManagementTestData.emInput.id + ", operator=" + - SystemParticipantTestData.emInput.operator.uuid + + EnergyManagementTestData.emInput.operator.uuid + ", operationTime=" + - SystemParticipantTestData.emInput.operationTime + - ", node=" + - SystemParticipantTestData.emInput.node.uuid + - ", qCharacteristics='" + - SystemParticipantTestData.emInput.qCharacteristics + + EnergyManagementTestData.emInput.operationTime + ", connectedAssets=" + - Arrays.toString(SystemParticipantTestData.emInput.connectedAssets) + + Arrays.toString(EnergyManagementTestData.emInput.connectedAssets) + ", controlStrategy=" + - SystemParticipantTestData.emInput.controlStrategy + + EnergyManagementTestData.emInput.controlStrategy + '}' } def "A EmInput copy method should work as expected"() { given: - def emInput = SystemParticipantTestData.emInput + def emInput = EnergyManagementTestData.emInput def newConnectedAssets = [ UUID.randomUUID(), UUID.randomUUID() @@ -94,7 +86,6 @@ class EmInputTest extends Specification { assert operationTime == emInput.operationTime assert operator == emInput.operator assert id == emInput.id - assert qCharacteristics == emInput.qCharacteristics assert connectedAssets == newConnectedAssets assert controlStrategy == NO_CONTROL_STRATEGY } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy index c07ff0d54..72461b659 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy @@ -294,6 +294,7 @@ class ContainerUtilsTest extends Specification { Set subNetNumbers = ContainerUtils.determineSubnetNumbers(ComplexTopology.grid.rawGrid.nodes) RawGridElements rawGrid = ComplexTopology.grid.rawGrid SystemParticipants systemParticipants = ComplexTopology.grid.systemParticipants + EnergyManagementUnits emUnits = ComplexTopology.grid.emUnits GraphicElements graphics = ComplexTopology.grid.graphics HashMap expectedSubGrids = ComplexTopology.expectedSubGrids @@ -304,6 +305,7 @@ class ContainerUtilsTest extends Specification { subNetNumbers, rawGrid, systemParticipants, + emUnits, graphics) then: @@ -323,6 +325,7 @@ class ContainerUtilsTest extends Specification { Set subNetNumbers = ContainerUtils.determineSubnetNumbers(ComplexTopology.grid.rawGrid.nodes) RawGridElements rawGridInput= ComplexTopology.grid.rawGrid SystemParticipants systemParticipantsInput = ComplexTopology.grid.systemParticipants + EnergyManagementUnits emUnits = ComplexTopology.grid.emUnits GraphicElements graphicsInput = ComplexTopology.grid.graphics HashMap unmodifiedSubGrids = ComplexTopology.expectedSubGrids @@ -332,6 +335,7 @@ class ContainerUtilsTest extends Specification { subNetNumbers, rawGridInput, systemParticipantsInput, + emUnits, graphicsInput) when: @@ -386,12 +390,14 @@ class ContainerUtilsTest extends Specification { Set subNetNumbers = ContainerUtils.determineSubnetNumbers(ComplexTopology.grid.rawGrid.nodes) RawGridElements rawGrid = ComplexTopology.grid.rawGrid SystemParticipants systemParticipants = ComplexTopology.grid.systemParticipants + EnergyManagementUnits emUnits = ComplexTopology.grid.emUnits GraphicElements graphics = ComplexTopology.grid.graphics Map subgrids = ContainerUtils.buildSubGridContainers( gridName, subNetNumbers, rawGrid, systemParticipants, + emUnits, graphics) SubGridTopologyGraph expectedSubGridTopology = ComplexTopology.expectedSubGridTopology @@ -409,6 +415,7 @@ class ContainerUtilsTest extends Specification { String gridName = ComplexTopology.gridName RawGridElements rawGrid = ComplexTopology.grid.rawGrid SystemParticipants systemParticpants = ComplexTopology.grid.systemParticipants + EnergyManagementUnits emUnits = ComplexTopology.grid.emUnits GraphicElements graphics = ComplexTopology.grid.graphics SubGridTopologyGraph expectedSubGridTopology = ComplexTopology.expectedSubGridTopology @@ -417,6 +424,7 @@ class ContainerUtilsTest extends Specification { gridName, rawGrid, systemParticpants, + emUnits, graphics) then: diff --git a/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy b/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy index 5637f74d2..172675589 100644 --- a/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy +++ b/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy @@ -5,6 +5,7 @@ */ package edu.ie3.test.common +import static edu.ie3.test.common.EnergyManagementTestData.emptyEnergyManagementUnits import static edu.ie3.test.common.SystemParticipantTestData.emptySystemParticipants import edu.ie3.datamodel.graph.SubGridGate @@ -14,7 +15,6 @@ import edu.ie3.datamodel.models.input.container.GraphicElements import edu.ie3.datamodel.models.input.container.JointGridContainer import edu.ie3.datamodel.models.input.container.RawGridElements import edu.ie3.datamodel.models.input.container.SubGridContainer -import edu.ie3.datamodel.models.input.container.SystemParticipants import org.jgrapht.graph.DirectedMultigraph class ComplexTopology extends GridTestData { @@ -46,6 +46,7 @@ class ComplexTopology extends GridTestData { gridName, rawGrid, emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set)) @@ -65,18 +66,8 @@ class ComplexTopology extends GridTestData { [transformerAtoBtoC] as Set, [] as Set, [] as Set), - new SystemParticipants( - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set), + emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set) @@ -93,6 +84,7 @@ class ComplexTopology extends GridTestData { [] as Set, [] as Set), emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set) @@ -109,6 +101,7 @@ class ComplexTopology extends GridTestData { [] as Set, [] as Set), emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set) @@ -125,6 +118,7 @@ class ComplexTopology extends GridTestData { [] as Set, [] as Set), emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set) @@ -144,6 +138,7 @@ class ComplexTopology extends GridTestData { [] as Set, [] as Set), emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set) @@ -163,6 +158,7 @@ class ComplexTopology extends GridTestData { [] as Set, [] as Set), emptySystemParticipants, + emptyEnergyManagementUnits, new GraphicElements( [] as Set, [] as Set) diff --git a/src/test/groovy/edu/ie3/test/common/EnergyManagementTestData.groovy b/src/test/groovy/edu/ie3/test/common/EnergyManagementTestData.groovy new file mode 100644 index 000000000..4d8714c6b --- /dev/null +++ b/src/test/groovy/edu/ie3/test/common/EnergyManagementTestData.groovy @@ -0,0 +1,30 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.test.common + +import edu.ie3.datamodel.models.input.container.EnergyManagementUnits +import edu.ie3.datamodel.models.input.system.EmInput + +class EnergyManagementTestData { + + public static final UUID[] connectedAssets = new UUID[]{ + SystemParticipantTestData.loadInput.uuid, + SystemParticipantTestData.pvInput.uuid + } + public static final String emControlStrategy = "self_optimization" + + public static final emInput = new EmInput( + UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"), + "test_emInput", + SystemParticipantTestData.operator, + SystemParticipantTestData.operationTime, + connectedAssets, + emControlStrategy + ) + + public static EnergyManagementUnits emptyEnergyManagementUnits = + new EnergyManagementUnits([] as List) +} diff --git a/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy b/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy index 8adea5e57..44243df05 100644 --- a/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy +++ b/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy @@ -15,6 +15,7 @@ import edu.ie3.datamodel.models.input.connector.LineInput import edu.ie3.datamodel.models.input.connector.Transformer2WInput import edu.ie3.datamodel.models.input.connector.type.LineTypeInput import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput +import edu.ie3.datamodel.models.input.container.EnergyManagementUnits import edu.ie3.datamodel.models.input.container.GraphicElements import edu.ie3.datamodel.models.input.container.JointGridContainer import edu.ie3.datamodel.models.input.container.RawGridElements @@ -47,6 +48,7 @@ class SampleJointGrid extends SystemParticipantTestData { "sampleGrid", rawGridElements, systemParticipants(rawGridElements), + new EnergyManagementUnits(Collections.emptySet()), new GraphicElements(Collections.emptySet())) } @@ -127,19 +129,18 @@ class SampleJointGrid extends SystemParticipantTestData { Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), - new HashSet<>(Arrays.asList(loadInput, loadInput1)), + Set.of(loadInput, loadInput1), Collections.singleton(pvInput), Collections.singleton(storageInput), - Collections.emptySet(), Collections.emptySet()) } private static RawGridElements jointSampleRawGridElements() throws ParseException { return new RawGridElements( - new HashSet<>(Arrays.asList(nodeA, nodeB, nodeC, nodeD, nodeE, nodeF, nodeG)), - new HashSet<>(Arrays.asList(lineAB, lineAC, lineBC, lineDE, lineDF, lineEF)), - new HashSet<>(Arrays.asList(transformerDtoA, transformerGtoD)), + Set.of(nodeA, nodeB, nodeC, nodeD, nodeE, nodeF, nodeG), + Set.of(lineAB, lineAC, lineBC, lineDE, lineDF, lineEF), + Set.of(transformerDtoA, transformerGtoD), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()) diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index 067ed6a50..8db7f21cf 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -312,22 +312,6 @@ class SystemParticipantTestData { v2gSupport ) - // Energy Management - public static final UUID[] connectedAssets = new UUID[]{ - loadInput.getUuid(), pvInput.getUuid() - } - public static final String emControlStrategy = "self_optimization" - public static final emInput = new EmInput( - UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"), - "test_emInput", - operator, - operationTime, - participantNode, - cosPhiFixed, - connectedAssets, - emControlStrategy - ) - public static allParticipants = [ fixedFeedInInput, pvInput, @@ -337,22 +321,19 @@ class SystemParticipantTestData { wecInput, evInput, chpInput, - hpInput, - emInput + hpInput ] - static SystemParticipants getEmptySystemParticipants() { - return new SystemParticipants( - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set) - } + public static SystemParticipants emptySystemParticipants = + new SystemParticipants( + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set) } diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv index ad93c0222..5cc111444 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv @@ -1,2 +1,2 @@ -uuid,connected_assets,control_strategy,id,node,operates_from,operates_until,operator,q_characteristics -977157f4-25e5-4c72-bf34-440edc778792,eaf77f7e-9001-479f-94ca-7fb657766f5f d56f15b7-8293-4b98-b5bd-58f6273ce229,self_optimization,test_emInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,cosPhiFixed:{(0.00,0.95)} +uuid,connected_assets,control_strategy,id,operates_from,operates_until,operator +977157f4-25e5-4c72-bf34-440edc778792,eaf77f7e-9001-479f-94ca-7fb657766f5f d56f15b7-8293-4b98-b5bd-58f6273ce229,self_optimization,test_emInput,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510