From 39fa9ea442edf23166bb596eb4205282c21b4042 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 23 Mar 2023 15:28:14 +0100 Subject: [PATCH 1/5] Replaced ChpData --- .../simona/model/participant/ChpModel.scala | 38 +++++++++---------- .../model/participant/ChpModelTest.groovy | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 36d976119b..78bc5038b4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -52,7 +52,7 @@ final case class ChpModel( cosPhiRated: Double, pThermal: ComparableQuantity[Power], storage: ThermalStorage with MutableStorage -) extends SystemParticipant[ChpData]( +) extends SystemParticipant[ChpRelevantData]( uuid, id, operationInterval, @@ -77,11 +77,11 @@ final case class ChpModel( * active power */ override protected def calculateActivePower( - chpData: ChpData + chpData: ChpRelevantData ): ComparableQuantity[Power] = chpData.chpState.activePower - /** Given a [[ChpData]] object, containing the [[ChpState]], the heat demand + /** Given a [[ChpRelevantData]] object, containing the [[ChpState]], the heat demand * and the current time tick, this function calculates the CHPs next state * while trying to cover the demand. To get the actual active power of this * state please use [[calculateActivePower]] with the generated state @@ -92,7 +92,7 @@ final case class ChpModel( * next [[ChpState]] */ def calculateNextState( - chpData: ChpData + chpData: ChpRelevantData ): ChpState = generateStateCalculation(chpData)(chpData) /** Depending on the input, this function returns a fitting 'calculateState' @@ -110,11 +110,11 @@ final case class ChpModel( * @param chpData * state of the chp and heat demand * @return - * partially applied function taking a [[ChpData]] object + * partially applied function taking a [[ChpRelevantData]] object */ private def generateStateCalculation( - chpData: ChpData - ): ChpData => ChpState = { + chpData: ChpRelevantData + ): ChpRelevantData => ChpState = { val isRunning = chpData.chpState.isRunning val hasDemand = chpData.heatDemand.isGreaterThan(DefaultQuantities.zeroKWH) val isCovered = isDemandCovered(chpData) @@ -137,7 +137,7 @@ final case class ChpModel( * next [[ChpState]] */ private def calculateStateNotRunningNoDemand( - chpData: ChpData + chpData: ChpRelevantData ): ChpState = ChpState( isRunning = false, @@ -155,7 +155,7 @@ final case class ChpModel( * next [[ChpState]] */ private def calculateStateDemandNotCovered( - chpData: ChpData + chpData: ChpRelevantData ): ChpState = { val energy = chpEnergy(chpData) // ChpModel ignores possible lack of energy from prior time steps. @@ -172,7 +172,7 @@ final case class ChpModel( * next [[ChpState]] */ private def calculateStateNotRunningDemandCovered( - chpData: ChpData + chpData: ChpRelevantData ): ChpState = { // Returned lack is always zero, because demand is covered. storage.tryToTakeAndReturnLack(chpData.heatDemand) @@ -194,7 +194,7 @@ final case class ChpModel( * next [[ChpState]] */ private def calculateStateRunningDemandCovered( - chpData: ChpData + chpData: ChpRelevantData ): ChpState = { val differenceEnergy = chpEnergy(chpData).subtract(chpData.heatDemand) if (differenceEnergy.isLessThan(DefaultQuantities.zeroKWH)) { @@ -219,7 +219,7 @@ final case class ChpModel( * total energy minus surplus energy */ private def calculateStateRunningSurplus( - chpData: ChpData, + chpData: ChpRelevantData, surplus: Option[ComparableQuantity[Energy]] = None ): ChpState = { surplus match { @@ -248,7 +248,7 @@ final case class ChpModel( * energy */ private def powerToEnergy( - chpData: ChpData, + chpData: ChpRelevantData, power: ComparableQuantity[Power] ): ComparableQuantity[Energy] = power.multiply(timeRunning(chpData)).asType(classOf[Energy]) @@ -262,12 +262,12 @@ final case class ChpModel( * @return * is demand covered */ - private def isDemandCovered(chpData: ChpData) = + private def isDemandCovered(chpData: ChpRelevantData) = storage.isDemandCoveredByStorage(chpData.heatDemand) || totalUsableEnergy( chpData ).isGreaterThanOrEqualTo(chpData.heatDemand) - private def chpEnergy(chpData: ChpData): ComparableQuantity[Energy] = + private def chpEnergy(chpData: ChpRelevantData): ComparableQuantity[Energy] = powerToEnergy(chpData, pThermal) /** Returns the storage mediums total usable plus the CHP thermal output @@ -280,11 +280,11 @@ final case class ChpModel( * total usable energy */ private def totalUsableEnergy( - chpData: ChpData + chpData: ChpRelevantData ): ComparableQuantity[Energy] = storage.usableThermalEnergy.add(chpEnergy(chpData)) - private def timeRunning(chpData: ChpData): ComparableQuantity[Time] = + private def timeRunning(chpData: ChpRelevantData): ComparableQuantity[Time] = getQuantity( chpData.currentTimeTick - chpData.chpState.lastTimeTick, Units.SECOND @@ -316,7 +316,7 @@ case object ChpModel { ) /** Main data required for simulation/calculation, containing a [[ChpState]], - * the heat demand and the current time tick.

[[ChpData.currentTimeTick]] + * the heat demand and the current time tick.

[[ChpRelevantData.currentTimeTick]] * and [[ChpState.lastTimeTick]] form a time interval for the current state * calculation. One time tick represents one second (3600 time ticks = 1 * hour). @@ -328,7 +328,7 @@ case object ChpModel { * @param currentTimeTick * contains current time tick */ - final case class ChpData( + final case class ChpRelevantData( chpState: ChpState, heatDemand: ComparableQuantity[Energy], currentTimeTick: Long diff --git a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy index 325bd9538b..043bd142a7 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy @@ -90,7 +90,7 @@ class ChpModelTest extends Specification { } static def buildChpData(ChpState chpState, Double heatDemand) { - return new ChpModel.ChpData(chpState, getQuantity(heatDemand, KILOWATTHOUR), 7200) + return new ChpModel.ChpRelevantData(chpState, getQuantity(heatDemand, KILOWATTHOUR), 7200) } static def buildThermalStorage(CylindricalStorageInput storageInput, Double storageLvl) { From e782189a280c447c074bfb13edef5b2a431b8746 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 23 Mar 2023 15:40:02 +0100 Subject: [PATCH 2/5] Edit CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96b386591d..03769f53d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updating `CONTRIBUTING.md` [#201](https://github.com/ie3-institute/simona/issues/201) - Speeding up additionalActivationTicks in participant's BaseStateData [#421](https://github.com/ie3-institute/simona/pull/421) - Changed format of example grid `vn_simona` [#216](https://github.com/ie3-institute/simona/issues/216) +- Renamed ChpData to ChpRelevantData [#494](https://github.com/ie3-institute/simona/issues/494) ### Fixed - Location of `vn_simona` test grid (was partially in Berlin and Dortmund) [#72](https://github.com/ie3-institute/simona/issues/72) From 506d96701b4b58ad7543e98e778914933d9fe4d3 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Fri, 24 Mar 2023 09:52:56 +0100 Subject: [PATCH 3/5] Spotless Apply --- .../ie3/simona/model/participant/ChpModel.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 78bc5038b4..f8c196cb9c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -81,10 +81,10 @@ final case class ChpModel( ): ComparableQuantity[Power] = chpData.chpState.activePower - /** Given a [[ChpRelevantData]] object, containing the [[ChpState]], the heat demand - * and the current time tick, this function calculates the CHPs next state - * while trying to cover the demand. To get the actual active power of this - * state please use [[calculateActivePower]] with the generated state + /** Given a [[ChpRelevantData]] object, containing the [[ChpState]], the heat + * demand and the current time tick, this function calculates the CHPs next + * state while trying to cover the demand. To get the actual active power of + * this state please use [[calculateActivePower]] with the generated state * * @param chpData * state of the chp and heat demand @@ -316,10 +316,10 @@ case object ChpModel { ) /** Main data required for simulation/calculation, containing a [[ChpState]], - * the heat demand and the current time tick.

[[ChpRelevantData.currentTimeTick]] - * and [[ChpState.lastTimeTick]] form a time interval for the current state - * calculation. One time tick represents one second (3600 time ticks = 1 - * hour). + * the heat demand and the current time tick.

+ * [[ChpRelevantData.currentTimeTick]] and [[ChpState.lastTimeTick]] form a + * time interval for the current state calculation. One time tick represents + * one second (3600 time ticks = 1 hour). * * @param chpState * a [[ChpState]] From d6a71fc8e092dfbc3ceec59b2433aa5920cebd13 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 4 Apr 2023 16:00:16 +0200 Subject: [PATCH 4/5] Changed name in ChpModelTest --- .../groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy index 043bd142a7..3866faef93 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy @@ -89,7 +89,7 @@ class ChpModelTest extends Specification { thermalStorage) } - static def buildChpData(ChpState chpState, Double heatDemand) { + static def buildChpRelevantData(ChpState chpState, Double heatDemand) { return new ChpModel.ChpRelevantData(chpState, getQuantity(heatDemand, KILOWATTHOUR), 7200) } From c0abff1b577acd0053fe3964fb985150167ee24f Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Tue, 4 Apr 2023 16:23:54 +0200 Subject: [PATCH 5/5] Changed name in ChpModelTest once again --- .../edu/ie3/simona/model/participant/ChpModelTest.groovy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy index 3866faef93..03932fea4a 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy @@ -102,7 +102,7 @@ class ChpModelTest extends Specification { @Unroll def "Check active power after calculating next state with #chpState and heat demand #heatDemand kWh:"() { given: - def chpData = buildChpData(chpState, heatDemand) + def chpData = buildChpRelevantData(chpState, heatDemand) def thermalStorage = buildThermalStorage(storageInput, storageLvl) def chpModel = buildChpModel(thermalStorage) @@ -129,7 +129,7 @@ class ChpModelTest extends Specification { @Unroll def "Check total energy after calculating next state with #chpState and heat demand #heatDemand kWh:"() { given: - def chpData = buildChpData(chpState, heatDemand) + def chpData = buildChpRelevantData(chpState, heatDemand) def thermalStorage = buildThermalStorage(storageInput, storageLvl) def chpModel = buildChpModel(thermalStorage) @@ -157,7 +157,7 @@ class ChpModelTest extends Specification { def "Check storage level after calculating next state with #chpState and heat demand #heatDemand kWh:"() { given: - def chpData = buildChpData(chpState, heatDemand) + def chpData = buildChpRelevantData(chpState, heatDemand) def thermalStorage = buildThermalStorage(storageInput, storageLvl) def chpModel = buildChpModel(thermalStorage) @@ -185,7 +185,7 @@ class ChpModelTest extends Specification { def "Check time tick and running status after calculating next state with #chpState and heat demand #heatDemand kWh:"() { given: - def chpData = buildChpData(chpState, heatDemand) + def chpData = buildChpRelevantData(chpState, heatDemand) def thermalStorage = buildThermalStorage(storageInput, storageLvl) def chpModel = buildChpModel(thermalStorage)