Skip to content

Commit 8ae31c6

Browse files
committed
Adapt to changes in dev.
1 parent 279e586 commit 8ae31c6

File tree

4 files changed

+33
-25
lines changed

4 files changed

+33
-25
lines changed

src/main/java/edu/ie3/datamodel/io/factory/timeseries/RandomLoadProfileFactory.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import edu.ie3.datamodel.models.value.load.RandomLoadValues;
1515
import edu.ie3.util.quantities.PowerSystemUnits;
1616
import java.util.List;
17-
import java.util.Optional;
1817
import java.util.Set;
1918
import javax.measure.quantity.Energy;
2019
import javax.measure.quantity.Power;
@@ -74,7 +73,13 @@ protected List<Set<String>> getFields(Class<?> entityClass) {
7473
@Override
7574
public RandomLoadProfileTimeSeries build(
7675
LoadProfileMetaInformation metaInformation, Set<LoadProfileEntry<RandomLoadValues>> entries) {
77-
return new RandomLoadProfileTimeSeries(metaInformation.getUuid(), RANDOM_LOAD_PROFILE, entries);
76+
RandomLoadProfile profile = RANDOM_LOAD_PROFILE;
77+
78+
ComparableQuantity<Power> maxPower = calculateMaxPower(profile, entries);
79+
ComparableQuantity<Energy> profileEnergyScaling = getLoadProfileEnergyScaling(profile);
80+
81+
return new RandomLoadProfileTimeSeries(
82+
metaInformation.getUuid(), profile, entries, maxPower, profileEnergyScaling);
7883
}
7984

8085
@Override
@@ -83,14 +88,13 @@ public RandomLoadProfile parseProfile(String profile) {
8388
}
8489

8590
@Override
86-
public Optional<ComparableQuantity<Power>> calculateMaxPower(
91+
public ComparableQuantity<Power> calculateMaxPower(
8792
RandomLoadProfile loadProfile, Set<LoadProfileEntry<RandomLoadValues>> loadProfileEntries) {
88-
return Optional.of(Quantities.getQuantity(159d, PowerSystemUnits.WATT));
93+
return Quantities.getQuantity(159d, PowerSystemUnits.WATT);
8994
}
9095

9196
@Override
92-
public Optional<ComparableQuantity<Energy>> getLoadProfileEnergyScaling(
93-
RandomLoadProfile loadProfile) {
94-
return Optional.of(Quantities.getQuantity(716.5416966513656, PowerSystemUnits.KILOWATTHOUR));
97+
public ComparableQuantity<Energy> getLoadProfileEnergyScaling(RandomLoadProfile loadProfile) {
98+
return Quantities.getQuantity(716.5416966513656, PowerSystemUnits.KILOWATTHOUR);
9599
}
96100
}

src/main/java/edu/ie3/datamodel/models/timeseries/repetitive/LoadProfileTimeSeries.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
import edu.ie3.datamodel.models.value.PValue;
1010
import edu.ie3.datamodel.models.value.load.LoadValues;
1111
import edu.ie3.datamodel.utils.TimeSeriesUtils;
12+
import edu.ie3.util.quantities.PowerSystemUnits;
1213
import java.time.ZonedDateTime;
1314
import java.util.*;
1415
import java.util.stream.Collectors;
1516
import javax.measure.quantity.Energy;
1617
import javax.measure.quantity.Power;
1718
import tech.units.indriya.ComparableQuantity;
19+
import tech.units.indriya.quantity.Quantities;
1820

1921
/**
2022
* Describes a load profile time series with repetitive values that can be calculated from a pattern
@@ -25,8 +27,8 @@ public class LoadProfileTimeSeries<V extends LoadValues>
2527
private final Map<Integer, V> valueMapping;
2628

2729
/**
28-
* The maximum average power consumption per quarter-hour for a given calculated over all seasons
29-
* and weekday types of given load profile.
30+
* The maximum average power consumption per quarter-hour calculated over all seasons and weekday
31+
* types of given load profile.
3032
*/
3133
public final ComparableQuantity<Power> maxPower;
3234

@@ -46,8 +48,13 @@ public LoadProfileTimeSeries(
4648
.collect(
4749
Collectors.toMap(LoadProfileEntry::getQuarterHour, LoadProfileEntry::getValue));
4850

49-
this.maxPower = maxPower;
50-
this.profileEnergyScaling = profileEnergyScaling;
51+
// use default value is null value is given
52+
this.maxPower =
53+
Optional.ofNullable(maxPower)
54+
.orElseGet(() -> Quantities.getQuantity(0d, PowerSystemUnits.KILOWATT));
55+
this.profileEnergyScaling =
56+
Optional.ofNullable(profileEnergyScaling)
57+
.orElseGet(() -> Quantities.getQuantity(1000d, PowerSystemUnits.KILOWATTHOUR));
5158
}
5259

5360
/** Returns the {@link LoadProfile}. */

src/main/java/edu/ie3/datamodel/models/timeseries/repetitive/RandomLoadProfileTimeSeries.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import de.lmu.ifi.dbs.elki.math.statistics.distribution.GeneralizedExtremeValueDistribution;
99
import edu.ie3.datamodel.models.profile.LoadProfile;
1010
import edu.ie3.datamodel.models.value.load.RandomLoadValues;
11-
import edu.ie3.util.quantities.PowerSystemUnits;
1211
import java.util.Objects;
13-
import java.util.Optional;
1412
import java.util.Set;
1513
import java.util.UUID;
16-
import tech.units.indriya.quantity.Quantities;
14+
import javax.measure.quantity.Energy;
15+
import javax.measure.quantity.Power;
16+
import tech.units.indriya.ComparableQuantity;
1717

1818
/**
1919
* Describes a random load profile time series based on a {@link
@@ -22,13 +22,12 @@
2222
public class RandomLoadProfileTimeSeries extends LoadProfileTimeSeries<RandomLoadValues> {
2323

2424
public RandomLoadProfileTimeSeries(
25-
UUID uuid, LoadProfile loadProfile, Set<LoadProfileEntry<RandomLoadValues>> entries) {
26-
super(
27-
uuid,
28-
loadProfile,
29-
entries,
30-
Optional.empty(),
31-
Optional.of(Quantities.getQuantity(716.5416966513656, PowerSystemUnits.KILOWATTHOUR)));
25+
UUID uuid,
26+
LoadProfile loadProfile,
27+
Set<LoadProfileEntry<RandomLoadValues>> entries,
28+
ComparableQuantity<Power> maxPower,
29+
ComparableQuantity<Energy> profileEnergyScaling) {
30+
super(uuid, loadProfile, entries, maxPower, profileEnergyScaling);
3231
}
3332

3433
@Override

src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/RandomLoadProfileFactoryTest.groovy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,14 @@ class RandomLoadProfileFactoryTest extends Specification {
148148
def maxPower = factory.calculateMaxPower(LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE, allEntries)
149149

150150
then:
151-
maxPower.isPresent()
152-
maxPower.get() == Quantities.getQuantity(159d, PowerSystemUnits.WATT)
151+
maxPower == Quantities.getQuantity(159d, PowerSystemUnits.WATT)
153152
}
154153

155154
def "A RandomLoadProfileFactory does return an energy scaling correctly"() {
156155
when:
157156
def energyScaling = factory.getLoadProfileEnergyScaling(LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE)
158157

159158
then:
160-
energyScaling.isPresent()
161-
energyScaling.get() == Quantities.getQuantity(716.5416966513656, PowerSystemUnits.KILOWATTHOUR)
159+
energyScaling == Quantities.getQuantity(716.5416966513656, PowerSystemUnits.KILOWATTHOUR)
162160
}
163161
}

0 commit comments

Comments
 (0)