Skip to content

Refactoring CongestionResult #1235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 5, 2025
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 @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Renamed timeseries mapping `participant` column to `asset` [#1191](https://github.com/ie3-institute/PowerSystemDataModel/issues/1191)
- Removed attribute `dsm` from `LoadInput` [#1195](https://github.com/ie3-institute/PowerSystemDataModel/issues/1195)
- Fix spotless deprecations [#1123](https://github.com/ie3-institute/PowerSystemDataModel/issues/1223)
- Refactored `CongestionResult`, removed `ModelResultEntity` [#1234](https://github.com/ie3-institute/PowerSystemDataModel/issues/1234)

## [5.1.0] - 2024-06-24

Expand Down
42 changes: 21 additions & 21 deletions docs/readthedocs/models/result/grid/congestion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Congestion

Representation of a congestion result for a given subnet.
Representation of a congestion result for a given asset.

## Attributes, Units and Remarks

Expand All @@ -18,30 +18,30 @@ Representation of a congestion result for a given subnet.
* - time
- ZonedDateTime
- date and time for the produced result

* - subgrid
* - inputModel
-
- Sub grid number

* - vMin
- p.u.
- minimal voltage of the subnet

* - vMax
- p.u.
- maximal voltage of the subnet

* - voltage
- uuid for the associated input model

* - inputModelType
-
- Boolean indicator, if a voltage congestion occurred

* - line
- the type of the input model (e.g. node, line, etc.)
* - subgrid
-
- Boolean indicator, if a line congestion occurred
- Sub grid number

* - transformer
-
- Boolean indicator, if a transformer congestion occurred
* - value
- Percent
- the actual value that was calculated in relation to its base value

* - min
- Percent
- minimal limit value

* - max
- Percent
- maximal limit value
```

## Caveats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
*/
package edu.ie3.datamodel.io.factory.result;

import static edu.ie3.util.quantities.PowerSystemUnits.PU;
import static tech.units.indriya.unit.Units.PERCENT;

import edu.ie3.datamodel.exceptions.FactoryException;
import edu.ie3.datamodel.exceptions.ParsingException;
import edu.ie3.datamodel.io.factory.EntityData;
import edu.ie3.datamodel.models.result.CongestionResult;
import edu.ie3.datamodel.models.result.CongestionResult.InputModelType;
import edu.ie3.datamodel.utils.Try;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.measure.quantity.Dimensionless;
import tech.units.indriya.ComparableQuantity;

public class CongestionResultFactory extends ResultEntityFactory<CongestionResult> {
private static final String TYPE = "type";
private static final String SUBGRID = "subgrid";
private static final String VMIN = "vMin";
private static final String VMAX = "vMax";
private static final String VOLTAGE = "voltage";
private static final String LINE = "line";
private static final String TRANSFORMER = "transformer";
private static final String VALUE = "value";
private static final String MIN = "min";
private static final String MAX = "max";

public CongestionResultFactory() {
super(CongestionResult.class);
Expand All @@ -34,19 +38,25 @@ public CongestionResultFactory(DateTimeFormatter dateTimeFormatter) {

@Override
protected List<Set<String>> getFields(Class<?> entityClass) {
return List.of(newSet(TIME, SUBGRID, VMIN, VMAX, VOLTAGE, LINE, TRANSFORMER));
return List.of(newSet(TIME, INPUT_MODEL, TYPE, SUBGRID, MIN, MAX));
}

@Override
protected CongestionResult buildModel(EntityData data) {
ZonedDateTime zdtTime = timeUtil.toZonedDateTime(data.getField(TIME));
UUID inputModel = data.getUUID(INPUT_MODEL);

InputModelType type =
Try.of(() -> InputModelType.parse(data.getField(TYPE)), ParsingException.class)
.transformF(FactoryException::new)
.getOrThrow();

int subgrid = data.getInt(SUBGRID);
ComparableQuantity<Dimensionless> vMin = data.getQuantity(VMIN, PU);
ComparableQuantity<Dimensionless> vMax = data.getQuantity(VMAX, PU);
boolean voltage = data.getBoolean(VOLTAGE);
boolean line = data.getBoolean(LINE);
boolean transformer = data.getBoolean(TRANSFORMER);

return new CongestionResult(zdtTime, subgrid, vMin, vMax, voltage, line, transformer);
ComparableQuantity<Dimensionless> value = data.getQuantity(VALUE, PERCENT);
ComparableQuantity<Dimensionless> min = data.getQuantity(MIN, PERCENT);
ComparableQuantity<Dimensionless> max = data.getQuantity(MAX, PERCENT);

return new CongestionResult(zdtTime, inputModel, type, subgrid, value, min, max);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.measure.quantity.ElectricCurrent;
import tech.units.indriya.ComparableQuantity;

public class ConnectorResultFactory extends ModelResultFactory<ConnectorResult> {
public class ConnectorResultFactory extends ResultEntityFactory<ConnectorResult> {

private static final String IAMAG = "iAMag";
private static final String IAANG = "iAAng";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import javax.measure.quantity.Power;
import tech.units.indriya.ComparableQuantity;

public class FlexOptionsResultFactory extends ModelResultFactory<FlexOptionsResult> {
public class FlexOptionsResultFactory extends ResultEntityFactory<FlexOptionsResult> {

private static final String P_REF = "pRef";
private static final String P_MIN = "pMin";
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import javax.measure.quantity.Dimensionless;
import tech.units.indriya.ComparableQuantity;

public class NodeResultFactory extends ModelResultFactory<NodeResult> {
public class NodeResultFactory extends ResultEntityFactory<NodeResult> {
private static final String VMAG = "vMag";
private static final String VANG = "vAng";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public abstract class ResultEntityFactory<T extends ResultEntity>
extends EntityFactory<T, EntityData> {

protected static final String TIME = "time";
protected static final String INPUT_MODEL = "inputModel";

protected final TimeUtil timeUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.time.format.DateTimeFormatter;
import java.util.*;

public class SwitchResultFactory extends ModelResultFactory<SwitchResult> {
public class SwitchResultFactory extends ResultEntityFactory<SwitchResult> {

private static final String CLOSED = "closed";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Factory class for creating {@link SystemParticipantResult} entities from provided {@link
* EntityData} data objects.
*/
public class SystemParticipantResultFactory extends ModelResultFactory<SystemParticipantResult> {
public class SystemParticipantResultFactory extends ResultEntityFactory<SystemParticipantResult> {

private static final String POWER = "p";
private static final String REACTIVE_POWER = "q";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.measure.quantity.Temperature;
import tech.units.indriya.ComparableQuantity;

public class ThermalResultFactory extends ModelResultFactory<ThermalUnitResult> {
public class ThermalResultFactory extends ResultEntityFactory<ThermalUnitResult> {
private static final String Q_DOT = "qDot";
private static final String INDOOR_TEMPERATURE = "indoorTemperature";
private static final String ENERGY = "energy";
Expand Down
Loading