diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f6bf5e3f..3758fbeafd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,9 @@ 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) +- Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin [#894](https://github.com/ie3-institute/simona/issues/894) +- 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) @@ -107,6 +110,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix determineState of ThermalHouse [#926](https://github.com/ie3-institute/simona/issues/926) - 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) - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) ## [3.0.0] - 2023-08-07 diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index 9543697f03..373387d8b8 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -165,7 +165,7 @@ package simona-api { interface ExtTriggerResponse class CompletionMessage { - - List newTriggers + - Optional nextActivation } CompletionMessage --|> ExtTriggerResponse 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..b5d9ff3de4 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: ! CompletionMessage(newTriggers) +ExtSimulation -> ExtSimAdapter: ! CompletionMessage(newTick) deactivate ExtSimulation activate ExtSimAdapter -ExtSimAdapter -> Scheduler: ! Completion(newTriggers) +ExtSimAdapter -> Scheduler: ! Completion(newTick) deactivate ExtSimAdapter ExtEvDataService -> EvcsAgent1: ! RegistrationSuccessfulMessage(t1) diff --git a/docs/uml/protocol/InitializationPhase.puml b/docs/uml/protocol/InitializationPhase.puml index a5cd1c48d0..b46e4b3c06 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: ! ScheduleTriggerMessage(\n\tInitializeServiceTrigger(0),\n\tweatherActorRef) -MainController -> GridAgents: create() -MainController -> SimScheduler: ! ScheduleTriggerMessage(\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[...]) -SimScheduler -> GridAgents: ! TriggerWithIdMessage(\n\tInitializeGridAgentTrigger(_),\n\ttriggerId,\n\t_) -GridAgents -> SimScheduler: ! ScheduleTriggerMessage(\n\tInitializeSystemComponentsTrigger(0),\n\tassetAgentRef) -GridAgents --> SimScheduler: ! CompletionMessage(triggerId, ScheduleTriggerMessage[...]) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tIInitializeSystemComponentsTrigger(_),\n\ttriggerId,\n\t_) +SimonaSim -> Listener: create() +SimonaSim -> Scheduler: create() +SimonaSim -> Services: create() +Services -> Scheduler: ! ScheduleActivation(\n\tweatherActorRef, \n\tINIT_SIM_TICK) +SimonaSim -> GridAgents: create() +GridAgents -> Scheduler: ! ScheduleActivation(\n\tgridAgentRef, \n\tINIT_SIM_TICK) +SimonaSim -> Scheduler: ? StartScheduleMessage() +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 --> SimScheduler: ! CompletionMessage(\n\ttriggerId,\n\tScheduleTriggerMessage[\n\t\tActivityStartTrigger(tick)\n\t]) +ParticipantAgents --> Scheduler: ! Completion(\n\tassetAgentRef,\n\ttick) @enduml \ No newline at end of file diff --git a/docs/uml/protocol/ParticipantTriggeredByItself.puml b/docs/uml/protocol/ParticipantTriggeredByItself.puml index 94b5f84985..b476a6e232 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) +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 diff --git a/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml b/docs/uml/protocol/ParticipantTriggeredByPrimaryData.puml index 03874b19bd..c9ee2e21bd 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_) +Scheduler -> PrimaryServiceWorker: ! Activation(\n\tInit_SIM_TICK) PrimaryServiceWorker -> ParticipantAgents: ! ProvisionMessage -PrimaryServiceWorker --> SimScheduler: ! CompletionMessage(triggerId, None) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) -ParticipantAgents --> SimScheduler: ! CompletionMessage(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 bf79a7e891..a3837f60fb 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_) +Scheduler -> Services: ! Activation(\n\tINIT_SIM_TICK) Services -> ParticipantAgents: ! ProvideWeatherMessage(\n\ttick,\n\tweatherData,\n\tnextDataTick) -SimScheduler -> ParticipantAgents: ! TriggerWithIdMessage(\n\tActivityStartTrigger(tick),\n\t_,\n\t_) +Scheduler -> ParticipantAgents: ! Activation(\n\ttick) Services -> ParticipantAgents: ! ProvisionMessage Services -> ParticipantAgents: ! ProvisionMessage -Services --> SimScheduler: ! CompletionMessage(triggerId, None) +Services --> Scheduler: ! Completion(\n\tactor, None) ParticipantAgents -> ParticipantAgents: ! StartCalculationTrigger(tick) -ParticipantAgents --> SimScheduler: ! CompletionMessage(triggerId, None) +ParticipantAgents --> Scheduler: ! Completion(\n\tactor, newTick) @enduml \ No newline at end of file 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 ee2d4941ff..984815a846 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 ) @@ -808,6 +808,7 @@ protected trait ParticipantAgentFundamentals[ nextActivation, ) + unstashAll() stay() using stateDataFinal } @@ -906,7 +907,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/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala index 547a639d08..71e992c4e0 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -199,100 +199,22 @@ final case class ThermalHouse( currentInnerTemperature: Temperature, ambientTemperature: Temperature, ): Temperature = { - val thermalEnergyChange = calcThermalEnergyChange( - calcThermalEnergyGain(thermalPower, duration), - calcThermalEnergyLoss( - currentInnerTemperature, - ambientTemperature, - duration, - ), - ) - calcNewInnerTemperature( + val thermalEnergyGain = thermalPower * duration + + // thermal energy loss due to the deviation between outside and inside temperature + 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 energyChange = thermalEnergyGain - thermalEnergyLoss - /** 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 - } - - /** 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 + // temperature change calculated from energy change(WattHours) and thermal capacity(Joules per Kelvin) + val temperatureChange = energyChange / ethCapa - /** 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, - ) + // return value new inner temperature + currentInnerTemperature + temperatureChange } /** Update the current state of the house @@ -358,7 +280,7 @@ final case class ThermalHouse( ambientTemperature: Temperature, ): Option[ThermalThreshold] = { val artificialDuration = Hours(1d) - val loss = calcThermalEnergyLoss( + val loss = ethLosses.calcThermalEnergyChange( innerTemperature, ambientTemperature, artificialDuration, 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/agent/participant/EvcsAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala index 06c3e797c0..e4e9f25ff1 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) 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..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,22 +104,23 @@ class SystemComponentSpec extends UnitSpec with DefaultTestData { ), ) - for ((operationStart, operationEnd, expected) <- testCases) { - 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) + 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) } } 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..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,38 +104,54 @@ 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) } } "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 wecData = new WecRelevantData( + 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), Some(Pascals(101325d)), ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - val expectedPower = Watts(power) + val expectedPowerInWatts = Watts(expectedPower) - result should be(expectedPower) + result should be(expectedPowerInWatts) } } @@ -170,21 +186,23 @@ 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), + ) - temperatures.zip(expectedPowers).foreach { case (temperature, power) => - val wecData = new WecRelevantData( + forAll(testCases) { (temperature: Double, expectedPower: Double) => + 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..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 @@ -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,10 @@ class FixedLoadModelSpec forAll(testData) { (reference, expectedPower: Power) => val relevantData = FixedLoadModel.FixedLoadRelevantData - var scale = 0.0 - while (scale <= 2) { + val scales: LazyList[Double] = + LazyList.iterate(0.0)(_ + 0.1).takeWhile(_ <= 2.0) + + scales.foreach { scale => val scaledSRated = Kilowatts( loadInput.getsRated .to(PowerSystemUnits.KILOWATT) @@ -142,8 +143,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/ThermalGridWithHouseAndStorageSpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala index cf5d5ec7ef..5d4fe69d88 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)) } } @@ -190,7 +192,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) @@ -371,7 +373,7 @@ class ThermalGridWithHouseAndStorageSpec ( ThermalStorageState( tick, - KilowattHours(50d), + KilowattHours(0d), testGridQDotInfeed, ), Some(StorageEmpty(tick)), @@ -414,7 +416,7 @@ class ThermalGridWithHouseAndStorageSpec ( ThermalStorageState( tick, - KilowattHours(250d), + KilowattHours(20d), testGridQDotInfeed, ), None, @@ -435,7 +437,7 @@ class ThermalGridWithHouseAndStorageSpec val formerStorageState = Some( ThermalStorageState( 0L, - KilowattHours(300d), + KilowattHours(70d), Kilowatts(-50d), ) ) @@ -472,8 +474,8 @@ class ThermalGridWithHouseAndStorageSpec thermalStorage.chargingPower * (-1) ) - houseWarmTick shouldBe 3718L - storageEmptyTick shouldBe 3678L + houseWarmTick shouldBe 3695L + storageEmptyTick shouldBe 3663L case _ => fail("Revision of states failed") } } @@ -566,7 +568,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 1a0e553fdc..bbb804c35f 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), ) ) @@ -126,7 +143,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.") } @@ -159,11 +176,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)) } } @@ -177,7 +194,7 @@ class ThermalGridWithStorageOnlySpec testGridQDotInfeed, ) - nextThreshold shouldBe Some(StorageFull(220800L)) + nextThreshold shouldBe Some(StorageFull(276000L)) updatedState match { case ThermalGridState( @@ -185,7 +202,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") } @@ -200,7 +217,7 @@ class ThermalGridWithStorageOnlySpec Some( ThermalStorageState( 0L, - KilowattHours(430d), + KilowattHours(200d), Kilowatts(0d), ) ) @@ -217,7 +234,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") @@ -241,7 +258,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/ThermalHouseSpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala index 20131046bf..f4a7c97574 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala @@ -42,45 +42,17 @@ class ThermalHouseSpec extends UnitSpec with HpInputTestData { (23d, true, false), ) - testCases.foreach { case (innerTemperature, isTooHigh, isTooLow) => - 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 } } - "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 = - thermalHouseTest.calcThermalEnergyGain(Kilowatts(100), Seconds(3600)) - val thermalEnergyLoss = thermalHouseTest.calcThermalEnergyLoss( - innerTemperature, - Temperature(10, Celsius), - Seconds(3600), - ) - val thermalEnergyChange = thermalHouseTest.calcThermalEnergyChange( - thermalEnergyGain, - thermalEnergyLoss, - ) - val innerTemperatureChange = - thermalHouseTest.calcInnerTemperatureChange(thermalEnergyChange) - val newInnerTemperature = thermalHouseTest.calcNewInnerTemperature( - 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) 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), 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), 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),