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/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 9b870aca17..cbb708fb1e 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -13,6 +13,7 @@ import edu.ie3.datamodel.models.result.thermal.{ CylindricalStorageResult, ThermalHouseResult, } +import edu.ie3.simona.exceptions.InvalidParameterException import edu.ie3.simona.exceptions.agent.InconsistentStateException import edu.ie3.simona.model.thermal.ThermalGrid.{ ThermalEnergyDemand, @@ -48,9 +49,9 @@ final case class ThermalGrid( * @param tick * Questioned instance in time * @param lastAmbientTemperature - * Ambient temperature until this tick + * Ambient temperature valid up until (not including) the current tick * @param ambientTemperature - * Ambient temperature in the instance in question + * Current ambient temperature in the instance in question * @param state * Currently applicable state of the thermal grid * @return @@ -152,17 +153,17 @@ 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 + * Determines whether the heat pump is running or not * @param qDot * Thermal energy balance * @param houseDemand - * determines if the thermal house has heat demand + * Determines if the thermal house has heat demand * @param storageDemand - * determines if the thermal storage has heat demand + * Determines if the thermal storage has heat demand * @return * The updated state of the grid */ @@ -201,19 +202,19 @@ 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 - * determines whether the heat pump is running or not + * Determines whether the heat pump is running or not * @param qDot * Infeed to the grid * @param houseDemand - * determines if the thermal house has heat demand + * Determines if the thermal house has heat demand * @param storageDemand - * determines if the thermal storage has heat demand + * Determines if the thermal storage has heat demand * @return * Updated thermal grid state */ @@ -352,9 +353,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 thermal grid * @param qDotHouse @@ -405,9 +406,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 @@ -504,9 +505,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 @@ -580,9 +581,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 0b8544fd67..547a639d08 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -302,9 +302,9 @@ final case class ThermalHouse( * @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 qDot * New thermal influx * @return 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)