Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
83cf8d7
Correctly persist EmInput entities in CsvFileSink
pierrepetersmeier Sep 1, 2025
7c5936f
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Sep 8, 2025
87937f9
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Sep 19, 2025
d0b9e56
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Sep 24, 2025
ac5b72a
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
staudtMarius Sep 25, 2025
15eb11a
Add a test that reads in the persisted grid and compares it with the …
pierrepetersmeier Sep 29, 2025
175e758
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Sep 29, 2025
14416ca
Add em_inputs.csv for GridIoIT
pierrepetersmeier Oct 2, 2025
41ee164
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Oct 2, 2025
71c5159
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Feb 10, 2026
7a9cac3
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
danielfeismann Feb 10, 2026
5f6da26
Add test for persisting JointGridContainer with EmInput
pierrepetersmeier Feb 12, 2026
15686a3
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Feb 12, 2026
88b61d8
Refactor GridIoIT setup and cleanup methods for improved clarity beca…
pierrepetersmeier Feb 12, 2026
cc3605c
Merge remote-tracking branch 'origin/pp/#1337-eminputs-arent-written-…
pierrepetersmeier Feb 12, 2026
fdf5bbb
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
danielfeismann Feb 13, 2026
7fa92bc
reintroduce EnergyManagementUnits
danielfeismann Feb 18, 2026
1aa5e70
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
danielfeismann Feb 18, 2026
baa0e5a
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
danielfeismann Mar 10, 2026
3db2a86
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
danielfeismann Mar 10, 2026
2f56e84
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
staudtMarius Mar 18, 2026
9800c50
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Mar 18, 2026
226345c
Fix EmInput serialization in CsvFileSink.java.
pierrepetersmeier Mar 23, 2026
058966e
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Mar 24, 2026
0d6ea6e
add missing EmInput to SampleJointGrid data and fmt
pierrepetersmeier Mar 25, 2026
8bd4863
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
pierrepetersmeier Mar 25, 2026
c1c79ed
Refactor persistJointGrid to remove redundant set allocations
pierrepetersmeier Mar 25, 2026
79022d7
Merge remote-tracking branch 'origin/pp/#1337-eminputs-arent-written-…
pierrepetersmeier Mar 25, 2026
acc2321
add examples for emControlStrategy to docs
danielfeismann Mar 25, 2026
57a90c4
optimize imports
danielfeismann Mar 25, 2026
bd3f1e1
Merge branch 'dev' into pp/#1337-eminputs-arent-written-while-persist…
danielfeismann Mar 26, 2026
cad3c6b
Adres review comments
pierrepetersmeier Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed handling of erroneous field values in `EntitySource.enrichWithDefault()` [#1511](https://github.com/ie3-institute/PowerSystemDataModel/issues/1511)
- Fixed some minor typos and inconsistencies in variable naming [#1542](https://github.com/ie3-institute/PowerSystemDataModel/issues/1542)
- Aligned temperature processing in `COSMO` and `ICON` factories to Kelvin [#1521](https://github.com/ie3-institute/PowerSystemDataModel/issues/1521)
- Correctly persist EmInput entities in CsvFileSink [#1337](https://github.com/ie3-institute/PowerSystemDataModel/issues/1337)

### Changed
- Updated CI-Pipeline to run task `Deploy` and `Staging` only for `Main` [#1403](https://github.com/ie3-institute/PowerSystemDataModel/issues/1403)
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import edu.ie3.datamodel.io.csv.BufferedCsvWriter;
import edu.ie3.datamodel.io.csv.CsvFileDefinition;
import edu.ie3.datamodel.io.extractor.Extractor;
import edu.ie3.datamodel.io.extractor.HasEm;
import edu.ie3.datamodel.io.extractor.NestedEntity;
import edu.ie3.datamodel.io.naming.FileNamingStrategy;
import edu.ie3.datamodel.io.processor.ProcessorProvider;
Expand Down Expand Up @@ -228,14 +229,34 @@ public void persistJointGrid(JointGridContainer jointGridContainer) {
.flatMap(Optional::stream)
.collect(Collectors.toSet());

// extract all EmInput entities
Set<EmInput> emInputs =
systemParticipants.allEntitiesAsList().stream()
.filter(HasEm.class::isInstance)
.map(HasEm.class::cast)
.map(HasEm::getControllingEm)
.flatMap(Optional::stream)
.flatMap(
em ->
Stream.iterate(
em, Objects::nonNull, current -> current.getControllingEm().orElse(null)))
.collect(Collectors.toSet());

Set<EmInput> containerEmInputs = new HashSet<>(jointGridContainer.getEmUnits().getEmUnits());

Set<EmInput> allEmInputs = new HashSet<>(containerEmInputs);
allEmInputs.addAll(emInputs);

// persist all entities
Stream.of(
rawGridElements.allEntitiesAsList(),
systemParticipants.allEntitiesAsList(),
graphicElements.allEntitiesAsList(),
types,
operators)
operators,
allEmInputs)
.flatMap(Collection::stream)
.collect(Collectors.toSet())
.forEach(this::persistIgnoreNested);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public static JointGridContainer read(
Try.of(
() -> systemParticipantSource.getSystemParticipants(operators, nodes),
SourceException.class);
Try<EnergyManagementUnits, SourceException> emUnits =
Try.of(
() -> new EnergyManagementUnits(new HashSet<>(emSource.getEmUnits(operators).values())),
SourceException.class);
Try<GraphicElements, SourceException> graphicElements =
Try.of(() -> graphicSource.getGraphicElements(nodes, lines), SourceException.class);

Expand All @@ -97,6 +101,7 @@ public static JointGridContainer read(
gridName,
rawGridElements.getOrThrow(),
systemParticipants.getOrThrow(),
emUnits.getOrThrow(),
graphicElements.getOrThrow());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* © 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.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<EmInput> {

protected final Map<UUID, EmInput> emUnits;

Check failure on line 16 in src/main/java/edu/ie3/datamodel/models/input/container/EnergyManagementUnits.java

View check run for this annotation

SonarQubeGithubPRChecks / SonarQube Code Analysis

src/main/java/edu/ie3/datamodel/models/input/container/EnergyManagementUnits.java#L16

Make non-static "emUnits" private or transient.

public EnergyManagementUnits(Set<EmInput> 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<EnergyManagementUnits> emUnits) {
this.emUnits =
emUnits.stream()
.flatMap(units -> units.emUnits.entrySet().stream())
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

public Set<EmInput> getEmUnits() {
return new HashSet<>(emUnits.values());
}

@Override
public List<EmInput> allEntitiesAsList() {
return emUnits.values().stream().toList();
}

public Map<UUID, EmInput> 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 Javadocs of {@link
* EnergyManagementUnits}
*/
public static class EnergyManagementUnitsCopyBuilder extends InputContainerCopyBuilder<EmInput> {
protected Set<EmInput> 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<EmInput> emUnits) {
this.emUnits = emUnits;
return this;
}

@Override
public EnergyManagementUnits build() {
return new EnergyManagementUnits(emUnits);
}

@Override
public InputContainerCopyBuilder<EmInput> thisInstance() {
return this;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@ public abstract class GridContainer implements InputContainer<UniqueInputEntity>
/** 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;

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;
}

Expand All @@ -38,6 +43,7 @@ public List<UniqueInputEntity> allEntitiesAsList() {
List<UniqueInputEntity> allEntities = new LinkedList<>();
allEntities.addAll(rawGrid.allEntitiesAsList());
allEntities.addAll(systemParticipants.allEntitiesAsList());
allEntities.addAll(emUnits.allEntitiesAsList());
allEntities.addAll(graphics.allEntitiesAsList());
return Collections.unmodifiableList(allEntities);
}
Expand All @@ -58,6 +64,10 @@ public SystemParticipants getSystemParticipants() {
return systemParticipants;
}

public EnergyManagementUnits getEmUnits() {
return emUnits;
}

public GraphicElements getGraphics() {
return graphics;
}
Expand All @@ -69,12 +79,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
Expand All @@ -94,6 +105,7 @@ protected abstract static class GridContainerCopyBuilder<B extends GridContainer
private String gridName;
private RawGridElements rawGrid;
private SystemParticipants systemParticipants;
private EnergyManagementUnits emUnits;
private GraphicElements graphics;

/**
Expand All @@ -105,6 +117,7 @@ protected GridContainerCopyBuilder(GridContainer gridContainer) {
this.gridName = gridContainer.getGridName();
this.rawGrid = gridContainer.getRawGrid();
this.systemParticipants = gridContainer.getSystemParticipants();
this.emUnits = gridContainer.getEmUnits();
this.graphics = gridContainer.getGraphics();
}

Expand All @@ -123,6 +136,11 @@ protected SystemParticipants getSystemParticipants() {
return systemParticipants;
}

/** Returns {@link EnergyManagementUnits} */
public EnergyManagementUnits getEmUnits() {
return emUnits;
}

/** Returns {@link GraphicElements} */
protected GraphicElements getGraphics() {
return graphics;
Expand Down Expand Up @@ -161,6 +179,17 @@ public B systemParticipants(SystemParticipants systemParticipants) {
return thisInstance();
}

/**
* Method to alter the {@link EnergyManagementUnits}s.
*
* @param emUnits altered em units
* @return this instance of {@link GridContainerCopyBuilder}
*/
public B emUnits(EnergyManagementUnits emUnits) {
this.emUnits = emUnits;
return thisInstance();
}

/**
* Method to alter the {@link GraphicElements}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,26 @@ public JointGridContainer(
String gridName,
RawGridElements rawGrid,
SystemParticipants systemParticipants,
EnergyManagementUnits emUnits,
GraphicElements graphics)
throws InvalidGridException {
super(gridName, rawGrid, systemParticipants, graphics);
super(gridName, rawGrid, systemParticipants, emUnits, graphics);

/* Build sub grid dependency */
this.subGridTopologyGraph =
ContainerUtils.buildSubGridTopologyGraph(
this.gridName, this.rawGrid, this.systemParticipants, this.graphics);
this.gridName, this.rawGrid, this.systemParticipants, this.emUnits, this.graphics);
checkSubGridTopologyGraph(subGridTopologyGraph);
}

public JointGridContainer(
String gridName,
RawGridElements rawGrid,
SystemParticipants systemParticipants,
EnergyManagementUnits emUnits,
GraphicElements graphics,
SubGridTopologyGraph subGridTopologyGraph) {
super(gridName, rawGrid, systemParticipants, graphics);
super(gridName, rawGrid, systemParticipants, emUnits, graphics);
this.subGridTopologyGraph = subGridTopologyGraph;
checkSubGridTopologyGraph(this.subGridTopologyGraph);
}
Expand Down Expand Up @@ -117,6 +119,7 @@ public JointGridContainer build() {
getGridName(),
getRawGrid(),
getSystemParticipants(),
getEmUnits(),
getGraphics(),
subGridTopologyGraph);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public SubGridContainer(
int subnet,
RawGridElements rawGrid,
SystemParticipants systemParticipants,
EnergyManagementUnits emUnits,
GraphicElements graphics)
throws InvalidGridException {
super(gridName, rawGrid, systemParticipants, graphics);
super(gridName, rawGrid, systemParticipants, emUnits, graphics);
this.subnet = subnet;
this.predominantVoltageLevel = ContainerUtils.determinePredominantVoltLvl(rawGrid, subnet);
}
Expand Down Expand Up @@ -113,7 +114,12 @@ protected SubGridContainerCopyBuilder thisInstance() {
@Override
public SubGridContainer build() throws InvalidGridException {
return new SubGridContainer(
getGridName(), subnet, getRawGrid(), getSystemParticipants(), getGraphics());
getGridName(),
subnet,
getRawGrid(),
getSystemParticipants(),
getEmUnits(),
getGraphics());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static JointGridContainer updateGridWithNodes(
grid.getGridName(),
updatedEntities.rawGridElements(),
updatedEntities.systemParticipants(),
grid.getEmUnits(),
updatedEntities.graphicElements());
}

Expand Down Expand Up @@ -112,6 +113,7 @@ public static SubGridContainer updateGridWithNodes(
grid.getSubnet(),
updatedEntities.rawGridElements(),
updatedEntities.systemParticipants(),
grid.getEmUnits(),
updatedEntities.graphicElements());
}

Expand Down Expand Up @@ -538,7 +540,7 @@ private static Set<Transformer3WInput> update3wTransformers(
* new nodes mapping affects at least one transformer. This is necessary because by policy, the
* geoPosition of a transformer is determined by its nodeA. If multiple transformers are now
* chained together e.g. nodeA - trafoAtoD - nodeD - trafoDtoG - nodeG than all transformer nodes
* needs to be updated if at least one of the provided nodes is affected. Otherwise inconsistency
* needs to be updated if at least one of the provided nodes is affected. Otherwise, inconsistency
* would occur because transformers would end up with multiple geoPositions which is physically
* not possible.
*
Expand Down
Loading