From 0c36ce5b151d949704b2554fdd58ec8908ab8668 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 20 Aug 2024 18:51:33 +0200 Subject: [PATCH] update ThermalGridIT to last changes --- .../ie3/simona/agent/grid/ThermalGridIT.scala | 279 +++++++++++------- 1 file changed, 168 insertions(+), 111 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/ThermalGridIT.scala b/src/test/scala/edu/ie3/simona/agent/grid/ThermalGridIT.scala index 9fe31484e7..70be23c118 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/ThermalGridIT.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/ThermalGridIT.scala @@ -154,7 +154,7 @@ class ThermalGridIT House demand water : tba ThermalStorage : requiredDemand = 10.44 kWh, additionalDemand = 10.44 kWh DomesticWaterStorage : tba - Heat pump: turned on - to serve the storage demand, but will heat up the house first + Heat pump: turned on - to serve the storage demand */ heatPumpAgent ! Activation(0L) @@ -218,22 +218,22 @@ class ThermalGridIT scheduler.expectMessage(Completion(heatPumpAgent, Some(0L))) - /* TICK 6353 - House is fully heated up - House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh + /* TICK 3417 + Storage is fully heated up + House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 17.37 kWh House demand water : tba - ThermalStorage : requiredDemand = 10.44 kWh, additionalDemand = 10.44 kWh + ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh DomesticWaterStorage : tba - Heat pump: stays on to serve storage demand + Heat pump: stays on since it was on and the house as additional demand */ - heatPumpAgent ! Activation(6353L) + heatPumpAgent ! Activation(3417) - // Results of tick 6353 for hp + // Results of tick 3417 for hp resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 6353.toDateTime + hpResult.getTime shouldBe 3417.toDateTime hpResult.getP should equalWithTolerance(pRunningHp) hpResult.getQ should equalWithTolerance( qRunningHp @@ -255,7 +255,7 @@ class ThermalGridIT ) => inputModel shouldBe typicalThermalHouse.getUuid time shouldBe 0.toDateTime - qDot should equalWithTolerance(0.011.asMegaWatt) + qDot should equalWithTolerance(0.asMegaWatt) indoorTemperature should equalWithTolerance( 19.9999074074074.asDegreeCelsius ) @@ -267,7 +267,7 @@ class ThermalGridIT ) => inputModel shouldBe typicalThermalStorage.getUuid time shouldBe 0.toDateTime - qDot should equalWithTolerance(0.asMegaWatt) + qDot should equalWithTolerance(0.011.asMegaWatt) energy should equalWithTolerance(0.asMegaWattHour) case _ => fail( @@ -276,14 +276,14 @@ class ThermalGridIT } } - // FIXME? Why next tick 6353? - scheduler.expectMessage(Completion(heatPumpAgent, Some(6353L))) + // FIXME? Why next tick 3417? + scheduler.expectMessage(Completion(heatPumpAgent, Some(3417))) /* TICK 7200 New weather data (unchanged) incoming - House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh + House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 8.41 kWh House demand water : tba - ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 7.85 kWh + ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh DomesticWaterStorage : tba Heat pump: stays on */ @@ -315,7 +315,7 @@ class ThermalGridIT ) } - // Results of 6353 for house and storage + // Results of 3417 for house and storage Range(0, 2) .map { _ => resultListener.expectMessageType[ResultEvent] @@ -329,10 +329,10 @@ class ThermalGridIT indoorTemperature, ) => inputModel shouldBe typicalThermalHouse.getUuid - time shouldBe 6353.toDateTime - qDot should equalWithTolerance(0.asMegaWatt) + time shouldBe 3417.toDateTime + qDot should equalWithTolerance(0.011.asMegaWatt) indoorTemperature should equalWithTolerance( - 21.99992810459535.asDegreeCelsius + 19.6835196903292.asDegreeCelsius ) case CylindricalThermalStorageResult( @@ -342,9 +342,9 @@ class ThermalGridIT energy, ) => inputModel shouldBe typicalThermalStorage.getUuid - time shouldBe 6353.toDateTime - qDot should equalWithTolerance(0.011.asMegaWatt) - energy should equalWithTolerance(0.asMegaWattHour) + time shouldBe 3417.toDateTime + qDot should equalWithTolerance(0.asMegaWatt) + energy should equalWithTolerance(0.01044.asMegaWattHour) case _ => fail( "Expected a ThermalHouseResult and a ThermalStorageResult but got something else" @@ -355,8 +355,8 @@ class ThermalGridIT // FIXME? Why next tick 7200? scheduler.expectMessage(Completion(heatPumpAgent, Some(7200L))) - /* TICK 7200 - Storage will be full + /* TICK 10798 + House reaches upper temperature boundary House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh House demand water : tba ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh @@ -364,13 +364,13 @@ class ThermalGridIT Heat pump: turned off */ - heatPumpAgent ! Activation(9770L) + heatPumpAgent ! Activation(10798) - // Results of 9770 for hp + // Results of 10798 for hp resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 9770.toDateTime + hpResult.getTime shouldBe 10798.toDateTime hpResult.getP should equalWithTolerance(0.asMegaWatt) hpResult.getQ should equalWithTolerance(0.asMegaVar) } @@ -390,9 +390,9 @@ class ThermalGridIT ) => inputModel shouldBe typicalThermalHouse.getUuid time shouldBe 7200.toDateTime - qDot should equalWithTolerance(0.asMegaWatt) + qDot should equalWithTolerance(0.011.asMegaWatt) indoorTemperature should equalWithTolerance( - 21.9152283301339.asDegreeCelsius + 20.8788983755569.asDegreeCelsius ) case CylindricalThermalStorageResult( time, @@ -402,8 +402,8 @@ class ThermalGridIT ) => inputModel shouldBe typicalThermalStorage.getUuid time shouldBe 7200.toDateTime - qDot should equalWithTolerance(0.011.asMegaWatt) - energy should equalWithTolerance(0.002588055555555.asMegaWattHour) + qDot should equalWithTolerance(0.asMegaWatt) + energy should equalWithTolerance(0.01044.asMegaWattHour) case _ => fail( "Expected a ThermalHouseResult and a ThermalStorageResult but got something else" @@ -411,13 +411,13 @@ class ThermalGridIT } } - // FIXME? Why next tick 9770? - scheduler.expectMessage(Completion(heatPumpAgent, Some(9770L))) + // FIXME? Why next tick 10798? + scheduler.expectMessage(Completion(heatPumpAgent, Some(10798))) /* TICK 28800 - House would reach lowerTempBoundary at tick 47518 + House would reach lowerTempBoundary at tick 50797 but now it's getting colder which should decrease inner temp of house faster - House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 27.22 kWh + House demand heating : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh House demand water : tba ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh DomesticWaterStorage : tba @@ -436,7 +436,7 @@ class ThermalGridIT Celsius(-25d), MetersPerSecond(0d), ), - Some(34200L), + Some(45000L), ) } @@ -448,7 +448,7 @@ class ThermalGridIT hpResult.getQ should equalWithTolerance(0.0.asMegaVar) } - // Results of 9770 for house and storage + // Results of 10798 for house and storage Range(0, 2) .map { _ => resultListener.expectMessageType[ResultEvent] @@ -462,10 +462,10 @@ class ThermalGridIT indoorTemperature, ) => inputModel shouldBe typicalThermalHouse.getUuid - time shouldBe 9770.toDateTime + time shouldBe 10798.toDateTime qDot should equalWithTolerance(0.asMegaWatt) indoorTemperature should equalWithTolerance( - 21.65903523084334.asDegreeCelsius + 21.9998899446115.asDegreeCelsius ) case CylindricalThermalStorageResult( time, @@ -474,7 +474,7 @@ class ThermalGridIT energy, ) => inputModel shouldBe typicalThermalStorage.getUuid - time shouldBe 9770.toDateTime + time shouldBe 10798.toDateTime qDot should equalWithTolerance(0.asMegaWatt) energy should equalWithTolerance(0.01044.asMegaWattHour) case _ => @@ -486,7 +486,7 @@ class ThermalGridIT scheduler.expectMessage(Completion(heatPumpAgent, Some(28800L))) - /* TICK 31106 + /* TICK 41940 House reach lowerTemperatureBoundary House demand heating : requiredDemand = 15.0 kWh, additionalDemand = 30.00 kWh House demand water : tba @@ -495,12 +495,12 @@ class ThermalGridIT Heat pump: stays off, demand should be covered by storage */ - heatPumpAgent ! Activation(31106L) + heatPumpAgent ! Activation(41940) resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 31106.toDateTime + hpResult.getTime shouldBe 41940.toDateTime hpResult.getP should equalWithTolerance(0.0.asMegaWatt) hpResult.getQ should equalWithTolerance( 0.0.asMegaVar @@ -523,7 +523,7 @@ class ThermalGridIT time shouldBe 28800.toDateTime qDot should equalWithTolerance(0.0.asMegaWatt) indoorTemperature should equalWithTolerance( - 18.3704373032769.asDegreeCelsius + 20.19969728245267.asDegreeCelsius ) case CylindricalThermalStorageResult( @@ -543,23 +543,23 @@ class ThermalGridIT } } - scheduler.expectMessage(Completion(heatPumpAgent, Some(31106L))) + scheduler.expectMessage(Completion(heatPumpAgent, Some(41940))) - /* TICK 34200 - Storage will be empty at tick 34706 + /* TICK 45000 + Storage will be empty at tick 45540 Additional trigger caused by (unchanged) weather data should not change this - House demand heating : requiredDemand = 9.72 kWh, additionalDemand = 24.72 kWh + House demand heating : requiredDemand = 9.78 kWh, additionalDemand = 24.78 kWh House demand water : tba - ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 8.97 kWh + ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 8.87 kWh DomesticWaterStorage : tba Heat pump: stays off */ - heatPumpAgent ! Activation(34200L) + heatPumpAgent ! Activation(45000) weatherDependentAgents.foreach { _ ! ProvideWeatherMessage( - 34200, + 45000, weatherService.ref.toClassic, WeatherData( WattsPerSquareMeter(3d), @@ -567,19 +567,19 @@ class ThermalGridIT Celsius(-25d), MetersPerSecond(0d), ), - Some(50400L), + Some(57600), ) } resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 34200.toDateTime + hpResult.getTime shouldBe 45000.toDateTime hpResult.getP should equalWithTolerance(0.0.asMegaWatt) hpResult.getQ should equalWithTolerance(0.0.asMegaVar) } - // Results of 31106 for house and storage + // Results of 34132 for house and storage Range(0, 2) .map { _ => resultListener.expectMessageType[ResultEvent] @@ -593,10 +593,10 @@ class ThermalGridIT indoorTemperature, ) => inputModel shouldBe typicalThermalHouse.getUuid - time shouldBe 31106.toDateTime + time shouldBe 41940.toDateTime qDot should equalWithTolerance(0.01044.asMegaWatt) indoorTemperature should equalWithTolerance( - 18.00002164245703.asDegreeCelsius + 17.9999786813733.asDegreeCelsius ) case CylindricalThermalStorageResult( time, @@ -605,7 +605,7 @@ class ThermalGridIT energy, ) => inputModel shouldBe typicalThermalStorage.getUuid - time shouldBe 31106.toDateTime + time shouldBe 41940.toDateTime qDot should equalWithTolerance((-0.01044).asMegaWatt) energy should equalWithTolerance(0.01044.asMegaWattHour) case _ => @@ -615,30 +615,30 @@ class ThermalGridIT } } - scheduler.expectMessage(Completion(heatPumpAgent, Some(34200L))) + scheduler.expectMessage(Completion(heatPumpAgent, Some(45000))) - /* TICK 34706 + /* TICK 45540 Storage will be empty - House demand heating : requiredDemand = 8.87 kWh, additionalDemand = 23.87 kWh + House demand heating : requiredDemand = 8.87kWh, additionalDemand = 23.87 kWh House demand water : tba - ThermalStorage : requiredDemand = 5.22 kWh, additionalDemand = 10.44 kWh + ThermalStorage : requiredDemand = 10.44 kWh, additionalDemand = 10.44 kWh DomesticWaterStorage : tba Heat pump: will be turned on - to serve the remaining heat demand of house (and refill storage later) */ - heatPumpAgent ! Activation(34706L) + heatPumpAgent ! Activation(45540) resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 34706.toDateTime + hpResult.getTime shouldBe 45540.toDateTime hpResult.getP should equalWithTolerance(pRunningHp) hpResult.getQ should equalWithTolerance( qRunningHp ) } - // Results of 34200 for house and storage + // Results of 45000 for house and storage Range(0, 2) .map { _ => resultListener.expectMessageType[ResultEvent] @@ -652,10 +652,10 @@ class ThermalGridIT indoorTemperature, ) => inputModel shouldBe typicalThermalHouse.getUuid - time shouldBe 34200.toDateTime + time shouldBe 45000.toDateTime qDot should equalWithTolerance(0.01044.asMegaWatt) indoorTemperature should equalWithTolerance( - 18.703619912969.asDegreeCelsius + 18.69584558965105.asDegreeCelsius ) case CylindricalThermalStorageResult( @@ -665,10 +665,10 @@ class ThermalGridIT energy, ) => inputModel shouldBe typicalThermalStorage.getUuid - time shouldBe 34200.toDateTime + time shouldBe 45000.toDateTime qDot should equalWithTolerance((-0.01044).asMegaWatt) energy should equalWithTolerance( - 0.0014673999999999996.asMegaWattHour + 0.00156599999999999.asMegaWattHour ) case _ => fail( @@ -677,9 +677,80 @@ class ThermalGridIT } } - scheduler.expectMessage(Completion(heatPumpAgent, Some(34706L))) + scheduler.expectMessage(Completion(heatPumpAgent, Some(45540))) + + /* TICK 57600 +New weather data: it's getting warmer again +House demand heating : requiredDemand = 0.00 kWh, additionalDemand = 1.70 kWh +House demand water : tba +ThermalStorage : requiredDemand = 10.44 kWh, additionalDemand = 10.44 kWh +DomesticWaterStorage : tba +Heat pump: stays on + */ + + heatPumpAgent ! Activation(57600) + + weatherDependentAgents.foreach { + _ ! ProvideWeatherMessage( + 57600, + weatherService.ref.toClassic, + WeatherData( + WattsPerSquareMeter(4d), + WattsPerSquareMeter(4d), + Celsius(5d), + MetersPerSecond(0d), + ), + Some(151200), + ) + } + + resultListener.expectMessageType[ParticipantResultEvent] match { + case ParticipantResultEvent(hpResult) => + hpResult.getInputModel shouldBe typicalHpInputModel.getUuid + hpResult.getTime shouldBe 57600.toDateTime + hpResult.getP should equalWithTolerance(pRunningHp) + hpResult.getQ should equalWithTolerance(qRunningHp) + } - /* TICK 47690 + // Results of 45540 for house and storage + Range(0, 2) + .map { _ => + resultListener.expectMessageType[ResultEvent] + } + .foreach { case ResultEvent.ThermalResultEvent(thermalUnitResult) => + thermalUnitResult match { + case ThermalHouseResult( + time, + inputModel, + qDot, + indoorTemperature, + ) => + inputModel shouldBe typicalThermalHouse.getUuid + time shouldBe 45540.toDateTime + qDot should equalWithTolerance(0.011.asMegaWatt) + indoorTemperature should equalWithTolerance( + 18.81725389847177.asDegreeCelsius + ) + + case CylindricalThermalStorageResult( + time, + inputModel, + qDot, + energy, + ) => + inputModel shouldBe typicalThermalStorage.getUuid + time shouldBe 45540.toDateTime + qDot should equalWithTolerance(0.asMegaWatt) + energy should equalWithTolerance(0.asMegaWattHour) + case _ => + fail( + "Expected a ThermalHouseResult and a ThermalStorageResult but got something else" + ) + } + } + scheduler.expectMessage(Completion(heatPumpAgent, Some(57600))) + + /* TICK 58256 House will reach the upperTemperatureBoundary House demand heating : requiredDemand = 0.00 kWh, additionalDemand = 0.00 kWh House demand water : tba @@ -688,17 +759,17 @@ class ThermalGridIT Heat pump: stays on to refill the storage now */ - heatPumpAgent ! Activation(47690L) + heatPumpAgent ! Activation(58256) resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 47690.toDateTime + hpResult.getTime shouldBe 58256.toDateTime hpResult.getP should equalWithTolerance(pRunningHp) hpResult.getQ should equalWithTolerance(qRunningHp) } - // Results of 34706 for house and storage + // Results of 57600 for house and storage Range(0, 2) .map { _ => resultListener.expectMessageType[ResultEvent] @@ -712,10 +783,10 @@ class ThermalGridIT indoorTemperature, ) => inputModel shouldBe typicalThermalHouse.getUuid - time shouldBe 34706L.toDateTime + time shouldBe 57600.toDateTime qDot should equalWithTolerance(0.011.asMegaWatt) indoorTemperature should equalWithTolerance( - 18.81736942528025.asDegreeCelsius + 21.77341655767336.asDegreeCelsius ) case CylindricalThermalStorageResult( @@ -725,7 +796,7 @@ class ThermalGridIT energy, ) => inputModel shouldBe typicalThermalStorage.getUuid - time shouldBe 34706L.toDateTime + time shouldBe 57600.toDateTime qDot should equalWithTolerance(0.asMegaWatt) energy should equalWithTolerance( 0.asMegaWattHour @@ -733,42 +804,28 @@ class ThermalGridIT } } - scheduler.expectMessage(Completion(heatPumpAgent, Some(47690L))) + scheduler.expectMessage(Completion(heatPumpAgent, Some(58256))) - /* TICK 50400 - New weather data: it's getting warmer again - House demand heating : requiredDemand = 0.00 kWh, additionalDemand = 0.00 kWh - House demand water : tba - ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 2.16 kWh - DomesticWaterStorage : tba - Heat pump: stays on + /* TICK 61673 + Storage will be fully charged + House demand heating : requiredDemand = ?0.00 kWh, additionalDemand = 0.00 kWh + House demand water : tba + ThermalStorage : requiredDemand = 0.0 kWh, additionalDemand = 0.0 kWh + DomesticWaterStorage : tba + Heat pump: stays on to refill the storage now */ - heatPumpAgent ! Activation(50400L) - - weatherDependentAgents.foreach { - _ ! ProvideWeatherMessage( - 50400L, - weatherService.ref.toClassic, - WeatherData( - WattsPerSquareMeter(4d), - WattsPerSquareMeter(4d), - Celsius(5d), - MetersPerSecond(0d), - ), - Some(151200L), - ) - } + heatPumpAgent ! Activation(61673) resultListener.expectMessageType[ParticipantResultEvent] match { case ParticipantResultEvent(hpResult) => hpResult.getInputModel shouldBe typicalHpInputModel.getUuid - hpResult.getTime shouldBe 50400.toDateTime - hpResult.getP should equalWithTolerance(pRunningHp) - hpResult.getQ should equalWithTolerance(qRunningHp) + hpResult.getTime shouldBe 61673.toDateTime + hpResult.getP should equalWithTolerance(0.asMegaWatt) + hpResult.getQ should equalWithTolerance(0.asMegaVar) } - // Results of 47690 for house and storage + // Results of 58256 for house and storage Range(0, 2) .map { _ => resultListener.expectMessageType[ResultEvent] @@ -782,10 +839,10 @@ class ThermalGridIT indoorTemperature, ) => inputModel shouldBe typicalThermalHouse.getUuid - time shouldBe 47690.toDateTime + time shouldBe 58256.toDateTime qDot should equalWithTolerance(0.asMegaWatt) indoorTemperature should equalWithTolerance( - 22.00001859336235.asDegreeCelsius + 21.999922627074.asDegreeCelsius ) case CylindricalThermalStorageResult( @@ -795,16 +852,16 @@ class ThermalGridIT energy, ) => inputModel shouldBe typicalThermalStorage.getUuid - time shouldBe 47690.toDateTime + time shouldBe 58256.toDateTime qDot should equalWithTolerance(0.011.asMegaWatt) - energy should equalWithTolerance(0.asMegaWattHour) - case _ => - fail( - "Expected a ThermalHouseResult and a ThermalStorageResult but got something else" + energy should equalWithTolerance( + 0.asMegaWattHour ) } } - scheduler.expectMessage(Completion(heatPumpAgent, Some(50400L))) + + scheduler.expectMessage(Completion(heatPumpAgent, Some(61673))) + } } }