Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pp/#1089-enhance-loadinput-by-ca…
Browse files Browse the repository at this point in the history
…tegories-for-markov' into pp/#1089-enhance-loadinput-by-categories-for-markov
  • Loading branch information
pierrepetersmeier committed Jun 11, 2024
2 parents b8b52a5 + e5b9ef1 commit 65dc940
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 169 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed `equals` of `ResultEntity` and `TimeSeriesEntry` [#1037](https://github.com/ie3-institute/PowerSystemDataModel/issues/1037)
- Fixed "depth of discharge" in documentation [#872](https://github.com/ie3-institute/PowerSystemDataModel/issues/872)

## [5.0.0] - 2024-03-06

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'signing'
id 'pmd' // code check, working on source code
id 'com.diffplug.spotless' version '6.25.0' //code format
id 'com.github.spotbugs' version '6.0.15' // code check, working on byte code
id 'com.github.spotbugs' version '6.0.16' // code check, working on byte code
id 'de.undercouch.download' version '5.6.0'
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
id 'jacoco' // java code coverage plugin
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation "org.spockframework:spock-core:2.3-groovy-$groovyVersion"
testImplementation 'org.objenesis:objenesis:3.4' // Mock creation with constructor parameters
testImplementation 'net.bytebuddy:byte-buddy:1.14.16' // Mocks of classes
testImplementation 'net.bytebuddy:byte-buddy:1.14.17' // Mocks of classes

// testcontainers (docker framework for testing)
testImplementation "org.testcontainers:testcontainers:$testcontainersVersion"
Expand Down
26 changes: 6 additions & 20 deletions docs/readthedocs/models/input/participant/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,6 @@ Model of an ideal electrical battery energy storage.
- %
- Efficiency of the electrical inverter
* - dod
- %
- | Maximum permissible depth of discharge. 80 % dod
| is equivalent to a state of charge of 20 %.
* - lifeTime
- h
- Permissible hours of full use
* - lifeCycle
- --
- Permissible amount of full cycles
* - em
- --
- | UUID reference to an :ref:`Energy Management Unit<em_model>` that is controlling
| this system participant. Field can be empty or missing, if this participant
| is not controlled.
```

### Entity Model
Expand Down Expand Up @@ -125,7 +106,12 @@ Model of an ideal electrical battery energy storage.
- --
- | Foreseen operation strategy of the storage.
| Eligible input: *"market"*, *"grid"*, *"self"*
* - em
- --
- | UUID reference to an :ref:`Energy Management Unit<em_model>` that is controlling
| this system participant. Field can be empty or missing, if this participant
| is not controlled.
```

Expand Down
3 changes: 0 additions & 3 deletions docs/uml/main/input/SystemDatamodelConcept.puml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ package models {
- pMax: ComparableQuantity<Power> [kW]
- activePowerGradient: ComparableQuantity<DimensionlessRate> [%/h]
- eta: ComparableQuantity<Dimensionless> [%]
- dod: ComparableQuantity<Dimensionless> [%]
- lifeTime: ComparableQuantity<Time> [h]
- lifeCycle: int
}
StorageTypeInput --|> SystemParticipantTypeInput

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ public class SystemParticipantTypeInputFactory
// StorageTypeInput
private static final String P_MAX = "pMax";
private static final String ETA = "eta";
private static final String DOD = "dod";
private static final String LIFETIME = "lifeTime";
private static final String LIFECYCLE = "lifeCycle";

// WecTypeInput
private static final String CP_CHARACTERISTIC = "cpCharacteristic";
Expand Down Expand Up @@ -89,15 +86,7 @@ protected List<Set<String>> getFields(Class<?> entityClass) {
expandSet(standardConstructorParams, ETA_EL, ETA_THERMAL, P_THERMAL, P_OWN);
} else if (entityClass.equals(StorageTypeInput.class)) {
constructorParameters =
expandSet(
standardConstructorParams,
E_STORAGE,
P_MAX,
ACTIVE_POWER_GRADIENT,
ETA,
DOD,
LIFETIME,
LIFECYCLE);
expandSet(standardConstructorParams, E_STORAGE, P_MAX, ACTIVE_POWER_GRADIENT, ETA);
}

return Collections.singletonList(constructorParameters);
Expand Down Expand Up @@ -241,23 +230,8 @@ private SystemParticipantTypeInput buildStorageTypeInput(
ComparableQuantity<DimensionlessRate> activePowerGradient =
data.getQuantity(ACTIVE_POWER_GRADIENT, StandardUnits.ACTIVE_POWER_GRADIENT);
ComparableQuantity<Dimensionless> eta = data.getQuantity(ETA, StandardUnits.EFFICIENCY);
ComparableQuantity<Dimensionless> dod = data.getQuantity(DOD, StandardUnits.DOD);
ComparableQuantity<Time> lifeTime = data.getQuantity(LIFETIME, StandardUnits.LIFE_TIME);
int lifeCycle = data.getInt(LIFECYCLE);

return new StorageTypeInput(
uuid,
id,
capEx,
opEx,
eStorage,
sRated,
cosPhi,
pMax,
activePowerGradient,
eta,
dod,
lifeTime,
lifeCycle);
uuid, id, capEx, opEx, eStorage, sRated, cosPhi, pMax, activePowerGradient, eta);
}
}
4 changes: 0 additions & 4 deletions src/main/java/edu/ie3/datamodel/models/StandardUnits.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ public class StandardUnits {
KILOWATTHOUR_PER_KELVIN_TIMES_CUBICMETRE;
/** Thermal transmission through an insulation in kW/K */
public static final Unit<ThermalConductance> THERMAL_TRANSMISSION = KILOWATT_PER_KELVIN;
/** Depth of discharge in % */
public static final Unit<Dimensionless> DOD = PERCENT;
/** State of charge in % */
public static final Unit<Dimensionless> SOC = PERCENT;
/** Life time of a system in h */
public static final Unit<Time> LIFE_TIME = HOUR;
/** Area covered by the rotor of a wind energy converter in m² */
public static final Unit<Area> ROTOR_AREA = SQUARE_METRE;
/** Height of the hub of an wind energy converter in metre */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ public class StorageTypeInput extends SystemParticipantTypeInput {
private final ComparableQuantity<DimensionlessRate> activePowerGradient;
/** Efficiency of the charging and discharging process (typically in %) */
private final ComparableQuantity<Dimensionless> eta;
/** Minimum permissible depth of discharge (typically in %) */
private final ComparableQuantity<Dimensionless> dod;
/** Maximum life time of the storage (typically in h) */
private final ComparableQuantity<Time> lifeTime;
/** Maximum amount of full charging cycles */
private final int lifeCycle;

/**
* @param uuid of the input entity
Expand All @@ -45,9 +39,6 @@ public class StorageTypeInput extends SystemParticipantTypeInput {
* @param pMax maximum permissible active power of the integrated inverter
* @param activePowerGradient maximum permissible gradient of active power change
* @param eta efficiency of the charging and discharging process
* @param dod maximum permissible depth of discharge
* @param lifeTime maximum life time of the storage
* @param lifeCycle maximum amount of full charging/discharging cycles
*/
public StorageTypeInput(
UUID uuid,
Expand All @@ -59,36 +50,18 @@ public StorageTypeInput(
double cosPhiRated,
ComparableQuantity<Power> pMax,
ComparableQuantity<DimensionlessRate> activePowerGradient,
ComparableQuantity<Dimensionless> eta,
ComparableQuantity<Dimensionless> dod,
ComparableQuantity<Time> lifeTime,
int lifeCycle) {
ComparableQuantity<Dimensionless> eta) {
super(uuid, id, capex, opex, sRated.to(StandardUnits.S_RATED), cosPhiRated);
this.eStorage = eStorage.to(StandardUnits.ENERGY_IN);
this.pMax = pMax.to(StandardUnits.ACTIVE_POWER_IN);
this.activePowerGradient = activePowerGradient.to(StandardUnits.ACTIVE_POWER_GRADIENT);
this.eta = eta.to(StandardUnits.EFFICIENCY);
this.dod = dod.to(StandardUnits.DOD);
this.lifeTime = lifeTime.to(StandardUnits.LIFE_TIME);
this.lifeCycle = lifeCycle;
}

public ComparableQuantity<Dimensionless> getEta() {
return eta;
}

public ComparableQuantity<Dimensionless> getDod() {
return dod;
}

public ComparableQuantity<Time> getLifeTime() {
return lifeTime;
}

public int getLifeCycle() {
return lifeCycle;
}

public ComparableQuantity<Energy> geteStorage() {
return eStorage;
}
Expand All @@ -111,19 +84,15 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof StorageTypeInput that)) return false;
if (!super.equals(o)) return false;
return lifeCycle == that.lifeCycle
&& eStorage.equals(that.eStorage)
return eStorage.equals(that.eStorage)
&& pMax.equals(that.pMax)
&& activePowerGradient.equals(that.activePowerGradient)
&& eta.equals(that.eta)
&& dod.equals(that.dod)
&& lifeTime.equals(that.lifeTime);
&& eta.equals(that.eta);
}

@Override
public int hashCode() {
return Objects.hash(
super.hashCode(), eStorage, pMax, activePowerGradient, eta, dod, lifeTime, lifeCycle);
return Objects.hash(super.hashCode(), eStorage, pMax, activePowerGradient, eta);
}

@Override
Expand All @@ -149,12 +118,6 @@ public String toString() {
+ activePowerGradient
+ ", eta="
+ eta
+ ", dod="
+ dod
+ ", lifeTime="
+ lifeTime
+ ", lifeCycle="
+ lifeCycle
+ '}';
}

Expand All @@ -180,9 +143,6 @@ private StorageTypeInputCopyBuilder(StorageTypeInput entity) {
this.pMax = entity.getpMax();
this.activePowerGradient = entity.getActivePowerGradient();
this.eta = entity.getEta();
this.dod = entity.getDod();
this.lifeTime = entity.getLifeTime();
this.lifeCycle = entity.getLifeCycle();
}

public StorageTypeInputCopyBuilder seteStorage(ComparableQuantity<Energy> eStorage) {
Expand Down Expand Up @@ -270,10 +230,7 @@ public StorageTypeInput build() {
getCosPhiRated(),
pMax,
activePowerGradient,
eta,
dod,
lifeTime,
lifeCycle);
eta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,10 @@ private static List<Try<Void, InvalidEntityException>> checkStorage(StorageInput
* Validates a StorageTypeInput if:
*
* <ul>
* <li>its permissible amount of full cycles is not negative
* <li>its efficiency of the electrical converter is between 0% and 100%
* <li>its maximum permissible depth of discharge is between 0% and 100%
* <li>its active power gradient is not negative
* <li>its battery capacity is positive
* <li>its maximum permissible active power (in-feed or consumption) is not negative
* <li>its permissible hours of full use is not negative
* </ul>
*
* @param storageTypeInput StorageTypeInput to validate
Expand All @@ -499,14 +496,6 @@ private static List<Try<Void, InvalidEntityException>> checkStorageType(
StorageTypeInput storageTypeInput) {
List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();

exceptions.add(
Try.ofVoid(
storageTypeInput.getLifeCycle() < 0,
() ->
new InvalidEntityException(
"Permissible amount of life cycles of the storage type must be zero or positive",
storageTypeInput)));

exceptions.addAll(
Try.ofVoid(
InvalidEntityException.class,
Expand All @@ -515,17 +504,10 @@ private static List<Try<Void, InvalidEntityException>> checkStorageType(
storageTypeInput,
storageTypeInput.getEta(),
"Efficiency of the electrical converter"),
() ->
isBetweenZeroAndHundredPercent(
storageTypeInput,
storageTypeInput.getDod(),
"Maximum permissible depth of discharge"),
() ->
detectNegativeQuantities(
new Quantity<?>[] {
storageTypeInput.getpMax(),
storageTypeInput.getActivePowerGradient(),
storageTypeInput.getLifeTime()
storageTypeInput.getpMax(), storageTypeInput.getActivePowerGradient(),
},
storageTypeInput),
() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac
"estorage" : "6",
"pmax" : "8",
"activepowergradient" : "1",
"eta" : "9",
"dod" : "10",
"lifetime" : "11",
"lifecycle" : "12"
"eta" : "9"
]
def typeInputClass = StorageTypeInput

Expand All @@ -273,24 +270,21 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac
assert pMax == getQuant(parameter["pmax"], StandardUnits.ACTIVE_POWER_IN)
assert activePowerGradient == getQuant(parameter["activepowergradient"], StandardUnits.ACTIVE_POWER_GRADIENT)
assert eta == getQuant(parameter["eta"], StandardUnits.EFFICIENCY)
assert dod == getQuant(parameter["dod"], StandardUnits.DOD)
assert lifeTime == getQuant(parameter["lifetime"], StandardUnits.LIFE_TIME)
assert lifeCycle == Integer.parseInt(parameter["lifecycle"])
}
}

def "A SystemParticipantTypeInputFactory should throw an exception on invalid or incomplete data"() {
given: "a system participant factory and model data"
def typeInputFactory = new SystemParticipantTypeInputFactory()
def actualFields = SystemParticipantTypeInputFactory.newSet("uuid", "id", "capex", "opex", "srated", "cosPhiRated", "estorage", "pmin", "pmax", "eta", "dod", "lifetime",)
def actualFields = SystemParticipantTypeInputFactory.newSet("uuid", "id", "capex", "opex", "srated", "cosPhiRated", "estorage", "pmin", "pmax", "eta",)

when:
def input = typeInputFactory.validate(actualFields, StorageTypeInput)

then:
input.failure
input.exception.get().message == "The provided fields [capex, cosPhiRated, dod, estorage, eta, id, lifetime, opex, pmax, pmin, srated, uuid] are invalid for instance of 'StorageTypeInput'. \n" +
input.exception.get().message == "The provided fields [capex, cosPhiRated, estorage, eta, id, opex, pmax, pmin, srated, uuid] are invalid for instance of 'StorageTypeInput'. \n" +
"The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'StorageTypeInput' are possible (NOT case-sensitive!):\n" +
"0: [activePowerGradient, capex, cosPhiRated, dod, eStorage, eta, id, lifeCycle, lifeTime, opex, pMax, sRated, uuid] or [active_power_gradient, capex, cos_phi_rated, dod, e_storage, eta, id, life_cycle, life_time, opex, p_max, s_rated, uuid]\n"
"0: [activePowerGradient, capex, cosPhiRated, eStorage, eta, id, opex, pMax, sRated, uuid] or [active_power_gradient, capex, cos_phi_rated, e_storage, eta, id, opex, p_max, s_rated, uuid]\n"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,7 @@ class InputEntityProcessorTest extends Specification {
"cosPhiRated" : "0.997",
"pMax" : "12.961",
"activePowerGradient": "3.0",
"eta" : "92.0",
"dod" : "20.0",
"lifeTime" : "43800.0",
"lifeCycle" : "100000"
"eta" : "92.0"
]

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta {
pMax == sptd.storageTypeInput.pMax
activePowerGradient == sptd.storageTypeInput.activePowerGradient
eta == sptd.storageTypeInput.eta
dod == sptd.storageTypeInput.dod
lifeTime == sptd.storageTypeInput.lifeTime
lifeCycle == sptd.storageTypeInput.lifeCycle
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class StorageTypeInputTest extends Specification {
def alteredUnit = storageTypeInput.copy()
.seteStorage(Quantities.getQuantity(90, ENERGY_IN))
.setpMax(Quantities.getQuantity(15, ACTIVE_POWER_IN))
.setLifeTime(Quantities.getQuantity(999999, LIFE_TIME))
.build()

then:
Expand All @@ -38,9 +37,6 @@ class StorageTypeInputTest extends Specification {
assert pMax == Quantities.getQuantity(15, ACTIVE_POWER_IN)
assert activePowerGradient == storageTypeInput.activePowerGradient
assert eta == storageTypeInput.eta
assert dod == storageTypeInput.dod
assert lifeTime == Quantities.getQuantity(999999, LIFE_TIME)
assert lifeCycle == storageTypeInput.lifeCycle
}
}

Expand All @@ -63,9 +59,6 @@ class StorageTypeInputTest extends Specification {
assert pMax == storageTypeInput.pMax * 2d
assert activePowerGradient == storageTypeInput.activePowerGradient
assert eta == storageTypeInput.eta
assert dod == storageTypeInput.dod
assert lifeTime == storageTypeInput.lifeTime
assert lifeCycle == storageTypeInput.lifeCycle
}
}
}
Loading

0 comments on commit 65dc940

Please sign in to comment.