From 27b94e98696bb5fb5b5758ca18a35c621c04e4f3 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 8 Aug 2024 14:58:58 +0200 Subject: [PATCH 01/27] Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin --- CHANGELOG.md | 1 + .../ThermalGridWithHouseAndStorageSpec.scala | 24 ++++++------ .../ThermalGridWithStorageOnlySpec.scala | 39 +++++++++++++------ .../thermal/ThermalStorageTestData.scala | 2 +- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 825935b29e..2eb780143e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rewrote SystemComponentTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Converting remaining rst files to markdown [#838](https://github.com/ie3-institute/simona/issues/838) - Merging both `FixedFeedInModelSpec` tests [#870](https://github.com/ie3-institute/simona/issues/870) +- Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin [#894](https://github.com/ie3-institute/simona/issues/894) ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala index 6955b3c705..d57055dc3e 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala @@ -104,7 +104,7 @@ class ThermalGridWithHouseAndStorageSpec gridDemand.required should approximate(KilowattHours(0d)) gridDemand.possible should approximate( - KilowattHours(31.05009722 + 920) + KilowattHours(31.05009722 + 1150) ) } @@ -122,8 +122,8 @@ class ThermalGridWithHouseAndStorageSpec ), ) - gridDemand.required should approximate(KilowattHours(0d)) - gridDemand.possible should approximate(KilowattHours(1041.200111111)) + gridDemand.required should approximate(KilowattHours(45.60005555555534)) + gridDemand.possible should approximate(KilowattHours(1225.600055555)) } "consider stored energy to reduce house demand if stored energy is not enough" in { @@ -139,7 +139,9 @@ class ThermalGridWithHouseAndStorageSpec ) ), ) - gridDemand.required should approximate(KilowattHours(8.64987499999)) + gridDemand.required should approximate( + KilowattHours(238.64987499999984) + ) gridDemand.possible should approximate(KilowattHours(1418.64987499999)) } } @@ -189,7 +191,7 @@ class ThermalGridWithHouseAndStorageSpec "take energy from storage, if there is actual consumption" in { val tick = 0L val initialGridState = ThermalGrid.startingState(thermalGrid) - val initialLoading = KilowattHours(430d) + val initialLoading = KilowattHours(200d) val gridState = initialGridState.copy(storageState = initialGridState.storageState.map(storageState => storageState.copy(storedEnergy = initialLoading) @@ -366,7 +368,7 @@ class ThermalGridWithHouseAndStorageSpec ( ThermalStorageState( tick, - KilowattHours(50d), + KilowattHours(0d), testGridQDotInfeed, ), Some(StorageEmpty(tick)), @@ -408,7 +410,7 @@ class ThermalGridWithHouseAndStorageSpec ( ThermalStorageState( tick, - KilowattHours(250d), + KilowattHours(20d), testGridQDotInfeed, ), None, @@ -429,7 +431,7 @@ class ThermalGridWithHouseAndStorageSpec val formerStorageState = Some( ThermalStorageState( 0L, - KilowattHours(300d), + KilowattHours(70d), Kilowatts(-50d), ) ) @@ -465,8 +467,8 @@ class ThermalGridWithHouseAndStorageSpec thermalStorage.chargingPower * (-1) ) - houseColdTick shouldBe 3718L - storageEmptyTick shouldBe 3678L + houseColdTick shouldBe 3695L + storageEmptyTick shouldBe 3663L case _ => fail("Revision of states failed") } } @@ -557,7 +559,7 @@ class ThermalGridWithHouseAndStorageSpec case _ => fail("Thermal grid state has been calculated wrong.") } reachedThreshold shouldBe Some( - StorageFull(220800L) + StorageFull(276000L) ) } } 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 fe4276909f..b45b054840 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala @@ -86,8 +86,25 @@ class ThermalGridWithStorageOnlySpec ThermalGrid.startingState(thermalGrid), ) - gridDemand.required should approximate(MegawattHours(0d)) - gridDemand.possible should approximate(MegawattHours(0.92d)) + gridDemand.required should approximate(KilowattHours(0d)) + gridDemand.possible should approximate(KilowattHours(1150d)) + + } + + "deliver the capabilities of a half full storage" in { + val tick = 10800 // after three hours + + val gridDemand = thermalGrid.energyDemand( + tick, + testGridambientTemperature, + ThermalGridState( + None, + Some(ThermalStorageState(0L, KilowattHours(575d), Kilowatts(0d))), + ), + ) + + gridDemand.required should approximate(KilowattHours(0d)) + gridDemand.possible should approximate(KilowattHours(575d)) } } @@ -105,7 +122,7 @@ class ThermalGridWithStorageOnlySpec Some( ThermalStorageState( 0L, - KilowattHours(430d), + KilowattHours(200d), Kilowatts(0d), ) ) @@ -125,7 +142,7 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(430d)) + storedEnergy should approximate(KilowattHours(200d)) qDot should approximate(testGridQDotConsumptionHigh) case _ => fail("Thermal grid state has been calculated wrong.") } @@ -157,11 +174,11 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(230d)) + storedEnergy should approximate(KilowattHours(0d)) qDot should approximate(testGridQDotInfeed) case _ => fail("Thermal grid state has been calculated wrong.") } - reachedThreshold shouldBe Some(StorageFull(220800L)) + reachedThreshold shouldBe Some(StorageFull(276000L)) } } @@ -174,7 +191,7 @@ class ThermalGridWithStorageOnlySpec testGridQDotInfeed, ) - nextThreshold shouldBe Some(StorageFull(220800L)) + nextThreshold shouldBe Some(StorageFull(276000L)) updatedState match { case ThermalGridState( @@ -182,7 +199,7 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(230d)) + storedEnergy should approximate(KilowattHours(0d)) qDot should approximate(testGridQDotInfeed) case _ => fail("Thermal grid state updated failed") } @@ -197,7 +214,7 @@ class ThermalGridWithStorageOnlySpec Some( ThermalStorageState( 0L, - KilowattHours(430d), + KilowattHours(200d), Kilowatts(0d), ) ) @@ -213,7 +230,7 @@ class ThermalGridWithStorageOnlySpec Some(StorageEmpty(thresholdTick)), ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(430d)) + storedEnergy should approximate(KilowattHours(200d)) qDot should approximate(testGridQDotConsumptionHigh) thresholdTick shouldBe 3600L case _ => fail("Thermal grid state updated failed") @@ -236,7 +253,7 @@ class ThermalGridWithStorageOnlySpec None, ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(230d)) + storedEnergy should approximate(KilowattHours(0d)) qDot should approximate(Megawatts(0d)) case _ => fail("Thermal grid state updated failed") diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalStorageTestData.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalStorageTestData.scala index b5434bbb17..2360fb6efc 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalStorageTestData.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalStorageTestData.scala @@ -25,7 +25,7 @@ trait ThermalStorageTestData extends ThermalGridTestData { "TestThermalBus", ), getQuantity(100, StandardUnits.VOLUME), - getQuantity(20, StandardUnits.VOLUME), + getQuantity(0, StandardUnits.VOLUME), getQuantity(30, StandardUnits.TEMPERATURE), getQuantity(40, StandardUnits.TEMPERATURE), getQuantity(1.15, StandardUnits.SPECIFIC_HEAT_CAPACITY), From fc1eeb9f6be9e6cd968c138dda2640517bce62b8 Mon Sep 17 00:00:00 2001 From: Toastwear Date: Tue, 20 Aug 2024 13:18:22 +0200 Subject: [PATCH 02/27] Renamed UML variables ActivityStartTrigger, ScheduleTriggerMessage, CompletionMessage --- docs/uml/main/ExtEvSimulationClasses.puml | 4 ++-- docs/uml/main/ParticipantInheritance.puml | 2 +- docs/uml/protocol/ExtEvSimulationSequence.puml | 4 ++-- docs/uml/protocol/InitializationPhase.puml | 12 ++++++------ docs/uml/protocol/ParticipantTriggeredByItself.puml | 6 +++--- .../protocol/ParticipantTriggeredByPrimaryData.puml | 8 ++++---- .../ParticipantTriggeredBySecondaryData.puml | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index 9543697f03..cde1b214d2 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -164,10 +164,10 @@ package simona-api { ActivationMessage --|> ExtTrigger interface ExtTriggerResponse - class CompletionMessage { + class Completion { - List newTriggers } - CompletionMessage --|> ExtTriggerResponse + Completion --|> ExtTriggerResponse ExtTrigger -[hidden]> ExtTriggerResponse ExtTrigger <- ExtSimAdapterData diff --git a/docs/uml/main/ParticipantInheritance.puml b/docs/uml/main/ParticipantInheritance.puml index 7a681fcb8d..ddd87cdc3b 100644 --- a/docs/uml/main/ParticipantInheritance.puml +++ b/docs/uml/main/ParticipantInheritance.puml @@ -26,7 +26,7 @@ + getAndCheckNodalVoltage(...): ComparableQuantity[Dimensionless] + initializeParticipant(...): FSM.State[AgentState, ParticipantStateData] + {abstract} determineBaseStateData(...): BaseStateData[ApparentPower] - + determineTriggersThroughoutSimulation(...): Option[List[ScheduleTriggerMessage]] + + determineTriggersThroughoutSimulation(...): Option[List[ScheduleActivation]] + baseStateDataForExternalDataProvision(...): FromOutsideBaseStateData + queryPrimaryDataAndChangeState(...): FSM.State[AgentState, ParticipantStateData] + querySecondaryDataAndChangeState(...): FSM.State[AgentState, ParticipantStateData] diff --git a/docs/uml/protocol/ExtEvSimulationSequence.puml b/docs/uml/protocol/ExtEvSimulationSequence.puml index dde2f869d6..b10835efac 100644 --- a/docs/uml/protocol/ExtEvSimulationSequence.puml +++ b/docs/uml/protocol/ExtEvSimulationSequence.puml @@ -43,7 +43,7 @@ Scheduler -> ExtEvDataService: ! Activation(t1) deactivate Scheduler activate ExtEvDataService -ExtSimulation -> ExtSimAdapter: ! CompletionMessage(newTriggers) +ExtSimulation -> ExtSimAdapter: ! Completion(newTriggers) deactivate ExtSimulation activate ExtSimAdapter @@ -192,7 +192,7 @@ group Provide arriving EVs deactivate EvcsAgent2 end -ExtSimulation -> ExtSimAdapter: ! CompletionMessage(t2) +ExtSimulation -> ExtSimAdapter: ! Completion(t2) deactivate ExtSimulation activate ExtSimAdapter diff --git a/docs/uml/protocol/InitializationPhase.puml b/docs/uml/protocol/InitializationPhase.puml index a5cd1c48d0..0758c5d2e5 100644 --- a/docs/uml/protocol/InitializationPhase.puml +++ b/docs/uml/protocol/InitializationPhase.puml @@ -2,18 +2,18 @@ MainController -> Listener: create() MainController -> SimScheduler: create() MainController -> Services: create() -MainController -> SimScheduler: ! ScheduleTriggerMessage(\n\tInitializeServiceTrigger(0),\n\tweatherActorRef) +MainController -> SimScheduler: ! ScheduleActivation(\n\tInitializeServiceTrigger(0),\n\tweatherActorRef) MainController -> GridAgents: create() -MainController -> SimScheduler: ! ScheduleTriggerMessage(\n\tInitializeGridAgentTrigger(0),\n\tgridAgentInitData,\n\tgridAgentRef) +MainController -> SimScheduler: ! ScheduleActivation(\n\tInitializeGridAgentTrigger(0),\n\tgridAgentInitData,\n\tgridAgentRef) MainController -> SimScheduler: ? StartScheduleMessage() SimScheduler -> Services: ! TriggerWithIdMessage(\n\tInitializeServiceTrigger(_),\n\ttriggerId,\n\t_) -Services --> SimScheduler: ! CompletionMessage(\n\ttriggerId,\n\tScheduleTriggerMessage[...]) +Services --> SimScheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[...]) SimScheduler -> GridAgents: ! TriggerWithIdMessage(\n\tInitializeGridAgentTrigger(_),\n\ttriggerId,\n\t_) -GridAgents -> SimScheduler: ! ScheduleTriggerMessage(\n\tInitializeSystemComponentsTrigger(0),\n\tassetAgentRef) -GridAgents --> SimScheduler: ! CompletionMessage(triggerId, ScheduleTriggerMessage[...]) +GridAgents -> SimScheduler: ! ScheduleActivation(\n\tInitializeSystemComponentsTrigger(0),\n\tassetAgentRef) +GridAgents --> SimScheduler: ! Completion(triggerId, ScheduleActivation[...]) SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) ParticipantAgents -> Services: ! RegisterForWeatherMessage(lat, lon) ParticipantAgents -> Services: ! RegisterFor... Services --> ParticipantAgents: ! RegistrationResponseMessages -ParticipantAgents --> SimScheduler: ! CompletionMessage(\n\ttriggerId,\n\tScheduleTriggerMessage[\n\t\tActivityStartTrigger(tick)\n\t]) +ParticipantAgents --> SimScheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[\n\t\tActivation(tick)\n\t]) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredByItself.puml b/docs/uml/protocol/ParticipantTriggeredByItself.puml index 94b5f84985..d3a93f0bcc 100644 --- a/docs/uml/protocol/ParticipantTriggeredByItself.puml +++ b/docs/uml/protocol/ParticipantTriggeredByItself.puml @@ -1,6 +1,6 @@ @startuml SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) -ParticipantAgents --> SimScheduler: ! CompletionMessage(triggerId, ScheduleTriggerMessage[...]) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) -ParticipantAgents --> SimScheduler: ! CompletionMessage(triggerId, None) +ParticipantAgents --> SimScheduler: ! Completion(triggerId, ScheduleActivation[...]) +SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +ParticipantAgents --> SimScheduler: ! Completion(triggerId, None) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml index 03874b19bd..327269060a 100644 --- a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml +++ b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml @@ -1,7 +1,7 @@ @startuml -SimScheduler -> PrimaryServiceWorker: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) +SimScheduler -> PrimaryServiceWorker: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) PrimaryServiceWorker -> ParticipantAgents: ! ProvisionMessage -PrimaryServiceWorker --> SimScheduler: ! CompletionMessage(triggerId, None) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) -ParticipantAgents --> SimScheduler: ! CompletionMessage(triggerId, None) +PrimaryServiceWorker --> SimScheduler: ! Completion(triggerId, None) +SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +ParticipantAgents --> SimScheduler: ! Completion(triggerId, None) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml b/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml index bf79a7e891..e7a8a012c9 100644 --- a/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml +++ b/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml @@ -1,10 +1,10 @@ @startuml -SimScheduler -> Services: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) +SimScheduler -> Services: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) Services -> ParticipantAgents: ! ProvideWeatherMessage(\n\ttick,\n\tweatherData,\n\tnextDataTick) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) +SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) Services -> ParticipantAgents: ! ProvisionMessage Services -> ParticipantAgents: ! ProvisionMessage -Services --> SimScheduler: ! CompletionMessage(triggerId, None) +Services --> SimScheduler: ! Completion(triggerId, None) ParticipantAgents -> ParticipantAgents: ! StartCalculationTrigger(tick) -ParticipantAgents --> SimScheduler: ! CompletionMessage(triggerId, None) +ParticipantAgents --> SimScheduler: ! Completion(triggerId, None) @enduml \ No newline at end of file From d8d19e066310c87de41d3654de566cca360b351f Mon Sep 17 00:00:00 2001 From: Toastwear Date: Tue, 20 Aug 2024 13:24:43 +0200 Subject: [PATCH 03/27] Renamed ActivityStartTrigger, ScheduleTriggerMessage, CompletionMessage in comments --- .../participant/ParticipantAgentFundamentals.scala | 4 ++-- .../EvcsAgentModelCalculationSpec.scala | 14 +++++++------- .../FixedFeedInAgentModelCalculationSpec.scala | 4 ++-- .../participant/HpAgentModelCalculationSpec.scala | 10 +++++----- .../LoadAgentFixedModelCalculationSpec.scala | 4 ++-- .../LoadAgentProfileModelCalculationSpec.scala | 4 ++-- .../ParticipantAgent2ListenerSpec.scala | 2 +- .../ParticipantAgentExternalSourceSpec.scala | 10 +++++----- .../participant/PvAgentModelCalculationSpec.scala | 10 +++++----- .../participant/WecAgentModelCalculationSpec.scala | 10 +++++----- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala index e9fef1ad20..2b25dea2f3 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -301,7 +301,7 @@ protected trait ParticipantAgentFundamentals[ awaitRegistrationResponsesFrom, ) } else { - /* Determine the next activation tick, create a ScheduleTriggerMessage and remove the recently triggered tick */ + /* Determine the next activation tick, create a ScheduleActivation and remove the recently triggered tick */ val (newTick, nextBaseStateData) = popNextActivationTrigger( baseStateData ) @@ -902,7 +902,7 @@ protected trait ParticipantAgentFundamentals[ updatedState, ) - /* In this case, without secondary data, the agent has been triggered by an ActivityStartTrigger by itself, + /* In this case, without secondary data, the agent has been triggered by an Activation(tick) by itself, * therefore pop the next one */ val baseStateDataWithUpdatedResultStore = baseStateData.copy( diff --git a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala index 3e3a9c7a2c..dd35c2e5dc 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala @@ -368,7 +368,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] evcsAgent.stateName shouldBe Idle @@ -434,7 +434,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(0)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(evcsAgent.stateName shouldBe Idle) /* State data is tested in another test */ @@ -568,7 +568,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(0)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(evcsAgent.stateName shouldBe Idle) /* State data is tested in another test */ @@ -699,7 +699,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(10800)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(evcsAgent.stateName shouldBe Idle) @@ -744,7 +744,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(0)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the CompletionM */ scheduler.expectMsgType[Completion] awaitAssert(evcsAgent.stateName shouldBe Idle) @@ -825,7 +825,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(0)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(evcsAgent.stateName shouldBe Idle) @@ -903,7 +903,7 @@ class EvcsAgentModelCalculationSpec RegistrationSuccessfulMessage(evService.ref, Some(0)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(evcsAgent.stateName shouldBe Idle) diff --git a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala index 35277823c6..bdaac6d366 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala @@ -249,7 +249,7 @@ class FixedFeedInAgentModelCalculationSpec RegistrationFailedMessage(primaryServiceProxy.ref), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] fixedFeedAgent.stateName shouldBe Idle @@ -305,7 +305,7 @@ class FixedFeedInAgentModelCalculationSpec RegistrationFailedMessage(primaryServiceProxy.ref), ) - /* I am not interested in the CompletionMessage */ + /* I am not interested in the Completion */ scheduler.expectMsgType[Completion] awaitAssert(fixedFeedAgent.stateName shouldBe Idle) /* State data is tested in another test */ diff --git a/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala index 79e64e7a12..3ff4229ab7 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala @@ -382,7 +382,7 @@ class HpAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] hpAgent.stateName shouldBe Idle @@ -446,7 +446,7 @@ class HpAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(0L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(hpAgent.stateName shouldBe Idle) /* State data is tested in another test */ @@ -577,7 +577,7 @@ class HpAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(0L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(hpAgent.stateName shouldBe Idle) @@ -706,7 +706,7 @@ class HpAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(3600L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(hpAgent.stateName shouldBe Idle) @@ -777,7 +777,7 @@ class HpAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(0L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(hpAgent.stateName shouldBe Idle) diff --git a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala index ca26c49cb7..a93d492e4b 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala @@ -243,7 +243,7 @@ class LoadAgentFixedModelCalculationSpec RegistrationFailedMessage(primaryServiceProxy.ref), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] loadAgent.stateName shouldBe Idle @@ -299,7 +299,7 @@ class LoadAgentFixedModelCalculationSpec RegistrationFailedMessage(primaryServiceProxy.ref), ) - /* I am not interested in the CompletionMessage */ + /* I am not interested in the Completion */ scheduler.expectMsgType[Completion] awaitAssert(loadAgent.stateName shouldBe Idle) /* State data is tested in another test */ diff --git a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala index 5790868a44..2e9a180fea 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala @@ -243,7 +243,7 @@ class LoadAgentProfileModelCalculationSpec RegistrationFailedMessage(primaryServiceProxy.ref), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] loadAgent.stateName shouldBe Idle @@ -299,7 +299,7 @@ class LoadAgentProfileModelCalculationSpec RegistrationFailedMessage(primaryServiceProxy.ref), ) - /* I am not interested in the CompletionMessage */ + /* I am not interested in the Completion */ scheduler.expectMsgType[Completion] awaitAssert(loadAgent.stateName shouldBe Idle) /* State data is tested in another test */ diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgent2ListenerSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgent2ListenerSpec.scala index a768fdb73f..b061ae512d 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgent2ListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgent2ListenerSpec.scala @@ -286,7 +286,7 @@ class ParticipantAgent2ListenerSpec /* Trigger the data generation in tick 0 */ scheduler.send(mockAgent, Activation(0)) - /* Appreciate the existence of two CompletionMessages */ + /* Appreciate the existence of two Completion */ scheduler.expectMsg(Completion(mockAgent.toTyped)) /* Ask the agent for average power in tick 3000 */ diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentExternalSourceSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentExternalSourceSpec.scala index 79158df7e7..27823d38df 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentExternalSourceSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentExternalSourceSpec.scala @@ -247,7 +247,7 @@ class ParticipantAgentExternalSourceSpec RegistrationSuccessfulMessage(primaryServiceProxy.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(mockAgent.stateName shouldBe Idle) @@ -312,7 +312,7 @@ class ParticipantAgentExternalSourceSpec RegistrationSuccessfulMessage(primaryServiceProxy.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(mockAgent.stateName shouldBe Idle) @@ -413,7 +413,7 @@ class ParticipantAgentExternalSourceSpec RegistrationSuccessfulMessage(primaryServiceProxy.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(mockAgent.stateName shouldBe Idle) @@ -508,7 +508,7 @@ class ParticipantAgentExternalSourceSpec RegistrationSuccessfulMessage(primaryServiceProxy.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(mockAgent.stateName shouldBe Idle) @@ -624,7 +624,7 @@ class ParticipantAgentExternalSourceSpec RegistrationSuccessfulMessage(primaryServiceProxy.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(mockAgent.stateName shouldBe Idle) diff --git a/src/test/scala/edu/ie3/simona/agent/participant/PvAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/PvAgentModelCalculationSpec.scala index 9bda1b8b99..4d480f154c 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/PvAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/PvAgentModelCalculationSpec.scala @@ -376,7 +376,7 @@ class PvAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] pvAgent.stateName shouldBe Idle @@ -439,7 +439,7 @@ class PvAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(0L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(pvAgent.stateName shouldBe Idle) /* State data is tested in another test */ @@ -546,7 +546,7 @@ class PvAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(0L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(pvAgent.stateName shouldBe Idle) @@ -651,7 +651,7 @@ class PvAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(3600L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(pvAgent.stateName shouldBe Idle) @@ -722,7 +722,7 @@ class PvAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(0L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(pvAgent.stateName shouldBe Idle) diff --git a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala index 08193e798c..2bcac7bc3c 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala @@ -356,7 +356,7 @@ class WecAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] wecAgent.stateName shouldBe Idle @@ -424,7 +424,7 @@ class WecAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(wecAgent.stateName shouldBe Idle) /* State data is tested in another test */ @@ -546,7 +546,7 @@ class WecAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(wecAgent.stateName shouldBe Idle) @@ -666,7 +666,7 @@ class WecAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(wecAgent.stateName shouldBe Idle) @@ -737,7 +737,7 @@ class WecAgentModelCalculationSpec RegistrationSuccessfulMessage(weatherService.ref, Some(900L)), ) - /* I'm not interested in the content of the CompletionMessage */ + /* I'm not interested in the content of the Completion */ scheduler.expectMsgType[Completion] awaitAssert(wecAgent.stateName shouldBe Idle) From 186a2506fe6a1a6d3f5635300c61ce8dfa31368a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 21 Aug 2024 09:11:16 +0200 Subject: [PATCH 04/27] fmt --- .../simona/model/thermal/ThermalGridWithStorageOnlySpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f533b7b27d..8898ac1709 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala @@ -96,7 +96,7 @@ class ThermalGridWithStorageOnlySpec val gridDemand = thermalGrid.energyDemand( tick, - testGridambientTemperature, + testGridAmbientTemperature, ThermalGridState( None, Some(ThermalStorageState(0L, KilowattHours(575d), Kilowatts(0d))), From 3ed3702ab4535f210ce7a95d19822bf5284e05af Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 21 Aug 2024 15:13:00 +0200 Subject: [PATCH 05/27] set storage minimumLvl to zero at HpInputTestData --- .../edu/ie3/simona/test/common/input/HpInputTestData.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/test/common/input/HpInputTestData.scala b/src/test/scala/edu/ie3/simona/test/common/input/HpInputTestData.scala index 4c5a48dfd1..c2f5fed9ea 100644 --- a/src/test/scala/edu/ie3/simona/test/common/input/HpInputTestData.scala +++ b/src/test/scala/edu/ie3/simona/test/common/input/HpInputTestData.scala @@ -117,7 +117,7 @@ trait HpInputTestData extends NodeInputTestData with ThermalGridTestData { OperatorInput.NO_OPERATOR_ASSIGNED, OperationTime.notLimited(), thermalBusInput, - KilowattHours(20d), + KilowattHours(0d), KilowattHours(500d), Kilowatts(10d), KilowattHours(0d), From ac9e26dd71f91215fafca0966d775745ffb6a9c8 Mon Sep 17 00:00:00 2001 From: Toastwear Date: Fri, 23 Aug 2024 14:01:03 +0200 Subject: [PATCH 06/27] Changed SimScheduler and MainController to Scheduler and SimonaSim --- docs/uml/protocol/InitializationPhase.puml | 28 +++++++++---------- .../ParticipantTriggeredByItself.puml | 8 +++--- .../ParticipantTriggeredByPrimaryData.puml | 8 +++--- .../ParticipantTriggeredBySecondaryData.puml | 8 +++--- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/uml/protocol/InitializationPhase.puml b/docs/uml/protocol/InitializationPhase.puml index 0758c5d2e5..4c23f9495b 100644 --- a/docs/uml/protocol/InitializationPhase.puml +++ b/docs/uml/protocol/InitializationPhase.puml @@ -1,19 +1,19 @@ @startuml -MainController -> Listener: create() -MainController -> SimScheduler: create() -MainController -> Services: create() -MainController -> SimScheduler: ! ScheduleActivation(\n\tInitializeServiceTrigger(0),\n\tweatherActorRef) -MainController -> GridAgents: create() -MainController -> SimScheduler: ! ScheduleActivation(\n\tInitializeGridAgentTrigger(0),\n\tgridAgentInitData,\n\tgridAgentRef) -MainController -> SimScheduler: ? StartScheduleMessage() -SimScheduler -> Services: ! TriggerWithIdMessage(\n\tInitializeServiceTrigger(_),\n\ttriggerId,\n\t_) -Services --> SimScheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[...]) -SimScheduler -> GridAgents: ! TriggerWithIdMessage(\n\tInitializeGridAgentTrigger(_),\n\ttriggerId,\n\t_) -GridAgents -> SimScheduler: ! ScheduleActivation(\n\tInitializeSystemComponentsTrigger(0),\n\tassetAgentRef) -GridAgents --> SimScheduler: ! Completion(triggerId, ScheduleActivation[...]) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) +SimonaSim -> Listener: create() +SimonaSim -> Scheduler: create() +SimonaSim -> Services: create() +SimonaSim -> Scheduler: ! ScheduleActivation(\n\tInitializeServiceTrigger(0),\n\tweatherActorRef) +SimonaSim -> GridAgents: create() +SimonaSim -> Scheduler: ! ScheduleActivation(\n\tInitializeGridAgentTrigger(0),\n\tgridAgentInitData,\n\tgridAgentRef) +SimonaSim -> Scheduler: ? StartScheduleMessage() +Scheduler -> Services: ! TriggerWithIdMessage(\n\tInitializeServiceTrigger(_),\n\ttriggerId,\n\t_) +Services --> Scheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[...]) +Scheduler -> GridAgents: ! TriggerWithIdMessage(\n\tInitializeGridAgentTrigger(_),\n\ttriggerId,\n\t_) +GridAgents -> Scheduler: ! ScheduleActivation(\n\tInitializeSystemComponentsTrigger(0),\n\tassetAgentRef) +GridAgents --> Scheduler: ! Completion(triggerId, ScheduleActivation[...]) +Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) ParticipantAgents -> Services: ! RegisterForWeatherMessage(lat, lon) ParticipantAgents -> Services: ! RegisterFor... Services --> ParticipantAgents: ! RegistrationResponseMessages -ParticipantAgents --> SimScheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[\n\t\tActivation(tick)\n\t]) +ParticipantAgents --> Scheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[\n\t\tActivation(tick)\n\t]) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredByItself.puml b/docs/uml/protocol/ParticipantTriggeredByItself.puml index d3a93f0bcc..1a6e8e7484 100644 --- a/docs/uml/protocol/ParticipantTriggeredByItself.puml +++ b/docs/uml/protocol/ParticipantTriggeredByItself.puml @@ -1,6 +1,6 @@ @startuml -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) -ParticipantAgents --> SimScheduler: ! Completion(triggerId, ScheduleActivation[...]) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) -ParticipantAgents --> SimScheduler: ! Completion(triggerId, None) +Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) +ParticipantAgents --> Scheduler: ! Completion(triggerId, ScheduleActivation[...]) +Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +ParticipantAgents --> Scheduler: ! Completion(triggerId, None) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml index 327269060a..8706dc862d 100644 --- a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml +++ b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml @@ -1,7 +1,7 @@ @startuml -SimScheduler -> PrimaryServiceWorker: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +Scheduler -> PrimaryServiceWorker: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) PrimaryServiceWorker -> ParticipantAgents: ! ProvisionMessage -PrimaryServiceWorker --> SimScheduler: ! Completion(triggerId, None) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) -ParticipantAgents --> SimScheduler: ! Completion(triggerId, None) +PrimaryServiceWorker --> Scheduler: ! Completion(triggerId, None) +Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +ParticipantAgents --> Scheduler: ! Completion(triggerId, None) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml b/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml index e7a8a012c9..ab8fbdb182 100644 --- a/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml +++ b/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml @@ -1,10 +1,10 @@ @startuml -SimScheduler -> Services: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +Scheduler -> Services: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) Services -> ParticipantAgents: ! ProvideWeatherMessage(\n\ttick,\n\tweatherData,\n\tnextDataTick) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) Services -> ParticipantAgents: ! ProvisionMessage Services -> ParticipantAgents: ! ProvisionMessage -Services --> SimScheduler: ! Completion(triggerId, None) +Services --> Scheduler: ! Completion(triggerId, None) ParticipantAgents -> ParticipantAgents: ! StartCalculationTrigger(tick) -ParticipantAgents --> SimScheduler: ! Completion(triggerId, None) +ParticipantAgents --> Scheduler: ! Completion(triggerId, None) @enduml \ No newline at end of file From 089ef2a567c585ea35c0283742d01f17bc18c6d9 Mon Sep 17 00:00:00 2001 From: Toastwear Date: Mon, 26 Aug 2024 15:52:20 +0200 Subject: [PATCH 07/27] Adapted UML Class Completion to existing variables --- docs/uml/main/ExtEvSimulationClasses.puml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index cde1b214d2..bea1b6c654 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -165,7 +165,8 @@ package simona-api { interface ExtTriggerResponse class Completion { - - List newTriggers + - ActorRef Activation + - Option Long } Completion --|> ExtTriggerResponse From 7a99cb061f302fc998ba352ffee256279738ddbd Mon Sep 17 00:00:00 2001 From: Toastwear Date: Tue, 27 Aug 2024 16:08:15 +0200 Subject: [PATCH 08/27] Changed - to + in Completion Class --- docs/uml/main/ExtEvSimulationClasses.puml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index bea1b6c654..d2e56559ef 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -165,8 +165,8 @@ package simona-api { interface ExtTriggerResponse class Completion { - - ActorRef Activation - - Option Long + + ActorRef Activation + + Option Long } Completion --|> ExtTriggerResponse From d457cae2a6b60b4441bdef047f1ab899cc83ec7b Mon Sep 17 00:00:00 2001 From: Toastwear Date: Wed, 28 Aug 2024 17:10:11 +0200 Subject: [PATCH 09/27] Removed Triggers from ScheduleActivation and triggerID from Completion --- docs/uml/protocol/InitializationPhase.puml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/uml/protocol/InitializationPhase.puml b/docs/uml/protocol/InitializationPhase.puml index 4c23f9495b..ceb64aeff1 100644 --- a/docs/uml/protocol/InitializationPhase.puml +++ b/docs/uml/protocol/InitializationPhase.puml @@ -2,18 +2,18 @@ SimonaSim -> Listener: create() SimonaSim -> Scheduler: create() SimonaSim -> Services: create() -SimonaSim -> Scheduler: ! ScheduleActivation(\n\tInitializeServiceTrigger(0),\n\tweatherActorRef) +SimonaSim -> Scheduler: ! ScheduleActivation(\n\tTick(),\n\tweatherActorRef) SimonaSim -> GridAgents: create() -SimonaSim -> Scheduler: ! ScheduleActivation(\n\tInitializeGridAgentTrigger(0),\n\tgridAgentInitData,\n\tgridAgentRef) +SimonaSim -> Scheduler: ! ScheduleActivation(\n\tTick(),\n\tgridAgentInitData,\n\tgridAgentRef) SimonaSim -> Scheduler: ? StartScheduleMessage() Scheduler -> Services: ! TriggerWithIdMessage(\n\tInitializeServiceTrigger(_),\n\ttriggerId,\n\t_) -Services --> Scheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[...]) +Services --> Scheduler: ! Completion(\n\tScheduleActivation[...]) Scheduler -> GridAgents: ! TriggerWithIdMessage(\n\tInitializeGridAgentTrigger(_),\n\ttriggerId,\n\t_) -GridAgents -> Scheduler: ! ScheduleActivation(\n\tInitializeSystemComponentsTrigger(0),\n\tassetAgentRef) -GridAgents --> Scheduler: ! Completion(triggerId, ScheduleActivation[...]) +GridAgents -> Scheduler: ! ScheduleActivation(\n\tTick(),\n\tassetAgentRef) +GridAgents --> Scheduler: ! Completion(ScheduleActivation[...]) Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) ParticipantAgents -> Services: ! RegisterForWeatherMessage(lat, lon) ParticipantAgents -> Services: ! RegisterFor... Services --> ParticipantAgents: ! RegistrationResponseMessages -ParticipantAgents --> Scheduler: ! Completion(\n\ttriggerId,\n\tScheduleActivation[\n\t\tActivation(tick)\n\t]) +ParticipantAgents --> Scheduler: ! Completion(\n\tScheduleActivation[\n\t\tActivation(tick)\n\t]) @enduml \ No newline at end of file From 43a3e32efbb67b084de43a84b2f62c3ae72c8546 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Thu, 29 Aug 2024 11:17:14 +0200 Subject: [PATCH 10/27] Correcting CompletionMessage for external simulation Signed-off-by: Sebastian Peter --- docs/uml/main/ExtEvSimulationClasses.puml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index d2e56559ef..373387d8b8 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -164,11 +164,10 @@ package simona-api { ActivationMessage --|> ExtTrigger interface ExtTriggerResponse - class Completion { - + ActorRef Activation - + Option Long + class CompletionMessage { + - Optional nextActivation } - Completion --|> ExtTriggerResponse + CompletionMessage --|> ExtTriggerResponse ExtTrigger -[hidden]> ExtTriggerResponse ExtTrigger <- ExtSimAdapterData From 37ac2af715cc53873d416eacc19d0bc6cbdd64e7 Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Tue, 3 Sep 2024 11:48:08 +0200 Subject: [PATCH 11/27] Removed TriggerIDMessage, Changed Completion and where ScheduleActivations come from --- docs/uml/protocol/InitializationPhase.puml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/uml/protocol/InitializationPhase.puml b/docs/uml/protocol/InitializationPhase.puml index ceb64aeff1..b46e4b3c06 100644 --- a/docs/uml/protocol/InitializationPhase.puml +++ b/docs/uml/protocol/InitializationPhase.puml @@ -2,18 +2,18 @@ SimonaSim -> Listener: create() SimonaSim -> Scheduler: create() SimonaSim -> Services: create() -SimonaSim -> Scheduler: ! ScheduleActivation(\n\tTick(),\n\tweatherActorRef) +Services -> Scheduler: ! ScheduleActivation(\n\tweatherActorRef, \n\tINIT_SIM_TICK) SimonaSim -> GridAgents: create() -SimonaSim -> Scheduler: ! ScheduleActivation(\n\tTick(),\n\tgridAgentInitData,\n\tgridAgentRef) +GridAgents -> Scheduler: ! ScheduleActivation(\n\tgridAgentRef, \n\tINIT_SIM_TICK) SimonaSim -> Scheduler: ? StartScheduleMessage() -Scheduler -> Services: ! TriggerWithIdMessage(\n\tInitializeServiceTrigger(_),\n\ttriggerId,\n\t_) -Services --> Scheduler: ! Completion(\n\tScheduleActivation[...]) -Scheduler -> GridAgents: ! TriggerWithIdMessage(\n\tInitializeGridAgentTrigger(_),\n\ttriggerId,\n\t_) -GridAgents -> Scheduler: ! ScheduleActivation(\n\tTick(),\n\tassetAgentRef) -GridAgents --> Scheduler: ! Completion(ScheduleActivation[...]) -Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) +Scheduler -> Services: ! Activation(\n\tINIT_SIM_TICK) +Services --> Scheduler: ! Completion(\n\tweatherActorRef, \n\ttick) +Scheduler -> GridAgents: ! Activation(\n\tINIT_SIM_TICK) +GridAgents -> Scheduler: ! ScheduleActivation(\n\tassetAgentRef, \n\tINIT_SIM_TICK) +GridAgents --> Scheduler: ! Completion(\n\tgridAgentRef,\n\ttick) +Scheduler -> ParticipantAgents: ! Activation(\n\tINIT_SIM_TICK) ParticipantAgents -> Services: ! RegisterForWeatherMessage(lat, lon) ParticipantAgents -> Services: ! RegisterFor... Services --> ParticipantAgents: ! RegistrationResponseMessages -ParticipantAgents --> Scheduler: ! Completion(\n\tScheduleActivation[\n\t\tActivation(tick)\n\t]) +ParticipantAgents --> Scheduler: ! Completion(\n\tassetAgentRef,\n\ttick) @enduml \ No newline at end of file From 2568bf2308972a013a274763d8267b13201b69d3 Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 9 Sep 2024 12:38:30 +0200 Subject: [PATCH 12/27] Remove TriggerWithIDMessage() and triggerIDs from Completion --- docs/uml/protocol/ParticipantTriggeredByItself.puml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/uml/protocol/ParticipantTriggeredByItself.puml b/docs/uml/protocol/ParticipantTriggeredByItself.puml index 1a6e8e7484..b476a6e232 100644 --- a/docs/uml/protocol/ParticipantTriggeredByItself.puml +++ b/docs/uml/protocol/ParticipantTriggeredByItself.puml @@ -1,6 +1,6 @@ @startuml -Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) -ParticipantAgents --> Scheduler: ! Completion(triggerId, ScheduleActivation[...]) -Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) -ParticipantAgents --> Scheduler: ! Completion(triggerId, None) +Scheduler -> ParticipantAgents: ! Activation(\n\tINIT_SIM_TICK) +ParticipantAgents --> Scheduler: ! Completion(\n\tactor, tick) +Scheduler -> ParticipantAgents: ! Activation(\n\ttick) +ParticipantAgents --> Scheduler: ! Completion(\n\tactor, newTick) @enduml \ No newline at end of file From ddff841febff7f46f18c3caeae39720e000f5818 Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 9 Sep 2024 12:38:38 +0200 Subject: [PATCH 13/27] Remove TriggerWithIDMessage() and triggerIDs from Completion --- docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml | 8 ++++---- .../uml/protocol/ParticipantTriggeredBySecondaryData.puml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml index 8706dc862d..c9ee2e21bd 100644 --- a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml +++ b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml @@ -1,7 +1,7 @@ @startuml -Scheduler -> PrimaryServiceWorker: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +Scheduler -> PrimaryServiceWorker: ! Activation(\n\tInit_SIM_TICK) PrimaryServiceWorker -> ParticipantAgents: ! ProvisionMessage -PrimaryServiceWorker --> Scheduler: ! Completion(triggerId, None) -Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) -ParticipantAgents --> Scheduler: ! Completion(triggerId, None) +PrimaryServiceWorker --> Scheduler: ! Completion(\n\tactor,None) +Scheduler -> ParticipantAgents: ! Activation(\n\ttick) +ParticipantAgents --> Scheduler: ! Completion(\n\tactor, newTick) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml b/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml index ab8fbdb182..a3837f60fb 100644 --- a/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml +++ b/docs/uml/protocol/ParticipantTriggeredBySecondaryData.puml @@ -1,10 +1,10 @@ @startuml -Scheduler -> Services: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +Scheduler -> Services: ! Activation(\n\tINIT_SIM_TICK) Services -> ParticipantAgents: ! ProvideWeatherMessage(\n\ttick,\n\tweatherData,\n\tnextDataTick) -Scheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivation(tick),\n\t_,\n\t_) +Scheduler -> ParticipantAgents: ! Activation(\n\ttick) Services -> ParticipantAgents: ! ProvisionMessage Services -> ParticipantAgents: ! ProvisionMessage -Services --> Scheduler: ! Completion(triggerId, None) +Services --> Scheduler: ! Completion(\n\tactor, None) ParticipantAgents -> ParticipantAgents: ! StartCalculationTrigger(tick) -ParticipantAgents --> Scheduler: ! Completion(triggerId, None) +ParticipantAgents --> Scheduler: ! Completion(\n\tactor, newTick) @enduml \ No newline at end of file From 6a421448b421be6040cf4961e28cd36f46fe05a7 Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 9 Sep 2024 16:05:40 +0200 Subject: [PATCH 14/27] Changed methods to values: calcNewTemperatureChange, calcInnerTemperatureChange, calcThermalEnergyChange and calcThermalEnergyGain --- .../simona/model/thermal/ThermalHouse.scala | 100 ++---------------- .../scala/quantities/ThermalConductance.scala | 2 +- .../model/thermal/ThermalHouseSpec.scala | 21 ++-- .../quantities/ThermalConductanceSpec.scala | 4 +- 4 files changed, 20 insertions(+), 107 deletions(-) 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 547a639d08..ac6b56a4c1 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -199,101 +199,19 @@ final case class ThermalHouse( currentInnerTemperature: Temperature, ambientTemperature: Temperature, ): Temperature = { - val thermalEnergyChange = calcThermalEnergyChange( - calcThermalEnergyGain(thermalPower, duration), - calcThermalEnergyLoss( - currentInnerTemperature, - ambientTemperature, - duration, - ), - ) - calcNewInnerTemperature( + val thermalEnergyGain = thermalPower * duration + + val thermalEnergyLoss = ethLosses.calcThermalEnergyChange( currentInnerTemperature, - calcInnerTemperatureChange(thermalEnergyChange), + ambientTemperature, + duration, ) - } - /** Calculate the new inner temperature of the thermal house - * - * @param oldInnerTemperature - * previous inner temperature - * @param temperatureChange - * temperature change - * @return - * new inner temperature - */ - def calcNewInnerTemperature( - oldInnerTemperature: Temperature, - temperatureChange: Temperature, - ): Temperature = - oldInnerTemperature + temperatureChange + val temperatureChange = (thermalEnergyGain - thermalEnergyLoss) / ethCapa - /** Calculate the temperature change for the thermal house form the thermal - * energy change - * - * @param thermalEnergyChange - * thermal energy change (e.g. through heat pump) - * @return - * temperature change - */ - def calcInnerTemperatureChange( - thermalEnergyChange: Energy - ): Temperature = { - thermalEnergyChange / ethCapa + currentInnerTemperature + temperatureChange } - /** Calculate the thermal energy change combining the added and lost energy - * - * @param thermalEnergyGain - * thermal energy added - * @param thermalEnergyLoss - * thermal energy lost - * @return - * thermal energy change - */ - def calcThermalEnergyChange( - thermalEnergyGain: Energy, - thermalEnergyLoss: Energy, - ): Energy = - thermalEnergyGain - thermalEnergyLoss - - /** Calculate the thermal energy gain, e.g. due to a running heat pump - * - * @param pThermal - * added thermal power (e.g. of heat pump) - * @param time - * time step length in which thermal power is added - * @return - * resulting thermal energy gain - */ - def calcThermalEnergyGain( - pThermal: Power, - time: Time, - ): Energy = pThermal * time - - /** Calculate the thermal energy loss due to the temperature deviation over - * the time step - * - * @param innerTemperature - * previous inner temperature - * @param ambientTemperature - * ambient temperature of thermal house - * @param time - * time step length - * @return - * resulting thermal energy loss - */ - def calcThermalEnergyLoss( - innerTemperature: Temperature, - ambientTemperature: Temperature, - time: Time, - ): Energy = { - ethLosses.thermalConductanceToEnergy( - innerTemperature, - ambientTemperature, - time, - ) - } /** Update the current state of the house * @@ -358,11 +276,11 @@ final case class ThermalHouse( ambientTemperature: Temperature, ): Option[ThermalThreshold] = { val artificialDuration = Hours(1d) - val loss = calcThermalEnergyLoss( + val loss = ethLosses.calcThermalEnergyChange( innerTemperature, ambientTemperature, artificialDuration, - ) / artificialDuration + ) / artificialDuration val resultingQDot = qDotExternal - loss if ( resultingQDot < zeroMW && !isInnerTemperatureTooLow( diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ThermalConductance.scala b/src/main/scala/edu/ie3/util/scala/quantities/ThermalConductance.scala index ce8f9d4293..a5fa7648c4 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ThermalConductance.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ThermalConductance.scala @@ -33,7 +33,7 @@ final class ThermalConductance private ( * Time duration * @return */ - def thermalConductanceToEnergy( + def calcThermalEnergyChange( temperatureInner: Temperature, temperatureOuter: Temperature, time: squants.Time, 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 20131046bf..8422061cdc 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -56,23 +56,18 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { val thermalHouseTest = thermalHouse(18, 22) val innerTemperature = Temperature(20, Celsius) - val thermalEnergyGain = - thermalHouseTest.calcThermalEnergyGain(Kilowatts(100), Seconds(3600)) - val thermalEnergyLoss = thermalHouseTest.calcThermalEnergyLoss( + val thermalEnergyGain = KilowattHours(100) + val thermalEnergyLoss = thermalHouseTest.ethLosses.calcThermalEnergyChange( innerTemperature, Temperature(10, Celsius), Seconds(3600), ) - val thermalEnergyChange = thermalHouseTest.calcThermalEnergyChange( - thermalEnergyGain, - thermalEnergyLoss, - ) - val innerTemperatureChange = - thermalHouseTest.calcInnerTemperatureChange(thermalEnergyChange) - val newInnerTemperature = thermalHouseTest.calcNewInnerTemperature( - innerTemperature, - innerTemperatureChange, - ) + val thermalEnergyChange = thermalEnergyGain - thermalEnergyLoss + + val innerTemperatureChange = thermalEnergyChange/thermalHouseTest.ethCapa + + val newInnerTemperature = innerTemperature + innerTemperatureChange + thermalEnergyGain should approximate(KilowattHours(100)) thermalEnergyLoss should approximate(KilowattHours(10)) diff --git a/src/test/scala/edu/ie3/util/quantities/ThermalConductanceSpec.scala b/src/test/scala/edu/ie3/util/quantities/ThermalConductanceSpec.scala index 7b71137d69..9b54c25a81 100644 --- a/src/test/scala/edu/ie3/util/quantities/ThermalConductanceSpec.scala +++ b/src/test/scala/edu/ie3/util/quantities/ThermalConductanceSpec.scala @@ -33,7 +33,7 @@ class ThermalConductanceSpec extends AnyFlatSpec with Matchers { } it should "return Energy when multiplied by Temperature in Kelvin and Time" in { - WattsPerKelvin(1000).thermalConductanceToEnergy( + WattsPerKelvin(1000).calcThermalEnergyChange( Kelvin(10), Kelvin(0), Hours(5), @@ -41,7 +41,7 @@ class ThermalConductanceSpec extends AnyFlatSpec with Matchers { } it should "return Energy when multiplied by Temperature in Celsius and Time" in { - WattsPerKelvin(1000).thermalConductanceToEnergy( + WattsPerKelvin(1000).calcThermalEnergyChange( Celsius(10), Celsius(0), Hours(5), From 25d2d35b7265852f2c60c959fd6ef219eb3b6dff Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Tue, 10 Sep 2024 13:19:08 +0200 Subject: [PATCH 15/27] spotlessApply changes --- .../ie3/simona/model/thermal/ThermalHouse.scala | 3 +-- .../simona/model/thermal/ThermalHouseSpec.scala | 15 ++++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) 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 ac6b56a4c1..afc49ad5b3 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -212,7 +212,6 @@ final case class ThermalHouse( currentInnerTemperature + temperatureChange } - /** Update the current state of the house * * @param tick @@ -280,7 +279,7 @@ final case class ThermalHouse( innerTemperature, ambientTemperature, artificialDuration, - ) / artificialDuration + ) / artificialDuration val resultingQDot = qDotExternal - loss if ( resultingQDot < zeroMW && !isInnerTemperatureTooLow( 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 8422061cdc..7178db116b 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -57,18 +57,19 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { val innerTemperature = Temperature(20, Celsius) val thermalEnergyGain = KilowattHours(100) - val thermalEnergyLoss = thermalHouseTest.ethLosses.calcThermalEnergyChange( - innerTemperature, - Temperature(10, Celsius), - Seconds(3600), - ) + val thermalEnergyLoss = + thermalHouseTest.ethLosses.calcThermalEnergyChange( + innerTemperature, + Temperature(10, Celsius), + Seconds(3600), + ) val thermalEnergyChange = thermalEnergyGain - thermalEnergyLoss - val innerTemperatureChange = thermalEnergyChange/thermalHouseTest.ethCapa + val innerTemperatureChange = + thermalEnergyChange / thermalHouseTest.ethCapa val newInnerTemperature = innerTemperature + innerTemperatureChange - thermalEnergyGain should approximate(KilowattHours(100)) thermalEnergyLoss should approximate(KilowattHours(10)) thermalEnergyChange should approximate(KilowattHours(90)) From 1ccf1b81d57892e95ab5e6d00ef0e4f3558da40c Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 16 Sep 2024 00:12:53 +0200 Subject: [PATCH 16/27] Changed newTrigger to newTick --- docs/uml/protocol/ExtEvSimulationSequence.puml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/uml/protocol/ExtEvSimulationSequence.puml b/docs/uml/protocol/ExtEvSimulationSequence.puml index b10835efac..872d42b92a 100644 --- a/docs/uml/protocol/ExtEvSimulationSequence.puml +++ b/docs/uml/protocol/ExtEvSimulationSequence.puml @@ -43,11 +43,11 @@ Scheduler -> ExtEvDataService: ! Activation(t1) deactivate Scheduler activate ExtEvDataService -ExtSimulation -> ExtSimAdapter: ! Completion(newTriggers) +ExtSimulation -> ExtSimAdapter: ! Completion(newTick) deactivate ExtSimulation activate ExtSimAdapter -ExtSimAdapter -> Scheduler: ! Completion(newTriggers) +ExtSimAdapter -> Scheduler: ! Completion(newTick) deactivate ExtSimAdapter ExtEvDataService -> EvcsAgent1: ! RegistrationSuccessfulMessage(t1) From 5d64f23ffb15c98831eccbc11e204de86032938b Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 16 Sep 2024 12:13:57 +0200 Subject: [PATCH 17/27] Changed Completion to CompletionMessage --- .../uml/protocol/ExtEvSimulationSequence.puml | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/uml/protocol/ExtEvSimulationSequence.puml b/docs/uml/protocol/ExtEvSimulationSequence.puml index 872d42b92a..1c3cfccb8b 100644 --- a/docs/uml/protocol/ExtEvSimulationSequence.puml +++ b/docs/uml/protocol/ExtEvSimulationSequence.puml @@ -43,26 +43,26 @@ Scheduler -> ExtEvDataService: ! Activation(t1) deactivate Scheduler activate ExtEvDataService -ExtSimulation -> ExtSimAdapter: ! Completion(newTick) +ExtSimulation -> ExtSimAdapter: ! CompletionMessage(newTick) deactivate ExtSimulation activate ExtSimAdapter -ExtSimAdapter -> Scheduler: ! Completion(newTick) +ExtSimAdapter -> Scheduler: ! CompletionMessage(newTick) deactivate ExtSimAdapter ExtEvDataService -> EvcsAgent1: ! RegistrationSuccessfulMessage(t1) activate EvcsAgent1 -EvcsAgent1 -> Scheduler: ! Completion(t1) +EvcsAgent1 -> Scheduler: ! CompletionMessage(t1) deactivate EvcsAgent1 ExtEvDataService -> EvcsAgent2: ! RegistrationSuccessfulMessage(t1) activate EvcsAgent2 -EvcsAgent2 -> Scheduler: ! Completion(t1) +EvcsAgent2 -> Scheduler: ! CompletionMessage(t1) deactivate EvcsAgent2 -ExtEvDataService -> Scheduler: ! Completion(None) +ExtEvDataService -> Scheduler: ! CompletionMessage(None) deactivate ExtEvDataService ==Simulation== @@ -96,7 +96,7 @@ group Request free lots ExtEvDataService -> EvcsAgent2: ! EvFreeLotsRequest(t1) activate EvcsAgent2 - ExtEvDataService -> Scheduler: ! Completion(None) + ExtEvDataService -> Scheduler: ! CompletionMessage(None) EvcsAgent2 -> ExtEvDataService: ! FreeLotsResponse(_, _) deactivate EvcsAgent2 @@ -124,7 +124,7 @@ group Request current prices (dummy implementation) ExtEvDataService -> ExtSimulation: queue(ProvideCurrentPrices(_)) - ExtEvDataService -> Scheduler: ! Completion(None) + ExtEvDataService -> Scheduler: ! CompletionMessage(None) deactivate ExtEvDataService end @@ -149,7 +149,7 @@ group Request departing EVs ExtEvDataService -> EvcsAgent2: ! DepartingEvsRequest(t1) activate EvcsAgent2 - ExtEvDataService -> Scheduler: ! Completion(None) + ExtEvDataService -> Scheduler: ! CompletionMessage(None) EvcsAgent2 -> ExtEvDataService: ! DepartingEvsResponse(_, _) deactivate EvcsAgent2 @@ -182,21 +182,21 @@ group Provide arriving EVs ExtEvDataService -> EvcsAgent2: ! ProvideEvDataMessage(evs, t2) activate EvcsAgent2 - ExtEvDataService -> Scheduler: ! Completion(None) + ExtEvDataService -> Scheduler: ! CompletionMessage(None) deactivate ExtEvDataService - EvcsAgent1 -> Scheduler: ! Completion(t2) + EvcsAgent1 -> Scheduler: ! CompletionMessage(t2) deactivate EvcsAgent1 - EvcsAgent2 -> Scheduler: ! Completion(t2) + EvcsAgent2 -> Scheduler: ! CompletionMessage(t2) deactivate EvcsAgent2 end -ExtSimulation -> ExtSimAdapter: ! Completion(t2) +ExtSimulation -> ExtSimAdapter: ! CompletionMessage(t2) deactivate ExtSimulation activate ExtSimAdapter -ExtSimAdapter -> Scheduler: ! Completion(t2) +ExtSimAdapter -> Scheduler: ! CompletionMessage(t2) deactivate ExtSimAdapter @enduml \ No newline at end of file From 7a49690eb95a81a56bd6b5fbfbebc7e3f0d3cac4 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 16 Sep 2024 13:23:06 +0200 Subject: [PATCH 18/27] Improve code quality in fixedloadmodelspec and other tests --- CHANGELOG.md | 1 + .../simona/model/grid/SystemComponentSpec.scala | 5 +---- .../simona/model/participant/WecModelSpec.scala | 15 ++++++++------- .../participant/load/FixedLoadModelSpec.scala | 10 ++++------ .../simona/model/thermal/ThermalHouseSpec.scala | 2 +- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff86ccca2..f305e7ee61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,7 @@ 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) +- Improve code quality in fixedloadmodelspec and other tests [#919](https://github.com/ie3-institute/simona/issues/919) ## [3.0.0] - 2023-08-07 diff --git a/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala b/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala index dce98587ad..6149b6d014 100644 --- a/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala @@ -103,12 +103,10 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { ), ) - for ((operationStart, operationEnd, expected) <- testCases) { + testCases.foreach { case (operationStart, operationEnd, expected) => val operationTimeBuilder = setup() - operationStart.foreach(operationTimeBuilder.withStart) operationEnd.foreach(operationTimeBuilder.withEnd) - val operationTime: OperationTime = operationTimeBuilder.build() val interval: OperationInterval = @@ -117,7 +115,6 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { simulationEnd, operationTime, ) - interval should be(expected) } } diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 8933819773..4e7ab8e76f 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -126,7 +126,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { -24573.39638823692, 0) velocities.zip(expectedPowers).foreach { case (velocity, power) => - val wecData = new WecRelevantData( + val wecData = WecRelevantData( MetersPerSecond(velocity), Celsius(20), Some(Pascals(101325d)), @@ -174,17 +174,18 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val expectedPowers = Seq(-23377.23862017266, -24573.41320418286, -29029.60338829823) - temperatures.zip(expectedPowers).foreach { case (temperature, power) => - val wecData = new WecRelevantData( + for (i <- temperatures.indices) { + val temperature = temperatures(i) + val expectedPower = expectedPowers(i) + val wecData = WecRelevantData( MetersPerSecond(3.0), Celsius(temperature), Some(Pascals(101325d)), ) - val result = { + val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - } - val expectedPower = Watts(power) - result shouldBe expectedPower + val expectedPowerInWatts = Watts(expectedPower) + result shouldBe expectedPowerInWatts } } } diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala index 98fd066841..d3492ea6f2 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala @@ -94,13 +94,12 @@ class FixedLoadModelSpec reference, ) - for (_ <- 0 until 10000) { + (1 to 10000).foreach { _ => val calculatedPower = dut .calculateActivePower( ModelState.ConstantState, FixedLoadModel.FixedLoadRelevantData, ) - calculatedPower should approximate(expectedPower) } } @@ -116,8 +115,9 @@ class FixedLoadModelSpec forAll(testData) { (reference, expectedPower: Power) => val relevantData = FixedLoadModel.FixedLoadRelevantData - var scale = 0.0 - while (scale <= 2) { + val scales = (0 to 20).map(_ * 0.1) + + scales.foreach { scale => val scaledSRated = Kilowatts( loadInput.getsRated .to(PowerSystemUnits.KILOWATT) @@ -142,8 +142,6 @@ class FixedLoadModelSpec val expectedScaledPower = expectedPower * scale calculatedPower should approximate(expectedScaledPower) - - scale += 0.1 } } } 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..b084257b83 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -36,7 +36,7 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { (23d, true, false), ) - testCases.foreach { case (innerTemperature, isTooHigh, isTooLow) => + forAll(testCases) { (innerTemperature: Double, isTooHigh: Boolean, isTooLow: Boolean) => val innerTemp = Temperature(innerTemperature, Celsius) val isHigher = thermalHouseTest.isInnerTemperatureTooHigh(innerTemp) val isLower = thermalHouseTest.isInnerTemperatureTooLow(innerTemp) From e3bce9ad1eddced7ceae5ad736be5ca88df59675 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 16 Sep 2024 13:23:59 +0200 Subject: [PATCH 19/27] fmt --- .../simona/model/thermal/ThermalHouseSpec.scala | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 b084257b83..944889abe2 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -36,13 +36,14 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { (23d, true, false), ) - forAll(testCases) { (innerTemperature: Double, isTooHigh: Boolean, isTooLow: Boolean) => - val innerTemp = Temperature(innerTemperature, Celsius) - val isHigher = thermalHouseTest.isInnerTemperatureTooHigh(innerTemp) - val isLower = thermalHouseTest.isInnerTemperatureTooLow(innerTemp) - - isHigher shouldBe isTooHigh - isLower shouldBe isTooLow + forAll(testCases) { + (innerTemperature: Double, isTooHigh: Boolean, isTooLow: Boolean) => + val innerTemp = Temperature(innerTemperature, Celsius) + val isHigher = thermalHouseTest.isInnerTemperatureTooHigh(innerTemp) + val isLower = thermalHouseTest.isInnerTemperatureTooLow(innerTemp) + + isHigher shouldBe isTooHigh + isLower shouldBe isTooLow } } From 5c5c7a4f3a7d7ff4500e1b88ef7005d2fe281f8f Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 16 Sep 2024 19:23:24 +0200 Subject: [PATCH 20/27] ThermalHouse tests and comments added, Changelog update --- CHANGELOG.md | 1 + .../simona/model/thermal/ThermalHouse.scala | 7 +++++- .../model/thermal/ThermalHouseSpec.scala | 25 ------------------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4030aa839..681b04b5dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated AUTHORS.md [#905](https://github.com/ie3-institute/simona/issues/905) - Rewrote BMModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Refactoring EM messages [#947](https://github.com/ie3-institute/simona/issues/947) +- Simplifying ThermalHouse [#940](https://github.com/ie3-institute/simona/issues/940) ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) 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 afc49ad5b3..71e992c4e0 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -201,14 +201,19 @@ final case class ThermalHouse( ): Temperature = { val thermalEnergyGain = thermalPower * duration + // thermal energy loss due to the deviation between outside and inside temperature val thermalEnergyLoss = ethLosses.calcThermalEnergyChange( currentInnerTemperature, ambientTemperature, duration, ) - val temperatureChange = (thermalEnergyGain - thermalEnergyLoss) / ethCapa + val energyChange = thermalEnergyGain - thermalEnergyLoss + // temperature change calculated from energy change(WattHours) and thermal capacity(Joules per Kelvin) + val temperatureChange = energyChange / ethCapa + + // return value new inner temperature currentInnerTemperature + temperatureChange } 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 7178db116b..0a967553e2 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -52,31 +52,6 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { } } - "Calculation of thermal energy change and new inner temperature is performed correctly" in { - val thermalHouseTest = thermalHouse(18, 22) - val innerTemperature = Temperature(20, Celsius) - - val thermalEnergyGain = KilowattHours(100) - val thermalEnergyLoss = - thermalHouseTest.ethLosses.calcThermalEnergyChange( - innerTemperature, - Temperature(10, Celsius), - Seconds(3600), - ) - val thermalEnergyChange = thermalEnergyGain - thermalEnergyLoss - - val innerTemperatureChange = - thermalEnergyChange / thermalHouseTest.ethCapa - - val newInnerTemperature = innerTemperature + innerTemperatureChange - - thermalEnergyGain should approximate(KilowattHours(100)) - thermalEnergyLoss should approximate(KilowattHours(10)) - thermalEnergyChange should approximate(KilowattHours(90)) - innerTemperatureChange should approximate(Kelvin(9.0)) - newInnerTemperature should approximate(Celsius(29.0)) - } - "Comprising function to calculate new inner temperature works as expected" in { val thermalHouseTest = thermalHouse(18, 22) val thermalPower = Kilowatts(100) From 71d6dd85e55e96737d634f5d9286487260d8ebe6 Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 16 Sep 2024 19:35:34 +0200 Subject: [PATCH 21/27] CompletionMessage only from SimonaAPI --- .../uml/protocol/ExtEvSimulationSequence.puml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/uml/protocol/ExtEvSimulationSequence.puml b/docs/uml/protocol/ExtEvSimulationSequence.puml index 1c3cfccb8b..b5d9ff3de4 100644 --- a/docs/uml/protocol/ExtEvSimulationSequence.puml +++ b/docs/uml/protocol/ExtEvSimulationSequence.puml @@ -47,22 +47,22 @@ ExtSimulation -> ExtSimAdapter: ! CompletionMessage(newTi deactivate ExtSimulation activate ExtSimAdapter -ExtSimAdapter -> Scheduler: ! CompletionMessage(newTick) +ExtSimAdapter -> Scheduler: ! Completion(newTick) deactivate ExtSimAdapter ExtEvDataService -> EvcsAgent1: ! RegistrationSuccessfulMessage(t1) activate EvcsAgent1 -EvcsAgent1 -> Scheduler: ! CompletionMessage(t1) +EvcsAgent1 -> Scheduler: ! Completion(t1) deactivate EvcsAgent1 ExtEvDataService -> EvcsAgent2: ! RegistrationSuccessfulMessage(t1) activate EvcsAgent2 -EvcsAgent2 -> Scheduler: ! CompletionMessage(t1) +EvcsAgent2 -> Scheduler: ! Completion(t1) deactivate EvcsAgent2 -ExtEvDataService -> Scheduler: ! CompletionMessage(None) +ExtEvDataService -> Scheduler: ! Completion(None) deactivate ExtEvDataService ==Simulation== @@ -96,7 +96,7 @@ group Request free lots ExtEvDataService -> EvcsAgent2: ! EvFreeLotsRequest(t1) activate EvcsAgent2 - ExtEvDataService -> Scheduler: ! CompletionMessage(None) + ExtEvDataService -> Scheduler: ! Completion(None) EvcsAgent2 -> ExtEvDataService: ! FreeLotsResponse(_, _) deactivate EvcsAgent2 @@ -124,7 +124,7 @@ group Request current prices (dummy implementation) ExtEvDataService -> ExtSimulation: queue(ProvideCurrentPrices(_)) - ExtEvDataService -> Scheduler: ! CompletionMessage(None) + ExtEvDataService -> Scheduler: ! Completion(None) deactivate ExtEvDataService end @@ -149,7 +149,7 @@ group Request departing EVs ExtEvDataService -> EvcsAgent2: ! DepartingEvsRequest(t1) activate EvcsAgent2 - ExtEvDataService -> Scheduler: ! CompletionMessage(None) + ExtEvDataService -> Scheduler: ! Completion(None) EvcsAgent2 -> ExtEvDataService: ! DepartingEvsResponse(_, _) deactivate EvcsAgent2 @@ -182,13 +182,13 @@ group Provide arriving EVs ExtEvDataService -> EvcsAgent2: ! ProvideEvDataMessage(evs, t2) activate EvcsAgent2 - ExtEvDataService -> Scheduler: ! CompletionMessage(None) + ExtEvDataService -> Scheduler: ! Completion(None) deactivate ExtEvDataService - EvcsAgent1 -> Scheduler: ! CompletionMessage(t2) + EvcsAgent1 -> Scheduler: ! Completion(t2) deactivate EvcsAgent1 - EvcsAgent2 -> Scheduler: ! CompletionMessage(t2) + EvcsAgent2 -> Scheduler: ! Completion(t2) deactivate EvcsAgent2 end @@ -196,7 +196,7 @@ ExtSimulation -> ExtSimAdapter: ! CompletionMessage(t2) deactivate ExtSimulation activate ExtSimAdapter -ExtSimAdapter -> Scheduler: ! CompletionMessage(t2) +ExtSimAdapter -> Scheduler: ! Completion(t2) deactivate ExtSimAdapter @enduml \ No newline at end of file From baf97f8bc1d60fddb00be1fcc013f583b2b4f2f9 Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Tue, 17 Sep 2024 10:19:08 +0200 Subject: [PATCH 22/27] Changelog Entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 681b04b5dd..817810772e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rewrote BMModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Refactoring EM messages [#947](https://github.com/ie3-institute/simona/issues/947) - Simplifying ThermalHouse [#940](https://github.com/ie3-institute/simona/issues/940) +- Renamed `ActivityStartTrigger`, `ScheduleTriggerMessage`, `CompletionMessage` in UML Diagrams[#675](https://github.com/ie3-institute/simona/issues/675) ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) From 1021c287ade7972244651139bfff044910c35d94 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Tue, 17 Sep 2024 17:40:14 +0200 Subject: [PATCH 23/27] Code improved --- .../model/grid/SystemComponentSpec.scala | 6 +-- .../model/participant/WecModelSpec.scala | 42 ++++++++++++------- .../participant/load/FixedLoadModelSpec.scala | 3 +- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala b/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala index 6149b6d014..99505d928e 100644 --- a/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala @@ -103,7 +103,7 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { ), ) - testCases.foreach { case (operationStart, operationEnd, expected) => + testCases.forall { case (operationStart, operationEnd, expected) => val operationTimeBuilder = setup() operationStart.foreach(operationTimeBuilder.withStart) operationEnd.foreach(operationTimeBuilder.withEnd) @@ -115,8 +115,8 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { simulationEnd, operationTime, ) - interval should be(expected) - } + interval == expected + } shouldBe true } "reject an operation end that is before the operation start" in { diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 4e7ab8e76f..04efdbec59 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -118,14 +118,23 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "calculate active power output depending on velocity" in { val wecModel = buildWecModel() - val velocities = - Seq(1.0, 2.0, 3.0, 7.0, 9.0, 13.0, 15.0, 19.0, 23.0, 27.0, 34.0, 40.0) - val expectedPowers = - Seq(0, -2948.8095851378266, -24573.41320418286, -522922.2325710509, - -1140000, -1140000, -1140000, -1140000, -1140000, -1140000, - -24573.39638823692, 0) - - velocities.zip(expectedPowers).foreach { case (velocity, power) => + val testCases = Table( + ("velocity", "expectedPower"), + (1.0, 0.0), + (2.0, -2948.8095851378266), + (3.0, -24573.41320418286), + (7.0, -522922.2325710509), + (9.0, -1140000.0), + (13.0, -1140000.0), + (15.0, -1140000.0), + (19.0, -1140000.0), + (23.0, -1140000.0), + (27.0, -1140000.0), + (34.0, -24573.39638823692), + (40.0, 0.0), + ) + + forAll(testCases) { (velocity: Double, expectedPower: Double) => val wecData = WecRelevantData( MetersPerSecond(velocity), Celsius(20), @@ -133,9 +142,9 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - val expectedPower = Watts(power) + val expectedPowerInWatts = Watts(expectedPower) - result should be(expectedPower) + result should be(expectedPowerInWatts) } } @@ -170,13 +179,14 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "calculate active power output depending on temperature" in { val wecModel = buildWecModel() - val temperatures = Seq(35.0, 20.0, -25.0) - val expectedPowers = - Seq(-23377.23862017266, -24573.41320418286, -29029.60338829823) + val testCases = Table( + ("temperature", "expectedPower"), + (35.0, -23377.23862017266), + (20.0, -24573.41320418286), + (-25.0, -29029.60338829823), + ) - for (i <- temperatures.indices) { - val temperature = temperatures(i) - val expectedPower = expectedPowers(i) + forAll(testCases) { (temperature: Double, expectedPower: Double) => val wecData = WecRelevantData( MetersPerSecond(3.0), Celsius(temperature), diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala index d3492ea6f2..1682d21b0c 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/FixedLoadModelSpec.scala @@ -115,7 +115,8 @@ class FixedLoadModelSpec forAll(testData) { (reference, expectedPower: Power) => val relevantData = FixedLoadModel.FixedLoadRelevantData - val scales = (0 to 20).map(_ * 0.1) + val scales: LazyList[Double] = + LazyList.iterate(0.0)(_ + 0.1).takeWhile(_ <= 2.0) scales.foreach { scale => val scaledSRated = Kilowatts( From 0d6b21655b7668cbf927c8249322ba8c57864cc1 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 19 Sep 2024 00:02:34 +0200 Subject: [PATCH 24/27] Use forall(testCases) --- .../model/grid/SystemComponentSpec.scala | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala b/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala index 99505d928e..098282e388 100644 --- a/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/grid/SystemComponentSpec.scala @@ -75,7 +75,8 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { val simulationEnd: ZonedDateTime = TimeUtil.withDefaults.toZonedDateTime("2019-01-02T00:00:00Z") - val testCases = Seq( + val testCases = Table( + ("operationStart", "operationEnd", "expectedInterval"), ( Some(TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z")), Some(TimeUtil.withDefaults.toZonedDateTime("2019-01-02T00:00:00Z")), @@ -103,20 +104,24 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { ), ) - testCases.forall { case (operationStart, operationEnd, expected) => - val operationTimeBuilder = setup() - operationStart.foreach(operationTimeBuilder.withStart) - operationEnd.foreach(operationTimeBuilder.withEnd) - val operationTime: OperationTime = operationTimeBuilder.build() - - val interval: OperationInterval = - SystemComponent.determineOperationInterval( - defaultSimulationStart, - simulationEnd, - operationTime, - ) - interval == expected - } shouldBe true + forAll(testCases) { + ( + operationStart: Option[ZonedDateTime], + operationEnd: Option[ZonedDateTime], + expected: OperationInterval, + ) => + val operationTimeBuilder = setup() + operationStart.foreach(operationTimeBuilder.withStart) + operationEnd.foreach(operationTimeBuilder.withEnd) + val operationTime: OperationTime = operationTimeBuilder.build() + val interval: OperationInterval = + SystemComponent.determineOperationInterval( + defaultSimulationStart, + simulationEnd, + operationTime, + ) + interval should be(expected) + } } "reject an operation end that is before the operation start" in { From f73b11f325bb793167059e0001acfb7395dcdb31 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Thu, 19 Sep 2024 10:27:09 +0200 Subject: [PATCH 25/27] Adapted one more test in WecModelSpec Signed-off-by: Sebastian Peter --- .../model/participant/WecModelSpec.scala | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 04efdbec59..82f69d3b0d 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -104,15 +104,22 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "determine Betz coefficient correctly" in { val wecModel = buildWecModel() - val velocities = Seq(2.0, 2.5, 18.0, 27.0, 34.0, 40.0) - val expectedBetzResults = Seq(0.115933516, 0.2010945555, 0.108671106, - 0.032198846, 0.000196644, 0.0) - velocities.zip(expectedBetzResults).foreach { - case (velocity, betzResult) => - val windVel = MetersPerSecond(velocity) - val betzFactor = wecModel.determineBetzCoefficient(windVel) - val expected = Each(betzResult) - betzFactor shouldEqual expected + + val testCases = Table( + ("velocity", "expectedBetzResult"), + (2.0, 0.115933516), + (2.5, 0.2010945555), + (18.0, 0.108671106), + (27.0, 0.032198846), + (34.0, 0.000196644), + (40.0, 0.0), + ) + + forAll(testCases) { case (velocity: Double, expectedBetzResult: Double) => + val windVel = MetersPerSecond(velocity) + val betzFactor = wecModel.determineBetzCoefficient(windVel) + + betzFactor shouldEqual Each(expectedBetzResult) } } From 20ee6e35d2043ad531de371711d73a26630ddbdf Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 19 Sep 2024 14:26:34 +0200 Subject: [PATCH 26/27] fix power flow --- .../simona/agent/participant/ParticipantAgentFundamentals.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala index 0b0ad206e0..984815a846 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -808,6 +808,7 @@ protected trait ParticipantAgentFundamentals[ nextActivation, ) + unstashAll() stay() using stateDataFinal } From f7dc403b198ca38b25f59009fb7dae1f384d3032 Mon Sep 17 00:00:00 2001 From: Johannes Bao Date: Thu, 19 Sep 2024 14:36:00 +0200 Subject: [PATCH 27/27] added changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e5d0b8a71..5faecc0281 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,6 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix activation of Hp when not under control of an EM [#922](https://github.com/ie3-institute/simona/issues/922) - Fix expected secondaryData in baseStateData [#955](https://github.com/ie3-institute/simona/issues/955) - Improve code quality in fixedloadmodelspec and other tests [#919](https://github.com/ie3-institute/simona/issues/919) +- Fix power flow calculation with em agents [#962](https://github.com/ie3-institute/simona/issues/962) ## [3.0.0] - 2023-08-07