Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
515611e
#236 Added SystemParticipantWithHeatResult class and modified ChpResu…
avgprog Jan 21, 2021
b039c9c
#269 Modified test cases due to the addition of thermal power variabl…
avgprog Jan 24, 2021
819cc41
#269 Fixed codacy static code analysis issues
avgprog Jan 24, 2021
8ba0441
#269 Fixed codacy static code analysis issues
avgprog Jan 27, 2021
8fc8448
#269 Fixed codacy static code analysis issues
avgprog Jan 27, 2021
86daf49
#269 Fixed codacy static code analysis issues
avgprog Jan 27, 2021
25031dd
#269 Fixed codacy static code analysis issues
avgprog Jan 27, 2021
589a394
#270 Modified test cases to check the builder implementations
avgprog Jan 29, 2021
976853f
#269 Added and modified functions as a part of code refinement
avgprog Jan 29, 2021
c05ed90
#269 Added other test cases for testing functionalities of ChpResult …
avgprog Feb 3, 2021
e840c82
#269 Added other test cases for testing functionalities of ChpResult …
avgprog Feb 3, 2021
492ae15
#269 Modified functionalities and test cases for ChpResult and System…
avgprog Feb 3, 2021
77aef5d
#269 Made changes as per the review
avgprog Feb 5, 2021
4abbd2c
#269 Removed unused imports
avgprog Feb 5, 2021
c101d77
#269 Modified documentation due to changes in ChpResult and HpResult …
avgprog Feb 8, 2021
a206b24
Merge branch 'dev' into sb/#236-modifyingChpResult
ckittl Feb 11, 2021
d5ffc93
Merge branch 'dev' into sb/#236-modifyingChpResult
ckittl Feb 11, 2021
c9a2390
#269 Modified uml documentation to add SystemParticipantWithHeatResul…
avgprog Feb 15, 2021
3b16fb8
Adapt Jenkinsfile to meet correct path to Java 11
ckittl Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Main Contributers:
- Sebastian Peter - https://github.com/sebastian-peter
- Christian Mahr - https://github.com/cmahr93
- Vasilios Zachopoulos - https://github.com/baszach
- Shubham Bajpai - https://github.com/ahamshubham

Coordination:
- Chris Kittl
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- reading time series from csv files (including a container object to hold the different types of time series)
- reading mapping from participant uuid to time series uuid including a mapping object for easy access to time series
- Couchbase, SQL and CSV connectors and sources for weather data
- added `SystemParticipantWithHeatResult` with thermal power variable to be used by heat plant result models

### Changed
- BREAKING: replaced [Unit API 1.0](https://github.com/unitsofmeasurement/uom-se) (JSR 363, tec.uom.se) with [Unit API 2.0](https://github.com/unitsofmeasurement/indriya) (JSR 385, tech.units.indriya)
Expand All @@ -23,13 +24,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- added coordinate distance sort method to GridAndGeoUtils
- BREAKING: Harmonized field naming for time information
- BREAKING: Properly applying snake case to result file names
- deprecated `TarballUtils`

### Fixed
- InfluxDbConnector now keeps session instead of creating a new one each call
(resolves [#247](https://github.com/ie3-institute/PowerSystemDataModel/issues/247)
and [#248](https://github.com/ie3-institute/PowerSystemDataModel/issues/248))
- BREAKING: fix invalid application of solar irradiance / irradiation ([#266](https://github.com/ie3-institute/PowerSystemDataModel/issues/266))
- BREAKING: deleted `IrradiationValue` as it is invalid and no longer required
- added copy builder implementations for thermal input models `CylindricalStorageInput`, `ThermalBusInput` and `ThermalHouseInput`

## [1.1.0] - 2020-09-15

Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ node {
'spotbugsTest test jacocoTestReport jacocoTestCoverageVerification', projectName)

// due to an issue with openjdk-8 we use openjdk-11 for javadocs generation
sh(script: """set +x && cd $projectName""" + ''' set +x; ./gradlew clean javadoc -Dorg.gradle.java.home=/usr/local/openjdk-11''', returnStdout: true)
sh(script: """set +x && cd $projectName""" + ''' set +x; ./gradlew clean javadoc -Dorg.gradle.java.home=/opt/java/openjdk''', returnStdout: true)
}

// sonarqube analysis
Expand Down Expand Up @@ -150,7 +150,7 @@ node {
*/
sh(
script: """set +x && cd $projectName""" +
''' set +x; ./gradlew clean javadoc -Dorg.gradle.java.home=/usr/local/openjdk-11''',
''' set +x; ./gradlew clean javadoc -Dorg.gradle.java.home=/opt/java/openjdk''',
returnStdout: true
)

Expand Down Expand Up @@ -364,7 +364,7 @@ def deployJavaDocs(String projectName, String sshCredentialsId, String gitChecko
"git config user.name 'Johannes Hiry' && " +
"git fetch --depth=1 origin api-docs && " +
"git checkout api-docs && " +
"cd .. && ./gradlew clean javadoc -Dorg.gradle.java.home=/usr/local/openjdk-11 && " +
"cd .. && ./gradlew clean javadoc -Dorg.gradle.java.home=/opt/java/openjdk && " +
"cp -R build/docs/javadoc/* tmp-api-docs && " +
"cd tmp-api-docs &&" +
"git add --all && git commit -m 'updated api-docs' && git push origin api-docs:api-docs" +
Expand Down
3 changes: 2 additions & 1 deletion docs/readthedocs/models/result/participant/chp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Attributes, Units and Remarks
+---------------+---------+--------------------------------------------------------------+
| q | MVAr | |
+---------------+---------+--------------------------------------------------------------+

| qDot | MW | Thermal power |
+---------------+---------+--------------------------------------------------------------+

Caveats
^^^^^^^
Expand Down
9 changes: 7 additions & 2 deletions docs/uml/main/OutputDatamodelConcept.puml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,16 @@ package models {
class PvResult
SystemParticipantResult <|-- PvResult

abstract class SystemParticipantWithHeatResult{
- qDot: ComparableQuantity<Power>
}
SystemParticipantResult <|-- SystemParticipantWithHeatResult

class ChpResult
SystemParticipantResult <|-- ChpResult
SystemParticipantWithHeatResult <|-- ChpResult

class HpResult
SystemParticipantResult <|-- HpResult
SystemParticipantWithHeatResult <|-- HpResult

class WecResult
SystemParticipantResult <|-- WecResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ protected List<Set<String>> getFields(SimpleEntityData data) {
optionalFields = expandSet(minConstructorParams, ENTITY_UUID);
}

if (data.getTargetClass().equals(HpResult.class)) {
minConstructorParams = newSet(TIME, INPUT_MODEL, POWER, REACTIVE_POWER, Q_DOT);
if (SystemParticipantWithHeatResult.class.isAssignableFrom(data.getTargetClass())) {
minConstructorParams = expandSet(minConstructorParams, Q_DOT);
optionalFields = expandSet(minConstructorParams, ENTITY_UUID);
}

Expand Down Expand Up @@ -95,19 +95,25 @@ protected SystemParticipantResult buildModel(SimpleEntityData data) {
return uuidOpt
.map(uuid -> new EvcsResult(uuid, zdtTime, inputModelUuid, p, q))
.orElseGet(() -> new EvcsResult(zdtTime, inputModelUuid, p, q));
} else if (entityClass.equals(ChpResult.class)) {
return uuidOpt
.map(uuid -> new ChpResult(uuid, zdtTime, inputModelUuid, p, q))
.orElseGet(() -> new ChpResult(zdtTime, inputModelUuid, p, q));
} else if (SystemParticipantWithHeatResult.class.isAssignableFrom(entityClass)) {
/* The following classes all have a heat component as well */
ComparableQuantity<Power> qDot = data.getQuantity(Q_DOT, StandardUnits.Q_DOT_RESULT);

if (entityClass.equals(ChpResult.class)) {
return uuidOpt
.map(uuid -> new ChpResult(uuid, zdtTime, inputModelUuid, p, q, qDot))
.orElseGet(() -> new ChpResult(zdtTime, inputModelUuid, p, q, qDot));
} else if (entityClass.equals(HpResult.class)) {
return uuidOpt
.map(uuid -> new HpResult(uuid, zdtTime, inputModelUuid, p, q, qDot))
.orElseGet(() -> new HpResult(zdtTime, inputModelUuid, p, q, qDot));
} else {
throw new FactoryException("Cannot process " + entityClass.getSimpleName() + ".class.");
}
} else if (entityClass.equals(WecResult.class)) {
return uuidOpt
.map(uuid -> new WecResult(uuid, zdtTime, inputModelUuid, p, q))
.orElseGet(() -> new WecResult(zdtTime, inputModelUuid, p, q));
} else if (entityClass.equals(HpResult.class)) {
ComparableQuantity<Power> qDotQuantity = data.getQuantity(Q_DOT, StandardUnits.Q_DOT_RESULT);
return uuidOpt
.map(uuid -> new HpResult(uuid, zdtTime, inputModelUuid, p, q, qDotQuantity))
.orElseGet(() -> new HpResult(zdtTime, inputModelUuid, p, q, qDotQuantity));
} else if (entityClass.equals(EvResult.class)) {
ComparableQuantity<Dimensionless> socQuantity = data.getQuantity(SOC, PERCENT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ protected SortedMap<String, Method> mapFieldNameToGetter(
fieldName = V_RATED;
resFieldNameToMethod.put(VOLT_LVL, pd.getReadMethod());
}

resFieldNameToMethod.put(fieldName, pd.getReadMethod());
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import tech.units.indriya.ComparableQuantity;

/** Represents calculation results of a {@link edu.ie3.datamodel.models.input.system.ChpInput} */
public class ChpResult extends SystemParticipantResult {
public class ChpResult extends SystemParticipantWithHeatResult {

/**
* Standard constructor with automatic uuid generation.
Expand All @@ -20,13 +20,15 @@ public class ChpResult extends SystemParticipantResult {
* @param inputModel uuid of the input model that produces the result
* @param p active power output normally provided in MW
* @param q reactive power output normally provided in MVAr
* @param qDot thermal power output normally provided in MW
*/
public ChpResult(
ZonedDateTime time,
UUID inputModel,
ComparableQuantity<Power> p,
ComparableQuantity<Power> q) {
super(time, inputModel, p, q);
ComparableQuantity<Power> q,
ComparableQuantity<Power> qDot) {
super(time, inputModel, p, q, qDot);
}

/**
Expand All @@ -38,14 +40,16 @@ public ChpResult(
* @param inputModel uuid of the input model that produces the result
* @param p active power output normally provided in MW
* @param q reactive power output normally provided in MVAr
* @param qDot thermal power output normally provided in MW
*/
public ChpResult(
UUID uuid,
ZonedDateTime time,
UUID inputModel,
ComparableQuantity<Power> p,
ComparableQuantity<Power> q) {
super(uuid, time, inputModel, p, q);
ComparableQuantity<Power> q,
ComparableQuantity<Power> qDot) {
super(uuid, time, inputModel, p, q, qDot);
}

@Override
Expand All @@ -61,6 +65,8 @@ public String toString() {
+ getP()
+ ", q="
+ getQ()
+ ", qDot="
+ getqDot()
+ '}';
}
}
36 changes: 6 additions & 30 deletions src/main/java/edu/ie3/datamodel/models/result/system/HpResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
package edu.ie3.datamodel.models.result.system;

import java.time.ZonedDateTime;
import java.util.Objects;
import java.util.UUID;
import javax.measure.Quantity;
import javax.measure.quantity.Power;
import tech.units.indriya.ComparableQuantity;

/** Represents calculation results of a {@link edu.ie3.datamodel.models.input.system.HpInput} */
public class HpResult extends SystemParticipantResult {

private final Quantity<Power> qDot;
public class HpResult extends SystemParticipantWithHeatResult {

/**
* Standard constructor with automatic uuid generation.
Expand All @@ -31,9 +27,8 @@ public HpResult(
UUID inputModel,
ComparableQuantity<Power> p,
ComparableQuantity<Power> q,
Quantity<Power> qDot) {
super(time, inputModel, p, q);
this.qDot = qDot;
ComparableQuantity<Power> qDot) {
super(time, inputModel, p, q, qDot);
}

/**
Expand All @@ -53,27 +48,8 @@ public HpResult(
UUID inputModel,
ComparableQuantity<Power> p,
ComparableQuantity<Power> q,
Quantity<Power> qDot) {
super(uuid, time, inputModel, p, q);
this.qDot = qDot;
}

public Quantity<Power> getqDot() {
return qDot;
}

@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;
HpResult hpResult = (HpResult) o;
return qDot.equals(hpResult.qDot);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), qDot);
ComparableQuantity<Power> qDot) {
super(uuid, time, inputModel, p, q, qDot);
}

@Override
Expand All @@ -90,7 +66,7 @@ public String toString() {
+ ", q="
+ getQ()
+ ", qDot="
+ qDot
+ getqDot()
+ '}';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* © 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.result.system;

import java.time.ZonedDateTime;
import java.util.Objects;
import java.util.UUID;
import javax.measure.quantity.Power;
import tech.units.indriya.ComparableQuantity;

/** Abstract class that holds values common to result entities having heat result */
public abstract class SystemParticipantWithHeatResult extends SystemParticipantResult {
/** The thermal power output normally provided in MW */
private final ComparableQuantity<Power> qDot;

/**
* @param time date and time when the result is produced
* @param inputModel uuid of the input model that produces the result
* @param p active power output normally provided in MW
* @param q reactive power output normally provided in MVAr
* @param qDot thermal power output normally provided in MW
*/
public SystemParticipantWithHeatResult(
ZonedDateTime time,
UUID inputModel,
ComparableQuantity<Power> p,
ComparableQuantity<Power> q,
ComparableQuantity<Power> qDot) {
super(time, inputModel, p, q);
this.qDot = qDot;
}

/**
* @param uuid uuid of this result entity, for automatic uuid generation use primary constructor
* above
* @param time date and time when the result is produced
* @param inputModel uuid of the input model that produces the result
* @param p active power output normally provided in MW
* @param q reactive power output normally provided in MVAr
* @param qDot thermal power output normally provided in MW
*/
public SystemParticipantWithHeatResult(
UUID uuid,
ZonedDateTime time,
UUID inputModel,
ComparableQuantity<Power> p,
ComparableQuantity<Power> q,
ComparableQuantity<Power> qDot) {
super(uuid, time, inputModel, p, q);
this.qDot = qDot;
}

/**
* Thermal power output of the decentralised energy resource asset. Convention: Generated powers
* are given in negative values.
*
* @return Thermal power output in MW.
*/
public ComparableQuantity<Power> getqDot() {
return qDot;
}

@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;
SystemParticipantWithHeatResult that = (SystemParticipantWithHeatResult) o;
return qDot.equals(that.qDot);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), qDot);
}

@Override
public String toString() {
return "SystemParticipantWithHeatResult{"
+ "uuid="
+ getUuid()
+ ", time="
+ getTime()
+ ", inputModel="
+ getInputModel()
+ ", p="
+ getP()
+ ", q="
+ getQ()
+ ", qDot="
+ getqDot()
+ '}';
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As also SonarQube suggests: Override equals and hasCode methods. The auto-generated ones from IntelliJ should mostly be fine.

Also please make sure, that you really check, what the static code analysis tools (SonarQube etc.) give you as hints.

Copy link
Contributor Author

@avgprog avgprog Feb 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will add equals and hashCode methods. Actually, I added them in one of the commits but there was a problem. The functions were not being tested and the code coverage was reduced. The hashCode function seemed to generate a new hash code for the same qDot as input so it was difficult to add a test case to test it. So, I added the test case for testing the equals method and made another commit but then there was an issue. It seemed like Codacy wanted the equals function replaced by == operator or some change to the groovy settings. That is why I removed the two functions in a later commit.

Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SystemParticipantResultFactoryTest extends Specification implements Factor
parameter["soc"] = "10"
}

if(modelClass == HpResult){
if (modelClass == HpResult || modelClass == ChpResult) {
parameter["qDot"] = "1"
}

Expand All @@ -69,11 +69,17 @@ class SystemParticipantResultFactoryTest extends Specification implements Factor
if (modelClass == EvResult) {
assert (((EvResult) result.get()).soc == getQuant(parameter["soc"], Units.PERCENT))
}
if(modelClass ==StorageResult){

if (modelClass == StorageResult) {
assert (((StorageResult) result.get()).soc == getQuant(parameter["soc"], Units.PERCENT))
}
if(modelClass == HpResult){
assert(((HpResult)result.get()).qDot == getQuant(parameter["qDot"], StandardUnits.Q_DOT_RESULT))

if (modelClass == HpResult) {
assert(((HpResult)result.get()).getqDot() == getQuant(parameter["qDot"], StandardUnits.Q_DOT_RESULT))
}

if (modelClass == ChpResult) {
assert(((ChpResult)result.get()).getqDot() == getQuant(parameter["qDot"], StandardUnits.Q_DOT_RESULT))
}

where:
Expand Down
Loading