diff --git a/CHANGELOG.md b/CHANGELOG.md index b2d3c2b5a0..428423c19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,9 +104,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed FixedFeedModelSpec [#861](https://github.com/ie3-institute/simona/issues/861) - Fixing duration calculation in result events [#801](https://github.com/ie3-institute/simona/issues/801) - Handle MobSim requests for current prices [#892](https://github.com/ie3-institute/simona/issues/892) +- Fix determineState of ThermalHouse [#926](https://github.com/ie3-institute/simona/issues/926) - Fixed Hp results leading to overheating house and other effects [#827](https://github.com/ie3-institute/simona/issues/827) - Fixed thermal storage getting recharged when empty [#827](https://github.com/ie3-institute/simona/issues/827) -- Provide actual ambient temperature of tick to HpModel when calculate state [#882](https://github.com/ie3-institute/simona/issues/882) ## [3.0.0] - 2023-08-07 diff --git a/build.gradle b/build.gradle index 3e72aa1327..b17292a4cb 100644 --- a/build.gradle +++ b/build.gradle @@ -103,7 +103,7 @@ dependencies { /* testing */ testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' testImplementation 'org.scalatestplus:mockito-3-4_2.13:3.2.10.0' - testImplementation 'org.mockito:mockito-core:5.12.0' // mocking framework + testImplementation 'org.mockito:mockito-core:5.13.0' // mocking framework testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.19" testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.8' //scalatest html output testImplementation group: 'org.pegdown', name: 'pegdown', version: '1.6.0' diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index c4323b31ae..c209d0b6c0 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -232,9 +232,9 @@ final case class ThermalGrid( * @param state * Currently applicable state * @param lastAmbientTemperature - * Ambient temperature until this tick + * Ambient temperature valid up until (not including) the current tick * @param ambientTemperature - * actual ambient temperature + * Current ambient temperature * @param isRunning * determines whether the heat pump is running or not * @param qDot @@ -295,9 +295,9 @@ final case class ThermalGrid( * @param tick * Current tick * @param lastAmbientTemperature - * Ambient temperature until this tick + * Ambient temperature valid up until (not including) the current tick * @param ambientTemperature - * actual ambient temperature + * Current ambient temperature * @param state * Current state of the houses * @param isRunning @@ -940,6 +940,7 @@ final case class ThermalGrid( * @param tick * Current tick * @param lastAmbientTemperature + * FIXME * Ambient temperature until this tick * @param ambientTemperature * actual ambient temperature @@ -1151,9 +1152,9 @@ final case class ThermalGrid( * @param tick * Current tick * @param lastAmbientTemperature - * Ambient temperature until this tick + * Ambient temperature valid up until (not including) the current tick * @param ambientTemperature - * actual ambient temperature + * Current ambient temperature * @param state * Current state of the houses * @param qDot @@ -1316,9 +1317,9 @@ final case class ThermalGrid( * @param formerStorageState * Previous thermal storage state before a first update was performed * @param lastAmbientTemperature - * Ambient temperature until this tick + * Ambient temperature valid up until (not including) the current tick * @param ambientTemperature - * actual ambient temperature + * Current ambient temperature * @param qDot * Thermal influx * @return diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala index bbd11c29f0..b15566de94 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -502,15 +502,15 @@ final case class ThermalHouse( /** Update the current state of the house * * @param tick - * current instance in time + * Current instance in time * @param state - * currently applicable state + * Currently applicable state * @param lastAmbientTemperature - * Ambient temperature until this tick + * Ambient temperature valid up until (not including) the current tick * @param ambientTemperature - * actual ambient temperature + * Current ambient temperature * @param qDot - * new thermal influx + * New thermal influx * @return * Updated state and the tick in which the next threshold is reached */ diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala index 3a4b856697..4908b70186 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala @@ -197,6 +197,7 @@ class ThermalGridWithHouseOnlySpec tick, testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, gridState, externalQDot, defaultSimulationStart, @@ -278,6 +279,7 @@ class ThermalGridWithHouseOnlySpec tick, testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, gridState, testGridQDotConsumption, defaultSimulationStart, @@ -374,6 +376,7 @@ class ThermalGridWithHouseOnlySpec tick, testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, gridState, isNotRunning, testGridQDotInfeed, @@ -565,6 +568,7 @@ class ThermalGridWithHouseOnlySpec ThermalGrid.startingState(thermalGrid), testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, isNotRunning, testGridQDotConsumption, ThermalEnergyDemand(KilowattHours(0), KilowattHours(1)), @@ -654,6 +658,7 @@ class ThermalGridWithHouseOnlySpec ThermalGrid.startingState(thermalGrid), testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, isNotRunning, zeroKW, ThermalEnergyDemand(zeroKWH, zeroKWH), diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala index 494f8f2ef7..6380a153ff 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala @@ -287,6 +287,7 @@ class ThermalGridWithStorageOnlySpec ), testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, isRunning, testGridQDotConsumptionHigh, ThermalEnergyDemand(zeroKWH, zeroKWH), @@ -317,6 +318,7 @@ class ThermalGridWithStorageOnlySpec ThermalGrid.startingState(thermalGrid), testGridAmbientTemperature, testGridAmbientTemperature, + testGridAmbientTemperature, isRunning, zeroKW, ThermalEnergyDemand(zeroKWH, zeroKWH), diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala index 56e1cac144..20131046bf 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -6,8 +6,14 @@ package edu.ie3.simona.model.thermal +import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.HouseTemperatureLowerBoundaryReached +import edu.ie3.simona.model.thermal.ThermalHouse.{ + ThermalHouseState, + startingState, +} import edu.ie3.simona.test.common.UnitSpec import edu.ie3.simona.test.common.input.HpInputTestData +import edu.ie3.util.scala.quantities.DefaultQuantities.zeroKW import edu.ie3.util.scala.quantities.WattsPerKelvin import org.scalatest.prop.TableFor3 import squants.energy._ @@ -92,6 +98,31 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { newInnerTemperature should approximate(Temperature(29, Celsius)) } + "Check for the correct state of house when ambient temperature changes" in { + val house = thermalHouse(18, 22) + val initialHousestate = startingState(house) + val lastAmbientTemperature = Temperature(15, Celsius) + val ambientTemperature = Temperature(-20, Celsius) + + val (thermalHouseState, threshold) = house.determineState( + 3600L, + initialHousestate, + lastAmbientTemperature, + ambientTemperature, + zeroKW, + ) + + thermalHouseState match { + case ThermalHouseState(tick, temperature, qDot) => + tick shouldBe 3600L + temperature should approximate(Kelvin(292.64986111)) + qDot shouldBe zeroKW + case unexpected => + fail(s"Expected a thermalHouseState but got none $unexpected.") + } + threshold shouldBe Some(HouseTemperatureLowerBoundaryReached(4967)) + } + "Check build method" in { val thermalTestHouse = thermalHouse(18, 22)