Skip to content

Commit 2131b24

Browse files
Merge pull request #959 from ie3-institute/sp/#955-eminput-asset
Separating em units from system participants
2 parents 7363bc9 + b02506d commit 2131b24

30 files changed

+470
-356
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Changing from comparing strings to comparing uuids in `EntitySource.findFirstEntityByUuid` [#829](https://github.com/ie3-institute/PowerSystemDataModel/issues/829)
1717
- Adding JavaDoc to `EntitySource.safeMapGet` [#828](https://github.com/ie3-institute/PowerSystemDataModel/issues/828)
1818
- Abstracting some methods in `ValidationUtils` [#852](https://github.com/ie3-institute/PowerSystemDataModel/issues/852)
19+
- `EmInput` should not be connected to the grid [#955](https://github.com/ie3-institute/PowerSystemDataModel/issues/955)
1920

2021
## [4.1.0] - 2023-11-02
2122

docs/uml/main/input/ModelContainerConcept.puml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ package models.input.container {
4242
class SystemParticipants {
4343
- bmPlants: Set<BmInput>
4444
- chpPlants: Set<ChpInput>
45-
- evCS: Set<EvcsInput>
45+
- evcs: Set<EvcsInput>
4646
- evs: Set<EvInput>
4747
- fixedFeedIns: Set<FixedFeedInInput>
4848
- heatPumps: Set<HpInput>

src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66
package edu.ie3.datamodel.io.factory.input.participant;
77

88
import edu.ie3.datamodel.exceptions.ParsingException;
9-
import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData;
9+
import edu.ie3.datamodel.io.factory.input.AssetInputEntityData;
10+
import edu.ie3.datamodel.io.factory.input.AssetInputEntityFactory;
1011
import edu.ie3.datamodel.models.ControlStrategy;
1112
import edu.ie3.datamodel.models.OperationTime;
12-
import edu.ie3.datamodel.models.input.NodeInput;
1313
import edu.ie3.datamodel.models.input.OperatorInput;
1414
import edu.ie3.datamodel.models.input.system.EmInput;
15-
import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic;
1615
import java.util.UUID;
1716
import org.slf4j.Logger;
1817
import org.slf4j.LoggerFactory;
1918

20-
public class EmInputFactory
21-
extends SystemParticipantInputEntityFactory<EmInput, NodeAssetInputEntityData> {
19+
public class EmInputFactory extends AssetInputEntityFactory<EmInput, AssetInputEntityData> {
2220
private static final Logger logger = LoggerFactory.getLogger(EmInputFactory.class);
2321

2422
private static final String CONNECTED_ASSETS = "connectedassets";
@@ -36,11 +34,9 @@ protected String[] getAdditionalFields() {
3634

3735
@Override
3836
protected EmInput buildModel(
39-
NodeAssetInputEntityData data,
37+
AssetInputEntityData data,
4038
UUID uuid,
4139
String id,
42-
NodeInput node,
43-
ReactivePowerCharacteristic qCharacteristics,
4440
OperatorInput operator,
4541
OperationTime operationTime) {
4642
ControlStrategy controlStrategy;
@@ -58,14 +54,6 @@ protected EmInput buildModel(
5854
if (connectedAssets.length == 0)
5955
logger.warn("There are no connected assets for energy management system \"{}\".", id);
6056

61-
return new EmInput(
62-
uuid,
63-
id,
64-
operator,
65-
operationTime,
66-
node,
67-
qCharacteristics,
68-
connectedAssets,
69-
controlStrategy);
57+
return new EmInput(uuid, id, operator, operationTime, connectedAssets, controlStrategy);
7058
}
7159
}

src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,14 @@ public void persistJointGrid(JointGridContainer jointGridContainer) {
170170
SystemParticipants systemParticipants = jointGridContainer.getSystemParticipants();
171171
Set<BmInput> bmPlants = systemParticipants.getBmPlants();
172172
Set<ChpInput> chpPlants = systemParticipants.getChpPlants();
173-
Set<EvcsInput> evCS = systemParticipants.getEvCS();
173+
Set<EvcsInput> evcs = systemParticipants.getEvcs();
174174
Set<EvInput> evs = systemParticipants.getEvs();
175175
Set<FixedFeedInInput> fixedFeedIns = systemParticipants.getFixedFeedIns();
176176
Set<HpInput> heatPumps = systemParticipants.getHeatPumps();
177177
Set<LoadInput> loads = systemParticipants.getLoads();
178178
Set<PvInput> pvPlants = systemParticipants.getPvPlants();
179179
Set<StorageInput> storages = systemParticipants.getStorages();
180180
Set<WecInput> wecPlants = systemParticipants.getWecPlants();
181-
Set<EmInput> emSystems = systemParticipants.getEmSystems();
182181

183182
// get graphic elements (just for better readability, we could also just get them directly
184183
// below)
@@ -211,15 +210,14 @@ public void persistJointGrid(JointGridContainer jointGridContainer) {
211210
measurementUnits,
212211
bmPlants,
213212
chpPlants,
214-
evCS,
213+
evcs,
215214
evs,
216215
fixedFeedIns,
217216
heatPumps,
218217
loads,
219218
pvPlants,
220219
storages,
221-
wecPlants,
222-
emSystems)
220+
wecPlants)
223221
.flatMap(Collection::stream)
224222
.map(Extractor::extractOperator)
225223
.flatMap(Optional::stream)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* © 2023. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.io.source;
7+
8+
import edu.ie3.datamodel.exceptions.SourceException;
9+
import edu.ie3.datamodel.io.factory.input.participant.EmInputFactory;
10+
import edu.ie3.datamodel.models.input.OperatorInput;
11+
import edu.ie3.datamodel.models.input.container.EnergyManagementUnits;
12+
import edu.ie3.datamodel.models.input.system.EmInput;
13+
import edu.ie3.datamodel.utils.Try;
14+
import java.util.Set;
15+
16+
public class EnergyManagementSource extends EntitySource {
17+
18+
private final TypeSource typeSource;
19+
20+
private final EmInputFactory emInputFactory;
21+
22+
public EnergyManagementSource(TypeSource typeSource, DataSource dataSource) {
23+
this.typeSource = typeSource;
24+
this.dataSource = dataSource;
25+
26+
this.emInputFactory = new EmInputFactory();
27+
}
28+
29+
/**
30+
* Returns a unique set of {@link EmInput} instances.
31+
*
32+
* <p>This set has to be unique in the sense of object uniqueness but also in the sense of {@link
33+
* java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as
34+
* {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}.
35+
*
36+
* @return a set of object and uuid unique {@link EmInput} entities
37+
*/
38+
public EnergyManagementUnits getEmUnits() throws SourceException {
39+
Set<OperatorInput> operators = typeSource.getOperators();
40+
return getEmUnits(operators);
41+
}
42+
43+
/**
44+
* This set has to be unique in the sense of object uniqueness but also in the sense of {@link
45+
* java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as
46+
* {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}.
47+
*
48+
* <p>In contrast to {@link #getEmUnits()} this method provides the ability to pass in an already
49+
* existing set of {@link OperatorInput} entities, the {@link EmInput} instances depend on. Doing
50+
* so, already loaded nodes can be recycled to improve performance and prevent unnecessary loading
51+
* operations.
52+
*
53+
* <p>If something fails during the creation process a {@link SourceException} is thrown, else a
54+
* set with all entities that has been able to be build is returned.
55+
*
56+
* @param operators a set of object and uuid unique {@link OperatorInput} that should be used for
57+
* the returning instances
58+
* @return a set of object and uuid unique {@link EmInput} entities
59+
*/
60+
public EnergyManagementUnits getEmUnits(Set<OperatorInput> operators) throws SourceException {
61+
Set<EmInput> emUnits =
62+
Try.scanCollection(
63+
buildAssetInputEntities(EmInput.class, emInputFactory, operators), EmInput.class)
64+
.transformF(SourceException::new)
65+
.getOrThrow();
66+
return new EnergyManagementUnits(emUnits);
67+
}
68+
}

src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class SystemParticipantSource extends EntitySource {
5050
private final StorageInputFactory storageInputFactory;
5151
private final WecInputFactory wecInputFactory;
5252
private final EvcsInputFactory evcsInputFactory;
53-
private final EmInputFactory emInputFactory;
5453

5554
public SystemParticipantSource(
5655
TypeSource typeSource,
@@ -74,7 +73,6 @@ public SystemParticipantSource(
7473
this.storageInputFactory = new StorageInputFactory();
7574
this.wecInputFactory = new WecInputFactory();
7675
this.evcsInputFactory = new EvcsInputFactory();
77-
this.emInputFactory = new EmInputFactory();
7876
}
7977

8078
/**
@@ -136,8 +134,6 @@ public SystemParticipants getSystemParticipants() throws SourceException {
136134
SourceException.class);
137135
Try<Set<HpInput>, SourceException> hpInputs =
138136
Try.of(() -> getHeatPumps(nodes, operators, hpTypes, thermalBuses), SourceException.class);
139-
Try<Set<EmInput>, SourceException> emInputs =
140-
Try.of(() -> getEmSystems(nodes, operators), SourceException.class);
141137

142138
List<SourceException> exceptions =
143139
Try.getExceptions(
@@ -151,8 +147,7 @@ public SystemParticipants getSystemParticipants() throws SourceException {
151147
evs,
152148
evcs,
153149
chpInputs,
154-
hpInputs,
155-
emInputs));
150+
hpInputs));
156151

157152
if (!exceptions.isEmpty()) {
158153
throw new SystemParticipantsException(
@@ -172,8 +167,7 @@ public SystemParticipants getSystemParticipants() throws SourceException {
172167
loads.getOrThrow(),
173168
pvInputs.getOrThrow(),
174169
storages.getOrThrow(),
175-
wecInputs.getOrThrow(),
176-
emInputs.getOrThrow());
170+
wecInputs.getOrThrow());
177171
}
178172
}
179173

@@ -527,46 +521,6 @@ public Set<EvInput> getEvs(
527521
.getOrThrow();
528522
}
529523

530-
/**
531-
* Returns a unique set of {@link EmInput} instances.
532-
*
533-
* <p>This set has to be unique in the sense of object uniqueness but also in the sense of {@link
534-
* java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as
535-
* {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}.
536-
*
537-
* @return a set of object and uuid unique {@link EmInput} entities
538-
*/
539-
public Set<EmInput> getEmSystems() throws SourceException {
540-
Set<OperatorInput> operators = typeSource.getOperators();
541-
return getEmSystems(rawGridSource.getNodes(operators), operators);
542-
}
543-
544-
/**
545-
* This set has to be unique in the sense of object uniqueness but also in the sense of {@link
546-
* java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as
547-
* {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}.
548-
*
549-
* <p>In contrast to {@link #getHeatPumps()} this method provides the ability to pass in an
550-
* already existing set of {@link NodeInput} and {@link OperatorInput} entities, the {@link
551-
* EmInput} instances depend on. Doing so, already loaded nodes can be recycled to improve
552-
* performance and prevent unnecessary loading operations.
553-
*
554-
* <p>If something fails during the creation process a {@link SourceException} is thrown, else a
555-
* set with all entities that has been able to be build is returned.
556-
*
557-
* @param operators a set of object and uuid unique {@link OperatorInput} that should be used for
558-
* the returning instances
559-
* @param nodes a set of object and uuid unique {@link NodeInput} entities
560-
* @return a set of object and uuid unique {@link EmInput} entities
561-
*/
562-
public Set<EmInput> getEmSystems(Set<NodeInput> nodes, Set<OperatorInput> operators)
563-
throws SourceException {
564-
return Try.scanCollection(
565-
buildNodeAssetEntities(EmInput.class, emInputFactory, nodes, operators), EmInput.class)
566-
.transformF(SourceException::new)
567-
.getOrThrow();
568-
}
569-
570524
public Set<ChpInput> getChpPlants() throws SourceException {
571525
Set<OperatorInput> operators = typeSource.getOperators();
572526
Set<ThermalBusInput> thermalBuses = thermalSource.getThermalBuses(operators);

src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy;
1313
import edu.ie3.datamodel.io.naming.FileNamingStrategy;
1414
import edu.ie3.datamodel.io.source.*;
15-
import edu.ie3.datamodel.models.input.container.GraphicElements;
16-
import edu.ie3.datamodel.models.input.container.JointGridContainer;
17-
import edu.ie3.datamodel.models.input.container.RawGridElements;
18-
import edu.ie3.datamodel.models.input.container.SystemParticipants;
15+
import edu.ie3.datamodel.models.input.container.*;
1916
import edu.ie3.datamodel.utils.Try;
2017
import java.nio.file.Path;
2118
import java.util.List;
@@ -50,13 +47,16 @@ public static JointGridContainer read(
5047
ThermalSource thermalSource = new ThermalSource(typeSource, dataSource);
5148
SystemParticipantSource systemParticipantSource =
5249
new SystemParticipantSource(typeSource, thermalSource, rawGridSource, dataSource);
50+
EnergyManagementSource emSource = new EnergyManagementSource(typeSource, dataSource);
5351
GraphicSource graphicSource = new GraphicSource(typeSource, rawGridSource, dataSource);
5452

5553
/* Loading models */
5654
Try<RawGridElements, SourceException> rawGridElements =
5755
Try.of(rawGridSource::getGridData, SourceException.class);
5856
Try<SystemParticipants, SourceException> systemParticipants =
5957
Try.of(systemParticipantSource::getSystemParticipants, SourceException.class);
58+
Try<EnergyManagementUnits, SourceException> emUnits =
59+
Try.of(emSource::getEmUnits, SourceException.class);
6060
Try<GraphicElements, SourceException> graphicElements =
6161
Try.of(graphicSource::getGraphicElements, SourceException.class);
6262

@@ -73,6 +73,7 @@ public static JointGridContainer read(
7373
gridName,
7474
rawGridElements.getOrThrow(),
7575
systemParticipants.getOrThrow(),
76+
emUnits.getOrThrow(),
7677
graphicElements.getOrThrow());
7778
}
7879
}

0 commit comments

Comments
 (0)