Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/uml/main/input/ModelContainerConcept.puml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ package models.input.container {
class SystemParticipants {
- bmPlants: Set<BmInput>
- chpPlants: Set<ChpInput>
- evCS: Set<EvcsInput>
- evcs: Set<EvcsInput>
- evs: Set<EvInput>
- fixedFeedIns: Set<FixedFeedInInput>
- heatPumps: Set<HpInput>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<EmInput, NodeAssetInputEntityData> {
public class EmInputFactory extends AssetInputEntityFactory<EmInput, AssetInputEntityData> {
private static final Logger logger = LoggerFactory.getLogger(EmInputFactory.class);

private static final String CONNECTED_ASSETS = "connectedassets";
Expand All @@ -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;
Expand All @@ -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);
}
}
8 changes: 3 additions & 5 deletions src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,14 @@ public void persistJointGrid(JointGridContainer jointGridContainer) {
SystemParticipants systemParticipants = jointGridContainer.getSystemParticipants();
Set<BmInput> bmPlants = systemParticipants.getBmPlants();
Set<ChpInput> chpPlants = systemParticipants.getChpPlants();
Set<EvcsInput> evCS = systemParticipants.getEvCS();
Set<EvcsInput> evcs = systemParticipants.getEvcs();
Set<EvInput> evs = systemParticipants.getEvs();
Set<FixedFeedInInput> fixedFeedIns = systemParticipants.getFixedFeedIns();
Set<HpInput> heatPumps = systemParticipants.getHeatPumps();
Set<LoadInput> loads = systemParticipants.getLoads();
Set<PvInput> pvPlants = systemParticipants.getPvPlants();
Set<StorageInput> storages = systemParticipants.getStorages();
Set<WecInput> wecPlants = systemParticipants.getWecPlants();
Set<EmInput> emSystems = systemParticipants.getEmSystems();

// get graphic elements (just for better readability, we could also just get them directly
// below)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
* <p>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<OperatorInput> 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}.
*
* <p>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.
*
* <p>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<OperatorInput> operators) throws SourceException {
Set<EmInput> emUnits =
Try.scanCollection(
buildAssetInputEntities(EmInput.class, emInputFactory, operators), EmInput.class)
.transformF(SourceException::new)
.getOrThrow();
return new EnergyManagementUnits(emUnits);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -74,7 +73,6 @@ public SystemParticipantSource(
this.storageInputFactory = new StorageInputFactory();
this.wecInputFactory = new WecInputFactory();
this.evcsInputFactory = new EvcsInputFactory();
this.emInputFactory = new EmInputFactory();
}

/**
Expand Down Expand Up @@ -136,8 +134,6 @@ public SystemParticipants getSystemParticipants() throws SourceException {
SourceException.class);
Try<Set<HpInput>, SourceException> hpInputs =
Try.of(() -> getHeatPumps(nodes, operators, hpTypes, thermalBuses), SourceException.class);
Try<Set<EmInput>, SourceException> emInputs =
Try.of(() -> getEmSystems(nodes, operators), SourceException.class);

List<SourceException> exceptions =
Try.getExceptions(
Expand All @@ -151,8 +147,7 @@ public SystemParticipants getSystemParticipants() throws SourceException {
evs,
evcs,
chpInputs,
hpInputs,
emInputs));
hpInputs));

if (!exceptions.isEmpty()) {
throw new SystemParticipantsException(
Expand All @@ -172,8 +167,7 @@ public SystemParticipants getSystemParticipants() throws SourceException {
loads.getOrThrow(),
pvInputs.getOrThrow(),
storages.getOrThrow(),
wecInputs.getOrThrow(),
emInputs.getOrThrow());
wecInputs.getOrThrow());
}
}

Expand Down Expand Up @@ -527,46 +521,6 @@ public Set<EvInput> getEvs(
.getOrThrow();
}

/**
* Returns a unique set of {@link EmInput} instances.
*
* <p>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<EmInput> getEmSystems() throws SourceException {
Set<OperatorInput> 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}.
*
* <p>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.
*
* <p>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<EmInput> getEmSystems(Set<NodeInput> nodes, Set<OperatorInput> operators)
throws SourceException {
return Try.scanCollection(
buildNodeAssetEntities(EmInput.class, emInputFactory, nodes, operators), EmInput.class)
.transformF(SourceException::new)
.getOrThrow();
}

public Set<ChpInput> getChpPlants() throws SourceException {
Set<OperatorInput> operators = typeSource.getOperators();
Set<ThermalBusInput> thermalBuses = thermalSource.getThermalBuses(operators);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,13 +47,16 @@ 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 */
Try<RawGridElements, SourceException> rawGridElements =
Try.of(rawGridSource::getGridData, SourceException.class);
Try<SystemParticipants, SourceException> systemParticipants =
Try.of(systemParticipantSource::getSystemParticipants, SourceException.class);
Try<EnergyManagementUnits, SourceException> emUnits =
Try.of(emSource::getEmUnits, SourceException.class);
Try<GraphicElements, SourceException> graphicElements =
Try.of(graphicSource::getGraphicElements, SourceException.class);

Expand All @@ -73,6 +73,7 @@ public static JointGridContainer read(
gridName,
rawGridElements.getOrThrow(),
systemParticipants.getOrThrow(),
emUnits.getOrThrow(),
graphicElements.getOrThrow());
}
}
Expand Down
Loading