Skip to content

Commit 04c692d

Browse files
authored
Merge pull request #1254 from ie3-institute/df/#1253-housingType-and-numberInhabitants
Add Attributes housingType and numberInhabitants to ThermalHouses
2 parents d364ce0 + 9d87328 commit 04c692d

File tree

14 files changed

+155
-27
lines changed

14 files changed

+155
-27
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- Added `BdewLoadProfileTimeSeries` [#1230](https://github.com/ie3-institute/PowerSystemDataModel/issues/1230)
1717
- Added `RandomLoadProfileTimeSeries` [#1232](https://github.com/ie3-institute/PowerSystemDataModel/issues/1232)
1818
- Attribute `pThermalRated` for `ThermalStorage`s [#679](https://github.com/ie3-institute/PowerSystemDataModel/issues/679)
19+
- Attributes `housingType` and `numberInhabitants` for `ThermalHouse`s [#1253](https://github.com/ie3-institute/PowerSystemDataModel/issues/1253)
1920

2021
### Fixed
2122
- Removing opened `SwitchInput` during connectivity check [#1221](https://github.com/ie3-institute/PowerSystemDataModel/issues/1221)

docs/readthedocs/io/ValidationUtils.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The ValidationUtils include validation checks for...
7474
- HpTypeInput
7575
- StorageTypeInput
7676
- WecTypeInput
77-
- ThermalUnitValidationUtils
77+
- ThermalValidationUtils
7878
- ThermalUnitInput
7979
- ThermalSinkInput
8080
- ThermalHouseInput

docs/readthedocs/models/input/thermal/thermalhouse.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ This reflects a simple shoe box with transmission losses
5656
* - lowerTemperatureLimit
5757
- °C
5858
- Lower temperature boundary
59+
60+
* - housingType
61+
- –
62+
- Type of building can either be house or flat
63+
64+
* - numberInhabititans
65+
- –
66+
- Number of people living in the house. Double values to enable modeling based on statistical data sources.
5967
6068
```
6169

docs/uml/main/input/ThermalDatamodelConcept.puml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ package models {
107107
- targetTemperature: ComparableQuantity<Temperature> [°C]
108108
- upperTemperatureLimit: ComparableQuantity<Temperature> [°C]
109109
- lowerTemperatureLimit: ComparableQuantity<Temperature> [°C]
110+
- houseType: String ['house' or 'flat']
111+
- numberInhabitants: Double
110112
}
111113
ThermalHouseInput --|> ThermalSinkInput
112114

src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class ThermalHouseInputFactory
2323
private static final String TARGET_TEMPERATURE = "targetTemperature";
2424
private static final String UPPER_TEMPERATURE_LIMIT = "upperTemperatureLimit";
2525
private static final String LOWER_TEMPERATURE_LIMIT = "lowerTemperatureLimit";
26+
private static final String HOUSING_TYPE = "housingType";
27+
private static final String NUMBER_INHABITANTS = "numberInhabitants";
2628

2729
public ThermalHouseInputFactory() {
2830
super(ThermalHouseInput.class);
@@ -31,7 +33,13 @@ public ThermalHouseInputFactory() {
3133
@Override
3234
protected String[] getAdditionalFields() {
3335
return new String[] {
34-
ETH_LOSSES, ETH_CAPA, TARGET_TEMPERATURE, UPPER_TEMPERATURE_LIMIT, LOWER_TEMPERATURE_LIMIT
36+
ETH_LOSSES,
37+
ETH_CAPA,
38+
TARGET_TEMPERATURE,
39+
UPPER_TEMPERATURE_LIMIT,
40+
LOWER_TEMPERATURE_LIMIT,
41+
HOUSING_TYPE,
42+
NUMBER_INHABITANTS
3543
};
3644
}
3745

@@ -53,6 +61,8 @@ protected ThermalHouseInput buildModel(
5361
data.getQuantity(UPPER_TEMPERATURE_LIMIT, StandardUnits.TEMPERATURE);
5462
final ComparableQuantity<Temperature> lowerTemperatureLimit =
5563
data.getQuantity(LOWER_TEMPERATURE_LIMIT, StandardUnits.TEMPERATURE);
64+
final String housingType = data.getField(HOUSING_TYPE);
65+
final double numberInhabitants = data.getDouble(NUMBER_INHABITANTS);
5666
return new ThermalHouseInput(
5767
uuid,
5868
id,
@@ -63,6 +73,8 @@ protected ThermalHouseInput buildModel(
6373
ethCapa,
6474
targetTemperature,
6575
upperTemperatureLimit,
66-
lowerTemperatureLimit);
76+
lowerTemperatureLimit,
77+
housingType,
78+
numberInhabitants);
6779
}
6880
}

src/main/java/edu/ie3/datamodel/models/input/thermal/ThermalHouseInput.java

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public class ThermalHouseInput extends ThermalSinkInput {
2727
private final ComparableQuantity<Temperature> upperTemperatureLimit;
2828
/** Lower boundary temperature of the thermal house model (typically in °C) */
2929
private final ComparableQuantity<Temperature> lowerTemperatureLimit;
30+
/** Type of the building, e.g. house or flat */
31+
private final String housingType;
32+
/** Number of people living in the building, double to allow proper scaling */
33+
private final double numberInhabitants;
3034

3135
/**
3236
* @param uuid Unique identifier of a thermal house model
@@ -37,6 +41,8 @@ public class ThermalHouseInput extends ThermalSinkInput {
3741
* @param targetTemperature Desired target temperature of the thermal house model
3842
* @param upperTemperatureLimit Upper boundary temperature of the thermal house model
3943
* @param lowerTemperatureLimit Lower boundary temperature of the thermal house model
44+
* @param housingType Type of the building: either house or flat
45+
* @param numberInhabitants Number of inhabitants living in this house
4046
*/
4147
public ThermalHouseInput(
4248
UUID uuid,
@@ -46,13 +52,17 @@ public ThermalHouseInput(
4652
ComparableQuantity<HeatCapacity> ethCapa,
4753
ComparableQuantity<Temperature> targetTemperature,
4854
ComparableQuantity<Temperature> upperTemperatureLimit,
49-
ComparableQuantity<Temperature> lowerTemperatureLimit) {
55+
ComparableQuantity<Temperature> lowerTemperatureLimit,
56+
String housingType,
57+
double numberInhabitants) {
5058
super(uuid, id, bus);
5159
this.ethLosses = ethLosses.to(StandardUnits.THERMAL_TRANSMISSION);
5260
this.ethCapa = ethCapa.to(StandardUnits.HEAT_CAPACITY);
5361
this.targetTemperature = targetTemperature.to(StandardUnits.TEMPERATURE);
5462
this.upperTemperatureLimit = upperTemperatureLimit.to(StandardUnits.TEMPERATURE);
5563
this.lowerTemperatureLimit = lowerTemperatureLimit.to(StandardUnits.TEMPERATURE);
64+
this.housingType = housingType;
65+
this.numberInhabitants = numberInhabitants;
5666
}
5767

5868
/**
@@ -66,6 +76,8 @@ public ThermalHouseInput(
6676
* @param targetTemperature Desired target temperature of the thermal house model
6777
* @param upperTemperatureLimit Upper boundary temperature of the thermal house model
6878
* @param lowerTemperatureLimit Lower boundary temperature of the thermal house model
79+
* @param housingType Type of the building: either house or flat
80+
* @param numberInhabitants Number of inhabitants living in this house
6981
*/
7082
public ThermalHouseInput(
7183
UUID uuid,
@@ -77,13 +89,17 @@ public ThermalHouseInput(
7789
ComparableQuantity<HeatCapacity> ethCapa,
7890
ComparableQuantity<Temperature> targetTemperature,
7991
ComparableQuantity<Temperature> upperTemperatureLimit,
80-
ComparableQuantity<Temperature> lowerTemperatureLimit) {
92+
ComparableQuantity<Temperature> lowerTemperatureLimit,
93+
String housingType,
94+
double numberInhabitants) {
8195
super(uuid, id, operator, operationTime, bus);
8296
this.ethLosses = ethLosses.to(StandardUnits.THERMAL_TRANSMISSION);
8397
this.ethCapa = ethCapa.to(StandardUnits.HEAT_CAPACITY);
8498
this.targetTemperature = targetTemperature.to(StandardUnits.TEMPERATURE);
8599
this.upperTemperatureLimit = upperTemperatureLimit.to(StandardUnits.TEMPERATURE);
86100
this.lowerTemperatureLimit = lowerTemperatureLimit.to(StandardUnits.TEMPERATURE);
101+
this.housingType = housingType;
102+
this.numberInhabitants = numberInhabitants;
87103
}
88104

89105
public ComparableQuantity<ThermalConductance> getEthLosses() {
@@ -106,6 +122,14 @@ public ComparableQuantity<Temperature> getLowerTemperatureLimit() {
106122
return lowerTemperatureLimit;
107123
}
108124

125+
public String getHousingType() {
126+
return housingType;
127+
}
128+
129+
public double getNumberOfInhabitants() {
130+
return numberInhabitants;
131+
}
132+
109133
@Override
110134
public ThermalHouseInputCopyBuilder copy() {
111135
return new ThermalHouseInputCopyBuilder(this);
@@ -120,7 +144,9 @@ public boolean equals(Object o) {
120144
&& ethCapa.equals(that.ethCapa)
121145
&& targetTemperature.equals(that.targetTemperature)
122146
&& upperTemperatureLimit.equals(that.upperTemperatureLimit)
123-
&& lowerTemperatureLimit.equals(that.lowerTemperatureLimit);
147+
&& lowerTemperatureLimit.equals(that.lowerTemperatureLimit)
148+
&& Objects.equals(housingType, that.housingType)
149+
&& Objects.equals(numberInhabitants, that.numberInhabitants);
124150
}
125151

126152
@Override
@@ -131,7 +157,9 @@ public int hashCode() {
131157
ethCapa,
132158
targetTemperature,
133159
upperTemperatureLimit,
134-
lowerTemperatureLimit);
160+
lowerTemperatureLimit,
161+
housingType,
162+
numberInhabitants);
135163
}
136164

137165
@Override
@@ -157,6 +185,10 @@ public String toString() {
157185
+ upperTemperatureLimit
158186
+ ", lowerTemperatureLimit="
159187
+ lowerTemperatureLimit
188+
+ ", housingType="
189+
+ housingType
190+
+ ", #inhabitants="
191+
+ numberInhabitants
160192
+ '}';
161193
}
162194

@@ -173,6 +205,8 @@ public static class ThermalHouseInputCopyBuilder
173205
private ComparableQuantity<Temperature> targetTemperature;
174206
private ComparableQuantity<Temperature> upperTemperatureLimit;
175207
private ComparableQuantity<Temperature> lowerTemperatureLimit;
208+
private String housingType;
209+
private double numberInhabitants;
176210

177211
private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) {
178212
super(entity);
@@ -181,6 +215,8 @@ private ThermalHouseInputCopyBuilder(ThermalHouseInput entity) {
181215
this.targetTemperature = entity.getTargetTemperature();
182216
this.upperTemperatureLimit = entity.getUpperTemperatureLimit();
183217
this.lowerTemperatureLimit = entity.getLowerTemperatureLimit();
218+
this.housingType = entity.getHousingType();
219+
this.numberInhabitants = entity.getNumberOfInhabitants();
184220
}
185221

186222
public ThermalHouseInputCopyBuilder ethLosses(
@@ -212,12 +248,23 @@ public ThermalHouseInputCopyBuilder lowerTemperatureLimit(
212248
return this;
213249
}
214250

251+
public ThermalHouseInputCopyBuilder housingType(String housingType) {
252+
this.housingType = housingType;
253+
return this;
254+
}
255+
256+
public ThermalHouseInputCopyBuilder numberInhabitants(double numberInhabitants) {
257+
this.numberInhabitants = numberInhabitants;
258+
return this;
259+
}
260+
215261
@Override
216262
public ThermalHouseInputCopyBuilder scale(Double factor) {
217-
// scale losses as well as capacity to keep equal
263+
// scale losses as well as capacity and number of inhabitants to keep equal
218264
// the time needed to heat a scaled house
219265
ethLosses(ethLosses.multiply(factor));
220266
ethCapa(ethCapa.multiply(factor));
267+
numberInhabitants(numberInhabitants * factor);
221268
return this;
222269
}
223270

@@ -233,7 +280,9 @@ public ThermalHouseInput build() {
233280
ethCapa,
234281
targetTemperature,
235282
upperTemperatureLimit,
236-
lowerTemperatureLimit);
283+
lowerTemperatureLimit,
284+
housingType,
285+
numberInhabitants);
237286
}
238287

239288
@Override

src/main/java/edu/ie3/datamodel/utils/validation/ThermalValidationUtils.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import edu.ie3.datamodel.utils.Try.Failure;
1414
import java.util.ArrayList;
1515
import java.util.List;
16+
import java.util.Set;
1617
import javax.measure.Quantity;
1718

1819
public class ThermalValidationUtils extends ValidationUtils {
@@ -172,6 +173,8 @@ private ThermalValidationUtils() {
172173
* <li>its thermal capacity is positive
173174
* <li>its upper temperature limit is higher than the lower temperature limit
174175
* <li>its target temperature lies between the upper und lower limit temperatures
176+
* <li>its housing type is either `house` or `flat`
177+
* <li>its number of inhabitants is higher than zero
175178
* </ul>
176179
*
177180
* @param thermalHouseInput ThermalHouseInput to validate
@@ -210,9 +213,33 @@ private static List<Try<Void, InvalidEntityException>> checkThermalHouse(
210213
thermalHouseInput)));
211214
}
212215

216+
if (!isValidHousingType(thermalHouseInput.getHousingType())) {
217+
exceptions.add(
218+
new Failure<>(
219+
new InvalidEntityException(
220+
"Housing type must be either 'house' or 'flat'", thermalHouseInput)));
221+
}
222+
223+
if (thermalHouseInput.getNumberOfInhabitants() <= 0) {
224+
exceptions.add(
225+
new Failure<>(
226+
new InvalidEntityException(
227+
"Number of inhabitants must be greater than zero", thermalHouseInput)));
228+
}
229+
213230
return exceptions;
214231
}
215232

233+
/**
234+
* Checks if the housing type is valid (either "house" or "flat").
235+
*
236+
* @param housingType The housing type to check
237+
* @return true if valid, false otherwise
238+
*/
239+
private static boolean isValidHousingType(String housingType) {
240+
return Set.of("house", "flat").contains(housingType.toLowerCase());
241+
}
242+
216243
/**
217244
* Validates a cylindricalStorageInput if:
218245
*

src/test/groovy/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactoryTest.groovy

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class ThermalHouseInputFactoryTest extends Specification implements FactoryTestH
3535
"ethcapa" : "4",
3636
"targetTemperature" : "5",
3737
"upperTemperatureLimit": "6",
38-
"lowerTemperatureLimit": "7"
38+
"lowerTemperatureLimit": "7",
39+
"housingType" : "flat",
40+
"numberInhabitants" : "9",
41+
3942
]
4043
def inputClass = ThermalHouseInput
4144
def thermalBusInput = Mock(ThermalBusInput)
@@ -57,6 +60,8 @@ class ThermalHouseInputFactoryTest extends Specification implements FactoryTestH
5760
assert targetTemperature == getQuant(parameter["targetTemperature"], StandardUnits.TEMPERATURE)
5861
assert upperTemperatureLimit == getQuant(parameter["upperTemperatureLimit"], StandardUnits.TEMPERATURE)
5962
assert lowerTemperatureLimit == getQuant(parameter["lowerTemperatureLimit"], StandardUnits.TEMPERATURE)
63+
assert housingType == parameter["housingType"]
64+
assert numberInhabitants == parameter["numberInhabitants"].toDouble()
6065
}
6166
}
6267
}

src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta {
115115
targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature
116116
upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit
117117
lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit
118+
housingType == ThermalUnitInputTestData.thermalHouseInput.housingType
119+
numberOfInhabitants == ThermalUnitInputTestData.thermalHouseInput.numberOfInhabitants
118120
}
119121

120122
//test method when operators and thermal buses are provided as constructor parameters
@@ -135,6 +137,8 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta {
135137
targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature
136138
upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit
137139
lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit
140+
housingType == ThermalUnitInputTestData.thermalHouseInput.housingType
141+
numberOfInhabitants == ThermalUnitInputTestData.thermalHouseInput.numberOfInhabitants
138142
}
139143
}
140144
}

src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class ThermalHouseInputTest extends Specification {
3838
assert targetTemperature == ThermalUnitInputTestData.TARGET_TEMPERATURE
3939
assert upperTemperatureLimit == ThermalUnitInputTestData.UPPER_TEMPERATURE_LIMIT
4040
assert lowerTemperatureLimit == ThermalUnitInputTestData.LOWER_TEMPERATURE_LIMIT
41+
assert housingType == ThermalUnitInputTestData.HOUSING_TYPE
42+
assert numberOfInhabitants == ThermalUnitInputTestData.NUMBER_INHABITANTS
4143
}
4244
}
4345

@@ -67,12 +69,17 @@ class ThermalHouseInputTest extends Specification {
6769
Quantities.getQuantity(20, StandardUnits.HEAT_CAPACITY),
6870
Quantities.getQuantity(20, StandardUnits.TEMPERATURE),
6971
Quantities.getQuantity(25, StandardUnits.TEMPERATURE),
70-
Quantities.getQuantity(15, StandardUnits.TEMPERATURE))
72+
Quantities.getQuantity(15, StandardUnits.TEMPERATURE),
73+
"house",
74+
2.0
75+
)
7176

7277
expect:
7378
thermalHouseInput.targetTemperature == Quantities.getQuantity(20, StandardUnits.TEMPERATURE)
7479
thermalHouseInput.upperTemperatureLimit == Quantities.getQuantity(25, StandardUnits.TEMPERATURE)
7580
thermalHouseInput.lowerTemperatureLimit == Quantities.getQuantity(15, StandardUnits.TEMPERATURE)
81+
thermalHouseInput.housingType == "house"
82+
thermalHouseInput.numberOfInhabitants == 2.0
7683
}
7784

7885
def "Scaling a ThermalHouseInput via builder should work as expected"() {
@@ -94,6 +101,8 @@ class ThermalHouseInputTest extends Specification {
94101
assert targetTemperature == thermalHouseInput.targetTemperature
95102
assert upperTemperatureLimit == thermalHouseInput.upperTemperatureLimit
96103
assert lowerTemperatureLimit == thermalHouseInput.lowerTemperatureLimit
104+
assert housingType == thermalHouseInput.housingType
105+
assert numberOfInhabitants == thermalHouseInput.numberOfInhabitants * 2d
97106
}
98107
}
99108
}

0 commit comments

Comments
 (0)