Skip to content

Commit 91bea33

Browse files
introduce DomesticHotWaterStorageResult
1 parent 852fa78 commit 91bea33

File tree

8 files changed

+160
-61
lines changed

8 files changed

+160
-61
lines changed

Diff for: src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import edu.ie3.datamodel.models.Entity;
1111
import edu.ie3.datamodel.models.StandardUnits;
1212
import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult;
13+
import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult;
1314
import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult;
1415
import edu.ie3.datamodel.models.result.thermal.ThermalUnitResult;
1516
import java.time.ZonedDateTime;
@@ -28,7 +29,10 @@ public class ThermalResultFactory extends ModelResultFactory<ThermalUnitResult>
2829
private static final String FILL_LEVEL = "fillLevel";
2930

3031
public ThermalResultFactory() {
31-
super(ThermalHouseResult.class, CylindricalStorageResult.class);
32+
super(
33+
ThermalHouseResult.class,
34+
CylindricalStorageResult.class,
35+
DomesticHotWaterStorageResult.class);
3236
}
3337

3438
/**
@@ -38,7 +42,11 @@ public ThermalResultFactory() {
3842
* @param dateTimeFormatter parse date time strings
3943
*/
4044
public ThermalResultFactory(DateTimeFormatter dateTimeFormatter) {
41-
super(dateTimeFormatter, ThermalHouseResult.class, CylindricalStorageResult.class);
45+
super(
46+
dateTimeFormatter,
47+
ThermalHouseResult.class,
48+
CylindricalStorageResult.class,
49+
DomesticHotWaterStorageResult.class);
4250
}
4351

4452
@Override
@@ -75,6 +83,14 @@ protected ThermalUnitResult buildModel(EntityData data) {
7583

7684
return new CylindricalStorageResult(
7785
zdtTime, inputModelUuid, energyQuantity, qDotQuantity, fillLevelQuantity);
86+
} else if (clazz.equals(DomesticHotWaterStorageResult.class)) {
87+
ComparableQuantity<Energy> energyQuantity =
88+
data.getQuantity(ENERGY, StandardUnits.ENERGY_RESULT);
89+
ComparableQuantity<Dimensionless> fillLevelQuantity =
90+
data.getQuantity(FILL_LEVEL, StandardUnits.FILL_LEVEL);
91+
92+
return new DomesticHotWaterStorageResult(
93+
zdtTime, inputModelUuid, energyQuantity, qDotQuantity, fillLevelQuantity);
7894
} else {
7995
throw new FactoryException("Cannot process " + clazz.getSimpleName() + ".class.");
8096
}

Diff for: src/main/java/edu/ie3/datamodel/io/processor/result/ResultEntityProcessor.java

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import edu.ie3.datamodel.models.result.connector.Transformer3WResult;
1919
import edu.ie3.datamodel.models.result.system.*;
2020
import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult;
21+
import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult;
2122
import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult;
2223
import edu.ie3.datamodel.utils.Try;
2324
import edu.ie3.datamodel.utils.Try.*;
@@ -58,6 +59,7 @@ public class ResultEntityProcessor extends EntityProcessor<ResultEntity> {
5859
NodeResult.class,
5960
ThermalHouseResult.class,
6061
CylindricalStorageResult.class,
62+
DomesticHotWaterStorageResult.class,
6163
EmResult.class,
6264
FlexOptionsResult.class,
6365
CongestionResult.class);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* © 2024. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.models.result.thermal;
7+
8+
import edu.ie3.datamodel.models.StandardUnits;
9+
import java.time.ZonedDateTime;
10+
import java.util.Objects;
11+
import java.util.UUID;
12+
import javax.measure.quantity.Dimensionless;
13+
import javax.measure.quantity.Energy;
14+
import javax.measure.quantity.Power;
15+
import tech.units.indriya.ComparableQuantity;
16+
17+
/** Abstract class representing the common results of different types of thermal storages */
18+
public abstract class AbstractThermalStorageResult extends ThermalStorageResult {
19+
/** Fill level of the storage */
20+
private ComparableQuantity<Dimensionless> fillLevel;
21+
22+
/**
23+
* Constructs the result with
24+
*
25+
* @param time date and time when the result is produced
26+
* @param inputModel uuid of the input model that produces the result
27+
* @param energy Currently stored energy
28+
* @param qDot Heat power flowing into (&gt; 0) or coming from (&lt; 0) the storage
29+
* @param fillLevel Fill level of the storage
30+
*/
31+
public AbstractThermalStorageResult(
32+
ZonedDateTime time,
33+
UUID inputModel,
34+
ComparableQuantity<Energy> energy,
35+
ComparableQuantity<Power> qDot,
36+
ComparableQuantity<Dimensionless> fillLevel) {
37+
super(time, inputModel, energy, qDot);
38+
this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL);
39+
}
40+
41+
public ComparableQuantity<Dimensionless> getFillLevel() {
42+
return fillLevel;
43+
}
44+
45+
public void setFillLevel(ComparableQuantity<Dimensionless> fillLevel) {
46+
this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL);
47+
}
48+
49+
@Override
50+
public boolean equals(Object o) {
51+
if (this == o) return true;
52+
if (o == null || getClass() != o.getClass()) return false;
53+
if (!super.equals(o)) return false;
54+
AbstractThermalStorageResult that = (AbstractThermalStorageResult) o;
55+
return fillLevel.equals(that.fillLevel);
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
return Objects.hash(super.hashCode(), fillLevel);
61+
}
62+
63+
@Override
64+
public String toString() {
65+
return getClass().getSimpleName()
66+
+ "{"
67+
+ "time="
68+
+ getTime()
69+
+ ", inputModel="
70+
+ getInputModel()
71+
+ ", qDot="
72+
+ getqDot()
73+
+ ", energy="
74+
+ getEnergy()
75+
+ ", fillLevel="
76+
+ fillLevel
77+
+ '}';
78+
}
79+
}

Diff for: src/main/java/edu/ie3/datamodel/models/result/thermal/CylindricalStorageResult.java

+3-56
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,22 @@
55
*/
66
package edu.ie3.datamodel.models.result.thermal;
77

8-
import edu.ie3.datamodel.models.StandardUnits;
9-
import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput;
108
import java.time.ZonedDateTime;
11-
import java.util.Objects;
129
import java.util.UUID;
1310
import javax.measure.quantity.Dimensionless;
1411
import javax.measure.quantity.Energy;
1512
import javax.measure.quantity.Power;
1613
import tech.units.indriya.ComparableQuantity;
1714

18-
/** Respresents the results of {@link CylindricalStorageInput} */
19-
public class CylindricalStorageResult extends ThermalStorageResult {
20-
/** Fill level of the storage */
21-
private ComparableQuantity<Dimensionless> fillLevel;
15+
/** Represents the results of Cylindrical Storage */
16+
public class CylindricalStorageResult extends AbstractThermalStorageResult {
2217

23-
/**
24-
* Constructs the result with
25-
*
26-
* @param time date and time when the result is produced
27-
* @param inputModel uuid of the input model that produces the result
28-
* @param energy Currently stored energy
29-
* @param qDot Heat power flowing into (&gt; 0) or coming from (&lt; 0) the storage
30-
* @param fillLevel Fill level of the storage
31-
*/
3218
public CylindricalStorageResult(
3319
ZonedDateTime time,
3420
UUID inputModel,
3521
ComparableQuantity<Energy> energy,
3622
ComparableQuantity<Power> qDot,
3723
ComparableQuantity<Dimensionless> fillLevel) {
38-
super(time, inputModel, energy, qDot);
39-
this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL);
40-
}
41-
42-
public ComparableQuantity<Dimensionless> getFillLevel() {
43-
return fillLevel;
44-
}
45-
46-
public void setFillLevel(ComparableQuantity<Dimensionless> fillLevel) {
47-
this.fillLevel = fillLevel.to(StandardUnits.FILL_LEVEL);
48-
}
49-
50-
@Override
51-
public boolean equals(Object o) {
52-
if (this == o) return true;
53-
if (o == null || getClass() != o.getClass()) return false;
54-
if (!super.equals(o)) return false;
55-
CylindricalStorageResult that = (CylindricalStorageResult) o;
56-
return fillLevel.equals(that.fillLevel);
57-
}
58-
59-
@Override
60-
public int hashCode() {
61-
return Objects.hash(super.hashCode(), fillLevel);
62-
}
63-
64-
@Override
65-
public String toString() {
66-
return "CylindricalStorageResult{"
67-
+ "time="
68-
+ getTime()
69-
+ ", inputModel="
70-
+ getInputModel()
71-
+ ", qDot="
72-
+ getqDot()
73-
+ ", energy="
74-
+ getEnergy()
75-
+ ", fillLevel="
76-
+ fillLevel
77-
+ '}';
24+
super(time, inputModel, energy, qDot, fillLevel);
7825
}
7926
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* © 2024. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.models.result.thermal;
7+
8+
import java.time.ZonedDateTime;
9+
import java.util.UUID;
10+
import javax.measure.quantity.Dimensionless;
11+
import javax.measure.quantity.Energy;
12+
import javax.measure.quantity.Power;
13+
import tech.units.indriya.ComparableQuantity;
14+
15+
/** Represents the results of Domestic Hot Water Storage */
16+
public class DomesticHotWaterStorageResult extends AbstractThermalStorageResult {
17+
18+
public DomesticHotWaterStorageResult(
19+
ZonedDateTime time,
20+
UUID inputModel,
21+
ComparableQuantity<Energy> energy,
22+
ComparableQuantity<Power> qDot,
23+
ComparableQuantity<Dimensionless> fillLevel) {
24+
super(time, inputModel, energy, qDot, fillLevel);
25+
}
26+
}

Diff for: src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import edu.ie3.datamodel.exceptions.FactoryException
99
import edu.ie3.datamodel.io.factory.EntityData
1010
import edu.ie3.datamodel.models.StandardUnits
1111
import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult
12+
import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult
1213
import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult
1314
import edu.ie3.datamodel.models.result.thermal.ThermalUnitResult
1415
import edu.ie3.datamodel.utils.Try
@@ -23,7 +24,8 @@ class ThermalResultFactoryTest extends Specification implements FactoryTestHelpe
2324
def resultFactory = new ThermalResultFactory()
2425
def expectedClasses = [
2526
ThermalHouseResult,
26-
CylindricalStorageResult
27+
CylindricalStorageResult,
28+
DomesticHotWaterStorageResult
2729
]
2830

2931
expect:

Diff for: src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import edu.ie3.datamodel.models.result.connector.Transformer2WResult
3535
import edu.ie3.datamodel.models.result.connector.Transformer3WResult
3636
import edu.ie3.datamodel.models.result.system.*
3737
import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult
38+
import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult
3839
import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult
3940
import edu.ie3.datamodel.models.timeseries.IntValue
4041
import edu.ie3.datamodel.models.timeseries.TimeSeries
@@ -121,7 +122,8 @@ class ProcessorProviderTest extends Specification implements TimeSeriesTestData
121122
NodeResult,
122123
CongestionResult,
123124
ThermalHouseResult,
124-
CylindricalStorageResult
125+
CylindricalStorageResult,
126+
DomesticHotWaterStorageResult
125127
]
126128
// currently known processors
127129

Diff for: src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy

+26-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import edu.ie3.datamodel.models.result.connector.Transformer2WResult
1515
import edu.ie3.datamodel.models.result.connector.Transformer3WResult
1616
import edu.ie3.datamodel.models.result.system.*
1717
import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult
18+
import edu.ie3.datamodel.models.result.thermal.DomesticHotWaterStorageResult
1819
import edu.ie3.util.quantities.PowerSystemUnits
1920
import spock.lang.Shared
2021
import spock.lang.Specification
@@ -252,6 +253,30 @@ class ResultEntityProcessorTest extends Specification {
252253
validProcessedElement == expectedResults
253254
}
254255

256+
def "A ResultEntityProcessor should serialize a DomesticHotWaterStorageResult correctly"() {
257+
given:
258+
def sysPartResProcessor = new ResultEntityProcessor(DomesticHotWaterStorageResult)
259+
260+
Quantity<Power> qDot = Quantities.getQuantity(2, StandardUnits.Q_DOT_RESULT)
261+
Quantity<Energy> energy = Quantities.getQuantity(3, StandardUnits.ENERGY_RESULT)
262+
Quantity<Dimensionless> fillLevel = Quantities.getQuantity(20, Units.PERCENT)
263+
264+
def validResult = new DomesticHotWaterStorageResult(ZonedDateTime.parse("2020-01-30T17:26:44Z"), inputModel, energy, qDot, fillLevel)
265+
266+
def expectedResults = [
267+
energy : '3.0',
268+
fillLevel : '20.0',
269+
inputModel: '22bea5fc-2cb2-4c61-beb9-b476e0107f52',
270+
qDot : '2.0',
271+
time : '2020-01-30T17:26:44Z']
272+
273+
when:
274+
def validProcessedElement = sysPartResProcessor.handleEntity(validResult)
275+
276+
then:
277+
validProcessedElement == expectedResults
278+
}
279+
255280
def "A ResultEntityProcessor should throw an EntityProcessorException when it receives an entity result that is not eligible"() {
256281

257282
given:
@@ -270,7 +295,7 @@ class ResultEntityProcessorTest extends Specification {
270295

271296
def "The list of eligible entity classes for a ResultEntityProcessor should be valid"() {
272297
given:
273-
int noOfElements = 20 // number of all currently implemented entity results
298+
int noOfElements = 21 // number of all currently implemented entity results
274299

275300
expect:
276301
ResultEntityProcessor.eligibleEntityClasses.size() == noOfElements

0 commit comments

Comments
 (0)