From 82e88ca9eaa1710ae3786eae47231ba9d27c0f1c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 8 Aug 2024 17:05:05 +0200 Subject: [PATCH 01/70] add attributes pThermalRated to cylindricalstorage and housingType, numberInhabitants to ThermalHouse --- CHANGELOG.md | 3 ++ .../input/thermal/cylindricalstorage.md | 4 ++ .../models/input/thermal/thermalhouse.md | 8 +++ .../input/CylindricalStorageInputFactory.java | 11 +++- .../input/ThermalHouseInputFactory.java | 16 +++++- .../thermal/CylindricalStorageInput.java | 41 ++++++++++++-- .../input/thermal/ThermalHouseInput.java | 54 +++++++++++++++++-- .../ThermalUnitValidationUtils.java | 30 ++++++++++- .../io/extractor/ExtractorTest.groovy | 8 +-- .../CylindricalStorageInputFactoryTest.groovy | 4 +- .../input/ThermalHouseInputFactoryTest.groovy | 7 ++- .../datamodel/io/sink/CsvFileSinkTest.groovy | 2 +- .../csv/CsvSystemParticipantSourceTest.groovy | 4 ++ .../io/source/csv/CsvThermalSourceTest.groovy | 6 +++ .../CylindricalStorageInputTest.groovy | 5 +- .../thermal/ThermalHouseInputTest.groovy | 5 +- .../ThermalUnitValidationUtilsTest.groovy | 29 ++++++---- .../common/SystemParticipantTestData.groovy | 8 ++- .../common/ThermalUnitInputTestData.groovy | 15 ++++-- .../cylindrical_storage_input.csv | 4 +- .../_thermal/cylindrical_storage_input.csv | 4 +- .../csv/_thermal/thermal_house_input.csv | 4 +- 22 files changed, 225 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 083590698..1f7a70dde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `ConnectorValidationUtils` checks if parallel devices is > 0 [#1077](https://github.com/ie3-institute/PowerSystemDataModel/issues/1077) - `GridContainerValidationUtils` checks the connectivity for all defined operation time intervals [#1091](https://github.com/ie3-institute/PowerSystemDataModel/issues/1091) - Implemented a `CongestionResult` [#1097](https://github.com/ie3-institute/PowerSystemDataModel/issues/1097) +- Attribute `pThermalRated` for `ThermalStorage`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) +- Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) +- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) ### Fixed - Fixed `MappingEntryies` not getting processed by adding `Getter` methods for record fields [#1084](https://github.com/ie3-institute/PowerSystemDataModel/issues/1084) diff --git a/docs/readthedocs/models/input/thermal/cylindricalstorage.md b/docs/readthedocs/models/input/thermal/cylindricalstorage.md index 553f63d3e..6d4b0d3a5 100644 --- a/docs/readthedocs/models/input/thermal/cylindricalstorage.md +++ b/docs/readthedocs/models/input/thermal/cylindricalstorage.md @@ -55,6 +55,10 @@ Model of a cylindrical thermal storage using a fluent to store thermal energy. * - c - kWh / (K :math:`\cdot` m³) - Specific heat capacity of the storage medium + + * - pThermalMax + - kW + - Maximum permissible thermal power of the storage ``` diff --git a/docs/readthedocs/models/input/thermal/thermalhouse.md b/docs/readthedocs/models/input/thermal/thermalhouse.md index d06a1f59c..018319d9e 100644 --- a/docs/readthedocs/models/input/thermal/thermalhouse.md +++ b/docs/readthedocs/models/input/thermal/thermalhouse.md @@ -56,6 +56,14 @@ This reflects a simple shoe box with transmission losses * - lowerTemperatureLimit - °C - Lower temperature boundary + + * - housingType + - -- + - Type of building can either be house or flat + + * - numberInhabititans + - # + - Number of people living in the house ``` diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java index 3b423465c..be49eadb0 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java @@ -12,6 +12,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; import java.util.UUID; +import javax.measure.quantity.Power; import javax.measure.quantity.Temperature; import javax.measure.quantity.Volume; import tech.units.indriya.ComparableQuantity; @@ -23,6 +24,7 @@ public class CylindricalStorageInputFactory private static final String INLET_TEMP = "inletTemp"; private static final String RETURN_TEMP = "returnTemp"; private static final String C = "c"; + private static final String P_THERMAL_MAX = "pThermalMax"; public CylindricalStorageInputFactory() { super(CylindricalStorageInput.class); @@ -30,7 +32,9 @@ public CylindricalStorageInputFactory() { @Override protected String[] getAdditionalFields() { - return new String[] {STORAGE_VOLUME_LVL, STORAGE_VOLUME_LVL_MIN, INLET_TEMP, RETURN_TEMP, C}; + return new String[] { + STORAGE_VOLUME_LVL, STORAGE_VOLUME_LVL_MIN, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX + }; } @Override @@ -51,6 +55,8 @@ protected CylindricalStorageInput buildModel( data.getQuantity(RETURN_TEMP, StandardUnits.TEMPERATURE); final ComparableQuantity c = data.getQuantity(C, StandardUnits.SPECIFIC_HEAT_CAPACITY); + final ComparableQuantity pThermalMax = + data.getQuantity(P_THERMAL_MAX, StandardUnits.ACTIVE_POWER_IN); return new CylindricalStorageInput( uuid, id, @@ -61,6 +67,7 @@ protected CylindricalStorageInput buildModel( storageVolumeLvlMin, inletTemp, returnTemp, - c); + c, + pThermalMax); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java index 6fab0fc61..69533c930 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java @@ -23,6 +23,8 @@ public class ThermalHouseInputFactory private static final String TARGET_TEMPERATURE = "targetTemperature"; private static final String UPPER_TEMPERATURE_LIMIT = "upperTemperatureLimit"; private static final String LOWER_TEMPERATURE_LIMIT = "lowerTemperatureLimit"; + private static final String HOUSING_TYPE = "housingType"; + private static final String NUMBER_INHABITANTS = "numberInhabitants"; public ThermalHouseInputFactory() { super(ThermalHouseInput.class); @@ -31,7 +33,13 @@ public ThermalHouseInputFactory() { @Override protected String[] getAdditionalFields() { return new String[] { - ETH_LOSSES, ETH_CAPA, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT + ETH_LOSSES, + ETH_CAPA, + TARGET_TEMPERATURE, + UPPER_TEMPERATURE_LIMIT, + LOWER_TEMPERATURE_LIMIT, + HOUSING_TYPE, + NUMBER_INHABITANTS }; } @@ -53,6 +61,8 @@ protected ThermalHouseInput buildModel( data.getQuantity(UPPER_TEMPERATURE_LIMIT, StandardUnits.TEMPERATURE); final ComparableQuantity lowerTemperatureLimit = data.getQuantity(LOWER_TEMPERATURE_LIMIT, StandardUnits.TEMPERATURE); + final String housingType = data.getField(HOUSING_TYPE); + final Integer numberInhabitants = data.getInt(NUMBER_INHABITANTS); return new ThermalHouseInput( uuid, id, @@ -63,6 +73,8 @@ protected ThermalHouseInput buildModel( ethCapa, targetTemperature, upperTemperatureLimit, - lowerTemperatureLimit); + lowerTemperatureLimit, + housingType, + numberInhabitants); } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 611c48e0a..d505323f0 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -11,6 +11,7 @@ import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; import java.util.Objects; import java.util.UUID; +import javax.measure.quantity.Power; import javax.measure.quantity.Temperature; import javax.measure.quantity.Volume; import tech.units.indriya.ComparableQuantity; @@ -27,6 +28,8 @@ public class CylindricalStorageInput extends ThermalStorageInput { private final ComparableQuantity returnTemp; /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ private final ComparableQuantity c; + /** Maximum permissible thermal power (typically in kW) */ + private final ComparableQuantity pThermalMax; /** * @param uuid Unique identifier of a cylindrical storage @@ -39,6 +42,7 @@ public class CylindricalStorageInput extends ThermalStorageInput { * @param inletTemp Temperature of the inlet * @param returnTemp Temperature of the outlet * @param c Specific heat capacity of the storage medium + * @param pThermalMax Maximum thermal power of the storage */ public CylindricalStorageInput( UUID uuid, @@ -50,13 +54,15 @@ public CylindricalStorageInput( ComparableQuantity storageVolumeLvlMin, ComparableQuantity inletTemp, ComparableQuantity returnTemp, - ComparableQuantity c) { + ComparableQuantity c, + ComparableQuantity pThermalMax) { super(uuid, id, operator, operationTime, bus); this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); this.storageVolumeLvlMin = storageVolumeLvlMin.to(StandardUnits.VOLUME); this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); } /** @@ -68,6 +74,7 @@ public CylindricalStorageInput( * @param inletTemp Temperature of the inlet * @param returnTemp Temperature of the outlet * @param c Specific heat capacity of the storage medium + * @param pThermalMax Maximum thermal power of the storage */ public CylindricalStorageInput( UUID uuid, @@ -77,13 +84,15 @@ public CylindricalStorageInput( ComparableQuantity storageVolumeLvlMin, ComparableQuantity inletTemp, ComparableQuantity returnTemp, - ComparableQuantity c) { + ComparableQuantity c, + ComparableQuantity pThermalMax) { super(uuid, id, bus); this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); this.storageVolumeLvlMin = storageVolumeLvlMin.to(StandardUnits.VOLUME); this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); } public ComparableQuantity getStorageVolumeLvl() { @@ -106,6 +115,10 @@ public ComparableQuantity getC() { return c; } + public ComparableQuantity getpThermalMax() { + return pThermalMax; + } + @Override public CylindricalStorageInputCopyBuilder copy() { return new CylindricalStorageInputCopyBuilder(this); @@ -120,13 +133,20 @@ public boolean equals(Object o) { && storageVolumeLvlMin.equals(that.storageVolumeLvlMin) && inletTemp.equals(that.inletTemp) && returnTemp.equals(that.returnTemp) - && c.equals(that.c); + && c.equals(that.c) + && pThermalMax.equals(that.pThermalMax); } @Override public int hashCode() { return Objects.hash( - super.hashCode(), storageVolumeLvl, storageVolumeLvlMin, inletTemp, returnTemp, c); + super.hashCode(), + storageVolumeLvl, + storageVolumeLvlMin, + inletTemp, + returnTemp, + c, + pThermalMax); } @Override @@ -152,6 +172,8 @@ public String toString() { + returnTemp + ", c=" + c + + ", pThermalMax=" + + pThermalMax + '}'; } @@ -168,6 +190,7 @@ public static class CylindricalStorageInputCopyBuilder private ComparableQuantity inletTemp; private ComparableQuantity returnTemp; private ComparableQuantity c; + private ComparableQuantity pThermalMax; private CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); @@ -176,6 +199,7 @@ private CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { this.inletTemp = entity.getInletTemp(); this.returnTemp = entity.getReturnTemp(); this.c = entity.getC(); + this.pThermalMax = entity.getpThermalMax(); } public CylindricalStorageInputCopyBuilder storageVolumeLvl( @@ -206,10 +230,16 @@ public CylindricalStorageInputCopyBuilder c(ComparableQuantity pThermalMax) { + this.pThermalMax = pThermalMax; + return this; + } + @Override public CylindricalStorageInputCopyBuilder scale(Double factor) { storageVolumeLvl(storageVolumeLvl.multiply(factor)); storageVolumeLvlMin(storageVolumeLvlMin.multiply(factor)); + pThermalMax(pThermalMax.multiply(factor)); return this; } @@ -225,7 +255,8 @@ public CylindricalStorageInput build() { storageVolumeLvlMin, inletTemp, returnTemp, - c); + c, + pThermalMax); } @Override diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java index b0fbab0b6..a92e54da8 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java @@ -27,6 +27,10 @@ public class ThermalHouseInput extends ThermalSinkInput { private final ComparableQuantity upperTemperatureLimit; /** Lower boundary temperature of the thermal house model (typically in °C) */ private final ComparableQuantity lowerTemperatureLimit; + /** Type of the building, e.g. house or flat */ + private final String housingType; + /** Number of people living in the building */ + private final Integer numberInhabitants; /** * @param uuid Unique identifier of a thermal house model @@ -46,13 +50,17 @@ public ThermalHouseInput( ComparableQuantity ethCapa, ComparableQuantity targetTemperature, ComparableQuantity upperTemperatureLimit, - ComparableQuantity lowerTemperatureLimit) { + ComparableQuantity lowerTemperatureLimit, + String housingType, + Integer numberInhabitants) { super(uuid, id, bus); this.ethLosses = ethLosses.to(StandardUnits.THERMAL_TRANSMISSION); this.ethCapa = ethCapa.to(StandardUnits.HEAT_CAPACITY); this.targetTemperature = targetTemperature.to(StandardUnits.TEMPERATURE); this.upperTemperatureLimit = upperTemperatureLimit.to(StandardUnits.TEMPERATURE); this.lowerTemperatureLimit = lowerTemperatureLimit.to(StandardUnits.TEMPERATURE); + this.housingType = housingType; + this.numberInhabitants = numberInhabitants; } /** @@ -77,13 +85,17 @@ public ThermalHouseInput( ComparableQuantity ethCapa, ComparableQuantity targetTemperature, ComparableQuantity upperTemperatureLimit, - ComparableQuantity lowerTemperatureLimit) { + ComparableQuantity lowerTemperatureLimit, + String housingType, + Integer numberInhabitants) { super(uuid, id, operator, operationTime, bus); this.ethLosses = ethLosses.to(StandardUnits.THERMAL_TRANSMISSION); this.ethCapa = ethCapa.to(StandardUnits.HEAT_CAPACITY); this.targetTemperature = targetTemperature.to(StandardUnits.TEMPERATURE); this.upperTemperatureLimit = upperTemperatureLimit.to(StandardUnits.TEMPERATURE); this.lowerTemperatureLimit = lowerTemperatureLimit.to(StandardUnits.TEMPERATURE); + this.housingType = housingType; + this.numberInhabitants = numberInhabitants; } public ComparableQuantity getEthLosses() { @@ -106,6 +118,14 @@ public ComparableQuantity getLowerTemperatureLimit() { return lowerTemperatureLimit; } + public String getHousingType() { + return housingType; + } + + public Integer getNumberOfInhabitants() { + return numberInhabitants; + } + @Override public ThermalHouseInputCopyBuilder copy() { return new ThermalHouseInputCopyBuilder(this); @@ -120,7 +140,9 @@ public boolean equals(Object o) { && ethCapa.equals(that.ethCapa) && targetTemperature.equals(that.targetTemperature) && upperTemperatureLimit.equals(that.upperTemperatureLimit) - && lowerTemperatureLimit.equals(that.lowerTemperatureLimit); + && lowerTemperatureLimit.equals(that.lowerTemperatureLimit) + && Objects.equals(housingType, that.housingType) + && Objects.equals(numberInhabitants, that.numberInhabitants); } @Override @@ -131,7 +153,9 @@ public int hashCode() { ethCapa, targetTemperature, upperTemperatureLimit, - lowerTemperatureLimit); + lowerTemperatureLimit, + housingType, + numberInhabitants); } @Override @@ -157,6 +181,10 @@ public String toString() { + upperTemperatureLimit + ", lowerTemperatureLimit=" + lowerTemperatureLimit + + ", housingType=" + + housingType + + ", numberInhabitants=" + + numberInhabitants + '}'; } @@ -173,6 +201,8 @@ public static class ThermalHouseInputCopyBuilder private ComparableQuantity targetTemperature; private ComparableQuantity upperTemperatureLimit; private ComparableQuantity lowerTemperatureLimit; + private String housingType; + private Integer numberInhabitants; private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) { super(entity); @@ -181,6 +211,8 @@ private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) { this.targetTemperature = entity.getTargetTemperature(); this.upperTemperatureLimit = entity.getUpperTemperatureLimit(); this.lowerTemperatureLimit = entity.getLowerTemperatureLimit(); + this.housingType = entity.getHousingType(); + this.numberInhabitants = entity.getNumberOfInhabitants(); } public ThermalHouseInputCopyBuilder ethLosses( @@ -212,6 +244,16 @@ public ThermalHouseInputCopyBuilder lowerTemperatureLimit( return this; } + public ThermalHouseInputCopyBuilder housingType(String housingType) { + this.housingType = housingType; + return this; + } + + public ThermalHouseInputCopyBuilder numberInhabitants(Integer numberInhabitants) { + this.numberInhabitants = numberInhabitants; + return this; + } + @Override public ThermalHouseInputCopyBuilder scale(Double factor) { // scale losses as well as capacity to keep equal @@ -233,7 +275,9 @@ public ThermalHouseInput build() { ethCapa, targetTemperature, upperTemperatureLimit, - lowerTemperatureLimit); + lowerTemperatureLimit, + housingType, + numberInhabitants); } @Override diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index 704567699..89c9f91c7 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -12,6 +12,7 @@ import edu.ie3.datamodel.utils.Try.Failure; import java.util.ArrayList; import java.util.List; +import java.util.Set; import javax.measure.Quantity; public class ThermalUnitValidationUtils extends ValidationUtils { @@ -135,6 +136,8 @@ private ThermalUnitValidationUtils() { *
  • its thermal capacity is positive *
  • its upper temperature limit is higher than the lower temperature limit *
  • its target temperature lies between the upper und lower limit temperatures + *
  • its housing type is either `house` or `flat` + *
  • its number of inhabitants is higher than zero * * * @param thermalHouseInput ThermalHouseInput to validate @@ -173,9 +176,33 @@ private static List> checkThermalHouse( thermalHouseInput))); } + if (!isValidHousingType(thermalHouseInput.getHousingType())) { + exceptions.add( + new Failure<>( + new InvalidEntityException( + "Housing type must be either 'house' or 'flat'", thermalHouseInput))); + } + + if (thermalHouseInput.getNumberOfInhabitants() <= 0) { + exceptions.add( + new Failure<>( + new InvalidEntityException( + "Number of inhabitants must be greater than zero", thermalHouseInput))); + } + return exceptions; } + /** + * Checks if the housing type is valid (either "house" or "flat"). + * + * @param housingType The housing type to check + * @return true if valid, false otherwise + */ + private static boolean isValidHousingType(String housingType) { + return Set.of("house", "flat").contains(housingType.toLowerCase()); + } + /** * Validates a cylindricalStorageInput if: * @@ -231,7 +258,8 @@ private static List> checkCylindricalStorage( new Quantity[] { cylindricalStorageInput.getStorageVolumeLvl(), cylindricalStorageInput.getStorageVolumeLvlMin(), - cylindricalStorageInput.getC() + cylindricalStorageInput.getC(), + cylindricalStorageInput.getpThermalMax() }, cylindricalStorageInput), InvalidEntityException.class)); diff --git a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy index be1cf541d..9c4968164 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy @@ -134,10 +134,10 @@ class ExtractorTest extends Specification { tutd.thermalBus.operator ] - tutd.cylindricStorageInput || [ - tutd.cylindricStorageInput.operator, - tutd.cylindricStorageInput.thermalBus, - tutd.cylindricStorageInput.thermalBus.operator + tutd.cylindricalStorageInput || [ + tutd.cylindricalStorageInput.operator, + tutd.cylindricalStorageInput.thermalBus, + tutd.cylindricalStorageInput.thermalBus.operator ] tutd.thermalHouseInput || [ diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy index cf75e1188..fe9b4d21b 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy @@ -35,7 +35,8 @@ class CylindricalStorageInputFactoryTest extends Specification implements Facto "storagevolumelvlmin": "4", "inlettemp" : "5", "returntemp" : "6", - "c" : "7" + "c" : "7", + "pThermalMax" : "8" ] def inputClass = CylindricalStorageInput def thermalBusInput = Mock(ThermalBusInput) @@ -57,6 +58,7 @@ class CylindricalStorageInputFactoryTest extends Specification implements Facto assert inletTemp == getQuant(parameter["inlettemp"], StandardUnits.TEMPERATURE) assert returnTemp == getQuant(parameter["returntemp"], StandardUnits.TEMPERATURE) assert c == getQuant(parameter["c"], StandardUnits.SPECIFIC_HEAT_CAPACITY) + assert pThermalMax == getQuant(parameter["pThermalMax"], StandardUnits.ACTIVE_POWER_IN) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactoryTest.groovy index 82c0e7843..07f5794fd 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactoryTest.groovy @@ -35,7 +35,10 @@ class ThermalHouseInputFactoryTest extends Specification implements FactoryTestH "ethcapa" : "4", "targetTemperature" : "5", "upperTemperatureLimit": "6", - "lowerTemperatureLimit": "7" + "lowerTemperatureLimit": "7", + "housingType" : "flat", + "numberInhabitants" : "9", + ] def inputClass = ThermalHouseInput def thermalBusInput = Mock(ThermalBusInput) @@ -57,6 +60,8 @@ class ThermalHouseInputFactoryTest extends Specification implements FactoryTestH assert targetTemperature == getQuant(parameter["targetTemperature"], StandardUnits.TEMPERATURE) assert upperTemperatureLimit == getQuant(parameter["upperTemperatureLimit"], StandardUnits.TEMPERATURE) assert lowerTemperatureLimit == getQuant(parameter["lowerTemperatureLimit"], StandardUnits.TEMPERATURE) + assert housingType == parameter["housingType"] + assert numberInhabitants == parameter["numberInhabitants"].toInteger() } } } 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 2914504c4..773f53c53 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy @@ -165,7 +165,7 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { GridTestData.transformerCtoG, GridTestData.lineGraphicCtoD, GridTestData.nodeGraphicC, - ThermalUnitInputTestData.cylindricStorageInput, + ThermalUnitInputTestData.cylindricalStorageInput, ThermalUnitInputTestData.thermalHouseInput, SystemParticipantTestData.evcsInput, SystemParticipantTestData.loadInput, 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 67316ab30..197d2644b 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 @@ -10,9 +10,13 @@ import static edu.ie3.test.helper.EntityMap.map import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.exceptions.SystemParticipantsException import edu.ie3.datamodel.io.source.* +import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData as sptd +import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity import spock.lang.Specification +import tech.units.indriya.ComparableQuantity +import tech.units.indriya.quantity.Quantities class CsvSystemParticipantSourceTest extends Specification implements CsvTestDataMeta { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy index 7351cf1a2..b54c719c7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy @@ -10,6 +10,7 @@ import edu.ie3.datamodel.io.source.ThermalSource import edu.ie3.datamodel.io.source.TypeSource import edu.ie3.test.common.SystemParticipantTestData as sptd import edu.ie3.test.common.ThermalUnitInputTestData +import org.apache.commons.compress.harmony.unpack200.bytecode.forms.ThisMethodRefForm import spock.lang.Specification class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { @@ -69,6 +70,7 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { inletTemp == sptd.inletTemp returnTemp == sptd.returnTemp c == sptd.c + pThermalMax == sptd.pThermalMax } //test method when operators and thermal buses are provided as constructor parameters @@ -116,6 +118,8 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit + housingType == ThermalUnitInputTestData.thermalHouseInput.housingType + numberOfInhabitants == ThermalUnitInputTestData.thermalHouseInput.numberOfInhabitants } //test method when operators and thermal buses are provided as constructor parameters @@ -136,6 +140,8 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit + housingType == ThermalUnitInputTestData.thermalHouseInput.housingType + numberOfInhabitants == ThermalUnitInputTestData.thermalHouseInput.numberOfInhabitants } } } \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy index 815876368..869175bd5 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy @@ -13,7 +13,7 @@ class CylindricalStorageInputTest extends Specification { def "A CylindricalStorageInput copy method should work as expected"() { given: - def cylindricalStorageInput = ThermalUnitInputTestData.cylindricStorageInput + def cylindricalStorageInput = ThermalUnitInputTestData.cylindricalStorageInput when: def alteredUnit = cylindricalStorageInput.copy().storageVolumeLvl(ThermalUnitInputTestData.storageVolumeLvl) @@ -39,7 +39,7 @@ class CylindricalStorageInputTest extends Specification { def "Scaling a CylindricalStorageInput via builder should work as expected"() { given: - def cylindricalStorageInput = ThermalUnitInputTestData.cylindricStorageInput + def cylindricalStorageInput = ThermalUnitInputTestData.cylindricalStorageInput when: def alteredUnit = cylindricalStorageInput.copy().scale(2d).build() @@ -56,6 +56,7 @@ class CylindricalStorageInputTest extends Specification { assert inletTemp == cylindricalStorageInput.inletTemp assert returnTemp == cylindricalStorageInput.returnTemp assert c == cylindricalStorageInput.c + assert pThermalMax == cylindricalStorageInput.pThermalMax * 2d } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy index d2f9c5afd..7f93dab21 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy @@ -67,7 +67,10 @@ class ThermalHouseInputTest extends Specification { Quantities.getQuantity(20, StandardUnits.HEAT_CAPACITY), Quantities.getQuantity(20, StandardUnits.TEMPERATURE), Quantities.getQuantity(25, StandardUnits.TEMPERATURE), - Quantities.getQuantity(15, StandardUnits.TEMPERATURE)) + Quantities.getQuantity(15, StandardUnits.TEMPERATURE), + "house", + 2 + ) expect: thermalHouseInput.targetTemperature == Quantities.getQuantity(20, StandardUnits.TEMPERATURE) diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy index 5c1de7967..4507b9d3d 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy @@ -16,6 +16,7 @@ import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData import edu.ie3.test.common.ThermalUnitInputTestData import edu.ie3.util.TimeUtil +import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.quantities.interfaces.HeatCapacity import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity import edu.ie3.util.quantities.interfaces.ThermalConductance @@ -23,6 +24,7 @@ import spock.lang.Specification import tech.units.indriya.ComparableQuantity import tech.units.indriya.quantity.Quantities +import javax.measure.quantity.Power import javax.measure.quantity.Temperature import javax.measure.quantity.Volume @@ -43,6 +45,8 @@ class ThermalUnitValidationUtilsTest extends Specification { private static final ComparableQuantity TARGET_TEMPERATURE = Quantities.getQuantity(20, StandardUnits.TEMPERATURE) private static final ComparableQuantity UPPER_TEMPERATURE_LIMIT = Quantities.getQuantity(25, StandardUnits.TEMPERATURE) private static final ComparableQuantity LOWER_TEMPERATURE_LIMIT = Quantities.getQuantity(15, StandardUnits.TEMPERATURE) + private static final String HOUSING_TYPE = "House" + private static final Integer NUMBER_INHABITANTS = 2 // Specific data for thermal cylindric storage input private static final ComparableQuantity storageVolumeLvl = Quantities.getQuantity(100, StandardUnits.VOLUME) @@ -50,6 +54,7 @@ class ThermalUnitValidationUtilsTest extends Specification { private static final ComparableQuantity inletTemp = Quantities.getQuantity(100, StandardUnits.TEMPERATURE) private static final ComparableQuantity returnTemp = Quantities.getQuantity(80, StandardUnits.TEMPERATURE) private static final ComparableQuantity c = Quantities.getQuantity(1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY) + private static final ComparableQuantity pThermalMax = Quantities.getQuantity(10.2, StandardUnits.ACTIVE_POWER_IN) // Thermal House @@ -75,19 +80,21 @@ class ThermalUnitValidationUtilsTest extends Specification { ex.message == expectedException.message where: - invalidThermalHouse || expectedSize || expectedException - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-10, StandardUnits.THERMAL_TRANSMISSION), ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT) || 1 || new InvalidEntityException("The following quantities have to be zero or positive: -10 kW/K", invalidThermalHouse) - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, Quantities.getQuantity(0, StandardUnits.HEAT_CAPACITY), TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT) || 1 || new InvalidEntityException("The following quantities have to be positive: 0 kWh/K", invalidThermalHouse) - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), LOWER_TEMPERATURE_LIMIT) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, Quantities.getQuantity(30, StandardUnits.TEMPERATURE)) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) + invalidThermalHouse || expectedSize || expectedException + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-10, StandardUnits.THERMAL_TRANSMISSION), ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("The following quantities have to be zero or positive: -10 kW/K", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, Quantities.getQuantity(0, StandardUnits.HEAT_CAPACITY), TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("The following quantities have to be positive: 0 kWh/K", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, Quantities.getQuantity(30, StandardUnits.TEMPERATURE), HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, "someWrongType", NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Housing type must be either 'house' or 'flat'", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, 0) || 1 || new InvalidEntityException("Number of inhabitants must be greater than zero", invalidThermalHouse) } // Thermal Cylindrical Storage def "Smoke Test: Correct thermal cylindrical storage throws no exception"() { given: - def cylindricalStorageInput = ThermalUnitInputTestData.cylindricStorageInput + def cylindricalStorageInput = ThermalUnitInputTestData.cylindricalStorageInput when: ValidationUtils.check(cylindricalStorageInput) @@ -107,9 +114,9 @@ class ThermalUnitValidationUtilsTest extends Specification { ex.message == expectedException.message where: - invalidCylindricalStorage || expectedSize || expectedException - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, storageVolumeLvlMin, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower than outlet temperature", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(100, StandardUnits.VOLUME), Quantities.getQuantity(200, StandardUnits.VOLUME), inletTemp, returnTemp, c) || 1 || new InvalidEntityException("Minimum permissible storage volume of the cylindrical storage cannot be higher than overall available storage volume", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), Quantities.getQuantity(-200, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -200 ㎥, -1.05 kWh/K*m³", invalidCylindricalStorage) + invalidCylindricalStorage || expectedSize || expectedException + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, storageVolumeLvlMin, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, pThermalMax) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower than outlet temperature", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(100, StandardUnits.VOLUME), Quantities.getQuantity(200, StandardUnits.VOLUME), inletTemp, returnTemp, c, pThermalMax) || 1 || new InvalidEntityException("Minimum permissible storage volume of the cylindrical storage cannot be higher than overall available storage volume", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), Quantities.getQuantity(-200, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -200 ㎥, -1.05 kWh/K*m³, -20 kW", invalidCylindricalStorage) } } diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index eca3b3d39..c5d0ceb77 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -27,6 +27,7 @@ import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.profile.StandardLoadProfile import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.interfaces.* +import org.testcontainers.shaded.org.checkerframework.checker.units.qual.A import tech.units.indriya.ComparableQuantity import tech.units.indriya.quantity.Quantities @@ -174,6 +175,9 @@ class SystemParticipantTestData { public static final ComparableQuantity returnTemp = Quantities.getQuantity(80, TEMPERATURE) public static final ComparableQuantity c = Quantities.getQuantity( 1, SPECIFIC_HEAT_CAPACITY) + public static final ComparableQuantity pThermalMax = Quantities.getQuantity( + 20, ACTIVE_POWER_IN) + public static final ThermalStorageInput thermalStorage = new CylindricalStorageInput( UUID.fromString("8851813b-3a7d-4fee-874b-4df9d724e4b3"), "test_cylindricThermalStorage", @@ -184,7 +188,9 @@ class SystemParticipantTestData { storageVolumeLvlMin, inletTemp, returnTemp, - c + c, + pThermalMax + ) public static final ChpInput chpInput = new ChpInput( diff --git a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy index 2802dc2da..1f132d43a 100644 --- a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy @@ -36,6 +36,9 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { private static final ComparableQuantity TARGET_TEMPERATURE = Quantities.getQuantity(20, StandardUnits.TEMPERATURE) private static final ComparableQuantity UPPER_TEMPERATURE_LIMIT = Quantities.getQuantity(25, StandardUnits.TEMPERATURE) private static final ComparableQuantity LOWER_TEMPERATURE_LIMIT = Quantities.getQuantity(15, StandardUnits.TEMPERATURE) + private static final String HOUSING_TYPE = "house" + private static final Integer NUMBER_INHABITANTS = 2 + public static final thermalHouseInput = new ThermalHouseInput( thermalUnitUuid, "test_thermalHouseInput", @@ -46,16 +49,19 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, - LOWER_TEMPERATURE_LIMIT) + LOWER_TEMPERATURE_LIMIT, + HOUSING_TYPE, + NUMBER_INHABITANTS) - // thermal cylindric storage input + // thermal cylindrical storage input private static final ComparableQuantity storageVolumeLvl = Quantities.getQuantity(100, StandardUnits.VOLUME) private static final ComparableQuantity storageVolumeLvlMin = Quantities.getQuantity(10, StandardUnits.VOLUME) private static final ComparableQuantity inletTemp = Quantities.getQuantity(100, StandardUnits.TEMPERATURE) private static final ComparableQuantity returnTemp = Quantities.getQuantity(80, StandardUnits.TEMPERATURE) private static final ComparableQuantity c = Quantities.getQuantity(1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY) + private static final ComparableQuantity pThermalMax = Quantities.getQuantity(20, StandardUnits.ACTIVE_POWER_IN) - public static final cylindricStorageInput = new CylindricalStorageInput( + public static final cylindricalStorageInput = new CylindricalStorageInput( thermalUnitUuid, "test_cylindricStorageInput", operator, @@ -65,5 +71,6 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { storageVolumeLvlMin, inletTemp, returnTemp, - c) + c, + pThermalMax) } diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv index 325d29445..0b0114091 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ -uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus,em -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 +uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,p_thermal_max,thermal_bus,em +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv index 4a11cda89..690c43217 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ -uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e +uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus,p_thermal_max +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e, 20.0 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv index a1a8cdbdc..9316f54b7 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv @@ -1,2 +1,2 @@ -uuid,id,operates_from,operates_until,operator,thermal_bus,eth_losses,eth_capa,target_temperature,upper_temperature_limit,lower_temperature_limit -717af017-cc69-406f-b452-e022d7fb516a,"test_thermalHouseInput",2020-03-24T15:11:31Z,2020-03-25T15:11:31Z,8f9682df-0744-4b58-a122-f0dc730f6510,0d95d7f2-49fb-4d49-8636-383a5220384e,10,20,20,25,15 \ No newline at end of file +uuid,id,operates_from,operates_until,operator,thermal_bus,eth_losses,eth_capa,target_temperature,upper_temperature_limit,lower_temperature_limit,housing_type,number_inhabitants +717af017-cc69-406f-b452-e022d7fb516a,"test_thermalHouseInput",2020-03-24T15:11:31Z,2020-03-25T15:11:31Z,8f9682df-0744-4b58-a122-f0dc730f6510,0d95d7f2-49fb-4d49-8636-383a5220384e,10,20,20,25,15,"house",2 \ No newline at end of file From 98c7e2f59dacddd3c2107a9abe3e8091a813f10c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 8 Aug 2024 17:09:44 +0200 Subject: [PATCH 02/70] fmt --- docs/readthedocs/models/input/thermal/thermalhouse.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/readthedocs/models/input/thermal/thermalhouse.md b/docs/readthedocs/models/input/thermal/thermalhouse.md index 018319d9e..02b8e0e1e 100644 --- a/docs/readthedocs/models/input/thermal/thermalhouse.md +++ b/docs/readthedocs/models/input/thermal/thermalhouse.md @@ -57,11 +57,11 @@ This reflects a simple shoe box with transmission losses - °C - Lower temperature boundary - * - housingType + * - housingType - -- - Type of building can either be house or flat - * - numberInhabititans + * - numberInhabititans - # - Number of people living in the house From 1f05eebf43395b1eab785b5697507eb14b2547d2 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 8 Aug 2024 17:14:50 +0200 Subject: [PATCH 03/70] codacy --- .../io/source/csv/CsvSystemParticipantSourceTest.groovy | 8 ++------ .../edu/ie3/test/common/ThermalUnitInputTestData.groovy | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) 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 197d2644b..b4c9ad0fa 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 @@ -5,18 +5,14 @@ */ package edu.ie3.datamodel.io.source.csv -import static edu.ie3.test.helper.EntityMap.map - import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.exceptions.SystemParticipantsException import edu.ie3.datamodel.io.source.* -import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData as sptd -import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity import spock.lang.Specification -import tech.units.indriya.ComparableQuantity -import tech.units.indriya.quantity.Quantities + +import static edu.ie3.test.helper.EntityMap.map class CsvSystemParticipantSourceTest extends Specification implements CsvTestDataMeta { diff --git a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy index 1f132d43a..c52dcc100 100644 --- a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy @@ -41,7 +41,7 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { public static final thermalHouseInput = new ThermalHouseInput( thermalUnitUuid, - "test_thermalHouseInput", + "testThermalHouseInput", operator, operationTime, thermalBus, @@ -63,7 +63,7 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { public static final cylindricalStorageInput = new CylindricalStorageInput( thermalUnitUuid, - "test_cylindricStorageInput", + "testCylindricStorageInput", operator, operationTime, thermalBus, From 25cbcc1b6f14a1811f8407d609b2db8d63c9f8fc Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 8 Aug 2024 17:16:10 +0200 Subject: [PATCH 04/70] fmt --- .../io/source/csv/CsvSystemParticipantSourceTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 b4c9ad0fa..67316ab30 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 @@ -5,6 +5,8 @@ */ package edu.ie3.datamodel.io.source.csv +import static edu.ie3.test.helper.EntityMap.map + import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.exceptions.SystemParticipantsException import edu.ie3.datamodel.io.source.* @@ -12,8 +14,6 @@ import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData as sptd import spock.lang.Specification -import static edu.ie3.test.helper.EntityMap.map - class CsvSystemParticipantSourceTest extends Specification implements CsvTestDataMeta { def "A SystemParticipantSource with csv input should provide an instance of SystemParticipants based on valid input data correctly"() { From ed0bb52860cb022ff3a19ec2722477dceba339ac Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 8 Aug 2024 17:19:51 +0200 Subject: [PATCH 05/70] fix test after codacy fix --- .../datamodel/io/source/csv/_thermal/thermal_house_input.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv index 9316f54b7..87dcf4374 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/thermal_house_input.csv @@ -1,2 +1,2 @@ uuid,id,operates_from,operates_until,operator,thermal_bus,eth_losses,eth_capa,target_temperature,upper_temperature_limit,lower_temperature_limit,housing_type,number_inhabitants -717af017-cc69-406f-b452-e022d7fb516a,"test_thermalHouseInput",2020-03-24T15:11:31Z,2020-03-25T15:11:31Z,8f9682df-0744-4b58-a122-f0dc730f6510,0d95d7f2-49fb-4d49-8636-383a5220384e,10,20,20,25,15,"house",2 \ No newline at end of file +717af017-cc69-406f-b452-e022d7fb516a,"testThermalHouseInput",2020-03-24T15:11:31Z,2020-03-25T15:11:31Z,8f9682df-0744-4b58-a122-f0dc730f6510,0d95d7f2-49fb-4d49-8636-383a5220384e,10,20,20,25,15,"house",2 \ No newline at end of file From e1cb1b3eadb1156d4533b2b1c488096e67f35f67 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 09:36:56 +0200 Subject: [PATCH 06/70] add domesticHotWaterStorage --- .../input/thermal/domestichotwaterstorage.md | 68 +++++ docs/readthedocs/models/models.md | 1 + .../DomesticHotWaterStorageInputFactory.java | 73 +++++ .../processor/input/InputEntityProcessor.java | 3 + .../datamodel/io/source/ThermalSource.java | 60 +++- .../io/source/csv/CsvThermalGridSource.java | 20 +- .../models/input/container/ThermalGrid.java | 60 +++- .../thermal/DomesticHotWaterStorageInput.java | 269 ++++++++++++++++++ .../input/thermal/ThermalHouseInput.java | 7 +- .../io/processor/ProcessorProviderTest.groovy | 2 + .../datamodel/io/sink/CsvFileSinkTest.groovy | 45 +-- .../csv/CsvThermalGridSourceTest.groovy | 3 +- .../input/container/ThermalGridTest.groovy | 27 +- .../DomesticHotWaterStorageInputTest.groovy | 62 ++++ .../common/ThermalUnitInputTestData.groovy | 17 +- 15 files changed, 659 insertions(+), 58 deletions(-) create mode 100644 docs/readthedocs/models/input/thermal/domestichotwaterstorage.md create mode 100644 src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java create mode 100644 src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java create mode 100644 src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy diff --git a/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md b/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md new file mode 100644 index 000000000..6d4ad99f9 --- /dev/null +++ b/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md @@ -0,0 +1,68 @@ +(domestichotwaterstorage-model)= + +# Domestic Hot Water Storage + +Model of a domestic hot water storage using a fluent to store thermal energy. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 1 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - thermalBus + - -- + - Connection point to the thermal system + + * - storageVolumeLvl + - m³ + - Overall available storage volume + + * - storageVolumeLvlMin + - m³ + - Minimum permissible storage volume + + * - inletTemp + - °C + - Temperature of the inlet + + * - returnTemp + - °C + - Temperature of the outlet + + * - c + - kWh / (K :math:`\cdot` m³) + - Specific heat capacity of the storage medium + + * - pThermalMax + - kW + - Maximum permissible thermal power of the storage + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/models.md b/docs/readthedocs/models/models.md index 56c314ac9..f49d958b6 100644 --- a/docs/readthedocs/models/models.md +++ b/docs/readthedocs/models/models.md @@ -129,6 +129,7 @@ maxdepth: 1 input/thermal/thermalbus input/thermal/thermalhouse input/thermal/cylindricalstorage +input/thermal/domestichotwaterstorage ``` ### Participant Related Models diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java new file mode 100644 index 000000000..b311d7f27 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java @@ -0,0 +1,73 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.factory.input; + +import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput; +import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; +import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; +import java.util.UUID; +import javax.measure.quantity.Power; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Volume; +import tech.units.indriya.ComparableQuantity; + +public class DomesticHotWaterStorageInputFactory + extends AssetInputEntityFactory { + private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; + private static final String STORAGE_VOLUME_LVL_MIN = "storageVolumeLvlMin"; + private static final String INLET_TEMP = "inletTemp"; + private static final String RETURN_TEMP = "returnTemp"; + private static final String C = "c"; + private static final String P_THERMAL_MAX = "pThermalMax"; + + public DomesticHotWaterStorageInputFactory() { + super(DomesticHotWaterStorageInput.class); + } + + @Override + protected String[] getAdditionalFields() { + return new String[] { + STORAGE_VOLUME_LVL, STORAGE_VOLUME_LVL_MIN, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX + }; + } + + @Override + protected DomesticHotWaterStorageInput buildModel( + ThermalUnitInputEntityData data, + UUID uuid, + String id, + OperatorInput operator, + OperationTime operationTime) { + final ThermalBusInput bus = data.getBusInput(); + final ComparableQuantity storageVolumeLvl = + data.getQuantity(STORAGE_VOLUME_LVL, StandardUnits.VOLUME); + final ComparableQuantity storageVolumeLvlMin = + data.getQuantity(STORAGE_VOLUME_LVL_MIN, StandardUnits.VOLUME); + final ComparableQuantity inletTemp = + data.getQuantity(INLET_TEMP, StandardUnits.TEMPERATURE); + final ComparableQuantity returnTemp = + data.getQuantity(RETURN_TEMP, StandardUnits.TEMPERATURE); + final ComparableQuantity c = + data.getQuantity(C, StandardUnits.SPECIFIC_HEAT_CAPACITY); + final ComparableQuantity pThermalMax = + data.getQuantity(P_THERMAL_MAX, StandardUnits.ACTIVE_POWER_IN); + return new DomesticHotWaterStorageInput( + uuid, + id, + operator, + operationTime, + bus, + storageVolumeLvl, + storageVolumeLvlMin, + inletTemp, + returnTemp, + c, + pThermalMax); + } +} diff --git a/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java index d21212531..9c6eaa892 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java @@ -18,6 +18,7 @@ import edu.ie3.datamodel.models.input.system.*; import edu.ie3.datamodel.models.input.system.type.*; import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput; +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput; import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput; import java.util.List; @@ -61,6 +62,8 @@ public class InputEntityProcessor extends EntityProcessor { /* -- ThermalUnitInput */ ThermalHouseInput.class, CylindricalStorageInput.class, + DomesticHotWaterStorageInput.class, + /* - GraphicInput */ NodeGraphicInput.class, LineGraphicInput.class, diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index f3334600d..3da565756 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -9,10 +9,7 @@ import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.input.*; import edu.ie3.datamodel.models.input.OperatorInput; -import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput; -import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; -import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput; -import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput; +import edu.ie3.datamodel.models.input.thermal.*; import edu.ie3.datamodel.utils.Try; import java.util.Map; import java.util.Set; @@ -34,6 +31,7 @@ public class ThermalSource extends AssetEntitySource { // factories private final ThermalBusInputFactory thermalBusInputFactory; private final CylindricalStorageInputFactory cylindricalStorageInputFactory; + private final DomesticHotWaterStorageInputFactory domesticHotWaterStorageInputFactory; private final ThermalHouseInputFactory thermalHouseInputFactory; // enriching function @@ -51,6 +49,7 @@ public ThermalSource(TypeSource typeSource, DataSource dataSource) { this.thermalBusInputFactory = new ThermalBusInputFactory(); this.cylindricalStorageInputFactory = new CylindricalStorageInputFactory(); + this.domesticHotWaterStorageInputFactory = new DomesticHotWaterStorageInputFactory(); this.thermalHouseInputFactory = new ThermalHouseInputFactory(); } @@ -60,6 +59,10 @@ public void validate() throws ValidationException { Stream.of( validate(ThermalBusInput.class, dataSource, thermalBusInputFactory), validate(CylindricalStorageInput.class, dataSource, cylindricalStorageInputFactory), + validate( + DomesticHotWaterStorageInput.class, + dataSource, + domesticHotWaterStorageInputFactory), validate(ThermalHouseInput.class, dataSource, thermalHouseInputFactory)), "Validation") .transformF(FailedValidationException::new) @@ -122,6 +125,7 @@ public Map getThermalBuses(Map opera */ public Map getThermalStorages() throws SourceException { return getCylindricalStorages().stream().collect(toMap()); + // FIXME } /** @@ -214,6 +218,23 @@ public Set getCylindricalStorages() throws SourceExcept return getCylindricalStorages(operators, thermalBuses); } + /** + * Returns a unique set of {@link DomesticHotWaterStorageInput} 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 DomesticHotWaterStorageInput} which has to be + * checked manually, as {@link DomesticHotWaterStorageInput#equals(Object)} is NOT restricted on + * the uuid of {@link DomesticHotWaterStorageInput}. + * + * @return a set of object- and uuid-unique {@link DomesticHotWaterStorageInput} entities + */ + public Set getDomesticHotWaterStorages() throws SourceException { + Map operators = typeSource.getOperators(); + Map thermalBuses = getThermalBuses(); + + return getDomesticHotWaterStorages(operators, thermalBuses); + } + /** * Returns a set of {@link CylindricalStorageInput} instances. * @@ -244,4 +265,35 @@ public Set getCylindricalStorages( data -> thermalUnitEnricher.apply(data, operators, thermalBuses)) .collect(toSet()); } + + /** + * Returns a set of {@link DomesticHotWaterStorageInput} 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 DomesticHotWaterStorageInput} which has to be + * checked manually, as {@link DomesticHotWaterStorageInput#equals(Object)} is NOT restricted on + * the uuid of {@link DomesticHotWaterStorageInput}. + * + *

    In contrast to {@link #getDomesticHotWaterStorages()} this interface provides the ability to + * pass in an already existing set of {@link OperatorInput} entities, the {@link + * DomesticHotWaterStorageInput} 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 it's up to the concrete implementation of an + * empty set or 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} entities + * @param thermalBuses a set of object- and uuid-unique {@link ThermalBusInput} entities + * @return a set of object- and uuid-unique {@link DomesticHotWaterStorageInput} entities + */ + public Set getDomesticHotWaterStorages( + Map operators, Map thermalBuses) + throws SourceException { + return getEntities( + DomesticHotWaterStorageInput.class, + dataSource, + domesticHotWaterStorageInputFactory, + data -> thermalUnitEnricher.apply(data, operators, thermalBuses)) + .collect(toSet()); + } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java index 377f54508..8673875e1 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java @@ -70,12 +70,16 @@ public static List read( Try, SourceException> houses = Try.of( () -> thermalSource.getThermalHouses(operators, buses).values(), SourceException.class); - Try, SourceException> storages = + Try, SourceException> heatStorages = + Try.of( + () -> thermalSource.getThermalStorages(operators, buses).values(), + SourceException.class); + Try, SourceException> waterStorages = Try.of( () -> thermalSource.getThermalStorages(operators, buses).values(), SourceException.class); - List exceptions = Try.getExceptions(houses, storages); + List exceptions = Try.getExceptions(houses, heatStorages, waterStorages); if (!exceptions.isEmpty()) { throw new SourceException( @@ -87,16 +91,20 @@ public static List read( Map> houseInputs = houses.getOrThrow().stream() .collect(Collectors.groupingBy(ThermalUnitInput::getThermalBus, Collectors.toSet())); - Map> storageInputs = - storages.getOrThrow().stream() + Map> heatStorageInputs = + heatStorages.getOrThrow().stream() + .collect(Collectors.groupingBy(ThermalUnitInput::getThermalBus, Collectors.toSet())); + Map> waterStorageInputs = + waterStorages.getOrThrow().stream() .collect(Collectors.groupingBy(ThermalUnitInput::getThermalBus, Collectors.toSet())); return buses.values().stream() .map( bus -> { Set h = houseInputs.getOrDefault(bus, emptySet()); - Set s = storageInputs.getOrDefault(bus, emptySet()); - return new ThermalGrid(bus, h, s); + Set hs = heatStorageInputs.getOrDefault(bus, emptySet()); + Set ws = waterStorageInputs.getOrDefault(bus, emptySet()); + return new ThermalGrid(bus, h, hs, ws); }) .toList(); } diff --git a/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java b/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java index b3616bc70..0a46b9ce2 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java +++ b/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java @@ -18,21 +18,31 @@ * edu.ie3.datamodel.models.input.thermal.ThermalUnitInput}s */ public record ThermalGrid( - ThermalBusInput bus, Set houses, Set storages) + ThermalBusInput bus, + Set houses, + Set heatStorages, + Set domesticHotWaterStorages) implements InputContainer { public ThermalGrid( ThermalBusInput bus, Collection houses, - Collection storages) { - this(bus, new HashSet<>(houses), new HashSet<>(storages)); + Collection heatStorages, + Collection domesticHotWaterStorages) { + this( + bus, + new HashSet<>(houses), + new HashSet<>(heatStorages), + new HashSet<>(domesticHotWaterStorages)); } @Override public List allEntitiesAsList() { - List ret = new ArrayList<>(houses.size() + storages.size() + 1); + List ret = + new ArrayList<>(houses.size() + heatStorages.size() + domesticHotWaterStorages.size() + 1); ret.add(bus); ret.addAll(houses); - ret.addAll(storages); + ret.addAll(heatStorages); + ret.addAll(domesticHotWaterStorages); return ret; } @@ -48,8 +58,10 @@ public String toString() { + bus + ", #houses=" + houses.size() - + ", #storages=" - + storages.size() + + ", #heatStorages=" + + heatStorages.size() + + ", #domesticHotWaterStorages=" + + domesticHotWaterStorages.size() + '}'; } @@ -63,7 +75,8 @@ public String toString() { public static class ThermalGridCopyBuilder implements InputContainerCopyBuilder { private ThermalBusInput bus; private Set houses; - private Set storages; + private Set heatStorages; + private Set domesticHotWaterStorages; /** * Constructor for {@link ThermalGridCopyBuilder} @@ -73,7 +86,8 @@ public static class ThermalGridCopyBuilder implements InputContainerCopyBuilder< protected ThermalGridCopyBuilder(ThermalGrid thermalGrid) { this.bus = thermalGrid.bus(); this.houses = thermalGrid.houses(); - this.storages = thermalGrid.storages(); + this.heatStorages = thermalGrid.heatStorages(); + this.domesticHotWaterStorages = thermalGrid.domesticHotWaterStorages(); } /** @@ -101,11 +115,23 @@ public ThermalGridCopyBuilder houses(Set houses) { /** * Method to alter {@link ThermalStorageInput} * - * @param storages altered thermal storages + * @param heatStorages altered thermal storages * @return this instance of {@link ThermalGridCopyBuilder} */ - public ThermalGridCopyBuilder storages(Set storages) { - this.storages = storages; + public ThermalGridCopyBuilder heatStorages(Set heatStorages) { + this.heatStorages = heatStorages; + return this; + } + + /** + * Method to alter {@link ThermalStorageInput} + * + * @param domesticHotWaterStorages altered thermal storages + * @return this instance of {@link ThermalGridCopyBuilder} + */ + public ThermalGridCopyBuilder domesticHotWaterStorages( + Set domesticHotWaterStorages) { + this.domesticHotWaterStorages = domesticHotWaterStorages; return this; } @@ -114,8 +140,12 @@ public ThermalGridCopyBuilder scale(Double factor) { houses.stream() .map(house -> house.copy().scale(factor).build()) .collect(Collectors.toSet())); - storages( - storages.stream() + heatStorages( + heatStorages.stream() + .map(storage -> storage.copy().scale(factor).build()) + .collect(Collectors.toSet())); + domesticHotWaterStorages( + domesticHotWaterStorages.stream() .map(storage -> storage.copy().scale(factor).build()) .collect(Collectors.toSet())); return this; @@ -123,7 +153,7 @@ public ThermalGridCopyBuilder scale(Double factor) { @Override public ThermalGrid build() { - return new ThermalGrid(bus, houses, storages); + return new ThermalGrid(bus, houses, heatStorages, domesticHotWaterStorages); } } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java new file mode 100644 index 000000000..9c712dd89 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -0,0 +1,269 @@ +/* + * © 2024. 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.thermal; + +import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; +import java.util.Objects; +import java.util.UUID; +import javax.measure.quantity.Power; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Volume; +import tech.units.indriya.ComparableQuantity; + +/** Thermal storage with cylindrical shape store hot tap water */ +public class DomesticHotWaterStorageInput extends ThermalStorageInput { + /** Available storage volume (typically in m³) */ + private final ComparableQuantity storageVolumeLvl; + /** Minimum permissible storage volume (typically in m³) */ + private final ComparableQuantity storageVolumeLvlMin; + /** Temperature of the inlet (typically in C) */ + private final ComparableQuantity inletTemp; + /** Temperature of the outlet (typically in C) */ + private final ComparableQuantity returnTemp; + /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ + private final ComparableQuantity c; + /** Maximum permissible thermal power (typically in kW) */ + private final ComparableQuantity pThermalMax; + + /** + * @param uuid Unique identifier of a cylindrical storage + * @param id Identifier of the thermal unit + * @param operator operator of the asset + * @param operationTime operation time of the asset + * @param bus Thermal bus, a thermal unit is connected to + * @param storageVolumeLvl Available storage volume + * @param storageVolumeLvlMin Minimum permissible storage volume + * @param inletTemp Temperature of the inlet + * @param returnTemp Temperature of the outlet + * @param c Specific heat capacity of the storage medium + * @param pThermalMax Maximum thermal power of the storage + */ + public DomesticHotWaterStorageInput( + UUID uuid, + String id, + OperatorInput operator, + OperationTime operationTime, + ThermalBusInput bus, + ComparableQuantity storageVolumeLvl, + ComparableQuantity storageVolumeLvlMin, + ComparableQuantity inletTemp, + ComparableQuantity returnTemp, + ComparableQuantity c, + ComparableQuantity pThermalMax) { + super(uuid, id, operator, operationTime, bus); + this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); + this.storageVolumeLvlMin = storageVolumeLvlMin.to(StandardUnits.VOLUME); + this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); + this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); + this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + } + + /** + * @param uuid Unique identifier of a cylindrical storage + * @param id Identifier of the thermal unit + * @param bus Thermal bus, a thermal unit is connected to + * @param storageVolumeLvl Available storage volume + * @param storageVolumeLvlMin Minimum permissible storage volume + * @param inletTemp Temperature of the inlet + * @param returnTemp Temperature of the outlet + * @param c Specific heat capacity of the storage medium + * @param pThermalMax Maximum thermal power of the storage + */ + public DomesticHotWaterStorageInput( + UUID uuid, + String id, + ThermalBusInput bus, + ComparableQuantity storageVolumeLvl, + ComparableQuantity storageVolumeLvlMin, + ComparableQuantity inletTemp, + ComparableQuantity returnTemp, + ComparableQuantity c, + ComparableQuantity pThermalMax) { + super(uuid, id, bus); + this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); + this.storageVolumeLvlMin = storageVolumeLvlMin.to(StandardUnits.VOLUME); + this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); + this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); + this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + } + + public ComparableQuantity getStorageVolumeLvl() { + return storageVolumeLvl; + } + + public ComparableQuantity getStorageVolumeLvlMin() { + return storageVolumeLvlMin; + } + + public ComparableQuantity getInletTemp() { + return inletTemp; + } + + public ComparableQuantity getReturnTemp() { + return returnTemp; + } + + public ComparableQuantity getC() { + return c; + } + + public ComparableQuantity getpThermalMax() { + return pThermalMax; + } + + @Override + public DomesticHotWaterStorageInputCopyBuilder copy() { + return new DomesticHotWaterStorageInputCopyBuilder(this); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof DomesticHotWaterStorageInput that)) return false; + if (!super.equals(o)) return false; + return storageVolumeLvl.equals(that.storageVolumeLvl) + && storageVolumeLvlMin.equals(that.storageVolumeLvlMin) + && inletTemp.equals(that.inletTemp) + && returnTemp.equals(that.returnTemp) + && c.equals(that.c) + && pThermalMax.equals(that.pThermalMax); + } + + @Override + public int hashCode() { + return Objects.hash( + super.hashCode(), + storageVolumeLvl, + storageVolumeLvlMin, + inletTemp, + returnTemp, + c, + pThermalMax); + } + + @Override + public String toString() { + return "DomesticHotWaterStorageInput{" + + "uuid=" + + getUuid() + + ", id=" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", bus=" + + getThermalBus().getUuid() + + ", storageVolumeLvl=" + + storageVolumeLvl + + ", storageVolumeLvlMin=" + + storageVolumeLvlMin + + ", inletTemp=" + + inletTemp + + ", returnTemp=" + + returnTemp + + ", c=" + + c + + ", pThermalMax=" + + pThermalMax + + '}'; + } + + /** + * A builder pattern based approach to create copies of {@link DomesticHotWaterStorageInput} + * entities with altered field values. For detailed field descriptions refer to java docs of + * {@link DomesticHotWaterStorageInput} + */ + public static class DomesticHotWaterStorageInputCopyBuilder + extends ThermalStorageInputCopyBuilder { + + private ComparableQuantity storageVolumeLvl; + private ComparableQuantity storageVolumeLvlMin; + private ComparableQuantity inletTemp; + private ComparableQuantity returnTemp; + private ComparableQuantity c; + private ComparableQuantity pThermalMax; + + private DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { + super(entity); + this.storageVolumeLvl = entity.getStorageVolumeLvl(); + this.storageVolumeLvlMin = entity.getStorageVolumeLvlMin(); + this.inletTemp = entity.getInletTemp(); + this.returnTemp = entity.getReturnTemp(); + this.c = entity.getC(); + this.pThermalMax = entity.getpThermalMax(); + } + + public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl( + ComparableQuantity storageVolumeLvl) { + this.storageVolumeLvl = storageVolumeLvl; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvlMin( + ComparableQuantity storageVolumeLvlMin) { + this.storageVolumeLvlMin = storageVolumeLvlMin; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder inletTemp( + ComparableQuantity inletTemp) { + this.inletTemp = inletTemp; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder returnTemp( + ComparableQuantity returnTemp) { + this.returnTemp = returnTemp; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder c(ComparableQuantity c) { + this.c = c; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder pThermalMax( + ComparableQuantity pThermalMax) { + this.pThermalMax = pThermalMax; + return this; + } + + @Override + public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { + storageVolumeLvl(storageVolumeLvl.multiply(factor)); + storageVolumeLvlMin(storageVolumeLvlMin.multiply(factor)); + pThermalMax(pThermalMax.multiply(factor)); + return this; + } + + @Override + public DomesticHotWaterStorageInput build() { + return new DomesticHotWaterStorageInput( + getUuid(), + getId(), + getOperator(), + getOperationTime(), + getThermalBus(), + storageVolumeLvl, + storageVolumeLvlMin, + inletTemp, + returnTemp, + c, + pThermalMax); + } + + @Override + protected DomesticHotWaterStorageInputCopyBuilder thisInstance() { + return this; + } + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java index a92e54da8..250ce365c 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java @@ -41,6 +41,8 @@ public class ThermalHouseInput extends ThermalSinkInput { * @param targetTemperature Desired target temperature of the thermal house model * @param upperTemperatureLimit Upper boundary temperature of the thermal house model * @param lowerTemperatureLimit Lower boundary temperature of the thermal house model + * @param housingType Type of the building: either house or flat + * @param numberInhabitants Number of inhabitants living in this house */ public ThermalHouseInput( UUID uuid, @@ -74,6 +76,8 @@ public ThermalHouseInput( * @param targetTemperature Desired target temperature of the thermal house model * @param upperTemperatureLimit Upper boundary temperature of the thermal house model * @param lowerTemperatureLimit Lower boundary temperature of the thermal house model + * @param housingType Type of the building: either house or flat + * @param numberInhabitants Number of inhabitants living in this house */ public ThermalHouseInput( UUID uuid, @@ -256,10 +260,11 @@ public ThermalHouseInputCopyBuilder numberInhabitants(Integer numberInhabitants) @Override public ThermalHouseInputCopyBuilder scale(Double factor) { - // scale losses as well as capacity to keep equal + // scale losses as well as capacity and number of inhabitants to keep equal // the time needed to heat a scaled house ethLosses(ethLosses.multiply(factor)); ethCapa(ethCapa.multiply(factor)); + numberInhabitants((int) Math.round(numberInhabitants.doubleValue() * factor)); return this; } diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy index b5e145799..257b8e33b 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy @@ -24,6 +24,7 @@ import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput import edu.ie3.datamodel.models.input.system.* import edu.ie3.datamodel.models.input.system.type.* import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalBusInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import edu.ie3.datamodel.models.result.CongestionResult @@ -86,6 +87,7 @@ class ProcessorProviderTest extends Specification implements TimeSeriesTestData /* -- ThermalUnitInput */ ThermalHouseInput, CylindricalStorageInput, + DomesticHotWaterStorageInput, /* - GraphicInput */ NodeGraphicInput, LineGraphicInput, 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 773f53c53..456b3ca19 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy @@ -5,6 +5,8 @@ */ package edu.ie3.datamodel.io.sink +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput + import static edu.ie3.util.quantities.PowerSystemUnits.DEGREE_GEOM import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE import static tech.units.indriya.unit.Units.PERCENT @@ -118,26 +120,27 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { given: CsvFileSink csvFileSink = new CsvFileSink(testBaseFolderPath, new ProcessorProvider([ - new ResultEntityProcessor(PvResult), - new ResultEntityProcessor(WecResult), - new ResultEntityProcessor(EvResult), - new ResultEntityProcessor(EvcsResult), - new ResultEntityProcessor(EmResult), - new ResultEntityProcessor(FlexOptionsResult), - new InputEntityProcessor(Transformer2WInput), - new InputEntityProcessor(NodeInput), - new InputEntityProcessor(EvcsInput), - new InputEntityProcessor(Transformer2WTypeInput), - new InputEntityProcessor(LineGraphicInput), - new InputEntityProcessor(NodeGraphicInput), - new InputEntityProcessor(CylindricalStorageInput), - new InputEntityProcessor(ThermalHouseInput), - new InputEntityProcessor(OperatorInput), - new InputEntityProcessor(LineInput), - new InputEntityProcessor(ThermalBusInput), - new InputEntityProcessor(LineTypeInput), - new InputEntityProcessor(LoadInput), - new InputEntityProcessor(EmInput) + new ResultEntityProcessor(PvResult), + new ResultEntityProcessor(WecResult), + new ResultEntityProcessor(EvResult), + new ResultEntityProcessor(EvcsResult), + new ResultEntityProcessor(EmResult), + new ResultEntityProcessor(FlexOptionsResult), + new InputEntityProcessor(Transformer2WInput), + new InputEntityProcessor(NodeInput), + new InputEntityProcessor(EvcsInput), + new InputEntityProcessor(Transformer2WTypeInput), + new InputEntityProcessor(LineGraphicInput), + new InputEntityProcessor(NodeGraphicInput), + new InputEntityProcessor(CylindricalStorageInput), + new InputEntityProcessor(DomesticHotWaterStorageInput), + new InputEntityProcessor(ThermalHouseInput), + new InputEntityProcessor(OperatorInput), + new InputEntityProcessor(LineInput), + new InputEntityProcessor(ThermalBusInput), + new InputEntityProcessor(LineTypeInput), + new InputEntityProcessor(LoadInput), + new InputEntityProcessor(EmInput) ], [] as Map), new FileNamingStrategy(), ",") @@ -166,6 +169,7 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { GridTestData.lineGraphicCtoD, GridTestData.nodeGraphicC, ThermalUnitInputTestData.cylindricalStorageInput, + ThermalUnitInputTestData.domesticHotWaterStorageInput, ThermalUnitInputTestData.thermalHouseInput, SystemParticipantTestData.evcsInput, SystemParticipantTestData.loadInput, @@ -185,6 +189,7 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { testBaseFolderPath.resolve("transformer_2_w_input.csv").toFile().exists() testBaseFolderPath.resolve("operator_input.csv").toFile().exists() testBaseFolderPath.resolve("cylindrical_storage_input.csv").toFile().exists() + testBaseFolderPath.resolve("domestic_hot_water_storage_input.csv").toFile().exists() testBaseFolderPath.resolve("line_graphic_input.csv").toFile().exists() testBaseFolderPath.resolve("line_input.csv").toFile().exists() testBaseFolderPath.resolve("operator_input.csv").toFile().exists() diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalGridSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalGridSourceTest.groovy index 57c1b2ec4..ce8b3c7a7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalGridSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalGridSourceTest.groovy @@ -18,7 +18,8 @@ class CsvThermalGridSourceTest extends Specification implements CsvTestDataMeta thermalGrids.get(0).with { def bus = it.bus() assert it.houses().every { it.thermalBus == bus } - assert it.storages().every { it.thermalBus == bus } + assert it.heatStorages().every { it.thermalBus == bus } + assert it.domesticHotWaterStorages().every { it.thermalBus == bus } } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy index fb8485acb..ca34f5270 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy @@ -6,6 +6,7 @@ package edu.ie3.datamodel.models.input.container import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalBusInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import spock.lang.Specification @@ -19,37 +20,43 @@ class ThermalGridTest extends Specification { Mock(ThermalHouseInput), Mock(ThermalHouseInput) ] - def thermalStorages = [Mock(CylindricalStorageInput)] - def thermalUnits = new ThermalGrid(thermalBus, thermalHouses, thermalStorages) + def heatStorages = [Mock(CylindricalStorageInput)] + def domesticHotWaterStorages = [ + Mock(DomesticHotWaterStorageInput) + ] + def thermalUnits = new ThermalGrid(thermalBus, thermalHouses, heatStorages, domesticHotWaterStorages) when: def actualAllEntities = thermalUnits.allEntitiesAsList() then: - actualAllEntities.size() == 1 + thermalHouses.size() + thermalStorages.size() + actualAllEntities.size() == 1 + thermalHouses.size() + heatStorages.size() + domesticHotWaterStorages.size() actualAllEntities.contains(thermalBus) actualAllEntities.containsAll(thermalHouses) - actualAllEntities.containsAll(thermalStorages) + actualAllEntities.containsAll(heatStorages) } def "A ThermalGrid's copy method should work as expected"() { given: def thermalBus = Mock(ThermalBusInput) def thermalHouses = [] - def thermalStorages = [] - def thermalGrid = new ThermalGrid(thermalBus, thermalHouses, thermalStorages) + def heatStorages = [] + def domesticHotWaterStorages = [] + def thermalGrid = new ThermalGrid(thermalBus, thermalHouses, heatStorages,domesticHotWaterStorages) def modifiedHouses = [Mock(ThermalHouseInput)] - def modifiedStorages = [Mock(CylindricalStorageInput)] - + def modifiedHeatStorages = [Mock(CylindricalStorageInput)] + def modifiedDomesticHotWaterStorages = [Mock(CylindricalStorageInput)] when: def modifiedThermalGrid = thermalGrid.copy() .houses(modifiedHouses as Set) - .storages(modifiedStorages as Set) + .heatStorages(modifiedHeatStorages as Set) + .domesticHotWaterStorages(modifiedDomesticHotWaterStorages as Set) .build() then: modifiedThermalGrid.houses().first() == modifiedHouses.get(0) - modifiedThermalGrid.storages().first() == modifiedStorages.get(0) + modifiedThermalGrid.heatStorages().first() == modifiedHeatStorages.get(0) + modifiedThermalGrid.domesticHotWaterStorages().first() == modifiedDomesticHotWaterStorages.get(0) } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy new file mode 100644 index 000000000..a8fb9adc6 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy @@ -0,0 +1,62 @@ +/* + * © 2021. 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.thermal + +import edu.ie3.test.common.ThermalUnitInputTestData +import spock.lang.Specification + + +class DomesticHotWaterStorageInputTest extends Specification { + + def "A DomesticHotWaterStorageInput copy method should work as expected"() { + given: + def domesticHotWaterStorageInput = ThermalUnitInputTestData.domesticHotWaterStorageInput + + when: + def alteredUnit = domesticHotWaterStorageInput.copy().storageVolumeLvl(ThermalUnitInputTestData.storageVolumeLvl) + .storageVolumeLvlMin(ThermalUnitInputTestData.storageVolumeLvlMin).inletTemp(ThermalUnitInputTestData.inletTemp) + .returnTemp(ThermalUnitInputTestData.returnTemp).c(ThermalUnitInputTestData.c) + .thermalBus(ThermalUnitInputTestData.thermalBus).build() + + + then: + alteredUnit.with { + assert uuid == domesticHotWaterStorageInput.uuid + assert id == domesticHotWaterStorageInput.id + assert operator == domesticHotWaterStorageInput.operator + assert operationTime == domesticHotWaterStorageInput.operationTime + assert thermalBus == domesticHotWaterStorageInput.thermalBus + assert storageVolumeLvl == ThermalUnitInputTestData.storageVolumeLvl + assert storageVolumeLvlMin == ThermalUnitInputTestData.storageVolumeLvlMin + assert inletTemp == ThermalUnitInputTestData.inletTemp + assert returnTemp == ThermalUnitInputTestData.returnTemp + assert c == ThermalUnitInputTestData.c + } + } + + def "Scaling a CylindricalStorageInput via builder should work as expected"() { + given: + def domesticHotWaterStorageInput = ThermalUnitInputTestData.domesticHotWaterStorageInput + + when: + def alteredUnit = domesticHotWaterStorageInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == domesticHotWaterStorageInput.uuid + assert id == domesticHotWaterStorageInput.id + assert operator == domesticHotWaterStorageInput.operator + assert operationTime == domesticHotWaterStorageInput.operationTime + assert thermalBus == domesticHotWaterStorageInput.thermalBus + assert storageVolumeLvl == domesticHotWaterStorageInput.storageVolumeLvl * 2d + assert storageVolumeLvlMin == domesticHotWaterStorageInput.storageVolumeLvlMin * 2d + assert inletTemp == domesticHotWaterStorageInput.inletTemp + assert returnTemp == domesticHotWaterStorageInput.returnTemp + assert c == domesticHotWaterStorageInput.c + assert pThermalMax == domesticHotWaterStorageInput.pThermalMax * 2d + } + } +} diff --git a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy index c52dcc100..a85899e57 100644 --- a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy @@ -9,6 +9,7 @@ import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.interfaces.HeatCapacity @@ -17,6 +18,7 @@ import edu.ie3.util.quantities.interfaces.ThermalConductance import tech.units.indriya.ComparableQuantity import tech.units.indriya.quantity.Quantities +import javax.measure.quantity.Power import javax.measure.quantity.Temperature import javax.measure.quantity.Volume @@ -59,7 +61,7 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { private static final ComparableQuantity inletTemp = Quantities.getQuantity(100, StandardUnits.TEMPERATURE) private static final ComparableQuantity returnTemp = Quantities.getQuantity(80, StandardUnits.TEMPERATURE) private static final ComparableQuantity c = Quantities.getQuantity(1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY) - private static final ComparableQuantity pThermalMax = Quantities.getQuantity(20, StandardUnits.ACTIVE_POWER_IN) + private static final ComparableQuantity pThermalMax = Quantities.getQuantity(20, StandardUnits.ACTIVE_POWER_IN) public static final cylindricalStorageInput = new CylindricalStorageInput( thermalUnitUuid, @@ -73,4 +75,17 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { returnTemp, c, pThermalMax) + + public static final domesticHotWaterStorageInput = new DomesticHotWaterStorageInput( + thermalUnitUuid, + "testDomesticHotWaterStorageInput", + operator, + operationTime, + thermalBus, + storageVolumeLvl, + storageVolumeLvlMin, + inletTemp, + returnTemp, + c, + pThermalMax) } From ea750dd9c11247ca211cf93e86da9ec642bb5365 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 09:47:18 +0200 Subject: [PATCH 07/70] further changes for domestic hot water storage --- .../datamodel/io/source/ThermalSource.java | 20 ++++++++++++++++--- .../thermal/DomesticHotWaterStorageInput.java | 4 ++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 3da565756..f4cd02950 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -14,6 +14,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -124,8 +125,14 @@ public Map getThermalBuses(Map opera * @return a map of UUID to object- and uuid-unique {@link ThermalStorageInput} entities */ public Map getThermalStorages() throws SourceException { - return getCylindricalStorages().stream().collect(toMap()); - // FIXME + return Stream.concat( + getCylindricalStorages().stream(), + getDomesticHotWaterStorages().stream() + ) + .collect(Collectors.toMap( + ThermalStorageInput::getUuid, + storage -> storage + )); } /** @@ -150,7 +157,14 @@ public Map getThermalStorages() throws SourceExceptio public Map getThermalStorages( Map operators, Map thermalBuses) throws SourceException { - return getCylindricalStorages(operators, thermalBuses).stream().collect(toMap()); + return Stream.concat( + getCylindricalStorages(operators, thermalBuses).stream(), + getDomesticHotWaterStorages(operators, thermalBuses).stream() + ) + .collect(Collectors.toMap( + ThermalStorageInput::getUuid, + storage -> storage + )); } /** diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 9c712dd89..270ea7519 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -32,7 +32,7 @@ public class DomesticHotWaterStorageInput extends ThermalStorageInput { private final ComparableQuantity pThermalMax; /** - * @param uuid Unique identifier of a cylindrical storage + * @param uuid Unique identifier of a domestic hot water storage * @param id Identifier of the thermal unit * @param operator operator of the asset * @param operationTime operation time of the asset @@ -66,7 +66,7 @@ public DomesticHotWaterStorageInput( } /** - * @param uuid Unique identifier of a cylindrical storage + * @param uuid Unique identifier of a domestic hot water storage * @param id Identifier of the thermal unit * @param bus Thermal bus, a thermal unit is connected to * @param storageVolumeLvl Available storage volume From 591a972dacf6c8f32af921f6e1f738ce74176b35 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 10:44:41 +0200 Subject: [PATCH 08/70] validation of domestic hot water storage --- .../DomesticHotWaterStorageInputFactory.java | 1 - .../thermal/CylindricalStorageInput.java | 2 +- .../thermal/DomesticHotWaterStorageInput.java | 24 --------- .../ThermalUnitValidationUtils.java | 54 +++++++++++++++++++ .../DomesticHotWaterStorageInputTest.groovy | 4 +- .../ThermalUnitValidationUtilsTest.groovy | 29 ++++++++-- .../common/ThermalUnitInputTestData.groovy | 1 - 7 files changed, 80 insertions(+), 35 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java index b311d7f27..a7a176310 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java @@ -64,7 +64,6 @@ protected DomesticHotWaterStorageInput buildModel( operationTime, bus, storageVolumeLvl, - storageVolumeLvlMin, inletTemp, returnTemp, c, diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 63c2758af..6ca1bf1cd 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -126,7 +126,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax);); + return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } @Override diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 270ea7519..b5da3207e 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -20,8 +20,6 @@ public class DomesticHotWaterStorageInput extends ThermalStorageInput { /** Available storage volume (typically in m³) */ private final ComparableQuantity storageVolumeLvl; - /** Minimum permissible storage volume (typically in m³) */ - private final ComparableQuantity storageVolumeLvlMin; /** Temperature of the inlet (typically in C) */ private final ComparableQuantity inletTemp; /** Temperature of the outlet (typically in C) */ @@ -38,7 +36,6 @@ public class DomesticHotWaterStorageInput extends ThermalStorageInput { * @param operationTime operation time of the asset * @param bus Thermal bus, a thermal unit is connected to * @param storageVolumeLvl Available storage volume - * @param storageVolumeLvlMin Minimum permissible storage volume * @param inletTemp Temperature of the inlet * @param returnTemp Temperature of the outlet * @param c Specific heat capacity of the storage medium @@ -51,14 +48,12 @@ public DomesticHotWaterStorageInput( OperationTime operationTime, ThermalBusInput bus, ComparableQuantity storageVolumeLvl, - ComparableQuantity storageVolumeLvlMin, ComparableQuantity inletTemp, ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { super(uuid, id, operator, operationTime, bus); this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.storageVolumeLvlMin = storageVolumeLvlMin.to(StandardUnits.VOLUME); this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); @@ -70,7 +65,6 @@ public DomesticHotWaterStorageInput( * @param id Identifier of the thermal unit * @param bus Thermal bus, a thermal unit is connected to * @param storageVolumeLvl Available storage volume - * @param storageVolumeLvlMin Minimum permissible storage volume * @param inletTemp Temperature of the inlet * @param returnTemp Temperature of the outlet * @param c Specific heat capacity of the storage medium @@ -88,7 +82,6 @@ public DomesticHotWaterStorageInput( ComparableQuantity pThermalMax) { super(uuid, id, bus); this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.storageVolumeLvlMin = storageVolumeLvlMin.to(StandardUnits.VOLUME); this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); @@ -99,10 +92,6 @@ public ComparableQuantity getStorageVolumeLvl() { return storageVolumeLvl; } - public ComparableQuantity getStorageVolumeLvlMin() { - return storageVolumeLvlMin; - } - public ComparableQuantity getInletTemp() { return inletTemp; } @@ -130,7 +119,6 @@ public boolean equals(Object o) { if (!(o instanceof DomesticHotWaterStorageInput that)) return false; if (!super.equals(o)) return false; return storageVolumeLvl.equals(that.storageVolumeLvl) - && storageVolumeLvlMin.equals(that.storageVolumeLvlMin) && inletTemp.equals(that.inletTemp) && returnTemp.equals(that.returnTemp) && c.equals(that.c) @@ -142,7 +130,6 @@ public int hashCode() { return Objects.hash( super.hashCode(), storageVolumeLvl, - storageVolumeLvlMin, inletTemp, returnTemp, c, @@ -164,8 +151,6 @@ public String toString() { + getThermalBus().getUuid() + ", storageVolumeLvl=" + storageVolumeLvl - + ", storageVolumeLvlMin=" - + storageVolumeLvlMin + ", inletTemp=" + inletTemp + ", returnTemp=" @@ -195,7 +180,6 @@ public static class DomesticHotWaterStorageInputCopyBuilder private DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); this.storageVolumeLvl = entity.getStorageVolumeLvl(); - this.storageVolumeLvlMin = entity.getStorageVolumeLvlMin(); this.inletTemp = entity.getInletTemp(); this.returnTemp = entity.getReturnTemp(); this.c = entity.getC(); @@ -208,12 +192,6 @@ public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl( return this; } - public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvlMin( - ComparableQuantity storageVolumeLvlMin) { - this.storageVolumeLvlMin = storageVolumeLvlMin; - return this; - } - public DomesticHotWaterStorageInputCopyBuilder inletTemp( ComparableQuantity inletTemp) { this.inletTemp = inletTemp; @@ -240,7 +218,6 @@ public DomesticHotWaterStorageInputCopyBuilder pThermalMax( @Override public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { storageVolumeLvl(storageVolumeLvl.multiply(factor)); - storageVolumeLvlMin(storageVolumeLvlMin.multiply(factor)); pThermalMax(pThermalMax.multiply(factor)); return this; } @@ -254,7 +231,6 @@ public DomesticHotWaterStorageInput build() { getOperationTime(), getThermalBus(), storageVolumeLvl, - storageVolumeLvlMin, inletTemp, returnTemp, c, diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index 5db4e9c4d..5c4984f6f 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -124,6 +124,12 @@ private ThermalUnitValidationUtils() { logNotImplemented(thermalStorageInput); } + if (DomesticHotWaterStorageInput.class.isAssignableFrom(thermalStorageInput.getClass())) { + exceptions.addAll(checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); + } else { + logNotImplemented(thermalStorageInput); + } + return exceptions; } @@ -251,4 +257,52 @@ private static List> checkCylindricalStorage( return exceptions; } + /** + * Validates a domcesticHotWaterStorageInput if: + * + *

      + *
    • it is not null + *
    • its available storage volume is positive + *
    • its inlet temperature is equal/greater than the outlet temperature + *
    • its specific heat capacity is positive + *
    + * + * @param domesticHotWaterStorageInput DomesticHotWaterStorageInput to validate + * @return a list of try objects either containing an {@link InvalidEntityException} or an empty + * Success + */ + private static List> checkDomesticHotWaterStorage( + DomesticHotWaterStorageInput domesticHotWaterStorageInput) { + Try isNull = + checkNonNull(domesticHotWaterStorageInput, "a domestic hot water storage"); + + if (isNull.isFailure()) { + return List.of(isNull); + } + + List> exceptions = new ArrayList<>(); + + // Check if inlet temperature is higher/equal to outlet temperature + exceptions.add( + Try.ofVoid( + domesticHotWaterStorageInput + .getInletTemp() + .isLessThan(domesticHotWaterStorageInput.getReturnTemp()), + () -> + new InvalidEntityException( + "Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", + domesticHotWaterStorageInput))); + + exceptions.add( + Try.ofVoid( + () -> + detectZeroOrNegativeQuantities( + new Quantity[] { + domesticHotWaterStorageInput.getStorageVolumeLvl(), domesticHotWaterStorageInput.getC(), domesticHotWaterStorageInput.getpThermalMax() + }, + domesticHotWaterStorageInput), + InvalidEntityException.class)); + + return exceptions; + } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy index a8fb9adc6..92232c3b0 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy @@ -17,7 +17,7 @@ class DomesticHotWaterStorageInputTest extends Specification { when: def alteredUnit = domesticHotWaterStorageInput.copy().storageVolumeLvl(ThermalUnitInputTestData.storageVolumeLvl) - .storageVolumeLvlMin(ThermalUnitInputTestData.storageVolumeLvlMin).inletTemp(ThermalUnitInputTestData.inletTemp) + .inletTemp(ThermalUnitInputTestData.inletTemp) .returnTemp(ThermalUnitInputTestData.returnTemp).c(ThermalUnitInputTestData.c) .thermalBus(ThermalUnitInputTestData.thermalBus).build() @@ -30,7 +30,6 @@ class DomesticHotWaterStorageInputTest extends Specification { assert operationTime == domesticHotWaterStorageInput.operationTime assert thermalBus == domesticHotWaterStorageInput.thermalBus assert storageVolumeLvl == ThermalUnitInputTestData.storageVolumeLvl - assert storageVolumeLvlMin == ThermalUnitInputTestData.storageVolumeLvlMin assert inletTemp == ThermalUnitInputTestData.inletTemp assert returnTemp == ThermalUnitInputTestData.returnTemp assert c == ThermalUnitInputTestData.c @@ -52,7 +51,6 @@ class DomesticHotWaterStorageInputTest extends Specification { assert operationTime == domesticHotWaterStorageInput.operationTime assert thermalBus == domesticHotWaterStorageInput.thermalBus assert storageVolumeLvl == domesticHotWaterStorageInput.storageVolumeLvl * 2d - assert storageVolumeLvlMin == domesticHotWaterStorageInput.storageVolumeLvlMin * 2d assert inletTemp == domesticHotWaterStorageInput.inletTemp assert returnTemp == domesticHotWaterStorageInput.returnTemp assert c == domesticHotWaterStorageInput.c diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy index da13dc194..08b949abf 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy @@ -11,6 +11,7 @@ import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData @@ -113,9 +114,27 @@ class ThermalUnitValidationUtilsTest extends Specification { ex.message == expectedException.message where: - invalidCylindricalStorage || expectedSize || expectedException - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower than outlet temperature", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -200 ㎥, -1.05 kWh/K*m³, -20 kW", invalidCylindricalStorage) + invalidCylindricalStorage || expectedSize || expectedException + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower than outlet temperature", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidCylindricalStorage) } -} + + +def "ThermalUnitValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { + when: + List> exceptions = ThermalUnitValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() + + then: + exceptions.size() == expectedSize + Exception ex = exceptions.get(0).exception.get() + ex.class == expectedException.class + ex.message == expectedException.message + + where: + invalidDomesticHotWaterStorage || expectedSize || expectedException + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) + +}} diff --git a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy index 56d6f0e9c..81d302368 100644 --- a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy @@ -81,7 +81,6 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { operationTime, thermalBus, storageVolumeLvl, - storageVolumeLvlMin, inletTemp, returnTemp, c, From cad8a2c0bb406684c65fc6f8f5168cfd34c65c4b Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 10:45:24 +0200 Subject: [PATCH 09/70] rtd --- .../models/input/thermal/domestichotwaterstorage.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md b/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md index 6d4ad99f9..81b84879c 100644 --- a/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md +++ b/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md @@ -40,10 +40,6 @@ Model of a domestic hot water storage using a fluent to store thermal energy. - m³ - Overall available storage volume - * - storageVolumeLvlMin - - m³ - - Minimum permissible storage volume - * - inletTemp - °C - Temperature of the inlet From d0f0df4c7944f8b8731cd91dd5c7b11e4c970679 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 11:05:23 +0200 Subject: [PATCH 10/70] update puml --- docs/uml/main/input/ThermalDatamodelConcept.puml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/uml/main/input/ThermalDatamodelConcept.puml b/docs/uml/main/input/ThermalDatamodelConcept.puml index 3f275bc5b..d1fa7404c 100644 --- a/docs/uml/main/input/ThermalDatamodelConcept.puml +++ b/docs/uml/main/input/ThermalDatamodelConcept.puml @@ -107,6 +107,8 @@ package models { - targetTemperature: ComparableQuantity [°C] - upperTemperatureLimit: ComparableQuantity [°C] - lowerTemperatureLimit: ComparableQuantity [°C] + - houseType: String ['house' or 'flat'] + - numberInhabitants: Integer } ThermalHouseInput --|> ThermalSinkInput @@ -120,6 +122,14 @@ package models { - c: ComparableQuantity [kWh/(K*m³)] } CylindricalStorageInput --|> ThermalStorageInput + + class DomesticHotWaterStorageInput { + - storageVolumeLvl: ComparableQuantity [m³] + - inletTemp: ComparableQuantity [°C] + - returnTemp: ComparableQuantity [°C] + - c: ComparableQuantity [kWh/(K*m³)] + } + DomesticHotWaterStorageInput --|> ThermalStorageInput } } } From ef634680b5e444a41f777ed04c904b07df12cba6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 11:23:06 +0200 Subject: [PATCH 11/70] add DomesticHotWaterStorageInputFactoryTest --- .../DomesticHotWaterStorageInputFactory.java | 5 +- .../io/extractor/ExtractorTest.groovy | 6 ++ .../CylindricalStorageInputFactoryTest.groovy | 9 ++- ...sticHotWaterStorageInputFactoryTest.groovy | 62 +++++++++++++++++++ .../io/source/csv/CsvThermalSourceTest.groovy | 1 - .../common/SystemParticipantTestData.groovy | 5 +- 6 files changed, 75 insertions(+), 13 deletions(-) create mode 100644 src/test/groovy/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactoryTest.groovy diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java index a7a176310..dfc99beb7 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java @@ -20,7 +20,6 @@ public class DomesticHotWaterStorageInputFactory extends AssetInputEntityFactory { private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; - private static final String STORAGE_VOLUME_LVL_MIN = "storageVolumeLvlMin"; private static final String INLET_TEMP = "inletTemp"; private static final String RETURN_TEMP = "returnTemp"; private static final String C = "c"; @@ -33,7 +32,7 @@ public DomesticHotWaterStorageInputFactory() { @Override protected String[] getAdditionalFields() { return new String[] { - STORAGE_VOLUME_LVL, STORAGE_VOLUME_LVL_MIN, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX + STORAGE_VOLUME_LVL, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX }; } @@ -47,8 +46,6 @@ protected DomesticHotWaterStorageInput buildModel( final ThermalBusInput bus = data.getBusInput(); final ComparableQuantity storageVolumeLvl = data.getQuantity(STORAGE_VOLUME_LVL, StandardUnits.VOLUME); - final ComparableQuantity storageVolumeLvlMin = - data.getQuantity(STORAGE_VOLUME_LVL_MIN, StandardUnits.VOLUME); final ComparableQuantity inletTemp = data.getQuantity(INLET_TEMP, StandardUnits.TEMPERATURE); final ComparableQuantity returnTemp = diff --git a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy index 9c4968164..fd513bf33 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy @@ -140,6 +140,12 @@ class ExtractorTest extends Specification { tutd.cylindricalStorageInput.thermalBus.operator ] + tutd.domesticHotWaterStorageInput || [ + tutd.domesticHotWaterStorageInput.operator, + tutd.domesticHotWaterStorageInput.thermalBus, + tutd.domesticHotWaterStorageInput.thermalBus.operator + ] + tutd.thermalHouseInput || [ tutd.thermalHouseInput.operator, tutd.thermalHouseInput.thermalBus, diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy index 1065d1fba..e8d7f8989 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactoryTest.groovy @@ -32,11 +32,10 @@ class CylindricalStorageInputFactoryTest extends Specification implements Facto "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", "id" : "TestID", "storagevolumelvl" : "3", - "storagevolumelvlmin": "4", - "inlettemp" : "5", - "returntemp" : "6", - "c" : "7", - "pThermalMax" : "8" + "inlettemp" : "4", + "returntemp" : "5", + "c" : "6", + "pThermalMax" : "7" ] def inputClass = CylindricalStorageInput def thermalBusInput = Mock(ThermalBusInput) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactoryTest.groovy new file mode 100644 index 000000000..38849415d --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactoryTest.groovy @@ -0,0 +1,62 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.factory.input + +import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.models.OperationTime +import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput +import edu.ie3.datamodel.models.input.thermal.ThermalBusInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.helper.FactoryTestHelper +import spock.lang.Specification + +class DomesticHotWaterStorageInputFactoryTest extends Specification implements FactoryTestHelper { + def "A DomesticHotWaterStorageInputFactory should contain exactly the expected class for parsing"() { + given: + def inputFactory = new DomesticHotWaterStorageInputFactory() + def expectedClasses = [DomesticHotWaterStorageInput] + + expect: + inputFactory.supportedClasses == Arrays.asList(expectedClasses.toArray()) + } + + def "A DomesticHotWaterStorageInputFactory should parse a valid DomesticHotWaterStorageInput correctly"() { + given: "a system participant input type factory and model data" + def inputFactory = new DomesticHotWaterStorageInputFactory() + Map parameter = [ + "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", + "id" : "TestID", + "storagevolumelvl" : "3", + "inlettemp" : "4", + "returntemp" : "5", + "c" : "6", + "pThermalMax" : "7" + ] + def inputClass = DomesticHotWaterStorageInput + def thermalBusInput = Mock(ThermalBusInput) + + when: + Try input = inputFactory.get(new ThermalUnitInputEntityData(parameter, inputClass, thermalBusInput)) + + then: + input.success + input.data.get().getClass() == inputClass + input.data.get().with { + assert uuid == UUID.fromString(parameter["uuid"]) + assert operationTime == OperationTime.notLimited() + assert operator == OperatorInput.NO_OPERATOR_ASSIGNED + assert id == parameter["id"] + assert thermalBus == thermalBusInput + assert storageVolumeLvl == getQuant(parameter["storagevolumelvl"], StandardUnits.VOLUME) + assert inletTemp == getQuant(parameter["inlettemp"], StandardUnits.TEMPERATURE) + assert returnTemp == getQuant(parameter["returntemp"], StandardUnits.TEMPERATURE) + assert c == getQuant(parameter["c"], StandardUnits.SPECIFIC_HEAT_CAPACITY) + assert pThermalMax == getQuant(parameter["pThermalMax"], StandardUnits.ACTIVE_POWER_IN) + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy index fee7a363a..b748fa265 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy @@ -10,7 +10,6 @@ import edu.ie3.datamodel.io.source.ThermalSource import edu.ie3.datamodel.io.source.TypeSource import edu.ie3.test.common.SystemParticipantTestData as sptd import edu.ie3.test.common.ThermalUnitInputTestData -import org.apache.commons.compress.harmony.unpack200.bytecode.forms.ThisMethodRefForm import spock.lang.Specification class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index 34c09ba71..be67fcd4b 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -5,8 +5,6 @@ */ package edu.ie3.test.common -import static edu.ie3.datamodel.models.StandardUnits.* - import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput @@ -27,12 +25,13 @@ import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.profile.StandardLoadProfile import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.interfaces.* -import org.testcontainers.shaded.org.checkerframework.checker.units.qual.A import tech.units.indriya.ComparableQuantity import tech.units.indriya.quantity.Quantities import javax.measure.quantity.* +import static edu.ie3.datamodel.models.StandardUnits.* + class SystemParticipantTestData { // general participant data From f3da3e321c598b227e4e3153e9de963cb44e24c1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 13:06:35 +0200 Subject: [PATCH 12/70] change numberInhabitants to double to allow proper scaling and using statistical data of average households --- .../input/thermal/ThermalHouseInput.java | 16 ++++----- .../ThermalUnitValidationUtilsTest.groovy | 34 +++++++++---------- .../common/ThermalUnitInputTestData.groovy | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java index 250ce365c..e2a89a833 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java @@ -29,8 +29,8 @@ public class ThermalHouseInput extends ThermalSinkInput { private final ComparableQuantity lowerTemperatureLimit; /** Type of the building, e.g. house or flat */ private final String housingType; - /** Number of people living in the building */ - private final Integer numberInhabitants; + /** Number of people living in the building, double to allow proper scaling */ + private final double numberInhabitants; /** * @param uuid Unique identifier of a thermal house model @@ -54,7 +54,7 @@ public ThermalHouseInput( ComparableQuantity upperTemperatureLimit, ComparableQuantity lowerTemperatureLimit, String housingType, - Integer numberInhabitants) { + double numberInhabitants) { super(uuid, id, bus); this.ethLosses = ethLosses.to(StandardUnits.THERMAL_TRANSMISSION); this.ethCapa = ethCapa.to(StandardUnits.HEAT_CAPACITY); @@ -91,7 +91,7 @@ public ThermalHouseInput( ComparableQuantity upperTemperatureLimit, ComparableQuantity lowerTemperatureLimit, String housingType, - Integer numberInhabitants) { + double numberInhabitants) { super(uuid, id, operator, operationTime, bus); this.ethLosses = ethLosses.to(StandardUnits.THERMAL_TRANSMISSION); this.ethCapa = ethCapa.to(StandardUnits.HEAT_CAPACITY); @@ -126,7 +126,7 @@ public String getHousingType() { return housingType; } - public Integer getNumberOfInhabitants() { + public double getNumberOfInhabitants() { return numberInhabitants; } @@ -206,7 +206,7 @@ public static class ThermalHouseInputCopyBuilder private ComparableQuantity upperTemperatureLimit; private ComparableQuantity lowerTemperatureLimit; private String housingType; - private Integer numberInhabitants; + private double numberInhabitants; private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) { super(entity); @@ -253,7 +253,7 @@ public ThermalHouseInputCopyBuilder housingType(String housingType) { return this; } - public ThermalHouseInputCopyBuilder numberInhabitants(Integer numberInhabitants) { + public ThermalHouseInputCopyBuilder numberInhabitants(double numberInhabitants) { this.numberInhabitants = numberInhabitants; return this; } @@ -264,7 +264,7 @@ public ThermalHouseInputCopyBuilder scale(Double factor) { // the time needed to heat a scaled house ethLosses(ethLosses.multiply(factor)); ethCapa(ethCapa.multiply(factor)); - numberInhabitants((int) Math.round(numberInhabitants.doubleValue() * factor)); + numberInhabitants(numberInhabitants * factor); return this; } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy index 08b949abf..aee06dc3e 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy @@ -47,7 +47,7 @@ class ThermalUnitValidationUtilsTest extends Specification { private static final ComparableQuantity UPPER_TEMPERATURE_LIMIT = Quantities.getQuantity(25, StandardUnits.TEMPERATURE) private static final ComparableQuantity LOWER_TEMPERATURE_LIMIT = Quantities.getQuantity(15, StandardUnits.TEMPERATURE) private static final String HOUSING_TYPE = "House" - private static final Integer NUMBER_INHABITANTS = 2 + private static final Integer NUMBER_INHABITANTS = 2.0 // Specific data for thermal cylindric storage input private static final ComparableQuantity storageVolumeLvl = Quantities.getQuantity(100, StandardUnits.VOLUME) @@ -87,7 +87,7 @@ class ThermalUnitValidationUtilsTest extends Specification { new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, Quantities.getQuantity(30, StandardUnits.TEMPERATURE), HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", invalidThermalHouse) new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, "someWrongType", NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Housing type must be either 'house' or 'flat'", invalidThermalHouse) - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, 0) || 1 || new InvalidEntityException("Number of inhabitants must be greater than zero", invalidThermalHouse) + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, 0d) || 1 || new InvalidEntityException("Number of inhabitants must be greater than zero", invalidThermalHouse) } // Thermal Cylindrical Storage @@ -121,20 +121,20 @@ class ThermalUnitValidationUtilsTest extends Specification { } -def "ThermalUnitValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { - when: - List> exceptions = ThermalUnitValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() - - then: - exceptions.size() == expectedSize - Exception ex = exceptions.get(0).exception.get() - ex.class == expectedException.class - ex.message == expectedException.message + def "ThermalUnitValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { + when: + List> exceptions = ThermalUnitValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() - where: - invalidDomesticHotWaterStorage || expectedSize || expectedException - new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", invalidDomesticHotWaterStorage) - new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidDomesticHotWaterStorage) - new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) + then: + exceptions.size() == expectedSize + Exception ex = exceptions.get(0).exception.get() + ex.class == expectedException.class + ex.message == expectedException.message -}} + where: + invalidDomesticHotWaterStorage || expectedSize || expectedException + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) + } +} diff --git a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy index 81d302368..863d26c55 100644 --- a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy @@ -39,7 +39,7 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { private static final ComparableQuantity UPPER_TEMPERATURE_LIMIT = Quantities.getQuantity(25, StandardUnits.TEMPERATURE) private static final ComparableQuantity LOWER_TEMPERATURE_LIMIT = Quantities.getQuantity(15, StandardUnits.TEMPERATURE) private static final String HOUSING_TYPE = "house" - private static final Integer NUMBER_INHABITANTS = 2 + private static final double NUMBER_INHABITANTS = 2.0 public static final thermalHouseInput = new ThermalHouseInput( thermalUnitUuid, From e44013b8d9ba6748f5cb45c964056362c0a902e1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 13:06:40 +0200 Subject: [PATCH 13/70] fmt --- .../input/CylindricalStorageInputFactory.java | 12 ++++- .../DomesticHotWaterStorageInputFactory.java | 4 +- .../datamodel/io/source/ThermalSource.java | 20 +++------ .../thermal/CylindricalStorageInput.java | 2 +- .../thermal/DomesticHotWaterStorageInput.java | 8 +--- .../ThermalUnitValidationUtils.java | 45 ++++++++++--------- .../io/extractor/ExtractorTest.groovy | 6 +-- .../datamodel/io/sink/CsvFileSinkTest.groovy | 45 +++++++++---------- .../common/SystemParticipantTestData.groovy | 4 +- 9 files changed, 70 insertions(+), 76 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java index 5aa6ca3a3..0e1b7d9f8 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java @@ -53,7 +53,15 @@ protected CylindricalStorageInput buildModel( final ComparableQuantity pThermalMax = data.getQuantity(P_THERMAL_MAX, StandardUnits.ACTIVE_POWER_IN); return new CylindricalStorageInput( - uuid, id, operator, operationTime, bus, storageVolumeLvl, inletTemp, returnTemp, c, - pThermalMax); + uuid, + id, + operator, + operationTime, + bus, + storageVolumeLvl, + inletTemp, + returnTemp, + c, + pThermalMax); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java index dfc99beb7..442e1903c 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java @@ -31,9 +31,7 @@ public DomesticHotWaterStorageInputFactory() { @Override protected String[] getAdditionalFields() { - return new String[] { - STORAGE_VOLUME_LVL, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX - }; + return new String[] {STORAGE_VOLUME_LVL, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX}; } @Override diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index f4cd02950..07f56a611 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -125,14 +125,8 @@ public Map getThermalBuses(Map opera * @return a map of UUID to object- and uuid-unique {@link ThermalStorageInput} entities */ public Map getThermalStorages() throws SourceException { - return Stream.concat( - getCylindricalStorages().stream(), - getDomesticHotWaterStorages().stream() - ) - .collect(Collectors.toMap( - ThermalStorageInput::getUuid, - storage -> storage - )); + return Stream.concat(getCylindricalStorages().stream(), getDomesticHotWaterStorages().stream()) + .collect(Collectors.toMap(ThermalStorageInput::getUuid, storage -> storage)); } /** @@ -158,13 +152,9 @@ public Map getThermalStorages( Map operators, Map thermalBuses) throws SourceException { return Stream.concat( - getCylindricalStorages(operators, thermalBuses).stream(), - getDomesticHotWaterStorages(operators, thermalBuses).stream() - ) - .collect(Collectors.toMap( - ThermalStorageInput::getUuid, - storage -> storage - )); + getCylindricalStorages(operators, thermalBuses).stream(), + getDomesticHotWaterStorages(operators, thermalBuses).stream()) + .collect(Collectors.toMap(ThermalStorageInput::getUuid, storage -> storage)); } /** diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 6ca1bf1cd..602175bcc 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -208,7 +208,7 @@ public CylindricalStorageInputCopyBuilder pThermalMax(ComparableQuantity @Override public CylindricalStorageInputCopyBuilder scale(Double factor) { storageVolumeLvl(storageVolumeLvl.multiply(factor)); - pThermalMax(pThermalMax.multiply(factor)); + pThermalMax(pThermalMax.multiply(factor)); return this; } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index b5da3207e..a33aa5af6 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -127,13 +127,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash( - super.hashCode(), - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); + return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } @Override diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index 5c4984f6f..bd79b3d48 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -125,7 +125,8 @@ private ThermalUnitValidationUtils() { } if (DomesticHotWaterStorageInput.class.isAssignableFrom(thermalStorageInput.getClass())) { - exceptions.addAll(checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); + exceptions.addAll( + checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); } else { logNotImplemented(thermalStorageInput); } @@ -250,7 +251,9 @@ private static List> checkCylindricalStorage( () -> detectZeroOrNegativeQuantities( new Quantity[] { - cylindricalStorageInput.getStorageVolumeLvl(), cylindricalStorageInput.getC(), cylindricalStorageInput.getpThermalMax() + cylindricalStorageInput.getStorageVolumeLvl(), + cylindricalStorageInput.getC(), + cylindricalStorageInput.getpThermalMax() }, cylindricalStorageInput), InvalidEntityException.class)); @@ -272,9 +275,9 @@ private static List> checkCylindricalStorage( * Success */ private static List> checkDomesticHotWaterStorage( - DomesticHotWaterStorageInput domesticHotWaterStorageInput) { + DomesticHotWaterStorageInput domesticHotWaterStorageInput) { Try isNull = - checkNonNull(domesticHotWaterStorageInput, "a domestic hot water storage"); + checkNonNull(domesticHotWaterStorageInput, "a domestic hot water storage"); if (isNull.isFailure()) { return List.of(isNull); @@ -284,24 +287,26 @@ private static List> checkDomesticHotWaterStor // Check if inlet temperature is higher/equal to outlet temperature exceptions.add( - Try.ofVoid( - domesticHotWaterStorageInput - .getInletTemp() - .isLessThan(domesticHotWaterStorageInput.getReturnTemp()), - () -> - new InvalidEntityException( - "Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", - domesticHotWaterStorageInput))); + Try.ofVoid( + domesticHotWaterStorageInput + .getInletTemp() + .isLessThan(domesticHotWaterStorageInput.getReturnTemp()), + () -> + new InvalidEntityException( + "Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", + domesticHotWaterStorageInput))); exceptions.add( - Try.ofVoid( - () -> - detectZeroOrNegativeQuantities( - new Quantity[] { - domesticHotWaterStorageInput.getStorageVolumeLvl(), domesticHotWaterStorageInput.getC(), domesticHotWaterStorageInput.getpThermalMax() - }, - domesticHotWaterStorageInput), - InvalidEntityException.class)); + Try.ofVoid( + () -> + detectZeroOrNegativeQuantities( + new Quantity[] { + domesticHotWaterStorageInput.getStorageVolumeLvl(), + domesticHotWaterStorageInput.getC(), + domesticHotWaterStorageInput.getpThermalMax() + }, + domesticHotWaterStorageInput), + InvalidEntityException.class)); return exceptions; } diff --git a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy index fd513bf33..8e8096879 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy @@ -141,9 +141,9 @@ class ExtractorTest extends Specification { ] tutd.domesticHotWaterStorageInput || [ - tutd.domesticHotWaterStorageInput.operator, - tutd.domesticHotWaterStorageInput.thermalBus, - tutd.domesticHotWaterStorageInput.thermalBus.operator + tutd.domesticHotWaterStorageInput.operator, + tutd.domesticHotWaterStorageInput.thermalBus, + tutd.domesticHotWaterStorageInput.thermalBus.operator ] tutd.thermalHouseInput || [ 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 456b3ca19..e97138f54 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy @@ -5,8 +5,6 @@ */ package edu.ie3.datamodel.io.sink -import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput - import static edu.ie3.util.quantities.PowerSystemUnits.DEGREE_GEOM import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE import static tech.units.indriya.unit.Units.PERCENT @@ -33,6 +31,7 @@ import edu.ie3.datamodel.models.input.system.LoadInput import edu.ie3.datamodel.models.input.system.PvInput import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput +import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalBusInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import edu.ie3.datamodel.models.result.system.EmResult @@ -120,27 +119,27 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { given: CsvFileSink csvFileSink = new CsvFileSink(testBaseFolderPath, new ProcessorProvider([ - new ResultEntityProcessor(PvResult), - new ResultEntityProcessor(WecResult), - new ResultEntityProcessor(EvResult), - new ResultEntityProcessor(EvcsResult), - new ResultEntityProcessor(EmResult), - new ResultEntityProcessor(FlexOptionsResult), - new InputEntityProcessor(Transformer2WInput), - new InputEntityProcessor(NodeInput), - new InputEntityProcessor(EvcsInput), - new InputEntityProcessor(Transformer2WTypeInput), - new InputEntityProcessor(LineGraphicInput), - new InputEntityProcessor(NodeGraphicInput), - new InputEntityProcessor(CylindricalStorageInput), - new InputEntityProcessor(DomesticHotWaterStorageInput), - new InputEntityProcessor(ThermalHouseInput), - new InputEntityProcessor(OperatorInput), - new InputEntityProcessor(LineInput), - new InputEntityProcessor(ThermalBusInput), - new InputEntityProcessor(LineTypeInput), - new InputEntityProcessor(LoadInput), - new InputEntityProcessor(EmInput) + new ResultEntityProcessor(PvResult), + new ResultEntityProcessor(WecResult), + new ResultEntityProcessor(EvResult), + new ResultEntityProcessor(EvcsResult), + new ResultEntityProcessor(EmResult), + new ResultEntityProcessor(FlexOptionsResult), + new InputEntityProcessor(Transformer2WInput), + new InputEntityProcessor(NodeInput), + new InputEntityProcessor(EvcsInput), + new InputEntityProcessor(Transformer2WTypeInput), + new InputEntityProcessor(LineGraphicInput), + new InputEntityProcessor(NodeGraphicInput), + new InputEntityProcessor(CylindricalStorageInput), + new InputEntityProcessor(DomesticHotWaterStorageInput), + new InputEntityProcessor(ThermalHouseInput), + new InputEntityProcessor(OperatorInput), + new InputEntityProcessor(LineInput), + new InputEntityProcessor(ThermalBusInput), + new InputEntityProcessor(LineTypeInput), + new InputEntityProcessor(LoadInput), + new InputEntityProcessor(EmInput) ], [] as Map), new FileNamingStrategy(), ",") diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index be67fcd4b..0247d5297 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -5,6 +5,8 @@ */ package edu.ie3.test.common +import static edu.ie3.datamodel.models.StandardUnits.* + import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput @@ -30,8 +32,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.* -import static edu.ie3.datamodel.models.StandardUnits.* - class SystemParticipantTestData { // general participant data From b16507b6e810362ec0121776b70dc59c9a4f0a7d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 14:13:30 +0200 Subject: [PATCH 14/70] refactor DomesticHotWaterStorageInput to extend CylindricalStorageInput --- .../input/CylindricalStorageInputFactory.java | 3 +- .../datamodel/io/source/ThermalSource.java | 3 +- .../thermal/CylindricalStorageInput.java | 2 +- .../thermal/DomesticHotWaterStorageInput.java | 157 ++++-------------- .../input/container/ThermalGridTest.groovy | 2 +- 5 files changed, 34 insertions(+), 133 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java index 0e1b7d9f8..4b2949519 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java @@ -25,7 +25,8 @@ public class CylindricalStorageInputFactory private static final String C = "c"; private static final String P_THERMAL_MAX = "pThermalMax"; - public CylindricalStorageInputFactory() { + public CylindricalStorageInputFactory( + Class cylindricalStorageInputClass) { super(CylindricalStorageInput.class); } diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 07f56a611..3450aaf54 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -49,7 +49,8 @@ public ThermalSource(TypeSource typeSource, DataSource dataSource) { this.typeSource = typeSource; this.thermalBusInputFactory = new ThermalBusInputFactory(); - this.cylindricalStorageInputFactory = new CylindricalStorageInputFactory(); + this.cylindricalStorageInputFactory = + new CylindricalStorageInputFactory(CylindricalStorageInput.class); this.domesticHotWaterStorageInputFactory = new DomesticHotWaterStorageInputFactory(); this.thermalHouseInputFactory = new ThermalHouseInputFactory(); } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 602175bcc..d0bf19713 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -169,7 +169,7 @@ public static class CylindricalStorageInputCopyBuilder private ComparableQuantity c; private ComparableQuantity pThermalMax; - private CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { + CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); this.storageVolumeLvl = entity.getStorageVolumeLvl(); this.inletTemp = entity.getInletTemp(); diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index a33aa5af6..7283b9a97 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -6,30 +6,19 @@ package edu.ie3.datamodel.models.input.thermal; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; -import java.util.Objects; import java.util.UUID; import javax.measure.quantity.Power; import javax.measure.quantity.Temperature; import javax.measure.quantity.Volume; import tech.units.indriya.ComparableQuantity; -/** Thermal storage with cylindrical shape store hot tap water */ -public class DomesticHotWaterStorageInput extends ThermalStorageInput { - /** Available storage volume (typically in m³) */ - private final ComparableQuantity storageVolumeLvl; - /** Temperature of the inlet (typically in C) */ - private final ComparableQuantity inletTemp; - /** Temperature of the outlet (typically in C) */ - private final ComparableQuantity returnTemp; - /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ - private final ComparableQuantity c; - /** Maximum permissible thermal power (typically in kW) */ - private final ComparableQuantity pThermalMax; +public class DomesticHotWaterStorageInput extends CylindricalStorageInput { /** + * Constructor for DomesticHotWaterStorageInput + * * @param uuid Unique identifier of a domestic hot water storage * @param id Identifier of the thermal unit * @param operator operator of the asset @@ -52,15 +41,22 @@ public DomesticHotWaterStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, operator, operationTime, bus); - this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); - this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); - this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + super( + uuid, + id, + operator, + operationTime, + bus, + storageVolumeLvl, + inletTemp, + returnTemp, + c, + pThermalMax); } /** + * Alternative constructor for DomesticHotWaterStorageInput + * * @param uuid Unique identifier of a domestic hot water storage * @param id Identifier of the thermal unit * @param bus Thermal bus, a thermal unit is connected to @@ -75,37 +71,11 @@ public DomesticHotWaterStorageInput( String id, ThermalBusInput bus, ComparableQuantity storageVolumeLvl, - ComparableQuantity storageVolumeLvlMin, ComparableQuantity inletTemp, ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, bus); - this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); - this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); - this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); - } - - public ComparableQuantity getStorageVolumeLvl() { - return storageVolumeLvl; - } - - public ComparableQuantity getInletTemp() { - return inletTemp; - } - - public ComparableQuantity getReturnTemp() { - return returnTemp; - } - - public ComparableQuantity getC() { - return c; - } - - public ComparableQuantity getpThermalMax() { - return pThermalMax; + super(uuid, id, bus, storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } @Override @@ -113,23 +83,6 @@ public DomesticHotWaterStorageInputCopyBuilder copy() { return new DomesticHotWaterStorageInputCopyBuilder(this); } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof DomesticHotWaterStorageInput that)) return false; - if (!super.equals(o)) return false; - return storageVolumeLvl.equals(that.storageVolumeLvl) - && inletTemp.equals(that.inletTemp) - && returnTemp.equals(that.returnTemp) - && c.equals(that.c) - && pThermalMax.equals(that.pThermalMax); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); - } - @Override public String toString() { return "DomesticHotWaterStorageInput{" @@ -144,76 +97,22 @@ public String toString() { + ", bus=" + getThermalBus().getUuid() + ", storageVolumeLvl=" - + storageVolumeLvl + + getStorageVolumeLvl() + ", inletTemp=" - + inletTemp + + getInletTemp() + ", returnTemp=" - + returnTemp + + getReturnTemp() + ", c=" - + c + + getC() + ", pThermalMax=" - + pThermalMax + + getpThermalMax() + '}'; } - /** - * A builder pattern based approach to create copies of {@link DomesticHotWaterStorageInput} - * entities with altered field values. For detailed field descriptions refer to java docs of - * {@link DomesticHotWaterStorageInput} - */ - public static class DomesticHotWaterStorageInputCopyBuilder - extends ThermalStorageInputCopyBuilder { - - private ComparableQuantity storageVolumeLvl; - private ComparableQuantity storageVolumeLvlMin; - private ComparableQuantity inletTemp; - private ComparableQuantity returnTemp; - private ComparableQuantity c; - private ComparableQuantity pThermalMax; + public class DomesticHotWaterStorageInputCopyBuilder extends CylindricalStorageInputCopyBuilder { private DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); - this.storageVolumeLvl = entity.getStorageVolumeLvl(); - this.inletTemp = entity.getInletTemp(); - this.returnTemp = entity.getReturnTemp(); - this.c = entity.getC(); - this.pThermalMax = entity.getpThermalMax(); - } - - public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl( - ComparableQuantity storageVolumeLvl) { - this.storageVolumeLvl = storageVolumeLvl; - return this; - } - - public DomesticHotWaterStorageInputCopyBuilder inletTemp( - ComparableQuantity inletTemp) { - this.inletTemp = inletTemp; - return this; - } - - public DomesticHotWaterStorageInputCopyBuilder returnTemp( - ComparableQuantity returnTemp) { - this.returnTemp = returnTemp; - return this; - } - - public DomesticHotWaterStorageInputCopyBuilder c(ComparableQuantity c) { - this.c = c; - return this; - } - - public DomesticHotWaterStorageInputCopyBuilder pThermalMax( - ComparableQuantity pThermalMax) { - this.pThermalMax = pThermalMax; - return this; - } - - @Override - public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { - storageVolumeLvl(storageVolumeLvl.multiply(factor)); - pThermalMax(pThermalMax.multiply(factor)); - return this; } @Override @@ -224,11 +123,11 @@ public DomesticHotWaterStorageInput build() { getOperator(), getOperationTime(), getThermalBus(), - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); + getStorageVolumeLvl(), + getInletTemp(), + getReturnTemp(), + getC(), + getpThermalMax()); } @Override diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy index ca34f5270..904635bb9 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy @@ -42,7 +42,7 @@ class ThermalGridTest extends Specification { def thermalHouses = [] def heatStorages = [] def domesticHotWaterStorages = [] - def thermalGrid = new ThermalGrid(thermalBus, thermalHouses, heatStorages,domesticHotWaterStorages) + def thermalGrid = new ThermalGrid(thermalBus, thermalHouses, heatStorages, domesticHotWaterStorages) def modifiedHouses = [Mock(ThermalHouseInput)] def modifiedHeatStorages = [Mock(CylindricalStorageInput)] From 322a48c4b08c6ec0403ebbc39789f520fee22658 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 14:30:43 +0200 Subject: [PATCH 15/70] fix validation test --- .../validation/ThermalUnitValidationUtils.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index bd79b3d48..27fbc3623 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -118,17 +118,11 @@ private ThermalUnitValidationUtils() { List> exceptions = new ArrayList<>(); // Further checks for subclasses - if (CylindricalStorageInput.class.isAssignableFrom(thermalStorageInput.getClass())) { - exceptions.addAll(checkCylindricalStorage((CylindricalStorageInput) thermalStorageInput)); - } else { - logNotImplemented(thermalStorageInput); - } + if (thermalStorageInput.getClass() == CylindricalStorageInput.class) { + exceptions.addAll(checkCylindricalStorage((CylindricalStorageInput) thermalStorageInput));} - if (DomesticHotWaterStorageInput.class.isAssignableFrom(thermalStorageInput.getClass())) { - exceptions.addAll( - checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); - } else { - logNotImplemented(thermalStorageInput); + if (thermalStorageInput.getClass() == DomesticHotWaterStorageInput.class) { + exceptions.addAll(checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); } return exceptions; From 211bd658247f1fe57698ee698679a606f1c1e2ac Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 14:37:44 +0200 Subject: [PATCH 16/70] fix scaling of DomesticHotWaterStorageInput --- .../models/input/thermal/DomesticHotWaterStorageInput.java | 6 ++++++ .../input/thermal/DomesticHotWaterStorageInputTest.groovy | 2 +- .../edu/ie3/test/common/ThermalUnitInputTestData.groovy | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 7283b9a97..5b63adbce 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -115,6 +115,12 @@ private DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput ent super(entity); } + public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { + storageVolumeLvl(getStorageVolumeLvl().multiply(factor)); + pThermalMax(getpThermalMax().multiply(factor)); + return this; + } + @Override public DomesticHotWaterStorageInput build() { return new DomesticHotWaterStorageInput( diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy index 92232c3b0..f28864c13 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInputTest.groovy @@ -36,7 +36,7 @@ class DomesticHotWaterStorageInputTest extends Specification { } } - def "Scaling a CylindricalStorageInput via builder should work as expected"() { + def "Scaling a DomesticHotWaterStorageInput via builder should work as expected"() { given: def domesticHotWaterStorageInput = ThermalUnitInputTestData.domesticHotWaterStorageInput diff --git a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy index 863d26c55..3f6b6c3db 100644 --- a/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ThermalUnitInputTestData.groovy @@ -64,7 +64,7 @@ class ThermalUnitInputTestData extends SystemParticipantTestData { public static final cylindricalStorageInput = new CylindricalStorageInput( thermalUnitUuid, - "testCylindricStorageInput", + "testCylindricalStorageInput", operator, operationTime, thermalBus, From e8f18f0135dd222d248eea5408091dbe4d73db59 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 14:37:57 +0200 Subject: [PATCH 17/70] fmt --- .../utils/validation/ThermalUnitValidationUtils.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index 27fbc3623..0d4f7e020 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -119,10 +119,12 @@ private ThermalUnitValidationUtils() { // Further checks for subclasses if (thermalStorageInput.getClass() == CylindricalStorageInput.class) { - exceptions.addAll(checkCylindricalStorage((CylindricalStorageInput) thermalStorageInput));} + exceptions.addAll(checkCylindricalStorage((CylindricalStorageInput) thermalStorageInput)); + } if (thermalStorageInput.getClass() == DomesticHotWaterStorageInput.class) { - exceptions.addAll(checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); + exceptions.addAll( + checkDomesticHotWaterStorage((DomesticHotWaterStorageInput) thermalStorageInput)); } return exceptions; From 6ca993f536dab724f3dae1b8391e672fee2c8108 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 9 Aug 2024 15:14:02 +0200 Subject: [PATCH 18/70] adapt copybuilders --- .../thermal/CylindricalStorageInput.java | 10 +++---- .../thermal/DomesticHotWaterStorageInput.java | 30 ++++++++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index d0bf19713..125fdf6e6 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -163,11 +163,11 @@ public String toString() { public static class CylindricalStorageInputCopyBuilder extends ThermalStorageInputCopyBuilder { - private ComparableQuantity storageVolumeLvl; - private ComparableQuantity inletTemp; - private ComparableQuantity returnTemp; - private ComparableQuantity c; - private ComparableQuantity pThermalMax; + ComparableQuantity storageVolumeLvl; + ComparableQuantity inletTemp; + ComparableQuantity returnTemp; + ComparableQuantity c; + ComparableQuantity pThermalMax; CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 5b63adbce..2d13747c1 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -111,10 +111,38 @@ public String toString() { public class DomesticHotWaterStorageInputCopyBuilder extends CylindricalStorageInputCopyBuilder { - private DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { + public DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); } + + public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl(ComparableQuantity storageVolumeLvl) { + this.storageVolumeLvl = storageVolumeLvl; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder inletTemp(ComparableQuantity inletTemp) { + this.inletTemp = inletTemp; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder returnTemp( + ComparableQuantity returnTemp) { + this.returnTemp = returnTemp; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder c(ComparableQuantity c) { + this.c = c; + return this; + } + + public DomesticHotWaterStorageInputCopyBuilder pThermalMax(ComparableQuantity pThermalMax) { + this.pThermalMax = pThermalMax; + return this; + } + + @Override public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { storageVolumeLvl(getStorageVolumeLvl().multiply(factor)); pThermalMax(getpThermalMax().multiply(factor)); From 2a428ef90fce6a400ffd68526d56b7f4a62fe417 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 14 Aug 2024 09:30:41 +0200 Subject: [PATCH 19/70] fmt --- .../input/thermal/DomesticHotWaterStorageInput.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 2d13747c1..b7ecc0bb7 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -115,19 +115,20 @@ public DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput enti super(entity); } - - public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl(ComparableQuantity storageVolumeLvl) { + public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl( + ComparableQuantity storageVolumeLvl) { this.storageVolumeLvl = storageVolumeLvl; return this; } - public DomesticHotWaterStorageInputCopyBuilder inletTemp(ComparableQuantity inletTemp) { + public DomesticHotWaterStorageInputCopyBuilder inletTemp( + ComparableQuantity inletTemp) { this.inletTemp = inletTemp; return this; } public DomesticHotWaterStorageInputCopyBuilder returnTemp( - ComparableQuantity returnTemp) { + ComparableQuantity returnTemp) { this.returnTemp = returnTemp; return this; } @@ -137,7 +138,8 @@ public DomesticHotWaterStorageInputCopyBuilder c(ComparableQuantity pThermalMax) { + public DomesticHotWaterStorageInputCopyBuilder pThermalMax( + ComparableQuantity pThermalMax) { this.pThermalMax = pThermalMax; return this; } From d7fd77c648b439ff4930eda38c33a6769f02d502 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 14 Aug 2024 09:52:05 +0200 Subject: [PATCH 20/70] avoid unused constructor parameters in CylindricalStorageInputFactory --- .../io/factory/input/CylindricalStorageInputFactory.java | 3 +-- src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java index 4b2949519..0e1b7d9f8 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java @@ -25,8 +25,7 @@ public class CylindricalStorageInputFactory private static final String C = "c"; private static final String P_THERMAL_MAX = "pThermalMax"; - public CylindricalStorageInputFactory( - Class cylindricalStorageInputClass) { + public CylindricalStorageInputFactory() { super(CylindricalStorageInput.class); } diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 3450aaf54..6f8a71dd8 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -50,7 +50,7 @@ public ThermalSource(TypeSource typeSource, DataSource dataSource) { this.thermalBusInputFactory = new ThermalBusInputFactory(); this.cylindricalStorageInputFactory = - new CylindricalStorageInputFactory(CylindricalStorageInput.class); + new CylindricalStorageInputFactory(); this.domesticHotWaterStorageInputFactory = new DomesticHotWaterStorageInputFactory(); this.thermalHouseInputFactory = new ThermalHouseInputFactory(); } From 852fa78b9474a336a619bedb476990965dbbe0b6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 15 Aug 2024 17:30:44 +0200 Subject: [PATCH 21/70] fix DomesticHotWaterStorage scaling --- .../ie3/datamodel/io/source/ThermalSource.java | 3 +-- .../thermal/DomesticHotWaterStorageInput.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 6f8a71dd8..07f56a611 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -49,8 +49,7 @@ public ThermalSource(TypeSource typeSource, DataSource dataSource) { this.typeSource = typeSource; this.thermalBusInputFactory = new ThermalBusInputFactory(); - this.cylindricalStorageInputFactory = - new CylindricalStorageInputFactory(); + this.cylindricalStorageInputFactory = new CylindricalStorageInputFactory(); this.domesticHotWaterStorageInputFactory = new DomesticHotWaterStorageInputFactory(); this.thermalHouseInputFactory = new ThermalHouseInputFactory(); } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index b7ecc0bb7..29d880770 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -109,7 +109,8 @@ public String toString() { + '}'; } - public class DomesticHotWaterStorageInputCopyBuilder extends CylindricalStorageInputCopyBuilder { + public static class DomesticHotWaterStorageInputCopyBuilder + extends CylindricalStorageInputCopyBuilder { public DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); @@ -146,8 +147,8 @@ public DomesticHotWaterStorageInputCopyBuilder pThermalMax( @Override public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { - storageVolumeLvl(getStorageVolumeLvl().multiply(factor)); - pThermalMax(getpThermalMax().multiply(factor)); + storageVolumeLvl(this.storageVolumeLvl.multiply(factor)); + pThermalMax(this.pThermalMax.multiply(factor)); return this; } @@ -159,11 +160,11 @@ public DomesticHotWaterStorageInput build() { getOperator(), getOperationTime(), getThermalBus(), - getStorageVolumeLvl(), - getInletTemp(), - getReturnTemp(), - getC(), - getpThermalMax()); + this.storageVolumeLvl, + this.inletTemp, + this.returnTemp, + this.c, + this.pThermalMax); } @Override From 91bea33221fda8344c9736c0f3abc5899c8b63c9 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 26 Aug 2024 15:09:03 +0200 Subject: [PATCH 22/70] introduce DomesticHotWaterStorageResult --- .../factory/result/ThermalResultFactory.java | 20 ++++- .../result/ResultEntityProcessor.java | 2 + .../thermal/AbstractThermalStorageResult.java | 79 +++++++++++++++++++ .../thermal/CylindricalStorageResult.java | 59 +------------- .../DomesticHotWaterStorageResult.java | 26 ++++++ .../result/ThermalResultFactoryTest.groovy | 4 +- .../io/processor/ProcessorProviderTest.groovy | 4 +- .../result/ResultEntityProcessorTest.groovy | 27 ++++++- 8 files changed, 160 insertions(+), 61 deletions(-) create mode 100644 src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java create mode 100644 src/main/java/edu/ie3/datamodel/models/result/thermal/DomesticHotWaterStorageResult.java diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java index 0ff9180d0..8bb06ba54 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java @@ -10,6 +10,7 @@ import edu.ie3.datamodel.models.Entity; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult; +import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult; import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult; import edu.ie3.datamodel.models.result.thermal.ThermalUnitResult; import java.time.ZonedDateTime; @@ -28,7 +29,10 @@ public class ThermalResultFactory extends ModelResultFactory private static final String FILL_LEVEL = "fillLevel"; public ThermalResultFactory() { - super(ThermalHouseResult.class, CylindricalStorageResult.class); + super( + ThermalHouseResult.class, + CylindricalStorageResult.class, + DomesticHotWaterStorageResult.class); } /** @@ -38,7 +42,11 @@ public ThermalResultFactory() { * @param dateTimeFormatter parse date time strings */ public ThermalResultFactory(DateTimeFormatter dateTimeFormatter) { - super(dateTimeFormatter, ThermalHouseResult.class, CylindricalStorageResult.class); + super( + dateTimeFormatter, + ThermalHouseResult.class, + CylindricalStorageResult.class, + DomesticHotWaterStorageResult.class); } @Override @@ -75,6 +83,14 @@ protected ThermalUnitResult buildModel(EntityData data) { return new CylindricalStorageResult( zdtTime, inputModelUuid, energyQuantity, qDotQuantity, fillLevelQuantity); + } else if (clazz.equals(DomesticHotWaterStorageResult.class)) { + ComparableQuantity energyQuantity = + data.getQuantity(ENERGY, StandardUnits.ENERGY_RESULT); + ComparableQuantity fillLevelQuantity = + data.getQuantity(FILL_LEVEL, StandardUnits.FILL_LEVEL); + + return new DomesticHotWaterStorageResult( + zdtTime, inputModelUuid, energyQuantity, qDotQuantity, fillLevelQuantity); } else { throw new FactoryException("Cannot process " + clazz.getSimpleName() + ".class."); } diff --git a/src/main/java/edu/ie3/datamodel/io/processor/result/ResultEntityProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/result/ResultEntityProcessor.java index 0e347aa5f..224b75850 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/result/ResultEntityProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/result/ResultEntityProcessor.java @@ -18,6 +18,7 @@ import edu.ie3.datamodel.models.result.connector.Transformer3WResult; import edu.ie3.datamodel.models.result.system.*; import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult; +import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult; import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult; import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.*; @@ -58,6 +59,7 @@ public class ResultEntityProcessor extends EntityProcessor { NodeResult.class, ThermalHouseResult.class, CylindricalStorageResult.class, + DomesticHotWaterStorageResult.class, EmResult.class, FlexOptionsResult.class, CongestionResult.class); diff --git a/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java b/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java new file mode 100644 index 000000000..a64d72b07 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java @@ -0,0 +1,79 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.models.result.thermal; + +import edu.ie3.datamodel.models.StandardUnits; +import java.time.ZonedDateTime; +import java.util.Objects; +import java.util.UUID; +import javax.measure.quantity.Dimensionless; +import javax.measure.quantity.Energy; +import javax.measure.quantity.Power; +import tech.units.indriya.ComparableQuantity; + +/** Abstract class representing the common results of different types of thermal storages */ +public abstract class AbstractThermalStorageResult extends ThermalStorageResult { + /** Fill level of the storage */ + private ComparableQuantity fillLevel; + + /** + * Constructs the result with + * + * @param time date and time when the result is produced + * @param inputModel uuid of the input model that produces the result + * @param energy Currently stored energy + * @param qDot Heat power flowing into (> 0) or coming from (< 0) the storage + * @param fillLevel Fill level of the storage + */ + public AbstractThermalStorageResult( + ZonedDateTime time, + UUID inputModel, + ComparableQuantity energy, + ComparableQuantity qDot, + ComparableQuantity fillLevel) { + super(time, inputModel, energy, qDot); + this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL); + } + + public ComparableQuantity getFillLevel() { + return fillLevel; + } + + public void setFillLevel(ComparableQuantity fillLevel) { + this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + AbstractThermalStorageResult that = (AbstractThermalStorageResult) o; + return fillLevel.equals(that.fillLevel); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), fillLevel); + } + + @Override + public String toString() { + return getClass().getSimpleName() + + "{" + + "time=" + + getTime() + + ", inputModel=" + + getInputModel() + + ", qDot=" + + getqDot() + + ", energy=" + + getEnergy() + + ", fillLevel=" + + fillLevel + + '}'; + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/result/thermal/CylindricalStorageResult.java b/src/main/java/edu/ie3/datamodel/models/result/thermal/CylindricalStorageResult.java index 40ab5bc1f..eeadc0bb8 100644 --- a/src/main/java/edu/ie3/datamodel/models/result/thermal/CylindricalStorageResult.java +++ b/src/main/java/edu/ie3/datamodel/models/result/thermal/CylindricalStorageResult.java @@ -5,75 +5,22 @@ */ package edu.ie3.datamodel.models.result.thermal; -import edu.ie3.datamodel.models.StandardUnits; -import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput; import java.time.ZonedDateTime; -import java.util.Objects; import java.util.UUID; import javax.measure.quantity.Dimensionless; import javax.measure.quantity.Energy; import javax.measure.quantity.Power; import tech.units.indriya.ComparableQuantity; -/** Respresents the results of {@link CylindricalStorageInput} */ -public class CylindricalStorageResult extends ThermalStorageResult { - /** Fill level of the storage */ - private ComparableQuantity fillLevel; +/** Represents the results of Cylindrical Storage */ +public class CylindricalStorageResult extends AbstractThermalStorageResult { - /** - * Constructs the result with - * - * @param time date and time when the result is produced - * @param inputModel uuid of the input model that produces the result - * @param energy Currently stored energy - * @param qDot Heat power flowing into (> 0) or coming from (< 0) the storage - * @param fillLevel Fill level of the storage - */ public CylindricalStorageResult( ZonedDateTime time, UUID inputModel, ComparableQuantity energy, ComparableQuantity qDot, ComparableQuantity fillLevel) { - super(time, inputModel, energy, qDot); - this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL); - } - - public ComparableQuantity getFillLevel() { - return fillLevel; - } - - public void setFillLevel(ComparableQuantity fillLevel) { - this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - if (!super.equals(o)) return false; - CylindricalStorageResult that = (CylindricalStorageResult) o; - return fillLevel.equals(that.fillLevel); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), fillLevel); - } - - @Override - public String toString() { - return "CylindricalStorageResult{" - + "time=" - + getTime() - + ", inputModel=" - + getInputModel() - + ", qDot=" - + getqDot() - + ", energy=" - + getEnergy() - + ", fillLevel=" - + fillLevel - + '}'; + super(time, inputModel, energy, qDot, fillLevel); } } diff --git a/src/main/java/edu/ie3/datamodel/models/result/thermal/DomesticHotWaterStorageResult.java b/src/main/java/edu/ie3/datamodel/models/result/thermal/DomesticHotWaterStorageResult.java new file mode 100644 index 000000000..cf604fe0e --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/result/thermal/DomesticHotWaterStorageResult.java @@ -0,0 +1,26 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.models.result.thermal; + +import java.time.ZonedDateTime; +import java.util.UUID; +import javax.measure.quantity.Dimensionless; +import javax.measure.quantity.Energy; +import javax.measure.quantity.Power; +import tech.units.indriya.ComparableQuantity; + +/** Represents the results of Domestic Hot Water Storage */ +public class DomesticHotWaterStorageResult extends AbstractThermalStorageResult { + + public DomesticHotWaterStorageResult( + ZonedDateTime time, + UUID inputModel, + ComparableQuantity energy, + ComparableQuantity qDot, + ComparableQuantity fillLevel) { + super(time, inputModel, energy, qDot, fillLevel); + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy index 9c64a97ec..1f22de467 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy @@ -9,6 +9,7 @@ import edu.ie3.datamodel.exceptions.FactoryException import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult +import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult import edu.ie3.datamodel.models.result.thermal.ThermalUnitResult import edu.ie3.datamodel.utils.Try @@ -23,7 +24,8 @@ class ThermalResultFactoryTest extends Specification implements FactoryTestHelpe def resultFactory = new ThermalResultFactory() def expectedClasses = [ ThermalHouseResult, - CylindricalStorageResult + CylindricalStorageResult, + DomesticHotWaterStorageResult ] expect: diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy index 257b8e33b..35f60261e 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy @@ -35,6 +35,7 @@ import edu.ie3.datamodel.models.result.connector.Transformer2WResult import edu.ie3.datamodel.models.result.connector.Transformer3WResult import edu.ie3.datamodel.models.result.system.* import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult +import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult import edu.ie3.datamodel.models.timeseries.IntValue import edu.ie3.datamodel.models.timeseries.TimeSeries @@ -121,7 +122,8 @@ class ProcessorProviderTest extends Specification implements TimeSeriesTestData NodeResult, CongestionResult, ThermalHouseResult, - CylindricalStorageResult + CylindricalStorageResult, + DomesticHotWaterStorageResult ] // currently known processors diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy index 7bf12fbb9..12924e74a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy @@ -15,6 +15,7 @@ import edu.ie3.datamodel.models.result.connector.Transformer2WResult import edu.ie3.datamodel.models.result.connector.Transformer3WResult import edu.ie3.datamodel.models.result.system.* import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult +import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult import edu.ie3.util.quantities.PowerSystemUnits import spock.lang.Shared import spock.lang.Specification @@ -252,6 +253,30 @@ class ResultEntityProcessorTest extends Specification { validProcessedElement == expectedResults } + def "A ResultEntityProcessor should serialize a DomesticHotWaterStorageResult correctly"() { + given: + def sysPartResProcessor = new ResultEntityProcessor(DomesticHotWaterStorageResult) + + Quantity qDot = Quantities.getQuantity(2, StandardUnits.Q_DOT_RESULT) + Quantity energy = Quantities.getQuantity(3, StandardUnits.ENERGY_RESULT) + Quantity fillLevel = Quantities.getQuantity(20, Units.PERCENT) + + def validResult = new DomesticHotWaterStorageResult(ZonedDateTime.parse("2020-01-30T17:26:44Z"), inputModel, energy, qDot, fillLevel) + + def expectedResults = [ + energy : '3.0', + fillLevel : '20.0', + inputModel: '22bea5fc-2cb2-4c61-beb9-b476e0107f52', + qDot : '2.0', + time : '2020-01-30T17:26:44Z'] + + when: + def validProcessedElement = sysPartResProcessor.handleEntity(validResult) + + then: + validProcessedElement == expectedResults + } + def "A ResultEntityProcessor should throw an EntityProcessorException when it receives an entity result that is not eligible"() { given: @@ -270,7 +295,7 @@ class ResultEntityProcessorTest extends Specification { def "The list of eligible entity classes for a ResultEntityProcessor should be valid"() { given: - int noOfElements = 20 // number of all currently implemented entity results + int noOfElements = 21 // number of all currently implemented entity results expect: ResultEntityProcessor.eligibleEntityClasses.size() == noOfElements From 7aa786fc917da2e83f1ebb2e0962d78430ea05d1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 26 Aug 2024 15:14:32 +0200 Subject: [PATCH 23/70] docs for domesticHotWaterStorage --- docs/readthedocs/models/models.md | 1 + .../participant/domesticHotWaterStorage.md | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 docs/readthedocs/models/result/participant/domesticHotWaterStorage.md diff --git a/docs/readthedocs/models/models.md b/docs/readthedocs/models/models.md index f49d958b6..a1b148f09 100644 --- a/docs/readthedocs/models/models.md +++ b/docs/readthedocs/models/models.md @@ -210,6 +210,7 @@ result/participant/thermalstorage result/participant/thermalunit result/participant/thermalhouse result/participant/cylindricalstorage +result/participant/domesticthotwaterstorage result/participant/systemparticipant result/participant/flexoption result/participant/em diff --git a/docs/readthedocs/models/result/participant/domesticHotWaterStorage.md b/docs/readthedocs/models/result/participant/domesticHotWaterStorage.md new file mode 100644 index 000000000..122841944 --- /dev/null +++ b/docs/readthedocs/models/result/participant/domesticHotWaterStorage.md @@ -0,0 +1,44 @@ +(domestichotwaterstorage-result)= + +# Domestic Hot Water Storage + +Result of a domestic hot water storage using a fluent to store thermal energy. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 1 + + + * - Attribute + - Unit + - Remarks + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - energy + - MWh + - + + * - qDot + - MW + - heat demand of the sink + + * - fillLevel + - -- + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! From d7506ce87deb7b7dc10f8a62fa90cda205b78b51 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 26 Aug 2024 15:17:38 +0200 Subject: [PATCH 24/70] rtd --- .../{domesticHotWaterStorage.md => domestichotwaterstorage.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/readthedocs/models/result/participant/{domesticHotWaterStorage.md => domestichotwaterstorage.md} (100%) diff --git a/docs/readthedocs/models/result/participant/domesticHotWaterStorage.md b/docs/readthedocs/models/result/participant/domestichotwaterstorage.md similarity index 100% rename from docs/readthedocs/models/result/participant/domesticHotWaterStorage.md rename to docs/readthedocs/models/result/participant/domestichotwaterstorage.md From 3b89d3e9b5c21ae80aac073203c8298bfe651ea5 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 26 Aug 2024 15:23:08 +0200 Subject: [PATCH 25/70] fix rtd --- docs/readthedocs/models/models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/readthedocs/models/models.md b/docs/readthedocs/models/models.md index a1b148f09..390d650cb 100644 --- a/docs/readthedocs/models/models.md +++ b/docs/readthedocs/models/models.md @@ -210,7 +210,7 @@ result/participant/thermalstorage result/participant/thermalunit result/participant/thermalhouse result/participant/cylindricalstorage -result/participant/domesticthotwaterstorage +result/participant/domestichotwaterstorage result/participant/systemparticipant result/participant/flexoption result/participant/em From c4a2575ef707718bb6cd87a403a6a6370303b69a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 18 Sep 2024 14:58:22 +0200 Subject: [PATCH 26/70] fix rtd --- docs/readthedocs/models/input/thermal/thermalhouse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/readthedocs/models/input/thermal/thermalhouse.md b/docs/readthedocs/models/input/thermal/thermalhouse.md index 02b8e0e1e..decd10639 100644 --- a/docs/readthedocs/models/input/thermal/thermalhouse.md +++ b/docs/readthedocs/models/input/thermal/thermalhouse.md @@ -62,7 +62,7 @@ This reflects a simple shoe box with transmission losses - Type of building can either be house or flat * - numberInhabititans - - # + - – - Number of people living in the house ``` From 1cf6d95f99030a8702268e966dd19d8156ad69ad Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 18 Sep 2024 15:14:47 +0200 Subject: [PATCH 27/70] fix fix rtd --- docs/readthedocs/models/input/thermal/thermalhouse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/readthedocs/models/input/thermal/thermalhouse.md b/docs/readthedocs/models/input/thermal/thermalhouse.md index 8b0083eb4..4aef04309 100644 --- a/docs/readthedocs/models/input/thermal/thermalhouse.md +++ b/docs/readthedocs/models/input/thermal/thermalhouse.md @@ -62,7 +62,7 @@ This reflects a simple shoe box with transmission losses - Type of building can either be house or flat * - numberInhabititans - - – + - -- - Number of people living in the house ``` From 2f66aca8ac3d2be53238852a8535d084e782d589 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 18 Sep 2024 17:30:10 +0200 Subject: [PATCH 28/70] new approach to fix rtd --- docs/readthedocs/models/input/thermal/thermalhouse.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/readthedocs/models/input/thermal/thermalhouse.md b/docs/readthedocs/models/input/thermal/thermalhouse.md index 4aef04309..bcf0da11d 100644 --- a/docs/readthedocs/models/input/thermal/thermalhouse.md +++ b/docs/readthedocs/models/input/thermal/thermalhouse.md @@ -58,11 +58,11 @@ This reflects a simple shoe box with transmission losses - Lower temperature boundary * - housingType - - -- + - – - Type of building can either be house or flat * - numberInhabititans - - -- + - – - Number of people living in the house ``` From 7e79c9bb7897a263c95a0066d984633aebaddffc Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 12:55:10 +0100 Subject: [PATCH 29/70] Sonar - change the visibility of constructor to protected --- .../models/result/thermal/AbstractThermalStorageResult.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java b/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java index a64d72b07..293ab29bf 100644 --- a/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java +++ b/src/main/java/edu/ie3/datamodel/models/result/thermal/AbstractThermalStorageResult.java @@ -28,7 +28,7 @@ public abstract class AbstractThermalStorageResult extends ThermalStorageResult * @param qDot Heat power flowing into (> 0) or coming from (< 0) the storage * @param fillLevel Fill level of the storage */ - public AbstractThermalStorageResult( + protected AbstractThermalStorageResult( ZonedDateTime time, UUID inputModel, ComparableQuantity energy, From 890322f320afe0d5edc5869dc6e2a5b820d0bc13 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 13:00:11 +0100 Subject: [PATCH 30/70] Sonar - add override annotations --- .../models/input/thermal/DomesticHotWaterStorageInput.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 29d880770..35c827b3f 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -116,29 +116,34 @@ public DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput enti super(entity); } + @Override public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl( ComparableQuantity storageVolumeLvl) { this.storageVolumeLvl = storageVolumeLvl; return this; } + @Override public DomesticHotWaterStorageInputCopyBuilder inletTemp( ComparableQuantity inletTemp) { this.inletTemp = inletTemp; return this; } + @Override public DomesticHotWaterStorageInputCopyBuilder returnTemp( ComparableQuantity returnTemp) { this.returnTemp = returnTemp; return this; } + @Override public DomesticHotWaterStorageInputCopyBuilder c(ComparableQuantity c) { this.c = c; return this; } + @Override public DomesticHotWaterStorageInputCopyBuilder pThermalMax( ComparableQuantity pThermalMax) { this.pThermalMax = pThermalMax; From be0d0286b8e4082cd3dccbae7b3b742949fc6142 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 27 Nov 2024 13:48:14 +0100 Subject: [PATCH 31/70] fix more tests with regard to ThermalUnitValidationUtils --- .../ThermalUnitValidationUtils.java | 4 +- .../ie3/datamodel/io/sink/SqlSinkTest.groovy | 2 +- .../ThermalUnitValidationUtilsTest.groovy | 43 ++++++++++--------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index a02dfe18f..9edcd6171 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -286,10 +286,10 @@ private static List> checkDomesticHotWaterStor Try.ofVoid( domesticHotWaterStorageInput .getInletTemp() - .isLessThan(domesticHotWaterStorageInput.getReturnTemp()), + .isLessThanOrEqualTo(domesticHotWaterStorageInput.getReturnTemp()), () -> new InvalidEntityException( - "Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", + "Inlet temperature of the domestic hot water storage cannot be lower or equal than outlet temperature", domesticHotWaterStorageInput))); exceptions.add( diff --git a/src/test/groovy/edu/ie3/datamodel/io/sink/SqlSinkTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/sink/SqlSinkTest.groovy index 67e5065e4..b7cbde944 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/SqlSinkTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/SqlSinkTest.groovy @@ -133,7 +133,7 @@ class SqlSinkTest extends Specification implements TestContainerHelper, TimeSeri GridTestData.transformerCtoG, GridTestData.lineGraphicCtoD, GridTestData.nodeGraphicC, - ThermalUnitInputTestData.cylindricStorageInput, + ThermalUnitInputTestData.cylindricalStorageInput, ThermalUnitInputTestData.thermalHouseInput, SystemParticipantTestData.evcsInput, SystemParticipantTestData.loadInput, diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy index 1b9693233..9f0b2c976 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy @@ -115,27 +115,28 @@ class ThermalUnitValidationUtilsTest extends Specification { ex.message == expectedException.message where: - invalidCylindricalStorage || expectedSize || expectedException - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower or equal than outlet temperature", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(100, StandardUnits.TEMPERATURE), c) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower or equal than outlet temperature", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidCylindricalStorage) - new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidCylindricalStorage) + invalidCylindricalStorage || expectedSize || expectedException + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower or equal than outlet temperature", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(100, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the cylindrical storage cannot be lower or equal than outlet temperature", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidCylindricalStorage) + new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidCylindricalStorage) } - def "ThermalUnitValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { - when: - List> exceptions = ThermalUnitValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() - - then: - exceptions.size() == expectedSize - Exception ex = exceptions.get(0).exception.get() - ex.class == expectedException.class - ex.message == expectedException.message - - where: - invalidDomesticHotWaterStorage || expectedSize || expectedException - new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the domestic hot water storage cannot be lower than outlet temperature", invalidDomesticHotWaterStorage) - new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidDomesticHotWaterStorage) - new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) - } + def "ThermalUnitValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { + when: + List> exceptions = ThermalUnitValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() + + then: + exceptions.size() == expectedSize + Exception ex = exceptions.get(0).exception.get() + ex.class == expectedException.class + ex.message == expectedException.message + + where: + invalidDomesticHotWaterStorage || expectedSize || expectedException + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(200, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the domestic hot water storage cannot be lower or equal than outlet temperature", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, storageVolumeLvl, Quantities.getQuantity(100, StandardUnits.TEMPERATURE), Quantities.getQuantity(100, StandardUnits.TEMPERATURE), c, Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("Inlet temperature of the domestic hot water storage cannot be lower or equal than outlet temperature", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidDomesticHotWaterStorage) + new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) + } } From 996b85b8ccc2dda100a64daec8fc4df160ed9e9c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 27 Nov 2024 13:59:58 +0100 Subject: [PATCH 32/70] remove storage_volume_lvl_min from resources --- .../io/source/csv/_participants/cylindrical_storage_input.csv | 4 ++-- .../io/source/csv/_thermal/cylindrical_storage_input.csv | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv index 0b0114091..d560ea36b 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ -uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,p_thermal_max,thermal_bus,em -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 +uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,p_thermal_max,thermal_bus,em +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv index 690c43217..211cd2857 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ -uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus,p_thermal_max -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e, 20.0 +uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,thermal_bus,p_thermal_max +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0d95d7f2-49fb-4d49-8636-383a5220384e,20.0 From ad01e5f274a5f72794a4c6b4fe6e6495e1d36579 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 27 Nov 2024 14:07:17 +0100 Subject: [PATCH 33/70] add new parameters to input_entities.sql --- .../edu/ie3/datamodel/io/sink/_sql/input_entities.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql index 9b63f3fba..8c4d48dc5 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql @@ -89,6 +89,7 @@ CREATE TABLE public.cylindrical_storage_input return_temp double precision NOT NULL, storage_volume_lvl double precision NOT NULL, thermal_bus uuid NOT NULL, + p_thermal_max DOUBLE PRECISION NOT NULL, grid_uuid uuid NOT NULL ) WITHOUT OIDS @@ -107,6 +108,8 @@ CREATE TABLE public.thermal_house_input target_temperature DOUBLE PRECISION NOT NULL, thermal_bus UUID NOT NULL, upper_temperature_limit DOUBLE PRECISION NOT NULL, + housing_type TEXT NOT NULL, + number_of_inhabitants TEXT NOT NULL, grid_uuid UUID NOT NULL REFERENCES grids(uuid) ) WITHOUT OIDS From 97f0424c2e7118170071b340f6078b5bbd16c784 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 30 Dec 2024 18:27:13 +0100 Subject: [PATCH 34/70] enhance testing for DomesticHotWaterStorageResult in ThermalResultFactoryTest --- .../result/ThermalResultFactoryTest.groovy | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy index 1f22de467..fa95f7d6f 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy @@ -57,6 +57,31 @@ class ThermalResultFactoryTest extends Specification implements FactoryTestHelpe } } + def "A ThermalResultFactory should parse a DomesticHotWaterStorageResult correctly"() { + given: "a thermal result factory and model data" + def resultFactory = new ThermalResultFactory() + Map parameter = [ + "time" : "2020-01-30T17:26:44Z", + "inputModel": "91ec3bcf-1897-4d38-af67-0bf7c9fa73c7", + "qDot" : "2", + "energy" : "3", + "fillLevel" : "20" + ] + when: + Try result = resultFactory.get(new EntityData(parameter, DomesticHotWaterStorageResult)) + + then: + result.success + result.data.get().getClass() == DomesticHotWaterStorageResult + ((DomesticHotWaterStorageResult) result.data.get()).with { + assert time == TIME_UTIL.toZonedDateTime(parameter.get("time")) + assert inputModel == UUID.fromString(parameter.get("inputModel")) + assert qDot == Quantities.getQuantity(Double.parseDouble(parameter.get("qDot")), StandardUnits.HEAT_DEMAND) + assert energy == Quantities.getQuantity(Double.parseDouble(parameter.get("energy")), StandardUnits.ENERGY_RESULT) + assert fillLevel == Quantities.getQuantity(Double.parseDouble(parameter.get("fillLevel")), StandardUnits.FILL_LEVEL) + } + } + def "A ThermalResultFactory should parse a ThermalHouseResult correctly"() { given: "a thermal result factory and model data" def resultFactory = new ThermalResultFactory() From b1524a5137e0acab14236e2297593170d72aa67b Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 30 Dec 2024 18:27:54 +0100 Subject: [PATCH 35/70] add getter for DomesticHotWaterStorageResult --- .../datamodel/io/source/ResultEntitySource.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java b/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java index 72ab4d8b7..d1889c4bd 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java @@ -18,6 +18,7 @@ import edu.ie3.datamodel.models.result.connector.Transformer3WResult; import edu.ie3.datamodel.models.result.system.*; import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult; +import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult; import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult; import edu.ie3.datamodel.utils.Try; import java.time.format.DateTimeFormatter; @@ -95,6 +96,7 @@ public void validate() throws ValidationException { List.of( validate(ThermalHouseResult.class, dataSource, thermalResultFactory), validate(CylindricalStorageResult.class, dataSource, thermalResultFactory), + validate(DomesticHotWaterStorageResult.class, dataSource, thermalResultFactory), validate(SwitchResult.class, dataSource, switchResultFactory), validate(NodeResult.class, dataSource, nodeResultFactory), validate(LineResult.class, dataSource, connectorResultFactory), @@ -336,6 +338,21 @@ public Set getCylindricalStorageResult() throws Source return getResultEntities(CylindricalStorageResult.class, thermalResultFactory); } + /** + * Returns a unique set of {@link DomesticHotWaterStorageResult} 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 DomesticHotWaterStorageResult} which has to + * be checked manually, as {@link DomesticHotWaterStorageResult#equals(Object)} is NOT restricted + * by the uuid of {@link DomesticHotWaterStorageResult}. + * + * @return a set of object and uuid unique {@link DomesticHotWaterStorageResult} entities + */ + public Set getDomesticHotWaterStorageResult() + throws SourceException { + return getResultEntities(DomesticHotWaterStorageResult.class, thermalResultFactory); + } + /** * Returns a unique set of {@link ThermalHouseResult} instances. * From d68ab7d18c4ed6e9e9470ef3dea2e9c03e89b8d6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 30 Dec 2024 18:28:31 +0100 Subject: [PATCH 36/70] adapt getter for fields of DomesticHotWaterStorageResult of ThermalResultFactory --- .../ie3/datamodel/io/factory/result/ThermalResultFactory.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java index 8bb06ba54..3b588a1b1 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java @@ -57,6 +57,8 @@ protected List> getFields(Class entityClass) { minConstructorParams = newSet(TIME, INPUT_MODEL, Q_DOT, INDOOR_TEMPERATURE); } else if (entityClass.equals(CylindricalStorageResult.class)) { minConstructorParams = newSet(TIME, INPUT_MODEL, Q_DOT, ENERGY, FILL_LEVEL); + } else if (entityClass.equals(DomesticHotWaterStorageResult.class)) { + minConstructorParams = newSet(TIME, INPUT_MODEL, Q_DOT, ENERGY, FILL_LEVEL); } return List.of(minConstructorParams); From 74c36735a4433c52f942fb2c95b219cb2462fb74 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 22 Jan 2025 17:24:47 +0100 Subject: [PATCH 37/70] Extend ValidationUtils for validating ThermalGrids --- CHANGELOG.md | 1 + .../ThermalUnitValidationUtils.java | 42 +++++++++++++++++++ .../utils/validation/ValidationUtils.java | 5 +++ .../ThermalUnitValidationUtilsTest.groovy | 28 +++++++++++++ 4 files changed, 76 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16400f306..228090ea0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enhance `WeatherSource` with method to retrieve all time keys after a given key [#572](https://github.com/ie3-institute/PowerSystemDataModel/issues/572) - Adding timeseries for voltage values [#1128](https://github.com/ie3-institute/PowerSystemDataModel/issues/1128) - Added Staudt to list of reviewers [#1190](https://github.com/ie3-institute/PowerSystemDataModel/issues/1190) +- Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) ### Fixed diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index 9edcd6171..106c407a9 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -7,12 +7,14 @@ import edu.ie3.datamodel.exceptions.InvalidEntityException; import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.models.input.container.ThermalGrid; import edu.ie3.datamodel.models.input.thermal.*; import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.Failure; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.stream.Stream; import javax.measure.Quantity; public class ThermalUnitValidationUtils extends ValidationUtils { @@ -58,6 +60,46 @@ private ThermalUnitValidationUtils() { return exceptions; } + /** + * Validates a thermal grid if: + * + *

      + *
    • it is not null + *
    + * + * A "distribution" method, that forwards the check request to specific implementations to fulfill + * the checking task, based on the class of the given object. + * + * @param thermalGrid ThermalGrid to validate + * @return a list of try objects either containing an {@link ValidationException} or an empty + * Success + */ + protected static List> check(ThermalGrid thermalGrid) { + Try isNull = checkNonNull(thermalGrid, "a thermal grid"); + + if (isNull.isFailure()) { + return List.of(isNull); + } + + List> exceptions = new ArrayList<>(); + + // Validate houses + for (ThermalHouseInput house : thermalGrid.houses()) { + exceptions.addAll(checkThermalHouse(house)); + } + + // Validate storages + for (ThermalStorageInput storage : + Stream.concat( + thermalGrid.heatStorages().stream(), + thermalGrid.domesticHotWaterStorages().stream()) + .toList()) { + exceptions.addAll(check(storage)); + } + + return exceptions; + } + /** * Validates a thermalSinkInput if: * diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java index cc04e8489..2859a8b8f 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java @@ -16,6 +16,7 @@ import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput; import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput; import edu.ie3.datamodel.models.input.container.GridContainer; +import edu.ie3.datamodel.models.input.container.ThermalGrid; import edu.ie3.datamodel.models.input.graphics.GraphicInput; import edu.ie3.datamodel.models.input.system.SystemParticipantInput; import edu.ie3.datamodel.models.input.system.type.SystemParticipantTypeInput; @@ -68,6 +69,8 @@ public static void check(Object obj) throws ValidationException { exceptions.addAll(GraphicValidationUtils.check((GraphicInput) obj)); } else if (AssetTypeInput.class.isAssignableFrom(obj.getClass())) { exceptions.addAll(checkAssetType((AssetTypeInput) obj)); + } else if (ThermalGrid.class.isAssignableFrom(obj.getClass())) { + exceptions.addAll(ThermalUnitValidationUtils.check((ThermalGrid) obj)); } else { logNotImplemented(obj); } @@ -152,6 +155,8 @@ else if (SystemParticipantInput.class.isAssignableFrom(assetInput.getClass())) SystemParticipantValidationUtils.check((SystemParticipantInput) assetInput)); else if (ThermalUnitInput.class.isAssignableFrom(assetInput.getClass())) exceptions.addAll(ThermalUnitValidationUtils.check((ThermalUnitInput) assetInput)); + else if (ThermalGrid.class.isAssignableFrom(assetInput.getClass())) + exceptions.addAll(ThermalUnitValidationUtils.check((ThermalUnitInput) assetInput)); else { logNotImplemented(assetInput); } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy index 9f0b2c976..373ac2a6f 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtilsTest.groovy @@ -10,6 +10,7 @@ import edu.ie3.datamodel.exceptions.ValidationException import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.container.ThermalGrid import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput @@ -139,4 +140,31 @@ class ThermalUnitValidationUtilsTest extends Specification { new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³", invalidDomesticHotWaterStorage) new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) } + + def "ThermalUnitValidationUtils.check() works for complete ThermalGrid as well"() { + when: + def thermalBus = ThermalUnitInputTestData.thermalBus + def domesticHotWaterStorageInput = [ + ThermalUnitInputTestData.domesticHotWaterStorageInput + ] + def cylindricalStorageInput = [ + ThermalUnitInputTestData.cylindricalStorageInput + ] + + ThermalGrid thermalGrid = new ThermalGrid(thermalBus, [thermalHouse], cylindricalStorageInput, domesticHotWaterStorageInput) + + + List> exceptions = ThermalUnitValidationUtils.check(thermalGrid).stream().filter { it -> it.failure }.toList() + + then: + exceptions.size() == expectedSize + Exception ex = exceptions.get(0).exception.get() + ex.class == expectedException.class + ex.message == expectedException.message + + + where: + thermalHouse || expectedSize || expectedException + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", thermalHouse) + } } From 0b6efc29f5e2d456686ec35d4bb78cf0ddfd0208 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 23 Jan 2025 18:39:24 +0100 Subject: [PATCH 38/70] fix changelog --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 228090ea0..a95ecf36e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adding timeseries for voltage values [#1128](https://github.com/ie3-institute/PowerSystemDataModel/issues/1128) - Added Staudt to list of reviewers [#1190](https://github.com/ie3-institute/PowerSystemDataModel/issues/1190) - Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) +- Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) +- Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) +- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) ### Fixed @@ -32,9 +35,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `ConnectorValidationUtils` checks if parallel devices is > 0 [#1077](https://github.com/ie3-institute/PowerSystemDataModel/issues/1077) - `GridContainerValidationUtils` checks the connectivity for all defined operation time intervals [#1091](https://github.com/ie3-institute/PowerSystemDataModel/issues/1091) - Implemented a `CongestionResult` [#1097](https://github.com/ie3-institute/PowerSystemDataModel/issues/1097) -- Attribute `pThermalRated` for `ThermalStorage`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) -- Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) -- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) ### Fixed - Fixed `MappingEntryies` not getting processed by adding `Getter` methods for record fields [#1084](https://github.com/ie3-institute/PowerSystemDataModel/issues/1084) From 19bcfb1ed198d49f4e51138546fce32b1b9b4847 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 5 Feb 2025 14:12:19 +0100 Subject: [PATCH 39/70] fix tests after merging dev --- docs/readthedocs/io/ValidationUtils.md | 2 +- .../validation/ThermalValidationUtils.java | 36 ------------------- .../utils/validation/ValidationUtils.java | 2 -- .../ThermalValidationUtilsTest.groovy | 25 +++++++------ 4 files changed, 15 insertions(+), 50 deletions(-) diff --git a/docs/readthedocs/io/ValidationUtils.md b/docs/readthedocs/io/ValidationUtils.md index 7937ac204..4c2bf9194 100644 --- a/docs/readthedocs/io/ValidationUtils.md +++ b/docs/readthedocs/io/ValidationUtils.md @@ -74,7 +74,7 @@ The ValidationUtils include validation checks for... - HpTypeInput - StorageTypeInput - WecTypeInput -- ThermalUnitValidationUtils +- ThermalValidationUtils - ThermalUnitInput - ThermalSinkInput - ThermalHouseInput diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java index 04d8c7a78..cbd63a98a 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java @@ -60,42 +60,6 @@ private ThermalValidationUtils() { return exceptions; } - /** - * Validates a thermal grid if: - * - *
      - *
    • it is not null - *
    - * - * A "distribution" method, that forwards the check request to specific implementations to fulfill - * the checking task, based on the class of the given object. - * - * @param thermalGrid ThermalGrid to validate - * @return a list of try objects either containing an {@link ValidationException} or an empty - * Success - */ - protected static List> check(ThermalGrid thermalGrid) { - Try isNull = checkNonNull(thermalGrid, "a thermal grid"); - - if (isNull.isFailure()) { - return List.of(isNull); - } - - List> exceptions = new ArrayList<>(); - - // Validate houses - for (ThermalHouseInput house : thermalGrid.houses()) { - exceptions.addAll(checkThermalHouse(house)); - } - - // Validate storages - for (ThermalStorageInput storage : thermalGrid.storages()) { - exceptions.addAll(check(storage)); - } - - return exceptions; - } - /** * Validates a thermal grid if: * diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java index b36bcc4d8..80006953b 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java @@ -157,8 +157,6 @@ else if (ThermalUnitInput.class.isAssignableFrom(assetInput.getClass())) exceptions.addAll(ThermalValidationUtils.check((ThermalUnitInput) assetInput)); else if (ThermalGrid.class.isAssignableFrom(assetInput.getClass())) exceptions.addAll(ThermalValidationUtils.check((ThermalUnitInput) assetInput)); - else if (ThermalGrid.class.isAssignableFrom(assetInput.getClass())) - exceptions.addAll(ThermalUnitValidationUtils.check((ThermalUnitInput) assetInput)); else { logNotImplemented(assetInput); } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy index fbdb4ad16..1c1188b1e 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy @@ -70,7 +70,7 @@ class ThermalValidationUtilsTest extends Specification { noExceptionThrown() } - def "ThermalUnitValidationUtils.checkThermalHouse() recognizes all potential errors for a thermal house"() { + def "ThermalValidationUtils.checkThermalHouse() recognizes all potential errors for a thermal house"() { when: List> exceptions = ThermalValidationUtils.check(invalidThermalHouse).stream().filter { it -> it.failure }.toList() @@ -105,7 +105,7 @@ class ThermalValidationUtilsTest extends Specification { noExceptionThrown() } - def "ThermalUnitValidationUtils.checkCylindricalStorage() recognizes all potential errors for a thermal cylindrical storage"() { + def "ThermalValidationUtils.checkCylindricalStorage() recognizes all potential errors for a thermal cylindrical storage"() { when: List> exceptions = ThermalValidationUtils.check(invalidCylindricalStorage).stream().filter { it -> it.failure }.toList() @@ -123,9 +123,9 @@ class ThermalValidationUtilsTest extends Specification { new CylindricalStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidCylindricalStorage) } - def "ThermalUnitValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { + def "ThermalValidationUtils.checkDomesticHotWaterStorage() recognizes all potential errors for a domestic hot water storage"() { when: - List> exceptions = ThermalUnitValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() + List> exceptions = ThermalValidationUtils.check(invalidDomesticHotWaterStorage).stream().filter { it -> it.failure }.toList() then: exceptions.size() == expectedSize @@ -141,7 +141,7 @@ class ThermalValidationUtilsTest extends Specification { new DomesticHotWaterStorageInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, Quantities.getQuantity(-100, StandardUnits.VOLUME), inletTemp, returnTemp, Quantities.getQuantity(-1.05, StandardUnits.SPECIFIC_HEAT_CAPACITY), Quantities.getQuantity(-20, PowerSystemUnits.KILOWATT)) || 1 || new InvalidEntityException("The following quantities have to be positive: -100 ㎥, -1.05 kWh/K*m³, -20 kW", invalidDomesticHotWaterStorage) } - def "ThermalUnitValidationUtils.check() works for complete ThermalGrid as well"() { + def "ThermalValidationUtils.check() works for complete ThermalGrid as well"() { when: def thermalBus = ThermalUnitInputTestData.thermalBus def domesticHotWaterStorageInput = [ @@ -154,7 +154,7 @@ class ThermalValidationUtilsTest extends Specification { ThermalGrid thermalGrid = new ThermalGrid(thermalBus, [thermalHouse], cylindricalStorageInput, domesticHotWaterStorageInput) - List> exceptions = ThermalUnitValidationUtils.check(thermalGrid).stream().filter { it -> it.failure }.toList() + List> exceptions = ThermalValidationUtils.check(thermalGrid).stream().filter { it -> it.failure }.toList() then: exceptions.size() == expectedSize @@ -168,15 +168,18 @@ class ThermalValidationUtilsTest extends Specification { new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, HOUSING_TYPE, NUMBER_INHABITANTS) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", thermalHouse) } - def "ThermalUnitValidationUtils.check() works for complete ThermalGrid as well"() { + def "ThermalValidationUtils.check() works for complete ThermalGrid as well"() { when: def thermalBus = ThermalUnitInputTestData.thermalBus def cylindricalStorageInput = [ - ThermalUnitInputTestData.cylindricStorageInput + ThermalUnitInputTestData.cylindricalStorageInput + ] + def domesticHotWaterStorageInput = [ + ThermalUnitInputTestData.domesticHotWaterStorageInput ] - ThermalGrid thermalGrid = new ThermalGrid(thermalBus, [thermalHouse], cylindricalStorageInput) + ThermalGrid thermalGrid = new ThermalGrid(thermalBus, [thermalHouse], cylindricalStorageInput, domesticHotWaterStorageInput) List> exceptions = ThermalValidationUtils.check(thermalGrid).stream().filter { it -> it.failure }.toList() @@ -189,7 +192,7 @@ class ThermalValidationUtilsTest extends Specification { where: - thermalHouse || expectedSize || expectedException - new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", thermalHouse) + thermalHouse || expectedSize || expectedException + new ThermalHouseInput(thermalUnitUuid, id, operator, operationTime, SystemParticipantTestData.thermalBus, thermalConductance, ethCapa, Quantities.getQuantity(0, StandardUnits.TEMPERATURE), UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT, "house", 2) || 1 || new InvalidEntityException("Target temperature must be higher than lower temperature limit and lower than upper temperature limit", thermalHouse) } } From 763507bef72d296be93f752f63a7a3af2f4d9010 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 5 Feb 2025 14:15:38 +0100 Subject: [PATCH 40/70] fix changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7742f8f..b7b8d2ba3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adding timeseries for voltage values [#1128](https://github.com/ie3-institute/PowerSystemDataModel/issues/1128) - Added Staudt to list of reviewers [#1190](https://github.com/ie3-institute/PowerSystemDataModel/issues/1190) - Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) -- Enhance `TimeSeriesSource` with method to retrieve the previous value before a given key [#1182](https://github.com/ie3-institute/PowerSystemDataModel/issues/1182) -- Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) +- Enhance `TimeSeriesSource` with method to retrieve the previous value before a given key [#1182](https://github.com/ie3-institute/PowerSystemDataModel/issues/1182) - Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) - Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) From 02e37af0b4925bfe106e643df5c365d804eafe6d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 5 Feb 2025 14:18:38 +0100 Subject: [PATCH 41/70] fmt --- CHANGELOG.md | 2 +- .../utils/validation/ThermalValidationUtilsTest.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b8d2ba3..7c6b6824d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adding timeseries for voltage values [#1128](https://github.com/ie3-institute/PowerSystemDataModel/issues/1128) - Added Staudt to list of reviewers [#1190](https://github.com/ie3-institute/PowerSystemDataModel/issues/1190) - Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) -- Enhance `TimeSeriesSource` with method to retrieve the previous value before a given key [#1182](https://github.com/ie3-institute/PowerSystemDataModel/issues/1182) +- Enhance `TimeSeriesSource` with method to retrieve the previous value before a given key [#1182](https://github.com/ie3-institute/PowerSystemDataModel/issues/1182) - Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) - Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy index 1c1188b1e..76ccec889 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ThermalValidationUtilsTest.groovy @@ -175,7 +175,7 @@ class ThermalValidationUtilsTest extends Specification { ThermalUnitInputTestData.cylindricalStorageInput ] def domesticHotWaterStorageInput = [ - ThermalUnitInputTestData.domesticHotWaterStorageInput + ThermalUnitInputTestData.domesticHotWaterStorageInput ] From 8c73ded10dda10b75233e2406f862c08bb96eec6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 20 Feb 2025 16:58:54 +0100 Subject: [PATCH 42/70] fix wording in docs --- docs/readthedocs/models/input/thermal/cylindricalstorage.md | 2 +- .../readthedocs/models/input/thermal/domestichotwaterstorage.md | 2 +- .../readthedocs/models/result/participant/cylindricalstorage.md | 2 +- .../models/result/participant/domestichotwaterstorage.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/readthedocs/models/input/thermal/cylindricalstorage.md b/docs/readthedocs/models/input/thermal/cylindricalstorage.md index 7ae0994da..5da1828df 100644 --- a/docs/readthedocs/models/input/thermal/cylindricalstorage.md +++ b/docs/readthedocs/models/input/thermal/cylindricalstorage.md @@ -2,7 +2,7 @@ # Cylindrical Thermal Storage -Model of a cylindrical thermal storage using a fluent to store thermal energy. +Model of a cylindrical thermal storage using a fluid to store thermal energy. ## Attributes, Units and Remarks diff --git a/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md b/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md index 81b84879c..4b675451a 100644 --- a/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md +++ b/docs/readthedocs/models/input/thermal/domestichotwaterstorage.md @@ -2,7 +2,7 @@ # Domestic Hot Water Storage -Model of a domestic hot water storage using a fluent to store thermal energy. +Model of a domestic hot water storage using a fluid to store thermal energy. ## Attributes, Units and Remarks diff --git a/docs/readthedocs/models/result/participant/cylindricalstorage.md b/docs/readthedocs/models/result/participant/cylindricalstorage.md index b8a83dbf7..9fe8c5df5 100644 --- a/docs/readthedocs/models/result/participant/cylindricalstorage.md +++ b/docs/readthedocs/models/result/participant/cylindricalstorage.md @@ -2,7 +2,7 @@ # Cylindrical Thermal Storage -Result of a cylindrical thermal storage using a fluent to store thermal energy. +Result of a cylindrical thermal storage using a fluid to store thermal energy. ## Attributes, Units and Remarks diff --git a/docs/readthedocs/models/result/participant/domestichotwaterstorage.md b/docs/readthedocs/models/result/participant/domestichotwaterstorage.md index 122841944..f0cefcd59 100644 --- a/docs/readthedocs/models/result/participant/domestichotwaterstorage.md +++ b/docs/readthedocs/models/result/participant/domestichotwaterstorage.md @@ -2,7 +2,7 @@ # Domestic Hot Water Storage -Result of a domestic hot water storage using a fluent to store thermal energy. +Result of a domestic hot water storage using a fluid to store thermal energy. ## Attributes, Units and Remarks From d8515fcd36bf51e124036d3419fd154889e74cf6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 20 Feb 2025 17:13:12 +0100 Subject: [PATCH 43/70] remove redundant methods that are already in superior class --- .../thermal/DomesticHotWaterStorageInput.java | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 35c827b3f..044b2a89e 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -115,66 +115,5 @@ public static class DomesticHotWaterStorageInputCopyBuilder public DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); } - - @Override - public DomesticHotWaterStorageInputCopyBuilder storageVolumeLvl( - ComparableQuantity storageVolumeLvl) { - this.storageVolumeLvl = storageVolumeLvl; - return this; - } - - @Override - public DomesticHotWaterStorageInputCopyBuilder inletTemp( - ComparableQuantity inletTemp) { - this.inletTemp = inletTemp; - return this; - } - - @Override - public DomesticHotWaterStorageInputCopyBuilder returnTemp( - ComparableQuantity returnTemp) { - this.returnTemp = returnTemp; - return this; - } - - @Override - public DomesticHotWaterStorageInputCopyBuilder c(ComparableQuantity c) { - this.c = c; - return this; - } - - @Override - public DomesticHotWaterStorageInputCopyBuilder pThermalMax( - ComparableQuantity pThermalMax) { - this.pThermalMax = pThermalMax; - return this; - } - - @Override - public DomesticHotWaterStorageInputCopyBuilder scale(Double factor) { - storageVolumeLvl(this.storageVolumeLvl.multiply(factor)); - pThermalMax(this.pThermalMax.multiply(factor)); - return this; - } - - @Override - public DomesticHotWaterStorageInput build() { - return new DomesticHotWaterStorageInput( - getUuid(), - getId(), - getOperator(), - getOperationTime(), - getThermalBus(), - this.storageVolumeLvl, - this.inletTemp, - this.returnTemp, - this.c, - this.pThermalMax); - } - - @Override - protected DomesticHotWaterStorageInputCopyBuilder thisInstance() { - return this; - } } } From eef015a9159cafd559bfa85ab95028a8f31b3449 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 20 Feb 2025 17:14:46 +0100 Subject: [PATCH 44/70] introduced AbstractThermalStorageInputFactory and make factories of cylindrical and domestic storage extending it --- .../AbstractThermalStorageInputFactory.java | 54 +++++++++++++++++++ .../input/CylindricalStorageInputFactory.java | 39 +++----------- .../DomesticHotWaterStorageInputFactory.java | 39 +++----------- 3 files changed, 68 insertions(+), 64 deletions(-) create mode 100644 src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java new file mode 100644 index 000000000..3686c3abe --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java @@ -0,0 +1,54 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.factory.input; + +import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.AssetInput; +import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; +import javax.measure.quantity.Power; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Volume; +import tech.units.indriya.ComparableQuantity; + +public abstract class AbstractThermalStorageInputFactory +extends AssetInputEntityFactory { + + private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; + private static final String INLET_TEMP = "inletTemp"; + private static final String RETURN_TEMP = "returnTemp"; + private static final String C = "c"; + private static final String P_THERMAL_MAX = "pThermalMax"; + + public AbstractThermalStorageInputFactory(Class clazz) { + super(clazz); + } + + @Override + protected String[] getAdditionalFields() { + return new String[] {STORAGE_VOLUME_LVL, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX}; + } + + protected ComparableQuantity getStorageVolumeLvl(ThermalUnitInputEntityData data) { + return data.getQuantity(STORAGE_VOLUME_LVL, StandardUnits.VOLUME); + } + + protected ComparableQuantity getInletTemp(ThermalUnitInputEntityData data) { + return data.getQuantity(INLET_TEMP, StandardUnits.TEMPERATURE); + } + + protected ComparableQuantity getReturnTemp(ThermalUnitInputEntityData data) { + return data.getQuantity(RETURN_TEMP, StandardUnits.TEMPERATURE); + } + + protected ComparableQuantity getSpecificHeatCapacity( + ThermalUnitInputEntityData data) { + return data.getQuantity(C, StandardUnits.SPECIFIC_HEAT_CAPACITY); + } + + protected ComparableQuantity getMaxThermalPower(ThermalUnitInputEntityData data) { + return data.getQuantity(P_THERMAL_MAX, StandardUnits.ACTIVE_POWER_IN); + } +} diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java index 0e1b7d9f8..541aa7f56 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java @@ -6,34 +6,18 @@ package edu.ie3.datamodel.io.factory.input; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput; import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; -import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; import java.util.UUID; -import javax.measure.quantity.Power; -import javax.measure.quantity.Temperature; -import javax.measure.quantity.Volume; -import tech.units.indriya.ComparableQuantity; public class CylindricalStorageInputFactory - extends AssetInputEntityFactory { - private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; - private static final String INLET_TEMP = "inletTemp"; - private static final String RETURN_TEMP = "returnTemp"; - private static final String C = "c"; - private static final String P_THERMAL_MAX = "pThermalMax"; + extends AbstractThermalStorageInputFactory { public CylindricalStorageInputFactory() { super(CylindricalStorageInput.class); } - @Override - protected String[] getAdditionalFields() { - return new String[] {STORAGE_VOLUME_LVL, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX}; - } - @Override protected CylindricalStorageInput buildModel( ThermalUnitInputEntityData data, @@ -41,27 +25,18 @@ protected CylindricalStorageInput buildModel( String id, OperatorInput operator, OperationTime operationTime) { + final ThermalBusInput bus = data.getBusInput(); - final ComparableQuantity storageVolumeLvl = - data.getQuantity(STORAGE_VOLUME_LVL, StandardUnits.VOLUME); - final ComparableQuantity inletTemp = - data.getQuantity(INLET_TEMP, StandardUnits.TEMPERATURE); - final ComparableQuantity returnTemp = - data.getQuantity(RETURN_TEMP, StandardUnits.TEMPERATURE); - final ComparableQuantity c = - data.getQuantity(C, StandardUnits.SPECIFIC_HEAT_CAPACITY); - final ComparableQuantity pThermalMax = - data.getQuantity(P_THERMAL_MAX, StandardUnits.ACTIVE_POWER_IN); return new CylindricalStorageInput( uuid, id, operator, operationTime, bus, - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); + getStorageVolumeLvl(data), + getInletTemp(data), + getReturnTemp(data), + getSpecificHeatCapacity(data), + getMaxThermalPower(data)); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java index 442e1903c..b59ed35bb 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/DomesticHotWaterStorageInputFactory.java @@ -6,34 +6,18 @@ package edu.ie3.datamodel.io.factory.input; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.thermal.DomesticHotWaterStorageInput; import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; -import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; import java.util.UUID; -import javax.measure.quantity.Power; -import javax.measure.quantity.Temperature; -import javax.measure.quantity.Volume; -import tech.units.indriya.ComparableQuantity; public class DomesticHotWaterStorageInputFactory - extends AssetInputEntityFactory { - private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; - private static final String INLET_TEMP = "inletTemp"; - private static final String RETURN_TEMP = "returnTemp"; - private static final String C = "c"; - private static final String P_THERMAL_MAX = "pThermalMax"; + extends AbstractThermalStorageInputFactory { public DomesticHotWaterStorageInputFactory() { super(DomesticHotWaterStorageInput.class); } - @Override - protected String[] getAdditionalFields() { - return new String[] {STORAGE_VOLUME_LVL, INLET_TEMP, RETURN_TEMP, C, P_THERMAL_MAX}; - } - @Override protected DomesticHotWaterStorageInput buildModel( ThermalUnitInputEntityData data, @@ -41,27 +25,18 @@ protected DomesticHotWaterStorageInput buildModel( String id, OperatorInput operator, OperationTime operationTime) { + final ThermalBusInput bus = data.getBusInput(); - final ComparableQuantity storageVolumeLvl = - data.getQuantity(STORAGE_VOLUME_LVL, StandardUnits.VOLUME); - final ComparableQuantity inletTemp = - data.getQuantity(INLET_TEMP, StandardUnits.TEMPERATURE); - final ComparableQuantity returnTemp = - data.getQuantity(RETURN_TEMP, StandardUnits.TEMPERATURE); - final ComparableQuantity c = - data.getQuantity(C, StandardUnits.SPECIFIC_HEAT_CAPACITY); - final ComparableQuantity pThermalMax = - data.getQuantity(P_THERMAL_MAX, StandardUnits.ACTIVE_POWER_IN); return new DomesticHotWaterStorageInput( uuid, id, operator, operationTime, bus, - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); + getStorageVolumeLvl(data), + getInletTemp(data), + getReturnTemp(data), + getSpecificHeatCapacity(data), + getMaxThermalPower(data)); } } From d9e37fb5836ed08ce2ee0a70f24e02dfec52a0bf Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 09:16:04 +0100 Subject: [PATCH 45/70] make inputs private again in CylindricalStorageInput --- .../input/thermal/CylindricalStorageInput.java | 12 ++++++------ .../input/thermal/DomesticHotWaterStorageInput.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 125fdf6e6..e51d1efbc 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -163,13 +163,13 @@ public String toString() { public static class CylindricalStorageInputCopyBuilder extends ThermalStorageInputCopyBuilder { - ComparableQuantity storageVolumeLvl; - ComparableQuantity inletTemp; - ComparableQuantity returnTemp; - ComparableQuantity c; - ComparableQuantity pThermalMax; + private ComparableQuantity storageVolumeLvl; + private ComparableQuantity inletTemp; + private ComparableQuantity returnTemp; + private ComparableQuantity c; + private ComparableQuantity pThermalMax; - CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { + protected CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); this.storageVolumeLvl = entity.getStorageVolumeLvl(); this.inletTemp = entity.getInletTemp(); diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 044b2a89e..64866069d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -112,7 +112,7 @@ public String toString() { public static class DomesticHotWaterStorageInputCopyBuilder extends CylindricalStorageInputCopyBuilder { - public DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { + protected DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); } } From 2023385faed916a913807041d9e8b4e9b41669c2 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 09:16:34 +0100 Subject: [PATCH 46/70] split both storages in ThermalValidationUtils --- .../utils/validation/ThermalValidationUtils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java index cbd63a98a..72ddf489f 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import java.util.stream.Stream; import javax.measure.Quantity; public class ThermalValidationUtils extends ValidationUtils { @@ -88,12 +87,13 @@ private ThermalValidationUtils() { exceptions.addAll(checkThermalHouse(house)); } - // Validate storages - for (ThermalStorageInput storage : - Stream.concat( - thermalGrid.heatStorages().stream(), - thermalGrid.domesticHotWaterStorages().stream()) - .toList()) { + // Validate heat storages + for (ThermalStorageInput storage : thermalGrid.heatStorages()) { + exceptions.addAll(check(storage)); + } + + // Validate domestic hot water storages + for (ThermalStorageInput storage : thermalGrid.domesticHotWaterStorages()) { exceptions.addAll(check(storage)); } From e0a719dddace17365f47a8f05d0d8f8963735a81 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 09:18:13 +0100 Subject: [PATCH 47/70] avoiding concat for getThermalStorages --- .../java/edu/ie3/datamodel/io/source/ThermalSource.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 07f56a611..0b9b2feb0 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -11,6 +11,7 @@ import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.thermal.*; import edu.ie3.datamodel.utils.Try; +import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -125,7 +126,8 @@ public Map getThermalBuses(Map opera * @return a map of UUID to object- and uuid-unique {@link ThermalStorageInput} entities */ public Map getThermalStorages() throws SourceException { - return Stream.concat(getCylindricalStorages().stream(), getDomesticHotWaterStorages().stream()) + return Stream.of(getCylindricalStorages(), getDomesticHotWaterStorages()) + .flatMap(Collection::stream) .collect(Collectors.toMap(ThermalStorageInput::getUuid, storage -> storage)); } @@ -151,9 +153,8 @@ public Map getThermalStorages() throws SourceExceptio public Map getThermalStorages( Map operators, Map thermalBuses) throws SourceException { - return Stream.concat( - getCylindricalStorages(operators, thermalBuses).stream(), - getDomesticHotWaterStorages(operators, thermalBuses).stream()) + return Stream.of(getCylindricalStorages(), getDomesticHotWaterStorages()) + .flatMap(Collection::stream) .collect(Collectors.toMap(ThermalStorageInput::getUuid, storage -> storage)); } From 52dd01c7afffcd24b9cf47d6aa48a46703e0ae7d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 09:18:21 +0100 Subject: [PATCH 48/70] fmt --- .../io/factory/input/AbstractThermalStorageInputFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java index 3686c3abe..f286217c7 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/AbstractThermalStorageInputFactory.java @@ -14,7 +14,7 @@ import tech.units.indriya.ComparableQuantity; public abstract class AbstractThermalStorageInputFactory -extends AssetInputEntityFactory { + extends AssetInputEntityFactory { private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; private static final String INLET_TEMP = "inletTemp"; From aa05e6f2736b70d68cb6aed014416d32bc9eb129 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 09:20:30 +0100 Subject: [PATCH 49/70] use specific methods for thermal storages in CsvThermalGridSource --- .../io/source/csv/CsvThermalGridSource.java | 15 +++++---------- src/main/java/edu/ie3/datamodel/utils/Try.java | 3 ++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java index 8673875e1..85b151635 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java @@ -14,10 +14,7 @@ import edu.ie3.datamodel.io.source.TypeSource; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.container.ThermalGrid; -import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; -import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput; -import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput; -import edu.ie3.datamodel.models.input.thermal.ThermalUnitInput; +import edu.ie3.datamodel.models.input.thermal.*; import edu.ie3.datamodel.utils.Try; import java.nio.file.Path; import java.util.*; @@ -70,13 +67,11 @@ public static List read( Try, SourceException> houses = Try.of( () -> thermalSource.getThermalHouses(operators, buses).values(), SourceException.class); - Try, SourceException> heatStorages = + Try, SourceException> heatStorages = + Try.of(() -> thermalSource.getCylindricalStorages(operators, buses), SourceException.class); + Try, SourceException> waterStorages = Try.of( - () -> thermalSource.getThermalStorages(operators, buses).values(), - SourceException.class); - Try, SourceException> waterStorages = - Try.of( - () -> thermalSource.getThermalStorages(operators, buses).values(), + () -> thermalSource.getDomesticHotWaterStorages(operators, buses), SourceException.class); List exceptions = Try.getExceptions(houses, heatStorages, waterStorages); diff --git a/src/main/java/edu/ie3/datamodel/utils/Try.java b/src/main/java/edu/ie3/datamodel/utils/Try.java index ffe006407..495a8eef8 100644 --- a/src/main/java/edu/ie3/datamodel/utils/Try.java +++ b/src/main/java/edu/ie3/datamodel/utils/Try.java @@ -8,6 +8,7 @@ import static java.util.stream.Collectors.partitioningBy; import edu.ie3.datamodel.exceptions.FailureException; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.exceptions.TryException; import java.util.*; import java.util.function.BiFunction; @@ -638,7 +639,7 @@ public int hashCode() { */ @FunctionalInterface public interface TrySupplier { - T get() throws E; + T get() throws E, SourceException; } /** From df5abb25b420c8696b37a3b40c0781d8b831becb Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 09:33:55 +0100 Subject: [PATCH 50/70] update comment --- .../edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java index 85b151635..03e647c55 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvThermalGridSource.java @@ -63,7 +63,6 @@ public static List read( Map operators = typeSource.getOperators(); Map buses = thermalSource.getThermalBuses(); - // calling Map.values() because we want to map the inputs to their thermal bus Try, SourceException> houses = Try.of( () -> thermalSource.getThermalHouses(operators, buses).values(), SourceException.class); From d38ded08afc7d0473123ff0af3e4e01eb763f2b9 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 10:01:02 +0100 Subject: [PATCH 51/70] split into AbstractThermalStorageInput --- .../thermal/AbstractThermalStorageInput.java | 221 ++++++++++++++++++ .../thermal/CylindricalStorageInput.java | 181 ++------------ .../thermal/DomesticHotWaterStorageInput.java | 35 +-- 3 files changed, 239 insertions(+), 198 deletions(-) create mode 100644 src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java new file mode 100644 index 000000000..940717377 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java @@ -0,0 +1,221 @@ +/* + * © 2025. 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.thermal; + +import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; +import java.util.Objects; +import java.util.UUID; +import javax.measure.quantity.Power; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Volume; +import tech.units.indriya.ComparableQuantity; + +public abstract class AbstractThermalStorageInput extends ThermalStorageInput { + + /** + * @param uuid Unique identifier of a cylindrical storage + * @param id Identifier of the thermal unit + * @param operator operator of the asset + * @param operationTime operation time of the asset + * @param bus Thermal bus, a thermal unit is connected to /** Available storage volume (typically + * in m³) + */ + private final ComparableQuantity storageVolumeLvl; + /** Temperature of the inlet (typically in C) */ + private final ComparableQuantity inletTemp; + /** Temperature of the outlet (typically in C) */ + private final ComparableQuantity returnTemp; + /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ + private final ComparableQuantity c; + /** Maximum permissible thermal power (typically in kW) */ + private final ComparableQuantity pThermalMax; + + AbstractThermalStorageInput( + UUID uuid, + String id, + OperatorInput operator, + OperationTime operationTime, + ThermalBusInput bus, + ComparableQuantity storageVolumeLvl, + ComparableQuantity inletTemp, + ComparableQuantity returnTemp, + ComparableQuantity c, + ComparableQuantity pThermalMax) { + super(uuid, id, operator, operationTime, bus); + this.storageVolumeLvl = storageVolumeLvl; + this.inletTemp = inletTemp; + this.returnTemp = returnTemp; + this.c = c; + this.pThermalMax = pThermalMax; + } + + AbstractThermalStorageInput( + UUID uuid, + String id, + ThermalBusInput bus, + ComparableQuantity storageVolumeLvl, + ComparableQuantity inletTemp, + ComparableQuantity returnTemp, + ComparableQuantity c, + ComparableQuantity pThermalMax) { + super(uuid, id, bus); + this.storageVolumeLvl = storageVolumeLvl; + this.inletTemp = inletTemp; + this.returnTemp = returnTemp; + this.c = c; + this.pThermalMax = pThermalMax; + } + + public ComparableQuantity getStorageVolumeLvl() { + return storageVolumeLvl; + } + + public ComparableQuantity getInletTemp() { + return inletTemp; + } + + public ComparableQuantity getReturnTemp() { + return returnTemp; + } + + public ComparableQuantity getC() { + return c; + } + + public ComparableQuantity getpThermalMax() { + return pThermalMax; + } + + @Override + public AbstractThermalStorageInputCopyBuilder copy() { + return new AbstractThermalStorageInputCopyBuilder(this); + } + + /** + * A builder pattern based approach to create copies of {@link AbstractThermalStorageInput} + * entities with altered field values. For detailed field descriptions refer to java docs of + * {@link AbstractThermalStorageInput} + */ + public static class AbstractThermalStorageInputCopyBuilder + extends ThermalStorageInputCopyBuilder { + + private ComparableQuantity storageVolumeLvl; + private ComparableQuantity inletTemp; + private ComparableQuantity returnTemp; + private ComparableQuantity c; + private ComparableQuantity pThermalMax; + + protected AbstractThermalStorageInputCopyBuilder(AbstractThermalStorageInput entity) { + super(entity); + this.storageVolumeLvl = entity.getStorageVolumeLvl(); + this.inletTemp = entity.getInletTemp(); + this.returnTemp = entity.getReturnTemp(); + this.c = entity.getC(); + this.pThermalMax = entity.getpThermalMax(); + } + + public AbstractThermalStorageInputCopyBuilder storageVolumeLvl( + ComparableQuantity storageVolumeLvl) { + this.storageVolumeLvl = storageVolumeLvl; + return this; + } + + public AbstractThermalStorageInputCopyBuilder inletTemp( + ComparableQuantity inletTemp) { + this.inletTemp = inletTemp; + return this; + } + + public AbstractThermalStorageInputCopyBuilder returnTemp( + ComparableQuantity returnTemp) { + this.returnTemp = returnTemp; + return this; + } + + public AbstractThermalStorageInputCopyBuilder c(ComparableQuantity c) { + this.c = c; + return this; + } + + public AbstractThermalStorageInputCopyBuilder pThermalMax( + ComparableQuantity pThermalMax) { + this.pThermalMax = pThermalMax; + return this; + } + + @Override + public AbstractThermalStorageInputCopyBuilder scale(Double factor) { + storageVolumeLvl(storageVolumeLvl.multiply(factor)); + pThermalMax(pThermalMax.multiply(factor)); + return this; + } + + @Override + public CylindricalStorageInput build() { + return new CylindricalStorageInput( + getUuid(), + getId(), + getOperator(), + getOperationTime(), + getThermalBus(), + storageVolumeLvl, + inletTemp, + returnTemp, + c, + pThermalMax); + } + + @Override + protected AbstractThermalStorageInputCopyBuilder thisInstance() { + return this; + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CylindricalStorageInput that)) return false; + if (!super.equals(o)) return false; + return storageVolumeLvl.equals(that.getStorageVolumeLvl()) + && inletTemp.equals(that.getInletTemp()) + && returnTemp.equals(that.getReturnTemp()) + && c.equals(that.getC()) + && pThermalMax.equals(that.getpThermalMax()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); + } + + @Override + public String toString() { + return "CylindricalStorageInput{" + + "uuid=" + + getUuid() + + ", id=" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", bus=" + + getThermalBus().getUuid() + + ", storageVolumeLvl=" + + storageVolumeLvl + + ", inletTemp=" + + inletTemp + + ", returnTemp=" + + returnTemp + + ", c=" + + c + + ", pThermalMax=" + + pThermalMax + + '}'; + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index e51d1efbc..9792deff4 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -6,10 +6,8 @@ package edu.ie3.datamodel.models.input.thermal; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; -import java.util.Objects; import java.util.UUID; import javax.measure.quantity.Power; import javax.measure.quantity.Temperature; @@ -17,19 +15,10 @@ import tech.units.indriya.ComparableQuantity; /** Thermal storage with cylindrical shape */ -public class CylindricalStorageInput extends ThermalStorageInput { - /** Available storage volume (typically in m³) */ - private final ComparableQuantity storageVolumeLvl; - /** Temperature of the inlet (typically in C) */ - private final ComparableQuantity inletTemp; - /** Temperature of the outlet (typically in C) */ - private final ComparableQuantity returnTemp; - /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ - private final ComparableQuantity c; - /** Maximum permissible thermal power (typically in kW) */ - private final ComparableQuantity pThermalMax; - +public class CylindricalStorageInput extends AbstractThermalStorageInput { /** + * Constructor for CylindricalStorageInput + * * @param uuid Unique identifier of a cylindrical storage * @param id Identifier of the thermal unit * @param operator operator of the asset @@ -52,12 +41,17 @@ public CylindricalStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, operator, operationTime, bus); - this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); - this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); - this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + super( + uuid, + id, + operator, + operationTime, + bus, + storageVolumeLvl, + inletTemp, + returnTemp, + c, + pThermalMax); } /** @@ -79,157 +73,14 @@ public CylindricalStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, bus); - this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); - this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); - this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); - } - - public ComparableQuantity getStorageVolumeLvl() { - return storageVolumeLvl; - } - - public ComparableQuantity getInletTemp() { - return inletTemp; - } - - public ComparableQuantity getReturnTemp() { - return returnTemp; - } - - public ComparableQuantity getC() { - return c; - } - - public ComparableQuantity getpThermalMax() { - return pThermalMax; - } - - @Override - public CylindricalStorageInputCopyBuilder copy() { - return new CylindricalStorageInputCopyBuilder(this); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof CylindricalStorageInput that)) return false; - if (!super.equals(o)) return false; - return storageVolumeLvl.equals(that.storageVolumeLvl) - && inletTemp.equals(that.inletTemp) - && returnTemp.equals(that.returnTemp) - && c.equals(that.c) - && pThermalMax.equals(that.pThermalMax); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); - } - - @Override - public String toString() { - return "CylindricalStorageInput{" - + "uuid=" - + getUuid() - + ", id=" - + getId() - + ", operator=" - + getOperator().getUuid() - + ", operationTime=" - + getOperationTime() - + ", bus=" - + getThermalBus().getUuid() - + ", storageVolumeLvl=" - + storageVolumeLvl - + ", inletTemp=" - + inletTemp - + ", returnTemp=" - + returnTemp - + ", c=" - + c - + ", pThermalMax=" - + pThermalMax - + '}'; + super(uuid, id, bus, storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } - /** - * A builder pattern based approach to create copies of {@link CylindricalStorageInput} entities - * with altered field values. For detailed field descriptions refer to java docs of {@link - * CylindricalStorageInput} - */ public static class CylindricalStorageInputCopyBuilder - extends ThermalStorageInputCopyBuilder { - - private ComparableQuantity storageVolumeLvl; - private ComparableQuantity inletTemp; - private ComparableQuantity returnTemp; - private ComparableQuantity c; - private ComparableQuantity pThermalMax; + extends AbstractThermalStorageInputCopyBuilder { protected CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); - this.storageVolumeLvl = entity.getStorageVolumeLvl(); - this.inletTemp = entity.getInletTemp(); - this.returnTemp = entity.getReturnTemp(); - this.c = entity.getC(); - this.pThermalMax = entity.getpThermalMax(); - } - - public CylindricalStorageInputCopyBuilder storageVolumeLvl( - ComparableQuantity storageVolumeLvl) { - this.storageVolumeLvl = storageVolumeLvl; - return this; - } - - public CylindricalStorageInputCopyBuilder inletTemp(ComparableQuantity inletTemp) { - this.inletTemp = inletTemp; - return this; - } - - public CylindricalStorageInputCopyBuilder returnTemp( - ComparableQuantity returnTemp) { - this.returnTemp = returnTemp; - return this; - } - - public CylindricalStorageInputCopyBuilder c(ComparableQuantity c) { - this.c = c; - return this; - } - - public CylindricalStorageInputCopyBuilder pThermalMax(ComparableQuantity pThermalMax) { - this.pThermalMax = pThermalMax; - return this; - } - - @Override - public CylindricalStorageInputCopyBuilder scale(Double factor) { - storageVolumeLvl(storageVolumeLvl.multiply(factor)); - pThermalMax(pThermalMax.multiply(factor)); - return this; - } - - @Override - public CylindricalStorageInput build() { - return new CylindricalStorageInput( - getUuid(), - getId(), - getOperator(), - getOperationTime(), - getThermalBus(), - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); - } - - @Override - protected CylindricalStorageInputCopyBuilder thisInstance() { - return this; } } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 64866069d..99012f3d4 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -14,7 +14,7 @@ import javax.measure.quantity.Volume; import tech.units.indriya.ComparableQuantity; -public class DomesticHotWaterStorageInput extends CylindricalStorageInput { +public class DomesticHotWaterStorageInput extends AbstractThermalStorageInput { /** * Constructor for DomesticHotWaterStorageInput @@ -78,39 +78,8 @@ public DomesticHotWaterStorageInput( super(uuid, id, bus, storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } - @Override - public DomesticHotWaterStorageInputCopyBuilder copy() { - return new DomesticHotWaterStorageInputCopyBuilder(this); - } - - @Override - public String toString() { - return "DomesticHotWaterStorageInput{" - + "uuid=" - + getUuid() - + ", id=" - + getId() - + ", operator=" - + getOperator().getUuid() - + ", operationTime=" - + getOperationTime() - + ", bus=" - + getThermalBus().getUuid() - + ", storageVolumeLvl=" - + getStorageVolumeLvl() - + ", inletTemp=" - + getInletTemp() - + ", returnTemp=" - + getReturnTemp() - + ", c=" - + getC() - + ", pThermalMax=" - + getpThermalMax() - + '}'; - } - public static class DomesticHotWaterStorageInputCopyBuilder - extends CylindricalStorageInputCopyBuilder { + extends AbstractThermalStorageInputCopyBuilder { protected DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); From d7a512cc1fff4ee4518743fb481663a5e18bc3e6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 10:16:09 +0100 Subject: [PATCH 52/70] removed double entries in changelog --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7504d61d..66a930899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,9 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) - Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) - Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) -- Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) -- Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) -- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) ### Fixed - Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221) From 79960727eb0f31b269fae8d192f0b4d8d6d4a427 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 21 Feb 2025 16:54:15 +0100 Subject: [PATCH 53/70] remove double entry from changelog --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66a930899..e5b9c0d64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,8 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `RandomLoadProfileTimeSeries` [#1232](https://github.com/ie3-institute/PowerSystemDataModel/issues/1232) - Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) -- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) -- Extend ValidationUtils for validating ThermalGrids [#1216](https://github.com/ie3-institute/PowerSystemDataModel/issues/1216) +- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) ### Fixed - Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221) From a765db569e02480e2b12fcd526569a20a338d895 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 13:06:11 +0100 Subject: [PATCH 54/70] fix test input data --- .../io/source/csv/_participants/cylindrical_storage_input.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv index b48e80e60..d560ea36b 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ -uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,p_thermal_max,p_thermal_max,thermal_bus,em -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,20.0,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 +uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,p_thermal_max,thermal_bus,em +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 From fdfbe0088d41c753672179b2bbe23fa7a9dae10e Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 13:06:25 +0100 Subject: [PATCH 55/70] fix CylindricalStorageInput --- .../datamodel/models/input/thermal/CylindricalStorageInput.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 6252efa72..9792deff4 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -52,7 +52,6 @@ public CylindricalStorageInput( returnTemp, c, pThermalMax); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); } /** From fd90159b8287cc18eb5049bfe4d58e25834fd584 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 13:12:51 +0100 Subject: [PATCH 56/70] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4c524d71..ace148413 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `RandomLoadProfileTimeSeries` [#1232](https://github.com/ie3-institute/PowerSystemDataModel/issues/1232) - Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1253](https://github.com/ie3-institute/PowerSystemDataModel/issues/1253) -- Added domestic hot water storage model [#1131](https://github.com/ie3-institute/PowerSystemDataModel/issues/1131) +- Added domestic hot water storage model [#1257](https://github.com/ie3-institute/PowerSystemDataModel/issues/1257) ### Fixed - Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221) From 2d2b26a52cd69e877a81e9abdf9cb36b4fa3b719 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 14:26:00 +0100 Subject: [PATCH 57/70] fix typo in naming --- .../groovy/edu/ie3/test/common/SystemParticipantTestData.groovy | 2 +- .../io/source/csv/_participants/cylindrical_storage_input.csv | 2 +- .../io/source/csv/_thermal/cylindrical_storage_input.csv | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index f3c12c657..7611b78bc 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -178,7 +178,7 @@ class SystemParticipantTestData { public static final ThermalStorageInput thermalStorage = new CylindricalStorageInput( UUID.fromString("8851813b-3a7d-4fee-874b-4df9d724e4b3"), - "test_cylindricThermalStorage", + "test_cylindricalThermalStorage", GridTestData.profBroccoli, OperationTime.notLimited(), thermalBus, diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv index d560ea36b..141286dbb 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,p_thermal_max,thermal_bus,em -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricalThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,20.0,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv index 211cd2857..98f6d91e2 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,thermal_bus,p_thermal_max -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0d95d7f2-49fb-4d49-8636-383a5220384e,20.0 +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricalThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0d95d7f2-49fb-4d49-8636-383a5220384e,20.0 From 0d2fba2b348f35936160077063907c24b9917990 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 14:48:33 +0100 Subject: [PATCH 58/70] rollback changes with regard to AbstractThermalStorageInput --- .../thermal/AbstractThermalStorageInput.java | 221 ------------------ .../thermal/CylindricalStorageInput.java | 183 +++++++++++++-- .../thermal/DomesticHotWaterStorageInput.java | 35 ++- 3 files changed, 199 insertions(+), 240 deletions(-) delete mode 100644 src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java deleted file mode 100644 index 940717377..000000000 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractThermalStorageInput.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * © 2025. 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.thermal; - -import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.input.OperatorInput; -import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; -import java.util.Objects; -import java.util.UUID; -import javax.measure.quantity.Power; -import javax.measure.quantity.Temperature; -import javax.measure.quantity.Volume; -import tech.units.indriya.ComparableQuantity; - -public abstract class AbstractThermalStorageInput extends ThermalStorageInput { - - /** - * @param uuid Unique identifier of a cylindrical storage - * @param id Identifier of the thermal unit - * @param operator operator of the asset - * @param operationTime operation time of the asset - * @param bus Thermal bus, a thermal unit is connected to /** Available storage volume (typically - * in m³) - */ - private final ComparableQuantity storageVolumeLvl; - /** Temperature of the inlet (typically in C) */ - private final ComparableQuantity inletTemp; - /** Temperature of the outlet (typically in C) */ - private final ComparableQuantity returnTemp; - /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ - private final ComparableQuantity c; - /** Maximum permissible thermal power (typically in kW) */ - private final ComparableQuantity pThermalMax; - - AbstractThermalStorageInput( - UUID uuid, - String id, - OperatorInput operator, - OperationTime operationTime, - ThermalBusInput bus, - ComparableQuantity storageVolumeLvl, - ComparableQuantity inletTemp, - ComparableQuantity returnTemp, - ComparableQuantity c, - ComparableQuantity pThermalMax) { - super(uuid, id, operator, operationTime, bus); - this.storageVolumeLvl = storageVolumeLvl; - this.inletTemp = inletTemp; - this.returnTemp = returnTemp; - this.c = c; - this.pThermalMax = pThermalMax; - } - - AbstractThermalStorageInput( - UUID uuid, - String id, - ThermalBusInput bus, - ComparableQuantity storageVolumeLvl, - ComparableQuantity inletTemp, - ComparableQuantity returnTemp, - ComparableQuantity c, - ComparableQuantity pThermalMax) { - super(uuid, id, bus); - this.storageVolumeLvl = storageVolumeLvl; - this.inletTemp = inletTemp; - this.returnTemp = returnTemp; - this.c = c; - this.pThermalMax = pThermalMax; - } - - public ComparableQuantity getStorageVolumeLvl() { - return storageVolumeLvl; - } - - public ComparableQuantity getInletTemp() { - return inletTemp; - } - - public ComparableQuantity getReturnTemp() { - return returnTemp; - } - - public ComparableQuantity getC() { - return c; - } - - public ComparableQuantity getpThermalMax() { - return pThermalMax; - } - - @Override - public AbstractThermalStorageInputCopyBuilder copy() { - return new AbstractThermalStorageInputCopyBuilder(this); - } - - /** - * A builder pattern based approach to create copies of {@link AbstractThermalStorageInput} - * entities with altered field values. For detailed field descriptions refer to java docs of - * {@link AbstractThermalStorageInput} - */ - public static class AbstractThermalStorageInputCopyBuilder - extends ThermalStorageInputCopyBuilder { - - private ComparableQuantity storageVolumeLvl; - private ComparableQuantity inletTemp; - private ComparableQuantity returnTemp; - private ComparableQuantity c; - private ComparableQuantity pThermalMax; - - protected AbstractThermalStorageInputCopyBuilder(AbstractThermalStorageInput entity) { - super(entity); - this.storageVolumeLvl = entity.getStorageVolumeLvl(); - this.inletTemp = entity.getInletTemp(); - this.returnTemp = entity.getReturnTemp(); - this.c = entity.getC(); - this.pThermalMax = entity.getpThermalMax(); - } - - public AbstractThermalStorageInputCopyBuilder storageVolumeLvl( - ComparableQuantity storageVolumeLvl) { - this.storageVolumeLvl = storageVolumeLvl; - return this; - } - - public AbstractThermalStorageInputCopyBuilder inletTemp( - ComparableQuantity inletTemp) { - this.inletTemp = inletTemp; - return this; - } - - public AbstractThermalStorageInputCopyBuilder returnTemp( - ComparableQuantity returnTemp) { - this.returnTemp = returnTemp; - return this; - } - - public AbstractThermalStorageInputCopyBuilder c(ComparableQuantity c) { - this.c = c; - return this; - } - - public AbstractThermalStorageInputCopyBuilder pThermalMax( - ComparableQuantity pThermalMax) { - this.pThermalMax = pThermalMax; - return this; - } - - @Override - public AbstractThermalStorageInputCopyBuilder scale(Double factor) { - storageVolumeLvl(storageVolumeLvl.multiply(factor)); - pThermalMax(pThermalMax.multiply(factor)); - return this; - } - - @Override - public CylindricalStorageInput build() { - return new CylindricalStorageInput( - getUuid(), - getId(), - getOperator(), - getOperationTime(), - getThermalBus(), - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); - } - - @Override - protected AbstractThermalStorageInputCopyBuilder thisInstance() { - return this; - } - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof CylindricalStorageInput that)) return false; - if (!super.equals(o)) return false; - return storageVolumeLvl.equals(that.getStorageVolumeLvl()) - && inletTemp.equals(that.getInletTemp()) - && returnTemp.equals(that.getReturnTemp()) - && c.equals(that.getC()) - && pThermalMax.equals(that.getpThermalMax()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); - } - - @Override - public String toString() { - return "CylindricalStorageInput{" - + "uuid=" - + getUuid() - + ", id=" - + getId() - + ", operator=" - + getOperator().getUuid() - + ", operationTime=" - + getOperationTime() - + ", bus=" - + getThermalBus().getUuid() - + ", storageVolumeLvl=" - + storageVolumeLvl - + ", inletTemp=" - + inletTemp - + ", returnTemp=" - + returnTemp - + ", c=" - + c - + ", pThermalMax=" - + pThermalMax - + '}'; - } -} diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 9792deff4..407466677 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -6,8 +6,10 @@ package edu.ie3.datamodel.models.input.thermal; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; +import java.util.Objects; import java.util.UUID; import javax.measure.quantity.Power; import javax.measure.quantity.Temperature; @@ -15,10 +17,19 @@ import tech.units.indriya.ComparableQuantity; /** Thermal storage with cylindrical shape */ -public class CylindricalStorageInput extends AbstractThermalStorageInput { +public class CylindricalStorageInput extends ThermalStorageInput { + /** Available storage volume (typically in m³) */ + private final ComparableQuantity storageVolumeLvl; + /** Temperature of the inlet (typically in C) */ + private final ComparableQuantity inletTemp; + /** Temperature of the outlet (typically in C) */ + private final ComparableQuantity returnTemp; + /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ + private final ComparableQuantity c; + /** Maximum permissible thermal power (typically in kW) */ + private final ComparableQuantity pThermalMax; + /** - * Constructor for CylindricalStorageInput - * * @param uuid Unique identifier of a cylindrical storage * @param id Identifier of the thermal unit * @param operator operator of the asset @@ -41,17 +52,12 @@ public CylindricalStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super( - uuid, - id, - operator, - operationTime, - bus, - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); + super(uuid, id, operator, operationTime, bus); + this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); + this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); + this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); + this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); } /** @@ -73,14 +79,157 @@ public CylindricalStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, bus, storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); + super(uuid, id, bus); + this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); + this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); + this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); + this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + } + + public ComparableQuantity getStorageVolumeLvl() { + return storageVolumeLvl; + } + + public ComparableQuantity getInletTemp() { + return inletTemp; + } + + public ComparableQuantity getReturnTemp() { + return returnTemp; + } + + public ComparableQuantity getC() { + return c; + } + + public ComparableQuantity getpThermalMax() { + return pThermalMax; + } + + @Override + public CylindricalStorageInputCopyBuilder copy() { + return new CylindricalStorageInputCopyBuilder(this); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CylindricalStorageInput that)) return false; + if (!super.equals(o)) return false; + return storageVolumeLvl.equals(that.storageVolumeLvl) + && inletTemp.equals(that.inletTemp) + && returnTemp.equals(that.returnTemp) + && c.equals(that.c) + && pThermalMax.equals(that.getpThermalMax()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); + } + + @Override + public String toString() { + return "CylindricalStorageInput{" + + "uuid=" + + getUuid() + + ", id=" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", bus=" + + getThermalBus().getUuid() + + ", storageVolumeLvl=" + + storageVolumeLvl + + ", inletTemp=" + + inletTemp + + ", returnTemp=" + + returnTemp + + ", c=" + + c + + ", pThermalMax=" + + pThermalMax + + '}'; } + /** + * A builder pattern based approach to create copies of {@link CylindricalStorageInput} entities + * with altered field values. For detailed field descriptions refer to java docs of {@link + * CylindricalStorageInput} + */ public static class CylindricalStorageInputCopyBuilder - extends AbstractThermalStorageInputCopyBuilder { + extends ThermalStorageInputCopyBuilder { + + private ComparableQuantity storageVolumeLvl; + private ComparableQuantity inletTemp; + private ComparableQuantity returnTemp; + private ComparableQuantity c; + private ComparableQuantity pThermalMax; - protected CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { + CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); + this.storageVolumeLvl = entity.getStorageVolumeLvl(); + this.inletTemp = entity.getInletTemp(); + this.returnTemp = entity.getReturnTemp(); + this.c = entity.getC(); + this.pThermalMax = entity.getpThermalMax(); + } + + public CylindricalStorageInputCopyBuilder storageVolumeLvl( + ComparableQuantity storageVolumeLvl) { + this.storageVolumeLvl = storageVolumeLvl; + return this; + } + + public CylindricalStorageInputCopyBuilder inletTemp(ComparableQuantity inletTemp) { + this.inletTemp = inletTemp; + return this; + } + + public CylindricalStorageInputCopyBuilder returnTemp( + ComparableQuantity returnTemp) { + this.returnTemp = returnTemp; + return this; + } + + public CylindricalStorageInputCopyBuilder c(ComparableQuantity c) { + this.c = c; + return this; + } + + public CylindricalStorageInputCopyBuilder pThermalMax(ComparableQuantity pThermalMax) { + this.pThermalMax = pThermalMax; + return this; + } + + @Override + public CylindricalStorageInputCopyBuilder scale(Double factor) { + storageVolumeLvl(storageVolumeLvl.multiply(factor)); + pThermalMax(pThermalMax.multiply(factor)); + return this; + } + + @Override + public CylindricalStorageInput build() { + return new CylindricalStorageInput( + getUuid(), + getId(), + getOperator(), + getOperationTime(), + getThermalBus(), + storageVolumeLvl, + inletTemp, + returnTemp, + c, + pThermalMax); + } + + @Override + protected CylindricalStorageInputCopyBuilder thisInstance() { + return this; } } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 99012f3d4..64866069d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -14,7 +14,7 @@ import javax.measure.quantity.Volume; import tech.units.indriya.ComparableQuantity; -public class DomesticHotWaterStorageInput extends AbstractThermalStorageInput { +public class DomesticHotWaterStorageInput extends CylindricalStorageInput { /** * Constructor for DomesticHotWaterStorageInput @@ -78,8 +78,39 @@ public DomesticHotWaterStorageInput( super(uuid, id, bus, storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } + @Override + public DomesticHotWaterStorageInputCopyBuilder copy() { + return new DomesticHotWaterStorageInputCopyBuilder(this); + } + + @Override + public String toString() { + return "DomesticHotWaterStorageInput{" + + "uuid=" + + getUuid() + + ", id=" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", bus=" + + getThermalBus().getUuid() + + ", storageVolumeLvl=" + + getStorageVolumeLvl() + + ", inletTemp=" + + getInletTemp() + + ", returnTemp=" + + getReturnTemp() + + ", c=" + + getC() + + ", pThermalMax=" + + getpThermalMax() + + '}'; + } + public static class DomesticHotWaterStorageInputCopyBuilder - extends AbstractThermalStorageInputCopyBuilder { + extends CylindricalStorageInputCopyBuilder { protected DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); From bb86ba5d4f57bdc0b501f03a52a1850deb42385d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 14:50:59 +0100 Subject: [PATCH 59/70] fmt changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ace148413..f09ecbf14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,9 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enhance `TimeSeriesSource` with method to retrieve the previous value before a given key [#1182](https://github.com/ie3-institute/PowerSystemDataModel/issues/1182) - Added `BdewLoadProfileTimeSeries` [#1230](https://github.com/ie3-institute/PowerSystemDataModel/issues/1230) - Added `RandomLoadProfileTimeSeries` [#1232](https://github.com/ie3-institute/PowerSystemDataModel/issues/1232) -- Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) +- Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1253](https://github.com/ie3-institute/PowerSystemDataModel/issues/1253) -- Added domestic hot water storage model [#1257](https://github.com/ie3-institute/PowerSystemDataModel/issues/1257) +- - Added domestic hot water storage model [#1257](https://github.com/ie3-institute/PowerSystemDataModel/issues/1257) ### Fixed - Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221) From ed4ab8ac187c7d26c00d573861f522643a388e18 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 14:51:50 +0100 Subject: [PATCH 60/70] fix uml --- docs/uml/main/input/ThermalDatamodelConcept.puml | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/uml/main/input/ThermalDatamodelConcept.puml b/docs/uml/main/input/ThermalDatamodelConcept.puml index 39aa15934..fcdd24472 100644 --- a/docs/uml/main/input/ThermalDatamodelConcept.puml +++ b/docs/uml/main/input/ThermalDatamodelConcept.puml @@ -129,6 +129,7 @@ package models { - inletTemp: ComparableQuantity [°C] - returnTemp: ComparableQuantity [°C] - c: ComparableQuantity [kWh/(K*m³)] + - pThermalMax: ComparableQuantity [kW] } DomesticHotWaterStorageInput --|> ThermalStorageInput } From 6de65f359123bf218654d228ed3a798ca84c4e34 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 24 Feb 2025 14:53:14 +0100 Subject: [PATCH 61/70] fmt --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f09ecbf14..89b866d0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `RandomLoadProfileTimeSeries` [#1232](https://github.com/ie3-institute/PowerSystemDataModel/issues/1232) - Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679) - Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1253](https://github.com/ie3-institute/PowerSystemDataModel/issues/1253) -- - Added domestic hot water storage model [#1257](https://github.com/ie3-institute/PowerSystemDataModel/issues/1257) +- Added domestic hot water storage model [#1257](https://github.com/ie3-institute/PowerSystemDataModel/issues/1257) ### Fixed - Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221) From 7656fc59407f13961dd6e0a4ba857386e831f7c1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 10:13:50 +0100 Subject: [PATCH 62/70] fmt ThermalDatamodelConcept.puml --- docs/uml/main/input/ThermalDatamodelConcept.puml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/uml/main/input/ThermalDatamodelConcept.puml b/docs/uml/main/input/ThermalDatamodelConcept.puml index fcdd24472..1f07c2b54 100644 --- a/docs/uml/main/input/ThermalDatamodelConcept.puml +++ b/docs/uml/main/input/ThermalDatamodelConcept.puml @@ -125,13 +125,13 @@ package models { CylindricalStorageInput --|> ThermalStorageInput class DomesticHotWaterStorageInput { - - storageVolumeLvl: ComparableQuantity [m³] - - inletTemp: ComparableQuantity [°C] - - returnTemp: ComparableQuantity [°C] - - c: ComparableQuantity [kWh/(K*m³)] - - pThermalMax: ComparableQuantity [kW] - } - DomesticHotWaterStorageInput --|> ThermalStorageInput + - storageVolumeLvl: ComparableQuantity [m³] + - inletTemp: ComparableQuantity [°C] + - returnTemp: ComparableQuantity [°C] + - c: ComparableQuantity [kWh/(K*m³)] + - pThermalMax: ComparableQuantity [kW] + } + DomesticHotWaterStorageInput --|> ThermalStorageInput } } } From c8ffad5f298c3d400f103d38f2b3f2d429502d85 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 10:20:17 +0100 Subject: [PATCH 63/70] use .collect(toMap()) --- src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 0b9b2feb0..ea714ab19 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -15,7 +15,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -128,7 +127,7 @@ public Map getThermalBuses(Map opera public Map getThermalStorages() throws SourceException { return Stream.of(getCylindricalStorages(), getDomesticHotWaterStorages()) .flatMap(Collection::stream) - .collect(Collectors.toMap(ThermalStorageInput::getUuid, storage -> storage)); + .collect(toMap()); } /** @@ -155,7 +154,7 @@ public Map getThermalStorages( throws SourceException { return Stream.of(getCylindricalStorages(), getDomesticHotWaterStorages()) .flatMap(Collection::stream) - .collect(Collectors.toMap(ThermalStorageInput::getUuid, storage -> storage)); + .collect(toMap()); } /** From 274ca0ea9a3c0f9a305987b8d52f2b1623e508e7 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 10:20:26 +0100 Subject: [PATCH 64/70] remove artefact --- src/main/java/edu/ie3/datamodel/utils/Try.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/edu/ie3/datamodel/utils/Try.java b/src/main/java/edu/ie3/datamodel/utils/Try.java index 495a8eef8..ffe006407 100644 --- a/src/main/java/edu/ie3/datamodel/utils/Try.java +++ b/src/main/java/edu/ie3/datamodel/utils/Try.java @@ -8,7 +8,6 @@ import static java.util.stream.Collectors.partitioningBy; import edu.ie3.datamodel.exceptions.FailureException; -import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.exceptions.TryException; import java.util.*; import java.util.function.BiFunction; @@ -639,7 +638,7 @@ public int hashCode() { */ @FunctionalInterface public interface TrySupplier { - T get() throws E, SourceException; + T get() throws E; } /** From 6eaaf33487b0f7161956797d1b4a22a5cd7240a4 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 10:25:51 +0100 Subject: [PATCH 65/70] fmt --- .../ie3/datamodel/models/input/container/ThermalGridTest.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy index 904635bb9..3dcde3c32 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/ThermalGridTest.groovy @@ -47,6 +47,7 @@ class ThermalGridTest extends Specification { def modifiedHouses = [Mock(ThermalHouseInput)] def modifiedHeatStorages = [Mock(CylindricalStorageInput)] def modifiedDomesticHotWaterStorages = [Mock(CylindricalStorageInput)] + when: def modifiedThermalGrid = thermalGrid.copy() .houses(modifiedHouses as Set) From 8c36978f449146976b7c7610685db85235ca94e9 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 10:26:17 +0100 Subject: [PATCH 66/70] make CylindricalStorageInputCopyBuilder protected --- .../datamodel/models/input/thermal/CylindricalStorageInput.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index 407466677..a2288bc0a 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -169,7 +169,7 @@ public static class CylindricalStorageInputCopyBuilder private ComparableQuantity c; private ComparableQuantity pThermalMax; - CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { + protected CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); this.storageVolumeLvl = entity.getStorageVolumeLvl(); this.inletTemp = entity.getInletTemp(); From d77f2910a8c79a4d8bae6b064f6539095ad70d3a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 13:44:23 +0100 Subject: [PATCH 67/70] introduce AbstractStorageInput --- .../input/thermal/AbstractStorageInput.java | 230 ++++++++++++++++++ .../thermal/CylindricalStorageInput.java | 143 ++--------- .../thermal/DomesticHotWaterStorageInput.java | 24 +- 3 files changed, 276 insertions(+), 121 deletions(-) create mode 100644 src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractStorageInput.java diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractStorageInput.java new file mode 100644 index 000000000..a7d495c45 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/AbstractStorageInput.java @@ -0,0 +1,230 @@ +/* + * © 2021. 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.thermal; + +import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; +import java.util.Objects; +import java.util.UUID; +import javax.measure.quantity.Power; +import javax.measure.quantity.Temperature; +import javax.measure.quantity.Volume; +import tech.units.indriya.ComparableQuantity; + +/** Thermal storage with cylindrical shape */ +public abstract class AbstractStorageInput extends ThermalStorageInput { + /** Available storage volume (typically in m³) */ + private final ComparableQuantity storageVolumeLvl; + /** Temperature of the inlet (typically in C) */ + private final ComparableQuantity inletTemp; + /** Temperature of the outlet (typically in C) */ + private final ComparableQuantity returnTemp; + /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ + private final ComparableQuantity c; + /** Maximum permissible thermal power (typically in kW) */ + private final ComparableQuantity pThermalMax; + + /** + * @param uuid Unique identifier of a cylindrical storage + * @param id Identifier of the thermal unit + * @param operator operator of the asset + * @param operationTime operation time of the asset + * @param bus Thermal bus, a thermal unit is connected to + * @param storageVolumeLvl Available storage volume + * @param inletTemp Temperature of the inlet + * @param returnTemp Temperature of the outlet + * @param c Specific heat capacity of the storage medium + * @param pThermalMax Maximum thermal power of the storage + */ + public AbstractStorageInput( + UUID uuid, + String id, + OperatorInput operator, + OperationTime operationTime, + ThermalBusInput bus, + ComparableQuantity storageVolumeLvl, + ComparableQuantity inletTemp, + ComparableQuantity returnTemp, + ComparableQuantity c, + ComparableQuantity pThermalMax) { + super(uuid, id, operator, operationTime, bus); + this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); + this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); + this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); + this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + } + + /** + * @param uuid Unique identifier of a cylindrical storage + * @param id Identifier of the thermal unit + * @param bus Thermal bus, a thermal unit is connected to + * @param storageVolumeLvl Available storage volume + * @param inletTemp Temperature of the inlet + * @param returnTemp Temperature of the outlet + * @param c Specific heat capacity of the storage medium + * @param pThermalMax Maximum thermal power of the storage + */ + public AbstractStorageInput( + UUID uuid, + String id, + ThermalBusInput bus, + ComparableQuantity storageVolumeLvl, + ComparableQuantity inletTemp, + ComparableQuantity returnTemp, + ComparableQuantity c, + ComparableQuantity pThermalMax) { + super(uuid, id, bus); + this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); + this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); + this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); + this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); + this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + } + + public ComparableQuantity getStorageVolumeLvl() { + return storageVolumeLvl; + } + + public ComparableQuantity getInletTemp() { + return inletTemp; + } + + public ComparableQuantity getReturnTemp() { + return returnTemp; + } + + public ComparableQuantity getC() { + return c; + } + + public ComparableQuantity getpThermalMax() { + return pThermalMax; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof AbstractStorageInput that)) return false; + if (!super.equals(o)) return false; + return storageVolumeLvl.equals(that.storageVolumeLvl) + && inletTemp.equals(that.inletTemp) + && returnTemp.equals(that.returnTemp) + && c.equals(that.c) + && pThermalMax.equals(that.getpThermalMax()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); + } + + @Override + public String toString() { + return "CylindricalStorageInput{" + + "uuid=" + + getUuid() + + ", id=" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", bus=" + + getThermalBus().getUuid() + + ", storageVolumeLvl=" + + storageVolumeLvl + + ", inletTemp=" + + inletTemp + + ", returnTemp=" + + returnTemp + + ", c=" + + c + + ", pThermalMax=" + + pThermalMax + + '}'; + } + + /** + * A builder pattern based approach to create copies of {@link AbstractStorageInput} entities with + * altered field values. For detailed field descriptions refer to java docs of {@link + * AbstractStorageInput} + */ + protected abstract static class AbstractStorageInputCopyBuilder< + B extends AbstractStorageInputCopyBuilder> + extends ThermalStorageInputCopyBuilder { + + private ComparableQuantity storageVolumeLvl; + private ComparableQuantity inletTemp; + private ComparableQuantity returnTemp; + private ComparableQuantity c; + private ComparableQuantity pThermalMax; + + protected AbstractStorageInputCopyBuilder(AbstractStorageInput entity) { + super(entity); + + this.storageVolumeLvl = entity.getStorageVolumeLvl(); + this.inletTemp = entity.getInletTemp(); + this.returnTemp = entity.getReturnTemp(); + this.c = entity.getC(); + this.pThermalMax = entity.getpThermalMax(); + } + + public B storageVolumeLvl(ComparableQuantity storageVolumeLvl) { + this.storageVolumeLvl = storageVolumeLvl; + return thisInstance(); + } + + public B inletTemp(ComparableQuantity inletTemp) { + this.inletTemp = inletTemp; + return thisInstance(); + } + + public B returnTemp(ComparableQuantity returnTemp) { + this.returnTemp = returnTemp; + return thisInstance(); + } + + public B c(ComparableQuantity c) { + this.c = c; + return thisInstance(); + } + + public B pThermalMax(ComparableQuantity pThermalMax) { + this.pThermalMax = pThermalMax; + return thisInstance(); + } + + @Override + public B scale(Double factor) { + storageVolumeLvl(storageVolumeLvl.multiply(factor)); + pThermalMax(pThermalMax.multiply(factor)); + return thisInstance(); + } + + public ComparableQuantity getStorageVolumeLvl() { + return storageVolumeLvl; + } + + public ComparableQuantity getInletTemp() { + return inletTemp; + } + + public ComparableQuantity getReturnTemp() { + return returnTemp; + } + + public ComparableQuantity getC() { + return c; + } + + public ComparableQuantity getpThermalMax() { + return pThermalMax; + } + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java index a2288bc0a..9e43ef04b 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInput.java @@ -6,10 +6,8 @@ package edu.ie3.datamodel.models.input.thermal; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.util.quantities.interfaces.SpecificHeatCapacity; -import java.util.Objects; import java.util.UUID; import javax.measure.quantity.Power; import javax.measure.quantity.Temperature; @@ -17,18 +15,7 @@ import tech.units.indriya.ComparableQuantity; /** Thermal storage with cylindrical shape */ -public class CylindricalStorageInput extends ThermalStorageInput { - /** Available storage volume (typically in m³) */ - private final ComparableQuantity storageVolumeLvl; - /** Temperature of the inlet (typically in C) */ - private final ComparableQuantity inletTemp; - /** Temperature of the outlet (typically in C) */ - private final ComparableQuantity returnTemp; - /** Specific heat capacity of the storage medium (typically in kWh/K*m³) */ - private final ComparableQuantity c; - /** Maximum permissible thermal power (typically in kW) */ - private final ComparableQuantity pThermalMax; - +public class CylindricalStorageInput extends AbstractStorageInput { /** * @param uuid Unique identifier of a cylindrical storage * @param id Identifier of the thermal unit @@ -52,12 +39,17 @@ public CylindricalStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, operator, operationTime, bus); - this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); - this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); - this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); + super( + uuid, + id, + operator, + operationTime, + bus, + storageVolumeLvl, + inletTemp, + returnTemp, + c, + pThermalMax); } /** @@ -79,32 +71,7 @@ public CylindricalStorageInput( ComparableQuantity returnTemp, ComparableQuantity c, ComparableQuantity pThermalMax) { - super(uuid, id, bus); - this.storageVolumeLvl = storageVolumeLvl.to(StandardUnits.VOLUME); - this.inletTemp = inletTemp.to(StandardUnits.TEMPERATURE); - this.returnTemp = returnTemp.to(StandardUnits.TEMPERATURE); - this.c = c.to(StandardUnits.SPECIFIC_HEAT_CAPACITY); - this.pThermalMax = pThermalMax.to(StandardUnits.ACTIVE_POWER_IN); - } - - public ComparableQuantity getStorageVolumeLvl() { - return storageVolumeLvl; - } - - public ComparableQuantity getInletTemp() { - return inletTemp; - } - - public ComparableQuantity getReturnTemp() { - return returnTemp; - } - - public ComparableQuantity getC() { - return c; - } - - public ComparableQuantity getpThermalMax() { - return pThermalMax; + super(uuid, id, bus, storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); } @Override @@ -112,23 +79,6 @@ public CylindricalStorageInputCopyBuilder copy() { return new CylindricalStorageInputCopyBuilder(this); } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof CylindricalStorageInput that)) return false; - if (!super.equals(o)) return false; - return storageVolumeLvl.equals(that.storageVolumeLvl) - && inletTemp.equals(that.inletTemp) - && returnTemp.equals(that.returnTemp) - && c.equals(that.c) - && pThermalMax.equals(that.getpThermalMax()); - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), storageVolumeLvl, inletTemp, returnTemp, c, pThermalMax); - } - @Override public String toString() { return "CylindricalStorageInput{" @@ -143,15 +93,15 @@ public String toString() { + ", bus=" + getThermalBus().getUuid() + ", storageVolumeLvl=" - + storageVolumeLvl + + getStorageVolumeLvl() + ", inletTemp=" - + inletTemp + + getInletTemp() + ", returnTemp=" - + returnTemp + + getReturnTemp() + ", c=" - + c + + getC() + ", pThermalMax=" - + pThermalMax + + getpThermalMax() + '}'; } @@ -161,55 +111,10 @@ public String toString() { * CylindricalStorageInput} */ public static class CylindricalStorageInputCopyBuilder - extends ThermalStorageInputCopyBuilder { - - private ComparableQuantity storageVolumeLvl; - private ComparableQuantity inletTemp; - private ComparableQuantity returnTemp; - private ComparableQuantity c; - private ComparableQuantity pThermalMax; + extends AbstractStorageInputCopyBuilder { protected CylindricalStorageInputCopyBuilder(CylindricalStorageInput entity) { super(entity); - this.storageVolumeLvl = entity.getStorageVolumeLvl(); - this.inletTemp = entity.getInletTemp(); - this.returnTemp = entity.getReturnTemp(); - this.c = entity.getC(); - this.pThermalMax = entity.getpThermalMax(); - } - - public CylindricalStorageInputCopyBuilder storageVolumeLvl( - ComparableQuantity storageVolumeLvl) { - this.storageVolumeLvl = storageVolumeLvl; - return this; - } - - public CylindricalStorageInputCopyBuilder inletTemp(ComparableQuantity inletTemp) { - this.inletTemp = inletTemp; - return this; - } - - public CylindricalStorageInputCopyBuilder returnTemp( - ComparableQuantity returnTemp) { - this.returnTemp = returnTemp; - return this; - } - - public CylindricalStorageInputCopyBuilder c(ComparableQuantity c) { - this.c = c; - return this; - } - - public CylindricalStorageInputCopyBuilder pThermalMax(ComparableQuantity pThermalMax) { - this.pThermalMax = pThermalMax; - return this; - } - - @Override - public CylindricalStorageInputCopyBuilder scale(Double factor) { - storageVolumeLvl(storageVolumeLvl.multiply(factor)); - pThermalMax(pThermalMax.multiply(factor)); - return this; } @Override @@ -220,11 +125,11 @@ public CylindricalStorageInput build() { getOperator(), getOperationTime(), getThermalBus(), - storageVolumeLvl, - inletTemp, - returnTemp, - c, - pThermalMax); + getStorageVolumeLvl(), + getInletTemp(), + getReturnTemp(), + getC(), + getpThermalMax()); } @Override diff --git a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java index 64866069d..b26af2c79 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/thermal/DomesticHotWaterStorageInput.java @@ -14,7 +14,7 @@ import javax.measure.quantity.Volume; import tech.units.indriya.ComparableQuantity; -public class DomesticHotWaterStorageInput extends CylindricalStorageInput { +public class DomesticHotWaterStorageInput extends AbstractStorageInput { /** * Constructor for DomesticHotWaterStorageInput @@ -110,10 +110,30 @@ public String toString() { } public static class DomesticHotWaterStorageInputCopyBuilder - extends CylindricalStorageInputCopyBuilder { + extends AbstractStorageInputCopyBuilder { protected DomesticHotWaterStorageInputCopyBuilder(DomesticHotWaterStorageInput entity) { super(entity); } + + @Override + public DomesticHotWaterStorageInput build() { + return new DomesticHotWaterStorageInput( + getUuid(), + getId(), + getOperator(), + getOperationTime(), + getThermalBus(), + getStorageVolumeLvl(), + getInletTemp(), + getReturnTemp(), + getC(), + getpThermalMax()); + } + + @Override + protected DomesticHotWaterStorageInputCopyBuilder thisInstance() { + return this; + } } } From 1267cb3f1ed2116f888cc00fb3009b839da4db53 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 14:00:46 +0100 Subject: [PATCH 68/70] introduce AbstractStorageInput also to puml --- docs/uml/main/input/ThermalDatamodelConcept.puml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/uml/main/input/ThermalDatamodelConcept.puml b/docs/uml/main/input/ThermalDatamodelConcept.puml index 1f07c2b54..5fafcb880 100644 --- a/docs/uml/main/input/ThermalDatamodelConcept.puml +++ b/docs/uml/main/input/ThermalDatamodelConcept.puml @@ -115,6 +115,9 @@ package models { abstract class ThermalStorageInput ThermalStorageInput --|> ThermalUnitInput + abstract class AbstractStorageInput + AbstractStorageInput --|> ThermalStorageInput + class CylindricalStorageInput { - storageVolumeLvl: ComparableQuantity [m³] - inletTemp: ComparableQuantity [°C] @@ -122,7 +125,7 @@ package models { - c: ComparableQuantity [kWh/(K*m³)] - pThermalMax: ComparableQuantity [kW] } - CylindricalStorageInput --|> ThermalStorageInput + CylindricalStorageInput --|> AbstractStorageInput class DomesticHotWaterStorageInput { - storageVolumeLvl: ComparableQuantity [m³] @@ -131,7 +134,7 @@ package models { - c: ComparableQuantity [kWh/(K*m³)] - pThermalMax: ComparableQuantity [kW] } - DomesticHotWaterStorageInput --|> ThermalStorageInput + DomesticHotWaterStorageInput --|> AbstractStorageInput } } } From 12ad54937023cd63f327ea4e3b70636d29f93041 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 14:13:50 +0100 Subject: [PATCH 69/70] introduce changes also to all other puml diagrams --- docs/uml/main/EntitySourceClassDiagram.puml | 8 ++++++-- docs/uml/main/OutputDatamodelConcept.puml | 10 ++++++++-- .../uml/main/input/DefaultInputDirectoryHierarchy.puml | 2 +- .../main/input/DefaultResultDirectoryHierarchy.puml | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/uml/main/EntitySourceClassDiagram.puml b/docs/uml/main/EntitySourceClassDiagram.puml index a9ae77130..d7c0de723 100644 --- a/docs/uml/main/EntitySourceClassDiagram.puml +++ b/docs/uml/main/EntitySourceClassDiagram.puml @@ -130,6 +130,7 @@ class ResultEntitySource { + Set getEvResults() throws SourceException + Set getHpResults() throws SourceException + Set getCylindricalStorageResult() throws SourceException + + Set getDomesticHotWaterStorageResult() throws SourceException + Set getThermalHouseResults() throws SourceException + Set getEmResults() throws SourceException + Set getCongestionResults() throws SourceException @@ -179,6 +180,7 @@ class ThermalSource { - TypeSource typeSource - ThermalBusInputFactory thermalBusInputFactory - CylindricalStorageInputFactory cylindricalStorageInputFactory + - DomesticHotWaterStorageInputFactory domesticHotWaterStorageInputFactory - ThermalHouseInputFactory thermalHouseInputFactory + ThermalSource(TypeSource, DataSource) + Map getThermalBuses() throws SourceException @@ -187,8 +189,10 @@ class ThermalSource { + Map getThermalStorages(Map, Map) throws SourceException + Map getThermalHouses() throws SourceException + Map getThermalHouses(Map, Map) throws SourceException - + Set getCylindricStorages() throws SourceException - + Set getCylindricStorages(Map, Map) throws SourceException + + Set getCylindricalStorages() throws SourceException + + Set getCylindricalStorages(Map, Map) throws SourceException + + Set getDomesticHotWaterStorages() throws SourceException + + Set getDomesticHotWaterStorages(Map, Map) throws SourceException } abstract class TimeSeriesMappingSource { diff --git a/docs/uml/main/OutputDatamodelConcept.puml b/docs/uml/main/OutputDatamodelConcept.puml index de0b7c745..5af946551 100644 --- a/docs/uml/main/OutputDatamodelConcept.puml +++ b/docs/uml/main/OutputDatamodelConcept.puml @@ -130,10 +130,16 @@ package models { } ThermalUnitResult <|-- ThermalStorageResult - class CylindricalStorageResult { + Abstract class AbstractThermalStorageResult { - fillLevel: ComparableQuantity [%] } - ThermalStorageResult <|-- CylindricalStorageResult + ThermalStorageResult <|-- AbstractThermalStorageResult + + class CylindricalStorageResult {} + AbstractThermalStorageResult <|-- CylindricalStorageResult + + class DomesticHotWaterStorageResult {} + AbstractThermalStorageResult <|-- DomesticHotWaterStorageResult } } } diff --git a/docs/uml/main/input/DefaultInputDirectoryHierarchy.puml b/docs/uml/main/input/DefaultInputDirectoryHierarchy.puml index f9bb14f35..f9b8a369b 100644 --- a/docs/uml/main/input/DefaultInputDirectoryHierarchy.puml +++ b/docs/uml/main/input/DefaultInputDirectoryHierarchy.puml @@ -9,7 +9,7 @@ package (.tar.gz) { label "line_input.csv\n//measurement_unit_input.csv//\nnode_input.csv\n//switch_input.csv//\ntransformer_2_w_input.csv\n//transformer_3_w_input.csv//" } package "//thermal//" as th { - label "//cylindrical_storage_input.csv//\n//thermal_bus_input.csv//\n//thermal_house_input.csv//" + label "//cylindrical_storage_input.csv//\n//domestic_hot_water_storage_input.csv//\n//thermal_bus_input.csv//\n//thermal_house_input.csv//" } package participants { label "//bm_input.csv//\n//chp_input.csv//\n//ev_input.csv//\n//evcs_input.csv//\n//fixed_feed_in_input.csv//\n//hp_input.csv//\n//load_input.csv//\n//pv_input.csv//\n//storage_input.csv//\n//wec_input.csv//" diff --git a/docs/uml/main/input/DefaultResultDirectoryHierarchy.puml b/docs/uml/main/input/DefaultResultDirectoryHierarchy.puml index ee194e413..08261fb74 100644 --- a/docs/uml/main/input/DefaultResultDirectoryHierarchy.puml +++ b/docs/uml/main/input/DefaultResultDirectoryHierarchy.puml @@ -6,7 +6,7 @@ package (.tar.gz) { label "//line_result.csv//\n//node_result.csv//\n//switch_result.csv//\n//transformer_2_w_result.csv//\n//transformer_3_w_result.csv//" } package "//thermal//" { - label "//cylindrical_storage_result.csv//\n//thermal_bus_result.csv//\n//thermal_house_result.csv//" + label "//cylindrical_storage_result.csv//\n//domestic_hot_water_storage_result.csv//\n//thermal_bus_result.csv//\n//thermal_house_result.csv//" } package "//participants//" { label "//bm_result.csv//\n//chp_result.csv//\n//ev_result.csv//\n//evcs_result.csv//\n//fixed_feed_in_result.csv//\n//hp_result.csv//\n//load_result.csv//\n//pv_result.csv//\n//storage_result.csv//\n//wec_result.csv//" From 64b7da7dce1f47b50d70b0ee57dc5ef7d1fe9b67 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 25 Feb 2025 14:38:10 +0100 Subject: [PATCH 70/70] use operators and thermalBuses for getThermalStorages --- src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index ea714ab19..f8d73a0a7 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -152,7 +152,9 @@ public Map getThermalStorages() throws SourceExceptio public Map getThermalStorages( Map operators, Map thermalBuses) throws SourceException { - return Stream.of(getCylindricalStorages(), getDomesticHotWaterStorages()) + return Stream.of( + getCylindricalStorages(operators, thermalBuses), + getDomesticHotWaterStorages(operators, thermalBuses)) .flatMap(Collection::stream) .collect(toMap()); }