From ac50b98064dc53774665b94c7cc1cc1c893ae177 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 4 Jul 2024 13:27:01 +0200 Subject: [PATCH 001/137] Differentiate between different power types --- .../edu/ie3/simona/agent/em/EmAgent.scala | 8 +- .../edu/ie3/simona/agent/em/EmDataCore.scala | 6 +- .../agent/em/FlexCorrespondenceStore.scala | 8 +- .../ParticipantAgentFundamentals.scala | 22 ++--- .../agent/participant/evcs/EvcsAgent.scala | 20 ++--- .../evcs/EvcsAgentFundamentals.scala | 72 +++++++++-------- .../fixedfeedin/FixedFeedInAgent.scala | 12 +-- .../FixedFeedInAgentFundamentals.scala | 42 +++++----- .../simona/agent/participant/hp/HpAgent.scala | 12 +-- .../participant/hp/HpAgentFundamentals.scala | 40 ++++----- .../agent/participant/load/LoadAgent.scala | 18 +++-- .../load/LoadAgentFundamentals.scala | 54 ++++++------- .../simona/agent/participant/pv/PvAgent.scala | 12 +-- .../participant/pv/PvAgentFundamentals.scala | 40 ++++----- .../participant/statedata/BaseStateData.scala | 5 +- .../agent/participant/wec/WecAgent.scala | 12 +-- .../wec/WecAgentFundamentals.scala | 42 +++++----- .../simona/model/participant/BMModel.scala | 16 ++-- .../simona/model/participant/ChpModel.scala | 18 +++-- .../model/participant/FixedFeedInModel.scala | 14 ++-- .../simona/model/participant/HpModel.scala | 24 +++--- .../simona/model/participant/PvModel.scala | 19 ++--- .../model/participant/SystemParticipant.scala | 19 ++--- .../simona/model/participant/WecModel.scala | 15 ++-- .../participant/evcs/EvModelWrapper.scala | 7 +- .../model/participant/evcs/EvcsModel.scala | 21 ++--- .../participant/load/FixedLoadModel.scala | 8 +- .../model/participant/load/LoadModel.scala | 22 ++--- .../load/profile/LoadProfileStore.scala | 5 +- .../load/profile/ProfileLoadModel.scala | 5 +- .../load/random/RandomLoadModel.scala | 9 ++- .../messages/flex/FlexibilityMessage.scala | 6 +- .../services/PrimaryDataMessage.scala | 10 ++- .../util/scala/quantities/ApparentPower.scala | 81 +++++++++++++++++++ .../EvcsAgentModelCalculationSpec.scala | 24 +++--- .../ParticipantAgentFundamentalsSpec.scala | 23 +++--- .../ApparentPowerAndHeatSpec.scala | 13 ++- .../participant/FixedFeedInModelSpec.scala | 11 ++- .../model/participant/HpModelTestData.scala | 3 +- .../model/participant/PvModelSpec.scala | 5 ++ .../participant/evcs/EvcsModelSpec.scala | 2 +- .../MaximumPowerChargingSpec.scala | 2 +- .../participant/load/LoadModelSpec.scala | 31 ++++--- .../load/LoadProfileStoreSpec.scala | 3 +- .../load/ProfileLoadModelSpec.scala | 16 ++-- .../load/RandomLoadModelSpec.scala | 20 +++-- 46 files changed, 525 insertions(+), 352 deletions(-) create mode 100644 src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala b/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala index 06a7bf598a..3bbbef2382 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.em import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.result.system.{EmResult, FlexOptionsResult} -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.statedata.BaseStateData.FlexControlledData import edu.ie3.simona.config.SimonaConfig.EmRuntimeConfig import edu.ie3.simona.event.ResultEvent @@ -394,10 +396,10 @@ object EmAgent { // calc result val result = inactiveCore.getResults .reduceOption { (power1, power2) => - ApparentPower(power1.p + power2.p, power1.q + power2.q) + ComplexPower(power1.p + power2.p, power1.q + power2.q) } .getOrElse( - ApparentPower( + ComplexPower( zeroMW, zeroMVAr, ) diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala index 3b46b176ee..8f6f3df941 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala @@ -7,7 +7,9 @@ package edu.ie3.simona.agent.em import edu.ie3.simona.exceptions.CriticalFailureException -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import EmAgent.Actor import FlexCorrespondenceStore.WithTime import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage._ @@ -162,7 +164,7 @@ object EmDataCore { /** Returns relevant results for all connected agents. */ - def getResults: Iterable[ApparentPower] = + def getResults: Iterable[ComplexPower] = correspondences.store.values.flatMap(_.receivedResult.map(_.get)) } diff --git a/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala b/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala index 5d69a5190a..aa4cca4b47 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala @@ -10,7 +10,9 @@ import edu.ie3.simona.agent.em.FlexCorrespondenceStore.{ FlexCorrespondence, WithTime, } -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.{ IssueFlexControl, ProvideFlexOptions, @@ -88,7 +90,7 @@ final case class FlexCorrespondenceStore( */ def updateResult( modelUuid: UUID, - result: ApparentPower, + result: ComplexPower, tick: Long, ): FlexCorrespondenceStore = updateCorrespondence( @@ -124,7 +126,7 @@ object FlexCorrespondenceStore { final case class FlexCorrespondence( receivedFlexOptions: Option[WithTime[ProvideFlexOptions]] = None, issuedCtrlMsg: Option[WithTime[IssueFlexControl]] = None, - receivedResult: Option[WithTime[ApparentPower]] = None, + receivedResult: Option[WithTime[ComplexPower]] = None, ) /** Wrapper that allows storing a tick with an object 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 e636872833..6ffdd0a106 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -23,8 +23,8 @@ import edu.ie3.simona.agent.participant.ParticipantAgent.StartCalculationTrigger import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals.RelevantResultValues import edu.ie3.simona.agent.participant.data.Data import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, - ApparentPowerAndHeat, + ApparentPower => ComplexPower, + ApparentPowerAndHeat => ComplexPowerAndHeat, EnrichableData, PrimaryDataWithApparentPower, } @@ -1768,7 +1768,7 @@ protected trait ParticipantAgentFundamentals[ ) averageResult.toApparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => stay() using nextStateData replying AssetPowerChangedMessage(p, q) } } @@ -2030,14 +2030,14 @@ object ParticipantAgentFundamentals { * The averaged apparent power */ def averageApparentPower( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ] = None, log: LoggingAdapter, - ): ApparentPower = { + ): ComplexPower = { val p = QuantityUtil.average[Power, Energy]( tickToResults.map { case (tick, pd) => tick -> pd.p @@ -2078,7 +2078,7 @@ object ParticipantAgentFundamentals { zeroMVAr } - ApparentPower(p, q) + ComplexPower(p, q) } /** Determine the average apparent power within the given tick window @@ -2095,20 +2095,20 @@ object ParticipantAgentFundamentals { * The averaged apparent power */ def averageApparentPowerAndHeat( - tickToResults: Map[Long, ApparentPowerAndHeat], + tickToResults: Map[Long, ComplexPowerAndHeat], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ] = None, log: LoggingAdapter, - ): ApparentPowerAndHeat = { + ): ComplexPowerAndHeat = { - val tickToResultsApparentPower: Map[Long, ApparentPower] = + val tickToResultsApparentPower: Map[Long, ComplexPower] = tickToResults.map { case (tick, pd) => ( tick, - ApparentPower(Megawatts(pd.p.toMegawatts), Megavars(pd.q.toMegavars)), + ComplexPower(Megawatts(pd.p.toMegawatts), Megavars(pd.q.toMegavars)), ) } @@ -2136,7 +2136,7 @@ object ParticipantAgentFundamentals { zeroMW } - ApparentPowerAndHeat(apparentPower.p, apparentPower.q, qDot) + ComplexPowerAndHeat(apparentPower.p, apparentPower.q, qDot) } } diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala index b2c428242d..8a675b90b6 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala @@ -8,7 +8,7 @@ package edu.ie3.simona.agent.participant.evcs import edu.ie3.datamodel.models.input.system.EvcsInput import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ApparentPower => ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService @@ -41,7 +41,7 @@ object EvcsAgent { initStateData: ParticipantInitializeStateData[ EvcsInput, EvcsRuntimeConfig, - ApparentPower, + ComplexPower, ], listener: Iterable[ActorRef], ): Props = @@ -63,26 +63,26 @@ class EvcsAgent( initStateData: ParticipantInitializeStateData[ EvcsInput, EvcsRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], EvcsInput, EvcsRuntimeConfig, EvcsModel, ](scheduler, initStateData) with EvcsAgentFundamentals { - override val alternativeResult: ApparentPower = ZERO_POWER + override val alternativeResult: ComplexPower = ZERO_POWER when(Idle) { case Event( EvFreeLotsRequest(tick), modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -94,7 +94,7 @@ class EvcsAgent( case Event( DepartingEvsRequest(tick, departingEvs), modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -119,13 +119,13 @@ class EvcsAgent( * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ], - ): ApparentPower = + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala index 941a86cb10..a92989bd98 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala @@ -15,7 +15,9 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.grid.GridAgentMessages.AssetPowerChangedMessage import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.data.Data.SecondaryData import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorEvMovementsService @@ -68,17 +70,17 @@ import scala.reflect.{ClassTag, classTag} protected trait EvcsAgentFundamentals extends ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], EvcsInput, EvcsRuntimeConfig, EvcsModel, ] { this: EvcsAgent => - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] /** Determines the needed base state data in dependence of the foreseen * simulation mode of the agent. @@ -115,7 +117,7 @@ protected trait EvcsAgentFundamentals outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -136,7 +138,7 @@ protected trait EvcsAgentFundamentals ) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -183,7 +185,7 @@ protected trait EvcsAgentFundamentals override protected def createInitialState( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -197,7 +199,7 @@ protected trait EvcsAgentFundamentals override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -236,7 +238,7 @@ protected trait EvcsAgentFundamentals def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -244,7 +246,7 @@ protected trait EvcsAgentFundamentals data: EvcsRelevantData, lastState: EvcsState, setPower: squants.Power, - ): (EvcsState, ApparentPower, FlexChangeIndicator) = { + ): (EvcsState, ComplexPower, FlexChangeIndicator) = { /* Calculate the power */ val voltage = getAndCheckNodalVoltage(baseStateData, tick) @@ -252,7 +254,7 @@ protected trait EvcsAgentFundamentals setPower, voltage, ) - val result = ApparentPower(setPower, reactivePower) + val result = ComplexPower(setPower, reactivePower) /* Handle the request within the model */ val (updatedState, flexChangeIndicator) = @@ -267,14 +269,14 @@ protected trait EvcsAgentFundamentals override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, ], EvcsState, Dimensionless, - ) => ApparentPower = + ) => ComplexPower = (_, _, _, _) => throw new InvalidRequestException( "Evcs model cannot be run without secondary data." @@ -303,7 +305,7 @@ protected trait EvcsAgentFundamentals */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -311,7 +313,7 @@ protected trait EvcsAgentFundamentals lastModelState: EvcsState, tick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = { + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = { /* extract EV data from secondary data, which should have been requested and received before */ baseStateData.receivedSecondaryDataStore .getOrElse(tick, Map.empty) @@ -344,7 +346,7 @@ protected trait EvcsAgentFundamentals protected def handleFreeLotsRequest( tick: Long, modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -378,13 +380,13 @@ protected trait EvcsAgentFundamentals tick: Long, requestedDepartingEvs: Seq[UUID], baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, ], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -475,12 +477,12 @@ protected trait EvcsAgentFundamentals tick: Long, scheduler: ActorRef, modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, ], - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = { + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = { val relevantData = createCalcRelevantData(modelBaseStateData, tick) @@ -541,12 +543,12 @@ protected trait EvcsAgentFundamentals */ override def determineReply( requestTick: Long, - baseStateData: BaseStateData[ApparentPower], - mostRecentRequest: Option[(Long, ApparentPower)], + baseStateData: BaseStateData[ComplexPower], + mostRecentRequest: Option[(Long, ComplexPower)], nodalVoltage: squants.Dimensionless, updatedVoltageValueStore: ValueStore[squants.Dimensionless], - alternativeResult: ApparentPower, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = { + alternativeResult: ComplexPower, + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = { /* No fast reply possible --> Some calculations have to be made */ mostRecentRequest match { case Some((lastRequestTick, _)) if lastRequestTick > requestTick => @@ -558,7 +560,7 @@ protected trait EvcsAgentFundamentals /* Repetitive request for the same tick, but with different voltage */ baseStateData match { case modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -602,7 +604,7 @@ protected trait EvcsAgentFundamentals val updatedBaseStateData = baseStateData match { case modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -669,15 +671,15 @@ protected trait EvcsAgentFundamentals */ override def handleCalculatedResult( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, ], - result: ApparentPower, + result: ComplexPower, currentTick: Long, ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -704,7 +706,7 @@ protected trait EvcsAgentFundamentals baseStateData.copy( resultValueStore = updatedResultValueStore ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -731,12 +733,12 @@ protected trait EvcsAgentFundamentals lastState: EvcsState, currentTick: Long, modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, ], - ): ValueStore[ApparentPower] = { + ): ValueStore[ComplexPower] = { val voltage = modelBaseStateData.voltageValueStore .last(currentTick) @@ -768,7 +770,7 @@ protected trait EvcsAgentFundamentals ValueStore.updateValueStore( resultValueStore, result.getTime.toTick(modelBaseStateData.startDate), - ApparentPower( + ComplexPower( Megawatts(result.getP.to(MEGAWATT).getValue.doubleValue), Megavars(result.getQ.to(MEGAVAR).getValue.doubleValue), ), @@ -790,7 +792,7 @@ protected trait EvcsAgentFundamentals override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new EvcsResult( dateTime, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala index 9b5b681f90..466ca9d070 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.participant.fixedfeedin import edu.ie3.datamodel.models.input.system.FixedFeedInInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.statedata.ParticipantStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.ParticipantInitializeStateData import edu.ie3.simona.config.SimonaConfig.FixedFeedInRuntimeConfig @@ -23,7 +25,7 @@ object FixedFeedInAgent { initStateData: ParticipantInitializeStateData[ FixedFeedInInput, FixedFeedInRuntimeConfig, - ApparentPower, + ComplexPower, ], listener: Iterable[ActorRef], ): Props = @@ -42,14 +44,14 @@ class FixedFeedInAgent( initStateData: ParticipantInitializeStateData[ FixedFeedInInput, FixedFeedInRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], FixedFeedInInput, FixedFeedInRuntimeConfig, FixedFeedInModel, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index cbaabae42e..788cd8e7c8 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ApparentPower => ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData @@ -63,18 +63,18 @@ import scala.reflect.{ClassTag, classTag} protected trait FixedFeedInAgentFundamentals extends ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], FixedFeedInInput, FixedFeedInRuntimeConfig, FixedFeedInModel, ] { this: FixedFeedInAgent => - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] - override val alternativeResult: ApparentPower = ZERO_POWER + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] + override val alternativeResult: ComplexPower = ZERO_POWER /** Determines the needed base state data in dependence of the foreseen * simulation mode of the agent. @@ -111,7 +111,7 @@ protected trait FixedFeedInAgentFundamentals outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -143,7 +143,7 @@ protected trait FixedFeedInAgentFundamentals ).filterNot(_ == lastTickInSimulation) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -188,7 +188,7 @@ protected trait FixedFeedInAgentFundamentals override protected def createInitialState( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -197,7 +197,7 @@ protected trait FixedFeedInAgentFundamentals override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -223,7 +223,7 @@ protected trait FixedFeedInAgentFundamentals def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -231,7 +231,7 @@ protected trait FixedFeedInAgentFundamentals data: FixedRelevantData.type, lastState: ConstantState.type, setPower: squants.Power, - ): (ConstantState.type, ApparentPower, FlexChangeIndicator) = { + ): (ConstantState.type, ComplexPower, FlexChangeIndicator) = { /* Calculate result */ val voltage = getAndCheckNodalVoltage(baseStateData, tick) @@ -239,7 +239,7 @@ protected trait FixedFeedInAgentFundamentals setPower, voltage, ) - val result = ApparentPower(setPower, reactivePower) + val result = ComplexPower(setPower, reactivePower) /* Handle the request within the model */ val (updatedState, flexChangeIndicator) = @@ -250,17 +250,17 @@ protected trait FixedFeedInAgentFundamentals override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, ], ConstantState.type, Dimensionless, - ) => ApparentPower = ( + ) => ComplexPower = ( currentTick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -305,7 +305,7 @@ protected trait FixedFeedInAgentFundamentals */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, FixedFeedInModel, @@ -313,7 +313,7 @@ protected trait FixedFeedInAgentFundamentals lastModelState: ConstantState.type, currentTick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = throw new InvalidRequestException( "Request to calculate power with secondary data cannot be processed in a fixed feed in agent." ) @@ -332,13 +332,13 @@ protected trait FixedFeedInAgentFundamentals * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ] = None, - ): ApparentPower = + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, @@ -361,7 +361,7 @@ protected trait FixedFeedInAgentFundamentals override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new FixedFeedInResult( dateTime, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala index 0be0c2877b..6bec55f80a 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.participant.hp import edu.ie3.datamodel.models.input.system.HpInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHeat +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPowerAndHeat => ComplexPowerAndHeat +} import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.ParticipantStateData @@ -24,7 +26,7 @@ object HpAgent { initStateData: ParticipantInitializeStateData[ HpInput, HpRuntimeConfig, - ApparentPowerAndHeat, + ComplexPowerAndHeat, ], listener: Iterable[ActorRef], ): Props = @@ -46,15 +48,15 @@ class HpAgent( initStateData: ParticipantInitializeStateData[ HpInput, HpRuntimeConfig, - ApparentPowerAndHeat, + ComplexPowerAndHeat, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, ParticipantStateData[ - ApparentPowerAndHeat + ComplexPowerAndHeat ], HpInput, HpRuntimeConfig, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index a428cd3cab..f61929c441 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -15,7 +15,9 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHeat +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPowerAndHeat => ComplexPowerAndHeat +} import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.hp.HpAgent.neededServices import edu.ie3.simona.agent.participant.statedata.BaseStateData.{ @@ -64,18 +66,18 @@ import scala.reflect.{ClassTag, classTag} trait HpAgentFundamentals extends ParticipantAgentFundamentals[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, - ParticipantStateData[ApparentPowerAndHeat], + ParticipantStateData[ComplexPowerAndHeat], HpInput, HpRuntimeConfig, HpModel, ] { this: HpAgent => - override protected val pdClassTag: ClassTag[ApparentPowerAndHeat] = - classTag[ApparentPowerAndHeat] - override val alternativeResult: ApparentPowerAndHeat = ApparentPowerAndHeat( + override protected val pdClassTag: ClassTag[ComplexPowerAndHeat] = + classTag[ComplexPowerAndHeat] + override val alternativeResult: ComplexPowerAndHeat = ComplexPowerAndHeat( zeroMW, zeroMVAr, zeroMW, @@ -88,14 +90,14 @@ trait HpAgentFundamentals override val calculateModelPowerFunc: ( Long, BaseStateData.ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, ], HpState, Dimensionless, - ) => ApparentPowerAndHeat = + ) => ComplexPowerAndHeat = (_, _, _, _) => throw new InvalidRequestException( "Heat pump model cannot be run without secondary data." @@ -103,7 +105,7 @@ trait HpAgentFundamentals override protected def createInitialState( baseStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, @@ -139,7 +141,7 @@ trait HpAgentFundamentals def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, @@ -147,7 +149,7 @@ trait HpAgentFundamentals data: HpRelevantData, lastState: HpState, setPower: squants.Power, - ): (HpState, ApparentPowerAndHeat, FlexChangeIndicator) = { + ): (HpState, ComplexPowerAndHeat, FlexChangeIndicator) = { /* Determine needed information */ val voltage = getAndCheckNodalVoltage(baseStateData, tick) @@ -210,7 +212,7 @@ trait HpAgentFundamentals */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, @@ -218,7 +220,7 @@ trait HpAgentFundamentals lastModelState: HpState, currentTick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPowerAndHeat]] = { + ): FSM.State[AgentState, ParticipantStateData[ComplexPowerAndHeat]] = { /* Determine needed information */ val voltage = @@ -300,7 +302,7 @@ trait HpAgentFundamentals outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): BaseStateData.ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, @@ -329,7 +331,7 @@ trait HpAgentFundamentals ) ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, @@ -368,7 +370,7 @@ trait HpAgentFundamentals override protected def createCalcRelevantData( baseStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpRelevantData, HpState, HpModel, @@ -449,13 +451,13 @@ trait HpAgentFundamentals * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPowerAndHeat], + tickToResults: Map[Long, ComplexPowerAndHeat], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ], - ): ApparentPowerAndHeat = + ): ComplexPowerAndHeat = ParticipantAgentFundamentals.averageApparentPowerAndHeat( tickToResults, windowStart, @@ -478,7 +480,7 @@ trait HpAgentFundamentals override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPowerAndHeat, + result: ComplexPowerAndHeat, ): SystemParticipantResult = new HpResult( dateTime, uuid, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala index 338547efbc..05c97cbecf 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.participant.load import edu.ie3.datamodel.models.input.system.LoadInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.load.LoadAgentFundamentals.{ FixedLoadAgentFundamentals, ProfileLoadAgentFundamentals, @@ -36,7 +38,7 @@ object LoadAgent { initStateData: ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ], listener: Iterable[ActorRef], ): Props = @@ -58,7 +60,7 @@ object LoadAgent { initStateData: ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends LoadAgent[ @@ -72,7 +74,7 @@ object LoadAgent { initStateData: ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends LoadAgent[ @@ -86,7 +88,7 @@ object LoadAgent { initStateData: ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends LoadAgent[ @@ -108,14 +110,14 @@ abstract class LoadAgent[LD <: LoadRelevantData, LM <: LoadModel[LD]]( initStateData: ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, LD, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], LoadInput, LoadRuntimeConfig, LM, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 79df65997c..05dad7dd4f 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ApparentPower => ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData @@ -74,18 +74,18 @@ import scala.reflect.{ClassTag, classTag} protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ LD ]] extends ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, LD, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], LoadInput, LoadRuntimeConfig, LM, ] { this: LoadAgent[LD, LM] => - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] - override val alternativeResult: ApparentPower = ZERO_POWER + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] + override val alternativeResult: ComplexPower = ZERO_POWER /** Determines the needed base state data in dependence of the foreseen * simulation mode of the agent. @@ -122,7 +122,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, LD, ConstantState.type, LM, @@ -172,7 +172,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ SortedSet.empty[Long] } - ParticipantModelBaseStateData[ApparentPower, LD, ConstantState.type, LM]( + ParticipantModelBaseStateData[ComplexPower, LD, ConstantState.type, LM]( simulationStartDate, simulationEndDate, model, @@ -229,7 +229,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ override protected def createInitialState( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, LD, ConstantState.type, LM, @@ -253,7 +253,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, LD, ConstantState.type, LM, @@ -261,7 +261,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ data: LD, lastState: ConstantState.type, setPower: squants.Power, - ): (ConstantState.type, ApparentPower, FlexChangeIndicator) = { + ): (ConstantState.type, ComplexPower, FlexChangeIndicator) = { /* Calculate result */ val voltage = getAndCheckNodalVoltage(baseStateData, tick) @@ -269,7 +269,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ setPower, voltage, ) - val result = ApparentPower(setPower, reactivePower) + val result = ComplexPower(setPower, reactivePower) /* Handle the request within the model */ val (updatedState, flexChangeIndicator) = @@ -300,7 +300,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, LD, ConstantState.type, LM, @@ -308,7 +308,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ lastModelState: ConstantState.type, currentTick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = throw new InconsistentStateException( s"Load model is not able to calculate power with secondary data." ) @@ -327,13 +327,13 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ] = None, - ): ApparentPower = + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, @@ -356,7 +356,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new LoadResult( dateTime, @@ -397,7 +397,7 @@ object LoadAgentFundamentals { override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedLoadRelevantData.type, ConstantState.type, FixedLoadModel, @@ -413,17 +413,17 @@ object LoadAgentFundamentals { override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedLoadRelevantData.type, ConstantState.type, FixedLoadModel, ], ConstantState.type, Dimensionless, - ) => ApparentPower = ( + ) => ComplexPower = ( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedLoadRelevantData.type, ConstantState.type, FixedLoadModel, @@ -461,7 +461,7 @@ object LoadAgentFundamentals { override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, ProfileRelevantData, ConstantState.type, ProfileLoadModel, @@ -479,14 +479,14 @@ object LoadAgentFundamentals { override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, ProfileRelevantData, ConstantState.type, ProfileLoadModel, ], ConstantState.type, Dimensionless, - ) => ApparentPower = (tick, baseStateData, _, voltage) => { + ) => ComplexPower = (tick, baseStateData, _, voltage) => { val profileRelevantData = createCalcRelevantData(baseStateData, tick) @@ -521,7 +521,7 @@ object LoadAgentFundamentals { override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, RandomRelevantData, ConstantState.type, RandomLoadModel, @@ -539,14 +539,14 @@ object LoadAgentFundamentals { override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, RandomRelevantData, ConstantState.type, RandomLoadModel, ], ConstantState.type, Dimensionless, - ) => ApparentPower = (tick, baseStateData, _, voltage) => { + ) => ComplexPower = (tick, baseStateData, _, voltage) => { val profileRelevantData = createCalcRelevantData(baseStateData, tick) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala index bf6f5db3b7..325159f08e 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.participant.pv import edu.ie3.datamodel.models.input.system.PvInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.ParticipantStateData @@ -25,7 +27,7 @@ object PvAgent { initStateData: ParticipantInitializeStateData[ PvInput, PvRuntimeConfig, - ApparentPower, + ComplexPower, ], listener: Iterable[ActorRef], ): Props = @@ -54,14 +56,14 @@ class PvAgent( initStateData: ParticipantInitializeStateData[ PvInput, PvRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], PvInput, PvRuntimeConfig, PvModel, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index a60fa87b63..0e3fee0857 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ApparentPower => ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData @@ -66,18 +66,18 @@ import scala.reflect.{ClassTag, classTag} protected trait PvAgentFundamentals extends ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], PvInput, PvRuntimeConfig, PvModel, ] { this: PvAgent => - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] - override val alternativeResult: ApparentPower = ZERO_POWER + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] + override val alternativeResult: ComplexPower = ZERO_POWER /** Determines the needed base state data in dependence of the foreseen * simulation mode of the agent. @@ -114,7 +114,7 @@ protected trait PvAgentFundamentals outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, @@ -135,7 +135,7 @@ protected trait PvAgentFundamentals ) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, @@ -180,7 +180,7 @@ protected trait PvAgentFundamentals override protected def createInitialState( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, @@ -190,7 +190,7 @@ protected trait PvAgentFundamentals override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, @@ -262,7 +262,7 @@ protected trait PvAgentFundamentals override def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, @@ -270,7 +270,7 @@ protected trait PvAgentFundamentals data: PvRelevantData, lastState: ConstantState.type, setPower: squants.Power, - ): (ConstantState.type, ApparentPower, FlexChangeIndicator) = { + ): (ConstantState.type, ComplexPower, FlexChangeIndicator) = { /* Calculate result */ val voltage = getAndCheckNodalVoltage(baseStateData, tick) @@ -278,7 +278,7 @@ protected trait PvAgentFundamentals setPower, voltage, ) - val result = ApparentPower(setPower, reactivePower) + val result = ComplexPower(setPower, reactivePower) /* Handle the request within the model */ val (updatedState, flexChangeIndicator) = @@ -293,14 +293,14 @@ protected trait PvAgentFundamentals override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, ], ConstantState.type, Dimensionless, - ) => ApparentPower = + ) => ComplexPower = (_, _, _, _) => throw new InvalidRequestException( "Pv model cannot be run without secondary data." @@ -329,7 +329,7 @@ protected trait PvAgentFundamentals */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, PvRelevantData, ConstantState.type, PvModel, @@ -337,7 +337,7 @@ protected trait PvAgentFundamentals lastModelState: ConstantState.type, currentTick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = { + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = { val voltage = getAndCheckNodalVoltage(baseStateData, currentTick) @@ -376,13 +376,13 @@ protected trait PvAgentFundamentals * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ] = None, - ): ApparentPower = + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, @@ -405,7 +405,7 @@ protected trait PvAgentFundamentals override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new PvResult( dateTime, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala index 96758a2d16..e1a8285cf8 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala @@ -68,8 +68,9 @@ trait BaseStateData[+PD <: PrimaryDataWithApparentPower[PD]] val resultValueStore: ValueStore[PD] /** A store, holding information of the lastly requested and provided results. - * The request from the grid always targets at [[ApparentPower]], but for the - * sake of traceability, the whole averaged result ist stored + * The request from the grid always targets at + * [[edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower]], + * but for the sake of traceability, the whole averaged result ist stored */ val requestValueStore: ValueStore[PD] diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala index 957d48a28f..0466b7765d 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.participant.wec import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.ParticipantStateData @@ -25,7 +27,7 @@ object WecAgent { initStateData: ParticipantInitializeStateData[ WecInput, WecRuntimeConfig, - ApparentPower, + ComplexPower, ], listener: Iterable[ActorRef], ): Props = @@ -54,14 +56,14 @@ class WecAgent( initStateData: ParticipantInitializeStateData[ WecInput, WecRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], WecInput, WecRuntimeConfig, WecModel, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala index 955131bafc..f48a01c92b 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent._ import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ApparentPower => ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData @@ -61,18 +61,18 @@ import scala.reflect.{ClassTag, classTag} protected trait WecAgentFundamentals extends ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], WecInput, WecRuntimeConfig, WecModel, ] { this: WecAgent => - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] - override val alternativeResult: ApparentPower = ZERO_POWER + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] + override val alternativeResult: ComplexPower = ZERO_POWER /** Determines the needed base state data in dependence of the foreseen * simulation mode of the agent. @@ -109,7 +109,7 @@ protected trait WecAgentFundamentals outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -130,7 +130,7 @@ protected trait WecAgentFundamentals ) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -175,7 +175,7 @@ protected trait WecAgentFundamentals override protected def createInitialState( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -185,7 +185,7 @@ protected trait WecAgentFundamentals override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -238,7 +238,7 @@ protected trait WecAgentFundamentals def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -246,7 +246,7 @@ protected trait WecAgentFundamentals data: WecRelevantData, lastState: ConstantState.type, setPower: squants.Power, - ): (ConstantState.type, ApparentPower, FlexChangeIndicator) = { + ): (ConstantState.type, ComplexPower, FlexChangeIndicator) = { /* Calculate result */ val voltage = getAndCheckNodalVoltage(baseStateData, tick) @@ -254,7 +254,7 @@ protected trait WecAgentFundamentals setPower, voltage, ) - val result = ApparentPower(setPower, reactivePower) + val result = ComplexPower(setPower, reactivePower) /* Handle the request within the model */ val (updatedState, flexChangeIndicator) = @@ -269,18 +269,18 @@ protected trait WecAgentFundamentals override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, ], ConstantState.type, Dimensionless, - ) => ApparentPower = + ) => ComplexPower = ( _: Long, _: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -315,7 +315,7 @@ protected trait WecAgentFundamentals */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -323,7 +323,7 @@ protected trait WecAgentFundamentals lastModelState: ConstantState.type, currentTick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = { + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = { val voltage = getAndCheckNodalVoltage(baseStateData, currentTick) @@ -362,13 +362,13 @@ protected trait WecAgentFundamentals * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ] = None, - ): ApparentPower = + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, @@ -391,7 +391,7 @@ protected trait WecAgentFundamentals override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new WecResult( dateTime, diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index 418af563d5..ad61d74654 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -6,7 +6,9 @@ package edu.ie3.simona.model.participant -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.participant.BMModel.BMCalcRelevantData import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.control.QControl @@ -14,7 +16,7 @@ import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptio import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.DefaultQuantities._ -import edu.ie3.util.scala.quantities.EnergyPrice +import edu.ie3.util.scala.quantities.{ApparentPower, EnergyPrice} import squants.energy.Megawatts import squants.{Dimensionless, Money, Power, Temperature} @@ -29,7 +31,7 @@ final case class BMModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhi: Double, private val node: String, private val isCostControlled: Boolean, @@ -38,7 +40,7 @@ final case class BMModel( private val loadGradient: Double, ) extends SystemParticipant[ BMCalcRelevantData, - ApparentPower, + ComplexPower, ConstantState.type, ]( uuid, @@ -59,7 +61,7 @@ final case class BMModel( voltage: Dimensionless, modelState: ConstantState.type, data: BMCalcRelevantData, - ): ApparentPower = { + ): ComplexPower = { val result = super.calculatePower(tick, voltage, modelState, data) _lastPower = Some(result.p) @@ -198,7 +200,7 @@ final case class BMModel( sRated * cosPhi * (-1) else sRated * usage * eff * cosPhi * (-1) - } + }.toPower /** Applies the load gradient to the electrical output * @param pEl @@ -212,7 +214,7 @@ final case class BMModel( _lastPower match { case None => pEl case Some(lastPowerVal) => - val pElDeltaMaxAbs = sRated * cosPhi * loadGradient + val pElDeltaMaxAbs = sRated.toPower * cosPhi * loadGradient pEl - lastPowerVal match { case pElDelta if pElDelta > pElDeltaMaxAbs => diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 5af1b68236..8ce0245c4c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -7,7 +7,9 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.ChpInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ChpModel._ import edu.ie3.simona.model.participant.ModelState.ConstantState @@ -17,8 +19,12 @@ import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptio import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.DefaultQuantities import edu.ie3.util.scala.quantities.DefaultQuantities._ +import edu.ie3.util.scala.quantities.{ + ApparentPower, + DefaultQuantities, + Kilovoltamperes, +} import squants.energy.Kilowatts import squants.{Energy, Power, Seconds, Time} @@ -50,11 +56,11 @@ final case class ChpModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, pThermal: Power, storage: ThermalStorage with MutableStorage, -) extends SystemParticipant[ChpRelevantData, ApparentPower, ConstantState.type]( +) extends SystemParticipant[ChpRelevantData, ComplexPower, ConstantState.type]( uuid, id, operationInterval, @@ -64,7 +70,7 @@ final case class ChpModel( ) with ApparentPowerParticipant[ChpRelevantData, ConstantState.type] { - val pRated: Power = sRated * cosPhiRated + val pRated: Power = sRated.toPower * cosPhiRated /** As this is a state-full model (with respect to the current operation * condition and its thermal storage), the power calculation operates on the @@ -387,7 +393,7 @@ object ChpModel { scaledInput.getId, operationInterval, qControl, - Kilowatts( + Kilovoltamperes( scaledInput.getType.getsRated .to(PowerSystemUnits.KILOWATT) .getValue diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index c50b2f6211..6b7b0834b8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.model.participant import com.typesafe.scalalogging.LazyLogging import edu.ie3.datamodel.models.input.system.FixedFeedInInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.config.SimonaConfig import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.CalcRelevantData.FixedRelevantData @@ -18,8 +20,8 @@ import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptio import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants.Power -import squants.energy.Kilowatts import java.time.ZonedDateTime import java.util.UUID @@ -44,11 +46,11 @@ final case class FixedFeedInModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, ) extends SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ]( uuid, @@ -72,7 +74,7 @@ final case class FixedFeedInModel( modelState: ConstantState.type, data: FixedRelevantData.type = FixedRelevantData, ): Power = - sRated * (-1) * cosPhiRated + sRated.toPower * (-1) * cosPhiRated override def determineFlexOptions( data: FixedRelevantData.type, @@ -115,7 +117,7 @@ object FixedFeedInModel extends LazyLogging { scaledInput.getId, operationInterval, QControl.apply(scaledInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( scaledInput.getsRated .to(PowerSystemUnits.KILOWATT) .getValue diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 7af9279611..47341eb919 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -7,7 +7,9 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.HpInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHeat +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPowerAndHeat => ComplexPowerAndHeat +} import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.HpModel.{HpRelevantData, HpState} import edu.ie3.simona.model.participant.control.QControl @@ -17,8 +19,12 @@ import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptio import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.DefaultQuantities import edu.ie3.util.scala.quantities.DefaultQuantities._ +import edu.ie3.util.scala.quantities.{ + ApparentPower, + DefaultQuantities, + Kilovoltamperes, +} import squants.energy.Kilowatts import squants.{Power, Temperature} @@ -53,13 +59,13 @@ final case class HpModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, pThermal: Power, thermalGrid: ThermalGrid, ) extends SystemParticipant[ HpRelevantData, - ApparentPowerAndHeat, + ComplexPowerAndHeat, HpState, ]( uuid, @@ -72,7 +78,7 @@ final case class HpModel( with ApparentPowerAndHeatParticipant[HpRelevantData, HpState] { private val pRated: Power = - sRated * cosPhiRated + sRated.toPower * cosPhiRated /** As this is a state-full model (with respect to the current operation * condition and inner temperature), the power calculation operates on the @@ -223,7 +229,7 @@ final case class HpModel( updatedState.activePower val upperBoundary = if (canOperate) - sRated * cosPhiRated + sRated.toPower * cosPhiRated else zeroKW @@ -258,7 +264,7 @@ final case class HpModel( setPower: Power, ): (HpState, FlexChangeIndicator) = { /* If the setpoint value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */ - val turnOn = setPower > (sRated * cosPhiRated * 0.5) + val turnOn = setPower > (sRated.toPower * cosPhiRated * 0.5) val updatedState = calcState(lastState, data, turnOn) ( @@ -299,7 +305,7 @@ object HpModel { scaledInput.getId, operationInterval, qControl, - Kilowatts( + Kilovoltamperes( scaledInput.getType.getsRated .to(PowerSystemUnits.KILOWATT) .getValue @@ -402,7 +408,7 @@ object HpModel { scaledInput.getId, operationInterval, qControl, - Kilowatts( + Kilovoltamperes( scaledInput.getType.getsRated .to(PowerSystemUnits.KILOWATT) .getValue diff --git a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala index 78508c91d5..bc226040c0 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala @@ -7,7 +7,9 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.PvInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.PvModel.PvRelevantData @@ -18,7 +20,6 @@ import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities._ import squants._ -import squants.energy.Kilowatts import squants.space.{Degrees, SquareMeters} import squants.time.Minutes import tech.units.indriya.unit.Units._ @@ -33,7 +34,7 @@ final case class PvModel private ( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, private val lat: Angle, private val lon: Angle, @@ -42,7 +43,7 @@ final case class PvModel private ( private val alphaE: Angle, private val gammaE: Angle, private val moduleSurface: Area = SquareMeters(1d), -) extends SystemParticipant[PvRelevantData, ApparentPower, ConstantState.type]( +) extends SystemParticipant[PvRelevantData, ComplexPower, ConstantState.type]( uuid, id, operationInterval, @@ -55,15 +56,15 @@ final case class PvModel private ( /** Override sMax as the power output of a pv unit could become easily up to * 10% higher than the sRated value found in the technical sheets */ - override val sMax: Power = sRated * 1.1 + override val sMax: ApparentPower = sRated * 1.1 /** Permissible maximum active power feed in (therefore negative) */ - protected val pMax: Power = sMax * cosPhiRated * -1d + protected val pMax: Power = sMax.toPower * cosPhiRated * -1d /** Reference yield at standard testing conditions (STC) */ private val yieldSTC = WattsPerSquareMeter(1000d) - private val activationThreshold = sRated * cosPhiRated * 0.001 * -1d + private val activationThreshold = sRated.toPower * cosPhiRated * 0.001 * -1d /** Calculate the active power behaviour of the model * @@ -691,7 +692,7 @@ final case class PvModel private ( eTotalInWhPerSM * moduleSurface.toSquareMeters * etaConv.toEach * (genCorr * tempCorr) /* Calculate the foreseen active power output without boundary condition adaptions */ - val proposal = sRated * (-1) * ( + val proposal = sRated.toPower * (-1) * ( actYield / irradiationSTC ) * cosPhiRated @@ -771,7 +772,7 @@ object PvModel { scaledInput.getId, operationInterval, QControl(scaledInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( scaledInput.getsRated .to(PowerSystemUnits.KILOWATT) .getValue diff --git a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala index 44c70539d7..84f09f5d0f 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala @@ -7,7 +7,7 @@ package edu.ie3.simona.model.participant import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ApparentPower => ComplexPower, PrimaryDataWithApparentPower, } import edu.ie3.simona.model.SystemComponent @@ -16,6 +16,7 @@ import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptio import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.DefaultQuantities._ import edu.ie3.util.scala.quantities.{ + ApparentPower, DefaultQuantities, Megavars, ReactivePower, @@ -55,7 +56,7 @@ abstract class SystemParticipant[ id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, ) extends SystemComponent(uuid, id, operationInterval) { @@ -64,7 +65,7 @@ abstract class SystemParticipant[ * overwritten if the system participant's apparent power can be higher than * sRated. */ - protected val sMax: Power = sRated + protected val sMax: ApparentPower = sRated /** Calculate the power behaviour based on the given data. * @@ -102,17 +103,17 @@ abstract class SystemParticipant[ voltage: Dimensionless, modelState: MS, data: CD, - ): ApparentPower = { + ): ComplexPower = { if (isInOperation(tick)) { val activePower = calculateActivePower(modelState, data) val reactivePower = calculateReactivePower(activePower, voltage) - ApparentPower( + ComplexPower( activePower, reactivePower, ) } else { - ApparentPower( + ComplexPower( DefaultQuantities.zeroMW, DefaultQuantities.zeroMVAr, ) @@ -173,7 +174,7 @@ abstract class SystemParticipant[ nodalVoltage: Dimensionless ): Power => ReactivePower = qControl.activeToReactivePowerFunc( - sRated, + sRated.toPower, cosPhiRated, nodalVoltage, ) @@ -221,7 +222,7 @@ abstract class SystemParticipant[ ) // tolerance for double inaccuracies - val sMaxWithTolerance = sMax * 1.00001d + val sMaxWithTolerance = sMax.toPower * 1.00001d if (apparentPower > sMaxWithTolerance) { logger.debug( @@ -232,7 +233,7 @@ abstract class SystemParticipant[ s"in correspondence to the existing active power $activePower." ) - val powerSquaredDifference = Math.pow(sMax.toMegawatts, 2) - + val powerSquaredDifference = Math.pow(sMax.toPower.toMegawatts, 2) - Math.pow(activePower.toMegawatts, 2) if (powerSquaredDifference < 0) { diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index f2f34ac771..3d8de4a1cb 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.WecModel.{ @@ -23,8 +25,9 @@ import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMin import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.DefaultQuantities._ +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants._ -import squants.energy.{Kilowatts, Watts} +import squants.energy.Watts import squants.mass.{Kilograms, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pressure} import squants.space.SquareMeters @@ -60,11 +63,11 @@ final case class WecModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, rotorArea: Area, betzCurve: WecCharacteristic, -) extends SystemParticipant[WecRelevantData, ApparentPower, ConstantState.type]( +) extends SystemParticipant[WecRelevantData, ComplexPower, ConstantState.type]( uuid, id, operationInterval, @@ -95,7 +98,7 @@ final case class WecModel( wecData: WecRelevantData, ): Power = { val activePower = determinePower(wecData) - val pMax = sMax * cosPhiRated + val pMax = sMax.toPower * cosPhiRated (if (activePower > pMax) { logger.warn( @@ -274,7 +277,7 @@ object WecModel { scaledInput.getId, operationInterval, QControl(scaledInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( scaledInput.getType.getsRated.to(KILOWATT).getValue.doubleValue ), scaledInput.getType.getCosPhiRated, diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala index f928af2fcf..b5d0d7ec94 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala @@ -9,6 +9,7 @@ package edu.ie3.simona.model.participant.evcs import edu.ie3.simona.api.data.ev.model.EvModel import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.quantities.QuantityUtils.RichQuantityDouble +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants.energy.{KilowattHours, Kilowatts} import java.util.UUID @@ -32,8 +33,10 @@ final case class EvModelWrapper( def uuid: UUID = original.getUuid def id: String = original.getId - lazy val sRatedAc: squants.Power = - Kilowatts(original.getSRatedAC.to(KILOWATT).getValue.doubleValue) + lazy val sRatedAc: ApparentPower = + Kilovoltamperes( + original.getSRatedAC.to(KILOVOLTAMPERE).getValue.doubleValue + ) lazy val sRatedDc: squants.Power = Kilowatts(original.getSRatedDC.to(KILOWATT).getValue.doubleValue) lazy val eStorage: squants.Energy = KilowattHours( diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index b00ec5e5e3..ad16931c9f 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -11,7 +11,9 @@ import edu.ie3.datamodel.models.ElectricCurrentType import edu.ie3.datamodel.models.input.system.EvcsInput import edu.ie3.datamodel.models.input.system.`type`.evcslocation.EvcsLocationType import edu.ie3.datamodel.models.result.system.{EvResult, EvcsResult} -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.model.participant.evcs.EvcsModel._ @@ -19,7 +21,6 @@ import edu.ie3.simona.model.participant.evcs.uncontrolled.{ ConstantPowerCharging, MaximumPowerCharging, } -import edu.ie3.util.scala.quantities.DefaultQuantities._ import edu.ie3.simona.model.participant.{ CalcRelevantData, FlexChangeIndicator, @@ -32,7 +33,9 @@ import edu.ie3.simona.util.TickUtil.TickLong import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.quantities.QuantityUtils.RichQuantityDouble import edu.ie3.util.scala.OperationInterval -import squants.energy.{KilowattHours, Kilowatts} +import edu.ie3.util.scala.quantities.DefaultQuantities._ +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} +import squants.energy.Kilowatts import squants.time.Seconds import squants.{Dimensionless, Energy, Power} import tech.units.indriya.unit.Units.PERCENT @@ -73,7 +76,7 @@ final case class EvcsModel( operationInterval: OperationInterval, simulationStartDate: ZonedDateTime, qControl: QControl, - sRated: Power, + sRated: ApparentPower, currentType: ElectricCurrentType, cosPhiRated: Double, chargingPoints: Int, @@ -81,7 +84,7 @@ final case class EvcsModel( vehicle2grid: Boolean, strategy: ChargingStrategy.Value, lowestEvSoc: Double, -) extends SystemParticipant[EvcsRelevantData, ApparentPower, EvcsState]( +) extends SystemParticipant[EvcsRelevantData, ComplexPower, EvcsState]( uuid, id, operationInterval, @@ -500,12 +503,12 @@ final case class EvcsModel( ): Power = { val evPower = currentType match { case ElectricCurrentType.AC => - ev.sRatedAc + ev.sRatedAc.toPower case ElectricCurrentType.DC => ev.sRatedDc } /* Limit the charging power to the minimum of ev's and evcs' permissible power */ - evPower.min(sRated) + evPower.min(sRated.toPower) } override def calculatePower( @@ -513,7 +516,7 @@ final case class EvcsModel( voltage: Dimensionless, modelState: EvcsState, data: EvcsRelevantData, - ): ApparentPower = + ): ComplexPower = throw new NotImplementedError("Use calculatePowerAndEvSoc() instead.") override protected def calculateActivePower( @@ -1062,7 +1065,7 @@ object EvcsModel { operationInterval, simulationStartDate, QControl(scaledInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( scaledInput.getType.getsRated.to(KILOWATT).getValue.doubleValue ), scaledInput.getType.getElectricCurrentType, diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala index 6b0b8a97ef..321c192849 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala @@ -17,8 +17,8 @@ import edu.ie3.simona.model.participant.load.LoadReference.{ } import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants.Power -import squants.energy.Kilowatts import squants.time.Days import java.util.UUID @@ -45,7 +45,7 @@ final case class FixedLoadModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, reference: LoadReference, ) extends LoadModel[FixedLoadRelevantData.type]( @@ -95,9 +95,9 @@ object FixedLoadModel { scaledInput.getId, operationInterval, QControl(scaledInput.getqCharacteristics()), - Kilowatts( + Kilovoltamperes( scaledInput.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala index 183f1dc5ae..1c94aa3020 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.model.participant.load import com.typesafe.scalalogging.LazyLogging import edu.ie3.datamodel.models.input.system.LoadInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.participant.CalcRelevantData.LoadRelevantData import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.control.QControl @@ -21,7 +23,7 @@ import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptio import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval -import squants.energy.Kilowatts +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants.{Energy, Power} import java.util.UUID @@ -36,9 +38,9 @@ abstract class LoadModel[D <: LoadRelevantData]( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, -) extends SystemParticipant[D, ApparentPower, ConstantState.type]( +) extends SystemParticipant[D, ComplexPower, ConstantState.type]( uuid, id, operationInterval, @@ -89,14 +91,14 @@ object LoadModel extends LazyLogging { inputModel: LoadInput, activePower: Power, safetyFactor: Double = 1d, - ): Power = { - val sRated = Kilowatts( + ): ApparentPower = { + val sRated = Kilovoltamperes( inputModel.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ) - val pRated = sRated * inputModel.getCosPhiRated + val pRated = sRated.toPower * inputModel.getCosPhiRated val referenceScalingFactor = activePower / pRated sRated * referenceScalingFactor * safetyFactor } @@ -129,10 +131,10 @@ object LoadModel extends LazyLogging { def scaleSRatedEnergy( inputModel: LoadInput, energyConsumption: Energy, - profileMaxPower: Power, + profileMaxPower: ApparentPower, profileEnergyScaling: Energy, safetyFactor: Double = 1d, - ): Power = { + ): ApparentPower = { (profileMaxPower / inputModel.getCosPhiRated) * ( energyConsumption / profileEnergyScaling ) * safetyFactor diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index f1e7d54f62..0104bd3875 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -17,6 +17,7 @@ import edu.ie3.simona.model.participant.load.profile.LoadProfileStore.{ initializeTypeDayValues, } import edu.ie3.simona.model.participant.load.{DayType, profile} +import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import org.apache.commons.csv.CSVFormat import squants.energy.{KilowattHours, Watts} @@ -88,10 +89,10 @@ class LoadProfileStore private (val reader: Reader) { */ def maxPower( loadProfile: StandardLoadProfile - ): squants.Power = { + ): ApparentPower = { maxParamMap.get(loadProfile) match { case Some(value) => - Watts(value) + Voltamperes(value) case None => throw new RuntimeException( "Max value for ConsumerType " + loadProfile.toString + " not found" diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala index 5e919a0064..5419436ebe 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala @@ -15,6 +15,7 @@ import edu.ie3.simona.model.participant.load.LoadReference._ import edu.ie3.simona.model.participant.load.profile.ProfileLoadModel.ProfileRelevantData import edu.ie3.simona.model.participant.load.{LoadModel, LoadReference} import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.ApparentPower import squants.Power import java.time.ZonedDateTime @@ -44,7 +45,7 @@ final case class ProfileLoadModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, loadProfile: StandardLoadProfile, reference: LoadReference, @@ -91,7 +92,7 @@ final case class ProfileLoadModel( reference match { case ActivePower(activePower) => /* scale the reference active power based on the profiles averagePower/maxPower ratio */ - val referenceScalingFactor = averagePower / profileMaxPower + val referenceScalingFactor = averagePower / profileMaxPower.toPower activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles average power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index a09e9bc8ff..e3ff1ee9e7 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -17,8 +17,9 @@ import edu.ie3.simona.model.participant.load.random.RandomLoadModel.RandomReleva import edu.ie3.simona.model.participant.load.{DayType, LoadModel, LoadReference} import edu.ie3.util.TimeUtil import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import squants.Power -import squants.energy.{KilowattHours, Kilowatts, Watts} +import squants.energy.{KilowattHours, Kilowatts} import java.time.ZonedDateTime import java.util.UUID @@ -50,7 +51,7 @@ final case class RandomLoadModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, reference: LoadReference, ) extends LoadModel[RandomRelevantData]( @@ -101,7 +102,7 @@ final case class RandomLoadModel( case ActivePower(activePower) => /* scale the reference active power based on the random profiles averagePower/maxPower ratio */ val referenceScalingFactor = - profilePower / RandomLoadModel.randomMaxPower + profilePower / RandomLoadModel.randomMaxPower.toPower activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles random power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ @@ -170,7 +171,7 @@ object RandomLoadModel { * @return * Reference power to use for later model calculations */ - private val randomMaxPower: Power = Watts(159d) + private val randomMaxPower: ApparentPower = Voltamperes(159d) def apply( input: LoadInput, diff --git a/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala b/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala index 812eafbfff..6715abd69d 100644 --- a/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala +++ b/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.ontology.messages.flex import edu.ie3.datamodel.models.input.AssetInput import edu.ie3.simona.agent.em.EmAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.scheduler.ScheduleLock.ScheduleKey import org.apache.pekko.actor.typed.ActorRef import squants.Power @@ -136,7 +138,7 @@ object FlexibilityMessage { */ final case class FlexCtrlCompletion( override val modelUuid: UUID, - result: ApparentPower, + result: ComplexPower, requestAtNextActivation: Boolean = false, requestAtTick: Option[Long] = None, ) extends FlexResponse diff --git a/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala b/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala index 73aa482b64..79f41a8811 100644 --- a/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala +++ b/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala @@ -6,7 +6,9 @@ package edu.ie3.simona.ontology.messages.services -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.ontology.messages.services.ServiceMessage.ProvisionMessage import edu.ie3.simona.scheduler.ScheduleLock.ScheduleKey import org.apache.pekko.actor.ActorRef @@ -15,7 +17,7 @@ sealed trait PrimaryDataMessage object PrimaryDataMessage { - /** Provides primary data in the form of [[ApparentPower]] + /** Provides primary data in the form of [[ComplexPower]] * * @param tick * Tick, the data belongs to @@ -28,9 +30,9 @@ object PrimaryDataMessage { final case class ApparentPowerProvisionMessage( override val tick: Long, override val serviceRef: ActorRef, - override val data: ApparentPower, + override val data: ComplexPower, override val nextDataTick: Option[Long], override val unlockKey: Option[ScheduleKey] = None, - ) extends ProvisionMessage[ApparentPower] + ) extends ProvisionMessage[ComplexPower] with PrimaryDataMessage } diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala new file mode 100644 index 0000000000..7c007d85b2 --- /dev/null +++ b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala @@ -0,0 +1,81 @@ +/* + * © 2022. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.util.scala.quantities + +import squants._ +import squants.energy._ +import squants.time.Time + +import scala.util.Try + +final class ApparentPower private ( + val value: Double, + val unit: ApparentPowerUnit, +) extends Quantity[ApparentPower] { + + def dimension: ApparentPower.type = ApparentPower + + def toMillivoltamperes: Double = to(Millivoltamperes) + def toVoltamperes: Double = to(Voltamperes) + def toKilovoltamperes: Double = to(Kilovoltamperes) + def toMegavoltamperes: Double = to(Megavoltamperes) + def toGigavoltamperes: Double = to(Gigavoltamperes) + + def toPower: Power = Watts(toVoltamperes) +} + +object ApparentPower extends Dimension[ApparentPower] { + private[quantities] def apply[A](n: A, unit: ApparentPowerUnit)(implicit + num: Numeric[A] + ) = new ApparentPower(num.toDouble(n), unit) + def apply(energy: Energy, time: Time): ApparentPower = + apply(energy.toWattHours / time.toHours, Voltamperes) + def apply(value: Any): Try[ApparentPower] = parse(value) + + def name = "Power" + def primaryUnit: Voltamperes.type = Voltamperes + def siUnit: Voltamperes.type = Voltamperes + def units: Set[UnitOfMeasure[ApparentPower]] = + Set( + Voltamperes, + Millivoltamperes, + Kilovoltamperes, + Megavoltamperes, + Gigavoltamperes, + ) +} + +trait ApparentPowerUnit + extends UnitOfMeasure[ApparentPower] + with UnitConverter { + def apply[A](n: A)(implicit num: Numeric[A]): ApparentPower = + ApparentPower(n, this) +} + +object Millivoltamperes extends ApparentPowerUnit with SiUnit { + val conversionFactor: Double = MetricSystem.Milli + val symbol = "mVA" +} + +object Voltamperes extends ApparentPowerUnit with PrimaryUnit with SiUnit { + val symbol = "VA" +} + +object Kilovoltamperes extends ApparentPowerUnit with SiUnit { + val conversionFactor: Double = MetricSystem.Kilo + val symbol = "kVA" +} + +object Megavoltamperes extends ApparentPowerUnit with SiUnit { + val conversionFactor: Double = MetricSystem.Mega + val symbol = "MVA" +} + +object Gigavoltamperes extends ApparentPowerUnit with SiUnit { + val conversionFactor: Double = MetricSystem.Giga + val symbol = "GVA" +} 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 08420edfbe..7bd48e2ac6 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala @@ -1300,9 +1300,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev900.sRatedAc - minPower shouldBe ev900.sRatedAc // battery is empty - maxPower shouldBe ev900.sRatedAc + referencePower shouldBe ev900.sRatedAc.toPower + minPower shouldBe ev900.sRatedAc.toPower // battery is empty + maxPower shouldBe ev900.sRatedAc.toPower } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1418,9 +1418,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc - minPower shouldBe ev900.sRatedAc // battery is empty - maxPower shouldBe ev4500.sRatedAc + referencePower shouldBe ev4500.sRatedAc.toPower + minPower shouldBe ev900.sRatedAc.toPower // battery is empty + maxPower shouldBe ev4500.sRatedAc.toPower } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1469,9 +1469,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc + referencePower shouldBe ev4500.sRatedAc.toPower minPower shouldBe Kilowatts(0.0) // battery is exactly at margin - maxPower shouldBe ev4500.sRatedAc + maxPower shouldBe ev4500.sRatedAc.toPower } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1558,7 +1558,7 @@ class EvcsAgentModelCalculationSpec ) => modelUuid shouldBe evcsInputModelQv.getUuid refPower shouldBe combinedChargingPowerSq - minPower shouldBe ev4500.sRatedAc * -1 // battery of earlier ev is above lowest soc now + minPower shouldBe ev4500.sRatedAc.toPower * -1 // battery of earlier ev is above lowest soc now maxPower shouldBe combinedChargingPowerSq } @@ -1712,7 +1712,7 @@ class EvcsAgentModelCalculationSpec ) => modelUuid shouldBe evcsInputModelQv.getUuid referencePower shouldBe combinedChargingPowerSq - minPower shouldBe ev4500.sRatedAc * -1 // battery of ev11700 is below lowest soc now + minPower shouldBe ev4500.sRatedAc.toPower * -1 // battery of ev11700 is below lowest soc now maxPower shouldBe combinedChargingPowerSq } @@ -1913,9 +1913,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc + referencePower shouldBe ev4500.sRatedAc.toPower minPower shouldBe Kilowatts(0d) - maxPower shouldBe ev4500.sRatedAc + maxPower shouldBe ev4500.sRatedAc.toPower } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala index 10a2652e9d..dde8ed4803 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala @@ -6,10 +6,6 @@ package edu.ie3.simona.agent.participant -import org.apache.pekko.actor.ActorRef.noSender -import org.apache.pekko.actor.{ActorRef, ActorSystem} -import org.apache.pekko.testkit.TestFSMRef -import org.apache.pekko.util.Timeout import breeze.numerics.pow import com.typesafe.config.ConfigFactory import edu.ie3.datamodel.models.input.system.SystemParticipantInput @@ -27,8 +23,8 @@ import edu.ie3.simona.exceptions.agent.{ InconsistentStateException, } import edu.ie3.simona.model.participant.CalcRelevantData.FixedRelevantData -import edu.ie3.simona.model.participant.SystemParticipant import edu.ie3.simona.model.participant.ModelState.ConstantState +import edu.ie3.simona.model.participant.SystemParticipant import edu.ie3.simona.model.participant.control.QControl.CosPhiFixed import edu.ie3.simona.model.participant.load.FixedLoadModel.FixedLoadRelevantData import edu.ie3.simona.model.participant.load.{FixedLoadModel, LoadReference} @@ -36,13 +32,22 @@ import edu.ie3.simona.test.common.AgentSpec import edu.ie3.simona.test.common.model.participant.LoadTestData import edu.ie3.util.TimeUtil import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.{Megavars, ReactivePower, Vars} +import edu.ie3.util.scala.quantities.{ + Kilovoltamperes, + Megavars, + ReactivePower, + Vars, +} +import org.apache.pekko.actor.ActorRef.noSender +import org.apache.pekko.actor.{ActorRef, ActorSystem} +import org.apache.pekko.testkit.TestFSMRef +import org.apache.pekko.util.Timeout import org.mockito.Mockito.when import org.scalatest.PrivateMethodTester import org.scalatest.prop.{TableDrivenPropertyChecks, TableFor3, TableFor5} import org.scalatestplus.mockito.MockitoSugar -import squants.{Each, Power} import squants.energy.{Kilowatts, Megawatts, Watts} +import squants.{Each, Power} import java.util.UUID import java.util.concurrent.TimeUnit @@ -538,7 +543,7 @@ class ParticipantAgentFundamentalsSpec "test_load", OperationInterval(0L, 1800L), CosPhiFixed(0.95), - Kilowatts(100.0), + Kilovoltamperes(100.0), 0.95, LoadReference.ActivePower(Kilowatts(95.0)), ), @@ -575,7 +580,7 @@ class ParticipantAgentFundamentalsSpec "test_load", OperationInterval(0L, 1800L), CosPhiFixed(0.95), - Kilowatts(100.0), + Kilovoltamperes(100.0), 0.95, LoadReference.ActivePower(Kilowatts(95.0)), ), diff --git a/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala index 6e8556d6ca..abcdb613a6 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala @@ -11,12 +11,17 @@ import edu.ie3.simona.model.participant.ApparentPowerAndHeatSpec.ApparentPowerAn import edu.ie3.simona.model.participant.CalcRelevantData.FixedRelevantData import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.control.QControl.CosPhiFixed -import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage +import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.{Megavars, ReactivePower, Vars} -import squants.energy.{Kilowatts, Megawatts, Watts} +import edu.ie3.util.scala.quantities.{ + Kilovoltamperes, + Megavars, + ReactivePower, + Vars, +} +import squants.energy.{Megawatts, Watts} import squants.{Each, Power} import java.util.UUID @@ -69,7 +74,7 @@ object ApparentPowerAndHeatSpec { "ParticipantMock", OperationInterval.apply(0L, 42L), CosPhiFixed(0.97), - Kilowatts(42d), + Kilovoltamperes(42d), 0.97, ) with ApparentPowerAndHeatParticipant[ diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala index bbd90653f1..d1308757e5 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala @@ -14,8 +14,13 @@ import edu.ie3.simona.test.common.input.FixedFeedInputTestData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.simona.util.ConfigUtil import edu.ie3.util.quantities.PowerSystemUnits.MEGAVOLTAMPERE +import edu.ie3.util.scala.quantities.{ + ApparentPower, + Megavoltamperes, + Voltamperes, +} import org.scalatest.PrivateMethodTester -import squants.energy.{Kilowatts, Megawatts, Watts} +import squants.energy.Kilowatts class FixedFeedInModelSpec extends UnitSpec @@ -23,7 +28,7 @@ class FixedFeedInModelSpec with DefaultTestData with PrivateMethodTester { - private implicit val powerTolerance: squants.Power = Watts( + private implicit val powerTolerance: ApparentPower = Voltamperes( 1.0 ) // Equals to 1 W power @@ -62,7 +67,7 @@ class FixedFeedInModelSpec operationInterval shouldBe defaultOperationInterval qControl shouldBe QControl(fixedFeedInput.getqCharacteristics) sRated should approximate( - Megawatts( + Megavoltamperes( fixedFeedInput.getsRated().to(MEGAVOLTAMPERE).getValue.doubleValue ) ) diff --git a/src/test/scala/edu/ie3/simona/model/participant/HpModelTestData.scala b/src/test/scala/edu/ie3/simona/model/participant/HpModelTestData.scala index cbbe51ba9e..eb4119d270 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/HpModelTestData.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/HpModelTestData.scala @@ -28,6 +28,7 @@ import edu.ie3.simona.model.thermal.{ } import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.Kilovoltamperes import squants.energy.{KilowattHours, Kilowatts} import squants.thermal.Celsius import squants.{Power, Temperature} @@ -78,7 +79,7 @@ trait HpModelTestData { "HpModel", OperationInterval.apply(0L, 86400L), QControl.CosPhiFixed(0.95), - Kilowatts(100d), + Kilovoltamperes(100d), 0.95, Kilowatts(15d), thermalGrid, diff --git a/src/test/scala/edu/ie3/simona/model/participant/PvModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/PvModelSpec.scala index 660852e28b..157ff0a041 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/PvModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/PvModelSpec.scala @@ -14,7 +14,9 @@ import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.scala.quantities.{ + ApparentPower, Irradiation, + Kilovoltamperes, Megavars, ReactivePower, WattHoursPerSquareMeter, @@ -92,6 +94,9 @@ class PvModelSpec extends UnitSpec with GivenWhenThen with DefaultTestData { private implicit val angleTolerance: Angle = Radians(1e-10) private implicit val irradiationTolerance: Irradiation = WattHoursPerSquareMeter(1e-10) + private implicit val apparentPowerTolerance: ApparentPower = Kilovoltamperes( + 1e-10 + ) private implicit val powerTolerance: Power = Kilowatts(1e-10) private implicit val reactivePowerTolerance: ReactivePower = Megavars(1e-10) diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala index 358090b0a3..e53dffc943 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala @@ -812,7 +812,7 @@ class EvcsModelSpec modelUuid shouldBe evcsModel.getUuid refPower should approximate(Kilowatts(5.0)) // one hour left minPower should approximate(Kilowatts(0d)) // no v2g allowed! - maxPower should approximate(ev1.sRatedAc) + maxPower should approximate(ev1.sRatedAc.toPower) } } diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala index a53b82981e..c265a9f987 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala @@ -85,7 +85,7 @@ class MaximumPowerChargingSpec ScheduleEntry( offset, offset + expectedDuration, - ev.sRatedAc, + ev.sRatedAc.toPower, ) ) ) diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/LoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/LoadModelSpec.scala index 8d29d36b32..cca01b7904 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/LoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/LoadModelSpec.scala @@ -11,6 +11,7 @@ import edu.ie3.simona.model.participant.load.profile.ProfileLoadModel import edu.ie3.simona.model.participant.load.random.RandomLoadModel import edu.ie3.simona.test.common.UnitSpec import edu.ie3.simona.test.common.input.LoadInputTestData +import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import org.scalatest.PrivateMethodTester import org.scalatest.prop.TableDrivenPropertyChecks import squants.energy.{KilowattHours, Power, Watts} @@ -21,7 +22,7 @@ class LoadModelSpec with PrivateMethodTester with TableDrivenPropertyChecks { - private implicit val powerTolerance: Power = Watts(1e-3) + private implicit val powerTolerance: ApparentPower = Voltamperes(1e-3) "The load model object" should { @@ -32,27 +33,31 @@ class LoadModelSpec ( LoadReference.ActivePower(Watts(268.6)), 1d, - Watts(282.7368), + Voltamperes(282.7368), ), ( LoadReference.EnergyConsumption(KilowattHours(3000.0)), 1d, - Watts(848.2105), + Voltamperes(848.2105), ), ( LoadReference.ActivePower(Watts(268.6)), 1.5d, - Watts(424.1053), + Voltamperes(424.1053), ), ( LoadReference.EnergyConsumption(KilowattHours(3000.0)), 1.5d, - Watts(1272.3158), + Voltamperes(1272.3158), ), ) forAll(params) { - (reference: LoadReference, scaling: Double, expectedSRated: Power) => + ( + reference: LoadReference, + scaling: Double, + expectedSRated: ApparentPower, + ) => { val actual = ProfileLoadModel( loadInput, @@ -91,27 +96,31 @@ class LoadModelSpec ( LoadReference.ActivePower(Watts(268.6)), 1d, - Watts(311.0105), + Voltamperes(311.0105), ), ( LoadReference.EnergyConsumption(KilowattHours(3000.0)), 1d, - Watts(770.8076), + Voltamperes(770.8076), ), ( LoadReference.ActivePower(Watts(268.6)), 1.5d, - Watts(466.5158), + Voltamperes(466.5158), ), ( LoadReference.EnergyConsumption(KilowattHours(3000.0)), 1.5d, - Watts(1156.2114), + Voltamperes(1156.2114), ), ) forAll(params) { - (reference: LoadReference, scaling: Double, expectedSRated: Power) => + ( + reference: LoadReference, + scaling: Double, + expectedSRated: ApparentPower, + ) => { val actual = RandomLoadModel( loadInput, diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala index 64701fa993..f8c6fddc74 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala @@ -16,6 +16,7 @@ import edu.ie3.simona.model.participant.load.profile.{ } import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.TimeUtil +import edu.ie3.util.scala.quantities.Voltamperes import org.scalatest.PrivateMethodTester import org.scalatest.prop.TableDrivenPropertyChecks import squants.energy.{KilowattHours, Watts} @@ -91,7 +92,7 @@ class LoadProfileStoreSpec forAll(maxParams) { (loadProfile: StandardLoadProfile, maxParamValue: Double) => - val maxParam = Watts(maxParamValue) + val maxParam = Voltamperes(maxParamValue) customStore.maxPower(loadProfile) shouldBe maxParam } diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/ProfileLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/ProfileLoadModelSpec.scala index 74077a250b..0cd81c66b5 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/ProfileLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/ProfileLoadModelSpec.scala @@ -21,8 +21,8 @@ import edu.ie3.simona.model.participant.load.profile.ProfileLoadModel import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import org.scalatest.prop.TableDrivenPropertyChecks -import squants.Power import squants.energy.{KilowattHours, Watts} import tech.units.indriya.quantity.Quantities @@ -30,7 +30,7 @@ import java.util.UUID class ProfileLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { - private implicit val tolerance: Power = Watts(1d) + private implicit val tolerance: ApparentPower = Voltamperes(1d) "Having a profile load model" when { val loadInput = @@ -78,38 +78,38 @@ class ProfileLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { ( BdewStandardLoadProfile.H0, ActivePower(Watts(268.6)), - Watts(282.74d), + Voltamperes(282.74d), ), ( BdewStandardLoadProfile.H0, EnergyConsumption( KilowattHours(3000d) ), - Watts(848.22d), + Voltamperes(848.22d), ), ( BdewStandardLoadProfile.L0, ActivePower(Watts(268.6)), - Watts(282.74d), + Voltamperes(282.74d), ), ( BdewStandardLoadProfile.L0, EnergyConsumption( KilowattHours(3000d) ), - Watts(759.158d), + Voltamperes(759.158d), ), ( BdewStandardLoadProfile.G0, ActivePower(Watts(268.6)), - Watts(282.74d), + Voltamperes(282.74d), ), ( BdewStandardLoadProfile.G0, EnergyConsumption( KilowattHours(3000d) ), - Watts(759.158d), + Voltamperes(759.158d), ), ) ) { (profile, reference, expectedSRated) => diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala index 82fa1041e5..c0ee464734 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala @@ -26,15 +26,19 @@ import edu.ie3.simona.model.participant.load.random.{ import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.scala.quantities.{ + ApparentPower, + Kilovoltamperes, + Voltamperes, +} import org.scalatest.prop.TableDrivenPropertyChecks -import squants.Power -import squants.energy.{KilowattHours, Kilowatts, Watts} +import squants.energy.{KilowattHours, Watts} import tech.units.indriya.quantity.Quantities import java.util.UUID class RandomLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { - implicit val tolerance: Power = Watts(1d) + implicit val tolerance: ApparentPower = Voltamperes(1d) "Having a random load model" when { val loadInput = new LoadInput( @@ -78,11 +82,11 @@ class RandomLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { val testData = Table( ("reference", "expectedSRated"), - (ActivePower(Watts(268.6)), Watts(311.0105263157895d)), - (EnergyConsumption(KilowattHours(2000d)), Watts(513.871737d)), + (ActivePower(Watts(268.6)), Voltamperes(311.0105263157895d)), + (EnergyConsumption(KilowattHours(2000d)), Voltamperes(513.871737d)), ) - forAll(testData) { (reference, expectedSRated: Power) => + forAll(testData) { (reference, expectedSRated: ApparentPower) => val actual = RandomLoadModel( loadInput, foreSeenOperationInterval, @@ -102,10 +106,10 @@ class RandomLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { loadInput.getId, foreSeenOperationInterval, QControl.apply(loadInput.getqCharacteristics()), - Kilowatts( + Kilovoltamperes( loadInput .getsRated() - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue() ), From aac2946293cf0a3a5d87650abb4b6d6d39ccff19 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 4 Jul 2024 13:59:19 +0200 Subject: [PATCH 002/137] Adapting groovy tests. --- .../model/participant/BMModelTest.groovy | 13 ++++++------ .../model/participant/ChpModelTest.groovy | 4 +++- .../participant/FixedFeedModelTest.groovy | 11 +++++----- .../participant/SystemParticipantTest.groovy | 21 +++++++++++-------- .../load/FixedLoadModelTest.groovy | 19 +++++++---------- .../test/common/model/MockParticipant.groovy | 3 ++- 6 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy index f6d83d770b..4c128dc207 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy @@ -6,9 +6,6 @@ package edu.ie3.simona.model.participant -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.unit.Units.PERCENT - import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed import edu.ie3.datamodel.models.input.system.type.BmTypeInput @@ -16,6 +13,7 @@ import edu.ie3.simona.model.participant.ModelState.ConstantState$ import edu.ie3.simona.model.participant.control.QControl import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.EuroPerKilowatthour$ +import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.util.scala.quantities.Sq import scala.Some import spock.lang.Shared @@ -28,6 +26,9 @@ import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.unit.Units.PERCENT + /** * Test class that tries to cover all special cases of the current implementation of the {@link BMModel} * @@ -63,7 +64,7 @@ class BMModelTest extends Specification { "BM Model Test", OperationInterval.apply(0L, 86400L), QControl.apply(new CosPhiFixed("cosPhiFixed:{(0.0,1.0)}")), - Sq.create(190, Kilowatts$.MODULE$), + Sq.create(190, Kilovoltamperes$.MODULE$), bmType.getCosPhiRated(), "MockNode", true, @@ -169,7 +170,7 @@ class BMModelTest extends Specification { "BM Model Test", OperationInterval.apply(0L, 86400L), QControl.apply(new CosPhiFixed("cosPhiFixed:{(0.0,1.0)}")), - Sq.create(190, Kilowatts$.MODULE$), + Sq.create(190, Kilovoltamperes$.MODULE$), bmType.getCosPhiRated(), "MockNode", true, @@ -221,7 +222,7 @@ class BMModelTest extends Specification { "BM Model Test", OperationInterval.apply(0L, 86400L), QControl.apply(new CosPhiFixed("cosPhiFixed:{(0.0,1.0)}")), - Sq.create(190, Kilowatts$.MODULE$), + Sq.create(190, Kilovoltamperes$.MODULE$), bmType.getCosPhiRated(), "MockNode", costControlled, diff --git a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy index a07273bb27..5c23821519 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy @@ -6,6 +6,8 @@ package edu.ie3.simona.model.participant +import edu.ie3.util.scala.quantities.Kilovoltamperes$ + import static edu.ie3.util.quantities.PowerSystemUnits.* import static tech.units.indriya.quantity.Quantities.getQuantity import static tech.units.indriya.unit.Units.PERCENT @@ -91,7 +93,7 @@ class ChpModelTest extends Specification { "ChpModel", null, null, - Sq.create(100, Kilowatts$.MODULE$), + Sq.create(100, Kilovoltamperes$.MODULE$), 0.95, Sq.create(50, Kilowatts$.MODULE$), thermalStorage) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy index 268323d95f..4e35daf57a 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy @@ -6,8 +6,6 @@ package edu.ie3.simona.model.participant -import static edu.ie3.util.quantities.PowerSystemUnits.* - import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput @@ -17,11 +15,14 @@ import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.control.QControl import edu.ie3.util.TimeUtil +import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.util.scala.quantities.Sq import spock.lang.Specification -import squants.energy.* +import squants.energy.Watts$ import tech.units.indriya.quantity.Quantities +import static edu.ie3.util.quantities.PowerSystemUnits.* + class FixedFeedModelTest extends Specification { def fixedFeedInput = new FixedFeedInInput( @@ -54,7 +55,7 @@ class FixedFeedModelTest extends Specification { fixedFeedInput.operationTime ) - def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1.0, Kilowatts$.MODULE$) + def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1000, Watts$.MODULE$) def "A fixed feed model should return approximately correct power calculations"() { when: @@ -68,7 +69,7 @@ class FixedFeedModelTest extends Specification { .to(KILOWATT) .value.doubleValue() .doubleValue(), - Kilowatts$.MODULE$ + Kilovoltamperes$.MODULE$ ), fixedFeedInput.cosPhiRated ) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/SystemParticipantTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/SystemParticipantTest.groovy index d13782be0c..8e484440ce 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/SystemParticipantTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/SystemParticipantTest.groovy @@ -12,10 +12,13 @@ import edu.ie3.datamodel.models.input.system.characteristic.QV import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.test.common.model.MockParticipant import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.util.scala.quantities.Sq import spock.lang.Specification -import squants.* -import squants.energy.* +import squants.Dimensionless +import squants.Each$ +import squants.energy.Kilowatts$ +import squants.energy.Power class SystemParticipantTest extends Specification { @@ -27,7 +30,7 @@ class SystemParticipantTest extends Specification { "System participant calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new CosPhiFixed(varCharacteristicString)), - Sq.create(200, Kilowatts$.MODULE$), + Sq.create(200, Kilovoltamperes$.MODULE$), 1d) Dimensionless adjustedVoltage = Sq.create(1, Each$.MODULE$) // needed for method call but not applicable for cosphi_p @@ -58,7 +61,7 @@ class SystemParticipantTest extends Specification { "Load calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new CosPhiP(varCharacteristicString)), - Sq.create(102, Kilowatts$.MODULE$), + Sq.create(102, Kilovoltamperes$.MODULE$), 1d) Dimensionless adjustedVoltage = Sq.create(1, Each$.MODULE$) // needed for method call but not applicable for cosphi_p @@ -87,7 +90,7 @@ class SystemParticipantTest extends Specification { "Generation calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new CosPhiP(varCharacteristicString)), - Sq.create(101, Kilowatts$.MODULE$), + Sq.create(101, Kilovoltamperes$.MODULE$), 1d) Dimensionless adjustedVoltage = Sq.create(1, Each$.MODULE$) // needed for method call but not applicable for cosphi_p @@ -118,7 +121,7 @@ class SystemParticipantTest extends Specification { "System participant calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Sq.create(200, Kilowatts$.MODULE$), + Sq.create(200, Kilovoltamperes$.MODULE$), 0.98) when: "the reactive power is calculated" @@ -151,7 +154,7 @@ class SystemParticipantTest extends Specification { "System participant calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Sq.create(200, Kilowatts$.MODULE$), + Sq.create(200, Kilovoltamperes$.MODULE$), 1d) when: "the reactive power is calculated" @@ -184,7 +187,7 @@ class SystemParticipantTest extends Specification { "System participant calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Sq.create(200, Kilowatts$.MODULE$), + Sq.create(200, Kilovoltamperes$.MODULE$), 0.95) when: "the reactive power is calculated" @@ -217,7 +220,7 @@ class SystemParticipantTest extends Specification { "System participant calculateQ Test", OperationInterval.apply(0L, 86400L), QControl.apply(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Sq.create(200, Kilowatts$.MODULE$), + Sq.create(200, Kilovoltamperes$.MODULE$), 0.95) when: "the reactive power is calculated" diff --git a/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy index a7ba4d9e87..73c2cffe09 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy @@ -6,11 +6,6 @@ package edu.ie3.simona.model.participant.load -import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower -import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static org.apache.commons.math3.util.FastMath.abs - import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput @@ -22,15 +17,17 @@ import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ModelState import edu.ie3.simona.model.participant.control.QControl import edu.ie3.util.TimeUtil -import spock.lang.Specification +import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.util.scala.quantities.Sq +import spock.lang.Specification import squants.energy.KilowattHours$ -import squants.energy.Kilowatts$ - import squants.energy.Watts$ import tech.units.indriya.quantity.Quantities - +import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower +import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static org.apache.commons.math3.util.FastMath.abs class FixedLoadModelTest extends Specification { def loadInput = @@ -75,7 +72,7 @@ class FixedLoadModelTest extends Specification { loadInput.id, operationInterval, QControl.apply(loadInput.qCharacteristics), - Sq.create(loadInput.sRated.to(KILOWATT).value.doubleValue(), Kilowatts$.MODULE$), + Sq.create(loadInput.sRated.to(KILOWATT).value.doubleValue(), Kilovoltamperes$.MODULE$), loadInput.cosPhiRated, reference ) @@ -96,7 +93,7 @@ class FixedLoadModelTest extends Specification { loadInput.id, operationInterval, QControl.apply(loadInput.qCharacteristics), - Sq.create(loadInput.sRated.to(KILOWATT).value.doubleValue(), Kilowatts$.MODULE$), + Sq.create(loadInput.sRated.to(KILOWATT).value.doubleValue(), Kilovoltamperes$.MODULE$), loadInput.cosPhiRated, reference ) diff --git a/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy b/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy index acfc06fa14..ccdc786b96 100644 --- a/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy +++ b/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy @@ -13,6 +13,7 @@ import edu.ie3.simona.model.participant.SystemParticipant import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.ApparentPower import edu.ie3.util.scala.quantities.Sq import scala.Tuple2 import squants.Dimensionless @@ -25,7 +26,7 @@ class MockParticipant extends SystemParticipant Date: Fri, 5 Jul 2024 15:45:30 +0200 Subject: [PATCH 003/137] Improving `ApparentPower`. --- .../simona/model/participant/BMModel.scala | 12 ++++---- .../simona/model/participant/ChpModel.scala | 2 +- .../model/participant/FixedFeedInModel.scala | 3 +- .../simona/model/participant/HpModel.scala | 7 ++--- .../simona/model/participant/PvModel.scala | 9 +++--- .../model/participant/SystemParticipant.scala | 21 ++++++-------- .../simona/model/participant/WecModel.scala | 4 +-- .../model/participant/control/QControl.scala | 22 +++++++++------ .../model/participant/evcs/EvcsModel.scala | 4 +-- .../model/participant/load/LoadModel.scala | 2 +- .../load/profile/LoadProfileStore.scala | 2 +- .../load/profile/ProfileLoadModel.scala | 5 +++- .../load/random/RandomLoadModel.scala | 8 +++--- .../util/scala/quantities/ApparentPower.scala | 6 +++- .../EvcsAgentModelCalculationSpec.scala | 28 +++++++++++-------- .../participant/ParticipantAgentMock.scala | 13 ++++++--- .../participant/evcs/EvcsModelSpec.scala | 2 +- .../MaximumPowerChargingSpec.scala | 2 +- 18 files changed, 82 insertions(+), 70 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index ad61d74654..02bc1242e2 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -32,7 +32,7 @@ final case class BMModel( operationInterval: OperationInterval, qControl: QControl, sRated: ApparentPower, - cosPhi: Double, + cosPhiRated: Double, private val node: String, private val isCostControlled: Boolean, private val opex: Money, @@ -48,7 +48,7 @@ final case class BMModel( operationInterval, qControl, sRated, - cosPhi, + cosPhiRated, ) with ApparentPowerParticipant[BMCalcRelevantData, ConstantState.type] { @@ -197,10 +197,10 @@ final case class BMModel( isCostControlled && avgOpex.value.doubleValue() < feedInTariff.value .doubleValue() ) - sRated * cosPhi * (-1) + sRated.toPower(cosPhiRated) * (-1) else - sRated * usage * eff * cosPhi * (-1) - }.toPower + sRated.toPower(cosPhiRated) * usage * eff * (-1) + } /** Applies the load gradient to the electrical output * @param pEl @@ -214,7 +214,7 @@ final case class BMModel( _lastPower match { case None => pEl case Some(lastPowerVal) => - val pElDeltaMaxAbs = sRated.toPower * cosPhi * loadGradient + val pElDeltaMaxAbs = sRated.toPower(cosPhiRated) * loadGradient pEl - lastPowerVal match { case pElDelta if pElDelta > pElDeltaMaxAbs => diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 8ce0245c4c..9005760064 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -70,7 +70,7 @@ final case class ChpModel( ) with ApparentPowerParticipant[ChpRelevantData, ConstantState.type] { - val pRated: Power = sRated.toPower * cosPhiRated + val pRated: Power = sRated.toPower(cosPhiRated) /** As this is a state-full model (with respect to the current operation * condition and its thermal storage), the power calculation operates on the diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index 6b7b0834b8..0eb7bcf73e 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -73,8 +73,7 @@ final case class FixedFeedInModel( override protected def calculateActivePower( modelState: ConstantState.type, data: FixedRelevantData.type = FixedRelevantData, - ): Power = - sRated.toPower * (-1) * cosPhiRated + ): Power = sRated.toPower(cosPhiRated) * (-1) override def determineFlexOptions( data: FixedRelevantData.type, diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 47341eb919..ed8af44311 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -77,8 +77,7 @@ final case class HpModel( ) with ApparentPowerAndHeatParticipant[HpRelevantData, HpState] { - private val pRated: Power = - sRated.toPower * cosPhiRated + private val pRated: Power = sRated.toPower(cosPhiRated) /** As this is a state-full model (with respect to the current operation * condition and inner temperature), the power calculation operates on the @@ -229,7 +228,7 @@ final case class HpModel( updatedState.activePower val upperBoundary = if (canOperate) - sRated.toPower * cosPhiRated + sRated.toPower(cosPhiRated) else zeroKW @@ -264,7 +263,7 @@ final case class HpModel( setPower: Power, ): (HpState, FlexChangeIndicator) = { /* If the setpoint value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */ - val turnOn = setPower > (sRated.toPower * cosPhiRated * 0.5) + val turnOn = setPower > (sRated.toPower(cosPhiRated) * 0.5) val updatedState = calcState(lastState, data, turnOn) ( diff --git a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala index bc226040c0..8262252bf0 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala @@ -59,12 +59,12 @@ final case class PvModel private ( override val sMax: ApparentPower = sRated * 1.1 /** Permissible maximum active power feed in (therefore negative) */ - protected val pMax: Power = sMax.toPower * cosPhiRated * -1d + protected val pMax: Power = sMax.toPower(cosPhiRated) * -1d /** Reference yield at standard testing conditions (STC) */ private val yieldSTC = WattsPerSquareMeter(1000d) - private val activationThreshold = sRated.toPower * cosPhiRated * 0.001 * -1d + private val activationThreshold = sRated.toPower(cosPhiRated) * 0.001 * -1d /** Calculate the active power behaviour of the model * @@ -692,9 +692,8 @@ final case class PvModel private ( eTotalInWhPerSM * moduleSurface.toSquareMeters * etaConv.toEach * (genCorr * tempCorr) /* Calculate the foreseen active power output without boundary condition adaptions */ - val proposal = sRated.toPower * (-1) * ( - actYield / irradiationSTC - ) * cosPhiRated + val proposal = + sRated.toPower(cosPhiRated) * (-1) * (actYield / irradiationSTC) /* Do sanity check, if the proposed feed in is above the estimated maximum to be apparent active power of the plant */ if (proposal < pMax) diff --git a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala index 84f09f5d0f..5a12280db2 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala @@ -7,22 +7,17 @@ package edu.ie3.simona.model.participant import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, PrimaryDataWithApparentPower, + ApparentPower => ComplexPower, } import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptions import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.DefaultQuantities._ -import edu.ie3.util.scala.quantities.{ - ApparentPower, - DefaultQuantities, - Megavars, - ReactivePower, -} +import edu.ie3.util.scala.quantities._ import squants.Dimensionless -import squants.energy.{Kilowatts, Power} +import squants.energy.Power import java.util.UUID @@ -174,7 +169,7 @@ abstract class SystemParticipant[ nodalVoltage: Dimensionless ): Power => ReactivePower = qControl.activeToReactivePowerFunc( - sRated.toPower, + sRated, cosPhiRated, nodalVoltage, ) @@ -213,7 +208,7 @@ abstract class SystemParticipant[ reactivePower: ReactivePower, ): ReactivePower = { { - val apparentPower: Power = Kilowatts( + val apparentPower: ApparentPower = Kilovoltamperes( Math .sqrt( Math.pow(activePower.toKilowatts, 2) + Math @@ -222,7 +217,7 @@ abstract class SystemParticipant[ ) // tolerance for double inaccuracies - val sMaxWithTolerance = sMax.toPower * 1.00001d + val sMaxWithTolerance = sMax * 1.00001d if (apparentPower > sMaxWithTolerance) { logger.debug( @@ -233,8 +228,8 @@ abstract class SystemParticipant[ s"in correspondence to the existing active power $activePower." ) - val powerSquaredDifference = Math.pow(sMax.toPower.toMegawatts, 2) - - Math.pow(activePower.toMegawatts, 2) + val powerSquaredDifference = Math.pow(sMax.toMegavoltamperes, 2) - Math + .pow(activePower.toMegawatts, 2) if (powerSquaredDifference < 0) { logger.warn( diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index 3d8de4a1cb..3489b8e31d 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -98,7 +98,7 @@ final case class WecModel( wecData: WecRelevantData, ): Power = { val activePower = determinePower(wecData) - val pMax = sMax.toPower * cosPhiRated + val pMax = sMax.toPower(cosPhiRated) (if (activePower > pMax) { logger.warn( @@ -278,7 +278,7 @@ object WecModel { operationInterval, QControl(scaledInput.getqCharacteristics), Kilovoltamperes( - scaledInput.getType.getsRated.to(KILOWATT).getValue.doubleValue + scaledInput.getType.getsRated.to(KILOVOLTAMPERE).getValue.doubleValue ), scaledInput.getType.getCosPhiRated, SquareMeters( diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index 25504c2fff..4ffed344af 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -13,7 +13,7 @@ import edu.ie3.simona.model.system.Characteristic import edu.ie3.simona.model.system.Characteristic.XYPair import edu.ie3.util.quantities.PowerSystemUnits.PU import edu.ie3.util.scala.quantities.DefaultQuantities._ -import edu.ie3.util.scala.quantities.{Megavars, ReactivePower} +import edu.ie3.util.scala.quantities.{ApparentPower, Megavars, ReactivePower} import squants.{Dimensionless, Each, Power} import tech.units.indriya.AbstractUnit @@ -44,7 +44,7 @@ sealed trait QControl { * The function */ def activeToReactivePowerFunc( - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, nodalVoltage: Dimensionless, ): Power => ReactivePower @@ -117,7 +117,7 @@ object QControl { * The function */ override def activeToReactivePowerFunc( - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, nodalVoltage: Dimensionless, ): Power => ReactivePower = { activePower: Power => @@ -169,19 +169,23 @@ object QControl { * The function */ override def activeToReactivePowerFunc( - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, nodalVoltage: Dimensionless, ): Power => ReactivePower = { activePower: Power => + val pRated = sRated.toPower(1.0) + val qMaxFromP = Megavars( sqrt( - pow(sRated.toMegawatts, 2) - + pow(pRated.toMegawatts, 2) - pow(activePower.toMegawatts, 2) ) ) - val qFromCharacteristic = - q(nodalVoltage, Megavars((sRated * sin(acos(cosPhiRated))).toMegawatts)) + val qFromCharacteristic = q( + nodalVoltage, + Megavars(sRated.toReactivePower(cosPhiRated).toMegavars), + ) qMaxPossible(qMaxFromP, qFromCharacteristic) } @@ -244,13 +248,13 @@ object QControl { * The function */ override def activeToReactivePowerFunc( - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, nodalVoltage: Dimensionless, ): Power => ReactivePower = { activePower: Power => /* cosphi( P / P_N ) = cosphi( P / (S_N * cosphi_rated) ) */ val pInPu = - activePower / (sRated * cosPhiRated) + activePower / sRated.toPower(cosPhiRated) val instantCosPhi = cosPhi(Each(pInPu)) _cosPhiMultiplication(instantCosPhi.value.doubleValue, activePower) } diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index ad16931c9f..59582f95ff 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -503,12 +503,12 @@ final case class EvcsModel( ): Power = { val evPower = currentType match { case ElectricCurrentType.AC => - ev.sRatedAc.toPower + ev.sRatedAc.toPower(1.0) case ElectricCurrentType.DC => ev.sRatedDc } /* Limit the charging power to the minimum of ev's and evcs' permissible power */ - evPower.min(sRated.toPower) + evPower.min(sRated.toPower(1.0)) } override def calculatePower( diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala index 1c94aa3020..f30a179a25 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala @@ -98,7 +98,7 @@ object LoadModel extends LazyLogging { .getValue .doubleValue ) - val pRated = sRated.toPower * inputModel.getCosPhiRated + val pRated = sRated.toPower(inputModel.getCosPhiRated) val referenceScalingFactor = activePower / pRated sRated * referenceScalingFactor * safetyFactor } diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index 0104bd3875..93b08ba62a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -85,7 +85,7 @@ class LoadProfileStore private (val reader: Reader) { * @param loadProfile * the consumer type * @return - * the maximum load in W + * the maximum load in VA */ def maxPower( loadProfile: StandardLoadProfile diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala index 5419436ebe..9c030d2b10 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala @@ -92,7 +92,10 @@ final case class ProfileLoadModel( reference match { case ActivePower(activePower) => /* scale the reference active power based on the profiles averagePower/maxPower ratio */ - val referenceScalingFactor = averagePower / profileMaxPower.toPower + val referenceScalingFactor = + averagePower / profileMaxPower.toPower( + 1.0 + ) // only active power => cosPhi = 1.0 activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles average power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index e3ff1ee9e7..152a413ee6 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -19,7 +19,7 @@ import edu.ie3.util.TimeUtil import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import squants.Power -import squants.energy.{KilowattHours, Kilowatts} +import squants.energy.{KilowattHours, Kilowatts, Watts} import java.time.ZonedDateTime import java.util.UUID @@ -102,7 +102,7 @@ final case class RandomLoadModel( case ActivePower(activePower) => /* scale the reference active power based on the random profiles averagePower/maxPower ratio */ val referenceScalingFactor = - profilePower / RandomLoadModel.randomMaxPower.toPower + profilePower / RandomLoadModel.randomMaxPower activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles random power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ @@ -171,7 +171,7 @@ object RandomLoadModel { * @return * Reference power to use for later model calculations */ - private val randomMaxPower: ApparentPower = Voltamperes(159d) + private val randomMaxPower: Power = Watts(159d) def apply( input: LoadInput, @@ -191,7 +191,7 @@ object RandomLoadModel { LoadModel.scaleSRatedEnergy( scaledInput, energyConsumption, - randomMaxPower, + Voltamperes(randomMaxPower.toWatts), randomProfileEnergyScaling, 1.1, ) diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala index 7c007d85b2..c67b87879a 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala @@ -10,6 +10,7 @@ import squants._ import squants.energy._ import squants.time.Time +import scala.math.{acos, sin} import scala.util.Try final class ApparentPower private ( @@ -25,7 +26,10 @@ final class ApparentPower private ( def toMegavoltamperes: Double = to(Megavoltamperes) def toGigavoltamperes: Double = to(Gigavoltamperes) - def toPower: Power = Watts(toVoltamperes) + def toPower(cosPhi: Double): Power = Watts(toVoltamperes) * cosPhi + + def toReactivePower(cosPhi: Double): ReactivePower = + Vars(toVoltamperes) * sin(acos(cosPhi)) } object ApparentPower extends Dimension[ApparentPower] { 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 7bd48e2ac6..cc8619915e 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala @@ -1300,9 +1300,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev900.sRatedAc.toPower - minPower shouldBe ev900.sRatedAc.toPower // battery is empty - maxPower shouldBe ev900.sRatedAc.toPower + referencePower shouldBe ev900.sRatedAc.toPower(1.0) + minPower shouldBe ev900.sRatedAc.toPower(1.0) // battery is empty + maxPower shouldBe ev900.sRatedAc.toPower(1.0) } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1418,9 +1418,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc.toPower - minPower shouldBe ev900.sRatedAc.toPower // battery is empty - maxPower shouldBe ev4500.sRatedAc.toPower + referencePower shouldBe ev4500.sRatedAc.toPower(1.0) + minPower shouldBe ev900.sRatedAc.toPower(1.0) // battery is empty + maxPower shouldBe ev4500.sRatedAc.toPower(1.0) } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1469,9 +1469,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc.toPower + referencePower shouldBe ev4500.sRatedAc.toPower(1.0) minPower shouldBe Kilowatts(0.0) // battery is exactly at margin - maxPower shouldBe ev4500.sRatedAc.toPower + maxPower shouldBe ev4500.sRatedAc.toPower(1.0) } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1558,7 +1558,9 @@ class EvcsAgentModelCalculationSpec ) => modelUuid shouldBe evcsInputModelQv.getUuid refPower shouldBe combinedChargingPowerSq - minPower shouldBe ev4500.sRatedAc.toPower * -1 // battery of earlier ev is above lowest soc now + minPower shouldBe ev4500.sRatedAc.toPower( + 1.0 + ) * -1 // battery of earlier ev is above lowest soc now maxPower shouldBe combinedChargingPowerSq } @@ -1712,7 +1714,9 @@ class EvcsAgentModelCalculationSpec ) => modelUuid shouldBe evcsInputModelQv.getUuid referencePower shouldBe combinedChargingPowerSq - minPower shouldBe ev4500.sRatedAc.toPower * -1 // battery of ev11700 is below lowest soc now + minPower shouldBe ev4500.sRatedAc.toPower( + 1.0 + ) * -1 // battery of ev11700 is below lowest soc now maxPower shouldBe combinedChargingPowerSq } @@ -1913,9 +1917,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc.toPower + referencePower shouldBe ev4500.sRatedAc.toPower(1.0) minPower shouldBe Kilowatts(0d) - maxPower shouldBe ev4500.sRatedAc.toPower + maxPower shouldBe ev4500.sRatedAc.toPower(1.0) } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index 2b7b5f399e..108bf91531 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -6,8 +6,6 @@ package edu.ie3.simona.agent.participant -import org.apache.pekko.actor.{ActorRef, FSM, Props} -import org.apache.pekko.actor.typed.{ActorRef => TypedActorRef} import edu.ie3.datamodel.models.input.system.SystemParticipantInput import edu.ie3.datamodel.models.result.system.SystemParticipantResult import edu.ie3.simona.agent.ValueStore @@ -43,7 +41,14 @@ import edu.ie3.simona.model.participant.{ } import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.FlexResponse import edu.ie3.util.quantities.QuantityUtils.RichQuantityDouble -import edu.ie3.util.scala.quantities.{Kilovars, Megavars, ReactivePower} +import edu.ie3.util.scala.quantities.{ + Kilovars, + Kilovoltamperes, + Megavars, + ReactivePower, +} +import org.apache.pekko.actor.typed.{ActorRef => TypedActorRef} +import org.apache.pekko.actor.{ActorRef, FSM, Props} import org.mockito.ArgumentMatchers.any import org.mockito.Mockito import org.mockito.Mockito.doReturn @@ -200,7 +205,7 @@ class ParticipantAgentMock( SystemParticipant[FixedRelevantData.type, ApparentPower, ConstantState.type], ] = { val func = CosPhiFixed(0.95).activeToReactivePowerFunc( - Kilowatts(0.0), + Kilovoltamperes(0.0), 0.95d, Each(1.0), ) diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala index e53dffc943..bb92b5b914 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala @@ -812,7 +812,7 @@ class EvcsModelSpec modelUuid shouldBe evcsModel.getUuid refPower should approximate(Kilowatts(5.0)) // one hour left minPower should approximate(Kilowatts(0d)) // no v2g allowed! - maxPower should approximate(ev1.sRatedAc.toPower) + maxPower should approximate(ev1.sRatedAc.toPower(1.0)) } } diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala index c265a9f987..0ad7182c2d 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala @@ -85,7 +85,7 @@ class MaximumPowerChargingSpec ScheduleEntry( offset, offset + expectedDuration, - ev.sRatedAc.toPower, + ev.sRatedAc.toPower(1.0), ) ) ) From 06c830694d78e6e057e7e28144adc2a06c4a8248 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 8 Jul 2024 11:13:06 +0200 Subject: [PATCH 004/137] Adapting `StorageModel`. --- .../simona/model/participant/StorageModel.scala | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala index 02f82d2670..2bd5a3b8e1 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala @@ -7,7 +7,9 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.StorageInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.StorageModel.{ RefTargetSocParams, @@ -20,6 +22,7 @@ import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMin import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.DefaultQuantities._ +import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants.energy.{KilowattHours, Kilowatts} import squants.{Dimensionless, Each, Energy, Power, Seconds} @@ -31,14 +34,14 @@ final case class StorageModel( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, eStorage: Energy, pMax: Power, eta: Dimensionless, initialSoc: Double, targetSoc: Option[Double], -) extends SystemParticipant[StorageRelevantData, ApparentPower, StorageState]( +) extends SystemParticipant[StorageRelevantData, ComplexPower, StorageState]( uuid, id, operationInterval, @@ -103,7 +106,7 @@ final case class StorageModel( voltage: Dimensionless, modelState: StorageState, data: StorageRelevantData, - ): ApparentPower = + ): ComplexPower = throw new NotImplementedError( "Storage model cannot calculate power without flexibility control." ) @@ -354,9 +357,9 @@ object StorageModel { scaledInput.getId, operationInterval, QControl.apply(scaledInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( scaledInput.getType.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), From 43f1ab9a7c6c13f527632a13c61e128fe464e897 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 9 Jul 2024 12:51:30 +0200 Subject: [PATCH 005/137] Adapting `StorageAgent`. Improving `ApparentPower`. --- .../agent/participant/storage/StorageAgent.scala | 12 +++++++----- .../simona/model/participant/control/QControl.scala | 4 +--- .../participant/load/random/RandomLoadModel.scala | 8 +++++--- .../ie3/util/scala/quantities/ApparentPower.scala | 4 ++-- .../model/participant/FixedFeedModelTest.groovy | 4 ++-- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala index f38328ea3b..5956f53822 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala @@ -8,7 +8,9 @@ package edu.ie3.simona.agent.participant.storage import edu.ie3.datamodel.models.input.system.StorageInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ApparentPower => ComplexPower +} import edu.ie3.simona.agent.participant.statedata.ParticipantStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.ParticipantInitializeStateData import edu.ie3.simona.config.SimonaConfig.StorageRuntimeConfig @@ -25,7 +27,7 @@ object StorageAgent { initStateData: ParticipantInitializeStateData[ StorageInput, StorageRuntimeConfig, - ApparentPower, + ComplexPower, ], listener: Iterable[ActorRef], ): Props = @@ -50,14 +52,14 @@ class StorageAgent( initStateData: ParticipantInitializeStateData[ StorageInput, StorageRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], StorageInput, StorageRuntimeConfig, StorageModel, diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index 4ffed344af..f01c413fd5 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -173,11 +173,9 @@ object QControl { cosPhiRated: Double, nodalVoltage: Dimensionless, ): Power => ReactivePower = { activePower: Power => - val pRated = sRated.toPower(1.0) - val qMaxFromP = Megavars( sqrt( - pow(pRated.toMegawatts, 2) - + pow(sRated.toPower(1.0).toMegawatts, 2) - pow(activePower.toMegawatts, 2) ) ) diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index 152a413ee6..8596662ed9 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -102,7 +102,9 @@ final case class RandomLoadModel( case ActivePower(activePower) => /* scale the reference active power based on the random profiles averagePower/maxPower ratio */ val referenceScalingFactor = - profilePower / RandomLoadModel.randomMaxPower + profilePower / RandomLoadModel.randomMaxPower.toPower( + 1.0 + ) // only active power => cosPhi = 1.0 activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles random power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ @@ -171,7 +173,7 @@ object RandomLoadModel { * @return * Reference power to use for later model calculations */ - private val randomMaxPower: Power = Watts(159d) + private val randomMaxPower: ApparentPower = Voltamperes(159d) def apply( input: LoadInput, @@ -191,7 +193,7 @@ object RandomLoadModel { LoadModel.scaleSRatedEnergy( scaledInput, energyConsumption, - Voltamperes(randomMaxPower.toWatts), + randomMaxPower, randomProfileEnergyScaling, 1.1, ) diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala index c67b87879a..a436727075 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala @@ -26,10 +26,10 @@ final class ApparentPower private ( def toMegavoltamperes: Double = to(Megavoltamperes) def toGigavoltamperes: Double = to(Gigavoltamperes) - def toPower(cosPhi: Double): Power = Watts(toVoltamperes) * cosPhi + def toPower(cosPhi: Double): Power = Watts(toVoltamperes * cosPhi) def toReactivePower(cosPhi: Double): ReactivePower = - Vars(toVoltamperes) * sin(acos(cosPhi)) + Vars(toVoltamperes * sin(acos(cosPhi))) } object ApparentPower extends Dimension[ApparentPower] { diff --git a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy index 4e35daf57a..e7784b2eb4 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy @@ -18,7 +18,7 @@ import edu.ie3.util.TimeUtil import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.util.scala.quantities.Sq import spock.lang.Specification -import squants.energy.Watts$ +import squants.energy.Kilowatts$ import tech.units.indriya.quantity.Quantities import static edu.ie3.util.quantities.PowerSystemUnits.* @@ -55,7 +55,7 @@ class FixedFeedModelTest extends Specification { fixedFeedInput.operationTime ) - def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1000, Watts$.MODULE$) + def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1.0, Kilowatts$.MODULE$) def "A fixed feed model should return approximately correct power calculations"() { when: From e3f4e99de3eee2d59ddd228d73805cc5131b9934 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 9 Jul 2024 14:35:49 +0200 Subject: [PATCH 006/137] Fixing test. --- .../ie3/simona/model/participant/FixedFeedModelTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy index e7784b2eb4..4e35daf57a 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy @@ -18,7 +18,7 @@ import edu.ie3.util.TimeUtil import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.util.scala.quantities.Sq import spock.lang.Specification -import squants.energy.Kilowatts$ +import squants.energy.Watts$ import tech.units.indriya.quantity.Quantities import static edu.ie3.util.quantities.PowerSystemUnits.* @@ -55,7 +55,7 @@ class FixedFeedModelTest extends Specification { fixedFeedInput.operationTime ) - def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1.0, Kilowatts$.MODULE$) + def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1000, Watts$.MODULE$) def "A fixed feed model should return approximately correct power calculations"() { when: From 4825f24ceae58216204c19b4f4eb875c8b41d921 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 29 Jul 2024 08:09:07 +0200 Subject: [PATCH 007/137] Fixing `codacy` issues. --- .../model/participant/ChpModelTest.groovy | 8 ++++---- .../model/participant/FixedFeedModelTest.groovy | 0 .../CylindricalThermalStorageTest.groovy | 6 +++--- .../model/thermal/ThermalHouseTest.groovy | 17 +++++++++-------- .../model/participant/FixedFeedModelSpec.scala | 3 ++- .../simona/model/participant/WecModelSpec.scala | 6 +++--- 6 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy diff --git a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy index 5c23821519..a4e0bbb0f0 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy @@ -8,10 +8,6 @@ package edu.ie3.simona.model.participant import edu.ie3.util.scala.quantities.Kilovoltamperes$ -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.quantity.Quantities.getQuantity -import static tech.units.indriya.unit.Units.PERCENT - import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.OperatorInput @@ -35,6 +31,10 @@ import squants.space.CubicMeters$ import squants.thermal.Celsius$ import testutils.TestObjectFactory +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.quantity.Quantities.getQuantity +import static tech.units.indriya.unit.Units.PERCENT + class ChpModelTest extends Specification { @Shared diff --git a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy b/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy index af5ffef8e5..b3c17eb4e0 100644 --- a/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy @@ -6,9 +6,6 @@ package edu.ie3.simona.model.thermal -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR -import static tech.units.indriya.quantity.Quantities.getQuantity - import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput import edu.ie3.util.scala.quantities.KilowattHoursPerKelvinCubicMeters$ @@ -20,6 +17,9 @@ import squants.energy.Kilowatts$ import squants.space.CubicMeters$ import squants.thermal.Celsius$ +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR +import static tech.units.indriya.quantity.Quantities.getQuantity + class CylindricalThermalStorageTest extends Specification { static final double TESTING_TOLERANCE = 1e-10 diff --git a/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy b/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy index f23d532b03..4d8df7a96d 100644 --- a/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy @@ -6,20 +6,21 @@ package edu.ie3.simona.model.thermal -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR_PER_KELVIN -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT_PER_KELVIN -import static tech.units.indriya.quantity.Quantities.getQuantity -import static tech.units.indriya.unit.Units.CELSIUS - import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import edu.ie3.util.scala.quantities.Sq import spock.lang.Shared import spock.lang.Specification -import squants.energy.* -import squants.thermal.* -import squants.time.* +import squants.energy.Kilowatts$ +import squants.thermal.Celsius$ +import squants.thermal.Kelvin$ +import squants.thermal.Temperature +import squants.time.Seconds$ +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR_PER_KELVIN +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT_PER_KELVIN +import static tech.units.indriya.quantity.Quantities.getQuantity +import static tech.units.indriya.unit.Units.CELSIUS class ThermalHouseTest extends Specification { diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala index 1cb083d9a0..e42f5d2655 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala @@ -10,6 +10,7 @@ import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.test.common.UnitSpec import edu.ie3.simona.test.common.input.FixedFeedInputTestData import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.scala.quantities.Kilovoltamperes import org.scalatest.prop.TableDrivenPropertyChecks import squants.energy.{Kilowatts, Power, Watts} @@ -35,7 +36,7 @@ class FixedFeedModelSpec fixedFeedInput.getId, defaultOperationInterval, QControl.apply(fixedFeedInput.getqCharacteristics()), - Kilowatts( + Kilovoltamperes( fixedFeedInput .getsRated() .to(PowerSystemUnits.KILOWATT) 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..ceac73c5e4 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -95,7 +95,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { wecModel.rotorArea.toSquareMeters shouldBe (typeInput.getRotorArea.toSystemUnit.getValue .doubleValue() +- 1e-5) wecModel.cosPhiRated shouldBe typeInput.getCosPhiRated - wecModel.sRated.toWatts shouldBe (typeInput.getsRated.toSystemUnit.getValue + wecModel.sRated.toVoltamperes shouldBe (typeInput.getsRated.toSystemUnit.getValue .doubleValue() +- 1e-5) wecModel.betzCurve shouldBe WecModel.WecCharacteristic.apply( inputModel.getType.getCpCharacteristic @@ -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)), @@ -175,7 +175,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { Seq(-23377.23862017266, -24573.41320418286, -29029.60338829823) temperatures.zip(expectedPowers).foreach { case (temperature, power) => - val wecData = new WecRelevantData( + val wecData = WecRelevantData( MetersPerSecond(3.0), Celsius(temperature), Some(Pascals(101325d)), From 6e49082e0599ab39dd94a5e18bbe54d973efc96b Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 29 Jul 2024 08:18:33 +0200 Subject: [PATCH 008/137] Fixing `codacy` issues. --- .../ie3/simona/model/participant/BMModelTest.groovy | 6 +++--- .../ie3/simona/model/participant/ChpModelTest.groovy | 8 ++++---- .../edu/ie3/simona/model/participant/PvModelIT.groovy | 6 +++--- .../simona/model/participant/StorageModelTest.groovy | 6 +++--- .../model/participant/load/FixedLoadModelTest.groovy | 10 +++++----- .../model/thermal/CylindricalThermalStorageTest.groovy | 6 +++--- .../ie3/simona/model/thermal/ThermalHouseTest.groovy | 10 +++++----- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy index 4c128dc207..0d23aaf479 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/BMModelTest.groovy @@ -6,6 +6,9 @@ package edu.ie3.simona.model.participant +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.unit.Units.PERCENT + import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed import edu.ie3.datamodel.models.input.system.type.BmTypeInput @@ -26,9 +29,6 @@ import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.unit.Units.PERCENT - /** * Test class that tries to cover all special cases of the current implementation of the {@link BMModel} * diff --git a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy index a4e0bbb0f0..455b82f068 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/ChpModelTest.groovy @@ -6,6 +6,10 @@ package edu.ie3.simona.model.participant +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.quantity.Quantities.getQuantity +import static tech.units.indriya.unit.Units.PERCENT + import edu.ie3.util.scala.quantities.Kilovoltamperes$ import edu.ie3.datamodel.models.OperationTime @@ -31,10 +35,6 @@ import squants.space.CubicMeters$ import squants.thermal.Celsius$ import testutils.TestObjectFactory -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.quantity.Quantities.getQuantity -import static tech.units.indriya.unit.Units.PERCENT - class ChpModelTest extends Specification { @Shared diff --git a/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy b/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy index 00caef8dee..4219b301e2 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy @@ -6,6 +6,9 @@ package edu.ie3.simona.model.participant +import static java.util.Locale.US +import static java.util.Locale.setDefault + import edu.ie3.datamodel.io.source.csv.CsvJointGridContainerSource import edu.ie3.datamodel.models.input.system.PvInput import edu.ie3.simona.ontology.messages.services.WeatherMessage @@ -27,9 +30,6 @@ import java.nio.file.Path import java.time.ZonedDateTime import java.util.zip.GZIPInputStream -import static java.util.Locale.US -import static java.util.Locale.setDefault - /** * A simple integration test that uses pre-calculated data to check if the pv model works as expected. * It uses 8 pv models located in GER. diff --git a/src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy index a28a405901..0bb982d6ff 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy @@ -6,6 +6,9 @@ package edu.ie3.simona.model.participant +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.quantity.Quantities.getQuantity + import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput @@ -21,9 +24,6 @@ import spock.lang.Shared import spock.lang.Specification import squants.energy.* -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.quantity.Quantities.getQuantity - class StorageModelTest extends Specification { @Shared diff --git a/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy index 73c2cffe09..a7976a0491 100644 --- a/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/participant/load/FixedLoadModelTest.groovy @@ -6,6 +6,11 @@ package edu.ie3.simona.model.participant.load +import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower +import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static org.apache.commons.math3.util.FastMath.abs + import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput @@ -24,11 +29,6 @@ import squants.energy.KilowattHours$ import squants.energy.Watts$ import tech.units.indriya.quantity.Quantities -import static edu.ie3.simona.model.participant.load.LoadReference.ActivePower -import static edu.ie3.simona.model.participant.load.LoadReference.EnergyConsumption -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static org.apache.commons.math3.util.FastMath.abs - class FixedLoadModelTest extends Specification { def loadInput = new LoadInput( diff --git a/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy b/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy index b3c17eb4e0..af5ffef8e5 100644 --- a/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/thermal/CylindricalThermalStorageTest.groovy @@ -6,6 +6,9 @@ package edu.ie3.simona.model.thermal +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR +import static tech.units.indriya.quantity.Quantities.getQuantity + import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput import edu.ie3.util.scala.quantities.KilowattHoursPerKelvinCubicMeters$ @@ -17,9 +20,6 @@ import squants.energy.Kilowatts$ import squants.space.CubicMeters$ import squants.thermal.Celsius$ -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR -import static tech.units.indriya.quantity.Quantities.getQuantity - class CylindricalThermalStorageTest extends Specification { static final double TESTING_TOLERANCE = 1e-10 diff --git a/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy b/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy index 4d8df7a96d..459f57ef7c 100644 --- a/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy +++ b/src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy @@ -6,6 +6,11 @@ package edu.ie3.simona.model.thermal +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR_PER_KELVIN +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT_PER_KELVIN +import static tech.units.indriya.quantity.Quantities.getQuantity +import static tech.units.indriya.unit.Units.CELSIUS + import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput import edu.ie3.util.scala.quantities.Sq @@ -17,11 +22,6 @@ import squants.thermal.Kelvin$ import squants.thermal.Temperature import squants.time.Seconds$ -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR_PER_KELVIN -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT_PER_KELVIN -import static tech.units.indriya.quantity.Quantities.getQuantity -import static tech.units.indriya.unit.Units.CELSIUS - class ThermalHouseTest extends Specification { @Shared From a1c0c584ddbc719bdb267525dceb0a98ee4801bc Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 30 Jul 2024 13:09:17 +0200 Subject: [PATCH 009/137] Adapting some tests. --- .../model/participant/load/FixedLoadModelSpec.scala | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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..24b9150d0d 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 @@ -16,9 +16,10 @@ import edu.ie3.simona.model.participant.load.LoadReference.{ import edu.ie3.simona.test.common.input.LoadInputTestData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.scala.quantities.Kilovoltamperes import org.scalatest.prop.TableDrivenPropertyChecks import squants.Power -import squants.energy.{KilowattHours, Kilowatts, Watts} +import squants.energy.{KilowattHours, Watts} class FixedLoadModelSpec extends UnitSpec @@ -50,7 +51,7 @@ class FixedLoadModelSpec loadInput.getId, defaultOperationInterval, QControl.apply(loadInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( loadInput.getsRated .to(PowerSystemUnits.KILOWATT) .getValue @@ -84,7 +85,7 @@ class FixedLoadModelSpec loadInput.getId, defaultOperationInterval, QControl.apply(loadInput.getqCharacteristics), - Kilowatts( + Kilovoltamperes( loadInput.getsRated .to(PowerSystemUnits.KILOWATT) .getValue @@ -118,7 +119,7 @@ class FixedLoadModelSpec var scale = 0.0 while (scale <= 2) { - val scaledSRated = Kilowatts( + val scaledSRated = Kilovoltamperes( loadInput.getsRated .to(PowerSystemUnits.KILOWATT) .getValue From be9df57ea39ebed969b890462210e773942c0831 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Wed, 21 Aug 2024 13:15:09 +0200 Subject: [PATCH 010/137] Adapting some parts. --- .../edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala | 8 ++++---- .../ontology/messages/services/PrimaryDataMessage.scala | 1 - .../simona/model/participant/FixedFeedInModelSpec.scala | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala index 095d722989..bbeb263592 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala @@ -116,11 +116,11 @@ class EvcsAgent( case Event( EvFreeLotsRequest(tick), - stateData: DataCollectionStateData[ApparentPower], + stateData: DataCollectionStateData[ComplexPower], ) => stateData.baseStateData match { case modelStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, @@ -135,11 +135,11 @@ class EvcsAgent( case Event( DepartingEvsRequest(tick, departingEvs), - stateData: DataCollectionStateData[ApparentPower], + stateData: DataCollectionStateData[ComplexPower], ) => stateData.baseStateData match { case modelStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, EvcsRelevantData, EvcsState, EvcsModel, diff --git a/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala b/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala index 04fe527ee3..4f35770662 100644 --- a/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala +++ b/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala @@ -31,7 +31,6 @@ object PrimaryDataMessage { override val serviceRef: ActorRef, override val data: ComplexPower, override val nextDataTick: Option[Long], - override val unlockKey: Option[ScheduleKey] = None, ) extends ProvisionMessage[ComplexPower] with PrimaryDataMessage } diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala index f983943531..763fb4b677 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala @@ -17,6 +17,7 @@ import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.quantities.PowerSystemUnits.MEGAVOLTAMPERE import edu.ie3.util.scala.quantities.{ ApparentPower, + Kilovoltamperes, Megavoltamperes, Voltamperes, } @@ -90,7 +91,7 @@ class FixedFeedInModelSpec fixedFeedInput.getId, defaultOperationInterval, QControl.apply(fixedFeedInput.getqCharacteristics()), - Kilowatts( + Kilovoltamperes( fixedFeedInput .getsRated() .to(PowerSystemUnits.KILOWATT) From 6e9b40f1c004020a54500edc5dccc408e88c318b Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Sat, 24 Aug 2024 09:56:41 +0200 Subject: [PATCH 011/137] Refactoring of ThermalGrid.energyGrid to distinguish between demand of house and storage --- CHANGELOG.md | 1 + .../participant/hp/HpAgentFundamentals.scala | 6 +- .../simona/model/participant/HpModel.scala | 148 +++-- .../simona/model/thermal/ThermalGrid.scala | 105 +++- .../model/participant/HpModelSpec.scala | 537 ++++++++++++++---- .../ThermalGridWithHouseAndStorageSpec.scala | 72 ++- .../ThermalGridWithHouseOnlySpec.scala | 32 +- .../ThermalGridWithStorageOnlySpec.scala | 51 +- 8 files changed, 693 insertions(+), 259 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91b25a5dbf..b1de2d3306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `Gradle` to version V8.10 [#829](https://github.com/ie3-institute/simona/issues/829) - Updated AUTHORS.md [#905](https://github.com/ie3-institute/simona/issues/905) - Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin [#894](https://github.com/ie3-institute/simona/issues/894) +- Refactoring of `ThermalGrid.energyGrid` to distinguish between demand of house and storage [#928](https://github.com/ie3-institute/simona/issues/928) ### 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/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index 9add5d8ddc..7940120b4c 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -293,7 +293,11 @@ trait HpAgentFundamentals calcRelevantData: HpRelevantData, nodalVoltage: squants.Dimensionless, model: HpModel, - ): HpState = model.determineState(modelState, calcRelevantData) + ): HpState = { + val (_, _, state) = + model.determineState(modelState, calcRelevantData) + state + } /** Abstract definition, individual implementations found in individual agent * fundamental classes diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 4d9fc68899..ad512a75e0 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -11,16 +11,15 @@ import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHe import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.HpModel.{HpRelevantData, HpState} import edu.ie3.simona.model.participant.control.QControl -import edu.ie3.simona.model.thermal.ThermalGrid.ThermalGridState +import edu.ie3.simona.model.thermal.ThermalGrid.{ThermalEnergyDemand, ThermalGridState} import edu.ie3.simona.model.thermal.{ThermalGrid, ThermalThreshold} import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptions import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.DefaultQuantities import edu.ie3.util.scala.quantities.DefaultQuantities._ -import squants.energy.Kilowatts -import squants.{Power, Temperature} +import squants.energy.{KilowattHours, Kilowatts} +import squants.{Energy, Power, Temperature} import java.time.ZonedDateTime import java.util.UUID @@ -116,19 +115,23 @@ final case class HpModel( * function calculates the heat pump's next state to get the actual active * power of this state use [[calculateActivePower]] with the generated state * - * @param state - * Current state of the heat pump + * @param lastState + * Last state of the heat pump * @param relevantData * data of heat pump including * @return - * next [[HpState]] + * Booleans if Hp can operate and can be out of operation plus next + * [[HpState]] */ def determineState( - state: HpState, + lastState: HpState, relevantData: HpRelevantData, - ): HpState = { - val turnOn = operatesInNextState(state, relevantData) - calcState(state, relevantData, turnOn) + ): (Boolean, Boolean, HpState) = { + val (turnOn, canOperate, canBeOutOfOperation, houseDemand, storageDemand) = + operatesInNextState(lastState, relevantData) + val updatedState = + calcState(lastState, relevantData, turnOn, houseDemand, storageDemand) + (canOperate, canBeOutOfOperation, updatedState) } /** Depending on the input, this function decides whether the heat pump will @@ -142,18 +145,63 @@ final case class HpModel( * @param relevantData * Relevant (external) data * @return - * boolean defining if heat pump runs in next time step + * boolean defining if heat pump runs in next time step, if it can be in + * operation and out of operation plus the demand of house and storage */ private def operatesInNextState( state: HpState, relevantData: HpRelevantData, - ): Boolean = { - val demand = thermalGrid.energyDemand( - relevantData.currentTick, - relevantData.ambientTemperature, - state.thermalGridState, + ): (Boolean, Boolean, Boolean, Boolean, Boolean) = { + val (demandHouse, demandThermalStorage, updatedState) = + thermalGrid.energyDemandAndUpdatedState( + relevantData.currentTick, + state.ambientTemperature.getOrElse(relevantData.ambientTemperature), + relevantData.ambientTemperature, + state.thermalGridState, + ) + + val ( + houseDemand, + heatStorageDemand, + noThermalStorageOrThermalStorageIsEmpty, + ) = determineDemandBooleans( + state, + updatedState, + demandHouse, + demandThermalStorage, ) - demand.hasRequiredDemand || (state.isRunning && demand.hasAdditionalDemand) + + val turnHpOn: Boolean = + houseDemand || heatStorageDemand + + val canOperate = + demandHouse.hasRequiredDemand || demandHouse.hasAdditionalDemand || + demandThermalStorage.hasRequiredDemand || demandThermalStorage.hasAdditionalDemand + val canBeOutOfOperation = + !(demandHouse.hasRequiredDemand && noThermalStorageOrThermalStorageIsEmpty) + + (turnHpOn, canOperate, canBeOutOfOperation, houseDemand, heatStorageDemand) + } + + def determineDemandBooleans( + hpState: HpState, + updatedGridState: ThermalGridState, + demandHouse: ThermalEnergyDemand, + demandThermalStorage: ThermalEnergyDemand, + ): (Boolean, Boolean, Boolean) = { + implicit val tolerance: Energy = KilowattHours(1e-3) + val noThermalStorageOrThermalStorageIsEmpty: Boolean = + updatedGridState.storageState.isEmpty || updatedGridState.storageState + .exists( + _.storedEnergy =~ zeroKWH + ) + + val houseDemand = + (demandHouse.hasRequiredDemand && noThermalStorageOrThermalStorageIsEmpty) || (hpState.isRunning && demandHouse.hasAdditionalDemand) + val heatStorageDemand = { + (demandThermalStorage.hasRequiredDemand) || (hpState.isRunning && demandThermalStorage.hasAdditionalDemand) + } + (houseDemand, heatStorageDemand, noThermalStorageOrThermalStorageIsEmpty) } /** Calculate state depending on whether heat pump is needed or not. Also @@ -173,11 +221,19 @@ final case class HpModel( state: HpState, relevantData: HpRelevantData, isRunning: Boolean, + houseDemand: Boolean, + storageDemand: Boolean, ): HpState = { + val lastStateStorageqDot = state.thermalGridState.storageState + .map(_.qDot) + .getOrElse(zeroKW) + val (newActivePower, newThermalPower) = if (isRunning) (pRated, pThermal) - else (DefaultQuantities.zeroKW, DefaultQuantities.zeroKW) + else if (lastStateStorageqDot < zeroKW) + (zeroKW, lastStateStorageqDot * (-1)) + else (zeroKW, zeroKW) /* Push thermal energy to the thermal grid and get its updated state in return */ val (thermalGridState, maybeThreshold) = @@ -205,23 +261,14 @@ final case class HpModel( lastState: HpState, ): ProvideFlexOptions = { /* Determine the operating state in the given tick */ - val updatedState = determineState(lastState, data) - - /* Determine the options we have */ - val thermalEnergyDemand = thermalGrid.energyDemand( - data.currentTick, - data.ambientTemperature, - lastState.thermalGridState, - ) - val canOperate = - thermalEnergyDemand.hasRequiredDemand || thermalEnergyDemand.hasAdditionalDemand - val canBeOutOfOperation = !thermalEnergyDemand.hasRequiredDemand + val (canOperate, canBeOutOfOperation, updatedHpState) + : (Boolean, Boolean, HpState) = determineState(lastState, data) val lowerBoundary = if (canBeOutOfOperation) zeroKW else - updatedState.activePower + updatedHpState.activePower val upperBoundary = if (canOperate) sRated * cosPhiRated @@ -230,7 +277,7 @@ final case class HpModel( ProvideMinMaxFlexOptions( uuid, - updatedState.activePower, + updatedHpState.activePower, lowerBoundary, upperBoundary, ) @@ -260,13 +307,44 @@ final case class HpModel( ): (HpState, FlexChangeIndicator) = { /* If the setpoint value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */ val turnOn = setPower > (sRated * cosPhiRated * 0.5) - val updatedState = calcState(lastState, data, turnOn) + + val ( + thermalEnergyDemandHouse, + thermalEnergyDemandStorage, + updatedThermalGridState, + ) = + thermalGrid.energyDemandAndUpdatedState( + data.currentTick, + lastState.ambientTemperature.getOrElse(data.ambientTemperature), + data.ambientTemperature, + lastState.thermalGridState, + ) + + val ( + houseDemand, + heatStorageDemand, + noThermalStorageOrThermalStorageIsEmpty, + ) = determineDemandBooleans( + lastState, + updatedThermalGridState, + thermalEnergyDemandHouse, + thermalEnergyDemandStorage, + ) + + val updatedHpState: HpState = + calcState( + lastState, + data, + turnOn, + houseDemand, + heatStorageDemand, + ) ( - updatedState, + updatedHpState, FlexChangeIndicator( changesAtNextActivation = true, - updatedState.maybeThermalThreshold.map(_.tick), + updatedHpState.maybeThermalThreshold.map(_.tick), ), ) } diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 286b0e829f..3e983b6abe 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -43,60 +43,105 @@ final case class ThermalGrid( ) extends LazyLogging { /** Determine the energy demand of the total grid at the given instance in - * time + * time and returns it including the updatedState + * * @param tick * Questioned instance in time + * @param lastAmbientTemperature + * Ambient temperature until this tick * @param ambientTemperature * Ambient temperature in the instance in question * @param state * Currently applicable state of the thermal grid * @return - * The total energy demand of the grid + * The total energy demand of the house and the storage and an updated + * [[ThermalGridState]] */ - def energyDemand( + def energyDemandAndUpdatedState( tick: Long, + // FIXME this is also in state + lastAmbientTemperature: Temperature, ambientTemperature: Temperature, state: ThermalGridState, - ): ThermalEnergyDemand = { - /* First get the energy demand of the houses */ - val houseDemand = house - .zip(state.houseState) - .map { case (house, state) => - house.energyDemand( - tick, - ambientTemperature, - state, - ) + ): (ThermalEnergyDemand, ThermalEnergyDemand, ThermalGridState) = { + /* First get the energy demand of the houses but only if inner temperature is below target temperature */ + + val (houseDemand, updatedHouseState) = + house.zip(state.houseState).headOption match { + case Some((thermalHouse, lastHouseState)) => + val (updatedHouseState, updatedStorageState) = + thermalHouse.determineState( + tick, + lastHouseState, + lastAmbientTemperature, + ambientTemperature, + lastHouseState.qDot, + ) + if ( + updatedHouseState.innerTemperature < thermalHouse.targetTemperature | (lastHouseState.qDot > zeroKW && updatedHouseState.innerTemperature < thermalHouse.upperBoundaryTemperature) + ) { + ( + thermalHouse.energyDemand( + tick, + ambientTemperature, + updatedHouseState, + ), + Some(updatedHouseState), + ) + + } else { + (ThermalEnergyDemand.noDemand, Some(updatedHouseState)) + } + + case None => + (ThermalEnergyDemand.noDemand, None) } - .getOrElse(ThermalEnergyDemand.noDemand) /* Then go over the storages, see what they can provide and what they might be able to charge */ - val (storedEnergy, remainingCapacity) = { + val (storageDemand, updatedStorageState) = { + storage .zip(state.storageState) .map { case (storage, state) => - val usableEnergy = state.storedEnergy - val remaining = storage.getMaxEnergyThreshold - usableEnergy + val (updatedStorageState, _) = + storage.updateState(tick, state.qDot, state) + val storedEnergy = updatedStorageState.storedEnergy + val soc = storedEnergy / storage.getMaxEnergyThreshold + val storageRequired = { + if (soc == 0d) { + storage.getMaxEnergyThreshold - storedEnergy + + } else { + zeroMWH + } + } + + val storagePossible = storage.getMaxEnergyThreshold - storedEnergy ( - usableEnergy, - remaining, + ThermalEnergyDemand( + storageRequired, + storagePossible, + ), + Some(updatedStorageState), ) + } .getOrElse( - (zeroMWH, zeroMWH) + ThermalEnergyDemand(zeroMWH, zeroMWH), + None, ) } - val usedEnergy = - if (storedEnergy >= houseDemand.required) - houseDemand.required - else - storedEnergy - val finallyRemaining = remainingCapacity + usedEnergy - - ThermalEnergyDemand( - houseDemand.required - usedEnergy, - houseDemand.possible + finallyRemaining, + ( + ThermalEnergyDemand( + houseDemand.required, + houseDemand.possible, + ), + ThermalEnergyDemand( + storageDemand.required, + storageDemand.possible, + ), + ThermalGridState(updatedHouseState, updatedStorageState), ) } diff --git a/src/test/scala/edu/ie3/simona/model/participant/HpModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/HpModelSpec.scala index e99a5c8c26..81c62e549d 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/HpModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/HpModelSpec.scala @@ -208,14 +208,18 @@ class HpModelSpec val hp = hpModel(grid) hp.determineState(state, data) match { - case HpState( - isRunning, + case ( _, _, - activePower, - _, - ThermalGridState(Some(thermalHouseState), _), - maybeThreshold, + HpState( + isRunning, + _, + _, + activePower, + _, + ThermalGridState(Some(thermalHouseState), _), + maybeThreshold, + ), ) => isRunning shouldBe expectedRunningState activePower should approximate(Kilowatts(expectedActivePower)) @@ -234,166 +238,447 @@ class HpModelSpec "determining the flexibility options for different states" should { "deliver correct flexibility options" in { - val testCases = Table( - ("thermalState", "lastState", "expectedValues"), - // House is below lower temperature boundary - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), - Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + val testCases = + Table( + ("thermalState", "lastState", "expectedValues"), + // 1. Hp actually not running + // House is below lower temperature boundary + // Heat storage is empty + // hp must be turned on + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(0.0), + Kilowatts(0.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + None, + ), + (95.0, 95.0, 95.0), ), - HpState( - isRunning = false, - 0, - Some(hpData.ambientTemperature), - Kilowatts(0.0), - Kilowatts(0.0), + // 2. Same as before but heat storage is NOT empty + // should be possible to keep hp off + ( ThermalGridState( Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), - Some( - ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(0.0), + Kilowatts(0.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + ), ), + None, ), - None, + (0.0, 0.0, 95.0), ), - (95.0, 95.0, 95.0), - ), - // House is between target temperature and lower temperature boundary, Hp actually running - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), - Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + // 3. Hp actually running + // House is below lower temperature boundary + // Heat storage is empty + // Hp must run because of house and storage + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(0.0), + Kilowatts(0.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(0), Kilowatts(0)) + ), + ), + None, + ), + (95.0, 95.0, 95.0), ), - HpState( - isRunning = true, - 0, - Some(hpData.ambientTemperature), - Kilowatts(95.0), - Kilowatts(80.0), + // 4. Same as before but heat storage is NOT empty + // Hp should not run because of storage but can be turned on + ( ThermalGridState( - Some(ThermalHouseState(0L, Celsius(19), Kilowatts(80))), - Some( - ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(0.0), + Kilowatts(0.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(15), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + ), ), + None, ), - None, + (0.0, 0.0, 95.0), ), - (95.0, 0.0, 95.0), - ), - - // House is between target temperature and lower temperature boundary, Hp actually not running - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), - Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + // 5. Hp actually running + // House is between target temperature and lower temperature boundary + // Heat storage is empty + // Hp runs but can be turned off + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(0), Kilowatts(0)) + ), + ), + None, + ), + (95.0, 0.0, 95.0), ), - HpState( - isRunning = false, - 0, - Some(hpData.ambientTemperature), - Kilowatts(0.0), - Kilowatts(0.0), + // 6. Same as before but heat storage is NOT empty + // should be possible to keep hp off + ( ThermalGridState( Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), - Some( - ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + ), ), + None, ), - None, + (95.0, 0.0, 95.0), ), - (0.0, 0.0, 95.0), - ), - // Storage and house have remaining capacity - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(21), Kilowatts(80))), - Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + // 7. Hp actually NOT running + // House is between target temperature and lower temperature boundary + // Heat storage is empty + // Hp should run because of storage but can be turned off + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(0), Kilowatts(0)) + ), + ), + None, + ), + (95.0, 0.0, 95.0), ), - HpState( - isRunning = true, - 0, - Some(hpData.ambientTemperature), - Kilowatts(95.0), - Kilowatts(80.0), + // 8. Same as before but heat storage is NOT empty + // Hp should be off but able to turn on + ( ThermalGridState( - Some(ThermalHouseState(0L, Celsius(21), Kilowatts(80))), + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), ), - Some(HouseTemperatureUpperBoundaryReached(0L)), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(20), Kilowatts(0)) + ), + ), + None, + ), + (0.0, 0.0, 95.0), ), - (95.0, 0.0, 95.0), - ), - - // Storage is full, House has capacity till upper boundary - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(21), Kilowatts(80))), - Some(ThermalStorageState(0L, KilowattHours(500), Kilowatts(0))), + // 9. Hp actually running + // House is between target temperature and upper temperature boundary + // Heat storage is empty + // Hp will run because of storage but can be turned off + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (95.0, 0.0, 95.0), ), - HpState( - isRunning = false, - 0, - Some(hpData.ambientTemperature), - Kilowatts(0.0), - Kilowatts(0.0), + // 10. Same as before but storage is NOT empty + // Hp should run but can be turned off + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (95.0, 0.0, 95.0), + ), + // 11. Hp actually not running + // House is between target temperature and upper temperature boundary + // Heat storage is empty + // Hp should run because of storage but can be turned off + ( ThermalGridState( - Some(ThermalHouseState(0L, Celsius(21), Kilowatts(80))), - Some( - ThermalStorageState(0L, KilowattHours(500), Kilowatts(0)) + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), ), + Some(HouseTemperatureUpperBoundaryReached(0L)), ), - Some(HouseTemperatureUpperBoundaryReached(0L)), + (95.0, 0.0, 95.0), + ), + // 12. Same as before but storage is NOT empty + // Hp should not run but can be turned on for storage or house + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (0.0, 0.0, 95.0), ), - (0.0, 0.0, 95.0), - ), - // No capacity for flexibility at all because house is - // at upperTempBoundary and storage is at max capacity - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(22), Kilowatts(80))), - Some(ThermalStorageState(0L, KilowattHours(500), Kilowatts(0))), + // 13. Hp actually running + // House is at upper temperature boundary + // Heat storage is empty + // Hp should run because of storage but can be turned off + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(22), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (95.0, 0.0, 95.0), ), - HpState( - isRunning = true, - 0, - Some(hpData.ambientTemperature), - Kilowatts(95.0), - Kilowatts(80.0), + // 14. Same as before but storage is NOT empty + // Hp should run but can be turned off + ( ThermalGridState( - Some(ThermalHouseState(0L, Celsius(22), Kilowatts(80))), - Some( - ThermalStorageState(0L, KilowattHours(500), Kilowatts(0)) + Some(ThermalHouseState(0L, Celsius(22), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), ), + Some(HouseTemperatureUpperBoundaryReached(0L)), ), - Some(HouseTemperatureUpperBoundaryReached(0L)), + (95.0, 0.0, 95.0), + ), + // 15. Hp actually not running + // House is at upper temperature boundary + // Heat storage is empty + // Hp should run because of storage but can be turned off + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(22), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(0), Kilowatts(0))), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (95.0, 0.0, 95.0), ), - (0.0, 0.0, 0.0), - ), - // No capacity for flexibility at all when storage is full and house has been (externally) heated up above upperTemperatureBoundary - ( - ThermalGridState( - Some(ThermalHouseState(0L, Celsius(25), Kilowatts(0))), - Some(ThermalStorageState(0L, KilowattHours(500), Kilowatts(0))), + // 16. Same as before but storage is NOT empty + // Hp should not run but can be turned on for storage + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(22), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(20), Kilowatts(0))), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (0.0, 0.0, 95.0), ), - HpState( - isRunning = false, - 0, - Some(hpData.ambientTemperature), - Kilowatts(95.0), - Kilowatts(80.0), + + // Storage is full, House has capacity till upper boundary + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(21), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(500), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(0.0), + Kilowatts(0.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(19), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(500), Kilowatts(0)) + ), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (0.0, 0.0, 95.0), + ), + // No capacity for flexibility at all because house is + // at upperTempBoundary and storage is at max capacity + ( + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(22), Kilowatts(0))), + Some(ThermalStorageState(0L, KilowattHours(500), Kilowatts(0))), + ), + HpState( + isRunning = true, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(22), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(500), Kilowatts(0)) + ), + ), + Some(HouseTemperatureUpperBoundaryReached(0L)), + ), + (0.0, 0.0, 0.0), + ), + + // No capacity for flexibility at all when storage is full and house has been (externally) heated up above upperTemperatureBoundary + ( ThermalGridState( Some(ThermalHouseState(0L, Celsius(25), Kilowatts(0))), - Some( - ThermalStorageState(0L, KilowattHours(500), Kilowatts(0)) + Some(ThermalStorageState(0L, KilowattHours(500), Kilowatts(0))), + ), + HpState( + isRunning = false, + 0, + Some(hpData.ambientTemperature), + Kilowatts(95.0), + Kilowatts(80.0), + ThermalGridState( + Some(ThermalHouseState(0L, Celsius(25), Kilowatts(0))), + Some( + ThermalStorageState(0L, KilowattHours(500), Kilowatts(0)) + ), ), + None, ), - None, + (0.0, 0.0, 0.0), ), - (0.0, 0.0, 0.0), - ), - ) + ) // Run the test cases forAll(testCases) { 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 5d4fe69d88..1ea45a656d 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala @@ -96,53 +96,51 @@ class ThermalGridWithHouseAndStorageSpec "deliver the house demand (no demand) with added flexibility by storage" in { val tick = 10800 // after three hours - val gridDemand = thermalGrid.energyDemand( - tick, - testGridAmbientTemperature, - ThermalGrid.startingState(thermalGrid), + val (houseDemand, storageDemand, updatedThermalGridState) = + thermalGrid.energyDemandAndUpdatedState( + tick, + testGridAmbientTemperature, + testGridAmbientTemperature, + ThermalGrid.startingState(thermalGrid), + ) + houseDemand.required should approximate(KilowattHours(0d)) + houseDemand.possible should approximate(KilowattHours(31.05009722d)) + storageDemand.required should approximate(KilowattHours(1150d)) + storageDemand.possible should approximate(KilowattHours(1150d)) + updatedThermalGridState.houseState shouldBe Some( + ThermalHouseState(10800, Kelvin(292.0799935185185), Kilowatts(0d)) ) - - gridDemand.required should approximate(KilowattHours(0d)) - gridDemand.possible should approximate( - KilowattHours(31.05009722 + 1150) + updatedThermalGridState.storageState shouldBe Some( + ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d)) ) } - "consider stored energy to reduce house demand" in { + "deliver the correct house and storage demand" in { val tick = 10800 // after three hours val startingState = ThermalGrid.startingState(thermalGrid) - val gridDemand = thermalGrid.energyDemand( - tick, - testGridAmbientTemperature, - startingState.copy(houseState = - startingState.houseState.map( - _.copy(innerTemperature = Celsius(16d)) - ) - ), - ) - - 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 { - val tick = 10800 // after three hours + val (houseDemand, storageDemand, updatedThermalGridState) = + thermalGrid.energyDemandAndUpdatedState( + tick, + testGridAmbientTemperature, + testGridAmbientTemperature, + startingState.copy(houseState = + startingState.houseState.map( + _.copy(innerTemperature = Celsius(16d)) + ) + ), + ) - val startingState = ThermalGrid.startingState(thermalGrid) - val gridDemand = thermalGrid.energyDemand( - tick, - testGridAmbientTemperature, - startingState.copy(houseState = - startingState.houseState.map( - _.copy(innerTemperature = Celsius(3d)) - ) - ), + houseDemand.required should approximate(KilowattHours(45.6000555)) + houseDemand.possible should approximate(KilowattHours(75.600055555)) + storageDemand.required should approximate(KilowattHours(1150d)) + storageDemand.possible should approximate(KilowattHours(1150d)) + updatedThermalGridState.houseState shouldBe Some( + ThermalHouseState(10800, Celsius(15.959996296296296), Kilowatts(0d)) ) - gridDemand.required should approximate( - KilowattHours(238.64987499999984) + updatedThermalGridState.storageState shouldBe Some( + ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d)) ) - gridDemand.possible should approximate(KilowattHours(1418.64987499999)) } } diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala index d2b48ff3b3..eb447d0fc4 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala @@ -14,9 +14,9 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{ HouseTemperatureUpperBoundaryReached, } import edu.ie3.simona.test.common.UnitSpec -import squants.energy.{Kilowatts, Megawatts, WattHours, Watts} +import squants.energy._ import squants.thermal.Celsius -import squants.{Energy, Power, Temperature} +import squants.{Energy, Kelvin, Power, Temperature} import scala.jdk.CollectionConverters._ @@ -73,21 +73,29 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { "determining the energy demand" should { "exactly be the demand of the house" in { - val tick = 10800 // after three house - val houseDemand = thermalHouse.energyDemand( + val tick = 10800 // after three hours + val expectedHouseDemand = thermalHouse.energyDemand( tick, testGridAmbientTemperature, expectedHouseStartingState, ) - val gridDemand = thermalGrid.energyDemand( - tick, - testGridAmbientTemperature, - ThermalGrid.startingState(thermalGrid), - ) + val (houseDemand, storageDemand, updatedThermalGridState) = + thermalGrid.energyDemandAndUpdatedState( + tick, + testGridAmbientTemperature, + testGridAmbientTemperature, + ThermalGrid.startingState(thermalGrid), + ) - gridDemand.required should approximate(houseDemand.required) - gridDemand.possible should approximate(houseDemand.possible) + houseDemand.required should approximate(expectedHouseDemand.required) + houseDemand.possible should approximate(expectedHouseDemand.possible) + storageDemand.required should approximate(KilowattHours(0d)) + storageDemand.possible should approximate(KilowattHours(0d)) + updatedThermalGridState.houseState shouldBe Some( + ThermalHouseState(10800, Kelvin(292.0799935185185), Kilowatts(0d)) + ) + updatedThermalGridState.storageState shouldBe None } } @@ -127,7 +135,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { } "not withdraw energy from the house, if actual consumption is given" in { - val tick = 0L // after three house + val tick = 0L // after three hours val gridState = ThermalGrid.startingState(thermalGrid) val (updatedGridState, reachedThreshold) = 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 bbb804c35f..93a45e3180 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala @@ -80,31 +80,46 @@ class ThermalGridWithStorageOnlySpec "deliver the capabilities of the storage" in { val tick = 10800 // after three hours - val gridDemand = thermalGrid.energyDemand( - tick, - testGridAmbientTemperature, - ThermalGrid.startingState(thermalGrid), - ) - - gridDemand.required should approximate(KilowattHours(0d)) - gridDemand.possible should approximate(KilowattHours(1150d)) + val (houseDemand, storageDemand, updatedThermalGridState) = + thermalGrid.energyDemandAndUpdatedState( + tick, + testGridAmbientTemperature, + testGridAmbientTemperature, + ThermalGrid.startingState(thermalGrid), + ) + houseDemand.required should approximate(KilowattHours(0d)) + houseDemand.possible should approximate(KilowattHours(0d)) + storageDemand.required should approximate(KilowattHours(1150d)) + storageDemand.possible should approximate(KilowattHours(1150d)) + updatedThermalGridState.houseState shouldBe None + updatedThermalGridState.storageState shouldBe Some( + ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d)) + ) } "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))), - ), - ) + val (houseDemand, storageDemand, updatedThermalGridState) = + thermalGrid.energyDemandAndUpdatedState( + tick, + testGridAmbientTemperature, + testGridAmbientTemperature, + ThermalGridState( + None, + Some(ThermalStorageState(0L, KilowattHours(575d), Kilowatts(0d))), + ), + ) - gridDemand.required should approximate(KilowattHours(0d)) - gridDemand.possible should approximate(KilowattHours(575d)) + houseDemand.required should approximate(KilowattHours(0d)) + houseDemand.possible should approximate(KilowattHours(0d)) + storageDemand.required should approximate(KilowattHours(0d)) + storageDemand.possible should approximate(KilowattHours(575d)) + updatedThermalGridState.houseState shouldBe None + updatedThermalGridState.storageState shouldBe Some( + ThermalStorageState(10800L, KilowattHours(575d), Kilowatts(0d)) + ) } } From 67e2a4e433b0c7d5ef8931ae95299de116f15066 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Sat, 24 Aug 2024 10:00:39 +0200 Subject: [PATCH 012/137] fmt --- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index ad512a75e0..569bd48c10 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -11,7 +11,10 @@ import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHe import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.HpModel.{HpRelevantData, HpState} import edu.ie3.simona.model.participant.control.QControl -import edu.ie3.simona.model.thermal.ThermalGrid.{ThermalEnergyDemand, ThermalGridState} +import edu.ie3.simona.model.thermal.ThermalGrid.{ + ThermalEnergyDemand, + ThermalGridState, +} import edu.ie3.simona.model.thermal.{ThermalGrid, ThermalThreshold} import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.ProvideFlexOptions import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions From 1ec348cc749eccd6a27a21d044ee5efca8cde191 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Sat, 24 Aug 2024 11:10:56 +0200 Subject: [PATCH 013/137] Add unapply method for ThermalHouseResults --- CHANGELOG.md | 1 + .../edu/ie3/simona/agent/ValueStore.scala | 2 +- .../ParticipantAgentFundamentals.scala | 5 +- .../edu/ie3/simona/event/ResultEvent.scala | 59 ++++++++++++++++++- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b43cb834c8..2b39983e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update RTD references and bibliography [#868](https://github.com/ie3-institute/simona/issues/868) - Add gradle application plugin for command line execution with gradle run [#890](https://github.com/ie3-institute/simona/issues/890) - Additional tests to check flexibility options of thermal house and storage [#729](https://github.com/ie3-institute/simona/issues/729) +- Add unapply method for ThermalHouseResults [#934](https://github.com/ie3-institute/simona/issues/934) ### Changed - Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435) diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index a21f7d0f58..fbae2ff77c 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -22,7 +22,7 @@ import scala.collection.SortedMap */ final case class ValueStore[+D]( maxTickSpan: Long, - private val store: SortedMap[Long, D] = SortedMap.empty[Long, D], + store: SortedMap[Long, D] = SortedMap.empty[Long, D], ) { /** Determine the lastly known data tick, if available. Includes the given 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..fe78e9136f 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -1907,8 +1907,9 @@ protected trait ParticipantAgentFundamentals[ def buildResultEvent[R <: ResultEntity]( result: R ): Option[ResultEvent] = result match { - case thermalResult: ThermalUnitResult => - Some(ThermalResultEvent(thermalResult)) + case thermalUnitResult: ThermalUnitResult => + Some(ThermalResultEvent(thermalUnitResult)) + case unsupported => log.debug( s"Results of class '${unsupported.getClass.getSimpleName}' are currently not supported." diff --git a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala index d81242c608..a1a765d977 100644 --- a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala @@ -16,9 +16,18 @@ import edu.ie3.datamodel.models.result.system.{ FlexOptionsResult, SystemParticipantResult, } -import edu.ie3.datamodel.models.result.thermal.ThermalUnitResult +import edu.ie3.datamodel.models.result.thermal.{ + CylindricalStorageResult, + ThermalHouseResult, + ThermalUnitResult, +} import edu.ie3.simona.agent.grid.GridResultsSupport.PartialTransformer3wResult import edu.ie3.simona.event.listener.ResultEventListener +import tech.units.indriya.ComparableQuantity + +import java.time.ZonedDateTime +import java.util.UUID +import javax.measure.quantity.{Energy, Power, Temperature} sealed trait ResultEvent extends Event with ResultEventListener.Request @@ -44,6 +53,54 @@ object ResultEvent { thermalResult: ThermalUnitResult ) extends ResultEvent + object ThermalHouseResult { + def unapply(result: ThermalHouseResult): Option[ + ( + ZonedDateTime, + UUID, + ComparableQuantity[Power], + ComparableQuantity[Temperature], + ) + ] = { + if (result != null) { + Some( + ( + result.getTime, + result.getInputModel, + result.getqDot, + result.getIndoorTemperature, + ) + ) + } else { + None + } + } + } + + object CylindricalThermalStorageResult { + def unapply(result: CylindricalStorageResult): Option[ + ( + ZonedDateTime, + UUID, + ComparableQuantity[Power], + ComparableQuantity[Energy], + ) + ] = { + if (result != null) { + Some( + ( + result.getTime, + result.getInputModel, + result.getqDot, + result.getEnergy, + ) + ) + } else { + None + } + } + } + /** Event that holds all grid calculation results of a power flow calculation. * The usage of a type is necessary here, to avoid passing in other instances * of [[edu.ie3.datamodel.models.result.ResultEntity]] except of the wanted From 707e0f30fdb303f5d370b54c909de049b620d47f Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 6 Sep 2024 14:00:50 +0200 Subject: [PATCH 014/137] Renaming some `ApparentPower` to `ComplexPower`. --- .../edu/ie3/simona/agent/em/EmAgent.scala | 4 +- .../edu/ie3/simona/agent/em/EmDataCore.scala | 8 +- .../agent/em/FlexCorrespondenceStore.scala | 4 +- .../ParticipantAgentFundamentals.scala | 12 +-- .../simona/agent/participant/data/Data.scala | 54 ++++++------ .../data/primary/PrimaryDataService.scala | 6 +- .../agent/participant/evcs/EvcsAgent.scala | 2 +- .../evcs/EvcsAgentFundamentals.scala | 4 +- .../fixedfeedin/FixedFeedInAgent.scala | 4 +- .../FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/hp/HpAgent.scala | 4 +- .../participant/hp/HpAgentFundamentals.scala | 4 +- .../agent/participant/load/LoadAgent.scala | 4 +- .../load/LoadAgentFundamentals.scala | 2 +- .../simona/agent/participant/pv/PvAgent.scala | 4 +- .../participant/pv/PvAgentFundamentals.scala | 2 +- .../participant/storage/StorageAgent.scala | 4 +- .../storage/StorageAgentFundamentals.scala | 46 +++++------ .../agent/participant/wec/WecAgent.scala | 4 +- .../wec/WecAgentFundamentals.scala | 2 +- .../ApparentPowerAndHeatParticipant.scala | 8 +- .../ApparentPowerParticipant.scala | 6 +- .../simona/model/participant/BMModel.scala | 4 +- .../simona/model/participant/ChpModel.scala | 4 +- .../model/participant/FixedFeedInModel.scala | 4 +- .../simona/model/participant/HpModel.scala | 4 +- .../simona/model/participant/PvModel.scala | 4 +- .../model/participant/StorageModel.scala | 4 +- .../model/participant/SystemParticipant.scala | 2 +- .../simona/model/participant/WecModel.scala | 4 +- .../model/participant/evcs/EvcsModel.scala | 4 +- .../model/participant/load/LoadModel.scala | 4 +- .../messages/flex/FlexibilityMessage.scala | 4 +- .../services/PrimaryDataMessage.scala | 4 +- .../test/common/model/MockParticipant.groovy | 4 +- .../edu/ie3/simona/agent/em/EmAgentSpec.scala | 30 +++---- .../EvcsAgentModelCalculationSpec.scala | 14 ++-- ...FixedFeedInAgentModelCalculationSpec.scala | 12 +-- .../HpAgentModelCalculationSpec.scala | 16 ++-- .../LoadAgentFixedModelCalculationSpec.scala | 12 +-- ...LoadAgentProfileModelCalculationSpec.scala | 12 +-- .../ParticipantAgent2ListenerSpec.scala | 6 +- .../ParticipantAgentExternalSourceSpec.scala | 76 ++++++++--------- .../ParticipantAgentFundamentalsSpec.scala | 80 +++++++++--------- .../participant/ParticipantAgentMock.scala | 82 +++++++++---------- .../PvAgentModelCalculationSpec.scala | 16 ++-- .../agent/participant/RichValueSpec.scala | 8 +- .../StorageAgentModelCalculationSpec.scala | 10 +-- .../WecAgentModelCalculationSpec.scala | 28 +++---- .../ApparentPowerAndHeatSpec.scala | 8 +- .../model/participant/BMModelSpec.scala | 12 +-- .../primary/PrimaryServiceWorkerSqlIT.scala | 4 +- 52 files changed, 311 insertions(+), 355 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala b/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala index 3bbbef2382..aea59cdae0 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.em import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.result.system.{EmResult, FlexOptionsResult} -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.statedata.BaseStateData.FlexControlledData import edu.ie3.simona.config.SimonaConfig.EmRuntimeConfig import edu.ie3.simona.event.ResultEvent diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala index 8f6f3df941..400047a4bf 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala @@ -6,12 +6,10 @@ package edu.ie3.simona.agent.em +import edu.ie3.simona.agent.em.EmAgent.Actor +import edu.ie3.simona.agent.em.FlexCorrespondenceStore.WithTime +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.exceptions.CriticalFailureException -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} -import EmAgent.Actor -import FlexCorrespondenceStore.WithTime import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage._ import edu.ie3.util.scala.collection.mutable.PriorityMultiBiSet import squants.Power diff --git a/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala b/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala index aa4cca4b47..8d4a12445c 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/FlexCorrespondenceStore.scala @@ -10,9 +10,7 @@ import edu.ie3.simona.agent.em.FlexCorrespondenceStore.{ FlexCorrespondence, WithTime, } -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage.{ IssueFlexControl, ProvideFlexOptions, 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 bdb53a3fc3..c8c10da18d 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -23,8 +23,8 @@ import edu.ie3.simona.agent.participant.ParticipantAgent.StartCalculationTrigger import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals.RelevantResultValues import edu.ie3.simona.agent.participant.data.Data import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, - ApparentPowerAndHeat => ComplexPowerAndHeat, + ComplexPower, + ComplexPowerAndHeat, EnrichableData, PrimaryDataWithApparentPower, } @@ -799,7 +799,7 @@ protected trait ParticipantAgentFundamentals[ flexStateData.emAgent ! FlexCtrlCompletion( baseStateData.modelUuid, - result.primaryData.toApparentPower, + result.primaryData.toComplexPower, flexChangeIndicator.changesAtNextActivation, nextActivation, ) @@ -1734,7 +1734,7 @@ protected trait ParticipantAgentFundamentals[ baseStateData.foreseenDataTicks, ) - averageResult.toApparentPower match { + averageResult.toComplexPower match { case ComplexPower(p, q) => stay() using nextStateData replying AssetPowerChangedMessage(p, q) } @@ -2028,8 +2028,8 @@ object ParticipantAgentFundamentals { case Some(qFunc) => // NOTE: The type conversion to Megawatts is done to satisfy the methods type constraints // and is undone after unpacking the results - tick -> Megawatts(qFunc(pd.toApparentPower.p).toMegavars) - case None => tick -> Megawatts(pd.toApparentPower.q.toMegavars) + tick -> Megawatts(qFunc(pd.toComplexPower.p).toMegavars) + case None => tick -> Megawatts(pd.toComplexPower.q.toMegavars) } }, windowStart, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/data/Data.scala b/src/main/scala/edu/ie3/simona/agent/participant/data/Data.scala index cb56e1af92..7da7b04c5c 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/data/Data.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/data/Data.scala @@ -7,13 +7,13 @@ package edu.ie3.simona.agent.participant.data import edu.ie3.datamodel.models.value._ -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.quantities.interfaces.EnergyPrice -import edu.ie3.util.scala.quantities.{Kilovars, Megavars, ReactivePower} -import squants.energy.{Power, Kilowatts, Megawatts} -import tech.units.indriya.ComparableQuantity import edu.ie3.util.scala.quantities.DefaultQuantities._ +import edu.ie3.util.scala.quantities.{Kilovars, ReactivePower} +import squants.energy.{Kilowatts, Power} +import tech.units.indriya.ComparableQuantity import java.time.ZonedDateTime import scala.jdk.OptionConverters.RichOptional @@ -36,7 +36,7 @@ object Data { */ sealed trait PrimaryData extends Data { val p: Power - def toApparentPower: ApparentPower + def toComplexPower: ComplexPower } object PrimaryData { @@ -61,7 +61,7 @@ object Data { val qDot: Power } - val ZERO_POWER: ApparentPower = ApparentPower(zeroMW, zeroMVAr) + val ZERO_POWER: ComplexPower = ComplexPower(zeroMW, zeroMVAr) /** Active power as participant simulation result * @@ -70,15 +70,15 @@ object Data { */ final case class ActivePower(override val p: Power) extends PrimaryData - with EnrichableData[ApparentPower] { - override def toApparentPower: ApparentPower = - ApparentPower( + with EnrichableData[ComplexPower] { + override def toComplexPower: ComplexPower = + ComplexPower( p, zeroMVAr, ) - override def add(q: ReactivePower): ApparentPower = - ApparentPower(p, q) + override def add(q: ReactivePower): ComplexPower = + ComplexPower(p, q) } /** Active and Reactive power as participant simulation result @@ -88,13 +88,13 @@ object Data { * @param q * Reactive power */ - final case class ApparentPower( + final case class ComplexPower( override val p: Power, override val q: ReactivePower, - ) extends PrimaryDataWithApparentPower[ApparentPower] { - override def toApparentPower: ApparentPower = this + ) extends PrimaryDataWithApparentPower[ComplexPower] { + override def toComplexPower: ComplexPower = this - override def withReactivePower(q: ReactivePower): ApparentPower = + override def withReactivePower(q: ReactivePower): ComplexPower = copy(q = q) } @@ -110,15 +110,15 @@ object Data { override val qDot: Power, ) extends PrimaryData with Heat - with EnrichableData[ApparentPowerAndHeat] { - override def toApparentPower: ApparentPower = - ApparentPower( + with EnrichableData[ComplexPowerAndHeat] { + override def toComplexPower: ComplexPower = + ComplexPower( p, zeroMVAr, ) - override def add(q: ReactivePower): ApparentPowerAndHeat = - ApparentPowerAndHeat(p, q, qDot) + override def add(q: ReactivePower): ComplexPowerAndHeat = + ComplexPowerAndHeat(p, q, qDot) } /** Apparent power and heat demand as participant simulation result @@ -130,16 +130,16 @@ object Data { * @param qDot * Heat demand */ - final case class ApparentPowerAndHeat( + final case class ComplexPowerAndHeat( override val p: Power, override val q: ReactivePower, override val qDot: Power, - ) extends PrimaryDataWithApparentPower[ApparentPowerAndHeat] + ) extends PrimaryDataWithApparentPower[ComplexPowerAndHeat] with Heat { - override def toApparentPower: ApparentPower = - ApparentPower(p, q) + override def toComplexPower: ComplexPower = + ComplexPower(p, q) - override def withReactivePower(q: ReactivePower): ApparentPowerAndHeat = + override def withReactivePower(q: ReactivePower): ComplexPowerAndHeat = copy(q = q) } @@ -150,7 +150,7 @@ object Data { (hs.getP.toScala, hs.getQ.toScala, hs.getHeatDemand.toScala) match { case (Some(p), Some(q), Some(qDot)) => Success( - ApparentPowerAndHeat( + ComplexPowerAndHeat( Kilowatts( p.to(PowerSystemUnits.KILOWATT).getValue.doubleValue ), @@ -173,7 +173,7 @@ object Data { (s.getP.toScala, s.getQ.toScala) match { case (Some(p), Some(q)) => Success( - ApparentPower( + ComplexPower( Kilowatts( p.to(PowerSystemUnits.KILOWATT).getValue.doubleValue ), diff --git a/src/main/scala/edu/ie3/simona/agent/participant/data/primary/PrimaryDataService.scala b/src/main/scala/edu/ie3/simona/agent/participant/data/primary/PrimaryDataService.scala index 33cb4b7519..92c4e510d3 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/data/primary/PrimaryDataService.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/data/primary/PrimaryDataService.scala @@ -6,10 +6,10 @@ package edu.ie3.simona.agent.participant.data.primary -import org.apache.pekko.actor.ActorRef import edu.ie3.simona.agent.participant.data.Data.PrimaryData -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.data.DataService +import org.apache.pekko.actor.ActorRef /** Enum-like trait to denote possible external data sources for systems */ @@ -23,5 +23,5 @@ object PrimaryDataService { * actor reference of the actual source */ final case class DummyPrimaryService(override val actorRef: ActorRef) - extends PrimaryDataService[ApparentPower] + extends PrimaryDataService[ComplexPower] } diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala index bbeb263592..5b37ae70e3 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala @@ -8,7 +8,7 @@ package edu.ie3.simona.agent.participant.evcs import edu.ie3.datamodel.models.input.system.EvcsInput import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala index 4d5fd31994..0b3798a6ab 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala @@ -16,9 +16,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.grid.GridAgentMessages.AssetPowerChangedMessage import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.data.Data.SecondaryData import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorExtEvDataService diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala index 466ca9d070..38826657e2 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.participant.fixedfeedin import edu.ie3.datamodel.models.input.system.FixedFeedInInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.statedata.ParticipantStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.ParticipantInitializeStateData import edu.ie3.simona.config.SimonaConfig.FixedFeedInRuntimeConfig diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index a4a6019e26..0960618890 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -16,7 +16,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala index 6bec55f80a..7861575ef5 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.participant.hp import edu.ie3.datamodel.models.input.system.HpInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPowerAndHeat => ComplexPowerAndHeat -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPowerAndHeat import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.ParticipantStateData diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index 71b584cc49..27ef1cefd0 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -15,9 +15,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPowerAndHeat => ComplexPowerAndHeat -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPowerAndHeat import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.hp.HpAgent.neededServices import edu.ie3.simona.agent.participant.statedata.BaseStateData.{ diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala index 05c97cbecf..67607acbf1 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.participant.load import edu.ie3.datamodel.models.input.system.LoadInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.load.LoadAgentFundamentals.{ FixedLoadAgentFundamentals, ProfileLoadAgentFundamentals, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 943069c16b..88d69b10c8 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -16,7 +16,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala index 325159f08e..a46f7478a8 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.participant.pv import edu.ie3.datamodel.models.input.system.PvInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.ParticipantStateData diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index 11891f76ca..f84d69306b 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -16,7 +16,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData diff --git a/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala index 5956f53822..84eda8c92b 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.participant.storage import edu.ie3.datamodel.models.input.system.StorageInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.statedata.ParticipantStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.ParticipantInitializeStateData import edu.ie3.simona.config.SimonaConfig.StorageRuntimeConfig diff --git a/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgentFundamentals.scala index 574cbbfbf7..bfa312e68a 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/storage/StorageAgentFundamentals.scala @@ -17,7 +17,7 @@ import edu.ie3.simona.agent.participant.ParticipantAgent.getAndCheckNodalVoltage import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService @@ -65,19 +65,19 @@ import scala.reflect.{ClassTag, classTag} trait StorageAgentFundamentals extends ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], StorageInput, StorageRuntimeConfig, StorageModel, ] { this: StorageAgent => - override val alternativeResult: ApparentPower = ZERO_POWER + override val alternativeResult: ComplexPower = ZERO_POWER - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] /** Abstract definition, individual implementations found in individual agent * fundamental classes @@ -93,7 +93,7 @@ trait StorageAgentFundamentals outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): BaseStateData.ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -113,7 +113,7 @@ trait StorageAgentFundamentals ) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -162,7 +162,7 @@ trait StorageAgentFundamentals override protected def createInitialState( baseStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -175,7 +175,7 @@ trait StorageAgentFundamentals override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -187,14 +187,14 @@ trait StorageAgentFundamentals override val calculateModelPowerFunc: ( Long, BaseStateData.ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, ], StorageState, Dimensionless, - ) => ApparentPower = + ) => ComplexPower = (_, _, _, _) => throw new InvalidRequestException( "Storage model cannot be run without secondary data." @@ -202,7 +202,7 @@ trait StorageAgentFundamentals override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -216,13 +216,13 @@ trait StorageAgentFundamentals ) override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ Power => ReactivePower ], - ): ApparentPower = ParticipantAgentFundamentals.averageApparentPower( + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, windowEnd, @@ -233,7 +233,7 @@ trait StorageAgentFundamentals override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new StorageResult( dateTime, uuid, @@ -256,15 +256,15 @@ trait StorageAgentFundamentals */ override protected def handleCalculatedResult( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, ], - result: AccompaniedSimulationResult[ApparentPower], + result: AccompaniedSimulationResult[ComplexPower], currentTick: Long, ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -325,7 +325,7 @@ trait StorageAgentFundamentals override def handleControlledPowerChange( tick: Long, baseStateData: BaseStateData.ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, StorageRelevantData, StorageState, StorageModel, @@ -335,7 +335,7 @@ trait StorageAgentFundamentals setPower: Power, ): ( StorageState, - AccompaniedSimulationResult[ApparentPower], + AccompaniedSimulationResult[ComplexPower], FlexChangeIndicator, ) = { val (updatedState, flexChangeIndicator) = @@ -350,9 +350,9 @@ trait StorageAgentFundamentals voltage, ) - val apparentPower = ApparentPower(updatedSetPower, reactivePower) + val apparentPower = ComplexPower(updatedSetPower, reactivePower) - val result: AccompaniedSimulationResult[ApparentPower] = + val result: AccompaniedSimulationResult[ComplexPower] = AccompaniedSimulationResult(apparentPower, Seq.empty[ResultEntity]) (updatedState, result, flexChangeIndicator) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala index 0466b7765d..f8858ded76 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgent.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.agent.participant.wec import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.simona.agent.participant.ParticipantAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.ParticipantStateData diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala index da05d47468..01c903dba1 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala @@ -16,7 +16,7 @@ import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgent._ import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData diff --git a/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatParticipant.scala index eb51174cb5..b9476aae14 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatParticipant.scala @@ -6,7 +6,7 @@ package edu.ie3.simona.model.participant -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHeat +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPowerAndHeat import edu.ie3.util.scala.quantities.DefaultQuantities._ import squants.{Dimensionless, Power} @@ -14,13 +14,13 @@ trait ApparentPowerAndHeatParticipant[ CD <: CalcRelevantData, MS <: ModelState, ] { - this: SystemParticipant[CD, ApparentPowerAndHeat, MS] => + this: SystemParticipant[CD, ComplexPowerAndHeat, MS] => override def calculatePower( tick: Long, voltage: Dimensionless, modelState: MS, data: CD, - ): ApparentPowerAndHeat = { + ): ComplexPowerAndHeat = { val apparentPower = calculateApparentPower(tick, voltage, modelState, data) val heat = @@ -29,7 +29,7 @@ trait ApparentPowerAndHeatParticipant[ else zeroMW - ApparentPowerAndHeat(apparentPower.p, apparentPower.q, heat) + ComplexPowerAndHeat(apparentPower.p, apparentPower.q, heat) } /** Calculate the heat of the asset. As for electrical assets, positive values diff --git a/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerParticipant.scala index d1d71a58ac..e630c7fb5c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ApparentPowerParticipant.scala @@ -6,16 +6,16 @@ package edu.ie3.simona.model.participant -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import squants.Dimensionless trait ApparentPowerParticipant[CD <: CalcRelevantData, MS <: ModelState] { - this: SystemParticipant[CD, ApparentPower, MS] => + this: SystemParticipant[CD, ComplexPower, MS] => override def calculatePower( tick: Long, voltage: Dimensionless, modelState: MS, data: CD, - ): ApparentPower = + ): ComplexPower = calculateApparentPower(tick, voltage, modelState, data) } diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index ad447896cd..7961758da9 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -6,9 +6,7 @@ package edu.ie3.simona.model.participant -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.participant.BMModel.BMCalcRelevantData import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.control.QControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 9005760064..36a420806f 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -7,9 +7,7 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.ChpInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ChpModel._ import edu.ie3.simona.model.participant.ModelState.ConstantState diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index d5159df267..ad76fbbddb 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.model.participant import com.typesafe.scalalogging.LazyLogging import edu.ie3.datamodel.models.input.system.FixedFeedInInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.config.SimonaConfig import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.CalcRelevantData.FixedRelevantData diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index c622d77b5d..48e3e1b11a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -7,9 +7,7 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.HpInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPowerAndHeat => ComplexPowerAndHeat -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPowerAndHeat import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.HpModel.{HpRelevantData, HpState} import edu.ie3.simona.model.participant.control.QControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala index 8262252bf0..581afdeb65 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala @@ -7,9 +7,7 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.PvInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.PvModel.PvRelevantData diff --git a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala index 2bd5a3b8e1..6d53c05466 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala @@ -7,9 +7,7 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.StorageInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.StorageModel.{ RefTargetSocParams, diff --git a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala index 5a12280db2..f70d9f2e05 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala @@ -7,8 +7,8 @@ package edu.ie3.simona.model.participant import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ + ComplexPower, PrimaryDataWithApparentPower, - ApparentPower => ComplexPower, } import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.control.QControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index c035527d94..e7345fbc8e 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.WecModel.{ diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index 59582f95ff..d8f904fbce 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -11,9 +11,7 @@ import edu.ie3.datamodel.models.ElectricCurrentType import edu.ie3.datamodel.models.input.system.EvcsInput import edu.ie3.datamodel.models.input.system.`type`.evcslocation.EvcsLocationType import edu.ie3.datamodel.models.result.system.{EvResult, EvcsResult} -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.SystemComponent import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.model.participant.evcs.EvcsModel._ diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala index f30a179a25..78378893a5 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.model.participant.load import com.typesafe.scalalogging.LazyLogging import edu.ie3.datamodel.models.input.system.LoadInput -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.model.participant.CalcRelevantData.LoadRelevantData import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.control.QControl diff --git a/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala b/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala index 6715abd69d..e34201290d 100644 --- a/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala +++ b/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala @@ -8,9 +8,7 @@ package edu.ie3.simona.ontology.messages.flex import edu.ie3.datamodel.models.input.AssetInput import edu.ie3.simona.agent.em.EmAgent -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.scheduler.ScheduleLock.ScheduleKey import org.apache.pekko.actor.typed.ActorRef import squants.Power diff --git a/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala b/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala index 4f35770662..f78e1f5fe4 100644 --- a/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala +++ b/src/main/scala/edu/ie3/simona/ontology/messages/services/PrimaryDataMessage.scala @@ -6,9 +6,7 @@ package edu.ie3.simona.ontology.messages.services -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower => ComplexPower -} +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.ontology.messages.services.ServiceMessage.ProvisionMessage import org.apache.pekko.actor.ActorRef diff --git a/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy b/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy index ccdc786b96..3af256e814 100644 --- a/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy +++ b/src/test/groovy/edu/ie3/simona/test/common/model/MockParticipant.groovy @@ -19,7 +19,7 @@ import scala.Tuple2 import squants.Dimensionless import squants.energy.* -class MockParticipant extends SystemParticipant { +class MockParticipant extends SystemParticipant { MockParticipant( UUID uuid, @@ -40,7 +40,7 @@ class MockParticipant extends SystemParticipant Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPower](resolution) + requestValueStore shouldBe ValueStore[ComplexPower](resolution) /* Additional information */ awaitRegistrationResponsesFrom shouldBe Iterable(evService.ref) @@ -389,11 +389,11 @@ class EvcsAgentModelCalculationSpec inside(evcsAgent.stateData) { case baseStateData: ParticipantModelBaseStateData[_, _, _, _] => baseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ) @@ -1167,7 +1167,7 @@ class EvcsAgentModelCalculationSpec resultValueStore shouldBe ValueStore( resolution ) - requestValueStore shouldBe ValueStore[ApparentPower]( + requestValueStore shouldBe ValueStore[ComplexPower]( resolution ) case unrecognized => 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..dc041f0efa 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/FixedFeedInAgentModelCalculationSpec.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{ AssetPowerUnchangedMessage, } import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.fixedfeedin.FixedFeedInAgent import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.{ @@ -105,7 +105,7 @@ class FixedFeedInAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ FixedFeedInInput, FixedFeedInRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, modelConfig = modelConfig, @@ -221,7 +221,7 @@ class FixedFeedInAgentModelCalculationSpec SortedMap(0L -> Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPower]( + requestValueStore shouldBe ValueStore[ComplexPower]( resolution ) case _ => @@ -270,11 +270,11 @@ class FixedFeedInAgentModelCalculationSpec inside(fixedFeedAgent.stateData) { case baseStateData: ParticipantModelBaseStateData[_, _, _, _] => baseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0d), Megavars(0d), ) @@ -324,7 +324,7 @@ class FixedFeedInAgentModelCalculationSpec baseStateData.resultValueStore.last(0L) match { case Some((tick, entry)) => tick shouldBe 0L - inside(entry) { case ApparentPower(p, q) => + inside(entry) { case ComplexPower(p, q) => p should approximate(Megawatts(-268.603e-6)) q should approximate(Megavars(0.0)) } 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..3d882c51a2 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/HpAgentModelCalculationSpec.scala @@ -14,7 +14,7 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{ AssetPowerUnchangedMessage, } import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHeat +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPowerAndHeat import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.hp.HpAgent import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData @@ -121,7 +121,7 @@ class HpAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ HpInput, HpRuntimeConfig, - ApparentPowerAndHeat, + ComplexPowerAndHeat, ]( inputModel = hpInput, modelConfig = modelConfig, @@ -186,7 +186,7 @@ class HpAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ HpInput, HpRuntimeConfig, - ApparentPowerAndHeat, + ComplexPowerAndHeat, ]( inputModel = hpInput, thermalGrid = defaultThermalGrid, @@ -318,7 +318,7 @@ class HpAgentModelCalculationSpec SortedMap(0L -> Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPowerAndHeat]( + requestValueStore shouldBe ValueStore[ComplexPowerAndHeat]( resolution ) @@ -403,11 +403,11 @@ class HpAgentModelCalculationSpec inside(hpAgent.stateData) { case modelBaseStateData: ParticipantModelBaseStateData[_, _, _, _] => modelBaseStateData.requestValueStore shouldBe ValueStore[ - ApparentPowerAndHeat + ComplexPowerAndHeat ]( resolution, SortedMap( - 0L -> ApparentPowerAndHeat( + 0L -> ComplexPowerAndHeat( Megawatts(0.0), Megavars(0.0), Megawatts(0.0), @@ -539,7 +539,7 @@ class HpAgentModelCalculationSpec 0L, fail("Expected a simulation result for tick 900."), ) match { - case ApparentPowerAndHeat(p, q, qDot) => + case ComplexPowerAndHeat(p, q, qDot) => p should approximate(Megawatts(0d)) q should approximate(Megavars(0d)) qDot should approximate(Megawatts(0d)) @@ -667,7 +667,7 @@ class HpAgentModelCalculationSpec 0L, fail("Expected a simulation result for tick 0."), ) match { - case ApparentPowerAndHeat(p, q, qDot) => + case ComplexPowerAndHeat(p, q, qDot) => p should approximate(Megawatts(0d)) q should approximate(Megavars(0d)) qDot should approximate(Megawatts(0d)) 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..5860fa04bb 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentFixedModelCalculationSpec.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{ AssetPowerUnchangedMessage, } import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.load.LoadAgent.FixedLoadAgent import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.{ @@ -99,7 +99,7 @@ class LoadAgentFixedModelCalculationSpec val initStateData = ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, modelConfig = modelConfig, @@ -215,7 +215,7 @@ class LoadAgentFixedModelCalculationSpec SortedMap(0L -> Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPower]( + requestValueStore shouldBe ValueStore[ComplexPower]( resolution ) case _ => @@ -264,11 +264,11 @@ class LoadAgentFixedModelCalculationSpec inside(loadAgent.stateData) { case baseStateData: ParticipantModelBaseStateData[_, _, _, _] => baseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0d), Megavars(0d), ) @@ -318,7 +318,7 @@ class LoadAgentFixedModelCalculationSpec baseStateData.resultValueStore.last(0L) match { case Some((tick, entry)) => tick shouldBe 0L - inside(entry) { case ApparentPower(p, q) => + inside(entry) { case ComplexPower(p, q) => p should approximate(Megawatts(268.603e-6)) q should approximate(Megavars(0.0)) } 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..7101b96671 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/LoadAgentProfileModelCalculationSpec.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{ AssetPowerUnchangedMessage, } import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.load.LoadAgent.ProfileLoadAgent import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.{ @@ -99,7 +99,7 @@ class LoadAgentProfileModelCalculationSpec val initStateData = ParticipantInitializeStateData[ LoadInput, LoadRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, modelConfig = modelConfig, @@ -215,7 +215,7 @@ class LoadAgentProfileModelCalculationSpec SortedMap(0L -> Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPower]( + requestValueStore shouldBe ValueStore[ComplexPower]( resolution ) case _ => @@ -264,11 +264,11 @@ class LoadAgentProfileModelCalculationSpec inside(loadAgent.stateData) { case baseStateData: ParticipantModelBaseStateData[_, _, _, _] => baseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0d), Megavars(0d), ) @@ -318,7 +318,7 @@ class LoadAgentProfileModelCalculationSpec baseStateData.resultValueStore.last(0L) match { case Some((tick, entry)) => tick shouldBe 0L - inside(entry) { case ApparentPower(p, q) => + inside(entry) { case ComplexPower(p, q) => p should approximate(Megawatts(84.000938e-6)) q should approximate(Megavars(0.0)) } 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..d233b102ed 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgent2ListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgent2ListenerSpec.scala @@ -17,7 +17,7 @@ import edu.ie3.simona.agent.participant.ParticipantAgent.{ FinishParticipantSimulation, RequestAssetPowerMessage, } -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.ParticipantInitializeStateData import edu.ie3.simona.config.SimonaConfig import edu.ie3.simona.config.SimonaConfig.BaseRuntimeConfig @@ -87,12 +87,12 @@ class ParticipantAgent2ListenerSpec val initStateData: NotifierConfig => ParticipantInitializeStateData[ SystemParticipantInput, BaseRuntimeConfig, - ApparentPower, + ComplexPower, ] = outputConfig => ParticipantInitializeStateData[ SystemParticipantInput, BaseRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = mockInputModel, modelConfig = mock[BaseRuntimeConfig], 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..7e152fedb3 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentExternalSourceSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentExternalSourceSpec.scala @@ -23,8 +23,8 @@ import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessag import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ ActivePower, ActivePowerAndHeat, - ApparentPower, - ApparentPowerAndHeat, + ComplexPower, + ComplexPowerAndHeat, } import edu.ie3.simona.agent.participant.statedata.BaseStateData.FromOutsideBaseStateData import edu.ie3.simona.agent.participant.statedata.DataCollectionStateData @@ -97,7 +97,7 @@ class ParticipantAgentExternalSourceSpec private val mockModel = mock[SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ]] when(mockModel.getUuid).thenReturn(testUUID) @@ -128,7 +128,7 @@ class ParticipantAgentExternalSourceSpec val initStateData = ParticipantInitializeStateData[ SystemParticipantInput, BaseRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = mockInputModel, modelConfig = mock[BaseRuntimeConfig], @@ -216,9 +216,9 @@ class ParticipantAgentExternalSourceSpec mockAgent.stateData match { case baseStateData: FromOutsideBaseStateData[SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower] => + ], ComplexPower] => /* Only check the awaited next data ticks, as the rest has yet been checked */ baseStateData.foreseenDataTicks shouldBe Map( primaryServiceProxy.ref -> Some(4711L) @@ -279,10 +279,10 @@ class ParticipantAgentExternalSourceSpec _, requestValueStore, ) => - requestValueStore shouldBe ValueStore[ApparentPower]( + requestValueStore shouldBe ValueStore[ComplexPower]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ) @@ -322,7 +322,7 @@ class ParticipantAgentExternalSourceSpec ProvidePrimaryDataMessage( 900L, primaryServiceProxy.ref, - ApparentPower( + ComplexPower( Kilowatts(0.0), Kilovars(900.0), ), @@ -336,9 +336,9 @@ class ParticipantAgentExternalSourceSpec case DataCollectionStateData( baseStateData: FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower], + ], ComplexPower], expectedSenders, isYetTriggered, ) => @@ -350,7 +350,7 @@ class ParticipantAgentExternalSourceSpec /* The yet sent data is also registered */ expectedSenders shouldBe Map( primaryServiceProxy.ref -> Some( - ApparentPower( + ComplexPower( Kilowatts(0.0), Kilovars(900.0), ) @@ -376,14 +376,14 @@ class ParticipantAgentExternalSourceSpec mockAgent.stateData match { case baseStateData: FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower] => + ], ComplexPower] => /* The new data is apparent in the result value store */ baseStateData.resultValueStore match { case ValueStore(_, store) => store shouldBe Map( - 900L -> ApparentPower( + 900L -> ComplexPower( Kilowatts(0.0), Kilovars(900.0), ) @@ -426,9 +426,9 @@ class ParticipantAgentExternalSourceSpec case DataCollectionStateData( baseStateData: FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower], + ], ComplexPower], expectedSenders, isYetTriggered, ) => @@ -454,7 +454,7 @@ class ParticipantAgentExternalSourceSpec ProvidePrimaryDataMessage( 900L, primaryServiceProxy.ref, - ApparentPower( + ComplexPower( Kilowatts(0.0), Kilovars(900.0), ), @@ -470,14 +470,14 @@ class ParticipantAgentExternalSourceSpec mockAgent.stateData match { case baseStateData: FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower] => + ], ComplexPower] => /* The new data is apparent in the result value store */ baseStateData.resultValueStore match { case ValueStore(_, store) => store shouldBe Map( - 900L -> ApparentPower( + 900L -> ComplexPower( Kilowatts(0.0), Kilovars(900.0), ) @@ -527,7 +527,7 @@ class ParticipantAgentExternalSourceSpec ProvidePrimaryDataMessage( 900L, primaryServiceProxy.ref, - ApparentPower( + ComplexPower( Kilowatts(0.0), Kilovars(900.0), ), @@ -554,13 +554,13 @@ class ParticipantAgentExternalSourceSpec "correctly determine the reactive power function when trivial reactive power is requested" in { val baseStateData: FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower] = FromOutsideBaseStateData[SystemParticipant[ + ], ComplexPower] = FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower]( + ], ComplexPower]( mockModel, defaultSimulationStart, defaultSimulationEnd, @@ -585,13 +585,13 @@ class ParticipantAgentExternalSourceSpec "correctly determine the reactive power function from model when requested" in { val baseStateData: FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower] = FromOutsideBaseStateData[SystemParticipant[ + ], ComplexPower] = FromOutsideBaseStateData[SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, - ], ApparentPower]( + ], ComplexPower]( mockModel, defaultSimulationStart, defaultSimulationEnd, @@ -635,7 +635,7 @@ class ParticipantAgentExternalSourceSpec ProvidePrimaryDataMessage( 900L, primaryServiceProxy.ref, - ApparentPower( + ComplexPower( Kilowatts(100.0), Kilovars(33.0), ), @@ -651,7 +651,7 @@ class ParticipantAgentExternalSourceSpec ProvidePrimaryDataMessage( 1800L, primaryServiceProxy.ref, - ApparentPower( + ComplexPower( Kilowatts(150.0), Kilovars(49.0), ), @@ -667,7 +667,7 @@ class ParticipantAgentExternalSourceSpec ProvidePrimaryDataMessage( 2700L, primaryServiceProxy.ref, - ApparentPower( + ComplexPower( Kilowatts(200.0), Kilovars(66.0), ), @@ -738,7 +738,7 @@ class ParticipantAgentExternalSourceSpec "fail" in { val data = Map( primaryServiceProxy.ref -> Some( - ApparentPowerAndHeat( + ComplexPowerAndHeat( Kilowatts(0.0), Kilovars(0.0), Kilowatts(0.0), @@ -748,7 +748,7 @@ class ParticipantAgentExternalSourceSpec participantAgent.prepareData(data, reactivePowerFunction) match { case Failure(exception: IllegalStateException) => - exception.getMessage shouldBe "Got the wrong primary data. Expected: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ApparentPower, got: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ApparentPowerAndHeat" + exception.getMessage shouldBe "Got the wrong primary data. Expected: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ComplexPower, got: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ComplexPowerAndHeat" case Failure(exception) => fail(s"Failed with wrong exception:\n\t$exception") case Success(_) => fail("Was meant to fail, but succeeded") @@ -769,7 +769,7 @@ class ParticipantAgentExternalSourceSpec participantAgent.prepareData(data, reactivePowerFunction) match { case Failure(exception: IllegalStateException) => - exception.getMessage shouldBe "Received primary data cannot be enriched to expected data. Expected: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ApparentPower, got: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ActivePowerAndHeat, enriched to: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ApparentPowerAndHeat" + exception.getMessage shouldBe "Received primary data cannot be enriched to expected data. Expected: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ComplexPower, got: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ActivePowerAndHeat, enriched to: edu.ie3.simona.agent.participant.data.Data$PrimaryData$ComplexPowerAndHeat" case Failure(exception) => fail(s"Failed with wrong exception:\n\t$exception") case Success(_) => fail("Was meant to fail, but succeeded") @@ -784,7 +784,7 @@ class ParticipantAgentExternalSourceSpec ) participantAgent.prepareData(data, reactivePowerFunction) match { - case Success(ApparentPower(p, q)) => + case Success(ComplexPower(p, q)) => p should approximate(Megawatts(0.0)) q should approximate(Megavars(0.0)) case Success(value) => @@ -808,7 +808,7 @@ class ParticipantAgentExternalSourceSpec data, (p: squants.Power) => Kilovars(p.toKilowatts * tan(acos(0.9))), ) match { - case Success(ApparentPower(p, q)) => + case Success(ComplexPower(p, q)) => p should approximate(Kilowatts(100.0)) q should approximate(Kilovars(48.43221)) case Success(value) => diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala index dde8ed4803..26058683b3 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentalsSpec.scala @@ -11,7 +11,7 @@ import com.typesafe.config.ConfigFactory import edu.ie3.datamodel.models.input.system.SystemParticipantInput import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.ParticipantAgentFundamentals.RelevantResultValues -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.ParticipantInitializeStateData @@ -82,7 +82,7 @@ class ParticipantAgentFundamentalsSpec /* Get one instance of the mock for participant agent */ private val mockAgentTestRef: TestFSMRef[AgentState, ParticipantStateData[ - ApparentPower + ComplexPower ], ParticipantAgentMock] = TestFSMRef( new ParticipantAgentMock( @@ -90,7 +90,7 @@ class ParticipantAgentFundamentalsSpec initStateData = mock[ParticipantInitializeStateData[ SystemParticipantInput, BaseRuntimeConfig, - ApparentPower, + ComplexPower, ]], ) ) @@ -98,35 +98,35 @@ class ParticipantAgentFundamentalsSpec private val powerValues = Map( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(1.0), Megavars(0.0), ), - 1L -> ApparentPower( + 1L -> ComplexPower( Megawatts(2.0), Megavars(1.0), ), - 3L -> ApparentPower( + 3L -> ComplexPower( Megawatts(3.0), Megavars(2.0), ), - 4L -> ApparentPower( + 4L -> ComplexPower( Megawatts(5.0), Megavars(4.0), ), - 7L -> ApparentPower( + 7L -> ComplexPower( Megawatts(3.0), Megavars(2.0), ), - 8L -> ApparentPower( + 8L -> ComplexPower( Megawatts(6.0), Megavars(5.0), ), - 9L -> ApparentPower( + 9L -> ComplexPower( Megawatts(6.0), Megavars(5.0), ), - 10L -> ApparentPower( + 10L -> ComplexPower( Megawatts(4.0), Megavars(3.0), ), @@ -326,7 +326,7 @@ class ParticipantAgentFundamentalsSpec None, ) apparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(0.8666666666666667)) q should approximate(Megavars(0.5333333333333334)) } @@ -341,7 +341,7 @@ class ParticipantAgentFundamentalsSpec None, ) apparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(4.571428571428573)) q should approximate(Megavars(3.571428571428571)) } @@ -356,7 +356,7 @@ class ParticipantAgentFundamentalsSpec None, ) apparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(4.571428571428573)) q should approximate(Megavars(3.571428571428571)) } @@ -371,7 +371,7 @@ class ParticipantAgentFundamentalsSpec activeToReactivePowerFuncOpt, ) apparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(0.8666666666666667)) q should approximate(Megavars(2.8666666666666667)) } @@ -386,7 +386,7 @@ class ParticipantAgentFundamentalsSpec activeToReactivePowerFuncOpt, ) apparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(4.571428571428573)) q should approximate(Megavars(21.71428571428571)) } @@ -401,7 +401,7 @@ class ParticipantAgentFundamentalsSpec activeToReactivePowerFuncOpt, ) apparentPower match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(4.571428571428573)) q should approximate(Megavars(21.71428571428571)) } @@ -414,27 +414,27 @@ class ParticipantAgentFundamentalsSpec val resultValueStore = ValueStore( 900, SortedMap( - 800L -> ApparentPower( + 800L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1000L -> ApparentPower( + 1000L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1200L -> ApparentPower( + 1200L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1400L -> ApparentPower( + 1400L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1600L -> ApparentPower( + 1600L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1800L -> ApparentPower( + 1800L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), @@ -443,7 +443,7 @@ class ParticipantAgentFundamentalsSpec val requestValueStore = ValueStore( 900, SortedMap( - 900L -> ApparentPower( + 900L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ) @@ -459,27 +459,27 @@ class ParticipantAgentFundamentalsSpec 900L, 1800L, Map( - 800L -> ApparentPower( + 800L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1000L -> ApparentPower( + 1000L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1200L -> ApparentPower( + 1200L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1400L -> ApparentPower( + 1400L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1600L -> ApparentPower( + 1600L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), - 1800L -> ApparentPower( + 1800L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ), @@ -493,7 +493,7 @@ class ParticipantAgentFundamentalsSpec val resultValueStore = ValueStore( 900, SortedMap( - 800L -> ApparentPower( + 800L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ) @@ -502,7 +502,7 @@ class ParticipantAgentFundamentalsSpec val requestValueStore = ValueStore( 900, SortedMap( - 900L -> ApparentPower( + 900L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ) @@ -518,7 +518,7 @@ class ParticipantAgentFundamentalsSpec 900L, 1800L, Map( - 800L -> ApparentPower( + 800L -> ComplexPower( Megawatts(0.0), Megavars(0.0), ) @@ -531,7 +531,7 @@ class ParticipantAgentFundamentalsSpec "Determining the applicable nodal voltage" should { "deliver the correct voltage" in { val baseStateData = ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedLoadRelevantData.type, ConstantState.type, FixedLoadModel, @@ -568,7 +568,7 @@ class ParticipantAgentFundamentalsSpec "throw an error, if no nodal voltage is available" in { val baseStateData = ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedLoadRelevantData.type, ConstantState.type, FixedLoadModel, @@ -620,25 +620,25 @@ case object ParticipantAgentFundamentalsSpec extends MockitoSugar { additionalActivationTicks: SortedSet[Long], foreseenDataTicks: Map[ActorRef, Option[Long]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, - SystemParticipant[FixedRelevantData.type, ApparentPower, ConstantState.type], + SystemParticipant[FixedRelevantData.type, ComplexPower, ConstantState.type], ] = { val modelMock = mock[SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ]] when(modelMock.getUuid).thenReturn(UUID.randomUUID()) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ]( diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index fb965d72d3..1e70a3f443 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -11,7 +11,7 @@ import edu.ie3.datamodel.models.result.ResultEntity import edu.ie3.datamodel.models.result.system.SystemParticipantResult import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ - ApparentPower, + ComplexPower, ZERO_POWER, } import edu.ie3.simona.agent.participant.data.Data.SecondaryData @@ -73,38 +73,38 @@ class ParticipantAgentMock( initStateData: ParticipantInitializeStateData[ SystemParticipantInput, SimonaConfig.BaseRuntimeConfig, - ApparentPower, + ComplexPower, ], override val listener: Iterable[ActorRef] = Iterable.empty[ActorRef], ) extends ParticipantAgent[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], SystemParticipantInput, SimonaConfig.BaseRuntimeConfig, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ](scheduler, initStateData) with ParticipantAgentFundamentals[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, - ParticipantStateData[ApparentPower], + ParticipantStateData[ComplexPower], SystemParticipantInput, SimonaConfig.BaseRuntimeConfig, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ] { - override protected val pdClassTag: ClassTag[ApparentPower] = - classTag[ApparentPower] - override val alternativeResult: ApparentPower = ZERO_POWER + override protected val pdClassTag: ClassTag[ComplexPower] = + classTag[ComplexPower] + override val alternativeResult: ComplexPower = ZERO_POWER /** Partial function, that is able to transfer * [[ParticipantModelBaseStateData]] (holding the actual calculation model) @@ -113,20 +113,20 @@ class ParticipantAgentMock( override val calculateModelPowerFunc: ( Long, ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ], ConstantState.type, squants.Dimensionless, - ) => ApparentPower = (_, _, _, _) => + ) => ComplexPower = (_, _, _, _) => // output different from default (0, 0) - ApparentPower( + ComplexPower( Megawatts(2.0), Megavars(1.0), ) @@ -149,19 +149,19 @@ class ParticipantAgentMock( */ override def calculatePowerWithSecondaryDataAndGoToIdle( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ], modelState: ConstantState.type, currentTick: Long, scheduler: ActorRef, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = throw new InvalidRequestException( "Request to calculate power with secondary data cannot be processed for this mock agent." ) @@ -201,10 +201,10 @@ class ParticipantAgentMock( outputConfig: NotifierConfig, maybeEmAgent: Option[TypedActorRef[FlexResponse]], ): ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, - SystemParticipant[FixedRelevantData.type, ApparentPower, ConstantState.type], + SystemParticipant[FixedRelevantData.type, ComplexPower, ConstantState.type], ] = { val func = CosPhiFixed(0.95).activeToReactivePowerFunc( Kilovoltamperes(0.0), @@ -213,23 +213,23 @@ class ParticipantAgentMock( ) val participant: SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ] = mock[SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ]] doReturn(func).when(participant).activeToReactivePowerFunc(any()) ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ]( @@ -272,13 +272,13 @@ class ParticipantAgentMock( simulationEndDate: ZonedDateTime, ): SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ] = { val mockModel = mock[SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ]] val uuid = inputModel.electricalInputModel.getUuid @@ -288,12 +288,12 @@ class ParticipantAgentMock( override protected def createInitialState( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ] @@ -302,12 +302,12 @@ class ParticipantAgentMock( override protected def createCalcRelevantData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, FixedRelevantData.type, ConstantState.type, SystemParticipant[ FixedRelevantData.type, - ApparentPower, + ComplexPower, ConstantState.type, ], ], @@ -325,9 +325,9 @@ class ParticipantAgentMock( * [[Idle]] with updated result values */ override def finalizeTickAfterPF( - baseStateData: BaseStateData[ApparentPower], + baseStateData: BaseStateData[ComplexPower], currentTick: Long, - ): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = + ): FSM.State[AgentState, ParticipantStateData[ComplexPower]] = goto(Idle) using baseStateData /** Determine the average result within the given tick window @@ -344,13 +344,13 @@ class ParticipantAgentMock( * The averaged result */ override def averageResults( - tickToResults: Map[Long, ApparentPower], + tickToResults: Map[Long, ComplexPower], windowStart: Long, windowEnd: Long, activeToReactivePowerFuncOpt: Option[ squants.Power => ReactivePower ] = None, - ): ApparentPower = + ): ComplexPower = ParticipantAgentFundamentals.averageApparentPower( tickToResults, windowStart, @@ -373,7 +373,7 @@ class ParticipantAgentMock( override protected def buildResult( uuid: UUID, dateTime: ZonedDateTime, - result: ApparentPower, + result: ComplexPower, ): SystemParticipantResult = new SystemParticipantResult( dateTime, @@ -400,12 +400,12 @@ class ParticipantAgentMock( override def handleControlledPowerChange( tick: Long, baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, CalcRelevantData.FixedRelevantData.type, ModelState.ConstantState.type, SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ModelState.ConstantState.type, ], ], @@ -414,12 +414,12 @@ class ParticipantAgentMock( setPower: squants.Power, ): ( ModelState.ConstantState.type, - AccompaniedSimulationResult[ApparentPower], + AccompaniedSimulationResult[ComplexPower], FlexChangeIndicator, ) = ( ConstantState, AccompaniedSimulationResult( - ApparentPower( + ComplexPower( Kilowatts(0.0), Kilovars(0.0), ), @@ -451,7 +451,7 @@ class ParticipantAgentMock( nodalVoltage: squants.Dimensionless, model: SystemParticipant[ CalcRelevantData.FixedRelevantData.type, - ApparentPower, + ComplexPower, ModelState.ConstantState.type, ], ): ModelState.ConstantState.type = modelState @@ -463,7 +463,7 @@ object ParticipantAgentMock { initStateData: ParticipantInitializeStateData[ SystemParticipantInput, SimonaConfig.BaseRuntimeConfig, - ApparentPower, + ComplexPower, ], ): Props = Props( 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..f2985dd693 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/PvAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/PvAgentModelCalculationSpec.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{ AssetPowerUnchangedMessage, } import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.pv.PvAgent import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData @@ -122,7 +122,7 @@ class PvAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ PvInput, PvRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, modelConfig = modelConfig, @@ -186,7 +186,7 @@ class PvAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ PvInput, PvRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, modelConfig = modelConfig, @@ -314,7 +314,7 @@ class PvAgentModelCalculationSpec SortedMap(0L -> Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPower](resolution) + requestValueStore shouldBe ValueStore[ComplexPower](resolution) /* Additional information */ awaitRegistrationResponsesFrom shouldBe Iterable(weatherService.ref) @@ -397,11 +397,11 @@ class PvAgentModelCalculationSpec inside(pvAgent.stateData) { case baseStateData: ParticipantModelBaseStateData[_, _, _, _] => baseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0d), Megavars(0d), ) @@ -509,7 +509,7 @@ class PvAgentModelCalculationSpec 0L, fail("Expected a simulation result for tick 900."), ) match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(0.0)) q should approximate(Megavars(0.0)) } @@ -613,7 +613,7 @@ class PvAgentModelCalculationSpec 0L, fail("Expected a simulation result for tick 0."), ) match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(0.0)) q should approximate(Megavars(0.0)) } diff --git a/src/test/scala/edu/ie3/simona/agent/participant/RichValueSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/RichValueSpec.scala index 5710c15417..0c8b16b35b 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/RichValueSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/RichValueSpec.scala @@ -18,8 +18,8 @@ import edu.ie3.simona.agent.participant.data.Data.PrimaryData import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ ActivePower, ActivePowerAndHeat, - ApparentPower, - ApparentPowerAndHeat, + ComplexPower, + ComplexPowerAndHeat, RichValue, } import edu.ie3.simona.test.common.UnitSpec @@ -116,7 +116,7 @@ class RichValueSpec extends UnitSpec with TableDrivenPropertyChecks { Quantities.getQuantity(50d, PowerSystemUnits.KILOWATT), Quantities.getQuantity(25d, PowerSystemUnits.KILOVAR), ), - ApparentPower( + ComplexPower( Kilowatts(50d), Kilovars(25d), ), @@ -127,7 +127,7 @@ class RichValueSpec extends UnitSpec with TableDrivenPropertyChecks { Quantities.getQuantity(25d, PowerSystemUnits.KILOVAR), Quantities.getQuantity(12.5, PowerSystemUnits.KILOWATT), ), - ApparentPowerAndHeat( + ComplexPowerAndHeat( Kilowatts(50d), Kilovars(25d), Kilowatts(12.5), diff --git a/src/test/scala/edu/ie3/simona/agent/participant/StorageAgentModelCalculationSpec.scala b/src/test/scala/edu/ie3/simona/agent/participant/StorageAgentModelCalculationSpec.scala index d7c8378ce5..dc2b1b96ff 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/StorageAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/StorageAgentModelCalculationSpec.scala @@ -13,7 +13,7 @@ import edu.ie3.datamodel.models.result.system.StorageResult import edu.ie3.simona.agent.ValueStore import edu.ie3.simona.agent.grid.GridAgentMessages.AssetPowerChangedMessage import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData import edu.ie3.simona.agent.participant.statedata.ParticipantStateData.{ ParticipantInitializeStateData, @@ -110,7 +110,7 @@ class StorageAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ StorageInput, StorageRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = storageInputQv, modelConfig = modelConfig, @@ -219,7 +219,7 @@ class StorageAgentModelCalculationSpec resultValueStore shouldBe ValueStore( resolution ) - requestValueStore shouldBe ValueStore[ApparentPower]( + requestValueStore shouldBe ValueStore[ComplexPower]( resolution ) case unrecognized => @@ -271,11 +271,11 @@ class StorageAgentModelCalculationSpec inside(storageAgent.stateData) { case modelBaseStateData: ParticipantModelBaseStateData[_, _, _, _] => modelBaseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0d), Megavars(0d), ) 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..704877ee79 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/WecAgentModelCalculationSpec.scala @@ -15,7 +15,7 @@ import edu.ie3.simona.agent.grid.GridAgentMessages.{ AssetPowerUnchangedMessage, } import edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorWeatherService import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData import edu.ie3.simona.agent.participant.statedata.DataCollectionStateData @@ -125,7 +125,7 @@ class WecAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ WecInput, WecRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, simulationStartDate = simulationStartDate, @@ -193,7 +193,7 @@ class WecAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ WecInput, WecRuntimeConfig, - ApparentPower, + ComplexPower, ]( inputModel = voltageSensitiveInput, modelConfig = modelConfig, @@ -291,7 +291,7 @@ class WecAgentModelCalculationSpec SortedMap(0L -> Each(1.0)), ) resultValueStore shouldBe ValueStore(resolution) - requestValueStore shouldBe ValueStore[ApparentPower](resolution) + requestValueStore shouldBe ValueStore[ComplexPower](resolution) /* Additional information */ awaitRegistrationResponsesFrom shouldBe Iterable(weatherService.ref) @@ -315,7 +315,7 @@ class WecAgentModelCalculationSpec wecAgent.stateName shouldBe Idle wecAgent.stateData match { case baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -376,17 +376,17 @@ class WecAgentModelCalculationSpec inside(wecAgent.stateData) { case modelBaseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, ] => modelBaseStateData.requestValueStore shouldBe ValueStore[ - ApparentPower + ComplexPower ]( resolution, SortedMap( - 0L -> ApparentPower( + 0L -> ComplexPower( Megawatts(0d), Megavars(0d), ) @@ -452,7 +452,7 @@ class WecAgentModelCalculationSpec wecAgent.stateData match { case DataCollectionStateData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -488,7 +488,7 @@ class WecAgentModelCalculationSpec wecAgent.stateName shouldBe Idle wecAgent.stateData match { case baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -509,7 +509,7 @@ class WecAgentModelCalculationSpec 900L, fail("Expected a simulation result for tick 900."), ) match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(0.0)) q should approximate(Megavars(0.0)) } @@ -558,7 +558,7 @@ class WecAgentModelCalculationSpec wecAgent.stateData match { case DataCollectionStateData( baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -607,7 +607,7 @@ class WecAgentModelCalculationSpec wecAgent.stateName shouldBe Idle wecAgent.stateData match { case baseStateData: ParticipantModelBaseStateData[ - ApparentPower, + ComplexPower, WecRelevantData, ConstantState.type, WecModel, @@ -628,7 +628,7 @@ class WecAgentModelCalculationSpec 900L, fail("Expected a simulation result for tick 900."), ) match { - case ApparentPower(p, q) => + case ComplexPower(p, q) => p should approximate(Megawatts(0.0)) q should approximate(Megavars(0.0)) } diff --git a/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala index abcdb613a6..e47c309c37 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/ApparentPowerAndHeatSpec.scala @@ -6,7 +6,7 @@ package edu.ie3.simona.model.participant -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPowerAndHeat +import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPowerAndHeat import edu.ie3.simona.model.participant.ApparentPowerAndHeatSpec.ApparentPowerAndHeatMock import edu.ie3.simona.model.participant.CalcRelevantData.FixedRelevantData import edu.ie3.simona.model.participant.ModelState.ConstantState @@ -38,7 +38,7 @@ class ApparentPowerAndHeatSpec extends UnitSpec { ConstantState, FixedRelevantData, ) match { - case ApparentPowerAndHeat(p, q, qDot) => + case ComplexPowerAndHeat(p, q, qDot) => p should approximate(Megawatts(0d)) q should approximate(Megavars(0d)) qDot should approximate(Megawatts(0d)) @@ -53,7 +53,7 @@ class ApparentPowerAndHeatSpec extends UnitSpec { ConstantState, FixedRelevantData, ) match { - case ApparentPowerAndHeat(p, q, qDot) => + case ComplexPowerAndHeat(p, q, qDot) => p should approximate(Megawatts(43d)) q should approximate(Megavars(0d)) qDot should approximate(Megawatts(42d)) @@ -67,7 +67,7 @@ object ApparentPowerAndHeatSpec { object ApparentPowerAndHeatMock extends SystemParticipant[ FixedRelevantData.type, - ApparentPowerAndHeat, + ComplexPowerAndHeat, ConstantState.type, ]( UUID.randomUUID(), diff --git a/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala index 011dbb9567..6320271e9a 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala @@ -11,7 +11,7 @@ import edu.ie3.simona.model.participant.ModelState.ConstantState import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.EuroPerKilowatthour +import edu.ie3.util.scala.quantities.{EuroPerKilowatthour, Kilovoltamperes} import squants.energy.{Kilowatts, Megawatts} import squants.market.EUR import squants.thermal.Celsius @@ -21,7 +21,7 @@ import java.time.ZonedDateTime import java.util.UUID /** Test class that tries to cover all special cases of the current - * implementation of the {@link BMModel} + * implementation of the [[BMModel]] * * Test results have been calculated on paper using equations from wiki: * https://wiki.ie3.e-technik.tu-dortmund.de/!simona/model:bm_model @@ -38,7 +38,7 @@ class BMModelSpec extends UnitSpec { "BM Model Test", OperationInterval(0L, 86400L), QControl(new CosPhiFixed("cosPhiFixed:{(0.0,1.0)}")), - Kilowatts(190), + Kilovoltamperes(190), 1d, "MockNode", isCostControlled = true, @@ -164,7 +164,7 @@ class BMModelSpec extends UnitSpec { "BM Model Test", OperationInterval(0L, 86400L), QControl(new CosPhiFixed("cosPhiFixed:{(0.0,1.0)}")), - Kilowatts(190), + Kilovoltamperes(190), 1d, "MockNode", isCostControlled = true, @@ -174,7 +174,7 @@ class BMModelSpec extends UnitSpec { ) val pElCalc = bmModel.calculateElOutput(usage, eff) - pElCalc.value should be(Kilowatts(pElSol).value +- 1e-4) + pElCalc.value should be(Kilovoltamperes(pElSol).toVoltamperes +- 1e-4) } } @@ -306,7 +306,7 @@ class BMModelSpec extends UnitSpec { "BM Model Test", OperationInterval(0L, 86400L), QControl(new CosPhiFixed("cosPhiFixed:{(0.0,1.0)}")), - Kilowatts(190), + Kilovoltamperes(190), 1d, "MockNode", costControlled, diff --git a/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSqlIT.scala b/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSqlIT.scala index 2b7023daa3..9a50b4fce9 100644 --- a/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSqlIT.scala +++ b/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSqlIT.scala @@ -15,7 +15,7 @@ import edu.ie3.datamodel.io.naming.DatabaseNamingStrategy import edu.ie3.datamodel.models.value.{HeatAndSValue, PValue} import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ ActivePower, - ApparentPowerAndHeat, + ComplexPowerAndHeat, } import edu.ie3.simona.config.SimonaConfig.Simona.Input.Primary.SqlParams import edu.ie3.simona.ontology.messages.Activation @@ -107,7 +107,7 @@ class PrimaryServiceWorkerSqlIT ), uuidPqh, 0L, - ApparentPowerAndHeat( + ComplexPowerAndHeat( Kilowatts(1000.0), Kilovars(329.0), Kilowatts(8000.0), From 7571eaa12777571eb9117a992cd2a5100107aacc Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 7 Oct 2024 01:55:50 +0200 Subject: [PATCH 015/137] Remade ExtEvSimulationClasses.puml --- CHANGELOG.md | 3 +- docs/uml/main/ExtEvSimulationClasses.puml | 312 +++++++++++----------- 2 files changed, 154 insertions(+), 161 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 781aba25a6..b4de5ac15d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,7 +77,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated AUTHORS.md [#904](https://github.com/ie3-institute/simona/issues/904) - Updated `Gradle` to version V8.10 [#829](https://github.com/ie3-institute/simona/issues/829) - 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) +- Rewrote BMModelTest from groov to scala [#646](https://github.com/ie3-institute/simona/issues/646) +- Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898) ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index 9543697f03..79e83b5ed9 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -1,223 +1,215 @@ @startuml -'https://plantuml.com/class-diagram -skinparam linetype ortho -package ev-simulation { - class ExtLink - class ExternalSampleSim - class EvModelImpl +skinparam linetype ortho +skinparam nodesep 50 +skinparam ranksep 40 - ' adding hidden elements for layout purposes - class placeholderA { - w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w +skinparam node{ + borderColor Transparent + fontColor Transparent } - hide placeholderA - class placeholderB { - w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w +package MobilitySimulator { + class ExtLink + class MobilitySim + class ElectricVehicle } - hide placeholderB - - ExtLink -[hidden]> placeholderA - placeholderA -[hidden]> ExternalSampleSim - ExternalSampleSim -[hidden]> placeholderB - placeholderB -[hidden]> EvModelImpl -} package simona-api { - ' MIDDLE PART - class ExtEvData { - ~ LinkedBlockingQueue receiveTriggerQueue - - ActorRef dataService - - ActorRef extSimAdapter - + List requestAvailablePublicEvCs() - + List sendEvPositions(EvMovementsMessage evMovementsMessage) - - void sendData(ExtEvMessage msg) - + void queueExtMsg(ExtEvResponseMessage extEvResponse) - } - - class ExtSimAdapterData { - ~ LinkedBlockingQueue receiveTriggerQueue - - ActorRef extSimAdapter - + void queueExtMsg(ExtTrigger trigger) - + void send(ExtTriggerResponse msg) - } - - interface ExtData +'top to bottom direction abstract class ExtSimulation { + - ExtSimAdapterData data + void setup(ExtSimAdapterData data, List adapters) + void run() - # {abstract} List doActivity(long tick) + # {abstract} Optional doActivity(long tick) + # {abstract} Long intitialize() + } + ExtSimulation --r> ExtData + MobilitySim -|> ExtSimulation + + interface ExtLinkInterface { + + ExtSimulation getExtSimulation() + + List getExtDataSimulations() } + ExtLink --|> ExtLinkInterface + 'ExtLinkInterface --d> ExtSimulation + interface ExtEvSimulation { - + void setExtEvData(ExtEvData evData) + + void setExtEvData(ExtEvData evData) } + MobilitySim --|> ExtEvSimulation + interface ExtDataSimulation - ExternalSampleSim --|> ExtSimulation - ExternalSampleSim --|> ExtEvSimulation + ExtEvSimulation --|> ExtDataSimulation - ExtSimulation -[hidden]> ExtDataSimulation - ExtEvSimulation -|> ExtDataSimulation - ExtEvSimulation --> ExtEvData + 'ExtLinkInterface -[norank]> ExtDataSimulation - ExtSimulation --> ExtData - ExtSimulation --> ExtSimAdapterData - ExtSimAdapterData -[hidden]> ExtEvData - ExtData <|-- ExtEvData + interface EvModel { + + UUID getUuid() + + String getId() + + ComparableQuantity getSRatedAC() + + ComparableQuantity getSRatedDC() + + ComparableQuantity getEStorage() + + ComparableQuantity getStoredEnergy() + + Long getDepartureTick() + + EvModel copyWith(ComparableQuantity newStoredEnergy) + } - ' placeholder - class plchldr1 { - w-w-w-w-w - } - hide plchldr1 - class placeholder2 { - w-w-w-w-w-w-w-w-w-w-w-w-w-w-w - } - hide placeholder2 - class placeholder3 { - w-w-w-w-w-w-w-w-w-w-w - } - hide placeholder3 - class placeholder4 { - w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w-w - } - hide placeholder4 + ElectricVehicle --|> EvModel - ExtData -[hidden]> plchldr1 - plchldr1 -[hidden]> placeholder4 - placeholder4 -[hidden]> EvMovement - ExtSimulation -[hidden]-> placeholder2 - placeholder2 -[hidden]-> placeholder3 - placeholder3 -[hidden]-> ExtSimAdapterData - placeholder2 -[hidden]> ExtData + interface ExtData - ' RIGHT PART - abstract class EvMovement - class Arrival - class Departure - Arrival --|> EvMovement - Departure --|> EvMovement - Arrival -[hidden]> Departure + class ExtEvData { + + LinkedBlockingQueue receiveTriggerQueue + - ActorRef dataService + - ActorRef extSimAdapter + + Map requestAvailablePublicEvcs() + + Map requestCurrentPrices() + + List requestDepartingEvs(Map> departures) + + void provideArrivingEvs(Map> arrivals, Optional maybeNextTick) + + void sendExtMsg(EvDataMessageFromExt msg) + + void queueExtResponseMsg(EvDataResponseMessageToExt extEvResponse) + } + + node sub2{ + interface EvDataMessageFromExt - interface EvModel { - + UUID getUuid() - + String getId() - + ComparableQuantity getSRated() - + ComparableQuantity getEStorage() - + ComparableQuantity getStoredEnergy() - + EvModel copyWith(ComparableQuantity newStoredEnergy) - } + interface DataMessageFromExt - ExtDataSimulation -[hidden]> Arrival - EvMovement *-> EvModel - EvModelImpl --|> EvModel + class ProvideArrivingEvs + class RequestCurrentPrices + + class RequestDepartingEvs - interface EvDataMessageFromExt - class EvMovementsMessage { - - Map> movements - } class RequestEvcsFreeLots - RequestEvcsFreeLots --|> EvDataMessageFromExt - EvMovementsMessage --|> EvDataMessageFromExt - RequestEvcsFreeLots -[hidden]> EvMovementsMessage + +} + RequestDepartingEvs --u|> EvDataMessageFromExt + RequestEvcsFreeLots --u|> EvDataMessageFromExt + ProvideArrivingEvs --u|> EvDataMessageFromExt + RequestCurrentPrices --u|> EvDataMessageFromExt + + DataMessageFromExt --d|> EvDataMessageFromExt + ExtEvData --r[norank]> EvDataMessageFromExt + ExtEvData --u|> ExtData + ExtEvSimulation -u> ExtEvData + + + + +node sub1{ + interface DataResponseMessageToExt interface EvDataResponseMessageToExt - class AllDepartedEvsRepsonse { - - Map> movements - } - class ProvideEvcsFreeLots - ProvideEvcsFreeLots --|> EvDataResponseMessageToExt - AllDepartedEvsRepsonse --|> EvDataResponseMessageToExt - ExtEvData -> EvDataMessageFromExt - ExtEvData -> EvDataResponseMessageToExt - EvMovement -[hidden]-> RequestEvcsFreeLots - EvDataMessageFromExt -[hidden]> EvDataResponseMessageToExt - EvMovementsMessage -[hidden]> ProvideEvcsFreeLots - ProvideEvcsFreeLots -[hidden]> AllDepartedEvsRepsonse - - class ScheduleDataServiceMessage { - - ExtEvDataService dataService - } - EvDataResponseMessageToExt -[hidden]> ScheduleDataServiceMessage - ExtEvData -> ScheduleDataServiceMessage + class ProvideCurrentPrices{ + + ProvideCurrentPrices() + } - ' LEFT PART - interface ExtLinkInterface { - + ExtSimulation getExtSimulation() - + List getExtDataSimulations() + class ProvideDepartingEvs{ + + ProvideDepartingEvs() } - ExtLinkInterface -[hidden]> ExtSimulation - ExtLink --|> ExtLinkInterface - interface ExtTrigger - class ActivationMessage { - - Long tick + class ProvideEvcsFreeLots{ + + ProvideEvcsFreeLots() } - ActivationMessage --|> ExtTrigger - interface ExtTriggerResponse - class CompletionMessage { - - List newTriggers + ProvideEvcsFreeLots --|> EvDataResponseMessageToExt + ProvideDepartingEvs --|> EvDataResponseMessageToExt + ProvideCurrentPrices --|> EvDataResponseMessageToExt + ExtEvData --> EvDataResponseMessageToExt + DataResponseMessageToExt --|> EvDataResponseMessageToExt +} + + +node sub3{ + class ExtSimAdapterData { + + LinkedBlockingQueue receiveTriggerQueue + - ActorRef extSimAdapter + - String[] mainArgs + + void queueExtMsg(ControlMessageToExt msg) + + void send(ControlResponseMessageFromExt msg) + + String[] getMainArgs() + } + + interface ControlMessageToExt + + interface ControlResponseMessageFromExt + + class CompletionMessage + + class ActivationMessage + + ExtSimAdapterData --u> ControlMessageToExt + ExtSimAdapterData --u> ControlResponseMessageFromExt + CompletionMessage --d|> ControlResponseMessageFromExt + ActivationMessage --d|> ControlMessageToExt + ExtSimulation -----> ExtSimAdapterData } - CompletionMessage --|> ExtTriggerResponse - ExtTrigger -[hidden]> ExtTriggerResponse - ExtTrigger <- ExtSimAdapterData - ExtTriggerResponse <- ExtSimAdapterData + } + + package simona { - abstract class ParticipantAgent + abstract class ParticipantAgent - class EvcsModel + class EvcsModel - class EvcsAgent + class EvcsAgent - interface SecondaryData - class EvMovementData { - movements: Set[EvMovement] - } + interface SecondaryData + class EvMovementData { + movements: Set[EvMovement] + } + + class SimonaSim - class SimonaSim + class Scheduler - class Scheduler + class SimonaStandaloneSetup - class SimonaStandaloneSetup + class ExtSimLoader - class ExtSimLoader + class ExtSimAdapter - class ExtSimAdapter + class ExtEvDataService - class ExtEvDataService + Scheduler -- SimonaSim + SimonaSim *- SimonaStandaloneSetup + SimonaStandaloneSetup *- ExtSimLoader - Scheduler -- SimonaSim - SimonaSim *- SimonaStandaloneSetup - SimonaStandaloneSetup *- ExtSimLoader + ExtSimAdapter - Scheduler + ExtEvDataService -- Scheduler - ExtSimAdapter -- Scheduler - ExtEvDataService -- Scheduler + SecondaryData <|-- EvMovementData - SecondaryData <|-- EvMovementData + SimonaService <|- ExtEvDataService + ExtEvData --- ExtEvDataService - SimonaService <|- ExtEvDataService - ExtEvData <--- ExtEvDataService + ExtSimAdapterData <--- ExtSimAdapter - ExtSimAdapterData <--- ExtSimAdapter + ExtEvDataService "n" <-> "1" EvcsAgent + EvcsAgent --|> ParticipantAgent + EvcsAgent *- EvcsModel - ' 1 and n are swapped here due to bug with linetype ortho and labels - ExtEvDataService "n" <-> "1" EvcsAgent - EvcsAgent --|> ParticipantAgent - EvcsAgent *- EvcsModel + } + + 'Order of classes/interfaces established through hidden connections: ExtSimAdapter -[hidden]> SimonaService -} + sub1 ---[hidden]d> sub2 + ExtLink -[hidden]> ElectricVehicle + ExtSimulation -[hidden]> ExtEvSimulation + ExtSimulation -[hidden]> DataResponseMessageToExt + RequestDepartingEvs --[hidden]> SecondaryData @enduml \ No newline at end of file From f582bf093629c0dccd642543ae0d9745d241e83f Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 7 Oct 2024 02:02:35 +0200 Subject: [PATCH 016/137] Changelog changes from dev --- CHANGELOG.md | 15 ++++++++++++++- docs/uml/main/ExtEvSimulationClasses.puml | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4de5ac15d..16e331282b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update RTD references and bibliography [#868](https://github.com/ie3-institute/simona/issues/868) - Add gradle application plugin for command line execution with gradle run [#890](https://github.com/ie3-institute/simona/issues/890) - Additional tests to check flexibility options of thermal house and storage [#729](https://github.com/ie3-institute/simona/issues/729) +- EmAgents should be able to handle initialization [#945](https://github.com/ie3-institute/simona/issues/945) +- Added option to directly zip the output files [#793](https://github.com/ie3-institute/simona/issues/793) +- Added weatherData HowTo for Copernicus ERA5 data [#967](https://github.com/ie3-institute/simona/issues/967) ### Changed - Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435) @@ -77,7 +80,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated AUTHORS.md [#904](https://github.com/ie3-institute/simona/issues/904) - Updated `Gradle` to version V8.10 [#829](https://github.com/ie3-institute/simona/issues/829) - Updated AUTHORS.md [#905](https://github.com/ie3-institute/simona/issues/905) -- Rewrote BMModelTest from groov to scala [#646](https://github.com/ie3-institute/simona/issues/646) +- 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) +- Simplifying quantity integration in QuantityUtil [#973](https://github.com/ie3-institute/simona/issues/973) +- Reorganized Jenkins pipeline to separate build and test stages for better efficiency [#938](https://github.com/ie3-institute/simona/issues/938) - Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898) ### Fixed @@ -105,6 +114,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Handle MobSim requests for current prices [#892](https://github.com/ie3-institute/simona/issues/892) - Fix determineState of ThermalHouse [#926](https://github.com/ie3-institute/simona/issues/926) - 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) +- Fix scheduling at Evcs with more than one Ev at a time without Em [#787](https://github.com/ie3-institute/simona/issues/787) ## [3.0.0] - 2023-08-07 diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index 79e83b5ed9..b7427e5293 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -1,5 +1,5 @@ @startuml - +'https://plantuml.com/class-diagram skinparam linetype ortho skinparam nodesep 50 skinparam ranksep 40 From 3bc2e53eca33a50cb7e3d40c2ee286af3ca4eeca Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 7 Oct 2024 20:37:45 +0200 Subject: [PATCH 017/137] Took out commented connections --- docs/uml/main/ExtEvSimulationClasses.puml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index b7427e5293..bb74a9b0e8 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -16,7 +16,6 @@ package MobilitySimulator { } package simona-api { -'top to bottom direction abstract class ExtSimulation { - ExtSimAdapterData data @@ -34,7 +33,6 @@ package simona-api { } ExtLink --|> ExtLinkInterface - 'ExtLinkInterface --d> ExtSimulation interface ExtEvSimulation { + void setExtEvData(ExtEvData evData) @@ -46,9 +44,6 @@ package simona-api { ExtEvSimulation --|> ExtDataSimulation - 'ExtLinkInterface -[norank]> ExtDataSimulation - - interface EvModel { + UUID getUuid() + String getId() @@ -101,9 +96,6 @@ package simona-api { ExtEvData --u|> ExtData ExtEvSimulation -u> ExtEvData - - - node sub1{ interface DataResponseMessageToExt From 32d34651b39c5b6c1ddd71281c93b55a1531a569 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 17 Oct 2024 12:24:45 +0200 Subject: [PATCH 018/137] test --- .../model/participant/StorageModelSpec.scala | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala new file mode 100644 index 0000000000..beda5cecab --- /dev/null +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -0,0 +1,121 @@ +/* + * © 2022. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.model.participant + +import edu.ie3.datamodel.models.OperationTime +import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} +import edu.ie3.datamodel.models.input.system.StorageInput +import edu.ie3.datamodel.models.input.system.`type`.StorageTypeInput +import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed +import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils +import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions +import edu.ie3.simona.test.common.UnitSpec +import edu.ie3.util.TimeUtil +import edu.ie3.util.quantities.PowerSystemUnits +import org.scalatest.matchers.should.Matchers +import squants.energy.{KilowattHours, Kilowatts} +import squants.market.EUR +import tech.units.indriya.quantity.Quantities +import tech.units.indriya.quantity.Quantities.getQuantity + +import java.util.UUID + +class StorageModelSpec extends UnitSpec with Matchers { + + var inputModel: StorageInput = _ + final val TOLERANCE = 1e-10 + + "Setup for StorageModel" should { + "initialize the input model" in { + val nodeInput = new NodeInput( + UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), + "NodeInput", + OperatorInput.NO_OPERATOR_ASSIGNED, + OperationTime.notLimited(), + Quantities.getQuantity(1, PowerSystemUnits.PU), + false, + NodeInput.DEFAULT_GEO_POSITION, + GermanVoltageLevelUtils.LV, + -1 + ) + + val typeInput = new StorageTypeInput( + UUID.fromString("fbee4995-24dd-45e4-9c85-7d986fe99ff3"), + "Test_StorageTypeInput", + Quantities.getQuantity(10000d, EUR0), + getQuantity(0.05d, EURO_PER_MEGAWATTHOUR), + Quantities.getQuantity(100d, KILOWATTHOUR), + getQuantity(13d, KILOVOLTAMPERE), + 0.997, + getQuantity(10d, KILOWATT), + getQuantity(0.03, PU_PER_HOUR), + getQuantity(0.9, PU), + ) + + inputModel = new StorageInput( + UUID.randomUUID(), + "Test_StorageInput", + new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), + OperationTime.notLimited(), + nodeInput, + CosPhiFixed.CONSTANT_CHARACTERISTIC, + null, + typeInput + ) + } + } + + def buildStorageModel(targetSoc: Option[Double] = Option.empty): StorageModel = { + StorageModel.apply( + inputModel, + 1, + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), + 0d, + targetSoc + ) + } + + "Calculate flex options" should { + "correctly compute the flexibility options" in { + val storageModel = buildStorageModel() + val startTick = 3600L + + val testCases = Table( + ("lastStored", "lastPower", "timeDelta", "pRef", "pMin", "pMax"), + // UNCHANGED STATE + (0.0, 0.0, 1, 0.0, 0.0, 10.0), + (0.011, 0.0, 1, 0.0, -10.0, 10.0), + (60.0, 0.0, 1, 0.0, -10.0, 10.0), + (99.989, 0.0, 1, 0.0, -10.0, 10.0), + (100.0, 0.0, 1, 0.0, -10.0, 0.0), + // CHANGED STATE + (10.0, -9.0, 3600, 0.0, 0.0, 10.0), + (10.0, -9.0, 3590, 0.0, -10.0, 10.0), + (41.0, 10.0, 3600, 0.0, -10.0, 10.0), + (60.0, -9.0, 3600, 0.0, -10.0, 10.0), + (95.5, 4.98, 3600, 0.0, -10.0, 10.0), + (95.5, 5.0, 3600, 0.0, -10.0, 0.0) + ) + + forAll(testCases) { (lastStored: Double, lastPower: Double, timeDelta: Int, pRef: Double, pMin: Double, pMax: Double) => + val data = StorageModel.StorageRelevantData(startTick + timeDelta) + val oldState = StorageModel.StorageState( + KilowattHours(lastStored), + Kilowatts(lastPower), + startTick + ) + + val result = storageModel.determineFlexOptions(data, oldState).asInstanceOf[ProvideMinMaxFlexOptions] + + result.ref.toKilowatts shouldBe pRef +- TOLERANCE + result.min.toKilowatts shouldBe pMin +- TOLERANCE + result.max.toKilowatts shouldBe pMax +- TOLERANCE + } + } + } +} From f9b228ef25c597d4178f3018c436c0c173db7b17 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 17 Oct 2024 13:26:55 +0200 Subject: [PATCH 019/137] test --- .../model/participant/StorageModelSpec.scala | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index beda5cecab..bbf5fbf0eb 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -7,18 +7,19 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.OperationTime -import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.input.system.StorageInput import edu.ie3.datamodel.models.input.system.`type`.StorageTypeInput import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed +import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.quantities.PowerSystemUnits._ import org.scalatest.matchers.should.Matchers +import squants.Power import squants.energy.{KilowattHours, Kilowatts} -import squants.market.EUR import tech.units.indriya.quantity.Quantities import tech.units.indriya.quantity.Quantities.getQuantity @@ -28,9 +29,9 @@ class StorageModelSpec extends UnitSpec with Matchers { var inputModel: StorageInput = _ final val TOLERANCE = 1e-10 + final implicit val TOLERANCE2: Power = Kilowatts(1e-10) - "Setup for StorageModel" should { - "initialize the input model" in { + "StorageModel" should { val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), "NodeInput", @@ -46,7 +47,7 @@ class StorageModelSpec extends UnitSpec with Matchers { val typeInput = new StorageTypeInput( UUID.fromString("fbee4995-24dd-45e4-9c85-7d986fe99ff3"), "Test_StorageTypeInput", - Quantities.getQuantity(10000d, EUR0), + Quantities.getQuantity(10000d, EURO), getQuantity(0.05d, EURO_PER_MEGAWATTHOUR), Quantities.getQuantity(100d, KILOWATTHOUR), getQuantity(13d, KILOVOLTAMPERE), @@ -112,9 +113,9 @@ class StorageModelSpec extends UnitSpec with Matchers { val result = storageModel.determineFlexOptions(data, oldState).asInstanceOf[ProvideMinMaxFlexOptions] - result.ref.toKilowatts shouldBe pRef +- TOLERANCE - result.min.toKilowatts shouldBe pMin +- TOLERANCE - result.max.toKilowatts shouldBe pMax +- TOLERANCE + result.ref should approximate(Kilowatts(pRef)) + result.min should approximate(Kilowatts(pMin)) + result.max should approximate(Kilowatts(pMax)) } } } From c8a6519c6852e699807dd7f51c59a9a3e57ace86 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 17 Oct 2024 13:41:36 +0200 Subject: [PATCH 020/137] test --- .../edu/ie3/simona/model/participant/StorageModelSpec.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index bbf5fbf0eb..c1d31c16dd 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -68,7 +68,7 @@ class StorageModelSpec extends UnitSpec with Matchers { typeInput ) } - } + def buildStorageModel(targetSoc: Option[Double] = Option.empty): StorageModel = { StorageModel.apply( @@ -81,8 +81,7 @@ class StorageModelSpec extends UnitSpec with Matchers { ) } - "Calculate flex options" should { - "correctly compute the flexibility options" in { + "Calculate flex options correctly compute the flexibility options" in { val storageModel = buildStorageModel() val startTick = 3600L @@ -118,5 +117,4 @@ class StorageModelSpec extends UnitSpec with Matchers { result.max should approximate(Kilowatts(pMax)) } } - } } From fdb8756faf2950b02aa550d278ebda10f163a046 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Tue, 22 Oct 2024 11:37:09 +0200 Subject: [PATCH 021/137] Rewrote StorageModelTest from groovy to scala --- CHANGELOG.md | 1 + .../model/participant/StorageModelTest.groovy | 374 ---------------- .../model/participant/StorageModelSpec.scala | 408 +++++++++++++++--- 3 files changed, 354 insertions(+), 429 deletions(-) delete mode 100644 src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy diff --git a/CHANGELOG.md b/CHANGELOG.md index b5c786457f..120d71724b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -87,6 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed `ActivityStartTrigger`, `ScheduleTriggerMessage`, `CompletionMessage` in UML Diagrams[#675](https://github.com/ie3-institute/simona/issues/675) - Simplifying quantity integration in QuantityUtil [#973](https://github.com/ie3-institute/simona/issues/973) - Reorganized Jenkins pipeline to separate build and test stages for better efficiency [#938](https://github.com/ie3-institute/simona/issues/938) +- Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) ### 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/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy deleted file mode 100644 index a28a405901..0000000000 --- a/src/test/groovy/edu/ie3/simona/model/participant/StorageModelTest.groovy +++ /dev/null @@ -1,374 +0,0 @@ -/* - * © 2022. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.model.participant - -import edu.ie3.datamodel.models.OperationTime -import edu.ie3.datamodel.models.input.NodeInput -import edu.ie3.datamodel.models.input.OperatorInput -import edu.ie3.datamodel.models.input.system.StorageInput -import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed -import edu.ie3.datamodel.models.input.system.type.StorageTypeInput -import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils -import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions -import edu.ie3.util.TimeUtil -import edu.ie3.util.scala.quantities.Sq -import scala.Option -import spock.lang.Shared -import spock.lang.Specification -import squants.energy.* - -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.quantity.Quantities.getQuantity - -class StorageModelTest extends Specification { - - @Shared - StorageInput inputModel - @Shared - static final Double TOLERANCE = 1e-10 - - def setupSpec() { - def nodeInput = new NodeInput( - UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), - "NodeInput", - OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited(), - getQuantity(1d, PU), - false, - NodeInput.DEFAULT_GEO_POSITION, - GermanVoltageLevelUtils.LV, - -1) - - def typeInput = new StorageTypeInput( - UUID.fromString("fbee4995-24dd-45e4-9c85-7d986fe99ff3"), - "Test_StorageTypeInput", - getQuantity(10000d, EURO), - getQuantity(0.05d, EURO_PER_MEGAWATTHOUR), - getQuantity(100d, KILOWATTHOUR), - getQuantity(13d, KILOVOLTAMPERE), - 0.997, - getQuantity(10d, KILOWATT), - getQuantity(0.03, PU_PER_HOUR), - getQuantity(0.9, PU), - ) - - inputModel = new StorageInput( - UUID.randomUUID(), - "Test_StorageInput", - new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), - OperationTime.notLimited(), - nodeInput, - CosPhiFixed.CONSTANT_CHARACTERISTIC, - null, - typeInput - ) - } - - def buildStorageModel(Option targetSoc = Option.empty()) { - return StorageModel.apply(inputModel, 1, - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), - 0d, - targetSoc) - } - - def "Calculate flex options"() { - given: - def storageModel = buildStorageModel() - def startTick = 3600L - def data = new StorageModel.StorageRelevantData(startTick + timeDelta) - def oldState = new StorageModel.StorageState( - Sq.create(lastStored.doubleValue(), KilowattHours$.MODULE$), - Sq.create(lastPower.doubleValue(), Kilowatts$.MODULE$), - startTick - ) - - when: - def result = (ProvideMinMaxFlexOptions) storageModel.determineFlexOptions(data, oldState) - - then: - Math.abs(result.ref().toKilowatts() - pRef) < TOLERANCE - Math.abs(result.min().toKilowatts() - pMin) < TOLERANCE - Math.abs(result.max().toKilowatts() - pMax) < TOLERANCE - - where: - lastStored | lastPower | timeDelta || pRef | pMin | pMax - // UNCHANGED STATE - // completely empty - 0 | 0 | 1 || 0 | 0 | 10 - // at a tiny bit above empty - 0.011d | 0 | 1 || 0 | -10 | 10 - // at mid-level charge - 60 | 0 | 1 || 0 | -10 | 10 - // almost fully charged - 99.989d | 0 | 1 || 0 | -10 | 10 - // fully charged - 100 | 0 | 1 || 0 | -10 | 0 - // CHANGED STATE - // discharged to empty - 10 | -9 | 3600 || 0 | 0 | 10 - // almost discharged to lowest allowed charge - 10 | -9 | 3590 || 0 | -10 | 10 - // charged to mid-level charge - 41 | 10 | 3600 || 0 | -10 | 10 - // discharged to mid-level charge - 60 | -9 | 3600 || 0 | -10 | 10 - // almost fully charged - 95.5 | 4.98 | 3600 || 0 | -10 | 10 - // fully charged - 95.5 | 5 | 3600 || 0 | -10 | 0 - } - - def "Calculate flex options with target SOC"() { - given: - def storageModel = buildStorageModel(Option.apply(0.5d)) - def startTick = 3600L - def data = new StorageModel.StorageRelevantData(startTick + 1) - def oldState = new StorageModel.StorageState( - Sq.create(lastStored.doubleValue(), KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = (ProvideMinMaxFlexOptions) storageModel.determineFlexOptions(data, oldState) - - then: - Math.abs(result.ref().toKilowatts() - pRef) < TOLERANCE - Math.abs(result.min().toKilowatts() - pMin) < TOLERANCE - Math.abs(result.max().toKilowatts() - pMax) < TOLERANCE - - where: - lastStored || pRef | pMin | pMax - // completely empty - 0 || 10 | 0 | 10 - // below margin of ref power target - 49.9974 || 10 | -10 | 10 - // within margin below ref power target - 49.9976 || 0 | -10 | 10 - // exactly at ref power target - 50 || 0 | -10 | 10 - // within margin above ref power target - 50.0030 || 0 | -10 | 10 - // above margin of ref power target - 50.0031 || -10 | -10 | 10 - // at mid-level charge - 60 || -10 | -10 | 10 - // fully charged - 100 || -10 | -10 | 0 - } - - def "Handle controlled power change"() { - given: - def storageModel = buildStorageModel() - def startTick = 3600L - def data = new StorageModel.StorageRelevantData(startTick + 1) - def oldState = new StorageModel.StorageState( - Sq.create(lastStored.doubleValue(), KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = storageModel.handleControlledPowerChange( - data, - oldState, - Sq.create(setPower.doubleValue(), Kilowatts$.MODULE$) - ) - - then: - Math.abs(result._1.chargingPower().toKilowatts() - expPower.doubleValue()) < TOLERANCE - result._1.tick() == startTick + 1 - Math.abs(result._1.storedEnergy().toKilowattHours() - lastStored.doubleValue()) < TOLERANCE - def flexChangeIndication = result._2 - flexChangeIndication.changesAtTick().defined == expScheduled - flexChangeIndication.changesAtTick().map(x -> x == startTick + 1 + expDelta).getOrElse(_ -> true) - flexChangeIndication.changesAtNextActivation() == expActiveNext - - where: - lastStored | setPower || expPower | expActiveNext | expScheduled | expDelta - // no power - 0 | 0 || 0 | false | false | 0 - 50 | 0 || 0 | false | false | 0 - 100 | 0 || 0 | false | false | 0 - // charging on empty - 0 | 1 || 1 | true | true | 100 * 3600 / 0.9 - 0 | 2.5 || 2.5 | true | true | 40 * 3600 / 0.9 - 0 | 5 || 5 | true | true | 20 * 3600 / 0.9 - 0 | 10 || 10 | true | true | 10 * 3600 / 0.9 - // charging on half full - 50 | 5 || 5 | false | true | 10 * 3600 / 0.9 - 50 | 10 || 10 | false | true | 5 * 3600 / 0.9 - // discharging on half full - 50 | -4.5 || -4.5 | false | true | 10 * 3600 - 50 | -9 || -9 | false | true | 5 * 3600 - // discharging on full - 100 | -4.5 || -4.5 | true | true | 20 * 3600 - 100 | -9 || -9 | true | true | 10 * 3600 - } - - def "Handle controlled power change with ref target SOC"() { - given: - def storageModel = buildStorageModel(Option.apply(0.5d)) - def startTick = 3600L - def data = new StorageModel.StorageRelevantData(startTick + 1) - def oldState = new StorageModel.StorageState( - Sq.create(lastStored.doubleValue(), KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = storageModel.handleControlledPowerChange( - data, - oldState, - Sq.create(setPower.doubleValue(), Kilowatts$.MODULE$) - ) - - then: - Math.abs(result._1.chargingPower().toKilowatts() - expPower.doubleValue()) < TOLERANCE - result._1.tick() == startTick + 1 - Math.abs(result._1.storedEnergy().toKilowattHours() - lastStored.doubleValue()) < TOLERANCE - def flexChangeIndication = result._2 - flexChangeIndication.changesAtTick().defined == expScheduled - flexChangeIndication.changesAtTick().map(x -> x == startTick + 1 + expDelta).getOrElse(_ -> true) - flexChangeIndication.changesAtNextActivation() == expActiveNext - - where: - lastStored | setPower || expPower | expActiveNext | expScheduled | expDelta - // no power - 0 | 0 || 0 | false | false | 0 - 50 | 0 || 0 | false | false | 0 - 100 | 0 || 0 | false | false | 0 - // charging on empty - 0 | 1 || 1 | true | true | 50 * 3600 / 0.9 - 0 | 2.5 || 2.5 | true | true | 20 * 3600 / 0.9 - 0 | 5 || 5 | true | true | 10 * 3600 / 0.9 - 0 | 10 || 10 | true | true | 5 * 3600 / 0.9 - // charging on target ref - 50 | 5 || 5 | true | true | 10 * 3600 / 0.9 - 50 | 10 || 10 | true | true | 5 * 3600 / 0.9 - // discharging on target ref - 50 | -4.5 || -4.5 | true | true | 10 * 3600 - 50 | -9 || -9 | true | true | 5 * 3600 - // discharging on full - 100 | -4.5 || -4.5 | true | true | 10 * 3600 - 100 | -9 || -9 | true | true | 5 * 3600 - } - - def "Handle the edge case of discharging in tolerance margins"() { - given: - def storageModel = buildStorageModel() - def startTick = 1800L - def data = new StorageModel.StorageRelevantData(startTick + 1) - // margin is at ~ 0.0030864 kWh - def oldState = new StorageModel.StorageState( - Sq.create(0.002d, KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = storageModel.handleControlledPowerChange( - data, - oldState, - Sq.create(-5d, Kilowatts$.MODULE$) - ) - - then: - Math.abs(result._1.chargingPower().toKilowatts()) < TOLERANCE - result._1.tick() == startTick + 1 - Math.abs(result._1.storedEnergy().toKilowattHours() - oldState.storedEnergy().toKilowattHours()) < TOLERANCE - def flexChangeIndication = result._2 - !flexChangeIndication.changesAtTick().defined - flexChangeIndication.changesAtNextActivation() - } - - def "Handle the edge case of charging in tolerance margins"() { - given: - def storageModel = buildStorageModel() - def startTick = 1800L - def data = new StorageModel.StorageRelevantData(startTick + 1) - // margin is at ~ 99.9975 kWh - def oldState = new StorageModel.StorageState( - Sq.create(99.999d, KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = storageModel.handleControlledPowerChange( - data, - oldState, - Sq.create(9d, Kilowatts$.MODULE$) - ) - - then: - Math.abs(result._1.chargingPower().toKilowatts()) < TOLERANCE - result._1.tick() == startTick + 1 - Math.abs(result._1.storedEnergy().toKilowattHours() - oldState.storedEnergy().toKilowattHours()) < TOLERANCE - def flexChangeIndication = result._2 - !flexChangeIndication.changesAtTick().defined - flexChangeIndication.changesAtNextActivation() - } - - def "Handle the edge case of discharging in positive target margin"() { - given: - def storageModel = buildStorageModel(Option.apply(0.3d)) - def startTick = 1800L - def data = new StorageModel.StorageRelevantData(startTick + 1) - // margin is at ~ 30.0025 kWh - def oldState = new StorageModel.StorageState( - Sq.create(30.0024d, KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = storageModel.handleControlledPowerChange( - data, - oldState, - Sq.create(-9d, Kilowatts$.MODULE$) - ) - - then: - Math.abs(result._1.chargingPower().toKilowatts() - (-9d)) < TOLERANCE - result._1.tick() == startTick + 1 - Math.abs(result._1.storedEnergy().toKilowattHours() - oldState.storedEnergy().toKilowattHours()) < TOLERANCE - def flexChangeIndication = result._2 - flexChangeIndication.changesAtTick() == Option.apply(startTick + 1L + 10801L) - flexChangeIndication.changesAtNextActivation() - } - - def "Handle the edge case of charging in negative target margin"() { - given: - def storageModel = buildStorageModel(Option.apply(0.4d)) - def startTick = 1800L - def data = new StorageModel.StorageRelevantData(startTick + 1) - // margin is at ~ 39.9975 kWh - def oldState = new StorageModel.StorageState( - Sq.create(39.998d, KilowattHours$.MODULE$), - Sq.create(0d, Kilowatts$.MODULE$), - startTick - ) - - when: - def result = storageModel.handleControlledPowerChange( - data, - oldState, - Sq.create(5d, Kilowatts$.MODULE$) - ) - - then: - Math.abs(result._1.chargingPower().toKilowatts() - (5d)) < TOLERANCE - result._1.tick() == startTick + 1 - Math.abs(result._1.storedEnergy().toKilowattHours() - oldState.storedEnergy().toKilowattHours()) < TOLERANCE - def flexChangeIndication = result._2 - flexChangeIndication.changesAtTick() == Option.apply(startTick + 1L + 48002L) - flexChangeIndication.changesAtNextActivation() - } -} diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index c1d31c16dd..e235a1d233 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -18,8 +18,8 @@ import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.quantities.PowerSystemUnits._ import org.scalatest.matchers.should.Matchers -import squants.Power import squants.energy.{KilowattHours, Kilowatts} +import squants.{Energy, Power} import tech.units.indriya.quantity.Quantities import tech.units.indriya.quantity.Quantities.getQuantity @@ -27,61 +27,63 @@ import java.util.UUID class StorageModelSpec extends UnitSpec with Matchers { - var inputModel: StorageInput = _ - final val TOLERANCE = 1e-10 - final implicit val TOLERANCE2: Power = Kilowatts(1e-10) + final val inputModel: StorageInput = createStorageInput() + final implicit val powerTolerance: Power = Kilowatts(1e-10) + final implicit val energyTolerance: Energy = KilowattHours(1e-10) - "StorageModel" should { - val nodeInput = new NodeInput( - UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), - "NodeInput", - OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited(), - Quantities.getQuantity(1, PowerSystemUnits.PU), - false, - NodeInput.DEFAULT_GEO_POSITION, - GermanVoltageLevelUtils.LV, - -1 - ) - - val typeInput = new StorageTypeInput( - UUID.fromString("fbee4995-24dd-45e4-9c85-7d986fe99ff3"), - "Test_StorageTypeInput", - Quantities.getQuantity(10000d, EURO), - getQuantity(0.05d, EURO_PER_MEGAWATTHOUR), - Quantities.getQuantity(100d, KILOWATTHOUR), - getQuantity(13d, KILOVOLTAMPERE), - 0.997, - getQuantity(10d, KILOWATT), - getQuantity(0.03, PU_PER_HOUR), - getQuantity(0.9, PU), - ) + def createStorageInput(): StorageInput = { + val nodeInput = new NodeInput( + UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), + "NodeInput", + OperatorInput.NO_OPERATOR_ASSIGNED, + OperationTime.notLimited(), + Quantities.getQuantity(1, PowerSystemUnits.PU), + false, + NodeInput.DEFAULT_GEO_POSITION, + GermanVoltageLevelUtils.LV, + -1, + ) - inputModel = new StorageInput( - UUID.randomUUID(), - "Test_StorageInput", - new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), - OperationTime.notLimited(), - nodeInput, - CosPhiFixed.CONSTANT_CHARACTERISTIC, - null, - typeInput - ) - } + val typeInput = new StorageTypeInput( + UUID.fromString("fbee4995-24dd-45e4-9c85-7d986fe99ff3"), + "Test_StorageTypeInput", + Quantities.getQuantity(10000d, EURO), + getQuantity(0.05d, EURO_PER_MEGAWATTHOUR), + Quantities.getQuantity(100d, KILOWATTHOUR), + getQuantity(13d, KILOVOLTAMPERE), + 0.997, + getQuantity(10d, KILOWATT), + getQuantity(0.03, PU_PER_HOUR), + getQuantity(0.9, PU), + ) + new StorageInput( + UUID.randomUUID(), + "Test_StorageInput", + new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), + OperationTime.notLimited(), + nodeInput, + CosPhiFixed.CONSTANT_CHARACTERISTIC, + null, + typeInput, + ) + } - def buildStorageModel(targetSoc: Option[Double] = Option.empty): StorageModel = { + def buildStorageModel( + targetSoc: Option[Double] = Option.empty + ): StorageModel = { StorageModel.apply( inputModel, 1, TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), 0d, - targetSoc + targetSoc, ) } - "Calculate flex options correctly compute the flexibility options" in { + "StorageModel" should { + "Calculate flex options" in { val storageModel = buildStorageModel() val startTick = 3600L @@ -99,22 +101,318 @@ class StorageModelSpec extends UnitSpec with Matchers { (41.0, 10.0, 3600, 0.0, -10.0, 10.0), (60.0, -9.0, 3600, 0.0, -10.0, 10.0), (95.5, 4.98, 3600, 0.0, -10.0, 10.0), - (95.5, 5.0, 3600, 0.0, -10.0, 0.0) + (95.5, 5.0, 3600, 0.0, -10.0, 0.0), ) - forAll(testCases) { (lastStored: Double, lastPower: Double, timeDelta: Int, pRef: Double, pMin: Double, pMax: Double) => - val data = StorageModel.StorageRelevantData(startTick + timeDelta) - val oldState = StorageModel.StorageState( - KilowattHours(lastStored), - Kilowatts(lastPower), - startTick - ) + forAll(testCases) { + ( + lastStored: Double, + lastPower: Double, + timeDelta: Int, + pRef: Double, + pMin: Double, + pMax: Double, + ) => + val data = StorageModel.StorageRelevantData(startTick + timeDelta) + val oldState = StorageModel.StorageState( + KilowattHours(lastStored), + Kilowatts(lastPower), + startTick, + ) - val result = storageModel.determineFlexOptions(data, oldState).asInstanceOf[ProvideMinMaxFlexOptions] + val result = storageModel + .determineFlexOptions(data, oldState) + .asInstanceOf[ProvideMinMaxFlexOptions] - result.ref should approximate(Kilowatts(pRef)) - result.min should approximate(Kilowatts(pMin)) - result.max should approximate(Kilowatts(pMax)) + result.ref should approximate(Kilowatts(pRef)) + result.min should approximate(Kilowatts(pMin)) + result.max should approximate(Kilowatts(pMax)) } } + "Calculate flex options with target SOC" in { + val storageModel = buildStorageModel(Some(0.5d)) + val startTick = 3600L + val data = StorageModel.StorageRelevantData(startTick + 1) + + val testCases = Table( + ("lastStored", "pRef", "pMin", "pMax"), + // completely empty + (0.0, 10.0, 0.0, 10.0), + // below margin of ref power target + (49.9974, 10.0, -10.0, 10.0), + // within margin below ref power target + (49.9976, 0.0, -10.0, 10.0), + // exactly at ref power target + (50.0, 0.0, -10.0, 10.0), + // within margin above ref power target + (50.0030, 0.0, -10.0, 10.0), + // above margin of ref power target + (50.0031, -10.0, -10.0, 10.0), + // at mid-level charge + (60.0, -10.0, -10.0, 10.0), + // fully charged + (100.0, -10.0, -10.0, 0.0), + ) + + forAll(testCases) { + (lastStored: Double, pRef: Double, pMin: Double, pMax: Double) => + val oldState = StorageModel.StorageState( + KilowattHours(lastStored), + Kilowatts(0d), + startTick, + ) + + val result = storageModel + .determineFlexOptions(data, oldState) + .asInstanceOf[ProvideMinMaxFlexOptions] + + result.ref should approximate(Kilowatts(pRef)) + result.min should approximate(Kilowatts(pMin)) + result.max should approximate(Kilowatts(pMax)) + } + } + + "Handle controlled power change" in { + val storageModel = buildStorageModel() + val startTick = 3600L + val data = StorageModel.StorageRelevantData(startTick + 1) + val testCases = Table( + ( + "lastStored", + "setPower", + "expPower", + "expActiveNext", + "expScheduled", + "expDelta", + ), + // no power + (0.0, 0.0, 0.0, false, false, 0), + (50.0, 0.0, 0.0, false, false, 0), + (100.0, 0.0, 0.0, false, false, 0), + // charging on empty + (0.0, 1.0, 1.0, true, true, (100 * 3600 / 0.9).toInt), + (0.0, 2.5, 2.5, true, true, (40 * 3600 / 0.9).toInt), + (0.0, 5.0, 5.0, true, true, (20 * 3600 / 0.9).toInt), + (0.0, 10.0, 10.0, true, true, (10 * 3600 / 0.9).toInt), + // charging on half full + (50.0, 5.0, 5.0, false, true, (10 * 3600 / 0.9).toInt), + (50.0, 10.0, 10.0, false, true, (5 * 3600 / 0.9).toInt), + // discharging on half full + (50.0, -4.5, -4.5, false, true, 10 * 3600), + (50.0, -9.0, -9.0, false, true, 5 * 3600), + // discharging on full + (100.0, -4.5, -4.5, true, true, 20 * 3600), + (100.0, -9.0, -9.0, true, true, 10 * 3600), + ) + + forAll(testCases) { + ( + lastStored: Double, + setPower: Double, + expPower: Double, + expActiveNext: Boolean, + expScheduled: Boolean, + expDelta: Int, + ) => + val oldState = StorageModel.StorageState( + KilowattHours(lastStored), + Kilowatts(0d), + startTick, + ) + + val result = storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(setPower), + ) + + val (newState, flexChangeIndication) = result + + newState.chargingPower should approximate(Kilowatts(expPower)) + newState.tick shouldBe (startTick + 1) + newState.storedEnergy should approximate(KilowattHours(lastStored)) + + flexChangeIndication.changesAtTick.isDefined shouldBe expScheduled + flexChangeIndication.changesAtTick.forall( + _ == (startTick + 1 + expDelta) + ) shouldBe true + flexChangeIndication.changesAtNextActivation shouldBe expActiveNext + } + } + + "Handle controlled power change with ref target SOC" in { + val storageModel = buildStorageModel(Some(0.5d)) + val startTick = 3600L + val data = StorageModel.StorageRelevantData(startTick + 1) + + val testCases = Table( + ( + "lastStored", + "setPower", + "expPower", + "expActiveNext", + "expScheduled", + "expDelta", + ), + // no power + (0.0, 0.0, 0.0, false, false, 0), + (50.0, 0.0, 0.0, false, false, 0), + (100.0, 0.0, 0.0, false, false, 0), + // charging on empty + (0.0, 1.0, 1.0, true, true, (50 * 3600 / 0.9).toInt), + (0.0, 2.5, 2.5, true, true, (20 * 3600 / 0.9).toInt), + (0.0, 5.0, 5.0, true, true, (10 * 3600 / 0.9).toInt), + (0.0, 10.0, 10.0, true, true, (5 * 3600 / 0.9).toInt), + // charging on target ref + (50.0, 5.0, 5.0, true, true, (10 * 3600 / 0.9).toInt), + (50.0, 10.0, 10.0, true, true, (5 * 3600 / 0.9).toInt), + // discharging on target ref + (50.0, -4.5, -4.5, true, true, 10 * 3600), + (50.0, -9.0, -9.0, true, true, 5 * 3600), + // discharging on full + (100.0, -4.5, -4.5, true, true, 10 * 3600), + (100.0, -9.0, -9.0, true, true, 5 * 3600), + ) + + forAll(testCases) { + ( + lastStored: Double, + setPower: Double, + expPower: Double, + expActiveNext: Boolean, + expScheduled: Boolean, + expDelta: Int, + ) => + val oldState = StorageModel.StorageState( + KilowattHours(lastStored), + Kilowatts(0d), + startTick, + ) + + val result = storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(setPower), + ) + + val (newState, flexChangeIndication) = result + + newState.chargingPower should approximate(Kilowatts(expPower)) + newState.tick shouldBe (startTick + 1) + newState.storedEnergy should approximate(KilowattHours(lastStored)) + + flexChangeIndication.changesAtTick.isDefined shouldBe expScheduled + flexChangeIndication.changesAtTick.forall( + _ == (startTick + 1 + expDelta) + ) shouldBe true + flexChangeIndication.changesAtNextActivation shouldBe expActiveNext + } + } + + "Handle the edge case of discharging in tolerance margins" in { + val storageModel = buildStorageModel() + val startTick = 1800L + val data = StorageModel.StorageRelevantData(startTick + 1) + // margin is at ~ 0.0030864 kWh + val oldState = StorageModel.StorageState( + KilowattHours(0.002d), + Kilowatts(0d), + startTick, + ) + + val result = storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(-5d), + ) + + result._1.chargingPower should approximate(Kilowatts(0)) + result._1.tick shouldBe (startTick + 1) + result._1.storedEnergy should approximate(oldState.storedEnergy) + + val flexChangeIndication = result._2 + flexChangeIndication.changesAtTick.isDefined shouldBe false + flexChangeIndication.changesAtNextActivation shouldBe true + } + + "Handle the edge case of charging in tolerance margins" in { + val storageModel = buildStorageModel() + val startTick = 1800L + val data = StorageModel.StorageRelevantData(startTick + 1) + // margin is at ~ 99.9975 kWh + val oldState = StorageModel.StorageState( + KilowattHours(99.999d), + Kilowatts(0d), + startTick, + ) + + val result = storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(9d), + ) + + result._1.chargingPower should approximate(Kilowatts(0)) + result._1.tick shouldBe (startTick + 1) + result._1.storedEnergy should approximate(oldState.storedEnergy) + + val flexChangeIndication = result._2 + flexChangeIndication.changesAtTick.isDefined shouldBe false + flexChangeIndication.changesAtNextActivation shouldBe true + } + "Handle the edge case of discharging in positive target margin" in { + val storageModel = buildStorageModel(Some(0.3d)) + val startTick = 1800L + val data = new StorageModel.StorageRelevantData(startTick + 1) + // margin is at ~ 30.0025 kWh + val oldState = new StorageModel.StorageState( + KilowattHours(30.0024d), + Kilowatts(0d), + startTick, + ) + + val result = storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(-9d), + ) + + // Verifications + result._1.chargingPower should approximate(Kilowatts(-9d)) + result._1.tick shouldBe (startTick + 1) + result._1.storedEnergy should approximate(oldState.storedEnergy) + val flexChangeIndication = result._2 + flexChangeIndication.changesAtTick should be( + Some(startTick + 1L + 10801L) + ) + flexChangeIndication.changesAtNextActivation should be(true) + } + "Handle the edge case of charging in negative target margin" in { + val storageModel = buildStorageModel(Some(0.4d)) + val startTick = 1800L + val data = new StorageModel.StorageRelevantData(startTick + 1) + // margin is at ~ 39.9975 kWh + val oldState = new StorageModel.StorageState( + KilowattHours(39.998d), + Kilowatts(0d), + startTick, + ) + + val result = storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(5d), + ) + + // Verifications + result._1.chargingPower should approximate(Kilowatts(5d)) + result._1.tick shouldBe (startTick + 1) + result._1.storedEnergy should approximate(oldState.storedEnergy) + val flexChangeIndication = result._2 + flexChangeIndication.changesAtTick should be( + Some(startTick + 1L + 48002L) + ) + flexChangeIndication.changesAtNextActivation should be(true) + } + } } From 5506f9ee2ec017d19b87dfe329521e57a9603f82 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Tue, 22 Oct 2024 11:38:37 +0200 Subject: [PATCH 022/137] Remove unnecessary use of new. --- .../ie3/simona/model/participant/StorageModelSpec.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index e235a1d233..0c85da85e9 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -363,9 +363,9 @@ class StorageModelSpec extends UnitSpec with Matchers { "Handle the edge case of discharging in positive target margin" in { val storageModel = buildStorageModel(Some(0.3d)) val startTick = 1800L - val data = new StorageModel.StorageRelevantData(startTick + 1) + val data = StorageModel.StorageRelevantData(startTick + 1) // margin is at ~ 30.0025 kWh - val oldState = new StorageModel.StorageState( + val oldState = StorageModel.StorageState( KilowattHours(30.0024d), Kilowatts(0d), startTick, @@ -390,9 +390,9 @@ class StorageModelSpec extends UnitSpec with Matchers { "Handle the edge case of charging in negative target margin" in { val storageModel = buildStorageModel(Some(0.4d)) val startTick = 1800L - val data = new StorageModel.StorageRelevantData(startTick + 1) + val data = StorageModel.StorageRelevantData(startTick + 1) // margin is at ~ 39.9975 kWh - val oldState = new StorageModel.StorageState( + val oldState = StorageModel.StorageState( KilowattHours(39.998d), Kilowatts(0d), startTick, From 32dea34a90aac575aeaf263eb2be80fb8e369d1f Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Sat, 26 Oct 2024 18:06:06 +0200 Subject: [PATCH 023/137] remove unused parameter --- .../simona/model/participant/HpModel.scala | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 569bd48c10..3c02b58f09 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -133,7 +133,7 @@ final case class HpModel( val (turnOn, canOperate, canBeOutOfOperation, houseDemand, storageDemand) = operatesInNextState(lastState, relevantData) val updatedState = - calcState(lastState, relevantData, turnOn, houseDemand, storageDemand) + calcState(lastState, relevantData, turnOn) (canOperate, canBeOutOfOperation, updatedState) } @@ -224,8 +224,6 @@ final case class HpModel( state: HpState, relevantData: HpRelevantData, isRunning: Boolean, - houseDemand: Boolean, - storageDemand: Boolean, ): HpState = { val lastStateStorageqDot = state.thermalGridState.storageState .map(_.qDot) @@ -311,36 +309,11 @@ final case class HpModel( /* If the setpoint value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */ val turnOn = setPower > (sRated * cosPhiRated * 0.5) - val ( - thermalEnergyDemandHouse, - thermalEnergyDemandStorage, - updatedThermalGridState, - ) = - thermalGrid.energyDemandAndUpdatedState( - data.currentTick, - lastState.ambientTemperature.getOrElse(data.ambientTemperature), - data.ambientTemperature, - lastState.thermalGridState, - ) - - val ( - houseDemand, - heatStorageDemand, - noThermalStorageOrThermalStorageIsEmpty, - ) = determineDemandBooleans( - lastState, - updatedThermalGridState, - thermalEnergyDemandHouse, - thermalEnergyDemandStorage, - ) - val updatedHpState: HpState = calcState( lastState, data, turnOn, - houseDemand, - heatStorageDemand, ) ( From e886345b083572f60a6d97665d4613cb42385c09 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 28 Oct 2024 09:25:43 +0100 Subject: [PATCH 024/137] remove unused parameter --- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 3c02b58f09..e136de4d54 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -130,7 +130,7 @@ final case class HpModel( lastState: HpState, relevantData: HpRelevantData, ): (Boolean, Boolean, HpState) = { - val (turnOn, canOperate, canBeOutOfOperation, houseDemand, storageDemand) = + val (turnOn, canOperate, canBeOutOfOperation) = operatesInNextState(lastState, relevantData) val updatedState = calcState(lastState, relevantData, turnOn) @@ -149,12 +149,12 @@ final case class HpModel( * Relevant (external) data * @return * boolean defining if heat pump runs in next time step, if it can be in - * operation and out of operation plus the demand of house and storage + * operation and can be out of operation */ private def operatesInNextState( state: HpState, relevantData: HpRelevantData, - ): (Boolean, Boolean, Boolean, Boolean, Boolean) = { + ): (Boolean, Boolean, Boolean) = { val (demandHouse, demandThermalStorage, updatedState) = thermalGrid.energyDemandAndUpdatedState( relevantData.currentTick, @@ -183,7 +183,7 @@ final case class HpModel( val canBeOutOfOperation = !(demandHouse.hasRequiredDemand && noThermalStorageOrThermalStorageIsEmpty) - (turnHpOn, canOperate, canBeOutOfOperation, houseDemand, heatStorageDemand) + (turnHpOn, canOperate, canBeOutOfOperation) } def determineDemandBooleans( From b893c0897a3a23b2725c8af9362bd7458dbb0bd2 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 28 Oct 2024 09:49:22 +0100 Subject: [PATCH 025/137] fix scapegoat code smell because of unnecessary store before return --- .../ie3/simona/agent/participant/hp/HpAgentFundamentals.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index a390f290b6..9eb908d1ac 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -314,9 +314,7 @@ trait HpAgentFundamentals nodalVoltage: squants.Dimensionless, model: HpModel, ): HpState = { - val (_, _, state) = - model.determineState(modelState, calcRelevantData) - state + model.determineState(modelState, calcRelevantData)._3 } /** Abstract definition, individual implementations found in individual agent From 23b2582f027a3869d7b09e623f550d1bbccfe686 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 28 Oct 2024 12:06:54 +0100 Subject: [PATCH 026/137] Proposal for separating state and operation point calculation --- .../simona/model/participant/HpModel.scala | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index e136de4d54..1eb45443ec 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -118,7 +118,7 @@ final case class HpModel( * function calculates the heat pump's next state to get the actual active * power of this state use [[calculateActivePower]] with the generated state * - * @param lastState + * @param lastHpState * Last state of the heat pump * @param relevantData * data of heat pump including @@ -127,13 +127,34 @@ final case class HpModel( * [[HpState]] */ def determineState( - lastState: HpState, + lastHpState: HpState, relevantData: HpRelevantData, ): (Boolean, Boolean, HpState) = { + + // Use lastHpState and relevantData to update state of thermalGrid to the current tick + val (demandHouse, demandThermalStorage, currentThermalGridState) = + thermalGrid.energyDemandAndUpdatedState( + relevantData.currentTick, + lastHpState.ambientTemperature.getOrElse( + relevantData.ambientTemperature + ), + relevantData.ambientTemperature, + lastHpState.thermalGridState, + ) + + // Determining the operation point and limitations at this tick val (turnOn, canOperate, canBeOutOfOperation) = - operatesInNextState(lastState, relevantData) + operatesInNextState( + lastHpState, + currentThermalGridState, + relevantData, + demandHouse, + demandThermalStorage, + ) + + // Updating the HpState val updatedState = - calcState(lastState, relevantData, turnOn) + calcState(lastHpState, relevantData, turnOn) (canOperate, canBeOutOfOperation, updatedState) } @@ -143,39 +164,41 @@ final case class HpModel( * met or the heat pump currently is in operation and the grid is able to * handle additional energy * - * @param state - * Current state of the heat pump + * @param lastState + * last state of the heat pump + * @param currentThermalGridState + * to current tick updated state of the thermalGrid * @param relevantData * Relevant (external) data + * @param demandHouse + * ThermalEnergyDemand of the house + * @param demandThermalStorage + * ThermalEnergyDemand of the thermal storage * @return * boolean defining if heat pump runs in next time step, if it can be in * operation and can be out of operation */ private def operatesInNextState( - state: HpState, + lastState: HpState, + currentThermalGridState: ThermalGridState, relevantData: HpRelevantData, + demandHouse: ThermalEnergyDemand, + demandThermalStorage: ThermalEnergyDemand, ): (Boolean, Boolean, Boolean) = { - val (demandHouse, demandThermalStorage, updatedState) = - thermalGrid.energyDemandAndUpdatedState( - relevantData.currentTick, - state.ambientTemperature.getOrElse(relevantData.ambientTemperature), - relevantData.ambientTemperature, - state.thermalGridState, - ) val ( - houseDemand, - heatStorageDemand, + houseHasDemand, + heatStorageHasDemand, noThermalStorageOrThermalStorageIsEmpty, ) = determineDemandBooleans( - state, - updatedState, + lastState, + currentThermalGridState, demandHouse, demandThermalStorage, ) val turnHpOn: Boolean = - houseDemand || heatStorageDemand + houseHasDemand || heatStorageHasDemand val canOperate = demandHouse.hasRequiredDemand || demandHouse.hasAdditionalDemand || From 7ada36fd5b6b57fb62a2833613afc3fd414a0ae2 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 28 Oct 2024 12:48:14 +0100 Subject: [PATCH 027/137] Use zeroKW and remove comments --- .../model/participant/StorageModelSpec.scala | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 0c85da85e9..c93c411b85 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -17,6 +17,7 @@ import edu.ie3.simona.test.common.UnitSpec import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.quantities.PowerSystemUnits._ +import edu.ie3.util.scala.quantities.DefaultQuantities.zeroKW import org.scalatest.matchers.should.Matchers import squants.energy.{KilowattHours, Kilowatts} import squants.{Energy, Power} @@ -28,8 +29,8 @@ import java.util.UUID class StorageModelSpec extends UnitSpec with Matchers { final val inputModel: StorageInput = createStorageInput() - final implicit val powerTolerance: Power = Kilowatts(1e-10) - final implicit val energyTolerance: Energy = KilowattHours(1e-10) + implicit val powerTolerance: Power = Kilowatts(1e-10) + implicit val energyTolerance: Energy = KilowattHours(1e-10) def createStorageInput(): StorageInput = { val nodeInput = new NodeInput( @@ -90,17 +91,28 @@ class StorageModelSpec extends UnitSpec with Matchers { val testCases = Table( ("lastStored", "lastPower", "timeDelta", "pRef", "pMin", "pMax"), // UNCHANGED STATE + // completely empty (0.0, 0.0, 1, 0.0, 0.0, 10.0), + // at a tiny bit above empty (0.011, 0.0, 1, 0.0, -10.0, 10.0), + // at mid-level charge (60.0, 0.0, 1, 0.0, -10.0, 10.0), + // almost fully charged (99.989, 0.0, 1, 0.0, -10.0, 10.0), + // fully charged (100.0, 0.0, 1, 0.0, -10.0, 0.0), // CHANGED STATE + // discharged to empty (10.0, -9.0, 3600, 0.0, 0.0, 10.0), + // almost discharged to lowest allowed charge (10.0, -9.0, 3590, 0.0, -10.0, 10.0), + // charged to mid-level charge (41.0, 10.0, 3600, 0.0, -10.0, 10.0), + // discharged to mid-level charge (60.0, -9.0, 3600, 0.0, -10.0, 10.0), + // almost fully charged (95.5, 4.98, 3600, 0.0, -10.0, 10.0), + // fully charged (95.5, 5.0, 3600, 0.0, -10.0, 0.0), ) @@ -158,7 +170,7 @@ class StorageModelSpec extends UnitSpec with Matchers { (lastStored: Double, pRef: Double, pMin: Double, pMax: Double) => val oldState = StorageModel.StorageState( KilowattHours(lastStored), - Kilowatts(0d), + zeroKW, startTick, ) @@ -220,14 +232,12 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel.handleControlledPowerChange( + val (newState, flexChangeIndication) = storageModel.handleControlledPowerChange( data, oldState, Kilowatts(setPower), ) - val (newState, flexChangeIndication) = result - newState.chargingPower should approximate(Kilowatts(expPower)) newState.tick shouldBe (startTick + 1) newState.storedEnergy should approximate(KilowattHours(lastStored)) @@ -259,13 +269,14 @@ class StorageModelSpec extends UnitSpec with Matchers { (50.0, 0.0, 0.0, false, false, 0), (100.0, 0.0, 0.0, false, false, 0), // charging on empty - (0.0, 1.0, 1.0, true, true, (50 * 3600 / 0.9).toInt), - (0.0, 2.5, 2.5, true, true, (20 * 3600 / 0.9).toInt), - (0.0, 5.0, 5.0, true, true, (10 * 3600 / 0.9).toInt), - (0.0, 10.0, 10.0, true, true, (5 * 3600 / 0.9).toInt), + (0.0, 1.0, 1.0, true, true, 50 * 3600 / 0.9), + //), + // (0.0, 2.5, 2.5, true, true, (20 * 3600 / 0.9)), + // (0.0, 5.0, 5.0, true, true, (10 * 3600 / 0.9)), + //(0.0, 10.0, 10.0, true, true, 5 * 3600 / 0.9), // charging on target ref - (50.0, 5.0, 5.0, true, true, (10 * 3600 / 0.9).toInt), - (50.0, 10.0, 10.0, true, true, (5 * 3600 / 0.9).toInt), + // (50.0, 5.0, 5.0, true, true, 10 * 3600 / 0.9), + // (50.0, 10.0, 10.0, true, true, 5 * 3600 / 0.9), // discharging on target ref (50.0, -4.5, -4.5, true, true, 10 * 3600), (50.0, -9.0, -9.0, true, true, 5 * 3600), @@ -276,16 +287,17 @@ class StorageModelSpec extends UnitSpec with Matchers { forAll(testCases) { ( + lastStored: Double, setPower: Double, expPower: Double, expActiveNext: Boolean, expScheduled: Boolean, - expDelta: Int, + expDelta: Double, ) => val oldState = StorageModel.StorageState( KilowattHours(lastStored), - Kilowatts(0d), + zeroKW, startTick, ) @@ -302,6 +314,7 @@ class StorageModelSpec extends UnitSpec with Matchers { newState.storedEnergy should approximate(KilowattHours(lastStored)) flexChangeIndication.changesAtTick.isDefined shouldBe expScheduled + // flexChangeIndication.changesAtTick().map(x -> x == startTick + 1 + expDelta).getOrElse(_ -> true) flexChangeIndication.changesAtTick.forall( _ == (startTick + 1 + expDelta) ) shouldBe true @@ -326,7 +339,7 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(-5d), ) - result._1.chargingPower should approximate(Kilowatts(0)) + result._1.chargingPower should approximate(zeroKW) result._1.tick shouldBe (startTick + 1) result._1.storedEnergy should approximate(oldState.storedEnergy) @@ -342,7 +355,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // margin is at ~ 99.9975 kWh val oldState = StorageModel.StorageState( KilowattHours(99.999d), - Kilowatts(0d), + zeroKW, startTick, ) @@ -352,7 +365,7 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(9d), ) - result._1.chargingPower should approximate(Kilowatts(0)) + result._1.chargingPower should approximate(zeroKW) result._1.tick shouldBe (startTick + 1) result._1.storedEnergy should approximate(oldState.storedEnergy) @@ -367,7 +380,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // margin is at ~ 30.0025 kWh val oldState = StorageModel.StorageState( KilowattHours(30.0024d), - Kilowatts(0d), + zeroKW, startTick, ) @@ -377,7 +390,6 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(-9d), ) - // Verifications result._1.chargingPower should approximate(Kilowatts(-9d)) result._1.tick shouldBe (startTick + 1) result._1.storedEnergy should approximate(oldState.storedEnergy) @@ -394,7 +406,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // margin is at ~ 39.9975 kWh val oldState = StorageModel.StorageState( KilowattHours(39.998d), - Kilowatts(0d), + zeroKW, startTick, ) @@ -404,7 +416,6 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(5d), ) - // Verifications result._1.chargingPower should approximate(Kilowatts(5d)) result._1.tick shouldBe (startTick + 1) result._1.storedEnergy should approximate(oldState.storedEnergy) From 6be8e36fe31833c3e6b727be6572b2b3b9e69ff4 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 11:30:30 +0100 Subject: [PATCH 028/137] aligning states of HpModel --- .../participant/hp/HpAgentFundamentals.scala | 4 +- .../simona/model/participant/HpModel.scala | 48 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index 9eb908d1ac..dc9465e67b 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -189,7 +189,7 @@ trait HpAgentFundamentals val accompanyingResults = baseStateData.model.thermalGrid.results( tick, - updatedState.thermalGridState, + updatedState.currentThermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) @@ -254,7 +254,7 @@ trait HpAgentFundamentals ) val accompanyingResults = baseStateData.model.thermalGrid.results( currentTick, - lastModelState.thermalGridState, + lastModelState.currentThermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 1eb45443ec..a3f04c0209 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -82,7 +82,7 @@ final case class HpModel( * [[HpModel.determineState]]. This state then is fed into the power * calculation logic by [[HpState]]. * - * @param modelState + * @param currentState * Current state of the heat pump * @param relevantData * data of heat pump including state of the heat pump @@ -90,9 +90,9 @@ final case class HpModel( * active power */ override protected def calculateActivePower( - modelState: HpState, + currentState: HpState, relevantData: HpRelevantData, - ): Power = modelState.activePower + ): Power = currentState.activePower /** "Calculate" the heat output of the heat pump. The hp's state is already * updated, because the calculation of apparent power in @@ -101,7 +101,7 @@ final case class HpModel( * * @param tick * Current simulation time for the calculation - * @param modelState + * @param currentState * Current state of the heat pump * @param data * Relevant (external) data for calculation @@ -110,20 +110,20 @@ final case class HpModel( */ override def calculateHeat( tick: Long, - modelState: HpState, + currentState: HpState, data: HpRelevantData, - ): Power = modelState.qDot + ): Power = currentState.qDot - /** Given a [[HpRelevantData]] object and the current [[HpState]], this - * function calculates the heat pump's next state to get the actual active - * power of this state use [[calculateActivePower]] with the generated state + /** Given a [[HpRelevantData]] object and the last [[HpState]], this function + * calculates the heat pump's next state to get the actual active power of + * this state use [[calculateActivePower]] with the generated state * * @param lastHpState * Last state of the heat pump * @param relevantData * data of heat pump including * @return - * Booleans if Hp can operate and can be out of operation plus next + * Booleans if Hp can operate and can be out of operation plus the updated * [[HpState]] */ def determineState( @@ -139,7 +139,7 @@ final case class HpModel( relevantData.ambientTemperature ), relevantData.ambientTemperature, - lastHpState.thermalGridState, + lastHpState.currentThermalGridState, ) // Determining the operation point and limitations at this tick @@ -210,7 +210,7 @@ final case class HpModel( } def determineDemandBooleans( - hpState: HpState, + lastHpState: HpState, updatedGridState: ThermalGridState, demandHouse: ThermalEnergyDemand, demandThermalStorage: ThermalEnergyDemand, @@ -223,9 +223,9 @@ final case class HpModel( ) val houseDemand = - (demandHouse.hasRequiredDemand && noThermalStorageOrThermalStorageIsEmpty) || (hpState.isRunning && demandHouse.hasAdditionalDemand) + (demandHouse.hasRequiredDemand && noThermalStorageOrThermalStorageIsEmpty) || (lastHpState.isRunning && demandHouse.hasAdditionalDemand) val heatStorageDemand = { - (demandThermalStorage.hasRequiredDemand) || (hpState.isRunning && demandThermalStorage.hasAdditionalDemand) + (demandThermalStorage.hasRequiredDemand) || (lastHpState.isRunning && demandThermalStorage.hasAdditionalDemand) } (houseDemand, heatStorageDemand, noThermalStorageOrThermalStorageIsEmpty) } @@ -234,8 +234,8 @@ final case class HpModel( * calculate inner temperature change of thermal house and update its inner * temperature. * - * @param state - * Current state of the heat pump + * @param lastState + * state of the heat pump until this tick * @param relevantData * data of heat pump including state of the heat pump * @param isRunning @@ -244,27 +244,27 @@ final case class HpModel( * next [[HpState]] */ private def calcState( - state: HpState, + lastState: HpState, relevantData: HpRelevantData, isRunning: Boolean, ): HpState = { - val lastStateStorageqDot = state.thermalGridState.storageState + val lastStateStorageQDot = lastState.currentThermalGridState.storageState .map(_.qDot) .getOrElse(zeroKW) val (newActivePower, newThermalPower) = if (isRunning) (pRated, pThermal) - else if (lastStateStorageqDot < zeroKW) - (zeroKW, lastStateStorageqDot * (-1)) + else if (lastStateStorageQDot < zeroKW) + (zeroKW, lastStateStorageQDot * (-1)) else (zeroKW, zeroKW) /* Push thermal energy to the thermal grid and get its updated state in return */ val (thermalGridState, maybeThreshold) = thermalGrid.updateState( relevantData.currentTick, - state.thermalGridState, - state.ambientTemperature.getOrElse(relevantData.ambientTemperature), + lastState.currentThermalGridState, + lastState.ambientTemperature.getOrElse(relevantData.ambientTemperature), relevantData.ambientTemperature, newThermalPower, ) @@ -411,7 +411,7 @@ object HpModel { * result active power * @param qDot * result heat power - * @param thermalGridState + * @param currentThermalGridState * Currently applicable state of the thermal grid * @param maybeThermalThreshold * An optional threshold of the thermal grid, indicating the next state @@ -423,7 +423,7 @@ object HpModel { ambientTemperature: Option[Temperature], activePower: Power, qDot: Power, - thermalGridState: ThermalGridState, + currentThermalGridState: ThermalGridState, maybeThermalThreshold: Option[ThermalThreshold], ) extends ModelState From 286f0ebad8d7f9b94dccf7a2bad139db0721ee61 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 29 Oct 2024 11:30:41 +0100 Subject: [PATCH 029/137] add scala doc --- .../edu/ie3/simona/model/participant/HpModel.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index a3f04c0209..c104571b9b 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -209,6 +209,20 @@ final case class HpModel( (turnHpOn, canOperate, canBeOutOfOperation) } + /** This method will return booleans whether there is a heat demand of house + * or thermal storage as well as a boolean indicating if there is no thermal + * storage or it is empty. + * + * @param lastHpState + * @param updatedGridState + * @param demandHouse + * @param demandThermalStorage + * @return + * First boolean: true, if house has heat demand Second boolean: true, if + * thermalStorage has heat demand Third boolean: true, if there is no + * thermalStorage or it's empty + */ + def determineDemandBooleans( lastHpState: HpState, updatedGridState: ThermalGridState, From bcef5a84fc4db9ba5242b5f07fff64a856cd996c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 31 Oct 2024 07:20:53 +0100 Subject: [PATCH 030/137] fix test to handle controlled power change and controlled power chang with ref target SOC --- .../model/participant/StorageModelSpec.scala | 66 +++++++++---------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index c93c411b85..e66a3ee408 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -198,23 +198,23 @@ class StorageModelSpec extends UnitSpec with Matchers { "expDelta", ), // no power - (0.0, 0.0, 0.0, false, false, 0), - (50.0, 0.0, 0.0, false, false, 0), - (100.0, 0.0, 0.0, false, false, 0), + (0.0, 0.0, 0.0, false, false, 0.0), + (50.0, 0.0, 0.0, false, false, 0.0), + (100.0, 0.0, 0.0, false, false, 0.0), // charging on empty - (0.0, 1.0, 1.0, true, true, (100 * 3600 / 0.9).toInt), - (0.0, 2.5, 2.5, true, true, (40 * 3600 / 0.9).toInt), - (0.0, 5.0, 5.0, true, true, (20 * 3600 / 0.9).toInt), - (0.0, 10.0, 10.0, true, true, (10 * 3600 / 0.9).toInt), + (0.0, 1.0, 1.0, true, true, 100 * 3600 / 0.9), + (0.0, 2.5, 2.5, true, true, 40 * 3600 / 0.9), + (0.0, 5.0, 5.0, true, true, 20 * 3600 / 0.9), + (0.0, 10.0, 10.0, true, true, 10 * 3600 / 0.9), // charging on half full - (50.0, 5.0, 5.0, false, true, (10 * 3600 / 0.9).toInt), - (50.0, 10.0, 10.0, false, true, (5 * 3600 / 0.9).toInt), + (50.0, 5.0, 5.0, false, true, 10 * 3600 / 0.9), + (50.0, 10.0, 10.0, false, true, 5 * 3600 / 0.9), // discharging on half full - (50.0, -4.5, -4.5, false, true, 10 * 3600), - (50.0, -9.0, -9.0, false, true, 5 * 3600), + (50.0, -4.5, -4.5, false, true, 10 * 3600.0), + (50.0, -9.0, -9.0, false, true, 5 * 3600.0), // discharging on full - (100.0, -4.5, -4.5, true, true, 20 * 3600), - (100.0, -9.0, -9.0, true, true, 10 * 3600), + (100.0, -4.5, -4.5, true, true, 20 * 3600.0), + (100.0, -9.0, -9.0, true, true, 10 * 3600.0), ) forAll(testCases) { @@ -224,7 +224,7 @@ class StorageModelSpec extends UnitSpec with Matchers { expPower: Double, expActiveNext: Boolean, expScheduled: Boolean, - expDelta: Int, + expDelta: Double, ) => val oldState = StorageModel.StorageState( KilowattHours(lastStored), @@ -232,11 +232,12 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val (newState, flexChangeIndication) = storageModel.handleControlledPowerChange( - data, - oldState, - Kilowatts(setPower), - ) + val (newState, flexChangeIndication) = + storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(setPower), + ) newState.chargingPower should approximate(Kilowatts(expPower)) newState.tick shouldBe (startTick + 1) @@ -265,29 +266,27 @@ class StorageModelSpec extends UnitSpec with Matchers { "expDelta", ), // no power - (0.0, 0.0, 0.0, false, false, 0), - (50.0, 0.0, 0.0, false, false, 0), - (100.0, 0.0, 0.0, false, false, 0), + (0.0, 0.0, 0.0, false, false, 0.0), + (50.0, 0.0, 0.0, false, false, 0.0), + (100.0, 0.0, 0.0, false, false, 0.0), // charging on empty (0.0, 1.0, 1.0, true, true, 50 * 3600 / 0.9), - //), - // (0.0, 2.5, 2.5, true, true, (20 * 3600 / 0.9)), - // (0.0, 5.0, 5.0, true, true, (10 * 3600 / 0.9)), - //(0.0, 10.0, 10.0, true, true, 5 * 3600 / 0.9), + (0.0, 2.5, 2.5, true, true, 20 * 3600 / 0.9), + (0.0, 5.0, 5.0, true, true, 10 * 3600 / 0.9), + (0.0, 10.0, 10.0, true, true, 5 * 3600 / 0.9), // charging on target ref - // (50.0, 5.0, 5.0, true, true, 10 * 3600 / 0.9), - // (50.0, 10.0, 10.0, true, true, 5 * 3600 / 0.9), + (50.0, 5.0, 5.0, true, true, 10 * 3600 / 0.9), + (50.0, 10.0, 10.0, true, true, 5 * 3600 / 0.9), // discharging on target ref - (50.0, -4.5, -4.5, true, true, 10 * 3600), - (50.0, -9.0, -9.0, true, true, 5 * 3600), + (50.0, -4.5, -4.5, true, true, 10 * 3600.0), + (50.0, -9.0, -9.0, true, true, 5 * 3600.0), // discharging on full - (100.0, -4.5, -4.5, true, true, 10 * 3600), - (100.0, -9.0, -9.0, true, true, 5 * 3600), + (100.0, -4.5, -4.5, true, true, 10 * 3600.0), + (100.0, -9.0, -9.0, true, true, 5 * 3600.0), ) forAll(testCases) { ( - lastStored: Double, setPower: Double, expPower: Double, @@ -314,7 +313,6 @@ class StorageModelSpec extends UnitSpec with Matchers { newState.storedEnergy should approximate(KilowattHours(lastStored)) flexChangeIndication.changesAtTick.isDefined shouldBe expScheduled - // flexChangeIndication.changesAtTick().map(x -> x == startTick + 1 + expDelta).getOrElse(_ -> true) flexChangeIndication.changesAtTick.forall( _ == (startTick + 1 + expDelta) ) shouldBe true From f44dddff0798a43571e0440edeb78ef265b46284 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 1 Nov 2024 18:15:07 +0100 Subject: [PATCH 031/137] merging dev --- .../ie3/simona/agent/participant/hp/HpAgentFundamentals.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index 58b9c402b1..128e1e7395 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -189,7 +189,7 @@ trait HpAgentFundamentals val accompanyingResults = baseStateData.model.thermalGrid.results( updatedState.tick, - updatedState.thermalGridState, + updatedState.currentThermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) @@ -254,7 +254,7 @@ trait HpAgentFundamentals ) val accompanyingResults = baseStateData.model.thermalGrid.results( updatedState.tick, - updatedState.thermalGridState, + updatedState.currentThermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) From d0fa7abecae7d38c5b38e751e21cf4a138d9faeb Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 4 Nov 2024 15:39:34 +0100 Subject: [PATCH 032/137] Cleaned up formatting Signed-off-by: Sebastian Peter --- docs/uml/main/ExtEvSimulationClasses.puml | 121 +++++++++++----------- 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index bb74a9b0e8..03507633f8 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -4,16 +4,16 @@ skinparam linetype ortho skinparam nodesep 50 skinparam ranksep 40 -skinparam node{ - borderColor Transparent - fontColor Transparent - } +skinparam node { + borderColor Transparent + fontColor Transparent +} package MobilitySimulator { class ExtLink class MobilitySim class ElectricVehicle - } +} package simona-api { @@ -53,11 +53,10 @@ package simona-api { + ComparableQuantity getStoredEnergy() + Long getDepartureTick() + EvModel copyWith(ComparableQuantity newStoredEnergy) - } + } ElectricVehicle --|> EvModel - interface ExtData class ExtEvData { @@ -70,22 +69,22 @@ package simona-api { + void provideArrivingEvs(Map> arrivals, Optional maybeNextTick) + void sendExtMsg(EvDataMessageFromExt msg) + void queueExtResponseMsg(EvDataResponseMessageToExt extEvResponse) - } + } node sub2{ - interface EvDataMessageFromExt + interface EvDataMessageFromExt - interface DataMessageFromExt + interface DataMessageFromExt - class ProvideArrivingEvs + class ProvideArrivingEvs - class RequestCurrentPrices + class RequestCurrentPrices - class RequestDepartingEvs + class RequestDepartingEvs - class RequestEvcsFreeLots + class RequestEvcsFreeLots + } -} RequestDepartingEvs --u|> EvDataMessageFromExt RequestEvcsFreeLots --u|> EvDataMessageFromExt ProvideArrivingEvs --u|> EvDataMessageFromExt @@ -96,61 +95,57 @@ package simona-api { ExtEvData --u|> ExtData ExtEvSimulation -u> ExtEvData -node sub1{ - interface DataResponseMessageToExt - - interface EvDataResponseMessageToExt + node sub1{ + interface DataResponseMessageToExt - class ProvideCurrentPrices{ - + ProvideCurrentPrices() - } + interface EvDataResponseMessageToExt - class ProvideDepartingEvs{ - + ProvideDepartingEvs() - } + class ProvideCurrentPrices{ + + ProvideCurrentPrices() + } - class ProvideEvcsFreeLots{ - + ProvideEvcsFreeLots() - } + class ProvideDepartingEvs{ + + ProvideDepartingEvs() + } - ProvideEvcsFreeLots --|> EvDataResponseMessageToExt - ProvideDepartingEvs --|> EvDataResponseMessageToExt - ProvideCurrentPrices --|> EvDataResponseMessageToExt - ExtEvData --> EvDataResponseMessageToExt - DataResponseMessageToExt --|> EvDataResponseMessageToExt -} + class ProvideEvcsFreeLots{ + + ProvideEvcsFreeLots() + } + ProvideEvcsFreeLots --|> EvDataResponseMessageToExt + ProvideDepartingEvs --|> EvDataResponseMessageToExt + ProvideCurrentPrices --|> EvDataResponseMessageToExt + ExtEvData --> EvDataResponseMessageToExt + DataResponseMessageToExt --|> EvDataResponseMessageToExt + } -node sub3{ - class ExtSimAdapterData { - + LinkedBlockingQueue receiveTriggerQueue - - ActorRef extSimAdapter - - String[] mainArgs - + void queueExtMsg(ControlMessageToExt msg) - + void send(ControlResponseMessageFromExt msg) - + String[] getMainArgs() - } + node sub3 { + class ExtSimAdapterData { + + LinkedBlockingQueue receiveTriggerQueue + - ActorRef extSimAdapter + - String[] mainArgs + + void queueExtMsg(ControlMessageToExt msg) + + void send(ControlResponseMessageFromExt msg) + + String[] getMainArgs() + } - interface ControlMessageToExt + interface ControlMessageToExt - interface ControlResponseMessageFromExt + interface ControlResponseMessageFromExt - class CompletionMessage + class CompletionMessage - class ActivationMessage + class ActivationMessage - ExtSimAdapterData --u> ControlMessageToExt - ExtSimAdapterData --u> ControlResponseMessageFromExt - CompletionMessage --d|> ControlResponseMessageFromExt - ActivationMessage --d|> ControlMessageToExt - ExtSimulation -----> ExtSimAdapterData + ExtSimAdapterData --u> ControlMessageToExt + ExtSimAdapterData --u> ControlResponseMessageFromExt + CompletionMessage --d|> ControlResponseMessageFromExt + ActivationMessage --d|> ControlMessageToExt + ExtSimulation -----> ExtSimAdapterData } - } - - package simona { abstract class ParticipantAgent @@ -193,15 +188,15 @@ package simona { EvcsAgent --|> ParticipantAgent EvcsAgent *- EvcsModel - } +} - 'Order of classes/interfaces established through hidden connections: +'Order of classes/interfaces established through hidden connections: - ExtSimAdapter -[hidden]> SimonaService - sub1 ---[hidden]d> sub2 - ExtLink -[hidden]> ElectricVehicle - ExtSimulation -[hidden]> ExtEvSimulation - ExtSimulation -[hidden]> DataResponseMessageToExt - RequestDepartingEvs --[hidden]> SecondaryData +ExtSimAdapter -[hidden]> SimonaService +sub1 ---[hidden]d> sub2 +ExtLink -[hidden]> ElectricVehicle +ExtSimulation -[hidden]> ExtEvSimulation +ExtSimulation -[hidden]> DataResponseMessageToExt +RequestDepartingEvs --[hidden]> SecondaryData @enduml \ No newline at end of file From bb8cbf238027d4c4693908fd317726350046ec49 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 4 Nov 2024 15:50:28 +0100 Subject: [PATCH 033/137] More cleaning Signed-off-by: Sebastian Peter --- docs/uml/main/ExtEvSimulationClasses.puml | 50 +++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index 03507633f8..f54e57393b 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -147,46 +147,46 @@ package simona-api { } package simona { - abstract class ParticipantAgent + abstract class ParticipantAgent - class EvcsModel + class EvcsModel - class EvcsAgent + class EvcsAgent - interface SecondaryData - class EvMovementData { - movements: Set[EvMovement] - } + interface SecondaryData + class EvMovementData { + movements: Set[EvMovement] + } - class SimonaSim + class SimonaSim - class Scheduler + class Scheduler - class SimonaStandaloneSetup + class SimonaStandaloneSetup - class ExtSimLoader + class ExtSimLoader - class ExtSimAdapter + class ExtSimAdapter - class ExtEvDataService + class ExtEvDataService - Scheduler -- SimonaSim - SimonaSim *- SimonaStandaloneSetup - SimonaStandaloneSetup *- ExtSimLoader + Scheduler -- SimonaSim + SimonaSim *- SimonaStandaloneSetup + SimonaStandaloneSetup *- ExtSimLoader - ExtSimAdapter - Scheduler - ExtEvDataService -- Scheduler + ExtSimAdapter - Scheduler + ExtEvDataService -- Scheduler - SecondaryData <|-- EvMovementData + SecondaryData <|-- EvMovementData - SimonaService <|- ExtEvDataService - ExtEvData --- ExtEvDataService + SimonaService <|- ExtEvDataService + ExtEvData --- ExtEvDataService - ExtSimAdapterData <--- ExtSimAdapter + ExtSimAdapterData <--- ExtSimAdapter - ExtEvDataService "n" <-> "1" EvcsAgent - EvcsAgent --|> ParticipantAgent - EvcsAgent *- EvcsModel + ExtEvDataService "n" <-> "1" EvcsAgent + EvcsAgent --|> ParticipantAgent + EvcsAgent *- EvcsModel } From ce17f46f49d56908b9f8c5377b4f9f1ef40da236 Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:21:49 +0100 Subject: [PATCH 034/137] Update src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../edu/ie3/simona/model/participant/StorageModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index e66a3ee408..53cfb416bf 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -327,7 +327,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // margin is at ~ 0.0030864 kWh val oldState = StorageModel.StorageState( KilowattHours(0.002d), - Kilowatts(0d), + zeroKW, startTick, ) From 5b3dacb8e0037f7b4a188c87132654ba04285a42 Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:23:13 +0100 Subject: [PATCH 035/137] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 636344e4d1..ac4517ba8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,8 +92,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rewrote ChpModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Rewrote CylindricalThermalStorageTest Test from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Replace mutable var in ChpModelSpec [#1002](https://github.com/ie3-institute/simona/issues/1002) -- Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Move compression of output files into `ResultEventListener`[#965](https://github.com/ie3-institute/simona/issues/965) +- Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) From 235ff63783a20decb10c2832e3e840025bce7e8a Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Tue, 5 Nov 2024 14:23:01 +0100 Subject: [PATCH 036/137] fmt --- .../edu/ie3/simona/model/participant/StorageModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 53cfb416bf..8f2ca46def 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -327,7 +327,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // margin is at ~ 0.0030864 kWh val oldState = StorageModel.StorageState( KilowattHours(0.002d), - zeroKW, + zeroKW, startTick, ) From 0977febd97f99494db8cff16eab29b64c02b8221 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Tue, 5 Nov 2024 15:15:30 +0100 Subject: [PATCH 037/137] remove unnecessary use of val result. --- .../model/participant/StorageModelSpec.scala | 123 ++++++++++-------- 1 file changed, 71 insertions(+), 52 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 8f2ca46def..7e4d85ce8c 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -228,7 +228,7 @@ class StorageModelSpec extends UnitSpec with Matchers { ) => val oldState = StorageModel.StorageState( KilowattHours(lastStored), - Kilowatts(0d), + zeroKW, startTick, ) @@ -300,13 +300,12 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel.handleControlledPowerChange( - data, - oldState, - Kilowatts(setPower), - ) - - val (newState, flexChangeIndication) = result + val (newState, flexChangeIndication) = + storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(setPower), + ) newState.chargingPower should approximate(Kilowatts(expPower)) newState.tick shouldBe (startTick + 1) @@ -331,19 +330,23 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel.handleControlledPowerChange( - data, - oldState, - Kilowatts(-5d), - ) + val (newState, flexChangeIndication) = + storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(-5d), + ) - result._1.chargingPower should approximate(zeroKW) - result._1.tick shouldBe (startTick + 1) - result._1.storedEnergy should approximate(oldState.storedEnergy) + (newState, flexChangeIndication)._1.chargingPower should approximate( + zeroKW + ) + (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) + (newState, flexChangeIndication)._1.storedEnergy should approximate( + oldState.storedEnergy + ) - val flexChangeIndication = result._2 - flexChangeIndication.changesAtTick.isDefined shouldBe false - flexChangeIndication.changesAtNextActivation shouldBe true + (newState, flexChangeIndication)._2.changesAtTick.isDefined shouldBe false + (newState, flexChangeIndication)._2.changesAtNextActivation shouldBe true } "Handle the edge case of charging in tolerance margins" in { @@ -357,19 +360,23 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel.handleControlledPowerChange( - data, - oldState, - Kilowatts(9d), - ) + val (newState, flexChangeIndication) = + storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(9d), + ) - result._1.chargingPower should approximate(zeroKW) - result._1.tick shouldBe (startTick + 1) - result._1.storedEnergy should approximate(oldState.storedEnergy) + (newState, flexChangeIndication)._1.chargingPower should approximate( + zeroKW + ) + (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) + (newState, flexChangeIndication)._1.storedEnergy should approximate( + oldState.storedEnergy + ) - val flexChangeIndication = result._2 - flexChangeIndication.changesAtTick.isDefined shouldBe false - flexChangeIndication.changesAtNextActivation shouldBe true + (newState, flexChangeIndication)._2.changesAtTick.isDefined shouldBe false + (newState, flexChangeIndication)._2.changesAtNextActivation shouldBe true } "Handle the edge case of discharging in positive target margin" in { val storageModel = buildStorageModel(Some(0.3d)) @@ -382,20 +389,26 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel.handleControlledPowerChange( - data, - oldState, - Kilowatts(-9d), - ) + val (newState, flexChangeIndication) = + storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(-9d), + ) - result._1.chargingPower should approximate(Kilowatts(-9d)) - result._1.tick shouldBe (startTick + 1) - result._1.storedEnergy should approximate(oldState.storedEnergy) - val flexChangeIndication = result._2 - flexChangeIndication.changesAtTick should be( + (newState, flexChangeIndication)._1.chargingPower should approximate( + Kilowatts(-9d) + ) + (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) + (newState, flexChangeIndication)._1.storedEnergy should approximate( + oldState.storedEnergy + ) + (newState, flexChangeIndication)._2.changesAtTick should be( Some(startTick + 1L + 10801L) ) - flexChangeIndication.changesAtNextActivation should be(true) + (newState, flexChangeIndication)._2.changesAtNextActivation should be( + true + ) } "Handle the edge case of charging in negative target margin" in { val storageModel = buildStorageModel(Some(0.4d)) @@ -408,20 +421,26 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel.handleControlledPowerChange( - data, - oldState, - Kilowatts(5d), - ) + val (newState, flexChangeIndication) = + storageModel.handleControlledPowerChange( + data, + oldState, + Kilowatts(5d), + ) - result._1.chargingPower should approximate(Kilowatts(5d)) - result._1.tick shouldBe (startTick + 1) - result._1.storedEnergy should approximate(oldState.storedEnergy) - val flexChangeIndication = result._2 - flexChangeIndication.changesAtTick should be( + (newState, flexChangeIndication)._1.chargingPower should approximate( + Kilowatts(5d) + ) + (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) + (newState, flexChangeIndication)._1.storedEnergy should approximate( + oldState.storedEnergy + ) + (newState, flexChangeIndication)._2.changesAtTick should be( Some(startTick + 1L + 48002L) ) - flexChangeIndication.changesAtNextActivation should be(true) + (newState, flexChangeIndication)._2.changesAtNextActivation should be( + true + ) } } } From afc673b017ca61a1a5d941a2132341fa73ce01c5 Mon Sep 17 00:00:00 2001 From: Pierre <155652256+pierrepetersmeier@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:27:31 +0100 Subject: [PATCH 038/137] Update src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../edu/ie3/simona/model/participant/StorageModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 7e4d85ce8c..4326925a05 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -428,7 +428,7 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(5d), ) - (newState, flexChangeIndication)._1.chargingPower should approximate( + newState.chargingPower should approximate( Kilowatts(5d) ) (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) From 907c9944d7bd3d8b1ac923483876bf7b286c0aae Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 5 Nov 2024 15:53:39 +0100 Subject: [PATCH 039/137] Resolving merge conflicts. --- .../edu/ie3/simona/agent/em/EmDataCore.scala | 4 ---- .../messages/flex/FlexibilityMessage.scala | 2 +- .../edu/ie3/simona/agent/em/EmAgentSpec.scala | 22 +++++++++---------- .../EvcsAgentModelCalculationSpec.scala | 2 +- .../model/participant/ChpModelSpec.scala | 4 ++-- .../participant/SystemParticipantSpec.scala | 21 +++++++++++------- .../test/common/model/MockParticipant.scala | 7 +++--- 7 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala index b4fc5e06f2..aaf3943cc2 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala @@ -6,10 +6,6 @@ package edu.ie3.simona.agent.em -import edu.ie3.simona.agent.em.EmAgent.Actor -import edu.ie3.simona.agent.em.FlexCorrespondenceStore.WithTime -import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower -import edu.ie3.simona.exceptions.CriticalFailureException import edu.ie3.simona.agent.em.EmAgent.Actor import edu.ie3.simona.agent.em.FlexCorrespondenceStore.WithTime import edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower diff --git a/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala b/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala index 21a7f32cd6..662c11e2d2 100644 --- a/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala +++ b/src/main/scala/edu/ie3/simona/ontology/messages/flex/FlexibilityMessage.scala @@ -128,7 +128,7 @@ object FlexibilityMessage { */ final case class FlexResult( override val modelUuid: UUID, - result: ApparentPower, + result: ComplexPower, ) extends FlexResponse /** Message sent by flex options providers indicating that the diff --git a/src/test/scala/edu/ie3/simona/agent/em/EmAgentSpec.scala b/src/test/scala/edu/ie3/simona/agent/em/EmAgentSpec.scala index 07da29ed41..c0b8f93489 100644 --- a/src/test/scala/edu/ie3/simona/agent/em/EmAgentSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/em/EmAgentSpec.scala @@ -307,7 +307,7 @@ class EmAgentSpec // send completions emAgent ! FlexResult( modelUuid = pvInput.getUuid, - result = ApparentPower(Kilowatts(-5d), Kilovars(-0.5d)), + result = ComplexPower(Kilowatts(-5d), Kilovars(-0.5d)), ) emAgent ! FlexCompletion( modelUuid = pvInput.getUuid, @@ -316,7 +316,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = evcsInput.getUuid, - result = ApparentPower(Kilowatts(5d), Kilovars(0.1d)), + result = ComplexPower(Kilowatts(5d), Kilovars(0.1d)), ) scheduler.expectNoMessage() @@ -361,7 +361,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = pvInput.getUuid, - result = ApparentPower(Kilowatts(-3d), Kilovars(-0.06d)), + result = ComplexPower(Kilowatts(-3d), Kilovars(-0.06d)), ) emAgent ! FlexCompletion( @@ -378,7 +378,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = evcsInput.getUuid, - result = ApparentPower(Kilowatts(3d), Kilovars(0.06d)), + result = ComplexPower(Kilowatts(3d), Kilovars(0.06d)), ) emAgent ! FlexCompletion( modelUuid = evcsInput.getUuid, @@ -470,7 +470,7 @@ class EmAgentSpec // send completions emAgent ! FlexResult( modelUuid = pvInput.getUuid, - result = ApparentPower(Kilowatts(-5d), Kilovars(-0.5d)), + result = ComplexPower(Kilowatts(-5d), Kilovars(-0.5d)), ) emAgent ! FlexCompletion( modelUuid = pvInput.getUuid, @@ -479,7 +479,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = evcsInput.getUuid, - result = ApparentPower(Kilowatts(5d), Kilovars(0.1d)), + result = ComplexPower(Kilowatts(5d), Kilovars(0.1d)), ) scheduler.expectNoMessage() @@ -534,7 +534,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = pvInput.getUuid, - result = ApparentPower(Kilowatts(-3d), Kilovars(-0.06d)), + result = ComplexPower(Kilowatts(-3d), Kilovars(-0.06d)), ) emAgent ! FlexCompletion( modelUuid = pvInput.getUuid @@ -549,7 +549,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = evcsInput.getUuid, - result = ApparentPower(Kilowatts(3d), Kilovars(0.06d)), + result = ComplexPower(Kilowatts(3d), Kilovars(0.06d)), ) emAgent ! FlexCompletion( modelUuid = evcsInput.getUuid // revoking tick 600 @@ -696,7 +696,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = pvInput.getUuid, - result = ApparentPower(Kilowatts(-5), Kilovars(-0.5)), + result = ComplexPower(Kilowatts(-5), Kilovars(-0.5)), ) emAgent ! FlexCompletion( modelUuid = pvInput.getUuid, @@ -712,7 +712,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = evcsInput.getUuid, - result = ApparentPower(Kilowatts(11), Kilovars(1.1)), + result = ComplexPower(Kilowatts(11), Kilovars(1.1)), ) emAgent ! FlexCompletion( modelUuid = evcsInput.getUuid, @@ -762,7 +762,7 @@ class EmAgentSpec emAgent ! FlexResult( modelUuid = evcsInput.getUuid, - result = ApparentPower(Kilowatts(5.0), Kilovars(0.5)), + result = ComplexPower(Kilowatts(5.0), Kilovars(0.5)), ) emAgent ! FlexCompletion( modelUuid = evcsInput.getUuid, 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 77bf5a1505..74d3c83d90 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala @@ -2020,7 +2020,7 @@ class EvcsAgentModelCalculationSpec val initStateData = ParticipantInitializeStateData[ EvcsInput, EvcsRuntimeConfig, - ApparentPower, + ComplexPower, ]( evcsInputModel, modelConfig = modelConfig, diff --git a/src/test/scala/edu/ie3/simona/model/participant/ChpModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/ChpModelSpec.scala index 2d4a66da85..91a72ddd63 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/ChpModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/ChpModelSpec.scala @@ -6,9 +6,9 @@ package edu.ie3.simona.model.participant +import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.ChpInput import edu.ie3.datamodel.models.input.system.`type`.ChpTypeInput -import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed import edu.ie3.datamodel.models.input.thermal.{ CylindricalStorageInput, @@ -105,7 +105,7 @@ class ChpModelSpec "ChpModel", null, null, - Kilowatts(100), + Kilovoltamperes(100), 0.95, Kilowatts(50), thermalStorage, diff --git a/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala index 0c36be3e9c..ecb8afe884 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala @@ -15,7 +15,12 @@ import edu.ie3.simona.model.participant.control.QControl import edu.ie3.simona.test.common.UnitSpec import edu.ie3.simona.test.common.model.MockParticipant import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.{Kilovars, Megavars, ReactivePower} +import edu.ie3.util.scala.quantities.{ + Kilovars, + Kilovoltamperes, + Megavars, + ReactivePower, +} import org.scalatest.matchers.should.Matchers import squants._ import squants.energy._ @@ -52,7 +57,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { "System participant calculateQ Test", OperationInterval(0L, 86400L), QControl(new CosPhiFixed(varCharacteristicString)), - Kilowatts(200), + Kilovoltamperes(200), 1d, ) val power = Kilowatts(pVal) @@ -92,7 +97,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { QControl( new CosPhiP(varCharacteristicString) ), - Kilowatts(102), + Kilovoltamperes(102), 1d, ) val power = Kilowatts(pVal) @@ -130,7 +135,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { QControl( new CosPhiP(varCharacteristicString) ), - Kilowatts(101), + Kilovoltamperes(101), 1d, ) val power = Kilowatts(pVal) @@ -146,7 +151,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { "System participant calculateQ Test", OperationInterval(0L, 86400L), QControl(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Kilowatts(200), + Kilovoltamperes(200), 0.98, ) @@ -177,7 +182,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { "System participant calculateQ Test", OperationInterval(0L, 86400L), QControl(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Kilowatts(200), + Kilovoltamperes(200), 1d, ) @@ -208,7 +213,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { "System participant calculateQ Test", OperationInterval(0L, 86400L), QControl(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Kilowatts(200), + Kilovoltamperes(200), 0.95, ) @@ -240,7 +245,7 @@ class SystemParticipantSpec extends UnitSpec with Matchers { "System participant calculateQ Test", OperationInterval(0L, 86400L), QControl(new QV("qV:{(0.93,-1),(0.97,0),(1,0),(1.03,0),(1.07,1)}")), - Kilowatts(200), + Kilovoltamperes(200), 0.95, ) diff --git a/src/test/scala/edu/ie3/simona/test/common/model/MockParticipant.scala b/src/test/scala/edu/ie3/simona/test/common/model/MockParticipant.scala index ad407dbfb4..fdd518cb4b 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/MockParticipant.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/MockParticipant.scala @@ -16,6 +16,7 @@ import edu.ie3.simona.model.participant.{ } import edu.ie3.simona.ontology.messages.flex.FlexibilityMessage import edu.ie3.util.scala.OperationInterval +import edu.ie3.util.scala.quantities.ApparentPower import squants.Dimensionless import squants.energy._ @@ -26,11 +27,11 @@ class MockParticipant( id: String, operationInterval: OperationInterval, qControl: QControl, - sRated: Power, + sRated: ApparentPower, cosPhiRated: Double, ) extends SystemParticipant[ CalcRelevantData, - Data.PrimaryData.ApparentPower, + Data.PrimaryData.ComplexPower, ModelState, ]( uuid, @@ -46,7 +47,7 @@ class MockParticipant( voltage: Dimensionless, state: ModelState, data: CalcRelevantData, - ): Data.PrimaryData.ApparentPower = { + ): Data.PrimaryData.ComplexPower = { super.calculateApparentPower(tick, voltage, state, data) } From ae614e9e6735edb76d83650d578ad2bc1d90c69d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:09:27 +0100 Subject: [PATCH 040/137] ValueStore.store again private val --- src/main/scala/edu/ie3/simona/agent/ValueStore.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index fbae2ff77c..a21f7d0f58 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -22,7 +22,7 @@ import scala.collection.SortedMap */ final case class ValueStore[+D]( maxTickSpan: Long, - store: SortedMap[Long, D] = SortedMap.empty[Long, D], + private val store: SortedMap[Long, D] = SortedMap.empty[Long, D], ) { /** Determine the lastly known data tick, if available. Includes the given From 3243763269dfa98026bfc340f2c0c87356f31255 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:09:47 +0100 Subject: [PATCH 041/137] SonarQube issue null parameter --- src/main/scala/edu/ie3/simona/event/ResultEvent.scala | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala index a1a765d977..da844a801f 100644 --- a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala @@ -62,7 +62,7 @@ object ResultEvent { ComparableQuantity[Temperature], ) ] = { - if (result != null) { + Option(result).flatMap { result => Some( ( result.getTime, @@ -71,8 +71,6 @@ object ResultEvent { result.getIndoorTemperature, ) ) - } else { - None } } } @@ -86,7 +84,7 @@ object ResultEvent { ComparableQuantity[Energy], ) ] = { - if (result != null) { + Option(result).flatMap { result => Some( ( result.getTime, @@ -95,8 +93,6 @@ object ResultEvent { result.getEnergy, ) ) - } else { - None } } } From 80fbc092122622856e269af10d4e7046a9d6c4f2 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:36:39 +0100 Subject: [PATCH 042/137] remove not necessary headOption --- src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index ee743d88ca..40de44725c 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -67,7 +67,7 @@ final case class ThermalGrid( /* First get the energy demand of the houses but only if inner temperature is below target temperature */ val (houseDemand, updatedHouseState) = - house.zip(state.houseState).headOption match { + house.zip(state.houseState) match { case Some((thermalHouse, lastHouseState)) => val (updatedHouseState, updatedStorageState) = thermalHouse.determineState( From 1beb478839d9ec62e979df7ffa753f994d053c3a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:36:47 +0100 Subject: [PATCH 043/137] break long line --- src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 40de44725c..074d80e0a4 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -78,7 +78,8 @@ final case class ThermalGrid( lastHouseState.qDot, ) if ( - updatedHouseState.innerTemperature < thermalHouse.targetTemperature | (lastHouseState.qDot > zeroKW && updatedHouseState.innerTemperature < thermalHouse.upperBoundaryTemperature) + updatedHouseState.innerTemperature < thermalHouse.targetTemperature | + (lastHouseState.qDot > zeroKW && updatedHouseState.innerTemperature < thermalHouse.upperBoundaryTemperature) ) { ( thermalHouse.energyDemand( From 07a65f11afef654dfdeae05de1208a95df2fa61f Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:37:02 +0100 Subject: [PATCH 044/137] use wildcard for not used val --- src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 074d80e0a4..0d868e64df 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -69,7 +69,7 @@ final case class ThermalGrid( val (houseDemand, updatedHouseState) = house.zip(state.houseState) match { case Some((thermalHouse, lastHouseState)) => - val (updatedHouseState, updatedStorageState) = + val (updatedHouseState, _) = thermalHouse.determineState( tick, lastHouseState, From 79e91c21efa356bc4d68184335e5eac170481f40 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:45:24 +0100 Subject: [PATCH 045/137] rollback currentThermalGridState to thermalGridState --- .../agent/participant/hp/HpAgentFundamentals.scala | 4 ++-- .../edu/ie3/simona/model/participant/HpModel.scala | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala index 128e1e7395..58b9c402b1 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala @@ -189,7 +189,7 @@ trait HpAgentFundamentals val accompanyingResults = baseStateData.model.thermalGrid.results( updatedState.tick, - updatedState.currentThermalGridState, + updatedState.thermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) @@ -254,7 +254,7 @@ trait HpAgentFundamentals ) val accompanyingResults = baseStateData.model.thermalGrid.results( updatedState.tick, - updatedState.currentThermalGridState, + updatedState.thermalGridState, )(baseStateData.startDate) val result = AccompaniedSimulationResult(power, accompanyingResults) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index ccc295e240..4f3b1f92bc 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -139,7 +139,7 @@ final case class HpModel( relevantData.ambientTemperature ), relevantData.ambientTemperature, - lastHpState.currentThermalGridState, + lastHpState.thermalGridState, ) // Determining the operation point and limitations at this tick @@ -262,7 +262,7 @@ final case class HpModel( relevantData: HpRelevantData, isRunning: Boolean, ): HpState = { - val lastStateStorageQDot = lastState.currentThermalGridState.storageState + val lastStateStorageQDot = lastState.thermalGridState.storageState .map(_.qDot) .getOrElse(zeroKW) @@ -277,7 +277,7 @@ final case class HpModel( val (thermalGridState, maybeThreshold) = thermalGrid.updateState( relevantData.currentTick, - lastState.currentThermalGridState, + lastState.thermalGridState, lastState.ambientTemperature.getOrElse(relevantData.ambientTemperature), relevantData.ambientTemperature, newThermalPower, @@ -425,8 +425,8 @@ object HpModel { * result active power * @param qDot * result heat power - * @param currentThermalGridState - * Currently applicable state of the thermal grid + * @param thermalGridState + * applicable state of the thermal grid * @param maybeThermalThreshold * An optional threshold of the thermal grid, indicating the next state * change @@ -437,7 +437,7 @@ object HpModel { ambientTemperature: Option[Temperature], activePower: Power, qDot: Power, - currentThermalGridState: ThermalGridState, + thermalGridState: ThermalGridState, maybeThermalThreshold: Option[ThermalThreshold], ) extends ModelState From 71c9852a0c38526266f5afeaadb1b6e6a61cc756 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Tue, 5 Nov 2024 16:45:36 +0100 Subject: [PATCH 046/137] scala doc format --- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 4f3b1f92bc..41927fd2b0 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -218,9 +218,9 @@ final case class HpModel( * @param demandHouse * @param demandThermalStorage * @return - * First boolean: true, if house has heat demand Second boolean: true, if - * thermalStorage has heat demand Third boolean: true, if there is no - * thermalStorage or it's empty + * First boolean is true, if house has heat demand. Second boolean is true, + * if thermalStorage has heat demand. Third boolean is true, if there is no + * thermalStorage or it's empty. */ def determineDemandBooleans( From 98f390010fb3ec13ea9feed2e487e7fbcac75d76 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Wed, 6 Nov 2024 11:00:54 +0100 Subject: [PATCH 047/137] Simplified code by accessing tuple directly. --- .../model/participant/StorageModelSpec.scala | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 4326925a05..2375639729 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -337,16 +337,16 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(-5d), ) - (newState, flexChangeIndication)._1.chargingPower should approximate( + newState.chargingPower should approximate( zeroKW ) - (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) - (newState, flexChangeIndication)._1.storedEnergy should approximate( + newState.tick shouldBe (startTick + 1) + newState.storedEnergy should approximate( oldState.storedEnergy ) - (newState, flexChangeIndication)._2.changesAtTick.isDefined shouldBe false - (newState, flexChangeIndication)._2.changesAtNextActivation shouldBe true + flexChangeIndication.changesAtTick.isDefined shouldBe false + flexChangeIndication.changesAtNextActivation shouldBe true } "Handle the edge case of charging in tolerance margins" in { @@ -367,16 +367,16 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(9d), ) - (newState, flexChangeIndication)._1.chargingPower should approximate( + newState.chargingPower should approximate( zeroKW ) - (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) - (newState, flexChangeIndication)._1.storedEnergy should approximate( + newState.tick shouldBe (startTick + 1) + newState.storedEnergy should approximate( oldState.storedEnergy ) - (newState, flexChangeIndication)._2.changesAtTick.isDefined shouldBe false - (newState, flexChangeIndication)._2.changesAtNextActivation shouldBe true + flexChangeIndication.changesAtTick.isDefined shouldBe false + flexChangeIndication.changesAtNextActivation shouldBe true } "Handle the edge case of discharging in positive target margin" in { val storageModel = buildStorageModel(Some(0.3d)) @@ -396,17 +396,17 @@ class StorageModelSpec extends UnitSpec with Matchers { Kilowatts(-9d), ) - (newState, flexChangeIndication)._1.chargingPower should approximate( + newState.chargingPower should approximate( Kilowatts(-9d) ) - (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) - (newState, flexChangeIndication)._1.storedEnergy should approximate( + newState.tick shouldBe (startTick + 1) + newState.storedEnergy should approximate( oldState.storedEnergy ) - (newState, flexChangeIndication)._2.changesAtTick should be( + flexChangeIndication.changesAtTick should be( Some(startTick + 1L + 10801L) ) - (newState, flexChangeIndication)._2.changesAtNextActivation should be( + flexChangeIndication.changesAtNextActivation should be( true ) } @@ -431,14 +431,14 @@ class StorageModelSpec extends UnitSpec with Matchers { newState.chargingPower should approximate( Kilowatts(5d) ) - (newState, flexChangeIndication)._1.tick shouldBe (startTick + 1) - (newState, flexChangeIndication)._1.storedEnergy should approximate( + newState.tick shouldBe (startTick + 1) + newState.storedEnergy should approximate( oldState.storedEnergy ) - (newState, flexChangeIndication)._2.changesAtTick should be( + flexChangeIndication.changesAtTick should be( Some(startTick + 1L + 48002L) ) - (newState, flexChangeIndication)._2.changesAtNextActivation should be( + flexChangeIndication.changesAtNextActivation should be( true ) } From 2c1252e282643c47ff1f4dfee9c823c8bbc309c6 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 7 Nov 2024 10:47:54 +0100 Subject: [PATCH 048/137] handle sonar code smell when using asInstanceOf --- .../model/participant/StorageModelSpec.scala | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 2375639729..4d6fff7060 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -132,13 +132,15 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel - .determineFlexOptions(data, oldState) - .asInstanceOf[ProvideMinMaxFlexOptions] - - result.ref should approximate(Kilowatts(pRef)) - result.min should approximate(Kilowatts(pMin)) - result.max should approximate(Kilowatts(pMax)) + storageModel + .determineFlexOptions(data, oldState) match { + case result: ProvideMinMaxFlexOptions => + result.ref should approximate(Kilowatts(pRef)) + result.min should approximate(Kilowatts(pMin)) + result.max should approximate(Kilowatts(pMax)) + case _ => + fail("Expected result of type ProvideMinMaxFlexOptions") + } } } "Calculate flex options with target SOC" in { @@ -174,13 +176,15 @@ class StorageModelSpec extends UnitSpec with Matchers { startTick, ) - val result = storageModel - .determineFlexOptions(data, oldState) - .asInstanceOf[ProvideMinMaxFlexOptions] - - result.ref should approximate(Kilowatts(pRef)) - result.min should approximate(Kilowatts(pMin)) - result.max should approximate(Kilowatts(pMax)) + storageModel + .determineFlexOptions(data, oldState) match { + case result: ProvideMinMaxFlexOptions => + result.ref should approximate(Kilowatts(pRef)) + result.min should approximate(Kilowatts(pMin)) + result.max should approximate(Kilowatts(pMax)) + case _ => + fail("Expected result of type ProvideMinMaxFlexOptions") + } } } From 5851215c9dd27d68497271a1bc475646bf6d4367 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 7 Nov 2024 15:14:53 +0100 Subject: [PATCH 049/137] Improving code. --- .../simona/model/participant/BMModel.scala | 6 +- .../simona/model/participant/ChpModel.scala | 2 +- .../model/participant/FixedFeedInModel.scala | 4 +- .../simona/model/participant/HpModel.scala | 4 +- .../simona/model/participant/PvModel.scala | 6 +- .../model/participant/evcs/EvcsModel.scala | 6 +- .../load/random/RandomLoadModel.scala | 8 +- .../util/scala/quantities/ApparentPower.scala | 25 +- .../simona/model/participant/PvModelIT.groovy | 223 ------------------ .../model/participant/BMModelSpec.scala | 2 +- .../participant/FixedFeedInModelSpec.scala | 2 +- .../participant/SystemParticipantSpec.scala | 1 - .../participant/load/FixedLoadModelSpec.scala | 4 +- 13 files changed, 46 insertions(+), 247 deletions(-) delete mode 100644 src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index 7961758da9..1d849d9783 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -195,9 +195,9 @@ final case class BMModel( isCostControlled && avgOpex.value.doubleValue() < feedInTariff.value .doubleValue() ) - sRated.toPower(cosPhiRated) * (-1) + sRated.toPower(cosPhiRated) * -1 else - sRated.toPower(cosPhiRated) * usage * eff * (-1) + sRated.toPower(cosPhiRated) * usage * eff * -1 } /** Applies the load gradient to the electrical output @@ -217,7 +217,7 @@ final case class BMModel( pEl - lastPowerVal match { case pElDelta if pElDelta > pElDeltaMaxAbs => lastPowerVal + pElDeltaMaxAbs - case pElDelta if pElDelta < (pElDeltaMaxAbs * (-1)) => + case pElDelta if pElDelta < (pElDeltaMaxAbs * -1) => lastPowerVal - pElDeltaMaxAbs case _ => pEl diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 36a420806f..2a704adc43 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -393,7 +393,7 @@ object ChpModel { qControl, Kilovoltamperes( scaledInput.getType.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index ad76fbbddb..84a6531a02 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -71,7 +71,7 @@ final case class FixedFeedInModel( override def calculateActivePower( modelState: ConstantState.type, data: FixedRelevantData.type = FixedRelevantData, - ): Power = sRated.toPower(cosPhiRated) * (-1) + ): Power = sRated.toPower(cosPhiRated) * -1 override def determineFlexOptions( data: FixedRelevantData.type, @@ -116,7 +116,7 @@ object FixedFeedInModel extends LazyLogging { QControl.apply(scaledInput.getqCharacteristics), Kilovoltamperes( scaledInput.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 94d2ae4bf9..8767e1f640 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -305,7 +305,7 @@ object HpModel { qControl, Kilovoltamperes( scaledInput.getType.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), @@ -408,7 +408,7 @@ object HpModel { qControl, Kilovoltamperes( scaledInput.getType.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), diff --git a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala index 581afdeb65..f6103aa1c3 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala @@ -240,7 +240,7 @@ final case class PvModel private ( /** Calculates the sunrise hour angle omegaSR given omegaSS. */ private val calcSunriseAngleOmegaSR = - (omegaSS: Angle) => omegaSS * (-1) + (omegaSS: Angle) => omegaSS * -1 /** Calculates the solar altitude angle alphaS which represents the angle * between the horizontal and the line to the sun, that is, the complement of @@ -691,7 +691,7 @@ final case class PvModel private ( /* Calculate the foreseen active power output without boundary condition adaptions */ val proposal = - sRated.toPower(cosPhiRated) * (-1) * (actYield / irradiationSTC) + sRated.toPower(cosPhiRated) * -1 * (actYield / irradiationSTC) /* Do sanity check, if the proposed feed in is above the estimated maximum to be apparent active power of the plant */ if (proposal < pMax) @@ -771,7 +771,7 @@ object PvModel { QControl(scaledInput.getqCharacteristics), Kilovoltamperes( scaledInput.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue ), diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index eed22dbabe..e39e6b0345 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -753,7 +753,7 @@ final case class EvcsModel( if (setPower > zeroKW) maxPower else - maxPower * (-1) + maxPower * -1 val chargingTicks = calcFlexOptionsChange(ev, power) val endTick = Math.min(currentTick + chargingTicks, ev.departureTick) @@ -822,7 +822,7 @@ final case class EvcsModel( (targetEnergy - ev.storedEnergy) / power } else - (ev.storedEnergy - (ev.eStorage * lowestEvSoc)) / (power * (-1)) + (ev.storedEnergy - (ev.eStorage * lowestEvSoc)) / (power * -1) Math.round(timeUntilFullOrEmpty.toSeconds) } @@ -1070,7 +1070,7 @@ object EvcsModel { simulationStartDate, QControl(scaledInput.getqCharacteristics), Kilovoltamperes( - scaledInput.getType.getsRated.to(KILOWATT).getValue.doubleValue + scaledInput.getType.getsRated.to(KILOVOLTAMPERE).getValue.doubleValue ), scaledInput.getType.getElectricCurrentType, scaledInput.getCosPhiRated, diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index 8596662ed9..c10c8ace44 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -102,7 +102,7 @@ final case class RandomLoadModel( case ActivePower(activePower) => /* scale the reference active power based on the random profiles averagePower/maxPower ratio */ val referenceScalingFactor = - profilePower / RandomLoadModel.randomMaxPower.toPower( + profilePower / RandomLoadModel.randomMaxApparentPower.toPower( 1.0 ) // only active power => cosPhi = 1.0 activePower * referenceScalingFactor @@ -171,9 +171,9 @@ object RandomLoadModel { * active power. * * @return - * Reference power to use for later model calculations + * Reference apparent power to use for later model calculations */ - private val randomMaxPower: ApparentPower = Voltamperes(159d) + private val randomMaxApparentPower: ApparentPower = Voltamperes(159d) def apply( input: LoadInput, @@ -193,7 +193,7 @@ object RandomLoadModel { LoadModel.scaleSRatedEnergy( scaledInput, energyConsumption, - randomMaxPower, + randomMaxApparentPower, randomProfileEnergyScaling, 1.1, ) diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala index a436727075..eeec8fd219 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala @@ -13,6 +13,13 @@ import squants.time.Time import scala.math.{acos, sin} import scala.util.Try +/** Class that represents an apparent power. An apparent power is the absolute + * value of the complex power (|S|). + * @param value + * power value + * @param unit + * of the power + */ final class ApparentPower private ( val value: Double, val unit: ApparentPowerUnit, @@ -26,10 +33,26 @@ final class ApparentPower private ( def toMegavoltamperes: Double = to(Megavoltamperes) def toGigavoltamperes: Double = to(Gigavoltamperes) + /** Method to convert this apparent power into a [[Power]] using a given + * cosPhi. + * @param cosPhi + * cosine of the corresponding angle + * @return + * the resulting active power + */ def toPower(cosPhi: Double): Power = Watts(toVoltamperes * cosPhi) - def toReactivePower(cosPhi: Double): ReactivePower = + /** Method to convert this apparent power into a [[ReactivePower]] using a + * given cosPhi. + * @param cosPhi + * cosine of the corresponding angle + * @return + * the resulting reactive power + */ + def toReactivePower(cosPhi: Double): ReactivePower = { + // Q = |S| * sin(φ), φ = acos(cosPhi) Vars(toVoltamperes * sin(acos(cosPhi))) + } } object ApparentPower extends Dimension[ApparentPower] { diff --git a/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy b/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy deleted file mode 100644 index 4219b301e2..0000000000 --- a/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy +++ /dev/null @@ -1,223 +0,0 @@ -/* - * © 2020. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ - -package edu.ie3.simona.model.participant - -import static java.util.Locale.US -import static java.util.Locale.setDefault - -import edu.ie3.datamodel.io.source.csv.CsvJointGridContainerSource -import edu.ie3.datamodel.models.input.system.PvInput -import edu.ie3.simona.ontology.messages.services.WeatherMessage -import edu.ie3.util.TimeUtil -import edu.ie3.util.scala.quantities.Sq -import edu.ie3.util.scala.quantities.WattsPerSquareMeter$ -import org.apache.commons.csv.CSVFormat -import org.apache.commons.csv.CSVRecord -import spock.lang.Shared -import spock.lang.Specification -import squants.Dimensionless -import squants.Each$ -import squants.energy.Megawatts$ -import squants.energy.Power -import squants.motion.MetersPerSecond$ -import squants.thermal.Kelvin$ - -import java.nio.file.Path -import java.time.ZonedDateTime -import java.util.zip.GZIPInputStream - -/** - * A simple integration test that uses pre-calculated data to check if the pv model works as expected. - * It uses 8 pv models located in GER. - * - */ -class PvModelIT extends Specification implements PvModelITHelper { - - @Shared - Map pvModels - - @Shared - Map> weatherMap - - @Shared - Map> resultsMap - - - def setupSpec() { - // input weather data values are in us format - // if locale is not set hard coded to US, quantity parsing will return invalid values - setDefault(US) - - pvModels = createPvModels() - weatherMap = weatherData - resultsMap = resultsData - } - - def "8 pv panels full year test"() { - - given: "an empty array to collect the results" - ArrayList testRes = new ArrayList<>() - - when: "we calculate the photovoltaic in-feed for each unit for the whole year" - List modelIds = new ArrayList<>(pvModels.keySet()) - // sort models: east, south, west - Collections.sort(modelIds) - final int modelCount = modelIds.size() - - // sort, in case dates & times have not been sorted before - List keyList = new ArrayList<>(weatherMap.keySet()) - Collections.sort(keyList) - - for (ZonedDateTime dateTime : keyList) { - - Map modelToWeatherMap = weatherMap.get(dateTime) - - String[] row = new String[2*modelCount+1] - row[0] = dateTime.toString() - - int modelI = 0 - for (String modelId : modelIds) { - PvModel model = pvModels.get(modelId) - - "build the needed data" - WeatherMessage.WeatherData weather = modelToWeatherMap.get(modelId) - PvModel.PvRelevantData neededData = new PvModel.PvRelevantData( - dateTime, - 3600L, - weather.diffIrr(), - weather.dirIrr() - ) - Dimensionless voltage = Sq.create(1.414213562d, Each$.MODULE$) - - "collect the results and calculate the difference between the provided results and the calculated ones" - double calc = model.calculatePower(0L, voltage, ModelState.ConstantState$.MODULE$, neededData).p().toMegawatts() - double sol = resultsMap.get(dateTime).get(modelId).toMegawatts() - - testRes.add(Math.abs(calc - sol)) - - row[1 + modelI] = calc.toString() - row[1 + modelCount + modelI] = sol.toString() - - modelI++ - } - } - - then: "we expect the calculated result to be quasi equal the provided results data" - testRes.every { - (it < 0.00000000000001) // floating point operation - } - } -} - -trait PvModelITHelper { - private static final CSV_FORMAT = CSVFormat.DEFAULT.builder().setHeader().build() - - Iterable getCsvRecords(String fileName) { - def resultsInputData = new File(this.getClass().getResource(fileName).file) - def fileStream = new FileInputStream(resultsInputData) - def gzipStream = new GZIPInputStream(fileStream) - def decoder = new InputStreamReader(gzipStream, "UTF-8") - def br = new BufferedReader(decoder) - return CSV_FORMAT.parse(br) - } - - Map createPvModels() { - "load the grid input data from the corresponding resources folder" - - def csvGridSource = CsvJointGridContainerSource.read("it_grid", ";", - Path.of(this.getClass().getResource("_pv/it/grid_data").toURI()), false) - - def simulationStartDate = TimeUtil.withDefaults.toZonedDateTime("2011-01-01T00:00:00Z") - def simulationEndDate = TimeUtil.withDefaults.toZonedDateTime("2012-01-01T00:00:00Z") - - Map pvModels = new HashMap<>() - for (PvInput inputModel : csvGridSource.systemParticipants.pvPlants) { - PvModel model = PvModel.apply( - inputModel, - 1d, - simulationStartDate, - simulationEndDate - ) - - pvModels.put(inputModel.getId(), model) - } - - return pvModels - } - - Map> getWeatherData() { - "read the weather data from the provided weather data file" - final String fileName = "_pv/it/weather.tar.gz" - final def csvRecords = getCsvRecords(fileName) - - Map> weatherMap = new HashMap<>() - for (row in csvRecords) { - ZonedDateTime time = TimeUtil.withDefaults.toZonedDateTime(row.get(0)) - Map modelToWeatherMap - if (weatherMap.containsKey(time)) { - modelToWeatherMap = weatherMap.get(time) - } - - if (modelToWeatherMap == null) { - modelToWeatherMap = new HashMap() - weatherMap.put(time, modelToWeatherMap) - } - - String modelId = row.get(1) - - double temp = 0 - double windVel = 0 - - WeatherMessage.WeatherData weather = new WeatherMessage.WeatherData( - Sq.create(row.get(22).replace("Wh/m²", "").toDouble(), WattsPerSquareMeter$.MODULE$), - Sq.create(row.get(21).replace("Wh/m²", "").toDouble(), WattsPerSquareMeter$.MODULE$), - Sq.create(temp, Kelvin$.MODULE$), - Sq.create(windVel, MetersPerSecond$.MODULE$)) - - modelToWeatherMap.put(modelId, weather) - } - - return weatherMap - } - - Map> getResultsData() { - "read the results data from the provided file" - final String fileName = "_pv/it/results2.tar.gz" - def csvRecords = getCsvRecords(fileName) - - // we skip the first line and use hardcoded headers, because the first line is garbled - String[] headers = [ - "Datetime", - "pv_east_1", - "pv_east_2", - "pv_south_1", - "pv_south_2", - "pv_south_3", - "pv_south_4", - "pv_west_1", - "pv_west_2" - ] - - Map> resultsMap = new HashMap<>() - for(row in csvRecords) { - // last line is trash - if (row.get(0).startsWith('\u0000')) - break - - ZonedDateTime time = TimeUtil.withDefaults.toZonedDateTime(row.get(0)) - Map modelToPowerMap = new HashMap<>() - for (int i = 1; i < headers.length; i++) { - String modelId = headers[i] - String rawValue = row[i] - Power power = Sq.create(Double.parseDouble(rawValue), Megawatts$.MODULE$) - modelToPowerMap.put(modelId, power) - } - resultsMap.put(time, modelToPowerMap) - } - return resultsMap - } -} \ No newline at end of file diff --git a/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala index 6320271e9a..9aa118c0b3 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/BMModelSpec.scala @@ -174,7 +174,7 @@ class BMModelSpec extends UnitSpec { ) val pElCalc = bmModel.calculateElOutput(usage, eff) - pElCalc.value should be(Kilovoltamperes(pElSol).toVoltamperes +- 1e-4) + pElCalc should approximate(Kilowatts(pElSol)) } } diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala index 763fb4b677..c787f6ce0d 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala @@ -94,7 +94,7 @@ class FixedFeedInModelSpec Kilovoltamperes( fixedFeedInput .getsRated() - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue() ), diff --git a/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala index ecb8afe884..02036d6a62 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/SystemParticipantSpec.scala @@ -141,7 +141,6 @@ class SystemParticipantSpec extends UnitSpec with Matchers { val power = Kilowatts(pVal) val qCalc = loadMock.calculateReactivePower(power, adjustedVoltage) qCalc should approximate(qSol) - } } 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 eb86f9a4aa..6a75bd93e5 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 @@ -53,7 +53,7 @@ class FixedLoadModelSpec QControl.apply(loadInput.getqCharacteristics), Kilovoltamperes( loadInput.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue() ), @@ -87,7 +87,7 @@ class FixedLoadModelSpec QControl.apply(loadInput.getqCharacteristics), Kilovoltamperes( loadInput.getsRated - .to(PowerSystemUnits.KILOWATT) + .to(PowerSystemUnits.KILOVOLTAMPERE) .getValue .doubleValue() ), From 52af7a91e9833e8472f9ae557f87090fd3efa511 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 7 Nov 2024 15:18:24 +0100 Subject: [PATCH 050/137] Updating `CHANGELOG`. --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4517ba8c..2b8f062475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added option to directly zip the output files [#793](https://github.com/ie3-institute/simona/issues/793) - Added weatherData HowTo for Copernicus ERA5 data [#967](https://github.com/ie3-institute/simona/issues/967) - Add some quote to 'printGoodbye' [#997](https://github.com/ie3-institute/simona/issues/997) +- Added `ApparentPower` to differentiate between different power types [#794](https://github.com/ie3-institute/simona/issues/794) ### Changed - Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435) @@ -94,7 +95,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replace mutable var in ChpModelSpec [#1002](https://github.com/ie3-institute/simona/issues/1002) - Move compression of output files into `ResultEventListener`[#965](https://github.com/ie3-institute/simona/issues/965) - Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - + ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) - Removed version number "2.0" from the logo printed to console [#642](https://github.com/ie3-institute/simona/issues/642) From 423a7d3f66a5ffb833b4b93e241aa618d53c62cc Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 8 Nov 2024 09:54:20 +0100 Subject: [PATCH 051/137] Addressing some change requests. --- .../participant/statedata/BaseStateData.scala | 2 +- .../participant/evcs/EvModelWrapper.scala | 2 +- .../model/participant/evcs/EvcsModel.scala | 2 +- .../model/participant/load/LoadModel.scala | 6 +- .../load/profile/LoadProfileStore.scala | 7 +- .../load/profile/ProfileLoadModel.scala | 5 +- .../load/random/RandomLoadModel.scala | 8 +- .../simona/model/participant/PvModelIT.groovy | 223 ++++++++++++++++++ .../EvcsAgentModelCalculationSpec.scala | 4 +- .../participant/FixedFeedInModelSpec.scala | 3 +- .../participant/evcs/EvcsModelSpec.scala | 2 +- .../load/LoadProfileStoreSpec.scala | 2 +- 12 files changed, 245 insertions(+), 21 deletions(-) create mode 100644 src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy diff --git a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala index e1a8285cf8..192d30b3cd 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala @@ -69,7 +69,7 @@ trait BaseStateData[+PD <: PrimaryDataWithApparentPower[PD]] /** A store, holding information of the lastly requested and provided results. * The request from the grid always targets at - * [[edu.ie3.simona.agent.participant.data.Data.PrimaryData.ApparentPower]], + * [[edu.ie3.simona.agent.participant.data.Data.PrimaryData.ComplexPower]], * but for the sake of traceability, the whole averaged result ist stored */ val requestValueStore: ValueStore[PD] diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala index b5d0d7ec94..457b0fe348 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala @@ -37,7 +37,7 @@ final case class EvModelWrapper( Kilovoltamperes( original.getSRatedAC.to(KILOVOLTAMPERE).getValue.doubleValue ) - lazy val sRatedDc: squants.Power = + lazy val pRatedDc: squants.Power = Kilowatts(original.getSRatedDC.to(KILOWATT).getValue.doubleValue) lazy val eStorage: squants.Energy = KilowattHours( original.getEStorage.to(KILOWATTHOUR).getValue.doubleValue diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index e39e6b0345..38d0d3e1b4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -505,7 +505,7 @@ final case class EvcsModel( case ElectricCurrentType.AC => ev.sRatedAc.toPower(1.0) case ElectricCurrentType.DC => - ev.sRatedDc + ev.pRatedDc } /* Limit the charging power to the minimum of ev's and evcs' permissible power */ evPower.min(sRated.toPower(1.0)) diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala index 78378893a5..bbb7f19063 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala @@ -129,13 +129,15 @@ object LoadModel extends LazyLogging { def scaleSRatedEnergy( inputModel: LoadInput, energyConsumption: Energy, - profileMaxPower: ApparentPower, + profileMaxPower: Power, profileEnergyScaling: Energy, safetyFactor: Double = 1d, ): ApparentPower = { - (profileMaxPower / inputModel.getCosPhiRated) * ( + val power = (profileMaxPower / inputModel.getCosPhiRated) * ( energyConsumption / profileEnergyScaling ) * safetyFactor + + Kilovoltamperes(power.toKilowatts) } } diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index 93b08ba62a..659efb5749 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -19,6 +19,7 @@ import edu.ie3.simona.model.participant.load.profile.LoadProfileStore.{ import edu.ie3.simona.model.participant.load.{DayType, profile} import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import org.apache.commons.csv.CSVFormat +import squants.Power import squants.energy.{KilowattHours, Watts} import java.io.{InputStreamReader, Reader} @@ -85,14 +86,14 @@ class LoadProfileStore private (val reader: Reader) { * @param loadProfile * the consumer type * @return - * the maximum load in VA + * the maximum load in W */ def maxPower( loadProfile: StandardLoadProfile - ): ApparentPower = { + ): Power = { maxParamMap.get(loadProfile) match { case Some(value) => - Voltamperes(value) + Watts(value) case None => throw new RuntimeException( "Max value for ConsumerType " + loadProfile.toString + " not found" diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala index 9c030d2b10..b2594a6b02 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala @@ -92,10 +92,7 @@ final case class ProfileLoadModel( reference match { case ActivePower(activePower) => /* scale the reference active power based on the profiles averagePower/maxPower ratio */ - val referenceScalingFactor = - averagePower / profileMaxPower.toPower( - 1.0 - ) // only active power => cosPhi = 1.0 + val referenceScalingFactor = averagePower / profileMaxPower activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles average power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index c10c8ace44..3ad619d7bb 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -102,9 +102,7 @@ final case class RandomLoadModel( case ActivePower(activePower) => /* scale the reference active power based on the random profiles averagePower/maxPower ratio */ val referenceScalingFactor = - profilePower / RandomLoadModel.randomMaxApparentPower.toPower( - 1.0 - ) // only active power => cosPhi = 1.0 + profilePower / RandomLoadModel.randomMaxPower activePower * referenceScalingFactor case _: EnergyConsumption => /* scale the profiles random power based on the energyConsumption/profileEnergyScaling(=1000kWh/year) ratio */ @@ -173,7 +171,7 @@ object RandomLoadModel { * @return * Reference apparent power to use for later model calculations */ - private val randomMaxApparentPower: ApparentPower = Voltamperes(159d) + private val randomMaxPower: Power = Watts(159d) def apply( input: LoadInput, @@ -193,7 +191,7 @@ object RandomLoadModel { LoadModel.scaleSRatedEnergy( scaledInput, energyConsumption, - randomMaxApparentPower, + randomMaxPower, randomProfileEnergyScaling, 1.1, ) diff --git a/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy b/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy new file mode 100644 index 0000000000..00caef8dee --- /dev/null +++ b/src/test/groovy/edu/ie3/simona/model/participant/PvModelIT.groovy @@ -0,0 +1,223 @@ +/* + * © 2020. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ + +package edu.ie3.simona.model.participant + +import edu.ie3.datamodel.io.source.csv.CsvJointGridContainerSource +import edu.ie3.datamodel.models.input.system.PvInput +import edu.ie3.simona.ontology.messages.services.WeatherMessage +import edu.ie3.util.TimeUtil +import edu.ie3.util.scala.quantities.Sq +import edu.ie3.util.scala.quantities.WattsPerSquareMeter$ +import org.apache.commons.csv.CSVFormat +import org.apache.commons.csv.CSVRecord +import spock.lang.Shared +import spock.lang.Specification +import squants.Dimensionless +import squants.Each$ +import squants.energy.Megawatts$ +import squants.energy.Power +import squants.motion.MetersPerSecond$ +import squants.thermal.Kelvin$ + +import java.nio.file.Path +import java.time.ZonedDateTime +import java.util.zip.GZIPInputStream + +import static java.util.Locale.US +import static java.util.Locale.setDefault + +/** + * A simple integration test that uses pre-calculated data to check if the pv model works as expected. + * It uses 8 pv models located in GER. + * + */ +class PvModelIT extends Specification implements PvModelITHelper { + + @Shared + Map pvModels + + @Shared + Map> weatherMap + + @Shared + Map> resultsMap + + + def setupSpec() { + // input weather data values are in us format + // if locale is not set hard coded to US, quantity parsing will return invalid values + setDefault(US) + + pvModels = createPvModels() + weatherMap = weatherData + resultsMap = resultsData + } + + def "8 pv panels full year test"() { + + given: "an empty array to collect the results" + ArrayList testRes = new ArrayList<>() + + when: "we calculate the photovoltaic in-feed for each unit for the whole year" + List modelIds = new ArrayList<>(pvModels.keySet()) + // sort models: east, south, west + Collections.sort(modelIds) + final int modelCount = modelIds.size() + + // sort, in case dates & times have not been sorted before + List keyList = new ArrayList<>(weatherMap.keySet()) + Collections.sort(keyList) + + for (ZonedDateTime dateTime : keyList) { + + Map modelToWeatherMap = weatherMap.get(dateTime) + + String[] row = new String[2*modelCount+1] + row[0] = dateTime.toString() + + int modelI = 0 + for (String modelId : modelIds) { + PvModel model = pvModels.get(modelId) + + "build the needed data" + WeatherMessage.WeatherData weather = modelToWeatherMap.get(modelId) + PvModel.PvRelevantData neededData = new PvModel.PvRelevantData( + dateTime, + 3600L, + weather.diffIrr(), + weather.dirIrr() + ) + Dimensionless voltage = Sq.create(1.414213562d, Each$.MODULE$) + + "collect the results and calculate the difference between the provided results and the calculated ones" + double calc = model.calculatePower(0L, voltage, ModelState.ConstantState$.MODULE$, neededData).p().toMegawatts() + double sol = resultsMap.get(dateTime).get(modelId).toMegawatts() + + testRes.add(Math.abs(calc - sol)) + + row[1 + modelI] = calc.toString() + row[1 + modelCount + modelI] = sol.toString() + + modelI++ + } + } + + then: "we expect the calculated result to be quasi equal the provided results data" + testRes.every { + (it < 0.00000000000001) // floating point operation + } + } +} + +trait PvModelITHelper { + private static final CSV_FORMAT = CSVFormat.DEFAULT.builder().setHeader().build() + + Iterable getCsvRecords(String fileName) { + def resultsInputData = new File(this.getClass().getResource(fileName).file) + def fileStream = new FileInputStream(resultsInputData) + def gzipStream = new GZIPInputStream(fileStream) + def decoder = new InputStreamReader(gzipStream, "UTF-8") + def br = new BufferedReader(decoder) + return CSV_FORMAT.parse(br) + } + + Map createPvModels() { + "load the grid input data from the corresponding resources folder" + + def csvGridSource = CsvJointGridContainerSource.read("it_grid", ";", + Path.of(this.getClass().getResource("_pv/it/grid_data").toURI()), false) + + def simulationStartDate = TimeUtil.withDefaults.toZonedDateTime("2011-01-01T00:00:00Z") + def simulationEndDate = TimeUtil.withDefaults.toZonedDateTime("2012-01-01T00:00:00Z") + + Map pvModels = new HashMap<>() + for (PvInput inputModel : csvGridSource.systemParticipants.pvPlants) { + PvModel model = PvModel.apply( + inputModel, + 1d, + simulationStartDate, + simulationEndDate + ) + + pvModels.put(inputModel.getId(), model) + } + + return pvModels + } + + Map> getWeatherData() { + "read the weather data from the provided weather data file" + final String fileName = "_pv/it/weather.tar.gz" + final def csvRecords = getCsvRecords(fileName) + + Map> weatherMap = new HashMap<>() + for (row in csvRecords) { + ZonedDateTime time = TimeUtil.withDefaults.toZonedDateTime(row.get(0)) + Map modelToWeatherMap + if (weatherMap.containsKey(time)) { + modelToWeatherMap = weatherMap.get(time) + } + + if (modelToWeatherMap == null) { + modelToWeatherMap = new HashMap() + weatherMap.put(time, modelToWeatherMap) + } + + String modelId = row.get(1) + + double temp = 0 + double windVel = 0 + + WeatherMessage.WeatherData weather = new WeatherMessage.WeatherData( + Sq.create(row.get(22).replace("Wh/m²", "").toDouble(), WattsPerSquareMeter$.MODULE$), + Sq.create(row.get(21).replace("Wh/m²", "").toDouble(), WattsPerSquareMeter$.MODULE$), + Sq.create(temp, Kelvin$.MODULE$), + Sq.create(windVel, MetersPerSecond$.MODULE$)) + + modelToWeatherMap.put(modelId, weather) + } + + return weatherMap + } + + Map> getResultsData() { + "read the results data from the provided file" + final String fileName = "_pv/it/results2.tar.gz" + def csvRecords = getCsvRecords(fileName) + + // we skip the first line and use hardcoded headers, because the first line is garbled + String[] headers = [ + "Datetime", + "pv_east_1", + "pv_east_2", + "pv_south_1", + "pv_south_2", + "pv_south_3", + "pv_south_4", + "pv_west_1", + "pv_west_2" + ] + + Map> resultsMap = new HashMap<>() + for(row in csvRecords) { + // last line is trash + if (row.get(0).startsWith('\u0000')) + break + + ZonedDateTime time = TimeUtil.withDefaults.toZonedDateTime(row.get(0)) + Map modelToPowerMap = new HashMap<>() + for (int i = 1; i < headers.length; i++) { + String modelId = headers[i] + String rawValue = row[i] + Power power = Sq.create(Double.parseDouble(rawValue), Megawatts$.MODULE$) + modelToPowerMap.put(modelId, power) + } + resultsMap.put(time, modelToPowerMap) + } + return resultsMap + } +} \ No newline at end of file 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 74d3c83d90..aa61fd4dd1 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala @@ -1609,9 +1609,11 @@ class EvcsAgentModelCalculationSpec ) => modelUuid shouldBe evcsInputModelQv.getUuid refPower shouldBe combinedChargingPowerSq + + // battery of earlier ev is above lowest soc now minPower shouldBe ev4500.sRatedAc.toPower( 1.0 - ) * -1 // battery of earlier ev is above lowest soc now + ) * -1 maxPower shouldBe combinedChargingPowerSq } diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala index c787f6ce0d..be5dc6ac69 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedInModelSpec.scala @@ -30,9 +30,10 @@ class FixedFeedInModelSpec with DefaultTestData with PrivateMethodTester { + // Equals to 1 VA power private implicit val powerTolerance: ApparentPower = Voltamperes( 1.0 - ) // Equals to 1 W power + ) "The fixed feed in model object" should { diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala index bb92b5b914..ede77ceda1 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala @@ -189,7 +189,7 @@ class EvcsModelSpec actualEv.uuid shouldBe ev.uuid actualEv.id shouldBe ev.id actualEv.sRatedAc shouldBe ev.sRatedAc - actualEv.sRatedDc shouldBe ev.sRatedDc + actualEv.pRatedDc shouldBe ev.pRatedDc actualEv.eStorage shouldBe ev.eStorage actualEv.storedEnergy should approximate( KilowattHours(expectedStored) diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala index f8c6fddc74..2a6ed9a6bb 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala @@ -92,7 +92,7 @@ class LoadProfileStoreSpec forAll(maxParams) { (loadProfile: StandardLoadProfile, maxParamValue: Double) => - val maxParam = Voltamperes(maxParamValue) + val maxParam = Watts(maxParamValue) customStore.maxPower(loadProfile) shouldBe maxParam } From 43c2786298bcfcf04523143d5bd7fca8d11b6e14 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 8 Nov 2024 14:10:42 +0100 Subject: [PATCH 052/137] Renaming `sRatedAc` in `EvModelWrapper` into `pRatedAc`. --- .../participant/evcs/EvModelWrapper.scala | 8 +++--- .../model/participant/evcs/EvcsModel.scala | 4 +-- .../EvcsAgentModelCalculationSpec.scala | 28 ++++++++----------- .../participant/evcs/EvcsModelSpec.scala | 4 +-- .../MaximumPowerChargingSpec.scala | 2 +- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala index 457b0fe348..3c9f1077c6 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala @@ -9,7 +9,7 @@ package edu.ie3.simona.model.participant.evcs import edu.ie3.simona.api.data.ev.model.EvModel import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.quantities.QuantityUtils.RichQuantityDouble -import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} +import squants.Power import squants.energy.{KilowattHours, Kilowatts} import java.util.UUID @@ -33,9 +33,9 @@ final case class EvModelWrapper( def uuid: UUID = original.getUuid def id: String = original.getId - lazy val sRatedAc: ApparentPower = - Kilovoltamperes( - original.getSRatedAC.to(KILOVOLTAMPERE).getValue.doubleValue + lazy val pRatedAc: Power = + Kilowatts( + original.getSRatedAC.to(KILOWATT).getValue.doubleValue ) lazy val pRatedDc: squants.Power = Kilowatts(original.getSRatedDC.to(KILOWATT).getValue.doubleValue) diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index 38d0d3e1b4..b27749046d 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -32,8 +32,6 @@ import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.quantities.QuantityUtils.RichQuantityDouble import edu.ie3.util.scala.OperationInterval import edu.ie3.util.scala.quantities.DefaultQuantities._ -import squants.energy.Kilowatts -import edu.ie3.util.scala.quantities.DefaultQuantities._ import edu.ie3.util.scala.quantities.{ApparentPower, Kilovoltamperes} import squants.energy.Kilowatts import squants.time.Seconds @@ -503,7 +501,7 @@ final case class EvcsModel( ): Power = { val evPower = currentType match { case ElectricCurrentType.AC => - ev.sRatedAc.toPower(1.0) + ev.pRatedAc case ElectricCurrentType.DC => ev.pRatedDc } 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 aa61fd4dd1..4d3c444156 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/EvcsAgentModelCalculationSpec.scala @@ -1355,9 +1355,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev900.sRatedAc.toPower(1.0) - minPower shouldBe ev900.sRatedAc.toPower(1.0) // battery is empty - maxPower shouldBe ev900.sRatedAc.toPower(1.0) + referencePower shouldBe ev900.pRatedAc + minPower shouldBe ev900.pRatedAc // battery is empty + maxPower shouldBe ev900.pRatedAc } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1472,9 +1472,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc.toPower(1.0) - minPower shouldBe ev900.sRatedAc.toPower(1.0) // battery is empty - maxPower shouldBe ev4500.sRatedAc.toPower(1.0) + referencePower shouldBe ev4500.pRatedAc + minPower shouldBe ev900.pRatedAc // battery is empty + maxPower shouldBe ev4500.pRatedAc } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1522,9 +1522,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc.toPower(1.0) + referencePower shouldBe ev4500.pRatedAc minPower shouldBe Kilowatts(0.0) // battery is exactly at margin - maxPower shouldBe ev4500.sRatedAc.toPower(1.0) + maxPower shouldBe ev4500.pRatedAc } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => @@ -1611,9 +1611,7 @@ class EvcsAgentModelCalculationSpec refPower shouldBe combinedChargingPowerSq // battery of earlier ev is above lowest soc now - minPower shouldBe ev4500.sRatedAc.toPower( - 1.0 - ) * -1 + minPower shouldBe ev4500.pRatedAc * -1 maxPower shouldBe combinedChargingPowerSq } @@ -1763,9 +1761,7 @@ class EvcsAgentModelCalculationSpec ) => modelUuid shouldBe evcsInputModelQv.getUuid referencePower shouldBe combinedChargingPowerSq - minPower shouldBe ev4500.sRatedAc.toPower( - 1.0 - ) * -1 // battery of ev11700 is below lowest soc now + minPower shouldBe ev4500.pRatedAc * -1 // battery of ev11700 is below lowest soc now maxPower shouldBe combinedChargingPowerSq } @@ -1961,9 +1957,9 @@ class EvcsAgentModelCalculationSpec maxPower, ) => modelUuid shouldBe evcsInputModelQv.getUuid - referencePower shouldBe ev4500.sRatedAc.toPower(1.0) + referencePower shouldBe ev4500.pRatedAc minPower shouldBe Kilowatts(0d) - maxPower shouldBe ev4500.sRatedAc.toPower(1.0) + maxPower shouldBe ev4500.pRatedAc } resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) => diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala index ede77ceda1..67d757c55e 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/EvcsModelSpec.scala @@ -188,7 +188,7 @@ class EvcsModelSpec actualEv.uuid shouldBe ev.uuid actualEv.id shouldBe ev.id - actualEv.sRatedAc shouldBe ev.sRatedAc + actualEv.pRatedAc shouldBe ev.pRatedAc actualEv.pRatedDc shouldBe ev.pRatedDc actualEv.eStorage shouldBe ev.eStorage actualEv.storedEnergy should approximate( @@ -812,7 +812,7 @@ class EvcsModelSpec modelUuid shouldBe evcsModel.getUuid refPower should approximate(Kilowatts(5.0)) // one hour left minPower should approximate(Kilowatts(0d)) // no v2g allowed! - maxPower should approximate(ev1.sRatedAc.toPower(1.0)) + maxPower should approximate(ev1.pRatedAc) } } diff --git a/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala index 0ad7182c2d..39f9a52564 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/evcs/uncontrolled/MaximumPowerChargingSpec.scala @@ -85,7 +85,7 @@ class MaximumPowerChargingSpec ScheduleEntry( offset, offset + expectedDuration, - ev.sRatedAc.toPower(1.0), + ev.pRatedAc, ) ) ) From ddfc34260691555999609ae9eac070b0c31af2df Mon Sep 17 00:00:00 2001 From: marvinheintze Date: Mon, 11 Nov 2024 18:03:12 +0100 Subject: [PATCH 053/137] EvData case classes added + format changes --- docs/uml/main/ExtEvSimulationClasses.puml | 36 ++++++++++++++++------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index f54e57393b..f4652d28eb 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -42,7 +42,7 @@ package simona-api { interface ExtDataSimulation - ExtEvSimulation --|> ExtDataSimulation + ExtEvSimulation --u|> ExtDataSimulation interface EvModel { + UUID getUuid() @@ -91,7 +91,7 @@ package simona-api { RequestCurrentPrices --u|> EvDataMessageFromExt DataMessageFromExt --d|> EvDataMessageFromExt - ExtEvData --r[norank]> EvDataMessageFromExt + ExtEvData -----> EvDataMessageFromExt ExtEvData --u|> ExtData ExtEvSimulation -u> ExtEvData @@ -101,22 +101,22 @@ package simona-api { interface EvDataResponseMessageToExt class ProvideCurrentPrices{ - + ProvideCurrentPrices() + + Map prices } class ProvideDepartingEvs{ - + ProvideDepartingEvs() + + List departedEvs } class ProvideEvcsFreeLots{ - + ProvideEvcsFreeLots() + + Map evcs } ProvideEvcsFreeLots --|> EvDataResponseMessageToExt ProvideDepartingEvs --|> EvDataResponseMessageToExt ProvideCurrentPrices --|> EvDataResponseMessageToExt ExtEvData --> EvDataResponseMessageToExt - DataResponseMessageToExt --|> EvDataResponseMessageToExt + EvDataResponseMessageToExt --|> DataResponseMessageToExt } node sub3 { @@ -154,10 +154,23 @@ package simona { class EvcsAgent interface SecondaryData - class EvMovementData { - movements: Set[EvMovement] + + class ArrivingEvs{ + + arrivals Seq[EvModelWrapper] + } + + class DepartingEvsRequest{ + + evcs UUID + + evModels Seq[EvModelWrapper] } + class EvFreeLotsRequest{ + + evcs: UUID, + + freeLots: Int, + } + + abstract EvData + class SimonaSim class Scheduler @@ -177,7 +190,10 @@ package simona { ExtSimAdapter - Scheduler ExtEvDataService -- Scheduler - SecondaryData <|-- EvMovementData + ArrivingEvs --u|> EvData + EvFreeLotsRequest --u|> EvData + DepartingEvsRequest --u|> EvData + SecondaryData <|-- EvData SimonaService <|- ExtEvDataService ExtEvData --- ExtEvDataService @@ -197,6 +213,6 @@ sub1 ---[hidden]d> sub2 ExtLink -[hidden]> ElectricVehicle ExtSimulation -[hidden]> ExtEvSimulation ExtSimulation -[hidden]> DataResponseMessageToExt -RequestDepartingEvs --[hidden]> SecondaryData +ProvideArrivingEvs --[hidden]> ExtSimAdapter @enduml \ No newline at end of file From 1521db7aea8a77afd669e490a480cd354ce53727 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 12 Nov 2024 08:01:19 +0100 Subject: [PATCH 054/137] Fixing `CHANGELOG` entry for issue 103. --- CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4517ba8c..7b2359990d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,7 +94,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replace mutable var in ChpModelSpec [#1002](https://github.com/ie3-institute/simona/issues/1002) - Move compression of output files into `ResultEventListener`[#965](https://github.com/ie3-institute/simona/issues/965) - Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - +- Changed implementation of actor naming for unique name generation [#103](https://github.com/ie3-institute/simona/issues/103) + ### Fixed - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) - Removed version number "2.0" from the logo printed to console [#642](https://github.com/ie3-institute/simona/issues/642) @@ -127,6 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix CheckWindow duration [#921](https://github.com/ie3-institute/simona/issues/921) - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) - Fix filter for thermal result checking for lastTick not for currentTick [#1008](https://github.com/ie3-institute/simona/issues/1008) +- Fixed `CHANGELOG` entry for issue ([#103](https://github.com/ie3-institute/simona/issues/103)) [#941](https://github.com/ie3-institute/simona/issues/941) ## [3.0.0] - 2023-08-07 @@ -189,7 +191,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changed format of example grid `vn_simona` [#216](https://github.com/ie3-institute/simona/issues/216) - Renamed ChpData to ChpRelevantData [#494](https://github.com/ie3-institute/simona/issues/494) - Updated gradle to 8.2.1, cleaned up `build.gradle` and `Jenkinsfile` [#572](https://github.com/ie3-institute/simona/issues/572) -- Changed implementation of actor naming for unique name generation [#103](https://github.com/ie3-institute/simona/issues/103) ### Fixed - Location of `vn_simona` test grid (was partially in Berlin and Dortmund) [#72](https://github.com/ie3-institute/simona/issues/72) From c4b06ad1dc1dec3df66c951ce6e25eeac5497e72 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 12 Nov 2024 14:08:47 +0100 Subject: [PATCH 055/137] Fix initialisation freezing on empty primary data. --- CHANGELOG.md | 1 + .../ParticipantAgentFundamentals.scala | 5 ++- .../primary/PrimaryServiceWorker.scala | 33 ++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4517ba8c..8b00d85bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix CheckWindow duration [#921](https://github.com/ie3-institute/simona/issues/921) - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) - Fix filter for thermal result checking for lastTick not for currentTick [#1008](https://github.com/ie3-institute/simona/issues/1008) +- Fix initialisation freezing on empty primary data [#1014](https://github.com/ie3-institute/simona/issues/1014) ## [3.0.0] - 2023-08-07 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 984815a846..afff60b338 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -139,9 +139,8 @@ protected trait ParticipantAgentFundamentals[ /* Confirm final initialization */ releaseTick() - senderToMaybeTick._2.foreach { tick => - scheduler ! Completion(self.toTyped, Some(tick)) - } + scheduler ! Completion(self.toTyped, senderToMaybeTick._2) + goto(Idle) using stateData } diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 7ff05ccf1a..9d12372375 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -20,6 +20,7 @@ import edu.ie3.simona.agent.participant.data.Data.PrimaryData.RichValue import edu.ie3.simona.config.SimonaConfig.Simona.Input.Primary.SqlParams import edu.ie3.simona.exceptions.InitializationException import edu.ie3.simona.exceptions.WeatherServiceException.InvalidRegistrationRequestException +import edu.ie3.simona.exceptions.agent.ServiceRegistrationException import edu.ie3.simona.ontology.messages.services.ServiceMessage import edu.ie3.simona.ontology.messages.services.ServiceMessage.RegistrationResponseMessage.RegistrationSuccessfulMessage import edu.ie3.simona.service.ServiceStateData.{ @@ -131,10 +132,10 @@ final case class PrimaryServiceWorker[V <: Value]( s"Provided init data '${unsupported.getClass.getSimpleName}' for primary service are invalid!" ) ) - }).map { case (source, simulationStart) => + }).flatMap { case (source, simulationStart) => implicit val startDateTime: ZonedDateTime = simulationStart - val (maybeNextTick, furtherActivationTicks) = SortedDistinctSeq( + val foundTicks = SortedDistinctSeq( // Note: The whole data set is used here, which might be inefficient depending on the source implementation. source.getTimeSeries.getEntries.asScala .filter { timeBasedValue => @@ -146,17 +147,27 @@ final case class PrimaryServiceWorker[V <: Value]( .map(timeBasedValue => timeBasedValue.getTime.toTick) .toSeq .sorted - ).pop + ) + + if (foundTicks.nonEmpty) { + val (maybeNextTick, furtherActivationTicks) = foundTicks.pop - /* Set up the state data and determine the next activation tick. */ - val initializedStateData = - PrimaryServiceInitializedStateData( - maybeNextTick, - furtherActivationTicks, - simulationStart, - source, + /* Set up the state data and determine the next activation tick. */ + val initializedStateData = + PrimaryServiceInitializedStateData( + maybeNextTick, + furtherActivationTicks, + simulationStart, + source, + ) + + Success(initializedStateData, maybeNextTick) + } else + Failure( + new ServiceRegistrationException( + s"No future data found for timeseries ${source.getTimeSeries.getUuid}!" + ) ) - (initializedStateData, maybeNextTick) } } From b68140baa47b8b52b93697436d105cac05fb7a48 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 12 Nov 2024 19:51:43 +0100 Subject: [PATCH 056/137] Adapting code for less changes --- .../ie3/simona/service/primary/PrimaryServiceWorker.scala | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 9d12372375..204bae2f64 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -135,7 +135,7 @@ final case class PrimaryServiceWorker[V <: Value]( }).flatMap { case (source, simulationStart) => implicit val startDateTime: ZonedDateTime = simulationStart - val foundTicks = SortedDistinctSeq( + val (maybeNextTick, furtherActivationTicks) = SortedDistinctSeq( // Note: The whole data set is used here, which might be inefficient depending on the source implementation. source.getTimeSeries.getEntries.asScala .filter { timeBasedValue => @@ -147,10 +147,9 @@ final case class PrimaryServiceWorker[V <: Value]( .map(timeBasedValue => timeBasedValue.getTime.toTick) .toSeq .sorted - ) + ).pop - if (foundTicks.nonEmpty) { - val (maybeNextTick, furtherActivationTicks) = foundTicks.pop + if (maybeNextTick.nonEmpty) { /* Set up the state data and determine the next activation tick. */ val initializedStateData = From f8f7a64a7a6cb97761a59b583dce46c65ecb6686 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 12 Nov 2024 19:51:53 +0100 Subject: [PATCH 057/137] Adapting error message --- .../edu/ie3/simona/service/primary/PrimaryServiceWorker.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 204bae2f64..1c245328ed 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -164,7 +164,7 @@ final case class PrimaryServiceWorker[V <: Value]( } else Failure( new ServiceRegistrationException( - s"No future data found for timeseries ${source.getTimeSeries.getUuid}!" + s"No appropriate data found within simulation time range in timeseries ${source.getTimeSeries.getUuid}!" ) ) } From 96a246f1b1b4ef2b5740000692519006097c8d30 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 12 Nov 2024 20:40:19 +0100 Subject: [PATCH 058/137] Some small fixes --- docs/uml/main/ExtEvSimulationClasses.puml | 29 +++++++++++------------ 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/uml/main/ExtEvSimulationClasses.puml b/docs/uml/main/ExtEvSimulationClasses.puml index f4652d28eb..500f1a8ea2 100644 --- a/docs/uml/main/ExtEvSimulationClasses.puml +++ b/docs/uml/main/ExtEvSimulationClasses.puml @@ -22,7 +22,7 @@ package simona-api { + void setup(ExtSimAdapterData data, List adapters) + void run() # {abstract} Optional doActivity(long tick) - # {abstract} Long intitialize() + # {abstract} Long initialize() } ExtSimulation --r> ExtData MobilitySim -|> ExtSimulation @@ -71,7 +71,7 @@ package simona-api { + void queueExtResponseMsg(EvDataResponseMessageToExt extEvResponse) } - node sub2{ + node sub2 { interface EvDataMessageFromExt interface DataMessageFromExt @@ -95,20 +95,20 @@ package simona-api { ExtEvData --u|> ExtData ExtEvSimulation -u> ExtEvData - node sub1{ + node sub1 { interface DataResponseMessageToExt interface EvDataResponseMessageToExt - class ProvideCurrentPrices{ + class ProvideCurrentPrices { + Map prices } - class ProvideDepartingEvs{ + class ProvideDepartingEvs { + List departedEvs } - class ProvideEvcsFreeLots{ + class ProvideEvcsFreeLots { + Map evcs } @@ -116,7 +116,7 @@ package simona-api { ProvideDepartingEvs --|> EvDataResponseMessageToExt ProvideCurrentPrices --|> EvDataResponseMessageToExt ExtEvData --> EvDataResponseMessageToExt - EvDataResponseMessageToExt --|> DataResponseMessageToExt + EvDataResponseMessageToExt --|> DataResponseMessageToExt } node sub3 { @@ -155,18 +155,17 @@ package simona { interface SecondaryData - class ArrivingEvs{ - + arrivals Seq[EvModelWrapper] + class ArrivingEvs { + + arrivals: Seq[EvModelWrapper] } - class DepartingEvsRequest{ - + evcs UUID - + evModels Seq[EvModelWrapper] + class DepartingEvsRequest { + + evcs: UUID + + departingEvs: Seq[EvModelWrapper] } - class EvFreeLotsRequest{ - + evcs: UUID, - + freeLots: Int, + class EvFreeLotsRequest { + + freeLots: Int } abstract EvData From f819146eac5a7099b6381c239c5ba7943af3d01c Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Wed, 13 Nov 2024 17:56:28 +0100 Subject: [PATCH 059/137] Tiny bit of code cleanup --- .../simona/model/participant/HpModel.scala | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 41927fd2b0..9f0e94a9cf 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -223,7 +223,7 @@ final case class HpModel( * thermalStorage or it's empty. */ - def determineDemandBooleans( + private def determineDemandBooleans( lastHpState: HpState, updatedGridState: ThermalGridState, demandHouse: ThermalEnergyDemand, @@ -238,9 +238,8 @@ final case class HpModel( val houseDemand = (demandHouse.hasRequiredDemand && noThermalStorageOrThermalStorageIsEmpty) || (lastHpState.isRunning && demandHouse.hasAdditionalDemand) - val heatStorageDemand = { - (demandThermalStorage.hasRequiredDemand) || (lastHpState.isRunning && demandThermalStorage.hasAdditionalDemand) - } + val heatStorageDemand = + demandThermalStorage.hasRequiredDemand || (lastHpState.isRunning && demandThermalStorage.hasAdditionalDemand) (houseDemand, heatStorageDemand, noThermalStorageOrThermalStorageIsEmpty) } @@ -270,7 +269,7 @@ final case class HpModel( if (isRunning) (pRated, pThermal) else if (lastStateStorageQDot < zeroKW) - (zeroKW, lastStateStorageQDot * (-1)) + (zeroKW, lastStateStorageQDot * -1) else (zeroKW, zeroKW) /* Push thermal energy to the thermal grid and get its updated state in return */ @@ -346,12 +345,11 @@ final case class HpModel( /* If the setpoint value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */ val turnOn = setPower > (sRated * cosPhiRated * 0.5) - val updatedHpState: HpState = - calcState( - lastState, - data, - turnOn, - ) + val updatedHpState = calcState( + lastState, + data, + turnOn, + ) ( updatedHpState, From 01059692787766be4c1eb2ebc2473bff2bf44b04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 08:26:54 +0000 Subject: [PATCH 060/137] Bump sphinx-rtd-theme from 3.0.1 to 3.0.2 in /docs/readthedocs (#1018) --- docs/readthedocs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/readthedocs/requirements.txt b/docs/readthedocs/requirements.txt index 5ed7a8bf17..fcef71943b 100644 --- a/docs/readthedocs/requirements.txt +++ b/docs/readthedocs/requirements.txt @@ -1,5 +1,5 @@ Sphinx==8.1.3 -sphinx-rtd-theme==3.0.1 +sphinx-rtd-theme==3.0.2 sphinxcontrib-plantuml==0.30 myst-parser==4.0.0 markdown-it-py==3.0.0 From 61acfb680ea1ac13088d6b0c89b9d54e142d743a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 14 Nov 2024 09:45:37 +0100 Subject: [PATCH 061/137] grammar --- src/main/scala/edu/ie3/simona/model/participant/HpModel.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 9f0e94a9cf..f555827013 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -211,7 +211,7 @@ final case class HpModel( /** This method will return booleans whether there is a heat demand of house * or thermal storage as well as a boolean indicating if there is no thermal - * storage or it is empty. + * storage, or it is empty. * * @param lastHpState * @param updatedGridState @@ -220,7 +220,7 @@ final case class HpModel( * @return * First boolean is true, if house has heat demand. Second boolean is true, * if thermalStorage has heat demand. Third boolean is true, if there is no - * thermalStorage or it's empty. + * thermalStorage, or it's empty. */ private def determineDemandBooleans( From 1ba1e2868d24ed84f751977bb2e9d0fdce6b26d7 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 14 Nov 2024 10:35:42 +0100 Subject: [PATCH 062/137] Adding test for problematic primary data cases. --- CHANGELOG.md | 2 +- .../primary/PrimaryServiceWorker.scala | 46 +++++++++++-------- .../primary/PrimaryServiceWorkerSpec.scala | 26 +++++++++++ 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d672382269..07b2a4a888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -128,7 +128,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix CheckWindow duration [#921](https://github.com/ie3-institute/simona/issues/921) - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) - Fix filter for thermal result checking for lastTick not for currentTick [#1008](https://github.com/ie3-institute/simona/issues/1008) -- Fix initialisation freezing on empty primary data [#1014](https://github.com/ie3-institute/simona/issues/1014) +- Fix initialisation freezing on empty primary data [#981](https://github.com/ie3-institute/simona/issues/981) ## [3.0.0] - 2023-08-07 diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 1c245328ed..60d0056b40 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -138,35 +138,41 @@ final case class PrimaryServiceWorker[V <: Value]( val (maybeNextTick, furtherActivationTicks) = SortedDistinctSeq( // Note: The whole data set is used here, which might be inefficient depending on the source implementation. source.getTimeSeries.getEntries.asScala - .filter { timeBasedValue => - val dateTime = timeBasedValue.getTime - dateTime.isEqual(simulationStart) || dateTime.isAfter( - simulationStart - ) - } .map(timeBasedValue => timeBasedValue.getTime.toTick) + .filter(_ >= 0L) .toSeq .sorted ).pop - if (maybeNextTick.nonEmpty) { + (maybeNextTick, furtherActivationTicks) match { + case (maybeNextTick @ Some(tick), furtherActivationTicks) + if tick == 0L => + /* Set up the state data and determine the next activation tick. */ + val initializedStateData = + PrimaryServiceInitializedStateData( + maybeNextTick, + furtherActivationTicks, + simulationStart, + source, + ) + + Success(initializedStateData, maybeNextTick) - /* Set up the state data and determine the next activation tick. */ - val initializedStateData = - PrimaryServiceInitializedStateData( - maybeNextTick, - furtherActivationTicks, - simulationStart, - source, + case (Some(tick), _) if tick > 0L => + /* The start of the data needs to be at the first tick of the simulation or before. */ + Failure( + new ServiceRegistrationException( + s"The data for the timeseries '${source.getTimeSeries.getUuid}' starts after the start of this simulation (tick: $tick)! This is not allowed!" + ) ) - Success(initializedStateData, maybeNextTick) - } else - Failure( - new ServiceRegistrationException( - s"No appropriate data found within simulation time range in timeseries ${source.getTimeSeries.getUuid}!" + case _ => + Failure( + new ServiceRegistrationException( + s"No appropriate data found within simulation time range in timeseries '${source.getTimeSeries.getUuid}'!" + ) ) - ) + } } } diff --git a/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSpec.scala b/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSpec.scala index db7e9abdea..c08f189b79 100644 --- a/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSpec.scala +++ b/src/test/scala/edu/ie3/simona/service/primary/PrimaryServiceWorkerSpec.scala @@ -105,6 +105,32 @@ class PrimaryServiceWorkerSpec } } + "fail to init, if time series ends with delay before simulation start" in { + val initData = validInitData.copy( + simulationStart = validInitData.simulationStart.plusHours(1) + ) + + service.init(initData) match { + case Failure(exception) => + exception.getMessage shouldBe "No appropriate data found within simulation time range in timeseries '9185b8c1-86ba-4a16-8dea-5ac898e8caa5'!" + case Success(_) => + fail("Initialisation with unsupported init data is meant to fail.") + } + } + + "fail to init, if time series starts with delay after simulation start" in { + val initData = validInitData.copy( + simulationStart = validInitData.simulationStart.minusHours(1) + ) + + service.init(initData) match { + case Failure(exception) => + exception.getMessage shouldBe "The data for the timeseries '9185b8c1-86ba-4a16-8dea-5ac898e8caa5' starts after the start of this simulation (tick: 3600)! This is not allowed!" + case Success(_) => + fail("Initialisation with unsupported init data is meant to fail.") + } + } + "fail, if pointed to the wrong file" in { // time series exists, but is malformed val tsUuid = UUID.fromString("3fbfaa97-cff4-46d4-95ba-a95665e87c27") From 1ca9b3a0c913876d09bff2c77b69ff84a3decc0a Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Thu, 14 Nov 2024 11:36:08 +0100 Subject: [PATCH 063/137] Also moving issue #505 to its right place Signed-off-by: Sebastian Peter --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ba1d272ba..ba1648c26b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898) ### Fixed +- Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505) - Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658) - Removed version number "2.0" from the logo printed to console [#642](https://github.com/ie3-institute/simona/issues/642) - Fixed PV Model documentation [#684](https://github.com/ie3-institute/simona/issues/684), [#686](https://github.com/ie3-institute/simona/issues/686) @@ -227,7 +228,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed broken layout in RTD documentation [#500](https://github.com/ie3-institute/simona/issues/500) - Corrected tests in RefSystemTest [#560](https://github.com/ie3-institute/simona/issues/560) - Take log file event filters from `logback.xml` when defining the run log appender [#108](https://github.com/ie3-institute/simona/issues/108) -- Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505) ### Removed - Remove workaround for tscfg tmp directory [#178](https://github.com/ie3-institute/simona/issues/178) From 671325ea387a1f5663794d39a07c493ab5b890ca Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 14 Nov 2024 12:56:30 +0100 Subject: [PATCH 064/137] fmt from review --- .../edu/ie3/simona/event/ResultEvent.scala | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala index da844a801f..5e86582ffb 100644 --- a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala @@ -53,47 +53,44 @@ object ResultEvent { thermalResult: ThermalUnitResult ) extends ResultEvent - object ThermalHouseResult { - def unapply(result: ThermalHouseResult): Option[ - ( - ZonedDateTime, - UUID, - ComparableQuantity[Power], - ComparableQuantity[Temperature], - ) - ] = { - Option(result).flatMap { result => - Some( - ( - result.getTime, - result.getInputModel, - result.getqDot, - result.getIndoorTemperature, - ) + object ThermalHouseResult + def unapply(result: ThermalHouseResult): Option[ + ( + ZonedDateTime, + UUID, + ComparableQuantity[Power], + ComparableQuantity[Temperature], + ) + ] = + Option(result).flatMap { result => + Some( + ( + result.getTime, + result.getInputModel, + result.getqDot, + result.getIndoorTemperature, ) - } + ) } - } - object CylindricalThermalStorageResult { - def unapply(result: CylindricalStorageResult): Option[ - ( - ZonedDateTime, - UUID, - ComparableQuantity[Power], - ComparableQuantity[Energy], - ) - ] = { - Option(result).flatMap { result => - Some( - ( - result.getTime, - result.getInputModel, - result.getqDot, - result.getEnergy, - ) + object CylindricalThermalStorageResult + def unapply(result: CylindricalStorageResult): Option[ + ( + ZonedDateTime, + UUID, + ComparableQuantity[Power], + ComparableQuantity[Energy], + ) + ] = { + Option(result).flatMap { result => + Some( + ( + result.getTime, + result.getInputModel, + result.getqDot, + result.getEnergy, ) - } + ) } } From 5790cff86f58e6d13c92d05aacc5cd0fc4731a6d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Thu, 14 Nov 2024 12:59:45 +0100 Subject: [PATCH 065/137] update scalaDoc --- src/main/scala/edu/ie3/simona/model/participant/HpModel.scala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index f555827013..bf26b80fd8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -214,9 +214,13 @@ final case class HpModel( * storage, or it is empty. * * @param lastHpState + * Current state of the heat pump * @param updatedGridState + * The updated state of the [[ThermalGrid]] * @param demandHouse + * heat demand of the thermal house * @param demandThermalStorage + * heat demand of the thermal storage * @return * First boolean is true, if house has heat demand. Second boolean is true, * if thermalStorage has heat demand. Third boolean is true, if there is no From 1e99533088964742ca9166b3cba4a65781125be3 Mon Sep 17 00:00:00 2001 From: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:09:27 +0100 Subject: [PATCH 066/137] Update src/main/scala/edu/ie3/simona/event/ResultEvent.scala include reviewers suggestion Co-authored-by: Sebastian Peter --- src/main/scala/edu/ie3/simona/event/ResultEvent.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala index 5e86582ffb..2ec9ab5882 100644 --- a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala @@ -62,16 +62,14 @@ object ResultEvent { ComparableQuantity[Temperature], ) ] = - Option(result).flatMap { result => - Some( + Option(result).map { result => ( result.getTime, result.getInputModel, result.getqDot, result.getIndoorTemperature, ) - ) - } + } object CylindricalThermalStorageResult def unapply(result: CylindricalStorageResult): Option[ From 005b9b7261ee5fd2f2fa007d219e9dbfd1a3fb4b Mon Sep 17 00:00:00 2001 From: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:09:57 +0100 Subject: [PATCH 067/137] Update src/main/scala/edu/ie3/simona/event/ResultEvent.scala include more suggestion from reviewer Co-authored-by: Sebastian Peter --- src/main/scala/edu/ie3/simona/event/ResultEvent.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala index 2ec9ab5882..0ccaa7f909 100644 --- a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala @@ -80,16 +80,14 @@ object ResultEvent { ComparableQuantity[Energy], ) ] = { - Option(result).flatMap { result => - Some( + Option(result).map { result => ( result.getTime, result.getInputModel, result.getqDot, result.getEnergy, ) - ) - } + } } /** Event that holds all grid calculation results of a power flow calculation. From 61e71a1cdc5b910b6662f98b3adbacb306a45486 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:14:59 +0100 Subject: [PATCH 068/137] add brackets for objects --- .../edu/ie3/simona/event/ResultEvent.scala | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala index 0ccaa7f909..6e91283b65 100644 --- a/src/main/scala/edu/ie3/simona/event/ResultEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/ResultEvent.scala @@ -53,15 +53,15 @@ object ResultEvent { thermalResult: ThermalUnitResult ) extends ResultEvent - object ThermalHouseResult - def unapply(result: ThermalHouseResult): Option[ - ( - ZonedDateTime, - UUID, - ComparableQuantity[Power], - ComparableQuantity[Temperature], - ) - ] = + object ThermalHouseResult { + def unapply(result: ThermalHouseResult): Option[ + ( + ZonedDateTime, + UUID, + ComparableQuantity[Power], + ComparableQuantity[Temperature], + ) + ] = Option(result).map { result => ( result.getTime, @@ -70,16 +70,17 @@ object ResultEvent { result.getIndoorTemperature, ) } + } - object CylindricalThermalStorageResult - def unapply(result: CylindricalStorageResult): Option[ - ( - ZonedDateTime, - UUID, - ComparableQuantity[Power], - ComparableQuantity[Energy], - ) - ] = { + object CylindricalThermalStorageResult { + def unapply(result: CylindricalStorageResult): Option[ + ( + ZonedDateTime, + UUID, + ComparableQuantity[Power], + ComparableQuantity[Energy], + ) + ] = { Option(result).map { result => ( result.getTime, @@ -88,6 +89,7 @@ object ResultEvent { result.getEnergy, ) } + } } /** Event that holds all grid calculation results of a power flow calculation. From df6aaa2ae9cfa88a236554de046592ca38373e19 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:32:56 +0100 Subject: [PATCH 069/137] access can be private --- .../edu/ie3/simona/service/weather/SampleWeatherSource.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala index c8045ced59..3b5ec71079 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala @@ -185,7 +185,7 @@ object SampleWeatherSource { // these lists contain the hourly weather values for each first of the month of 2011 + january of // 2012 at coordinate id 213089 - val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 1.18179e-12, + private val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 1.18179e-12, 4.42315e-11, 0.0585938, 1.94141, 15.1172, 74.8438, 89.0469, 104.062, 131.211, 98.3984, 74.5664, 9.52576e-10, 5.61295e-09, 3.74196e-09, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.3031e-12, 1.26833e-10, 0.123047, 21.7734, 44.8906, 62.5, @@ -220,7 +220,7 @@ object SampleWeatherSource { 0.0546875, 1.91406, 17.5312, 69.7578, 86.0391, 87.2578, 102.062, 78.9297, 64.0508, 4.10171e-09, 7.74083e-09, 1.05629e-08, 0, 0, 0, 0, 0) - val directRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + private val directRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03125, 0.34375, 0.171875, 0.117188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0136719, 3.625, 36.7266, 83.5, 278.094, 312.328, 333.422, 350.391, 314.328, 266.484, 80.1172, 43.6875, 29.125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, From 500aee6ed8eb4c5c0aa75b84cddf2bfb21df8f3d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:33:32 +0100 Subject: [PATCH 070/137] fix scala doc --- .../participant/load/LoadAgentFundamentals.scala | 2 +- .../scala/edu/ie3/simona/config/ConfigFailFast.scala | 12 ++++++------ .../ie3/simona/model/grid/TransformerTapping.scala | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 78519a54c1..89079e33bf 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -298,7 +298,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ * * @param baseStateData * The base state data with collected secondary data - * @param maybeLastModelState + * @param lastModelState * Optional last model state * @param currentTick * Tick, the trigger belongs to diff --git a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala index 3437944c78..20c0d201f9 100644 --- a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala +++ b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala @@ -785,29 +785,29 @@ case object ConfigFailFast extends LazyLogging { /** Check the suitability of storage config parameters. * - * @param StorageRuntimeConfig + * @param storageRuntimeConfig * RuntimeConfig of Storages */ private def checkStoragesConfig( - storageConfig: SimonaConfig.Simona.Runtime.Participant.Storage + storageRuntimeConfig: SimonaConfig.Simona.Runtime.Participant.Storage ): Unit = { if ( - storageConfig.defaultConfig.initialSoc < 0.0 || storageConfig.defaultConfig.initialSoc > 1.0 + storageRuntimeConfig.defaultConfig.initialSoc < 0.0 || storageRuntimeConfig.defaultConfig.initialSoc > 1.0 ) throw new RuntimeException( s"StorageRuntimeConfig: Default initial SOC needs to be between 0.0 and 1.0." ) if ( - storageConfig.defaultConfig.targetSoc.exists( + storageRuntimeConfig.defaultConfig.targetSoc.exists( _ < 0.0 - ) || storageConfig.defaultConfig.targetSoc.exists(_ > 1.0) + ) || storageRuntimeConfig.defaultConfig.targetSoc.exists(_ > 1.0) ) throw new RuntimeException( s"StorageRuntimeConfig: Default target SOC needs to be between 0.0 and 1.0." ) - storageConfig.individualConfigs.foreach { config => + storageRuntimeConfig.individualConfigs.foreach { config => if (config.initialSoc < 0.0 || config.initialSoc > 1.0) throw new RuntimeException( s"StorageRuntimeConfig: ${config.uuids} initial SOC needs to be between 0.0 and 1.0." diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala index 809e7c5f8f..2806aa159d 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala @@ -45,6 +45,7 @@ trait TransformerTapping { /** Increase transformer tap position by the provided delta value * * @param deltaTap + * number of tap positions to increase */ def incrTapPos(deltaTap: Int = 1): Unit = tapRatio = transformerTappingModel.incrTapPos(deltaTap) @@ -52,6 +53,7 @@ trait TransformerTapping { /** Decrease transformer tap position by the provided delta value * * @param deltaTap + * number of tap positions to decrease */ def decrTapPos(deltaTap: Int = 1): Unit = tapRatio = transformerTappingModel.decrTapPos(deltaTap) From d6d4ea29bd455901f2206065b1a6266115675c17 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:33:39 +0100 Subject: [PATCH 071/137] fmt --- .../service/weather/SampleWeatherSource.scala | 95 ++++++++++--------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala index 3b5ec71079..9225f4b340 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala @@ -185,55 +185,56 @@ object SampleWeatherSource { // these lists contain the hourly weather values for each first of the month of 2011 + january of // 2012 at coordinate id 213089 - private val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 1.18179e-12, - 4.42315e-11, 0.0585938, 1.94141, 15.1172, 74.8438, 89.0469, 104.062, - 131.211, 98.3984, 74.5664, 9.52576e-10, 5.61295e-09, 3.74196e-09, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4.3031e-12, 1.26833e-10, 0.123047, 21.7734, 44.8906, 62.5, - 116.304, 121.279, 124.103, 127.578, 126.474, 122.366, 72.7656, 50.4609, - 33.6406, 1.95692e-12, 9.96252e-13, 6.64168e-13, 0, 0, 0, 0, 0, 0, - 4.6561e-11, 0.179688, 7.00781, 70.375, 85.0805, 96.5268, 131.642, 134.801, - 136.495, 137.11, 133.496, 127.942, 95.6875, 79.7031, 57.375, 2.50246e-10, - 1.27398e-10, 8.49321e-11, 0, 0, 0, 0, 0, 0, 4.6561e-11, 0.179688, 7.00781, - 70.375, 85.0805, 96.5268, 131.642, 134.801, 136.495, 137.11, 133.496, - 127.942, 95.6875, 79.7031, 57.375, 2.50246e-10, 1.27398e-10, 8.49321e-11, 0, - 0, 0, 0, 0, 3.01617e-13, 0.320312, 9.46875, 31.536, 137.816, 144.761, - 148.295, 159.991, 179.943, 161.786, 167.365, 187.983, 186.71, 190.492, - 153.12, 109.372, 8.79227e-11, 4.47606e-11, 2.98404e-11, 0, 0, 0, 0, 0, - 0.0214844, 5.28906, 34.5625, 64.5749, 145.311, 158.575, 177.106, 203.842, - 208.607, 192.496, 153.726, 150.415, 146.707, 122.146, 112.221, 99.3091, - 32.2031, 16.3906, 10.9297, 0, 0, 0, 0, 0, 0.046875, 9.05859, 30.9102, - 49.6208, 111.284, 119.403, 126.256, 148.362, 150.649, 151.829, 151.844, - 149.184, 145.261, 123.728, 114.725, 103.147, 43.0547, 21.9219, 14.6133, 0, - 0, 0, 0, 0, 1.2934e-11, 0.460938, 13.4727, 40.0492, 144.359, 178.505, - 200.116, 217.874, 243.675, 270.285, 324.789, 288.28, 246.589, 213.373, - 161.242, 131.508, 27.2734, 13.8828, 9.25781, 0, 0, 0, 0, 0, 2.57911e-13, - 1.14858e-09, 0.28125, 10.9336, 98.3691, 119.471, 122.866, 142.176, 228.197, - 257.473, 168.816, 187.572, 185.407, 173.508, 128.359, 98.2266, 1.78996e-10, - 6.29864e-10, 1.1817e-09, 0, 0, 0, 0, 0, 0, 5.39019e-11, 0.0664062, 2.85742, - 73.9453, 94.8518, 100.687, 124.047, 126.782, 127.841, 125.49, 120.944, - 114.361, 73.6172, 52.5547, 35.0352, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3.2974e-13, - 4.56214e-11, 0.0996094, 18.0625, 45.7656, 73.1016, 143.159, 158.414, - 171.997, 164.156, 149.156, 124.133, 17.2539, 8.78516, 5.85547, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 4.99714e-11, 6.15368e-10, 0.464844, 13.3242, 29.8594, - 83.7578, 88.2578, 90.0703, 86.3281, 78.0234, 64.9609, 7.0161e-09, - 4.42477e-09, 2.94985e-09, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6.71801e-10, - 0.0546875, 1.91406, 17.5312, 69.7578, 86.0391, 87.2578, 102.062, 78.9297, - 64.0508, 4.10171e-09, 7.74083e-09, 1.05629e-08, 0, 0, 0, 0, 0) + private val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, + 1.18179e-12, 4.42315e-11, 0.0585938, 1.94141, 15.1172, 74.8438, 89.0469, + 104.062, 131.211, 98.3984, 74.5664, 9.52576e-10, 5.61295e-09, 3.74196e-09, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.3031e-12, 1.26833e-10, 0.123047, 21.7734, + 44.8906, 62.5, 116.304, 121.279, 124.103, 127.578, 126.474, 122.366, + 72.7656, 50.4609, 33.6406, 1.95692e-12, 9.96252e-13, 6.64168e-13, 0, 0, 0, + 0, 0, 0, 4.6561e-11, 0.179688, 7.00781, 70.375, 85.0805, 96.5268, 131.642, + 134.801, 136.495, 137.11, 133.496, 127.942, 95.6875, 79.7031, 57.375, + 2.50246e-10, 1.27398e-10, 8.49321e-11, 0, 0, 0, 0, 0, 0, 4.6561e-11, + 0.179688, 7.00781, 70.375, 85.0805, 96.5268, 131.642, 134.801, 136.495, + 137.11, 133.496, 127.942, 95.6875, 79.7031, 57.375, 2.50246e-10, + 1.27398e-10, 8.49321e-11, 0, 0, 0, 0, 0, 3.01617e-13, 0.320312, 9.46875, + 31.536, 137.816, 144.761, 148.295, 159.991, 179.943, 161.786, 167.365, + 187.983, 186.71, 190.492, 153.12, 109.372, 8.79227e-11, 4.47606e-11, + 2.98404e-11, 0, 0, 0, 0, 0, 0.0214844, 5.28906, 34.5625, 64.5749, 145.311, + 158.575, 177.106, 203.842, 208.607, 192.496, 153.726, 150.415, 146.707, + 122.146, 112.221, 99.3091, 32.2031, 16.3906, 10.9297, 0, 0, 0, 0, 0, + 0.046875, 9.05859, 30.9102, 49.6208, 111.284, 119.403, 126.256, 148.362, + 150.649, 151.829, 151.844, 149.184, 145.261, 123.728, 114.725, 103.147, + 43.0547, 21.9219, 14.6133, 0, 0, 0, 0, 0, 1.2934e-11, 0.460938, 13.4727, + 40.0492, 144.359, 178.505, 200.116, 217.874, 243.675, 270.285, 324.789, + 288.28, 246.589, 213.373, 161.242, 131.508, 27.2734, 13.8828, 9.25781, 0, 0, + 0, 0, 0, 2.57911e-13, 1.14858e-09, 0.28125, 10.9336, 98.3691, 119.471, + 122.866, 142.176, 228.197, 257.473, 168.816, 187.572, 185.407, 173.508, + 128.359, 98.2266, 1.78996e-10, 6.29864e-10, 1.1817e-09, 0, 0, 0, 0, 0, 0, + 5.39019e-11, 0.0664062, 2.85742, 73.9453, 94.8518, 100.687, 124.047, + 126.782, 127.841, 125.49, 120.944, 114.361, 73.6172, 52.5547, 35.0352, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3.2974e-13, 4.56214e-11, 0.0996094, 18.0625, 45.7656, + 73.1016, 143.159, 158.414, 171.997, 164.156, 149.156, 124.133, 17.2539, + 8.78516, 5.85547, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4.99714e-11, 6.15368e-10, + 0.464844, 13.3242, 29.8594, 83.7578, 88.2578, 90.0703, 86.3281, 78.0234, + 64.9609, 7.0161e-09, 4.42477e-09, 2.94985e-09, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 6.71801e-10, 0.0546875, 1.91406, 17.5312, 69.7578, 86.0391, 87.2578, + 102.062, 78.9297, 64.0508, 4.10171e-09, 7.74083e-09, 1.05629e-08, 0, 0, 0, + 0, 0) - private val directRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0.03125, 0.34375, 0.171875, 0.117188, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0.0136719, 3.625, 36.7266, 83.5, 278.094, 312.328, 333.422, 350.391, - 314.328, 266.484, 80.1172, 43.6875, 29.125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0.0234375, 1.3125, 83.7109, 146.523, 211.234, 448.781, 481.25, 499.109, - 505.359, 469.375, 420.406, 187.695, 126.977, 84.8438, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0.0234375, 1.3125, 83.7109, 146.523, 211.234, 448.781, 481.25, + private val directRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0.03125, 0.34375, 0.171875, 0.117188, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0.0136719, 3.625, 36.7266, 83.5, 278.094, 312.328, 333.422, + 350.391, 314.328, 266.484, 80.1172, 43.6875, 29.125, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0.0234375, 1.3125, 83.7109, 146.523, 211.234, 448.781, 481.25, 499.109, 505.359, 469.375, 420.406, 187.695, 126.977, 84.8438, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0.0234375, 0.898438, 12.6953, 110.062, 183.016, 262.141, - 527.344, 517.719, 426.094, 559.203, 326.797, 230.422, 43.25, 62.9062, - 41.9453, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.210938, 6.19531, 23.0156, 219.234, - 278.797, 324.406, 536.797, 559.438, 600.734, 657.719, 622.281, 573.391, - 346.172, 279.25, 215.422, 9.6875, 4.92969, 3.28906, 0, 0, 0, 0, 0, 0, - 0.773438, 19.5391, 59.8203, 275.453, 342.297, 406.078, 630.578, 658.984, + 0, 0, 0, 0, 0, 0, 0.0234375, 1.3125, 83.7109, 146.523, 211.234, 448.781, + 481.25, 499.109, 505.359, 469.375, 420.406, 187.695, 126.977, 84.8438, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0.0234375, 0.898438, 12.6953, 110.062, 183.016, + 262.141, 527.344, 517.719, 426.094, 559.203, 326.797, 230.422, 43.25, + 62.9062, 41.9453, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.210938, 6.19531, 23.0156, + 219.234, 278.797, 324.406, 536.797, 559.438, 600.734, 657.719, 622.281, + 573.391, 346.172, 279.25, 215.422, 9.6875, 4.92969, 3.28906, 0, 0, 0, 0, 0, + 0, 0.773438, 19.5391, 59.8203, 275.453, 342.297, 406.078, 630.578, 658.984, 674.172, 675.344, 641.859, 596.781, 376.188, 309.078, 243.672, 21.9141, 11.1562, 7.4375, 0, 0, 0, 0, 0, 0, 0, 0.0703125, 2.64062, 5.46875, 19.1094, 49.7969, 217.547, 295.953, 307.719, 316.812, 332.766, 294.828, 131.562, From c09edacd91aa8f0dd535c142fa332033a93d0830 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:37:02 +0100 Subject: [PATCH 072/137] remove redundant bracket --- .../agent/participant/statedata/ParticipantStateData.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/statedata/ParticipantStateData.scala b/src/main/scala/edu/ie3/simona/agent/participant/statedata/ParticipantStateData.scala index 95d8df3fcf..786caf63b0 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/statedata/ParticipantStateData.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/statedata/ParticipantStateData.scala @@ -29,7 +29,7 @@ object ParticipantStateData { /** Data for the state, in which the agent is not initialized, yet. *

IMPORTANT: Needs to be an empty case class due to typing

*/ - final class ParticipantUninitializedStateData[+PD <: PrimaryData]() + final class ParticipantUninitializedStateData[+PD <: PrimaryData] extends UninitializedStateData[PD] object ParticipantUninitializedStateData { From 6683164dc5fb4f21c8de8243a34266ebf36b2688 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:39:24 +0100 Subject: [PATCH 073/137] make methods private --- .../ie3/simona/agent/grid/GridResultsSupport.scala | 5 +++-- .../participant/ParticipantAgentFundamentals.scala | 12 ++++++------ .../scala/edu/ie3/simona/config/ArgsParser.scala | 4 ++-- .../simona/model/participant/evcs/EvcsModel.scala | 2 +- .../edu/ie3/simona/sim/setup/ExtSimLoader.scala | 2 +- .../scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 6 +++--- .../scala/edu/ie3/simona/util/CollectionUtils.scala | 2 +- .../edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index c872cc8e54..0a97764f73 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -201,8 +201,9 @@ private[grid] trait GridResultsSupport { * @return * a set of [[PartialTransformer3wResult]] s */ - def buildTransformer3wResults(transformers3w: Set[Transformer3wModel])( - implicit + private def buildTransformer3wResults( + transformers3w: Set[Transformer3wModel] + )(implicit sweepValueStoreData: Map[UUID, SweepValueStoreData], iNominal: ElectricCurrent, timestamp: ZonedDateTime, 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 984815a846..8cf02a9e09 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -1081,7 +1081,7 @@ protected trait ParticipantAgentFundamentals[ goto(Idle) using updatedBaseStateData } - def pollNextActivationTrigger( + private def pollNextActivationTrigger( baseStateData: BaseStateData[PD] ): Option[Long] = { /* Determine what comes next: An additional activation or new data - or both at once */ @@ -1278,7 +1278,7 @@ protected trait ParticipantAgentFundamentals[ * @return * Option on a possible fast state change */ - final def determineFastReply( + private final def determineFastReply( baseStateData: BaseStateData[PD], mostRecentRequest: Option[(Long, PD)], requestTick: Long, @@ -1655,7 +1655,7 @@ protected trait ParticipantAgentFundamentals[ * @return * Averaged result */ - def determineAverageResult( + private def determineAverageResult( baseStateData: BaseStateData[PD], tickToResult: Map[Long, PD], windowStartTick: Long, @@ -1757,7 +1757,7 @@ protected trait ParticipantAgentFundamentals[ * @param outputConfig * Configuration of the output behaviour */ - protected def announceSimulationResult( + private def announceSimulationResult( baseStateData: BaseStateData[PD], tick: Long, result: AccompaniedSimulationResult[PD], @@ -1888,7 +1888,7 @@ protected trait ParticipantAgentFundamentals[ * @return * The equivalent event */ - def buildResultEvent( + private def buildResultEvent( baseStateData: BaseStateData[PD], tick: Long, result: PD, @@ -1909,7 +1909,7 @@ protected trait ParticipantAgentFundamentals[ * @return * Optionally wrapped event */ - def buildResultEvent[R <: ResultEntity]( + private def buildResultEvent[R <: ResultEntity]( result: R ): Option[ResultEvent] = result match { case thermalResult: ThermalUnitResult => diff --git a/src/main/scala/edu/ie3/simona/config/ArgsParser.scala b/src/main/scala/edu/ie3/simona/config/ArgsParser.scala index 183aa8149c..e79c6b94ce 100644 --- a/src/main/scala/edu/ie3/simona/config/ArgsParser.scala +++ b/src/main/scala/edu/ie3/simona/config/ArgsParser.scala @@ -148,11 +148,11 @@ object ArgsParser extends LazyLogging { // sealed trait for cluster type sealed trait ClusterType - case object MasterNode extends ClusterType { + private case object MasterNode extends ClusterType { override def toString = "master" } - case object SeedNode extends ClusterType { + private case object SeedNode extends ClusterType { override def toString = "worker" } diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index a1d21252ec..674e35efd4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -928,7 +928,7 @@ final case class EvcsModel( * @param chargingPoints * max number of charging points available at this CS */ - def validateArrivals( + private def validateArrivals( lastEvs: Seq[EvModelWrapper], arrivals: Seq[EvModelWrapper], chargingPoints: Int, diff --git a/src/main/scala/edu/ie3/simona/sim/setup/ExtSimLoader.scala b/src/main/scala/edu/ie3/simona/sim/setup/ExtSimLoader.scala index 4275ab7d33..f876cc09eb 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/ExtSimLoader.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/ExtSimLoader.scala @@ -20,7 +20,7 @@ object ExtSimLoader extends LazyLogging { private val extSimPath = "input" + java.io.File.separator + "ext_sim" - def getStandardDirectory: File = { + private def getStandardDirectory: File = { val workingDir = new File(System.getProperty("user.dir")) if (!workingDir.isDirectory) throw new IOException("Error when accessing working directory.") diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 535b140798..a18afc9ce9 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -143,7 +143,7 @@ trait SetupHelper extends LazyLogging { * @return * The actor reference of the sub grid to look for */ - def getActorRef( + private def getActorRef( subGridToActorRefMap: Map[Int, ActorRef[GridAgent.Request]], currentSubGrid: Int, queriedSubGrid: Int, @@ -167,7 +167,7 @@ trait SetupHelper extends LazyLogging { * @return * The reference system to use */ - def getRefSystem( + private def getRefSystem( configRefSystems: ConfigRefSystems, subGridContainer: SubGridContainer, ): RefSystem = { @@ -252,7 +252,7 @@ object SetupHelper { * @return * Set of [[ResultEntity]] classes */ - def allResultEntitiesToWrite( + private def allResultEntitiesToWrite( outputConfig: SimonaConfig.Simona.Output ): Set[Class[_ <: ResultEntity]] = GridOutputConfigUtil( diff --git a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala index 6402ea7b2a..d73a2755bf 100644 --- a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala +++ b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala @@ -79,7 +79,7 @@ object CollectionUtils { * otherwise */ @tailrec - def isSorted[T](list: List[T])(implicit ord: Ordering[T]): Boolean = + private def isSorted[T](list: List[T])(implicit ord: Ordering[T]): Boolean = list match { case Nil => true // an empty list is sorted case _ :: Nil => true // a single-element list is sorted diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 171c5835a2..d9f1b7e7c4 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -257,7 +257,7 @@ object ResultFileHierarchy extends LazyLogging { * @param outputFileHierarchy * the [[ResultFileHierarchy]] the directories should be created for */ - def createOutputDirectories( + private def createOutputDirectories( outputFileHierarchy: ResultFileHierarchy ): Unit = { // try to create base output dir From 6d332ecb6e419089669c56d97703d46f4b053b09 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:40:06 +0100 Subject: [PATCH 074/137] add type annotations for public vals --- .../edu/ie3/simona/agent/grid/GridAgentDataHelperSpec.scala | 6 +++--- src/test/scala/edu/ie3/simona/model/grid/GridSpec.scala | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/GridAgentDataHelperSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/GridAgentDataHelperSpec.scala index 3e2170cbdc..df1251c266 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/GridAgentDataHelperSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/GridAgentDataHelperSpec.scala @@ -70,15 +70,15 @@ class GridAgentDataHelperSpec extends UnitSpec with SubGridGateMokka { UUID.fromString("3bcda4b0-2d1a-44f5-95c1-a63ce1d40bed"), 3000, ) - val superiorGridGates = Vector(superiorSubGridGate1) - val centerGridGates = Vector( + val superiorGridGates: Vector[SubGridGate] = Vector(superiorSubGridGate1) + val centerGridGates: Vector[SubGridGate] = Vector( superiorSubGridGate1, superiorSubGridGate2, centerSubGridGate1, centerSubGridGate2, centerSubGridGate3, ) - val inferiorGridGates = Vector(centerSubGridGate1) + val inferiorGridGates: Vector[SubGridGate] = Vector(centerSubGridGate1) val superiorGridId = 1 val superiorGridAgent: TestGridData = diff --git a/src/test/scala/edu/ie3/simona/model/grid/GridSpec.scala b/src/test/scala/edu/ie3/simona/model/grid/GridSpec.scala index 2f29248054..45b0e5a837 100644 --- a/src/test/scala/edu/ie3/simona/model/grid/GridSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/grid/GridSpec.scala @@ -231,7 +231,7 @@ class GridSpec nodes.foreach(_.enable()) // remove a line from the grid - val adaptedLines = lines - line3To4 + val adaptedLines: Set[LineModel] = lines - line3To4 adaptedLines.foreach(_.enable()) // enable transformer @@ -466,7 +466,7 @@ class GridSpec updateUuidToIndexMap(gridModel) // nodes 1, 13 and 14 should map to the same node - val node1Index = gridModel.nodeUuidToIndexMap + val node1Index: Int = gridModel.nodeUuidToIndexMap .get(node1.uuid) .value gridModel.nodeUuidToIndexMap.get(node13.uuid).value shouldBe node1Index From 990b1cfbc44faf30d3c6186a4a216169906f9b65 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:52:30 +0100 Subject: [PATCH 075/137] using past participle --- .../scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 5f21b06a39..d608d49393 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -1153,7 +1153,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { * @param askTimeout * a timeout for the request * @return - * true if this grids contains assets or false if no request has been send + * true if this grids contains assets or false if no request has been sent * due to non-existence of assets */ private def askForAssetPowers( @@ -1383,11 +1383,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { } /** This method uses [[ActorContext.pipeToSelf()]] to send a future message to - * itself. If the future is a [[Success]] the message is send, else a - * [[WrappedFailure]] with the thrown error is send. + * itself. If the future is a [[Success]] the message is sent, else a + * [[WrappedFailure]] with the thrown error is sent. * * @param future - * future message that should be send to the agent after it was processed + * future message that should be sent to the agent after it was processed * @param ctx * [[ActorContext]] of the receiving actor */ From 5f11ab02a915a853a6b978192973db4698b6a388 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:54:45 +0100 Subject: [PATCH 076/137] adding some commas --- src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 4 ++-- .../simona/agent/participant/statedata/BaseStateData.scala | 2 +- .../simona/test/common/model/grid/BasicGridWithSwitches.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index d608d49393..36abbc1d16 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -737,7 +737,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { gridAgentBaseData.powerFlowParams.sweepTimeout, )(ctx) - // when we don't have inferior grids and no assets both methods return None and we can skip doing another power + // when we don't have inferior grids and no assets both methods return None, and we can skip doing another power // flow calculation otherwise we go back to simulate grid and wait for the answers if (!askForAssetPowersOpt && !askForInferiorGridPowersOpt) { ctx.log.debug( @@ -832,7 +832,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { ) /* Regarding the power flow result of this grid, there are two cases. If this is the "highest" grid in a - * simulation without a three winding transformer, the grid consists of only one node and we can mock the power + * simulation without a three winding transformer, the grid consists of only one node, and we can mock the power * flow results. If there is a three winding transformer apparent, we actually have to perform power flow * calculations, as the high voltage branch of the transformer is modeled here. */ (if (gridModel.gridComponents.transformers3w.isEmpty) { diff --git a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala index 96758a2d16..9627ee1578 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala @@ -51,7 +51,7 @@ trait BaseStateData[+PD <: PrimaryDataWithApparentPower[PD]] */ val modelUuid: UUID - /** By default the agent should be triggered in the same tick, where data is + /** By default, the agent should be triggered in the same tick, where data is * incoming from primary or secondary sources. However, if there is no other * information needed, we might have the need to schedule ourselves for * activation triggers diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala index bd709daa01..5781848e1b 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala @@ -20,7 +20,7 @@ import tech.units.indriya.quantity.Quantities import java.util.UUID -/** Note: the line parameters are NOT adapted. Instead the line params from +/** Note: the line parameters are NOT adapted. Instead, the line params from * [[FiveLinesWithNodes]] are used instead! * * {{{ From 379f927dafcbef84b93aa08056c5cd1aec80e234 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:56:37 +0100 Subject: [PATCH 077/137] more grammar --- CHANGELOG.md | 2 +- docs/readthedocs/models/chp_model.md | 2 +- docs/readthedocs/models/cts_model.md | 2 +- .../ie3/simona/agent/grid/DBFSAlgorithm.scala | 28 +++++++++---------- .../ie3/simona/config/ConfigFailFast.scala | 8 +++--- .../simona/model/participant/ChpModel.scala | 2 +- .../simona/model/system/Characteristic.scala | 2 +- .../thermal/CylindricalThermalStorage.scala | 2 +- .../edu/ie3/simona/util/CollectionUtils.scala | 2 +- .../edu/ie3/simona/util/ConfigUtil.scala | 4 +-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b683cd1327..04377de7c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -224,7 +224,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for three winding transformers [#63](https://github.com/ie3-institute/simona/issues/63) - Handle incoming slack voltage accordingly - Allow multiple sub grid gates at one node (also allows multiple two winding transformers at one node) - - Perform power flow calculation in highest grid, if a three winding transformer is apparent + - Perform power flow calculation in the highest grid, if a three winding transformer is apparent - Write out results - Fixed broken layout in RTD documentation [#500](https://github.com/ie3-institute/simona/issues/500) - Corrected tests in RefSystemTest [#560](https://github.com/ie3-institute/simona/issues/560) diff --git a/docs/readthedocs/models/chp_model.md b/docs/readthedocs/models/chp_model.md index c5f01364bf..d7eb8232eb 100644 --- a/docs/readthedocs/models/chp_model.md +++ b/docs/readthedocs/models/chp_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the CHP Model (combined heat and power ## Assumptions -The CHP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the CHP unit does not posses a memory. Losses of the heat storage are not considered. +The CHP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the CHP unit does not possess a memory. Losses of the heat storage are not considered. ## Parameters diff --git a/docs/readthedocs/models/cts_model.md b/docs/readthedocs/models/cts_model.md index 5750820624..e03fa06563 100644 --- a/docs/readthedocs/models/cts_model.md +++ b/docs/readthedocs/models/cts_model.md @@ -3,7 +3,7 @@ This page documents the functionality of the cylindrical thermal storage available in SIMONA. ## Behaviour -This storage model operates on volumes, although the functions it provides for other models all operate with energy. Internally the storage model converts energy to volume and vice versa with formulas specified below. Furthermore it is assumed that the storage medium is water. Also the model holds a variable for the current storage level. +This storage model operates on volumes, although the functions it provides for other models all operate with energy. Internally the storage model converts energy to volume and vice versa with formulas specified below. Furthermore, it is assumed that the storage medium is water. Also, the model holds a variable for the current storage level. ## Attributes, Units and Remarks diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 36abbc1d16..d0a23ea6da 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -197,7 +197,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { case None => // this happens if this agent is either a) the superior grid agent, because it will always get a request for // the next sweep, as it triggers calculations for the next sweep or b) at all other - // (non last downstream grid agents) in sweep 0 + // (non-last downstream grid agents) in sweep 0 ctx.log.debug( "Unable to find slack voltage for nodes '{}' in sweep '{}'. Try to get voltage of previous sweep.", nodeUuids, @@ -386,7 +386,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { // update the sweep value store and clear all received maps // note: normally it is expected that this has to be done after power flow calculations but for the sake - // of having it only once in the code we put this here. Otherwise it would have to been put before EVERY + // of having it only once in the code we put this here. Otherwise, it would have to be put before EVERY // return with a valid power flow result (currently happens already in two situations) val updatedGridAgentBaseData = if (stillPendingRequestAnswers.isEmpty) { @@ -955,13 +955,13 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { } } - /** Checks if all data has been received and if yes checks if the there are - * any failed power flow indications from inferior grids. If both == true, - * then no [[Behavior]] change is triggered but the sweep value store is - * updated with a [[FailedPowerFlow]] information as well, the now used data - * is set to [[PowerFlowDoneData]] and this is escalated to the superior - * grid(s). If there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a - * behavior transition to [[handlePowerFlowCalculations]] is triggered. + /** Checks if all data has been received and if yes checks if there are any + * failed power flow indications from inferior grids. If both == true, then + * no [[Behavior]] change is triggered but the sweep value store is updated + * with a [[FailedPowerFlow]] information as well, the now used data is set + * to [[PowerFlowDoneData]] and this is escalated to the superior grid(s). If + * there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a behavior + * transition to [[handlePowerFlowCalculations]] is triggered. * * If allReceived == false, no [[Behavior]] transition is triggered * @@ -1023,11 +1023,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { /** Normally only reached by the superior (dummy) agent! * - * Checks if all data has been received and if yes checks if the there are - * any failed power flow indications from inferior grids. If both == true, - * then a finish simulation is triggered and depending on the configuration - * this step is skipped and the simulation goes on or this leads to a - * termination of the simulation due to a failed power flow calculation. + * Checks if all data has been received and if yes checks if there are any + * failed power flow indications from inferior grids. If both == true, then a + * finish simulation is triggered and depending on the configuration this + * step is skipped and the simulation goes on or this leads to a termination + * of the simulation due to a failed power flow calculation. * * If there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a * [[Behavior]] transition to [[checkPowerDifferences]] is triggered. diff --git a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala index 20c0d201f9..0eaa7e30ba 100644 --- a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala +++ b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala @@ -314,8 +314,8 @@ case object ConfigFailFast extends LazyLogging { ) } - /** Check participants's basic runtime configurations, as well as in default - * as in individual configs. This comprises + /** Check participants' basic runtime configurations, as well as in default as + * in individual configs. This comprises * i.e. uuid and scaling factor */ private def checkBaseRuntimeConfigs( @@ -663,7 +663,7 @@ case object ConfigFailFast extends LazyLogging { } - /** Check the config sub tree for output parameterization + /** Check the config subtree for output parameterization * * @param subConfig * Output sub config tree for participants @@ -685,7 +685,7 @@ case object ConfigFailFast extends LazyLogging { checkIndividualOutputConfigs(subConfig.individualConfigs) } - /** Check the config sub tree for output parameterization + /** Check the config subtree for output parameterization * * @param subConfig * Output sub config tree for participants diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 5af1b68236..795c62c9f8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -31,7 +31,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala b/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala index 2088ca6cdc..e4b7758b8f 100644 --- a/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala +++ b/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala @@ -14,7 +14,7 @@ import squants.Quantity import scala.collection.SortedSet import scala.reflect.ClassTag -/** Describes a mapping of a x-y-pairs with possibility to interpolate the y +/** Describes a mapping of an x-y-pairs with possibility to interpolate the y * values based on the provided x value */ trait Characteristic[A <: Quantity[A], O <: Quantity[O]] { diff --git a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala index fedea75204..8cde5ab086 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala @@ -40,7 +40,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala index d73a2755bf..6f737a0d1b 100644 --- a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala +++ b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala @@ -98,7 +98,7 @@ object CollectionUtils { * smallest map key is provided. * * @param map - * containing containing the (k,v) pairs (e.g. x,y pairs) + * containing the (k,v) pairs (e.g. x,y pairs) * @param key * the key values are needed for * @return diff --git a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala index f32b66ed5f..a91ff99924 100644 --- a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala +++ b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala @@ -73,7 +73,7 @@ object ConfigUtil { * participants config for faster access. * * @param subConfig - * Configuration sub tree for the behaviour of system participants + * Configuration subtree for the behaviour of system participants * @return * a matching config utility */ @@ -124,7 +124,7 @@ object ConfigUtil { * @param defaultConfig * Default config to use, when there is no specific one * @param configs - * Mapping from notifier identifier to it's notifier configuration + * Mapping from notifier identifier to its notifier configuration */ final case class OutputConfigUtil( private val defaultConfig: NotifierConfig, From fb6fbfb0fa0b31dc36aac820818a3c43d224ce70 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:56:46 +0100 Subject: [PATCH 078/137] remove brackets --- src/main/scala/edu/ie3/simona/model/grid/LineModel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala index 60a2621630..f5b6dd9ca8 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala @@ -77,7 +77,7 @@ final case class LineModel( * branch conductance g_ij between node A and B of the element in p.u. */ override def gij(): squants.Dimensionless = - super.gij() * (amount) + super.gij() * amount /** see [[PiEquivalentCircuit.g0()]] * From 569c42829df9a1820316861b143273fdbbaa390b Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:36:14 +0100 Subject: [PATCH 079/137] add some hyphens --- docs/readthedocs/models/load_model.md | 2 +- .../edu/ie3/simona/agent/grid/PowerFlowSupport.scala | 2 +- .../ie3/simona/agent/participant/ParticipantAgent.scala | 2 +- .../agent/participant/ParticipantAgentFundamentals.scala | 6 +++--- .../agent/participant/load/LoadAgentFundamentals.scala | 4 ++-- src/main/scala/edu/ie3/simona/model/SystemComponent.scala | 2 +- src/main/scala/edu/ie3/simona/model/grid/LineModel.scala | 2 +- src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala | 2 +- .../scala/edu/ie3/simona/model/grid/SwitchModel.scala | 2 +- .../edu/ie3/simona/model/grid/Transformer3wModel.scala | 2 +- .../edu/ie3/simona/model/grid/TransformerModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/BMModel.scala | 4 ++-- .../ie3/simona/model/participant/FixedFeedInModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 2 +- .../ie3/simona/model/participant/SystemParticipant.scala | 2 +- .../scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- .../edu/ie3/simona/model/participant/evcs/EvcsModel.scala | 2 +- .../simona/model/participant/load/FixedLoadModel.scala | 2 +- .../model/participant/load/profile/LoadProfileStore.scala | 6 +++--- .../model/participant/load/profile/ProfileLoadModel.scala | 2 +- .../model/participant/load/profile/TypeDayProfile.scala | 4 ++-- .../model/participant/load/random/RandomLoadModel.scala | 2 +- .../participant/load/random/RandomLoadParamStore.scala | 4 ++-- .../model/participant/load/random/TypeDayParameters.scala | 8 ++++---- .../scala/edu/ie3/simona/model/thermal/ThermalHouse.scala | 2 +- .../scala/edu/ie3/simona/model/thermal/ThermalSink.scala | 2 +- .../edu/ie3/simona/model/thermal/ThermalStorage.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/Irradiance.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/Irradiation.scala | 2 +- .../simona/agent/participant/ParticipantAgentMock.scala | 2 +- .../model/participant/load/LoadProfileStoreSpec.scala | 8 ++++---- .../model/participant/load/RandomLoadModelSpec.scala | 2 +- 33 files changed, 47 insertions(+), 47 deletions(-) diff --git a/docs/readthedocs/models/load_model.md b/docs/readthedocs/models/load_model.md index be2046d717..798a8b5e97 100644 --- a/docs/readthedocs/models/load_model.md +++ b/docs/readthedocs/models/load_model.md @@ -132,7 +132,7 @@ F_t = -3.92 \cdot 10^{-10} \cdot t^4 + 3.2 \cdot 10^{-7} \cdot t + 1.24 $$ -The factor $F_t$, after calculation, shall be rounded to four decimal places. After multiplication with the profile value for given quarter hour, the result should again be rounded to one decimal place. +The factor $F_t$, after calculation, shall be rounded to four decimal places. After multiplication with the profile value for given quarter-hour, the result should again be rounded to one decimal place. #### Maximum value diff --git a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala index eae1369de4..8bfcef23da 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala @@ -369,7 +369,7 @@ trait PowerFlowSupport { * from a [[ValidNewtonRaphsonPFResult]] * * @param validResult - * the result that should be converted to a human readable debug string + * the result that should be converted to a human-readable debug string * @param gridModel * the grid model this result comes from * @return diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 52e3a53a59..5efc4f053d 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -835,7 +835,7 @@ abstract class ParticipantAgent[ )(implicit outputConfig: NotifierConfig): Unit /** Abstract definition to clean up agent value stores after power flow - * convergence. This is necessary for agents whose results are time dependent + * convergence. This is necessary for agents whose results are time-dependent * e.g. storage agents * * @param baseStateData 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 8cf02a9e09..c3459445fd 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -368,7 +368,7 @@ protected trait ParticipantAgentFundamentals[ operationStart: Long, operationEnd: Long, ): SortedSet[Long] = { - /* The profile load model holds values in the specified resolution (e.g. for each full quarter hour (00:00, + /* The profile load model holds values in the specified resolution (e.g. for each full quarter-hour (00:00, * 00:15, ...)). As the simulation might not start at an integer multiple of the resolution, we have to * determine, what the first tick is, in which profile information do exist */ val firstProfileTick = @@ -1244,7 +1244,7 @@ protected trait ParticipantAgentFundamentals[ nodalVoltage, lastNodalVoltage, ).getOrElse { - /* If a fast reply is not possible, determine it the old fashioned way */ + /* If a fast reply is not possible, determine it the old-fashioned way */ determineReply( requestTick, baseStateData, @@ -1851,7 +1851,7 @@ protected trait ParticipantAgentFundamentals[ } /** To clean up agent value stores after power flow convergence. This is - * necessary for agents whose results are time dependent e.g. storage agents + * necessary for agents whose results are time-dependent e.g. storage agents * * @param baseStateData * Basic state data diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 89079e33bf..0fc809d85a 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -147,8 +147,8 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ /* As participant agents always return their last known operation point on request, it is sufficient * to let a fixed load model determine it's operation point on: * 1) The first tick of the simulation - * 2) The tick, it turns on (in time dependent operation) - * 3) The tick, it turns off (in time dependent operation) + * 2) The tick, it turns on (in time-dependent operation) + * 3) The tick, it turns off (in time-dependent operation) * Coinciding ticks are summarized and the last tick is removed, as the change in operation status * doesn't affect anything then */ SortedSet[Long]( diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index 623e5a58c3..7408c8cbef 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -28,7 +28,7 @@ import scala.util.{Failure, Success, Try} * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala index f5b6dd9ca8..0a592ccb68 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala @@ -28,7 +28,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param nodeAUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala b/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala index 506ea804a1..af26beb12b 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala @@ -23,7 +23,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param isSlack diff --git a/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala b/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala index 5a5a457a5f..8a947e9ee0 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala @@ -22,7 +22,7 @@ import scala.util.{Failure, Success, Try} * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param nodeAUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala b/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala index 8f61c2a897..46ce7f3e44 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala @@ -49,7 +49,7 @@ import scala.math.BigDecimal.RoundingMode * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param hvNodeUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala index ee03ef837a..81682693fc 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala @@ -33,7 +33,7 @@ import scala.math.BigDecimal.RoundingMode * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param hvNodeUuid diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index 19fbe3e601..e1c9ed715a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -94,7 +94,7 @@ final case class BMModel( applyLoadGradient(pEl) } - /** Calculates first time dependent factor for heat demand + /** Calculates first time-dependent factor for heat demand * @param time * the time * @return @@ -114,7 +114,7 @@ final case class BMModel( } } - /** Calculates second time dependent factor for heat demand + /** Calculates second time-dependent factor for heat demand * @param time * the time * @return diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index dbda236e4c..d5cd82c731 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -29,7 +29,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index bf26b80fd8..993bc276c4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -34,7 +34,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala index 44c70539d7..f245923356 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala @@ -30,7 +30,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index bffdd7fdae..8a7eeefcb4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -41,7 +41,7 @@ import scala.collection.SortedSet * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index 674e35efd4..8f6d8dd5bc 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -47,7 +47,7 @@ import scala.collection.immutable.SortedSet * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param simulationStartDate diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala index d1ab4bd657..cc4bc82c65 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala @@ -28,7 +28,7 @@ import java.util.UUID * @param uuid * unique identifier * @param id - * human readable id + * human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index f1e7d54f62..63e4a0d4a5 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -45,7 +45,7 @@ class LoadProfileStore private (val reader: Reader) { ) /** Returns the load profiles entry (average power consumption for the - * following quarter hour) for given time and load profile. + * following quarter-hour) for given time and load profile. * * @param time * the requested time @@ -77,7 +77,7 @@ class LoadProfileStore private (val reader: Reader) { } } - /** Returns the maximum average power consumption per quarter hour for a given + /** Returns the maximum average power consumption per quarter-hour for a given * load profile, calculated over all seasons and weekday types of given load * profile * @@ -171,7 +171,7 @@ object LoadProfileStore extends LazyLogging { val headerKeys: util.List[String] = parser.getHeaderNames - // skip last column "quarter hour" + // skip last column "quarter-hour" (for (i <- Range(0, headerKeys.size() - 1)) yield { val headerKey = headerKeys.get(i) val profileKey = LoadProfileKey(headerKey) diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala index 5e919a0064..e94f50867f 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala @@ -25,7 +25,7 @@ import java.util.UUID * @param uuid * unique identifier * @param id - * human readable id + * human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala index dd2fcb6a18..22358772b1 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala @@ -26,8 +26,8 @@ final case class TypeDayProfile(private val values: Array[Double]) { "You may only instantiate type day parameters with 96 values." ) - /** Returns a value for given time. If time is not a 15 min step, it is - * rounded up to the next 15 min slice. + /** Returns a value for given time. If time is not a 15-min step, it is + * rounded up to the next 15-min slice. * * @param time * the time diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index a09e9bc8ff..4409d62cf2 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -33,7 +33,7 @@ import scala.util.Random * @param uuid * unique identifier * @param id - * human readable id + * human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala index 36635ae940..394732bc4c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala @@ -105,7 +105,7 @@ case object RandomLoadParamStore extends LazyLogging { } catch { case e: FileIOException => throw new FileIOException( - s"Cannot determine random load parameters for day type '$dayType' and quarter hour '$quartHour'", + s"Cannot determine random load parameters for day type '$dayType' and quarter-hour '$quartHour'", e, ) } @@ -115,7 +115,7 @@ case object RandomLoadParamStore extends LazyLogging { case (_, quarterHour, randomLoadParameters) => (quarterHour, randomLoadParameters) } // Group entries by day type - .map { // For each day type, sort the parameters by quarter hour and build a type day parameter object from it + .map { // For each day type, sort the parameters by quarter-hour and build a type day parameter object from it case (dayType, quarterHourToParameters) => dayType -> TypeDayParameters( quarterHourToParameters.sortBy(_._1).map(_._2).toArray diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala index 36360ff600..57210c68b2 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala @@ -12,8 +12,8 @@ import edu.ie3.simona.model.participant.load.DayType import edu.ie3.util.TimeUtil /** Stores a slice of random load parameters, that comprises a whole day (96 - * quarter hours). The data describes a typical day, that can unequivocally be - * identified by it's [[DayType]]. + * quarter-hours). The data describes a typical day, that can unequivocally be + * identified by its [[DayType]]. * * @param values * 96 quarter-hour values for this day type @@ -26,8 +26,8 @@ final case class TypeDayParameters( s"You may only instantiate type day parameters with 96 values. Apparent: ${values.length}." ) - /** Returns a value for given time. If time is not a 15 min step, it is - * rounded up to the next 15 min slice. + /** Returns a value for given time. If time is not a 15-min step, it is + * rounded up to the next 15-min slice. * * @param time * the time 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 71e992c4e0..ae933f3f03 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -37,7 +37,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala index 97661b0201..2b70983c73 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala @@ -17,7 +17,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalBusInput * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala index 5886a4e7f8..c7818351b6 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala @@ -19,7 +19,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index a18afc9ce9..78a5afeb14 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -37,7 +37,7 @@ trait SetupHelper extends LazyLogging { /** Build the [[GridAgentInitData]]. This also includes the determination of a * mapping from [[SubGridGate]] to [[ActorRef]] of the representing - * [[edu.ie3.simona.agent.grid.GridAgent]] as well as the look up of the + * [[edu.ie3.simona.agent.grid.GridAgent]] as well as the look-up of the * [[RefSystem]] to use being defined in the config. * * @param subGridContainer diff --git a/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala b/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala index 2ad522980e..7476cbe225 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala @@ -31,7 +31,7 @@ final class Irradiance private (val value: Double, val unit: IrradianceUnit) def *(that: Area): Power = Watts( this.toWattsPerSquareMeter * that.toSquareMeters ) - // the Hours(1).toSeconds is to convert watt hours to watt seconds which + // the Hours(1).toSeconds is to convert watt-hours to watt-seconds which // isn't a normal supported type in Squants def *(that: AreaTime): Energy = WattHours( this.toWattsPerSquareMeter * that.toSquareMeterSeconds / Hours(1).toSeconds diff --git a/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala b/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala index 5b685fde7e..306d2c11f5 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala @@ -22,7 +22,7 @@ final class Irradiation private (val value: Double, val unit: IrradiationUnit) def *(that: Area): Energy = WattHours( this.toWattHoursPerSquareMeter * that.toSquareMeters ) - // the Hours(1).toSeconds is to convert watt hours to watt seconds which + // the Hours(1).toSeconds is to convert watt-hours to watt-seconds which // isn't a normal supported type in Squants def /(that: Time): Irradiance = WattsPerSquareMeter( diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index 300bfb7e79..a3da7629ca 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -311,7 +311,7 @@ class ParticipantAgentMock( FixedRelevantData /** To clean up agent value stores after power flow convergence. This is - * necessary for agents whose results are time dependent e.g. storage agents + * necessary for agents whose results are time-dependent e.g. storage agents * @param baseStateData * Basic state data * @param currentTick diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala index 64701fa993..358da83a31 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala @@ -49,22 +49,22 @@ class LoadProfileStoreSpec "2019-04-01T05:00:00+02:00[Europe/Berlin]", L0, 55.6d, - ), // Weekday, transitional, 20th quarter hour + ), // Weekday, transitional, 20th quarter-hour ( "2019-06-02T00:00:00+02:00[Europe/Berlin]", G0, 68.8d, - ), // Sunday, summer, 0th quarter hour + ), // Sunday, summer, 0th quarter-hour ( "2019-01-05T02:15:00+01:00[Europe/Berlin]", H0, 52.8d, - ), // Saturday, winter, 9th quarter hour, 5th day -> dynamization factor 1.2473 + ), // Saturday, winter, 9th quarter-hour, 5th day -> dynamization factor 1.2473 ( "2019-07-21T01:00:00+02:00[Europe/Berlin]", H0, 58.1d, - ), // Sunday, summer, 4th quarter hour, 202nd day -> dynamization factor 0.7847 + ), // Sunday, summer, 4th quarter-hour, 202nd day -> dynamization factor 0.7847 ) forAll(params) { diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala index 82fa1041e5..08457fc4c8 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala @@ -112,7 +112,7 @@ class RandomLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { loadInput.getCosPhiRated, ActivePower(Watts(268.6)), ) - /* Working day, 61th quarter hour */ + /* Working day, 61st quarter-hour */ val queryDate = TimeUtil.withDefaults.toZonedDateTime("2019-07-19T15:21:00Z") val expectedParams = new RandomLoadParameters( From 548bcb2d4ea93d40a16bd75e6dc7e885df79152c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:45:12 +0100 Subject: [PATCH 080/137] provide a second dot for all e.g. --- src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala | 2 +- .../edu/ie3/simona/agent/participant/ParticipantAgent.scala | 4 ++-- .../agent/participant/ParticipantAgentFundamentals.scala | 4 ++-- .../simona/agent/participant/evcs/EvcsAgentFundamentals.scala | 2 +- .../fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/load/LoadAgentFundamentals.scala | 2 +- .../ie3/simona/agent/participant/pv/PvAgentFundamentals.scala | 2 +- .../simona/agent/participant/wec/WecAgentFundamentals.scala | 2 +- .../ie3/simona/agent/participant/ParticipantAgentMock.scala | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala index f02d7c36b1..c9bca30ce1 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala @@ -57,7 +57,7 @@ object GridAgent extends DBFSAlgorithm { // val initialization val resolution: Long = simonaConfig.simona.powerflow.resolution.get( ChronoUnit.SECONDS - ) // this determines the agents regular time bin it wants to be triggered e.g one hour + ) // this determines the agents regular time bin it wants to be triggered e.g. one hour val simStartTime: ZonedDateTime = TimeUtil.withDefaults .toZonedDateTime(simonaConfig.simona.time.startDateTime) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 5efc4f053d..3506510ff7 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -493,7 +493,7 @@ abstract class ParticipantAgent[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different @@ -533,7 +533,7 @@ abstract class ParticipantAgent[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different 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 c3459445fd..1a4c474099 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -157,7 +157,7 @@ protected trait ParticipantAgentFundamentals[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different @@ -244,7 +244,7 @@ protected trait ParticipantAgentFundamentals[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala index 69b072e55b..8894a511ff 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala @@ -96,7 +96,7 @@ protected trait EvcsAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index 5d3a2d6805..d5ace59150 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -92,7 +92,7 @@ protected trait FixedFeedInAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 0fc809d85a..405a76e6e6 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -103,7 +103,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index ce152a3d7e..b3b96970b6 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -94,7 +94,7 @@ protected trait PvAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala index 9edf6f2ae8..5b43263925 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala @@ -89,7 +89,7 @@ protected trait WecAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index a3da7629ca..8087993f01 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -175,7 +175,7 @@ class ParticipantAgentMock( * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different From 8b5e4bf5ff57810f1b59123407db93f19e55f2fe Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:51:51 +0100 Subject: [PATCH 081/137] adding some commas --- docs/readthedocs/models/two_winding_transformer_model.md | 2 +- src/main/scala/edu/ie3/simona/agent/ValueStore.scala | 2 +- src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala | 2 +- .../scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala | 2 +- .../edu/ie3/simona/agent/participant/ParticipantAgent.scala | 2 +- .../agent/participant/ParticipantAgentFundamentals.scala | 4 ++-- .../scala/edu/ie3/simona/io/result/plain/PlainResult.scala | 4 ++-- src/main/scala/edu/ie3/simona/model/grid/GridModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/StorageModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- .../edu/ie3/simona/model/participant/control/QControl.scala | 2 +- .../scala/edu/ie3/simona/service/weather/WeatherService.scala | 4 ++-- .../scala/edu/ie3/simona/service/weather/WeatherSource.scala | 2 +- src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- src/main/scala/edu/ie3/util/scala/ReflectionTools.scala | 2 +- .../edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala | 2 +- .../edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala | 4 ++-- .../ie3/simona/integration/common/IntegrationSpecCommon.scala | 2 +- .../edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/readthedocs/models/two_winding_transformer_model.md b/docs/readthedocs/models/two_winding_transformer_model.md index eac989c18d..768785aaaf 100644 --- a/docs/readthedocs/models/two_winding_transformer_model.md +++ b/docs/readthedocs/models/two_winding_transformer_model.md @@ -32,7 +32,7 @@ When the load flow calculation asks for the values with regard to the low voltag 3. Main field resistance: $R_{M,LV} = \frac{R_{M}}{\gamma^{2}}$ 4. Main field reactance: $X_{M,LV} = \frac{X_{M}}{\gamma^{2}}$ -Finally all values are delivered as per unit-values and ready to use in the fundamental $\pi$circuit: +Finally, all values are delivered as per unit-values and ready to use in the fundamental $\pi$circuit: 1. Short circuit conductance: $g_{ij} = \frac{Z_{Ref}}{R_{SC}}$ 2. Short circuit susceptance: $b_{ij} = \frac{Z_{Ref}}{X_{SC}}$ diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index a21f7d0f58..a1a1190861 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -129,7 +129,7 @@ object ValueStore { def forResult[D](maxTickSpan: Long, multiplier: Long): ValueStore[D] = new ValueStore[D](maxTickSpan * multiplier) - /** Updates the value store. Additionally the size of the store is limited to + /** Updates the value store. Additionally, the size of the store is limited to * it's defined maximum capacity. Therefore, the oldest entries are removed. * * @param valueStore diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala index 9cd9070de8..cb8a73294d 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala @@ -260,7 +260,7 @@ object EmDataCore { awaitedConnectedAgents.excl(flexOptions.modelUuid), ) - /** Checks whether all awaited flex options have been received and we can + /** Checks whether all awaited flex options have been received, and we can * continue by calculating flex control. This method does not change the * state of the [[AwaitingFlexOptions]] data core. * @return diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index 0a97764f73..87aa1d8440 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -496,7 +496,7 @@ private[grid] trait GridResultsSupport { /** Calculate the current magnitude and the current angle in physical units * based on a provided electric current in p.u. and the nominal referenced * electric current. The arctangent "only" calculates the angle between the - * complex current and it's real part. This means, that i = (i_real, i_imag) + * complex current, and it's real part. This means, that i = (i_real, i_imag) * and i' = (-i_real, -i_imag) will lead to the same angle. However, for * power system simulation, the absolute orientation in the complex plane * with regard to the positive real axis is of interest. Therefore, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 3506510ff7..63784a277f 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -149,7 +149,7 @@ abstract class ParticipantAgent[ Activation(tick), modelBaseStateData: ParticipantModelBaseStateData[PD, CD, MS, M], ) if modelBaseStateData.services.isEmpty => - /* An activity start trigger is sent and no data is awaited (neither secondary nor primary). Therefore go straight + /* An activity start trigger is sent and no data is awaited (neither secondary nor primary). Therefore, go straight * ahead to calculations */ /* Hold tick, as state transition is needed */ 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 1a4c474099..40d510f13f 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -1070,7 +1070,7 @@ protected trait ParticipantAgentFundamentals[ false } - // If we're completing initialization and we're EM-managed: + // If we're completing initialization, and we're EM-managed: // There is no new tick for the scheduler, // since we are activated by the EmAgent from now on scheduler ! Completion( @@ -1475,7 +1475,7 @@ protected trait ParticipantAgentFundamentals[ determineTickWindow(requestTick, requestValueStore) /* All participants simulation results between the most recent simulation tick BEFORE or at the beginning of the - * averaging window and it's end (both including) are relevant for averaging the simulated primary data */ + * averaging window, and it's end (both including) are relevant for averaging the simulated primary data */ val firstRelevantTick = determineFirstRelevantTick( averagingWindowStart, resultValueStore, diff --git a/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala b/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala index c85cd167af..4a9e9a4c8d 100644 --- a/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala +++ b/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala @@ -10,8 +10,8 @@ import java.util.UUID /** Results that are sent out with Kafka and avro should use this trait and * corresponding implementing classes, since these give more control over - * attribute types and naming and they include sim run id. Plain result objects - * can be created by [[PlainWriter]]. + * attribute types and naming, and they include sim run id. Plain result + * objects can be created by [[PlainWriter]]. */ sealed trait PlainResult diff --git a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala index af90cfc344..ea60caa44d 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala @@ -194,7 +194,7 @@ object GridModel { /* Nodes that are connected via a [closed] switch map to the same idx as we fuse them during the power flow. - Therefore the admittance matrix has to be of the size of the distinct node idxs. + Therefore, the admittance matrix has to be of the size of the distinct node idxs. */ val linesAdmittanceMatrix = buildAssetAdmittanceMatrix( nodeUuidToIndexMap, diff --git a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala index 02f82d2670..336eef1979 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala @@ -52,7 +52,7 @@ final case class StorageModel( /** Tolerance for power comparisons. With very small (dis-)charging powers, * problems can occur when calculating the future tick at which storage is * full or empty. For sufficiently large time frames, the maximum Long value - * ([[Long.MaxValue]]) can be exceeded, thus the Long value overflows and we + * ([[Long.MaxValue]]) can be exceeded, thus the Long value overflows, and we * get undefined behavior. * * Thus, small (dis-)charging powers compared to storage capacity have to be diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index 8a7eeefcb4..4ecc4e5b5b 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -146,7 +146,7 @@ final case class WecModel( ) } - /** The coefficient is dependent on the wind velocity v. Therefore use v to + /** The coefficient is dependent on the wind velocity v. Therefore, use v to * determine the betz coefficient cₚ. * * @param windVelocity diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index 25504c2fff..391d4bca7c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -50,7 +50,7 @@ sealed trait QControl { ): Power => ReactivePower } -/** Object to create a [[QControl]]. Currently the following QControls +/** Object to create a [[QControl]]. Currently, the following QControls * characteristics are supported. * - cosine-Phi-Fixed * - cosine-Phi(P) diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala index a75b0c38fd..0f8039d30d 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala @@ -269,7 +269,7 @@ final case class WeatherService( serviceStateData case _ => - // actor is not registered and we don't have data for it + // actor is not registered, and we don't have data for it // inform the agentToBeRegistered that the registration failed as we don't have data for it agentToBeRegistered ! RegistrationFailedMessage(self) serviceStateData @@ -303,7 +303,7 @@ final case class WeatherService( // get the weather and send it to the subscribed agents // no sanity check needed here as we can assume that we always have weather available - // when we announce it. Otherwise the registration would have failed already! + // when we announce it. Otherwise, the registration would have failed already! updatedStateData.weatherSource .getWeather(tick, updatedStateData.weightedWeatherCoordinates) .foreach { case coordinate -> weatherResult => diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala index 12a26c3f6c..30ef9e8ed4 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala @@ -165,7 +165,7 @@ trait WeatherSource { val weightMap = nearestCoordinates .map(coordinateDistance => { /* Maybe some words on the calculus of the weight here: We intend to have a weight, that linear increases - * from zero to one, the closer the coordinate is to the coordinate in question. Therefore we calculate the + * from zero to one, the closer the coordinate is to the coordinate in question. Therefore, we calculate the * proximity of each node as a linear function between 1 at 0m distance to the questioned coordinate to zero * at the sum of all coordinates' distances (1 - d / d_sum). However, summing up this proximity over all * n coordinates brings n*1 from the left part of the sum and -1 as the sum of all distances shares. diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index d9f1b7e7c4..e90fa8975d 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -28,7 +28,7 @@ import scala.jdk.OptionConverters.RichOptional /** Represents the output directory where the results will be materialized. If * new directories are added please remember to add them to the dirsToBeCreated - * Vector if they should be created. Otherwise they will not be created! + * Vector if they should be created. Otherwise, they will not be created! * * @version 0.1 * @since 12.01.20 diff --git a/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala b/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala index 6ed62dc580..be6df1b955 100644 --- a/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala +++ b/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala @@ -47,7 +47,7 @@ object ReflectionTools { * @tparam A * type of the object * @return - * a map containing the field method and it's value of the object instance + * a map containing the field method, and it's value of the object instance */ def classFieldToVal[A](a: A)(implicit tt: TypeTag[A], diff --git a/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala b/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala index e63ec421f5..82ed0b58bc 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala @@ -45,7 +45,7 @@ final class SpecificHeatCapacity private ( ) /** Calculates the Energy of a medium with a given specific heat capacity - * based on the temperature delta and it's volume. + * based on the temperature delta, and it's volume. * @param temperatureA * First temperature of the medium (e.g. inlet temperature) * @param temperatureB diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index 4da922de62..861d35a6a7 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -41,8 +41,8 @@ import scala.language.postfixOps * be able to do if the DBFSAlgorithm is used. The scheduler, the weather * service as well as the inferior and superior [[GridAgent]] s are simulated * by the TestKit. By now this test does NOT cover interactions with generation - * or load asset agents due to unavailability during test development. Hence it - * would make sense to extend this test in the future to include asset agent + * or load asset agents due to unavailability during test development. Hence, + * it would make sense to extend this test in the future to include asset agent * interaction or cover this behaviour by another (integration) test! */ class DBFSAlgorithmCenGridSpec diff --git a/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala b/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala index eeb0804f77..f98abfd663 100644 --- a/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala +++ b/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala @@ -10,7 +10,7 @@ trait IntegrationSpecCommon { /* ATTENTION: Do not change this file to a path within "input". If you come to this point because the CI * or some of your tests are failing you very likely have altered the vn_simona.conf. This config although - * is NOT meant to be altered. Instead you should always use a delta config and only override the values and + * is NOT meant to be altered. Instead, you should always use a delta config and only override the values and * files of vn_simona/vn_simona.conf. Delta configs can be created by including the config you want to change * parameters from via include (e.g. include "input/samples/vn_simona/vn_simona.conf") at the * beginning of your config file and then just override the parameters you want to change! */ diff --git a/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala b/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala index 4a4834fff9..2a90b1432d 100644 --- a/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala @@ -43,7 +43,7 @@ class ProportionalFlexStratSpec * * Specifically, we use 40% of the flex potential 2 kW - 1 kW = 1 kW of * the first unit and 40% of the flex potential 4 kW - 0 kW = 4 kW of the - * second unit. Thus we arrive at 1 kW + 40% * 1 kW = 1.4 kW for the + * second unit. Thus, we arrive at 1 kW + 40% * 1 kW = 1.4 kW for the * first unit and 0 kW + 40% * 4 kW = 1.6 kW for the second unit. */ From ef28095779d2e7257fca64f18c661ae6cd0885c1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:58:05 +0100 Subject: [PATCH 082/137] grammar fix it's to its --- docs/readthedocs/models/hp_model.md | 2 +- src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala | 2 +- .../participant/fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/load/LoadAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/event/Event.scala | 2 +- .../edu/ie3/simona/model/grid/TransformerTappingModel.scala | 2 +- .../edu/ie3/simona/service/primary/PrimaryServiceProxy.scala | 2 +- .../scala/edu/ie3/simona/service/weather/WeatherSource.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala | 2 +- .../ie3/simona/test/common/model/grid/SubGridGateMokka.scala | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/readthedocs/models/hp_model.md b/docs/readthedocs/models/hp_model.md index 0458fffbac..d0153e7395 100644 --- a/docs/readthedocs/models/hp_model.md +++ b/docs/readthedocs/models/hp_model.md @@ -17,6 +17,6 @@ Please refer to {doc}`PowerSystemDataModel - HP Model /* As participant agents always return their last known operation point on request, it is sufficient - * to let a fixed load model determine it's operation point on: + * to let a fixed load model determine its operation point on: * 1) The first tick of the simulation * 2) The tick, it turns on (in time-dependent operation) * 3) The tick, it turns off (in time-dependent operation) diff --git a/src/main/scala/edu/ie3/simona/event/Event.scala b/src/main/scala/edu/ie3/simona/event/Event.scala index 2efb82b76e..dad24a314f 100644 --- a/src/main/scala/edu/ie3/simona/event/Event.scala +++ b/src/main/scala/edu/ie3/simona/event/Event.scala @@ -7,7 +7,7 @@ package edu.ie3.simona.event /** Trait that should be mixed into each event in [[edu.ie3.simona.event]] to - * provide an easy access to it's name + * provide easy access to its name */ trait Event { diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala index 602259cec2..a8534d7b7b 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala @@ -114,7 +114,7 @@ final case class TransformerTappingModel( * inverted. * * Furthermore, this method also considers the transformer not being able to - * change it's tap position anymore. Hence, 0 is returned, if no change is + * change its tap position anymore. Hence, 0 is returned, if no change is * possible anymore. * * @param vChangeRequest diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala index ca41a11234..478226755f 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala @@ -126,7 +126,7 @@ case class PrimaryServiceProxy( } /** Prepare the needed state data by building a - * [[edu.ie3.datamodel.io.source.TimeSeriesMappingSource]], obtain it's + * [[edu.ie3.datamodel.io.source.TimeSeriesMappingSource]], obtain its * information and compile them to state data * * @param primaryConfig diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala index 30ef9e8ed4..8cf874a885 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala @@ -424,7 +424,7 @@ object WeatherSource { * coordinates * * @param weighting - * Mapping from weather coordinate to it's weight in averaging + * Mapping from weather coordinate to its weight in averaging */ private[weather] final case class WeightedCoordinates( weighting: Map[Point, Double] diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 78a5afeb14..b7805219ce 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -46,7 +46,7 @@ trait SetupHelper extends LazyLogging { * Mapping from sub grid number to [[edu.ie3.simona.agent.grid.GridAgent]] * 's [[ActorRef]] * @param gridGates - * [[Set]] of all [[SubGridGate]] s connecting this sub grid with it's + * [[Set]] of all [[SubGridGate]] s connecting this sub grid with its * ancestors and children * @param configRefSystems * Collection of reference systems defined in config diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala b/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala index 238668e67a..137e24a2ce 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala @@ -8,7 +8,7 @@ package edu.ie3.util.scala.quantities import tech.units.indriya.function.DefaultNumberSystem -/** This number system simply delegates the method calls to it's parent class. +/** This number system simply delegates the method calls to its parent class. * The only difference is, that [[BigDecimal]] is transferred to * [[java.math.BigDecimal]] and back upon necessity. Due to its functionality * as an extension of the [[DefaultNumberSystem]] it CANNOT be an object! diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala index 6cf1b682d4..a5fc6ffb82 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala @@ -21,7 +21,7 @@ import org.scalatestplus.mockito.MockitoSugar */ trait SubGridGateMokka extends MockitoSugar { - /** Mocks a node with it's basic needed information + /** Mocks a node with its basic needed information * * @param uuid * Unique identifier of the node From 7df7e8b5f92799a12742702facfa9136c7effb26 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:05:57 +0100 Subject: [PATCH 083/137] grammar, spelling, typos, wording etc. --- docs/readthedocs/developersguide.md | 2 +- docs/readthedocs/models/em.md | 2 +- docs/readthedocs/models/hp_model.md | 2 +- docs/readthedocs/usersguide.md | 2 +- .../ie3/simona/actor/SimonaActorNaming.scala | 2 +- .../agent/grid/GridAgentController.scala | 2 +- .../simona/agent/grid/PowerFlowSupport.scala | 2 +- .../agent/participant/ParticipantAgent.scala | 6 +++--- .../ParticipantAgentFundamentals.scala | 21 ++++++++++--------- .../edu/ie3/simona/event/RuntimeEvent.scala | 2 +- .../exceptions/WeatherServiceException.scala | 2 +- .../ie3/simona/model/SystemComponent.scala | 2 +- .../model/em/PrioritizedFlexStrat.scala | 4 ++-- .../edu/ie3/simona/model/grid/GridModel.scala | 4 ++-- .../edu/ie3/simona/model/grid/RefSystem.scala | 2 +- .../model/grid/TransformerTapping.scala | 2 +- .../model/participant/evcs/EvcsModel.scala | 4 ++-- .../ie3/simona/service/SimonaService.scala | 2 +- .../service/primary/PrimaryServiceProxy.scala | 2 +- .../service/weather/SampleWeatherSource.scala | 2 +- .../ie3/simona/sim/setup/SimonaSetup.scala | 4 ++-- .../ie3/simona/util/ParsableEnumeration.scala | 2 +- .../util/scala/quantities/QuantityUtil.scala | 5 ++--- .../agent/grid/DBFSAlgorithmCenGridSpec.scala | 6 +++--- .../DBFSAlgorithmFailedPowerFlowSpec.scala | 8 +++---- .../RuntimeEventListenerLoggingSpec.scala | 2 +- .../model/participant/StorageModelSpec.scala | 2 +- .../common/model/grid/SubGridGateMokka.scala | 2 +- 28 files changed, 50 insertions(+), 50 deletions(-) diff --git a/docs/readthedocs/developersguide.md b/docs/readthedocs/developersguide.md index ace59e05e6..a246fc106a 100644 --- a/docs/readthedocs/developersguide.md +++ b/docs/readthedocs/developersguide.md @@ -2,7 +2,7 @@ # Developer’s Guide -The SIMONA repository can be found [on Github](https://github.com/ie3-institute/simona). +The SIMONA repository can be found [on GitHub](https://github.com/ie3-institute/simona). ```{contents} --- diff --git a/docs/readthedocs/models/em.md b/docs/readthedocs/models/em.md index ae10cb3ac2..ea7261d4f8 100644 --- a/docs/readthedocs/models/em.md +++ b/docs/readthedocs/models/em.md @@ -16,7 +16,7 @@ If an EmAgent is itself controlled by another EmAgent, it also behaves like a sy Every EmAgent aggregates flex options and power of its connected assets and disaggregates flex control among the connected assets. It also functions as a scheduler for all connected assets by processing information on the ticks of the next desired activations and conveying such information to the controlling EmAgent or a central scheduler respectively. -Uncontrolled EmAgents answer to a scheduler with regards to their activation. +Uncontrolled EmAgents answer to a scheduler with regard to their activation. ![](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/ie3-institute/simona/dev/docs/uml/protocol/em/UncontrolledEm.puml) diff --git a/docs/readthedocs/models/hp_model.md b/docs/readthedocs/models/hp_model.md index d0153e7395..8070e36f36 100644 --- a/docs/readthedocs/models/hp_model.md +++ b/docs/readthedocs/models/hp_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the Heat Pump Model (HP model) availabl ## Assumptions -The HP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the HP unit does not posses a memory. +The HP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the HP unit does not possess a memory. ## Parameters diff --git a/docs/readthedocs/usersguide.md b/docs/readthedocs/usersguide.md index 5b75b15ac7..ea6a9babf1 100644 --- a/docs/readthedocs/usersguide.md +++ b/docs/readthedocs/usersguide.md @@ -37,7 +37,7 @@ You can either delegate the job to your preferred IDE or build an executable jar In order to be able to execute SIMONA from a CLI, you need an executable fat jar. A fat jar contains all compiled classes and dependencies, ready for execution. For building one, you can use a Gradle task of the project. 1. Open a CLI and change directories to the top level directory of the project. -2. Execute ``gradlew shadowJar`` within the CLI. This creates a fat jar of SIMONA inside of the directory ``build/libs``. +2. Execute ``gradlew shadowJar`` within the CLI. This creates a fat jar of SIMONA inside the directory ``build/libs``. 3. For executing a fat jar you need to specify the classpath of the entrypoint of your application. Assuming we are still in the top level directory of our project, the execution command would look as follows: diff --git a/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala b/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala index fed8f600f3..2b0c62e780 100644 --- a/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala +++ b/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala @@ -21,7 +21,7 @@ object SimonaActorNaming { refFactory.actorOf(props, actorName(props, simonaActorId(actorId))) } - /** Constructs an Id for convenience actor naming. Although this is dangerous + /** Constructs an id for convenience actor naming. Although this is dangerous * as duplicates might be possible, it should be sufficient in our case as * the uniqueness is only required in one actor system * diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala index f2e78f7c53..ad0d6c3b07 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala @@ -158,7 +158,7 @@ class GridAgentController( /** Go through all provided input models, build agents for those and group the * resulting actor references for each connection nodes. All participant * agents are also introduced to the agent environment and the scheduler is - * requested to send a initialisation trigger. + * requested to send an initialisation trigger. * * @param participantsConfig * Configuration information for participant models diff --git a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala index 8bfcef23da..c43700466c 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala @@ -203,7 +203,7 @@ trait PowerFlowSupport { * p/q values from the provided sweepDataValues and combines them with * updated receivedSlackValues. Normally used in a forward sweep phase of * [[DBFSAlgorithm]] as in this state only voltages are updated and a power - * flow with new voltages but old p/q values is executed afterwards + * flow with new voltages but old p/q values is executed afterward. * * @param receivedSlackValues * new slack voltages provided by the superior grid diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 63784a277f..19eff90211 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -448,8 +448,8 @@ abstract class ParticipantAgent[ case _ => participantStateData.receivedSecondaryDataStore } - /* At least parts of the needed data has been received or it is an additional activation, that has been triggered. - * Anyways, the calculation routine has also to take care of filling up missing data. */ + /* At least parts of the needed data has been received, or it is an additional activation, that has been triggered. + * Anyway, the calculation routine has also to take care of filling up missing data. */ val lastModelState = getLastOrInitialStateData(participantStateData, currentTick) calculatePowerWithSecondaryDataAndGoToIdle( @@ -656,7 +656,7 @@ abstract class ParticipantAgent[ * the agent is meant to replay external primary data: Announce result, add * content to result value store, go to [[Idle]] and answer the scheduler, * that the activity start trigger is fulfilled. 2.2) All secondary data is - * there, go to [[Calculate]] and ask the scheduler to trigger ourself for + * there, go to [[Calculate]] and ask the scheduler to trigger ourselves for * starting the model based calculation 3) Everything is at place and the * [[Activation]] has NOT yet been sent: Stay here and wait * 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 40d510f13f..586947b839 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -388,7 +388,7 @@ protected trait ParticipantAgentFundamentals[ /** Assume we have information, that are available in a fixed resolution after * each full hour (including the full hour), then we have to determine, at - * what first tick those information are available. + * what first tick this information are available. * * @param simulationStartDate * Beginning of the simulation @@ -515,7 +515,7 @@ protected trait ParticipantAgentFundamentals[ val foreseenDataTicks = baseStateData.foreseenDataTicks + (msg.serviceRef -> msg.nextDataTick) - /* Go over to handling these information */ + /* Go over to handling this information */ val nextStateData = DataCollectionStateData( BaseStateData.updateBaseStateData( baseStateData, @@ -538,8 +538,9 @@ protected trait ParticipantAgentFundamentals[ * Announce result, add content to result value store, go to [[Idle]] and * answer the scheduler, that the activity start trigger is fulfilled. 2.2) * All secondary data is there, go to [[Calculate]] and ask the scheduler to - * trigger ourself for starting the model based calculation 3) Everything is - * at place and the [[Activation]] has NOT yet been sent: Stay here and wait + * trigger ourselves for starting the model based calculation 3) Everything + * is at place and the [[Activation]] has NOT yet been sent: Stay here and + * wait * * @param stateData * Apparent state data @@ -645,7 +646,7 @@ protected trait ParticipantAgentFundamentals[ ) } } else { - /* We sill have to wait - either for data or activation */ + /* We still have to wait - either for data or activation */ stay() using stateData } } @@ -1141,7 +1142,7 @@ protected trait ParticipantAgentFundamentals[ baseStateData, ) case (Some(additionalTick), _) => - /* The next activation is additional (either there is no foreseen data tick or it is after the additional tick. + /* The next activation is additional (either there is no foreseen data tick or it is after the additional tick). * Remove the tick from the list of additional activation ticks. */ val upcomingActivationTicks = baseStateData.additionalActivationTicks.rangeFrom(additionalTick + 1) @@ -1159,7 +1160,7 @@ protected trait ParticipantAgentFundamentals[ updatedBaseStateData, ) case (None, None) => - /* We don't know nothing about either additional activation nor new incoming data */ + /* We don't know anything about either additional activation nor new incoming data */ (None, baseStateData) } } @@ -1258,7 +1259,7 @@ protected trait ParticipantAgentFundamentals[ } /** Checks, if a fast reply is possible, when the very same request (in terms - * of tick and nodal voltage) already has been answered. Then a Option on + * of tick and nodal voltage) already has been answered. Then an Option on * stay in the same state with sending an [[AssetPowerUnchangedMessage]] is * given back. If a fast reply is not possible, [[None]] is given back. * Additionally, the listener are informed about the result. @@ -1292,7 +1293,7 @@ protected trait ParticipantAgentFundamentals[ case Some((mostRecentRequestTick, latestProvidedValues)) if mostRecentRequestTick == requestTick => /* A request for this tick has already been answered. Check, if it has been the same request. - * if it has been the same request we wanna answer with the same values afterwards, this data MUST always + * if it has been the same request we want to answer with the same values afterwards, this data MUST always * be available when we already provided data for this tick */ baseStateData match { case externalBaseStateData: FromOutsideBaseStateData[M, PD] => @@ -1753,7 +1754,7 @@ protected trait ParticipantAgentFundamentals[ * @param tick * Tick, the result belongs to * @param result - * The result to build a event for + * The result to build an event for * @param outputConfig * Configuration of the output behaviour */ diff --git a/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala b/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala index da02b9c258..44d092ea0f 100644 --- a/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala @@ -21,7 +21,7 @@ object RuntimeEvent { /** Indicates that the scheduler has finished a pre-defined advancement in * ticks and is ready to carry out the next task. In contrast to the * [[CheckWindowPassed]] event, whenever a [[Ready]] event is scheduled, the - * scheduled of [[edu.ie3.simona.scheduler.Scheduler]] will be stopped and + * schedule of [[edu.ie3.simona.scheduler.Scheduler]] will be stopped and * further commands are necessary to continue the schedule. * * @param tick diff --git a/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala b/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala index 08d109a2a6..b1291f6694 100644 --- a/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala +++ b/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala @@ -45,7 +45,7 @@ object WeatherServiceException { private val cause: Throwable = None.orNull, ) extends WeatherServiceException(msg, cause) - /** Exception to be thrown if the registration of the an agent fails + /** Exception to be thrown if the registration of an agent fails * @param msg * Message to prompt to the end user * @param cause diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index 7408c8cbef..efc70ba0cf 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -40,7 +40,7 @@ abstract class SystemComponent( private val elementType: String = this.getClass.getSimpleName - // check if a uuid is provided + // check if an uuid is provided if (Option.apply(uuid).isEmpty) throw new InvalidParameterException( s"Uuid of $elementType $id cannot be null!" diff --git a/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala b/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala index 98162db86c..3d934e21f3 100644 --- a/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala +++ b/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala @@ -122,7 +122,7 @@ final case class PrioritizedFlexStrat(curtailRegenerative: Boolean) (issueCtrlMsgs, Some(remainingExcessPower)) } else if (remainingExcessPower < flexPotential) { // we cannot cover the excess feed-in with just this flexibility, - // thus use all of the available flexibility and continue + // thus use all the available flexibility and continue ( issueCtrlMsgs :+ (inputModel.getUuid, flexOption.max), Some(remainingExcessPower - flexPotential), @@ -171,7 +171,7 @@ final case class PrioritizedFlexStrat(curtailRegenerative: Boolean) (issueCtrlMsgs, Some(remainingExcessPower)) } else if (remainingExcessPower > flexPotential) { // we cannot cover the excess load with just this flexibility, - // thus use all of the available flexibility and continue + // thus use all the available flexibility and continue ( issueCtrlMsgs :+ (inputModel.getUuid, flexOption.min), Some(remainingExcessPower - flexPotential), diff --git a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala index ea60caa44d..16285b9317 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala @@ -332,7 +332,7 @@ object GridModel { } /** This checks whether the provided grid model graph is connected, that means - * if every node can be reached from every other node trough a sequence of + * if every node can be reached from every other node through a sequence of * edges. Also checks for referenced nodes that are missing. This check * considers the state (enabled/disabled) of the elements. * @@ -605,7 +605,7 @@ object GridModel { /** Check and validates the grid. Especially the consistency of the grid * model the connectivity of the grid model if there is InitData for - * superior or inferior GridGates if there exits voltage measurements for + * superior or inferior GridGates if there exists voltage measurements for * transformerControlGroups */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala b/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala index 40319e699a..d9a6090601 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala @@ -153,7 +153,7 @@ final case class RefSystem private ( /** Converts a provided voltage value from physical SI value into p.u. value * * @param vInSi - * real or imaginary part of a unreferenced physical SI value + * real or imaginary part of an unreferenced physical SI value * @return * referenced voltage value in p.u. */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala index 2806aa159d..d199923de8 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala @@ -17,7 +17,7 @@ import tech.units.indriya.quantity.Quantities * necessary to override updateTapPos (e.g. in [[Transformer3wModel]]). The * provided [[TransformerTappingModel]] *should* be protected and not be * accessible from outside to prevent direct access to internal functions! - * Instead all the functions provided here should be used for tap position + * Instead, all the functions provided here should be used for tap position * manipulation. */ trait TransformerTapping { diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index 8f6d8dd5bc..0588f7abee 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -194,7 +194,7 @@ final case class EvcsModel( state.evs } - /** Charge the given EV under consideration a applicable schedule + /** Charge the given EV under consideration an applicable schedule * * @param ev * Electric vehicle to charge @@ -271,7 +271,7 @@ final case class EvcsModel( /* Filter for entries, that end after the last schedule application and that start before the current tick. Entries that end at lastTick are not included because schedule - intervals are open at the right hand side. + intervals are open on the right hand side. Entries that start at currentTick are not included because these will be calculated with the next state. */ diff --git a/src/main/scala/edu/ie3/simona/service/SimonaService.scala b/src/main/scala/edu/ie3/simona/service/SimonaService.scala index 1b41b30400..75a1813f0a 100644 --- a/src/main/scala/edu/ie3/simona/service/SimonaService.scala +++ b/src/main/scala/edu/ie3/simona/service/SimonaService.scala @@ -30,7 +30,7 @@ object SimonaService { /** Service initialization data can sometimes only be constructed once the * service actor is created (e.g. - * [[edu.ie3.simona.service.ev.ExtEvDataService]]. Thus, we need an extra + * [[edu.ie3.simona.service.ev.ExtEvDataService]]). Thus, we need an extra * initialization message. */ final case class Create[+I <: InitializeServiceStateData]( diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala index 478226755f..838608a514 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala @@ -269,7 +269,7 @@ case class PrimaryServiceProxy( unhandled(x) } - /** Handle the registration request for a covered model. First, try to get a + /** Handle the registration request for a covered model. First, try to get an * already existing worker for this time series, otherwise spin-off a new * one, remember it and forward the request * diff --git a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala index 9225f4b340..0db3ded44c 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala @@ -183,7 +183,7 @@ object SampleWeatherSource { } } - // these lists contain the hourly weather values for each first of the month of 2011 + january of + // these lists contain the hourly weather values for each first of the month of 2011 + january // 2012 at coordinate id 213089 private val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 1.18179e-12, 4.42315e-11, 0.0585938, 1.94141, 15.1172, 74.8438, 89.0469, diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index 9c6effa859..edcd0ffe2f 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -24,8 +24,8 @@ import org.apache.pekko.actor.{ActorRef => ClassicRef} /** Trait that can be used to setup a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending - * [[SimonaStandaloneSetup]] might be considered instead of providing a your - * own implementation for all methods. + * [[SimonaStandaloneSetup]] might be considered instead of providing your own + * implementation for all methods. * * @version 0.1 * @since 01.07.20 diff --git a/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala b/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala index 6097ac1247..eee647d73f 100644 --- a/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala +++ b/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala @@ -26,7 +26,7 @@ abstract class ParsableEnumeration extends Enumeration { withName(cleanedInput) } - /** Checks, if the given input is an eligible description of a enum value + /** Checks, if the given input is an eligible description of an enum value * * @param input * Input string diff --git a/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala b/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala index b55678ef83..7ccc3b7aa2 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala @@ -21,9 +21,8 @@ object QuantityUtil { /** The [[tech.units.indriya.function.DefaultNumberSystem]] is only covering * java [[Number]] children. As [[BigDecimal]] is not related to * [[java.math.BigDecimal]], this causes issues, why the - * [[tech.units.indriya.spi.NumberSystem]] has to be to be used has to be - * specified to something, that actually is able to handle the scala number - * system. + * [[tech.units.indriya.spi.NumberSystem]] has to be used has to be specified + * to something, that actually is able to handle the scala number system. */ def adjustNumberSystem(): Unit = Calculus.setCurrentNumberSystem( diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index 861d35a6a7..c4a3dfa717 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -164,7 +164,7 @@ class DBFSAlgorithmCenGridSpec val firstSlackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(firstSweepNo) - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculations + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculations // we simulate this behaviour now by doing the same for our three inferior grid agents inferiorGrid11.requestSlackVoltage(centerGridAgent, firstSweepNo) @@ -300,7 +300,7 @@ class DBFSAlgorithmCenGridSpec Kilovolts(374.22694614463d), // 380 kV @ 10° Kilovolts(65.9863075134335d), // 380 kV @ 10° ), - ExchangeVoltage( // this one should currently be ignored anyways + ExchangeVoltage( // this one should currently be ignored anyway supNodeA.getUuid, Kilovolts(380d), Kilovolts(0d), @@ -320,7 +320,7 @@ class DBFSAlgorithmCenGridSpec val secondPowerRequestSender13 = inferiorGrid13.expectGridPowerRequest() - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculations + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculations // we simulate this behaviour now by doing the same for our three inferior grid agents inferiorGrid11.requestSlackVoltage(centerGridAgent, secondSweepNo) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala index ce904d0b11..0609a974ec 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala @@ -145,7 +145,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val slackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(sweepNo) - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent inferiorGridAgent.requestSlackVoltage(centerGridAgent, sweepNo) @@ -191,7 +191,7 @@ class DBFSAlgorithmFailedPowerFlowSpec // hence we ask for them and expect a corresponding response superiorGridAgent.requestGridPower(centerGridAgent, sweepNo) - // the requested power is to high for the grid to handle, therefore the superior grid agent + // the requested power is too high for the grid to handle, therefore the superior grid agent // receives a FailedPowerFlow message // wait 30 seconds max for power flow to finish superiorGridAgent.gaProbe.expectMessage(30 seconds, FailedPowerFlow) @@ -229,7 +229,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val slackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(sweepNo) - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent inferiorGridAgent.requestSlackVoltage(centerGridAgent, sweepNo) @@ -341,7 +341,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val powerRequestSender = hvGridAgent.expectGridPowerRequest() - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent hvGridAgent.requestSlackVoltage(slackGridAgent, sweepNo) diff --git a/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala index 4e37001c11..7f77f7ca77 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala @@ -29,7 +29,7 @@ import org.apache.pekko.actor.testkit.typed.scaladsl.{ import org.slf4j.event.Level /** Logging must be tested in a separate test, since LoggingTestKit can still - * receives logs from test that it was not enabled for + * receive logs from test that it was not enabled for */ class RuntimeEventListenerLoggingSpec extends ScalaTestWithActorTestKit( diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 4d6fff7060..032743fa97 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -104,7 +104,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // CHANGED STATE // discharged to empty (10.0, -9.0, 3600, 0.0, 0.0, 10.0), - // almost discharged to lowest allowed charge + // almost discharged to the lowest allowed charge (10.0, -9.0, 3590, 0.0, -10.0, 10.0), // charged to mid-level charge (41.0, 10.0, 3600, 0.0, -10.0, 10.0), diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala index a5fc6ffb82..d3ab3e97b3 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala @@ -28,7 +28,7 @@ trait SubGridGateMokka extends MockitoSugar { * @param subnet * Sub net number * @return - * [[NodeInput]] with these information + * [[NodeInput]] with this information */ protected def mockNode(uuid: UUID, subnet: Int): NodeInput = { val node = mock[NodeInput] From a63dc876367ca0dfcca099c49516671bdea154fa Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:21:37 +0100 Subject: [PATCH 084/137] grammar correct tense --- .../scala/edu/ie3/simona/agent/grid/GridAgentData.scala | 2 +- .../edu/ie3/simona/agent/grid/GridAgentMessages.scala | 2 +- .../edu/ie3/simona/service/ev/ExtEvDataService.scala | 2 +- .../ie3/simona/service/primary/PrimaryServiceWorker.scala | 4 ++-- .../ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala | 4 ++-- .../agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala | 8 ++++---- .../ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala index 636baca646..6b77430487 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala @@ -56,7 +56,7 @@ object GridAgentData { } } - /** Data that is send to the [[GridAgent]] directly after startup. It contains + /** Data that is sent to the [[GridAgent]] directly after startup. It contains * the main information for initialization. This data should include all * [[GridAgent]] individual data, for data that is the same for all * [[GridAgent]] s please use [[GridAgent.apply()]] diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala index b0d98be1e9..288add1bd9 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala @@ -186,7 +186,7 @@ object GridAgentMessages { /** Provide values as a reply to a * [[edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage]]. * In contrast to [[AssetPowerChangedMessage]], this message indicates that - * the same values for [[p]] and [[q]] has been send again as in the previous + * the same values for [[p]] and [[q]] has been sent again as in the previous * request * * @param p diff --git a/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala b/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala index 66cfaa96f1..680c6050b1 100644 --- a/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala +++ b/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala @@ -170,7 +170,7 @@ class ExtEvDataService(override val scheduler: ActorRef) * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send + * with updated values) together with the completion message that is sent * in response to the trigger that was sent to start this announcement */ override protected def announceInformation( diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 7ff05ccf1a..bd09c0b81b 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -198,8 +198,8 @@ final case class PrimaryServiceWorker[V <: Value]( * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send - * in response to the trigger that is send to start the initialization + * with updated values) together with the completion message that is sent + * in response to the trigger that is sent to start the initialization * process */ override protected def announceInformation( diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index c4a3dfa717..8d23af9c46 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -424,8 +424,8 @@ class DBFSAlgorithmCenGridSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is send the inferior grids, they themselves will send the - // Trigger forward the trigger to their connected inferior grids. Therefore the inferior grid + // after a FinishGridSimulationTrigger is sent the inferior grids, they themselves will send the + // Trigger forward the trigger to their connected inferior grids. Therefore, the inferior grid // agent should receive a FinishGridSimulationTrigger inferiorGrid11.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala index 0609a974ec..a1047edeff 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala @@ -200,8 +200,8 @@ class DBFSAlgorithmFailedPowerFlowSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is send to the inferior grids, they themselves will - // forward the trigger to their connected inferior grids. Therefore the inferior grid agent + // after a FinishGridSimulationTrigger is sent to the inferior grids, they themselves will + // forward the trigger to their connected inferior grids. Therefore, the inferior grid agent // should receive a FinishGridSimulationTrigger inferiorGridAgent.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) @@ -272,8 +272,8 @@ class DBFSAlgorithmFailedPowerFlowSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is send to the inferior grids, they themselves will - // forward the trigger to their connected inferior grids. Therefore the inferior grid agent + // after a FinishGridSimulationTrigger is sent to the inferior grids, they themselves will + // forward the trigger to their connected inferior grids. Therefore, the inferior grid agent // should receive a FinishGridSimulationTrigger inferiorGridAgent.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala index 9c716def88..beb1408270 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala @@ -154,7 +154,7 @@ class DBFSAlgorithmSupGridSpec ) // we expect a completion message here and that the agent goes back to simulate grid - // and waits until the newly scheduled StartGridSimulationTrigger is send + // and waits until the newly scheduled StartGridSimulationTrigger is sent // wait 30 seconds max for power flow to finish scheduler.expectMessageType[Completion](130 seconds) match { case Completion(_, Some(3600)) => @@ -271,7 +271,7 @@ class DBFSAlgorithmSupGridSpec ) // we expect a completion message here and that the agent goes back to simulate grid - // and waits until the newly scheduled StartGridSimulationTrigger is send + // and waits until the newly scheduled StartGridSimulationTrigger is sent // Simulate Grid // wait 30 seconds max for power flow to finish From 5694a9f9d98d8cebf1016602c944740347d5d4b8 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:26:48 +0100 Subject: [PATCH 085/137] grammar correct tense second part --- .../edu/ie3/simona/agent/grid/GridResultsSupport.scala | 6 +++--- src/main/scala/edu/ie3/simona/service/SimonaService.scala | 6 +++--- .../edu/ie3/simona/service/weather/WeatherService.scala | 6 +++--- .../scala/edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index 87aa1d8440..59f0248f81 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -96,7 +96,7 @@ private[grid] trait GridResultsSupport { * and the corresponding sweep value data * * @param lines - * the set of lines which the result should be build for + * the set of lines which the result should be built for * @param sweepValueStoreData * the value store with all power flow result values of the provided lines * @param iNominal @@ -142,7 +142,7 @@ private[grid] trait GridResultsSupport { * [[TransformerModel]] and the corresponding sweep value data * * @param transformers - * the set of transformers which the result should be build for + * the set of transformers which the result should be built for * @param sweepValueStoreData * the value store with all power flow result values of the provided * transformers @@ -190,7 +190,7 @@ private[grid] trait GridResultsSupport { * [[Transformer3wModel]] and the corresponding sweep value data * * @param transformers3w - * the set of 3 winding transformers which the result should be build for + * the set of 3 winding transformers which the result should be built for * @param sweepValueStoreData * the value store with all power flow result values of the provided 3 * winding transformers diff --git a/src/main/scala/edu/ie3/simona/service/SimonaService.scala b/src/main/scala/edu/ie3/simona/service/SimonaService.scala index 75a1813f0a..310c7f0b32 100644 --- a/src/main/scala/edu/ie3/simona/service/SimonaService.scala +++ b/src/main/scala/edu/ie3/simona/service/SimonaService.scala @@ -182,9 +182,9 @@ abstract class SimonaService[ /** Initialize the concrete service implementation using the provided * initialization data. This method should perform all heavyweight tasks * before the actor becomes ready. The return values are a) the state data of - * the initialized service and b) optional triggers that should be send to + * the initialized service and b) optional triggers that should be sent to * the [[edu.ie3.simona.scheduler.Scheduler]] together with the completion - * message that is send in response to the trigger that is send to start the + * message that is sent in response to the trigger that is sent to start the * initialization process * * @param initServiceData @@ -221,7 +221,7 @@ abstract class SimonaService[ * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send + * with updated values) together with the completion message that is sent * in response to the trigger that was sent to start this announcement */ protected def announceInformation(tick: Long)(implicit diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala index 0f8039d30d..a31a217eb0 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala @@ -107,9 +107,9 @@ final case class WeatherService( /** Initialize the concrete service implementation using the provided * initialization data. This method should perform all heavyweight tasks * before the actor becomes ready. The return values are a) the state data of - * the initialized service and b) optional triggers that should be send to + * the initialized service and b) optional triggers that should be sent to * the [[edu.ie3.simona.scheduler.Scheduler]] together with the completion - * message that is send in response to the trigger that is send to start the + * message that is sent in response to the trigger that is sent to start the * initialization process * * @param initServiceData @@ -284,7 +284,7 @@ final case class WeatherService( * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send + * with updated values) together with the completion message that is sent * in response to the trigger that was sent to start this announcement */ override protected def announceInformation(tick: Long)(implicit diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index e90fa8975d..8b74574226 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -156,7 +156,7 @@ object ResultFileHierarchy extends LazyLogging { ) /** @param modelClass - * the model class a file path should be build for + * the model class a file path should be built for * @param csvSink * the csv sink type parameters * @param rawOutputDataDir From a5dd416237130ac2ac4a13db69ef515ef935ab63 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:30:47 +0100 Subject: [PATCH 086/137] spelling --- docs/readthedocs/models/thermal_house_model.md | 2 +- .../fixedfeedin/FixedFeedInAgentFundamentals.scala | 4 ++-- .../simona/agent/participant/pv/PvAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/main/RunSimona.scala | 2 +- .../participant/load/random/RandomLoadParamStore.scala | 6 +++--- src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala | 2 +- .../ie3/simona/event/listener/ResultEventListenerSpec.scala | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/readthedocs/models/thermal_house_model.md b/docs/readthedocs/models/thermal_house_model.md index 7914270c7f..84044085dc 100644 --- a/docs/readthedocs/models/thermal_house_model.md +++ b/docs/readthedocs/models/thermal_house_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the thermal house available in SIMONA. ## Behaviour -This house model represents the thermal behaviour of a building. This reflects a simple shoe box with a thermal capacity and with transmission losses. +This house model represents the thermal behaviour of a building. This reflects a simple shoebox with a thermal capacity and with transmission losses. ## Attributes, Units and Remarks diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index f634bf0454..233246ca81 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -134,8 +134,8 @@ protected trait FixedFeedInAgentFundamentals /* As participant agents always return their last known operation point on request, it is sufficient * to let a fixed model determine its operation point on: * 1) The first tick of the simulation - * 2) The tick, it turns on (in time dependent operation) - * 3) The tick, it turns off (in time dependent operation) + * 2) The tick, it turns on (in time-dependent operation) + * 3) The tick, it turns off (in time-dependent operation) * Coinciding ticks are summarized and the last tick is removed, as the change in operation status * doesn't affect anything then */ SortedSet[Long]( diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index b3b96970b6..52f0a76e24 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -210,7 +210,7 @@ protected trait PvAgentFundamentals tick - dataTick case _ => /* At the first tick, we are not able to determine the tick interval from last tick - * (since there is none). Then we use a fall back pv stem distance. */ + * (since there is none). Then we use a fallback pv stem distance. */ FALLBACK_WEATHER_STEM_DISTANCE } diff --git a/src/main/scala/edu/ie3/simona/main/RunSimona.scala b/src/main/scala/edu/ie3/simona/main/RunSimona.scala index c255990a05..9d03f38665 100644 --- a/src/main/scala/edu/ie3/simona/main/RunSimona.scala +++ b/src/main/scala/edu/ie3/simona/main/RunSimona.scala @@ -86,7 +86,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { } } - /** Method to be implemented to setup everything that is necessary for a + /** Method to be implemented to set up everything that is necessary for a * simulations. This is by creating an instance of [[SimonaSetup]] * implementation * diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala index 394732bc4c..33fb57a38a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala @@ -124,13 +124,13 @@ case object RandomLoadParamStore extends LazyLogging { } /** Builds a descriptor tree, which gives information what to find where in - * the file. Each head line element breaks down to encoded information about + * the file. Each headline element breaks down to encoded information about * the probability density function parameter and the addressed day type. All - * head line elements are treated this way and a mapping from day type to + * headline elements are treated this way and a mapping from day type to * column position of parameter is build. * * @param headerElements - * List of head line elements + * List of headline elements * @return * Mapping from day type to a mapping from parameter to column index */ diff --git a/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala b/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala index 7339fbbe61..7cc4174e10 100644 --- a/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala +++ b/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala @@ -160,7 +160,7 @@ object Scheduler { stopOnError(ctx, s"Received unexpected message $unexpected when active") } - /** Data that is constant over the life time of a scheduler. + /** Data that is constant over the lifetime of a scheduler. * @param parent * The parent of the scheduler * @param activationAdapter diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index edcd0ffe2f..4a2d8abd42 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -21,7 +21,7 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} -/** Trait that can be used to setup a customized simona simulation by providing +/** Trait that can be used to set up a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending * [[SimonaStandaloneSetup]] might be considered instead of providing your own diff --git a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala index f110feca8e..26c3145945 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala @@ -316,7 +316,7 @@ class ResultEventListenerSpec ), ) ) - /* The result file is created at start up and only contains a head line. */ + /* The result file is created at start up and only contains a headline. */ awaitCond( outputFile.exists(), interval = 500.millis, From c3a823a2bc8298038bf9634c876a57e4f3d2251d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:30:47 +0100 Subject: [PATCH 087/137] spelling --- docs/readthedocs/models/thermal_house_model.md | 2 +- .../fixedfeedin/FixedFeedInAgentFundamentals.scala | 4 ++-- .../simona/agent/participant/pv/PvAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/main/RunSimona.scala | 2 +- .../participant/load/random/RandomLoadParamStore.scala | 6 +++--- src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala | 2 +- .../ie3/simona/event/listener/ResultEventListenerSpec.scala | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/readthedocs/models/thermal_house_model.md b/docs/readthedocs/models/thermal_house_model.md index 7914270c7f..84044085dc 100644 --- a/docs/readthedocs/models/thermal_house_model.md +++ b/docs/readthedocs/models/thermal_house_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the thermal house available in SIMONA. ## Behaviour -This house model represents the thermal behaviour of a building. This reflects a simple shoe box with a thermal capacity and with transmission losses. +This house model represents the thermal behaviour of a building. This reflects a simple shoebox with a thermal capacity and with transmission losses. ## Attributes, Units and Remarks diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index 5d3a2d6805..a1da136749 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -134,8 +134,8 @@ protected trait FixedFeedInAgentFundamentals /* As participant agents always return their last known operation point on request, it is sufficient * to let a fixed fixed in model determine it's operation point on: * 1) The first tick of the simulation - * 2) The tick, it turns on (in time dependent operation) - * 3) The tick, it turns off (in time dependent operation) + * 2) The tick, it turns on (in time-dependent operation) + * 3) The tick, it turns off (in time-dependent operation) * Coinciding ticks are summarized and the last tick is removed, as the change in operation status * doesn't affect anything then */ SortedSet[Long]( diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index ce152a3d7e..d1e441e4b4 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -210,7 +210,7 @@ protected trait PvAgentFundamentals tick - dataTick case _ => /* At the first tick, we are not able to determine the tick interval from last tick - * (since there is none). Then we use a fall back pv stem distance. */ + * (since there is none). Then we use a fallback pv stem distance. */ FALLBACK_WEATHER_STEM_DISTANCE } diff --git a/src/main/scala/edu/ie3/simona/main/RunSimona.scala b/src/main/scala/edu/ie3/simona/main/RunSimona.scala index c255990a05..9d03f38665 100644 --- a/src/main/scala/edu/ie3/simona/main/RunSimona.scala +++ b/src/main/scala/edu/ie3/simona/main/RunSimona.scala @@ -86,7 +86,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { } } - /** Method to be implemented to setup everything that is necessary for a + /** Method to be implemented to set up everything that is necessary for a * simulations. This is by creating an instance of [[SimonaSetup]] * implementation * diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala index 36635ae940..195b40a4a3 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala @@ -124,13 +124,13 @@ case object RandomLoadParamStore extends LazyLogging { } /** Builds a descriptor tree, which gives information what to find where in - * the file. Each head line element breaks down to encoded information about + * the file. Each headline element breaks down to encoded information about * the probability density function parameter and the addressed day type. All - * head line elements are treated this way and a mapping from day type to + * headline elements are treated this way and a mapping from day type to * column position of parameter is build. * * @param headerElements - * List of head line elements + * List of headline elements * @return * Mapping from day type to a mapping from parameter to column index */ diff --git a/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala b/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala index 7339fbbe61..7cc4174e10 100644 --- a/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala +++ b/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala @@ -160,7 +160,7 @@ object Scheduler { stopOnError(ctx, s"Received unexpected message $unexpected when active") } - /** Data that is constant over the life time of a scheduler. + /** Data that is constant over the lifetime of a scheduler. * @param parent * The parent of the scheduler * @param activationAdapter diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index 9c6effa859..170c807e80 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -21,7 +21,7 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} -/** Trait that can be used to setup a customized simona simulation by providing +/** Trait that can be used to set up a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending * [[SimonaStandaloneSetup]] might be considered instead of providing a your diff --git a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala index f110feca8e..26c3145945 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala @@ -316,7 +316,7 @@ class ResultEventListenerSpec ), ) ) - /* The result file is created at start up and only contains a head line. */ + /* The result file is created at start up and only contains a headline. */ awaitCond( outputFile.exists(), interval = 500.millis, From a960acec51427a38dfb323e9a8aa6a005ad5ee4a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:26:48 +0100 Subject: [PATCH 088/137] grammar correct tense second part --- .../edu/ie3/simona/agent/grid/GridResultsSupport.scala | 6 +++--- src/main/scala/edu/ie3/simona/service/SimonaService.scala | 6 +++--- .../edu/ie3/simona/service/weather/WeatherService.scala | 6 +++--- .../scala/edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index c872cc8e54..55ea126136 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -96,7 +96,7 @@ private[grid] trait GridResultsSupport { * and the corresponding sweep value data * * @param lines - * the set of lines which the result should be build for + * the set of lines which the result should be built for * @param sweepValueStoreData * the value store with all power flow result values of the provided lines * @param iNominal @@ -142,7 +142,7 @@ private[grid] trait GridResultsSupport { * [[TransformerModel]] and the corresponding sweep value data * * @param transformers - * the set of transformers which the result should be build for + * the set of transformers which the result should be built for * @param sweepValueStoreData * the value store with all power flow result values of the provided * transformers @@ -190,7 +190,7 @@ private[grid] trait GridResultsSupport { * [[Transformer3wModel]] and the corresponding sweep value data * * @param transformers3w - * the set of 3 winding transformers which the result should be build for + * the set of 3 winding transformers which the result should be built for * @param sweepValueStoreData * the value store with all power flow result values of the provided 3 * winding transformers diff --git a/src/main/scala/edu/ie3/simona/service/SimonaService.scala b/src/main/scala/edu/ie3/simona/service/SimonaService.scala index 1b41b30400..f6db7b5c72 100644 --- a/src/main/scala/edu/ie3/simona/service/SimonaService.scala +++ b/src/main/scala/edu/ie3/simona/service/SimonaService.scala @@ -182,9 +182,9 @@ abstract class SimonaService[ /** Initialize the concrete service implementation using the provided * initialization data. This method should perform all heavyweight tasks * before the actor becomes ready. The return values are a) the state data of - * the initialized service and b) optional triggers that should be send to + * the initialized service and b) optional triggers that should be sent to * the [[edu.ie3.simona.scheduler.Scheduler]] together with the completion - * message that is send in response to the trigger that is send to start the + * message that is sent in response to the trigger that is sent to start the * initialization process * * @param initServiceData @@ -221,7 +221,7 @@ abstract class SimonaService[ * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send + * with updated values) together with the completion message that is sent * in response to the trigger that was sent to start this announcement */ protected def announceInformation(tick: Long)(implicit diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala index a75b0c38fd..4092a2850f 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala @@ -107,9 +107,9 @@ final case class WeatherService( /** Initialize the concrete service implementation using the provided * initialization data. This method should perform all heavyweight tasks * before the actor becomes ready. The return values are a) the state data of - * the initialized service and b) optional triggers that should be send to + * the initialized service and b) optional triggers that should be sent to * the [[edu.ie3.simona.scheduler.Scheduler]] together with the completion - * message that is send in response to the trigger that is send to start the + * message that is sent in response to the trigger that is sent to start the * initialization process * * @param initServiceData @@ -284,7 +284,7 @@ final case class WeatherService( * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send + * with updated values) together with the completion message that is sent * in response to the trigger that was sent to start this announcement */ override protected def announceInformation(tick: Long)(implicit diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 171c5835a2..0212ad124e 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -156,7 +156,7 @@ object ResultFileHierarchy extends LazyLogging { ) /** @param modelClass - * the model class a file path should be build for + * the model class a file path should be built for * @param csvSink * the csv sink type parameters * @param rawOutputDataDir From a9a335d779fe42d2f7a9f9d675d3bb0b82155878 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:21:37 +0100 Subject: [PATCH 089/137] grammar correct tense --- .../scala/edu/ie3/simona/agent/grid/GridAgentData.scala | 2 +- .../edu/ie3/simona/agent/grid/GridAgentMessages.scala | 2 +- .../edu/ie3/simona/service/ev/ExtEvDataService.scala | 2 +- .../ie3/simona/service/primary/PrimaryServiceWorker.scala | 4 ++-- .../ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala | 4 ++-- .../agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala | 8 ++++---- .../ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala index 636baca646..6b77430487 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala @@ -56,7 +56,7 @@ object GridAgentData { } } - /** Data that is send to the [[GridAgent]] directly after startup. It contains + /** Data that is sent to the [[GridAgent]] directly after startup. It contains * the main information for initialization. This data should include all * [[GridAgent]] individual data, for data that is the same for all * [[GridAgent]] s please use [[GridAgent.apply()]] diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala index b0d98be1e9..288add1bd9 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala @@ -186,7 +186,7 @@ object GridAgentMessages { /** Provide values as a reply to a * [[edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage]]. * In contrast to [[AssetPowerChangedMessage]], this message indicates that - * the same values for [[p]] and [[q]] has been send again as in the previous + * the same values for [[p]] and [[q]] has been sent again as in the previous * request * * @param p diff --git a/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala b/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala index 66cfaa96f1..680c6050b1 100644 --- a/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala +++ b/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala @@ -170,7 +170,7 @@ class ExtEvDataService(override val scheduler: ActorRef) * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send + * with updated values) together with the completion message that is sent * in response to the trigger that was sent to start this announcement */ override protected def announceInformation( diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 7ff05ccf1a..bd09c0b81b 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -198,8 +198,8 @@ final case class PrimaryServiceWorker[V <: Value]( * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is send - * in response to the trigger that is send to start the initialization + * with updated values) together with the completion message that is sent + * in response to the trigger that is sent to start the initialization * process */ override protected def announceInformation( diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index 4da922de62..c93a049bf0 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -424,8 +424,8 @@ class DBFSAlgorithmCenGridSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is send the inferior grids, they themselves will send the - // Trigger forward the trigger to their connected inferior grids. Therefore the inferior grid + // after a FinishGridSimulationTrigger is sent the inferior grids, they themselves will send the + // Trigger forward the trigger to their connected inferior grids. Therefore, the inferior grid // agent should receive a FinishGridSimulationTrigger inferiorGrid11.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala index ce904d0b11..7a4b2bce6e 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala @@ -200,8 +200,8 @@ class DBFSAlgorithmFailedPowerFlowSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is send to the inferior grids, they themselves will - // forward the trigger to their connected inferior grids. Therefore the inferior grid agent + // after a FinishGridSimulationTrigger is sent to the inferior grids, they themselves will + // forward the trigger to their connected inferior grids. Therefore, the inferior grid agent // should receive a FinishGridSimulationTrigger inferiorGridAgent.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) @@ -272,8 +272,8 @@ class DBFSAlgorithmFailedPowerFlowSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is send to the inferior grids, they themselves will - // forward the trigger to their connected inferior grids. Therefore the inferior grid agent + // after a FinishGridSimulationTrigger is sent to the inferior grids, they themselves will + // forward the trigger to their connected inferior grids. Therefore, the inferior grid agent // should receive a FinishGridSimulationTrigger inferiorGridAgent.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala index 9c716def88..beb1408270 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala @@ -154,7 +154,7 @@ class DBFSAlgorithmSupGridSpec ) // we expect a completion message here and that the agent goes back to simulate grid - // and waits until the newly scheduled StartGridSimulationTrigger is send + // and waits until the newly scheduled StartGridSimulationTrigger is sent // wait 30 seconds max for power flow to finish scheduler.expectMessageType[Completion](130 seconds) match { case Completion(_, Some(3600)) => @@ -271,7 +271,7 @@ class DBFSAlgorithmSupGridSpec ) // we expect a completion message here and that the agent goes back to simulate grid - // and waits until the newly scheduled StartGridSimulationTrigger is send + // and waits until the newly scheduled StartGridSimulationTrigger is sent // Simulate Grid // wait 30 seconds max for power flow to finish From aa22b46371665aae0dbe2e081a01cabd31a295c7 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:05:57 +0100 Subject: [PATCH 090/137] grammar, spelling, typos, wording etc. --- docs/readthedocs/developersguide.md | 2 +- docs/readthedocs/models/em.md | 2 +- docs/readthedocs/models/hp_model.md | 2 +- docs/readthedocs/usersguide.md | 2 +- .../ie3/simona/actor/SimonaActorNaming.scala | 2 +- .../agent/grid/GridAgentController.scala | 2 +- .../simona/agent/grid/PowerFlowSupport.scala | 2 +- .../agent/participant/ParticipantAgent.scala | 6 +++--- .../ParticipantAgentFundamentals.scala | 21 ++++++++++--------- .../edu/ie3/simona/event/RuntimeEvent.scala | 2 +- .../exceptions/WeatherServiceException.scala | 2 +- .../ie3/simona/model/SystemComponent.scala | 2 +- .../model/em/PrioritizedFlexStrat.scala | 4 ++-- .../edu/ie3/simona/model/grid/GridModel.scala | 4 ++-- .../edu/ie3/simona/model/grid/RefSystem.scala | 2 +- .../model/grid/TransformerTapping.scala | 2 +- .../model/participant/evcs/EvcsModel.scala | 4 ++-- .../ie3/simona/service/SimonaService.scala | 2 +- .../service/primary/PrimaryServiceProxy.scala | 2 +- .../service/weather/SampleWeatherSource.scala | 2 +- .../ie3/simona/sim/setup/SimonaSetup.scala | 4 ++-- .../ie3/simona/util/ParsableEnumeration.scala | 2 +- .../util/scala/quantities/QuantityUtil.scala | 5 ++--- .../agent/grid/DBFSAlgorithmCenGridSpec.scala | 6 +++--- .../DBFSAlgorithmFailedPowerFlowSpec.scala | 8 +++---- .../RuntimeEventListenerLoggingSpec.scala | 2 +- .../model/participant/StorageModelSpec.scala | 2 +- .../common/model/grid/SubGridGateMokka.scala | 2 +- 28 files changed, 50 insertions(+), 50 deletions(-) diff --git a/docs/readthedocs/developersguide.md b/docs/readthedocs/developersguide.md index ace59e05e6..a246fc106a 100644 --- a/docs/readthedocs/developersguide.md +++ b/docs/readthedocs/developersguide.md @@ -2,7 +2,7 @@ # Developer’s Guide -The SIMONA repository can be found [on Github](https://github.com/ie3-institute/simona). +The SIMONA repository can be found [on GitHub](https://github.com/ie3-institute/simona). ```{contents} --- diff --git a/docs/readthedocs/models/em.md b/docs/readthedocs/models/em.md index ae10cb3ac2..ea7261d4f8 100644 --- a/docs/readthedocs/models/em.md +++ b/docs/readthedocs/models/em.md @@ -16,7 +16,7 @@ If an EmAgent is itself controlled by another EmAgent, it also behaves like a sy Every EmAgent aggregates flex options and power of its connected assets and disaggregates flex control among the connected assets. It also functions as a scheduler for all connected assets by processing information on the ticks of the next desired activations and conveying such information to the controlling EmAgent or a central scheduler respectively. -Uncontrolled EmAgents answer to a scheduler with regards to their activation. +Uncontrolled EmAgents answer to a scheduler with regard to their activation. ![](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/ie3-institute/simona/dev/docs/uml/protocol/em/UncontrolledEm.puml) diff --git a/docs/readthedocs/models/hp_model.md b/docs/readthedocs/models/hp_model.md index 0458fffbac..bcc10f3a97 100644 --- a/docs/readthedocs/models/hp_model.md +++ b/docs/readthedocs/models/hp_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the Heat Pump Model (HP model) availabl ## Assumptions -The HP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the HP unit does not posses a memory. +The HP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the HP unit does not possess a memory. ## Parameters diff --git a/docs/readthedocs/usersguide.md b/docs/readthedocs/usersguide.md index 5b75b15ac7..ea6a9babf1 100644 --- a/docs/readthedocs/usersguide.md +++ b/docs/readthedocs/usersguide.md @@ -37,7 +37,7 @@ You can either delegate the job to your preferred IDE or build an executable jar In order to be able to execute SIMONA from a CLI, you need an executable fat jar. A fat jar contains all compiled classes and dependencies, ready for execution. For building one, you can use a Gradle task of the project. 1. Open a CLI and change directories to the top level directory of the project. -2. Execute ``gradlew shadowJar`` within the CLI. This creates a fat jar of SIMONA inside of the directory ``build/libs``. +2. Execute ``gradlew shadowJar`` within the CLI. This creates a fat jar of SIMONA inside the directory ``build/libs``. 3. For executing a fat jar you need to specify the classpath of the entrypoint of your application. Assuming we are still in the top level directory of our project, the execution command would look as follows: diff --git a/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala b/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala index fed8f600f3..2b0c62e780 100644 --- a/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala +++ b/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala @@ -21,7 +21,7 @@ object SimonaActorNaming { refFactory.actorOf(props, actorName(props, simonaActorId(actorId))) } - /** Constructs an Id for convenience actor naming. Although this is dangerous + /** Constructs an id for convenience actor naming. Although this is dangerous * as duplicates might be possible, it should be sufficient in our case as * the uniqueness is only required in one actor system * diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala index f2e78f7c53..ad0d6c3b07 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala @@ -158,7 +158,7 @@ class GridAgentController( /** Go through all provided input models, build agents for those and group the * resulting actor references for each connection nodes. All participant * agents are also introduced to the agent environment and the scheduler is - * requested to send a initialisation trigger. + * requested to send an initialisation trigger. * * @param participantsConfig * Configuration information for participant models diff --git a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala index eae1369de4..50a785af8d 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala @@ -203,7 +203,7 @@ trait PowerFlowSupport { * p/q values from the provided sweepDataValues and combines them with * updated receivedSlackValues. Normally used in a forward sweep phase of * [[DBFSAlgorithm]] as in this state only voltages are updated and a power - * flow with new voltages but old p/q values is executed afterwards + * flow with new voltages but old p/q values is executed afterward. * * @param receivedSlackValues * new slack voltages provided by the superior grid diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 52e3a53a59..19a18c60c7 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -448,8 +448,8 @@ abstract class ParticipantAgent[ case _ => participantStateData.receivedSecondaryDataStore } - /* At least parts of the needed data has been received or it is an additional activation, that has been triggered. - * Anyways, the calculation routine has also to take care of filling up missing data. */ + /* At least parts of the needed data has been received, or it is an additional activation, that has been triggered. + * Anyway, the calculation routine has also to take care of filling up missing data. */ val lastModelState = getLastOrInitialStateData(participantStateData, currentTick) calculatePowerWithSecondaryDataAndGoToIdle( @@ -656,7 +656,7 @@ abstract class ParticipantAgent[ * the agent is meant to replay external primary data: Announce result, add * content to result value store, go to [[Idle]] and answer the scheduler, * that the activity start trigger is fulfilled. 2.2) All secondary data is - * there, go to [[Calculate]] and ask the scheduler to trigger ourself for + * there, go to [[Calculate]] and ask the scheduler to trigger ourselves for * starting the model based calculation 3) Everything is at place and the * [[Activation]] has NOT yet been sent: Stay here and wait * 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 984815a846..536dc8d412 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -388,7 +388,7 @@ protected trait ParticipantAgentFundamentals[ /** Assume we have information, that are available in a fixed resolution after * each full hour (including the full hour), then we have to determine, at - * what first tick those information are available. + * what first tick this information are available. * * @param simulationStartDate * Beginning of the simulation @@ -515,7 +515,7 @@ protected trait ParticipantAgentFundamentals[ val foreseenDataTicks = baseStateData.foreseenDataTicks + (msg.serviceRef -> msg.nextDataTick) - /* Go over to handling these information */ + /* Go over to handling this information */ val nextStateData = DataCollectionStateData( BaseStateData.updateBaseStateData( baseStateData, @@ -538,8 +538,9 @@ protected trait ParticipantAgentFundamentals[ * Announce result, add content to result value store, go to [[Idle]] and * answer the scheduler, that the activity start trigger is fulfilled. 2.2) * All secondary data is there, go to [[Calculate]] and ask the scheduler to - * trigger ourself for starting the model based calculation 3) Everything is - * at place and the [[Activation]] has NOT yet been sent: Stay here and wait + * trigger ourselves for starting the model based calculation 3) Everything + * is at place and the [[Activation]] has NOT yet been sent: Stay here and + * wait * * @param stateData * Apparent state data @@ -645,7 +646,7 @@ protected trait ParticipantAgentFundamentals[ ) } } else { - /* We sill have to wait - either for data or activation */ + /* We still have to wait - either for data or activation */ stay() using stateData } } @@ -1141,7 +1142,7 @@ protected trait ParticipantAgentFundamentals[ baseStateData, ) case (Some(additionalTick), _) => - /* The next activation is additional (either there is no foreseen data tick or it is after the additional tick. + /* The next activation is additional (either there is no foreseen data tick or it is after the additional tick). * Remove the tick from the list of additional activation ticks. */ val upcomingActivationTicks = baseStateData.additionalActivationTicks.rangeFrom(additionalTick + 1) @@ -1159,7 +1160,7 @@ protected trait ParticipantAgentFundamentals[ updatedBaseStateData, ) case (None, None) => - /* We don't know nothing about either additional activation nor new incoming data */ + /* We don't know anything about either additional activation nor new incoming data */ (None, baseStateData) } } @@ -1258,7 +1259,7 @@ protected trait ParticipantAgentFundamentals[ } /** Checks, if a fast reply is possible, when the very same request (in terms - * of tick and nodal voltage) already has been answered. Then a Option on + * of tick and nodal voltage) already has been answered. Then an Option on * stay in the same state with sending an [[AssetPowerUnchangedMessage]] is * given back. If a fast reply is not possible, [[None]] is given back. * Additionally, the listener are informed about the result. @@ -1292,7 +1293,7 @@ protected trait ParticipantAgentFundamentals[ case Some((mostRecentRequestTick, latestProvidedValues)) if mostRecentRequestTick == requestTick => /* A request for this tick has already been answered. Check, if it has been the same request. - * if it has been the same request we wanna answer with the same values afterwards, this data MUST always + * if it has been the same request we want to answer with the same values afterwards, this data MUST always * be available when we already provided data for this tick */ baseStateData match { case externalBaseStateData: FromOutsideBaseStateData[M, PD] => @@ -1753,7 +1754,7 @@ protected trait ParticipantAgentFundamentals[ * @param tick * Tick, the result belongs to * @param result - * The result to build a event for + * The result to build an event for * @param outputConfig * Configuration of the output behaviour */ diff --git a/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala b/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala index da02b9c258..44d092ea0f 100644 --- a/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala @@ -21,7 +21,7 @@ object RuntimeEvent { /** Indicates that the scheduler has finished a pre-defined advancement in * ticks and is ready to carry out the next task. In contrast to the * [[CheckWindowPassed]] event, whenever a [[Ready]] event is scheduled, the - * scheduled of [[edu.ie3.simona.scheduler.Scheduler]] will be stopped and + * schedule of [[edu.ie3.simona.scheduler.Scheduler]] will be stopped and * further commands are necessary to continue the schedule. * * @param tick diff --git a/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala b/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala index 08d109a2a6..b1291f6694 100644 --- a/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala +++ b/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala @@ -45,7 +45,7 @@ object WeatherServiceException { private val cause: Throwable = None.orNull, ) extends WeatherServiceException(msg, cause) - /** Exception to be thrown if the registration of the an agent fails + /** Exception to be thrown if the registration of an agent fails * @param msg * Message to prompt to the end user * @param cause diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index 623e5a58c3..6553faab08 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -40,7 +40,7 @@ abstract class SystemComponent( private val elementType: String = this.getClass.getSimpleName - // check if a uuid is provided + // check if an uuid is provided if (Option.apply(uuid).isEmpty) throw new InvalidParameterException( s"Uuid of $elementType $id cannot be null!" diff --git a/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala b/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala index 98162db86c..3d934e21f3 100644 --- a/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala +++ b/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala @@ -122,7 +122,7 @@ final case class PrioritizedFlexStrat(curtailRegenerative: Boolean) (issueCtrlMsgs, Some(remainingExcessPower)) } else if (remainingExcessPower < flexPotential) { // we cannot cover the excess feed-in with just this flexibility, - // thus use all of the available flexibility and continue + // thus use all the available flexibility and continue ( issueCtrlMsgs :+ (inputModel.getUuid, flexOption.max), Some(remainingExcessPower - flexPotential), @@ -171,7 +171,7 @@ final case class PrioritizedFlexStrat(curtailRegenerative: Boolean) (issueCtrlMsgs, Some(remainingExcessPower)) } else if (remainingExcessPower > flexPotential) { // we cannot cover the excess load with just this flexibility, - // thus use all of the available flexibility and continue + // thus use all the available flexibility and continue ( issueCtrlMsgs :+ (inputModel.getUuid, flexOption.min), Some(remainingExcessPower - flexPotential), diff --git a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala index af90cfc344..25cee7edcf 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala @@ -332,7 +332,7 @@ object GridModel { } /** This checks whether the provided grid model graph is connected, that means - * if every node can be reached from every other node trough a sequence of + * if every node can be reached from every other node through a sequence of * edges. Also checks for referenced nodes that are missing. This check * considers the state (enabled/disabled) of the elements. * @@ -605,7 +605,7 @@ object GridModel { /** Check and validates the grid. Especially the consistency of the grid * model the connectivity of the grid model if there is InitData for - * superior or inferior GridGates if there exits voltage measurements for + * superior or inferior GridGates if there exists voltage measurements for * transformerControlGroups */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala b/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala index 40319e699a..d9a6090601 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala @@ -153,7 +153,7 @@ final case class RefSystem private ( /** Converts a provided voltage value from physical SI value into p.u. value * * @param vInSi - * real or imaginary part of a unreferenced physical SI value + * real or imaginary part of an unreferenced physical SI value * @return * referenced voltage value in p.u. */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala index 809e7c5f8f..a1679a54f2 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala @@ -17,7 +17,7 @@ import tech.units.indriya.quantity.Quantities * necessary to override updateTapPos (e.g. in [[Transformer3wModel]]). The * provided [[TransformerTappingModel]] *should* be protected and not be * accessible from outside to prevent direct access to internal functions! - * Instead all the functions provided here should be used for tap position + * Instead, all the functions provided here should be used for tap position * manipulation. */ trait TransformerTapping { diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index a1d21252ec..b703304893 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -194,7 +194,7 @@ final case class EvcsModel( state.evs } - /** Charge the given EV under consideration a applicable schedule + /** Charge the given EV under consideration an applicable schedule * * @param ev * Electric vehicle to charge @@ -271,7 +271,7 @@ final case class EvcsModel( /* Filter for entries, that end after the last schedule application and that start before the current tick. Entries that end at lastTick are not included because schedule - intervals are open at the right hand side. + intervals are open on the right hand side. Entries that start at currentTick are not included because these will be calculated with the next state. */ diff --git a/src/main/scala/edu/ie3/simona/service/SimonaService.scala b/src/main/scala/edu/ie3/simona/service/SimonaService.scala index f6db7b5c72..310c7f0b32 100644 --- a/src/main/scala/edu/ie3/simona/service/SimonaService.scala +++ b/src/main/scala/edu/ie3/simona/service/SimonaService.scala @@ -30,7 +30,7 @@ object SimonaService { /** Service initialization data can sometimes only be constructed once the * service actor is created (e.g. - * [[edu.ie3.simona.service.ev.ExtEvDataService]]. Thus, we need an extra + * [[edu.ie3.simona.service.ev.ExtEvDataService]]). Thus, we need an extra * initialization message. */ final case class Create[+I <: InitializeServiceStateData]( diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala index ca41a11234..be9a87fc4d 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala @@ -269,7 +269,7 @@ case class PrimaryServiceProxy( unhandled(x) } - /** Handle the registration request for a covered model. First, try to get a + /** Handle the registration request for a covered model. First, try to get an * already existing worker for this time series, otherwise spin-off a new * one, remember it and forward the request * diff --git a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala index c8045ced59..2e2dd58c7c 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala @@ -183,7 +183,7 @@ object SampleWeatherSource { } } - // these lists contain the hourly weather values for each first of the month of 2011 + january of + // these lists contain the hourly weather values for each first of the month of 2011 + january // 2012 at coordinate id 213089 val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 1.18179e-12, 4.42315e-11, 0.0585938, 1.94141, 15.1172, 74.8438, 89.0469, 104.062, diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index 170c807e80..4a2d8abd42 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -24,8 +24,8 @@ import org.apache.pekko.actor.{ActorRef => ClassicRef} /** Trait that can be used to set up a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending - * [[SimonaStandaloneSetup]] might be considered instead of providing a your - * own implementation for all methods. + * [[SimonaStandaloneSetup]] might be considered instead of providing your own + * implementation for all methods. * * @version 0.1 * @since 01.07.20 diff --git a/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala b/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala index 6097ac1247..eee647d73f 100644 --- a/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala +++ b/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala @@ -26,7 +26,7 @@ abstract class ParsableEnumeration extends Enumeration { withName(cleanedInput) } - /** Checks, if the given input is an eligible description of a enum value + /** Checks, if the given input is an eligible description of an enum value * * @param input * Input string diff --git a/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala b/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala index b55678ef83..7ccc3b7aa2 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala @@ -21,9 +21,8 @@ object QuantityUtil { /** The [[tech.units.indriya.function.DefaultNumberSystem]] is only covering * java [[Number]] children. As [[BigDecimal]] is not related to * [[java.math.BigDecimal]], this causes issues, why the - * [[tech.units.indriya.spi.NumberSystem]] has to be to be used has to be - * specified to something, that actually is able to handle the scala number - * system. + * [[tech.units.indriya.spi.NumberSystem]] has to be used has to be specified + * to something, that actually is able to handle the scala number system. */ def adjustNumberSystem(): Unit = Calculus.setCurrentNumberSystem( diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index c93a049bf0..59a32256d2 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -164,7 +164,7 @@ class DBFSAlgorithmCenGridSpec val firstSlackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(firstSweepNo) - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculations + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculations // we simulate this behaviour now by doing the same for our three inferior grid agents inferiorGrid11.requestSlackVoltage(centerGridAgent, firstSweepNo) @@ -300,7 +300,7 @@ class DBFSAlgorithmCenGridSpec Kilovolts(374.22694614463d), // 380 kV @ 10° Kilovolts(65.9863075134335d), // 380 kV @ 10° ), - ExchangeVoltage( // this one should currently be ignored anyways + ExchangeVoltage( // this one should currently be ignored anyway supNodeA.getUuid, Kilovolts(380d), Kilovolts(0d), @@ -320,7 +320,7 @@ class DBFSAlgorithmCenGridSpec val secondPowerRequestSender13 = inferiorGrid13.expectGridPowerRequest() - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculations + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculations // we simulate this behaviour now by doing the same for our three inferior grid agents inferiorGrid11.requestSlackVoltage(centerGridAgent, secondSweepNo) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala index 7a4b2bce6e..a1047edeff 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala @@ -145,7 +145,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val slackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(sweepNo) - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent inferiorGridAgent.requestSlackVoltage(centerGridAgent, sweepNo) @@ -191,7 +191,7 @@ class DBFSAlgorithmFailedPowerFlowSpec // hence we ask for them and expect a corresponding response superiorGridAgent.requestGridPower(centerGridAgent, sweepNo) - // the requested power is to high for the grid to handle, therefore the superior grid agent + // the requested power is too high for the grid to handle, therefore the superior grid agent // receives a FailedPowerFlow message // wait 30 seconds max for power flow to finish superiorGridAgent.gaProbe.expectMessage(30 seconds, FailedPowerFlow) @@ -229,7 +229,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val slackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(sweepNo) - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent inferiorGridAgent.requestSlackVoltage(centerGridAgent, sweepNo) @@ -341,7 +341,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val powerRequestSender = hvGridAgent.expectGridPowerRequest() - // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent hvGridAgent.requestSlackVoltage(slackGridAgent, sweepNo) diff --git a/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala index 4e37001c11..7f77f7ca77 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala @@ -29,7 +29,7 @@ import org.apache.pekko.actor.testkit.typed.scaladsl.{ import org.slf4j.event.Level /** Logging must be tested in a separate test, since LoggingTestKit can still - * receives logs from test that it was not enabled for + * receive logs from test that it was not enabled for */ class RuntimeEventListenerLoggingSpec extends ScalaTestWithActorTestKit( diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 4d6fff7060..032743fa97 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -104,7 +104,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // CHANGED STATE // discharged to empty (10.0, -9.0, 3600, 0.0, 0.0, 10.0), - // almost discharged to lowest allowed charge + // almost discharged to the lowest allowed charge (10.0, -9.0, 3590, 0.0, -10.0, 10.0), // charged to mid-level charge (41.0, 10.0, 3600, 0.0, -10.0, 10.0), diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala index 6cf1b682d4..1f4761c034 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala @@ -28,7 +28,7 @@ trait SubGridGateMokka extends MockitoSugar { * @param subnet * Sub net number * @return - * [[NodeInput]] with these information + * [[NodeInput]] with this information */ protected def mockNode(uuid: UUID, subnet: Int): NodeInput = { val node = mock[NodeInput] From e3eb74850510d9de1820fab1030ad13733ca1f35 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:58:05 +0100 Subject: [PATCH 091/137] grammar fix it's to its --- docs/readthedocs/models/hp_model.md | 2 +- src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala | 2 +- .../participant/fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/load/LoadAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/event/Event.scala | 2 +- .../edu/ie3/simona/model/grid/TransformerTappingModel.scala | 2 +- .../edu/ie3/simona/service/primary/PrimaryServiceProxy.scala | 2 +- .../scala/edu/ie3/simona/service/weather/WeatherSource.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala | 2 +- .../ie3/simona/test/common/model/grid/SubGridGateMokka.scala | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/readthedocs/models/hp_model.md b/docs/readthedocs/models/hp_model.md index bcc10f3a97..8070e36f36 100644 --- a/docs/readthedocs/models/hp_model.md +++ b/docs/readthedocs/models/hp_model.md @@ -17,6 +17,6 @@ Please refer to {doc}`PowerSystemDataModel - HP Model /* As participant agents always return their last known operation point on request, it is sufficient - * to let a fixed load model determine it's operation point on: + * to let a fixed load model determine its operation point on: * 1) The first tick of the simulation * 2) The tick, it turns on (in time dependent operation) * 3) The tick, it turns off (in time dependent operation) diff --git a/src/main/scala/edu/ie3/simona/event/Event.scala b/src/main/scala/edu/ie3/simona/event/Event.scala index 2efb82b76e..dad24a314f 100644 --- a/src/main/scala/edu/ie3/simona/event/Event.scala +++ b/src/main/scala/edu/ie3/simona/event/Event.scala @@ -7,7 +7,7 @@ package edu.ie3.simona.event /** Trait that should be mixed into each event in [[edu.ie3.simona.event]] to - * provide an easy access to it's name + * provide easy access to its name */ trait Event { diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala index 602259cec2..a8534d7b7b 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala @@ -114,7 +114,7 @@ final case class TransformerTappingModel( * inverted. * * Furthermore, this method also considers the transformer not being able to - * change it's tap position anymore. Hence, 0 is returned, if no change is + * change its tap position anymore. Hence, 0 is returned, if no change is * possible anymore. * * @param vChangeRequest diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala index be9a87fc4d..838608a514 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala @@ -126,7 +126,7 @@ case class PrimaryServiceProxy( } /** Prepare the needed state data by building a - * [[edu.ie3.datamodel.io.source.TimeSeriesMappingSource]], obtain it's + * [[edu.ie3.datamodel.io.source.TimeSeriesMappingSource]], obtain its * information and compile them to state data * * @param primaryConfig diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala index 12a26c3f6c..fbc5af9c1f 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala @@ -424,7 +424,7 @@ object WeatherSource { * coordinates * * @param weighting - * Mapping from weather coordinate to it's weight in averaging + * Mapping from weather coordinate to its weight in averaging */ private[weather] final case class WeightedCoordinates( weighting: Map[Point, Double] diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 535b140798..751dd3fad3 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -46,7 +46,7 @@ trait SetupHelper extends LazyLogging { * Mapping from sub grid number to [[edu.ie3.simona.agent.grid.GridAgent]] * 's [[ActorRef]] * @param gridGates - * [[Set]] of all [[SubGridGate]] s connecting this sub grid with it's + * [[Set]] of all [[SubGridGate]] s connecting this sub grid with its * ancestors and children * @param configRefSystems * Collection of reference systems defined in config diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala b/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala index 238668e67a..137e24a2ce 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala @@ -8,7 +8,7 @@ package edu.ie3.util.scala.quantities import tech.units.indriya.function.DefaultNumberSystem -/** This number system simply delegates the method calls to it's parent class. +/** This number system simply delegates the method calls to its parent class. * The only difference is, that [[BigDecimal]] is transferred to * [[java.math.BigDecimal]] and back upon necessity. Due to its functionality * as an extension of the [[DefaultNumberSystem]] it CANNOT be an object! diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala index 1f4761c034..d3ab3e97b3 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala @@ -21,7 +21,7 @@ import org.scalatestplus.mockito.MockitoSugar */ trait SubGridGateMokka extends MockitoSugar { - /** Mocks a node with it's basic needed information + /** Mocks a node with its basic needed information * * @param uuid * Unique identifier of the node From 8467fb64ef726e51f782bc5fdc287fadef28fbe2 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:51:51 +0100 Subject: [PATCH 092/137] adding some commas --- docs/readthedocs/models/two_winding_transformer_model.md | 2 +- src/main/scala/edu/ie3/simona/agent/ValueStore.scala | 2 +- src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala | 2 +- .../scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala | 2 +- .../edu/ie3/simona/agent/participant/ParticipantAgent.scala | 2 +- .../agent/participant/ParticipantAgentFundamentals.scala | 4 ++-- .../scala/edu/ie3/simona/io/result/plain/PlainResult.scala | 4 ++-- src/main/scala/edu/ie3/simona/model/grid/GridModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/StorageModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- .../edu/ie3/simona/model/participant/control/QControl.scala | 2 +- .../scala/edu/ie3/simona/service/weather/WeatherService.scala | 4 ++-- .../scala/edu/ie3/simona/service/weather/WeatherSource.scala | 2 +- src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- src/main/scala/edu/ie3/util/scala/ReflectionTools.scala | 2 +- .../edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala | 2 +- .../edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala | 4 ++-- .../ie3/simona/integration/common/IntegrationSpecCommon.scala | 2 +- .../edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/readthedocs/models/two_winding_transformer_model.md b/docs/readthedocs/models/two_winding_transformer_model.md index eac989c18d..768785aaaf 100644 --- a/docs/readthedocs/models/two_winding_transformer_model.md +++ b/docs/readthedocs/models/two_winding_transformer_model.md @@ -32,7 +32,7 @@ When the load flow calculation asks for the values with regard to the low voltag 3. Main field resistance: $R_{M,LV} = \frac{R_{M}}{\gamma^{2}}$ 4. Main field reactance: $X_{M,LV} = \frac{X_{M}}{\gamma^{2}}$ -Finally all values are delivered as per unit-values and ready to use in the fundamental $\pi$circuit: +Finally, all values are delivered as per unit-values and ready to use in the fundamental $\pi$circuit: 1. Short circuit conductance: $g_{ij} = \frac{Z_{Ref}}{R_{SC}}$ 2. Short circuit susceptance: $b_{ij} = \frac{Z_{Ref}}{X_{SC}}$ diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index a21f7d0f58..a1a1190861 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -129,7 +129,7 @@ object ValueStore { def forResult[D](maxTickSpan: Long, multiplier: Long): ValueStore[D] = new ValueStore[D](maxTickSpan * multiplier) - /** Updates the value store. Additionally the size of the store is limited to + /** Updates the value store. Additionally, the size of the store is limited to * it's defined maximum capacity. Therefore, the oldest entries are removed. * * @param valueStore diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala index 9cd9070de8..cb8a73294d 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala @@ -260,7 +260,7 @@ object EmDataCore { awaitedConnectedAgents.excl(flexOptions.modelUuid), ) - /** Checks whether all awaited flex options have been received and we can + /** Checks whether all awaited flex options have been received, and we can * continue by calculating flex control. This method does not change the * state of the [[AwaitingFlexOptions]] data core. * @return diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index 55ea126136..8d6d4adcfe 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -495,7 +495,7 @@ private[grid] trait GridResultsSupport { /** Calculate the current magnitude and the current angle in physical units * based on a provided electric current in p.u. and the nominal referenced * electric current. The arctangent "only" calculates the angle between the - * complex current and it's real part. This means, that i = (i_real, i_imag) + * complex current, and it's real part. This means, that i = (i_real, i_imag) * and i' = (-i_real, -i_imag) will lead to the same angle. However, for * power system simulation, the absolute orientation in the complex plane * with regard to the positive real axis is of interest. Therefore, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 19a18c60c7..56f992b0f8 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -149,7 +149,7 @@ abstract class ParticipantAgent[ Activation(tick), modelBaseStateData: ParticipantModelBaseStateData[PD, CD, MS, M], ) if modelBaseStateData.services.isEmpty => - /* An activity start trigger is sent and no data is awaited (neither secondary nor primary). Therefore go straight + /* An activity start trigger is sent and no data is awaited (neither secondary nor primary). Therefore, go straight * ahead to calculations */ /* Hold tick, as state transition is needed */ 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 536dc8d412..3435057ae0 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -1071,7 +1071,7 @@ protected trait ParticipantAgentFundamentals[ false } - // If we're completing initialization and we're EM-managed: + // If we're completing initialization, and we're EM-managed: // There is no new tick for the scheduler, // since we are activated by the EmAgent from now on scheduler ! Completion( @@ -1476,7 +1476,7 @@ protected trait ParticipantAgentFundamentals[ determineTickWindow(requestTick, requestValueStore) /* All participants simulation results between the most recent simulation tick BEFORE or at the beginning of the - * averaging window and it's end (both including) are relevant for averaging the simulated primary data */ + * averaging window, and it's end (both including) are relevant for averaging the simulated primary data */ val firstRelevantTick = determineFirstRelevantTick( averagingWindowStart, resultValueStore, diff --git a/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala b/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala index c85cd167af..4a9e9a4c8d 100644 --- a/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala +++ b/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala @@ -10,8 +10,8 @@ import java.util.UUID /** Results that are sent out with Kafka and avro should use this trait and * corresponding implementing classes, since these give more control over - * attribute types and naming and they include sim run id. Plain result objects - * can be created by [[PlainWriter]]. + * attribute types and naming, and they include sim run id. Plain result + * objects can be created by [[PlainWriter]]. */ sealed trait PlainResult diff --git a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala index 25cee7edcf..16285b9317 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala @@ -194,7 +194,7 @@ object GridModel { /* Nodes that are connected via a [closed] switch map to the same idx as we fuse them during the power flow. - Therefore the admittance matrix has to be of the size of the distinct node idxs. + Therefore, the admittance matrix has to be of the size of the distinct node idxs. */ val linesAdmittanceMatrix = buildAssetAdmittanceMatrix( nodeUuidToIndexMap, diff --git a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala index 02f82d2670..336eef1979 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala @@ -52,7 +52,7 @@ final case class StorageModel( /** Tolerance for power comparisons. With very small (dis-)charging powers, * problems can occur when calculating the future tick at which storage is * full or empty. For sufficiently large time frames, the maximum Long value - * ([[Long.MaxValue]]) can be exceeded, thus the Long value overflows and we + * ([[Long.MaxValue]]) can be exceeded, thus the Long value overflows, and we * get undefined behavior. * * Thus, small (dis-)charging powers compared to storage capacity have to be diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index bffdd7fdae..b661d98948 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -146,7 +146,7 @@ final case class WecModel( ) } - /** The coefficient is dependent on the wind velocity v. Therefore use v to + /** The coefficient is dependent on the wind velocity v. Therefore, use v to * determine the betz coefficient cₚ. * * @param windVelocity diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index 25504c2fff..391d4bca7c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -50,7 +50,7 @@ sealed trait QControl { ): Power => ReactivePower } -/** Object to create a [[QControl]]. Currently the following QControls +/** Object to create a [[QControl]]. Currently, the following QControls * characteristics are supported. * - cosine-Phi-Fixed * - cosine-Phi(P) diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala index 4092a2850f..a31a217eb0 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala @@ -269,7 +269,7 @@ final case class WeatherService( serviceStateData case _ => - // actor is not registered and we don't have data for it + // actor is not registered, and we don't have data for it // inform the agentToBeRegistered that the registration failed as we don't have data for it agentToBeRegistered ! RegistrationFailedMessage(self) serviceStateData @@ -303,7 +303,7 @@ final case class WeatherService( // get the weather and send it to the subscribed agents // no sanity check needed here as we can assume that we always have weather available - // when we announce it. Otherwise the registration would have failed already! + // when we announce it. Otherwise, the registration would have failed already! updatedStateData.weatherSource .getWeather(tick, updatedStateData.weightedWeatherCoordinates) .foreach { case coordinate -> weatherResult => diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala index fbc5af9c1f..8cf874a885 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala @@ -165,7 +165,7 @@ trait WeatherSource { val weightMap = nearestCoordinates .map(coordinateDistance => { /* Maybe some words on the calculus of the weight here: We intend to have a weight, that linear increases - * from zero to one, the closer the coordinate is to the coordinate in question. Therefore we calculate the + * from zero to one, the closer the coordinate is to the coordinate in question. Therefore, we calculate the * proximity of each node as a linear function between 1 at 0m distance to the questioned coordinate to zero * at the sum of all coordinates' distances (1 - d / d_sum). However, summing up this proximity over all * n coordinates brings n*1 from the left part of the sum and -1 as the sum of all distances shares. diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 0212ad124e..3c1028be2b 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -28,7 +28,7 @@ import scala.jdk.OptionConverters.RichOptional /** Represents the output directory where the results will be materialized. If * new directories are added please remember to add them to the dirsToBeCreated - * Vector if they should be created. Otherwise they will not be created! + * Vector if they should be created. Otherwise, they will not be created! * * @version 0.1 * @since 12.01.20 diff --git a/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala b/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala index 6ed62dc580..be6df1b955 100644 --- a/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala +++ b/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala @@ -47,7 +47,7 @@ object ReflectionTools { * @tparam A * type of the object * @return - * a map containing the field method and it's value of the object instance + * a map containing the field method, and it's value of the object instance */ def classFieldToVal[A](a: A)(implicit tt: TypeTag[A], diff --git a/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala b/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala index e63ec421f5..82ed0b58bc 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala @@ -45,7 +45,7 @@ final class SpecificHeatCapacity private ( ) /** Calculates the Energy of a medium with a given specific heat capacity - * based on the temperature delta and it's volume. + * based on the temperature delta, and it's volume. * @param temperatureA * First temperature of the medium (e.g. inlet temperature) * @param temperatureB diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index 59a32256d2..8d23af9c46 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -41,8 +41,8 @@ import scala.language.postfixOps * be able to do if the DBFSAlgorithm is used. The scheduler, the weather * service as well as the inferior and superior [[GridAgent]] s are simulated * by the TestKit. By now this test does NOT cover interactions with generation - * or load asset agents due to unavailability during test development. Hence it - * would make sense to extend this test in the future to include asset agent + * or load asset agents due to unavailability during test development. Hence, + * it would make sense to extend this test in the future to include asset agent * interaction or cover this behaviour by another (integration) test! */ class DBFSAlgorithmCenGridSpec diff --git a/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala b/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala index eeb0804f77..f98abfd663 100644 --- a/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala +++ b/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala @@ -10,7 +10,7 @@ trait IntegrationSpecCommon { /* ATTENTION: Do not change this file to a path within "input". If you come to this point because the CI * or some of your tests are failing you very likely have altered the vn_simona.conf. This config although - * is NOT meant to be altered. Instead you should always use a delta config and only override the values and + * is NOT meant to be altered. Instead, you should always use a delta config and only override the values and * files of vn_simona/vn_simona.conf. Delta configs can be created by including the config you want to change * parameters from via include (e.g. include "input/samples/vn_simona/vn_simona.conf") at the * beginning of your config file and then just override the parameters you want to change! */ diff --git a/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala b/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala index 4a4834fff9..2a90b1432d 100644 --- a/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala @@ -43,7 +43,7 @@ class ProportionalFlexStratSpec * * Specifically, we use 40% of the flex potential 2 kW - 1 kW = 1 kW of * the first unit and 40% of the flex potential 4 kW - 0 kW = 4 kW of the - * second unit. Thus we arrive at 1 kW + 40% * 1 kW = 1.4 kW for the + * second unit. Thus, we arrive at 1 kW + 40% * 1 kW = 1.4 kW for the * first unit and 0 kW + 40% * 4 kW = 1.6 kW for the second unit. */ From 1cb082409561029fedc0695c0dad6845dfdca405 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:45:12 +0100 Subject: [PATCH 093/137] provide a second dot for all e.g. --- src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala | 2 +- .../edu/ie3/simona/agent/participant/ParticipantAgent.scala | 4 ++-- .../agent/participant/ParticipantAgentFundamentals.scala | 4 ++-- .../simona/agent/participant/evcs/EvcsAgentFundamentals.scala | 2 +- .../fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/load/LoadAgentFundamentals.scala | 2 +- .../ie3/simona/agent/participant/pv/PvAgentFundamentals.scala | 2 +- .../simona/agent/participant/wec/WecAgentFundamentals.scala | 2 +- .../ie3/simona/agent/participant/ParticipantAgentMock.scala | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala index f02d7c36b1..c9bca30ce1 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala @@ -57,7 +57,7 @@ object GridAgent extends DBFSAlgorithm { // val initialization val resolution: Long = simonaConfig.simona.powerflow.resolution.get( ChronoUnit.SECONDS - ) // this determines the agents regular time bin it wants to be triggered e.g one hour + ) // this determines the agents regular time bin it wants to be triggered e.g. one hour val simStartTime: ZonedDateTime = TimeUtil.withDefaults .toZonedDateTime(simonaConfig.simona.time.startDateTime) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 56f992b0f8..d04e6b5154 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -493,7 +493,7 @@ abstract class ParticipantAgent[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different @@ -533,7 +533,7 @@ abstract class ParticipantAgent[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different 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 3435057ae0..949fb76f18 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -157,7 +157,7 @@ protected trait ParticipantAgentFundamentals[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different @@ -244,7 +244,7 @@ protected trait ParticipantAgentFundamentals[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala index 69b072e55b..8894a511ff 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala @@ -96,7 +96,7 @@ protected trait EvcsAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index da81883206..233246ca81 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -92,7 +92,7 @@ protected trait FixedFeedInAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 48818d1477..7de29efddf 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -103,7 +103,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index d1e441e4b4..52f0a76e24 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -94,7 +94,7 @@ protected trait PvAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala index 9edf6f2ae8..5b43263925 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala @@ -89,7 +89,7 @@ protected trait WecAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index 300bfb7e79..4224fc3ff4 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -175,7 +175,7 @@ class ParticipantAgentMock( * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g one hour + * Agents regular time bin it wants to be triggered e.g. one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different From f8c0b342e568b203713bd4acd0a809e10618629a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 09:36:14 +0100 Subject: [PATCH 094/137] add some hyphens --- docs/readthedocs/models/load_model.md | 2 +- .../edu/ie3/simona/agent/grid/PowerFlowSupport.scala | 2 +- .../ie3/simona/agent/participant/ParticipantAgent.scala | 2 +- .../agent/participant/ParticipantAgentFundamentals.scala | 6 +++--- .../agent/participant/load/LoadAgentFundamentals.scala | 4 ++-- src/main/scala/edu/ie3/simona/model/SystemComponent.scala | 2 +- src/main/scala/edu/ie3/simona/model/grid/LineModel.scala | 2 +- src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala | 2 +- .../scala/edu/ie3/simona/model/grid/SwitchModel.scala | 2 +- .../edu/ie3/simona/model/grid/Transformer3wModel.scala | 2 +- .../edu/ie3/simona/model/grid/TransformerModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/BMModel.scala | 4 ++-- .../ie3/simona/model/participant/FixedFeedInModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 2 +- .../ie3/simona/model/participant/SystemParticipant.scala | 2 +- .../scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- .../edu/ie3/simona/model/participant/evcs/EvcsModel.scala | 2 +- .../simona/model/participant/load/FixedLoadModel.scala | 2 +- .../model/participant/load/profile/LoadProfileStore.scala | 6 +++--- .../model/participant/load/profile/ProfileLoadModel.scala | 2 +- .../model/participant/load/profile/TypeDayProfile.scala | 4 ++-- .../model/participant/load/random/RandomLoadModel.scala | 2 +- .../participant/load/random/RandomLoadParamStore.scala | 4 ++-- .../model/participant/load/random/TypeDayParameters.scala | 8 ++++---- .../scala/edu/ie3/simona/model/thermal/ThermalHouse.scala | 2 +- .../scala/edu/ie3/simona/model/thermal/ThermalSink.scala | 2 +- .../edu/ie3/simona/model/thermal/ThermalStorage.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/Irradiance.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/Irradiation.scala | 2 +- .../simona/agent/participant/ParticipantAgentMock.scala | 2 +- .../model/participant/load/LoadProfileStoreSpec.scala | 8 ++++---- .../model/participant/load/RandomLoadModelSpec.scala | 2 +- 33 files changed, 47 insertions(+), 47 deletions(-) diff --git a/docs/readthedocs/models/load_model.md b/docs/readthedocs/models/load_model.md index be2046d717..798a8b5e97 100644 --- a/docs/readthedocs/models/load_model.md +++ b/docs/readthedocs/models/load_model.md @@ -132,7 +132,7 @@ F_t = -3.92 \cdot 10^{-10} \cdot t^4 + 3.2 \cdot 10^{-7} \cdot t + 1.24 $$ -The factor $F_t$, after calculation, shall be rounded to four decimal places. After multiplication with the profile value for given quarter hour, the result should again be rounded to one decimal place. +The factor $F_t$, after calculation, shall be rounded to four decimal places. After multiplication with the profile value for given quarter-hour, the result should again be rounded to one decimal place. #### Maximum value diff --git a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala index 50a785af8d..c43700466c 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala @@ -369,7 +369,7 @@ trait PowerFlowSupport { * from a [[ValidNewtonRaphsonPFResult]] * * @param validResult - * the result that should be converted to a human readable debug string + * the result that should be converted to a human-readable debug string * @param gridModel * the grid model this result comes from * @return diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index d04e6b5154..19eff90211 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -835,7 +835,7 @@ abstract class ParticipantAgent[ )(implicit outputConfig: NotifierConfig): Unit /** Abstract definition to clean up agent value stores after power flow - * convergence. This is necessary for agents whose results are time dependent + * convergence. This is necessary for agents whose results are time-dependent * e.g. storage agents * * @param baseStateData 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 949fb76f18..5c1c484163 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -368,7 +368,7 @@ protected trait ParticipantAgentFundamentals[ operationStart: Long, operationEnd: Long, ): SortedSet[Long] = { - /* The profile load model holds values in the specified resolution (e.g. for each full quarter hour (00:00, + /* The profile load model holds values in the specified resolution (e.g. for each full quarter-hour (00:00, * 00:15, ...)). As the simulation might not start at an integer multiple of the resolution, we have to * determine, what the first tick is, in which profile information do exist */ val firstProfileTick = @@ -1245,7 +1245,7 @@ protected trait ParticipantAgentFundamentals[ nodalVoltage, lastNodalVoltage, ).getOrElse { - /* If a fast reply is not possible, determine it the old fashioned way */ + /* If a fast reply is not possible, determine it the old-fashioned way */ determineReply( requestTick, baseStateData, @@ -1852,7 +1852,7 @@ protected trait ParticipantAgentFundamentals[ } /** To clean up agent value stores after power flow convergence. This is - * necessary for agents whose results are time dependent e.g. storage agents + * necessary for agents whose results are time-dependent e.g. storage agents * * @param baseStateData * Basic state data diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 7de29efddf..f7cb1d695e 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -147,8 +147,8 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ /* As participant agents always return their last known operation point on request, it is sufficient * to let a fixed load model determine its operation point on: * 1) The first tick of the simulation - * 2) The tick, it turns on (in time dependent operation) - * 3) The tick, it turns off (in time dependent operation) + * 2) The tick, it turns on (in time-dependent operation) + * 3) The tick, it turns off (in time-dependent operation) * Coinciding ticks are summarized and the last tick is removed, as the change in operation status * doesn't affect anything then */ SortedSet[Long]( diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index 6553faab08..efc70ba0cf 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -28,7 +28,7 @@ import scala.util.{Failure, Success, Try} * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala index 60a2621630..7c643a2298 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala @@ -28,7 +28,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param nodeAUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala b/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala index 506ea804a1..af26beb12b 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala @@ -23,7 +23,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param isSlack diff --git a/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala b/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala index 5a5a457a5f..8a947e9ee0 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala @@ -22,7 +22,7 @@ import scala.util.{Failure, Success, Try} * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param nodeAUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala b/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala index 8f61c2a897..46ce7f3e44 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala @@ -49,7 +49,7 @@ import scala.math.BigDecimal.RoundingMode * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param hvNodeUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala index ee03ef837a..81682693fc 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala @@ -33,7 +33,7 @@ import scala.math.BigDecimal.RoundingMode * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param hvNodeUuid diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index 19fbe3e601..e1c9ed715a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -94,7 +94,7 @@ final case class BMModel( applyLoadGradient(pEl) } - /** Calculates first time dependent factor for heat demand + /** Calculates first time-dependent factor for heat demand * @param time * the time * @return @@ -114,7 +114,7 @@ final case class BMModel( } } - /** Calculates second time dependent factor for heat demand + /** Calculates second time-dependent factor for heat demand * @param time * the time * @return diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index dbda236e4c..d5cd82c731 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -29,7 +29,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index bf26b80fd8..993bc276c4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -34,7 +34,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala index 44c70539d7..f245923356 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala @@ -30,7 +30,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index b661d98948..4ecc4e5b5b 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -41,7 +41,7 @@ import scala.collection.SortedSet * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index b703304893..f0a6a34988 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -47,7 +47,7 @@ import scala.collection.immutable.SortedSet * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param simulationStartDate diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala index d1ab4bd657..cc4bc82c65 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala @@ -28,7 +28,7 @@ import java.util.UUID * @param uuid * unique identifier * @param id - * human readable id + * human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index f1e7d54f62..63e4a0d4a5 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -45,7 +45,7 @@ class LoadProfileStore private (val reader: Reader) { ) /** Returns the load profiles entry (average power consumption for the - * following quarter hour) for given time and load profile. + * following quarter-hour) for given time and load profile. * * @param time * the requested time @@ -77,7 +77,7 @@ class LoadProfileStore private (val reader: Reader) { } } - /** Returns the maximum average power consumption per quarter hour for a given + /** Returns the maximum average power consumption per quarter-hour for a given * load profile, calculated over all seasons and weekday types of given load * profile * @@ -171,7 +171,7 @@ object LoadProfileStore extends LazyLogging { val headerKeys: util.List[String] = parser.getHeaderNames - // skip last column "quarter hour" + // skip last column "quarter-hour" (for (i <- Range(0, headerKeys.size() - 1)) yield { val headerKey = headerKeys.get(i) val profileKey = LoadProfileKey(headerKey) diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala index 5e919a0064..e94f50867f 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala @@ -25,7 +25,7 @@ import java.util.UUID * @param uuid * unique identifier * @param id - * human readable id + * human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala index dd2fcb6a18..22358772b1 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala @@ -26,8 +26,8 @@ final case class TypeDayProfile(private val values: Array[Double]) { "You may only instantiate type day parameters with 96 values." ) - /** Returns a value for given time. If time is not a 15 min step, it is - * rounded up to the next 15 min slice. + /** Returns a value for given time. If time is not a 15-min step, it is + * rounded up to the next 15-min slice. * * @param time * the time diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index a09e9bc8ff..4409d62cf2 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -33,7 +33,7 @@ import scala.util.Random * @param uuid * unique identifier * @param id - * human readable id + * human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala index 195b40a4a3..33fb57a38a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala @@ -105,7 +105,7 @@ case object RandomLoadParamStore extends LazyLogging { } catch { case e: FileIOException => throw new FileIOException( - s"Cannot determine random load parameters for day type '$dayType' and quarter hour '$quartHour'", + s"Cannot determine random load parameters for day type '$dayType' and quarter-hour '$quartHour'", e, ) } @@ -115,7 +115,7 @@ case object RandomLoadParamStore extends LazyLogging { case (_, quarterHour, randomLoadParameters) => (quarterHour, randomLoadParameters) } // Group entries by day type - .map { // For each day type, sort the parameters by quarter hour and build a type day parameter object from it + .map { // For each day type, sort the parameters by quarter-hour and build a type day parameter object from it case (dayType, quarterHourToParameters) => dayType -> TypeDayParameters( quarterHourToParameters.sortBy(_._1).map(_._2).toArray diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala index 36360ff600..57210c68b2 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala @@ -12,8 +12,8 @@ import edu.ie3.simona.model.participant.load.DayType import edu.ie3.util.TimeUtil /** Stores a slice of random load parameters, that comprises a whole day (96 - * quarter hours). The data describes a typical day, that can unequivocally be - * identified by it's [[DayType]]. + * quarter-hours). The data describes a typical day, that can unequivocally be + * identified by its [[DayType]]. * * @param values * 96 quarter-hour values for this day type @@ -26,8 +26,8 @@ final case class TypeDayParameters( s"You may only instantiate type day parameters with 96 values. Apparent: ${values.length}." ) - /** Returns a value for given time. If time is not a 15 min step, it is - * rounded up to the next 15 min slice. + /** Returns a value for given time. If time is not a 15-min step, it is + * rounded up to the next 15-min slice. * * @param time * the time 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 71e992c4e0..ae933f3f03 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -37,7 +37,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala index 97661b0201..2b70983c73 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala @@ -17,7 +17,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalBusInput * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala index 5886a4e7f8..c7818351b6 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala @@ -19,7 +19,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 751dd3fad3..d5b21a99a7 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -37,7 +37,7 @@ trait SetupHelper extends LazyLogging { /** Build the [[GridAgentInitData]]. This also includes the determination of a * mapping from [[SubGridGate]] to [[ActorRef]] of the representing - * [[edu.ie3.simona.agent.grid.GridAgent]] as well as the look up of the + * [[edu.ie3.simona.agent.grid.GridAgent]] as well as the look-up of the * [[RefSystem]] to use being defined in the config. * * @param subGridContainer diff --git a/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala b/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala index 2ad522980e..7476cbe225 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala @@ -31,7 +31,7 @@ final class Irradiance private (val value: Double, val unit: IrradianceUnit) def *(that: Area): Power = Watts( this.toWattsPerSquareMeter * that.toSquareMeters ) - // the Hours(1).toSeconds is to convert watt hours to watt seconds which + // the Hours(1).toSeconds is to convert watt-hours to watt-seconds which // isn't a normal supported type in Squants def *(that: AreaTime): Energy = WattHours( this.toWattsPerSquareMeter * that.toSquareMeterSeconds / Hours(1).toSeconds diff --git a/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala b/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala index 5b685fde7e..306d2c11f5 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala @@ -22,7 +22,7 @@ final class Irradiation private (val value: Double, val unit: IrradiationUnit) def *(that: Area): Energy = WattHours( this.toWattHoursPerSquareMeter * that.toSquareMeters ) - // the Hours(1).toSeconds is to convert watt hours to watt seconds which + // the Hours(1).toSeconds is to convert watt-hours to watt-seconds which // isn't a normal supported type in Squants def /(that: Time): Irradiance = WattsPerSquareMeter( diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index 4224fc3ff4..8087993f01 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -311,7 +311,7 @@ class ParticipantAgentMock( FixedRelevantData /** To clean up agent value stores after power flow convergence. This is - * necessary for agents whose results are time dependent e.g. storage agents + * necessary for agents whose results are time-dependent e.g. storage agents * @param baseStateData * Basic state data * @param currentTick diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala index 64701fa993..358da83a31 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala @@ -49,22 +49,22 @@ class LoadProfileStoreSpec "2019-04-01T05:00:00+02:00[Europe/Berlin]", L0, 55.6d, - ), // Weekday, transitional, 20th quarter hour + ), // Weekday, transitional, 20th quarter-hour ( "2019-06-02T00:00:00+02:00[Europe/Berlin]", G0, 68.8d, - ), // Sunday, summer, 0th quarter hour + ), // Sunday, summer, 0th quarter-hour ( "2019-01-05T02:15:00+01:00[Europe/Berlin]", H0, 52.8d, - ), // Saturday, winter, 9th quarter hour, 5th day -> dynamization factor 1.2473 + ), // Saturday, winter, 9th quarter-hour, 5th day -> dynamization factor 1.2473 ( "2019-07-21T01:00:00+02:00[Europe/Berlin]", H0, 58.1d, - ), // Sunday, summer, 4th quarter hour, 202nd day -> dynamization factor 0.7847 + ), // Sunday, summer, 4th quarter-hour, 202nd day -> dynamization factor 0.7847 ) forAll(params) { diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala index 82fa1041e5..08457fc4c8 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala @@ -112,7 +112,7 @@ class RandomLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { loadInput.getCosPhiRated, ActivePower(Watts(268.6)), ) - /* Working day, 61th quarter hour */ + /* Working day, 61st quarter-hour */ val queryDate = TimeUtil.withDefaults.toZonedDateTime("2019-07-19T15:21:00Z") val expectedParams = new RandomLoadParameters( From 06baf0526f1be3896cf72e3d6ae86107da5972cc Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:56:37 +0100 Subject: [PATCH 095/137] more grammar --- CHANGELOG.md | 2 +- docs/readthedocs/models/chp_model.md | 2 +- docs/readthedocs/models/cts_model.md | 2 +- .../ie3/simona/agent/grid/DBFSAlgorithm.scala | 28 +++++++++---------- .../ie3/simona/config/ConfigFailFast.scala | 8 +++--- .../simona/model/participant/ChpModel.scala | 2 +- .../simona/model/system/Characteristic.scala | 2 +- .../thermal/CylindricalThermalStorage.scala | 2 +- .../edu/ie3/simona/util/CollectionUtils.scala | 2 +- .../edu/ie3/simona/util/ConfigUtil.scala | 4 +-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b683cd1327..04377de7c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -224,7 +224,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for three winding transformers [#63](https://github.com/ie3-institute/simona/issues/63) - Handle incoming slack voltage accordingly - Allow multiple sub grid gates at one node (also allows multiple two winding transformers at one node) - - Perform power flow calculation in highest grid, if a three winding transformer is apparent + - Perform power flow calculation in the highest grid, if a three winding transformer is apparent - Write out results - Fixed broken layout in RTD documentation [#500](https://github.com/ie3-institute/simona/issues/500) - Corrected tests in RefSystemTest [#560](https://github.com/ie3-institute/simona/issues/560) diff --git a/docs/readthedocs/models/chp_model.md b/docs/readthedocs/models/chp_model.md index c5f01364bf..d7eb8232eb 100644 --- a/docs/readthedocs/models/chp_model.md +++ b/docs/readthedocs/models/chp_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the CHP Model (combined heat and power ## Assumptions -The CHP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the CHP unit does not posses a memory. Losses of the heat storage are not considered. +The CHP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the CHP unit does not possess a memory. Losses of the heat storage are not considered. ## Parameters diff --git a/docs/readthedocs/models/cts_model.md b/docs/readthedocs/models/cts_model.md index 5750820624..e03fa06563 100644 --- a/docs/readthedocs/models/cts_model.md +++ b/docs/readthedocs/models/cts_model.md @@ -3,7 +3,7 @@ This page documents the functionality of the cylindrical thermal storage available in SIMONA. ## Behaviour -This storage model operates on volumes, although the functions it provides for other models all operate with energy. Internally the storage model converts energy to volume and vice versa with formulas specified below. Furthermore it is assumed that the storage medium is water. Also the model holds a variable for the current storage level. +This storage model operates on volumes, although the functions it provides for other models all operate with energy. Internally the storage model converts energy to volume and vice versa with formulas specified below. Furthermore, it is assumed that the storage medium is water. Also, the model holds a variable for the current storage level. ## Attributes, Units and Remarks diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 5f21b06a39..a3d54a7d7a 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -197,7 +197,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { case None => // this happens if this agent is either a) the superior grid agent, because it will always get a request for // the next sweep, as it triggers calculations for the next sweep or b) at all other - // (non last downstream grid agents) in sweep 0 + // (non-last downstream grid agents) in sweep 0 ctx.log.debug( "Unable to find slack voltage for nodes '{}' in sweep '{}'. Try to get voltage of previous sweep.", nodeUuids, @@ -386,7 +386,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { // update the sweep value store and clear all received maps // note: normally it is expected that this has to be done after power flow calculations but for the sake - // of having it only once in the code we put this here. Otherwise it would have to been put before EVERY + // of having it only once in the code we put this here. Otherwise, it would have to be put before EVERY // return with a valid power flow result (currently happens already in two situations) val updatedGridAgentBaseData = if (stillPendingRequestAnswers.isEmpty) { @@ -955,13 +955,13 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { } } - /** Checks if all data has been received and if yes checks if the there are - * any failed power flow indications from inferior grids. If both == true, - * then no [[Behavior]] change is triggered but the sweep value store is - * updated with a [[FailedPowerFlow]] information as well, the now used data - * is set to [[PowerFlowDoneData]] and this is escalated to the superior - * grid(s). If there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a - * behavior transition to [[handlePowerFlowCalculations]] is triggered. + /** Checks if all data has been received and if yes checks if there are any + * failed power flow indications from inferior grids. If both == true, then + * no [[Behavior]] change is triggered but the sweep value store is updated + * with a [[FailedPowerFlow]] information as well, the now used data is set + * to [[PowerFlowDoneData]] and this is escalated to the superior grid(s). If + * there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a behavior + * transition to [[handlePowerFlowCalculations]] is triggered. * * If allReceived == false, no [[Behavior]] transition is triggered * @@ -1023,11 +1023,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { /** Normally only reached by the superior (dummy) agent! * - * Checks if all data has been received and if yes checks if the there are - * any failed power flow indications from inferior grids. If both == true, - * then a finish simulation is triggered and depending on the configuration - * this step is skipped and the simulation goes on or this leads to a - * termination of the simulation due to a failed power flow calculation. + * Checks if all data has been received and if yes checks if there are any + * failed power flow indications from inferior grids. If both == true, then a + * finish simulation is triggered and depending on the configuration this + * step is skipped and the simulation goes on or this leads to a termination + * of the simulation due to a failed power flow calculation. * * If there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a * [[Behavior]] transition to [[checkPowerDifferences]] is triggered. diff --git a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala index 3437944c78..8192814ae3 100644 --- a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala +++ b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala @@ -314,8 +314,8 @@ case object ConfigFailFast extends LazyLogging { ) } - /** Check participants's basic runtime configurations, as well as in default - * as in individual configs. This comprises + /** Check participants' basic runtime configurations, as well as in default as + * in individual configs. This comprises * i.e. uuid and scaling factor */ private def checkBaseRuntimeConfigs( @@ -663,7 +663,7 @@ case object ConfigFailFast extends LazyLogging { } - /** Check the config sub tree for output parameterization + /** Check the config subtree for output parameterization * * @param subConfig * Output sub config tree for participants @@ -685,7 +685,7 @@ case object ConfigFailFast extends LazyLogging { checkIndividualOutputConfigs(subConfig.individualConfigs) } - /** Check the config sub tree for output parameterization + /** Check the config subtree for output parameterization * * @param subConfig * Output sub config tree for participants diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 5af1b68236..795c62c9f8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -31,7 +31,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala b/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala index 2088ca6cdc..e4b7758b8f 100644 --- a/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala +++ b/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala @@ -14,7 +14,7 @@ import squants.Quantity import scala.collection.SortedSet import scala.reflect.ClassTag -/** Describes a mapping of a x-y-pairs with possibility to interpolate the y +/** Describes a mapping of an x-y-pairs with possibility to interpolate the y * values based on the provided x value */ trait Characteristic[A <: Quantity[A], O <: Quantity[O]] { diff --git a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala index fedea75204..8cde5ab086 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala @@ -40,7 +40,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human readable id + * the element's human-readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala index 6402ea7b2a..c5e2b45beb 100644 --- a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala +++ b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala @@ -98,7 +98,7 @@ object CollectionUtils { * smallest map key is provided. * * @param map - * containing containing the (k,v) pairs (e.g. x,y pairs) + * containing the (k,v) pairs (e.g. x,y pairs) * @param key * the key values are needed for * @return diff --git a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala index f32b66ed5f..a91ff99924 100644 --- a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala +++ b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala @@ -73,7 +73,7 @@ object ConfigUtil { * participants config for faster access. * * @param subConfig - * Configuration sub tree for the behaviour of system participants + * Configuration subtree for the behaviour of system participants * @return * a matching config utility */ @@ -124,7 +124,7 @@ object ConfigUtil { * @param defaultConfig * Default config to use, when there is no specific one * @param configs - * Mapping from notifier identifier to it's notifier configuration + * Mapping from notifier identifier to its notifier configuration */ final case class OutputConfigUtil( private val defaultConfig: NotifierConfig, From a5bf81201622539a0815ea9a2bd1e05ff9615401 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:54:45 +0100 Subject: [PATCH 096/137] adding some commas --- src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 4 ++-- .../simona/agent/participant/statedata/BaseStateData.scala | 2 +- .../simona/test/common/model/grid/BasicGridWithSwitches.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index a3d54a7d7a..f2fdc716f4 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -737,7 +737,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { gridAgentBaseData.powerFlowParams.sweepTimeout, )(ctx) - // when we don't have inferior grids and no assets both methods return None and we can skip doing another power + // when we don't have inferior grids and no assets both methods return None, and we can skip doing another power // flow calculation otherwise we go back to simulate grid and wait for the answers if (!askForAssetPowersOpt && !askForInferiorGridPowersOpt) { ctx.log.debug( @@ -832,7 +832,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { ) /* Regarding the power flow result of this grid, there are two cases. If this is the "highest" grid in a - * simulation without a three winding transformer, the grid consists of only one node and we can mock the power + * simulation without a three winding transformer, the grid consists of only one node, and we can mock the power * flow results. If there is a three winding transformer apparent, we actually have to perform power flow * calculations, as the high voltage branch of the transformer is modeled here. */ (if (gridModel.gridComponents.transformers3w.isEmpty) { diff --git a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala index 96758a2d16..9627ee1578 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala @@ -51,7 +51,7 @@ trait BaseStateData[+PD <: PrimaryDataWithApparentPower[PD]] */ val modelUuid: UUID - /** By default the agent should be triggered in the same tick, where data is + /** By default, the agent should be triggered in the same tick, where data is * incoming from primary or secondary sources. However, if there is no other * information needed, we might have the need to schedule ourselves for * activation triggers diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala index bd709daa01..5781848e1b 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala @@ -20,7 +20,7 @@ import tech.units.indriya.quantity.Quantities import java.util.UUID -/** Note: the line parameters are NOT adapted. Instead the line params from +/** Note: the line parameters are NOT adapted. Instead, the line params from * [[FiveLinesWithNodes]] are used instead! * * {{{ From 2236f41ab982c77919a924e6c07be80f3a7e6d7a Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 08:52:30 +0100 Subject: [PATCH 097/137] using past participle --- .../scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index f2fdc716f4..d0a23ea6da 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -1153,7 +1153,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { * @param askTimeout * a timeout for the request * @return - * true if this grids contains assets or false if no request has been send + * true if this grids contains assets or false if no request has been sent * due to non-existence of assets */ private def askForAssetPowers( @@ -1383,11 +1383,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { } /** This method uses [[ActorContext.pipeToSelf()]] to send a future message to - * itself. If the future is a [[Success]] the message is send, else a - * [[WrappedFailure]] with the thrown error is send. + * itself. If the future is a [[Success]] the message is sent, else a + * [[WrappedFailure]] with the thrown error is sent. * * @param future - * future message that should be send to the agent after it was processed + * future message that should be sent to the agent after it was processed * @param ctx * [[ActorContext]] of the receiving actor */ From 85b881acb2cf7104b067c286df34ce174e4172a0 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:36:55 +0100 Subject: [PATCH 098/137] Revert "spelling" This reverts commit a5dd416237130ac2ac4a13db69ef515ef935ab63. --- docs/readthedocs/models/thermal_house_model.md | 2 +- .../fixedfeedin/FixedFeedInAgentFundamentals.scala | 4 ++-- .../simona/agent/participant/pv/PvAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/main/RunSimona.scala | 2 +- .../participant/load/random/RandomLoadParamStore.scala | 6 +++--- src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala | 2 +- .../ie3/simona/event/listener/ResultEventListenerSpec.scala | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/readthedocs/models/thermal_house_model.md b/docs/readthedocs/models/thermal_house_model.md index 84044085dc..7914270c7f 100644 --- a/docs/readthedocs/models/thermal_house_model.md +++ b/docs/readthedocs/models/thermal_house_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the thermal house available in SIMONA. ## Behaviour -This house model represents the thermal behaviour of a building. This reflects a simple shoebox with a thermal capacity and with transmission losses. +This house model represents the thermal behaviour of a building. This reflects a simple shoe box with a thermal capacity and with transmission losses. ## Attributes, Units and Remarks diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index 233246ca81..f634bf0454 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -134,8 +134,8 @@ protected trait FixedFeedInAgentFundamentals /* As participant agents always return their last known operation point on request, it is sufficient * to let a fixed model determine its operation point on: * 1) The first tick of the simulation - * 2) The tick, it turns on (in time-dependent operation) - * 3) The tick, it turns off (in time-dependent operation) + * 2) The tick, it turns on (in time dependent operation) + * 3) The tick, it turns off (in time dependent operation) * Coinciding ticks are summarized and the last tick is removed, as the change in operation status * doesn't affect anything then */ SortedSet[Long]( diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index 52f0a76e24..b3b96970b6 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -210,7 +210,7 @@ protected trait PvAgentFundamentals tick - dataTick case _ => /* At the first tick, we are not able to determine the tick interval from last tick - * (since there is none). Then we use a fallback pv stem distance. */ + * (since there is none). Then we use a fall back pv stem distance. */ FALLBACK_WEATHER_STEM_DISTANCE } diff --git a/src/main/scala/edu/ie3/simona/main/RunSimona.scala b/src/main/scala/edu/ie3/simona/main/RunSimona.scala index 9d03f38665..c255990a05 100644 --- a/src/main/scala/edu/ie3/simona/main/RunSimona.scala +++ b/src/main/scala/edu/ie3/simona/main/RunSimona.scala @@ -86,7 +86,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { } } - /** Method to be implemented to set up everything that is necessary for a + /** Method to be implemented to setup everything that is necessary for a * simulations. This is by creating an instance of [[SimonaSetup]] * implementation * diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala index 33fb57a38a..394732bc4c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala @@ -124,13 +124,13 @@ case object RandomLoadParamStore extends LazyLogging { } /** Builds a descriptor tree, which gives information what to find where in - * the file. Each headline element breaks down to encoded information about + * the file. Each head line element breaks down to encoded information about * the probability density function parameter and the addressed day type. All - * headline elements are treated this way and a mapping from day type to + * head line elements are treated this way and a mapping from day type to * column position of parameter is build. * * @param headerElements - * List of headline elements + * List of head line elements * @return * Mapping from day type to a mapping from parameter to column index */ diff --git a/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala b/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala index 7cc4174e10..7339fbbe61 100644 --- a/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala +++ b/src/main/scala/edu/ie3/simona/scheduler/Scheduler.scala @@ -160,7 +160,7 @@ object Scheduler { stopOnError(ctx, s"Received unexpected message $unexpected when active") } - /** Data that is constant over the lifetime of a scheduler. + /** Data that is constant over the life time of a scheduler. * @param parent * The parent of the scheduler * @param activationAdapter diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index 4a2d8abd42..edcd0ffe2f 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -21,7 +21,7 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} -/** Trait that can be used to set up a customized simona simulation by providing +/** Trait that can be used to setup a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending * [[SimonaStandaloneSetup]] might be considered instead of providing your own diff --git a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala index 26c3145945..f110feca8e 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala @@ -316,7 +316,7 @@ class ResultEventListenerSpec ), ) ) - /* The result file is created at start up and only contains a headline. */ + /* The result file is created at start up and only contains a head line. */ awaitCond( outputFile.exists(), interval = 500.millis, From ca534cff3f5337815f65d8875767eb0c50979873 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:04 +0100 Subject: [PATCH 099/137] Revert "grammar correct tense second part" This reverts commit 5694a9f9d98d8cebf1016602c944740347d5d4b8. --- .../edu/ie3/simona/agent/grid/GridResultsSupport.scala | 6 +++--- src/main/scala/edu/ie3/simona/service/SimonaService.scala | 6 +++--- .../edu/ie3/simona/service/weather/WeatherService.scala | 6 +++--- .../scala/edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index 59f0248f81..87aa1d8440 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -96,7 +96,7 @@ private[grid] trait GridResultsSupport { * and the corresponding sweep value data * * @param lines - * the set of lines which the result should be built for + * the set of lines which the result should be build for * @param sweepValueStoreData * the value store with all power flow result values of the provided lines * @param iNominal @@ -142,7 +142,7 @@ private[grid] trait GridResultsSupport { * [[TransformerModel]] and the corresponding sweep value data * * @param transformers - * the set of transformers which the result should be built for + * the set of transformers which the result should be build for * @param sweepValueStoreData * the value store with all power flow result values of the provided * transformers @@ -190,7 +190,7 @@ private[grid] trait GridResultsSupport { * [[Transformer3wModel]] and the corresponding sweep value data * * @param transformers3w - * the set of 3 winding transformers which the result should be built for + * the set of 3 winding transformers which the result should be build for * @param sweepValueStoreData * the value store with all power flow result values of the provided 3 * winding transformers diff --git a/src/main/scala/edu/ie3/simona/service/SimonaService.scala b/src/main/scala/edu/ie3/simona/service/SimonaService.scala index 310c7f0b32..75a1813f0a 100644 --- a/src/main/scala/edu/ie3/simona/service/SimonaService.scala +++ b/src/main/scala/edu/ie3/simona/service/SimonaService.scala @@ -182,9 +182,9 @@ abstract class SimonaService[ /** Initialize the concrete service implementation using the provided * initialization data. This method should perform all heavyweight tasks * before the actor becomes ready. The return values are a) the state data of - * the initialized service and b) optional triggers that should be sent to + * the initialized service and b) optional triggers that should be send to * the [[edu.ie3.simona.scheduler.Scheduler]] together with the completion - * message that is sent in response to the trigger that is sent to start the + * message that is send in response to the trigger that is send to start the * initialization process * * @param initServiceData @@ -221,7 +221,7 @@ abstract class SimonaService[ * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is sent + * with updated values) together with the completion message that is send * in response to the trigger that was sent to start this announcement */ protected def announceInformation(tick: Long)(implicit diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala index a31a217eb0..0f8039d30d 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala @@ -107,9 +107,9 @@ final case class WeatherService( /** Initialize the concrete service implementation using the provided * initialization data. This method should perform all heavyweight tasks * before the actor becomes ready. The return values are a) the state data of - * the initialized service and b) optional triggers that should be sent to + * the initialized service and b) optional triggers that should be send to * the [[edu.ie3.simona.scheduler.Scheduler]] together with the completion - * message that is sent in response to the trigger that is sent to start the + * message that is send in response to the trigger that is send to start the * initialization process * * @param initServiceData @@ -284,7 +284,7 @@ final case class WeatherService( * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is sent + * with updated values) together with the completion message that is send * in response to the trigger that was sent to start this announcement */ override protected def announceInformation(tick: Long)(implicit diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 8b74574226..e90fa8975d 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -156,7 +156,7 @@ object ResultFileHierarchy extends LazyLogging { ) /** @param modelClass - * the model class a file path should be built for + * the model class a file path should be build for * @param csvSink * the csv sink type parameters * @param rawOutputDataDir From b0a8ec8136ef26b3314c681c3348be14fc16ba9b Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:08 +0100 Subject: [PATCH 100/137] Revert "grammar correct tense" This reverts commit a63dc876367ca0dfcca099c49516671bdea154fa. --- .../scala/edu/ie3/simona/agent/grid/GridAgentData.scala | 2 +- .../edu/ie3/simona/agent/grid/GridAgentMessages.scala | 2 +- .../edu/ie3/simona/service/ev/ExtEvDataService.scala | 2 +- .../ie3/simona/service/primary/PrimaryServiceWorker.scala | 4 ++-- .../ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala | 4 ++-- .../agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala | 8 ++++---- .../ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala index 6b77430487..636baca646 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala @@ -56,7 +56,7 @@ object GridAgentData { } } - /** Data that is sent to the [[GridAgent]] directly after startup. It contains + /** Data that is send to the [[GridAgent]] directly after startup. It contains * the main information for initialization. This data should include all * [[GridAgent]] individual data, for data that is the same for all * [[GridAgent]] s please use [[GridAgent.apply()]] diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala index 288add1bd9..b0d98be1e9 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentMessages.scala @@ -186,7 +186,7 @@ object GridAgentMessages { /** Provide values as a reply to a * [[edu.ie3.simona.agent.participant.ParticipantAgent.RequestAssetPowerMessage]]. * In contrast to [[AssetPowerChangedMessage]], this message indicates that - * the same values for [[p]] and [[q]] has been sent again as in the previous + * the same values for [[p]] and [[q]] has been send again as in the previous * request * * @param p diff --git a/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala b/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala index 680c6050b1..66cfaa96f1 100644 --- a/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala +++ b/src/main/scala/edu/ie3/simona/service/ev/ExtEvDataService.scala @@ -170,7 +170,7 @@ class ExtEvDataService(override val scheduler: ActorRef) * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is sent + * with updated values) together with the completion message that is send * in response to the trigger that was sent to start this announcement */ override protected def announceInformation( diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index bd09c0b81b..7ff05ccf1a 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -198,8 +198,8 @@ final case class PrimaryServiceWorker[V <: Value]( * the current state data of this service * @return * the service stata data that should be used in the next state (normally - * with updated values) together with the completion message that is sent - * in response to the trigger that is sent to start the initialization + * with updated values) together with the completion message that is send + * in response to the trigger that is send to start the initialization * process */ override protected def announceInformation( diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index 8d23af9c46..c4a3dfa717 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -424,8 +424,8 @@ class DBFSAlgorithmCenGridSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is sent the inferior grids, they themselves will send the - // Trigger forward the trigger to their connected inferior grids. Therefore, the inferior grid + // after a FinishGridSimulationTrigger is send the inferior grids, they themselves will send the + // Trigger forward the trigger to their connected inferior grids. Therefore the inferior grid // agent should receive a FinishGridSimulationTrigger inferiorGrid11.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala index a1047edeff..0609a974ec 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala @@ -200,8 +200,8 @@ class DBFSAlgorithmFailedPowerFlowSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is sent to the inferior grids, they themselves will - // forward the trigger to their connected inferior grids. Therefore, the inferior grid agent + // after a FinishGridSimulationTrigger is send to the inferior grids, they themselves will + // forward the trigger to their connected inferior grids. Therefore the inferior grid agent // should receive a FinishGridSimulationTrigger inferiorGridAgent.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) @@ -272,8 +272,8 @@ class DBFSAlgorithmFailedPowerFlowSpec // connected inferior grids, because the slack node is just a mock, we imitate this behavior centerGridAgent ! FinishGridSimulationTrigger(3600) - // after a FinishGridSimulationTrigger is sent to the inferior grids, they themselves will - // forward the trigger to their connected inferior grids. Therefore, the inferior grid agent + // after a FinishGridSimulationTrigger is send to the inferior grids, they themselves will + // forward the trigger to their connected inferior grids. Therefore the inferior grid agent // should receive a FinishGridSimulationTrigger inferiorGridAgent.gaProbe.expectMessage(FinishGridSimulationTrigger(3600)) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala index beb1408270..9c716def88 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmSupGridSpec.scala @@ -154,7 +154,7 @@ class DBFSAlgorithmSupGridSpec ) // we expect a completion message here and that the agent goes back to simulate grid - // and waits until the newly scheduled StartGridSimulationTrigger is sent + // and waits until the newly scheduled StartGridSimulationTrigger is send // wait 30 seconds max for power flow to finish scheduler.expectMessageType[Completion](130 seconds) match { case Completion(_, Some(3600)) => @@ -271,7 +271,7 @@ class DBFSAlgorithmSupGridSpec ) // we expect a completion message here and that the agent goes back to simulate grid - // and waits until the newly scheduled StartGridSimulationTrigger is sent + // and waits until the newly scheduled StartGridSimulationTrigger is send // Simulate Grid // wait 30 seconds max for power flow to finish From bde34ee0cae7e66a0ef0621a2e06ff9697d7d8b1 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:11 +0100 Subject: [PATCH 101/137] Revert "grammar, spelling, typos, wording etc." This reverts commit 7df7e8b5f92799a12742702facfa9136c7effb26. --- docs/readthedocs/developersguide.md | 2 +- docs/readthedocs/models/em.md | 2 +- docs/readthedocs/models/hp_model.md | 2 +- docs/readthedocs/usersguide.md | 2 +- .../ie3/simona/actor/SimonaActorNaming.scala | 2 +- .../agent/grid/GridAgentController.scala | 2 +- .../simona/agent/grid/PowerFlowSupport.scala | 2 +- .../agent/participant/ParticipantAgent.scala | 6 +++--- .../ParticipantAgentFundamentals.scala | 21 +++++++++---------- .../edu/ie3/simona/event/RuntimeEvent.scala | 2 +- .../exceptions/WeatherServiceException.scala | 2 +- .../ie3/simona/model/SystemComponent.scala | 2 +- .../model/em/PrioritizedFlexStrat.scala | 4 ++-- .../edu/ie3/simona/model/grid/GridModel.scala | 4 ++-- .../edu/ie3/simona/model/grid/RefSystem.scala | 2 +- .../model/grid/TransformerTapping.scala | 2 +- .../model/participant/evcs/EvcsModel.scala | 4 ++-- .../ie3/simona/service/SimonaService.scala | 2 +- .../service/primary/PrimaryServiceProxy.scala | 2 +- .../service/weather/SampleWeatherSource.scala | 2 +- .../ie3/simona/sim/setup/SimonaSetup.scala | 4 ++-- .../ie3/simona/util/ParsableEnumeration.scala | 2 +- .../util/scala/quantities/QuantityUtil.scala | 5 +++-- .../agent/grid/DBFSAlgorithmCenGridSpec.scala | 6 +++--- .../DBFSAlgorithmFailedPowerFlowSpec.scala | 8 +++---- .../RuntimeEventListenerLoggingSpec.scala | 2 +- .../model/participant/StorageModelSpec.scala | 2 +- .../common/model/grid/SubGridGateMokka.scala | 2 +- 28 files changed, 50 insertions(+), 50 deletions(-) diff --git a/docs/readthedocs/developersguide.md b/docs/readthedocs/developersguide.md index a246fc106a..ace59e05e6 100644 --- a/docs/readthedocs/developersguide.md +++ b/docs/readthedocs/developersguide.md @@ -2,7 +2,7 @@ # Developer’s Guide -The SIMONA repository can be found [on GitHub](https://github.com/ie3-institute/simona). +The SIMONA repository can be found [on Github](https://github.com/ie3-institute/simona). ```{contents} --- diff --git a/docs/readthedocs/models/em.md b/docs/readthedocs/models/em.md index ea7261d4f8..ae10cb3ac2 100644 --- a/docs/readthedocs/models/em.md +++ b/docs/readthedocs/models/em.md @@ -16,7 +16,7 @@ If an EmAgent is itself controlled by another EmAgent, it also behaves like a sy Every EmAgent aggregates flex options and power of its connected assets and disaggregates flex control among the connected assets. It also functions as a scheduler for all connected assets by processing information on the ticks of the next desired activations and conveying such information to the controlling EmAgent or a central scheduler respectively. -Uncontrolled EmAgents answer to a scheduler with regard to their activation. +Uncontrolled EmAgents answer to a scheduler with regards to their activation. ![](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/ie3-institute/simona/dev/docs/uml/protocol/em/UncontrolledEm.puml) diff --git a/docs/readthedocs/models/hp_model.md b/docs/readthedocs/models/hp_model.md index 8070e36f36..d0153e7395 100644 --- a/docs/readthedocs/models/hp_model.md +++ b/docs/readthedocs/models/hp_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the Heat Pump Model (HP model) availabl ## Assumptions -The HP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the HP unit does not possess a memory. +The HP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the HP unit does not posses a memory. ## Parameters diff --git a/docs/readthedocs/usersguide.md b/docs/readthedocs/usersguide.md index ea6a9babf1..5b75b15ac7 100644 --- a/docs/readthedocs/usersguide.md +++ b/docs/readthedocs/usersguide.md @@ -37,7 +37,7 @@ You can either delegate the job to your preferred IDE or build an executable jar In order to be able to execute SIMONA from a CLI, you need an executable fat jar. A fat jar contains all compiled classes and dependencies, ready for execution. For building one, you can use a Gradle task of the project. 1. Open a CLI and change directories to the top level directory of the project. -2. Execute ``gradlew shadowJar`` within the CLI. This creates a fat jar of SIMONA inside the directory ``build/libs``. +2. Execute ``gradlew shadowJar`` within the CLI. This creates a fat jar of SIMONA inside of the directory ``build/libs``. 3. For executing a fat jar you need to specify the classpath of the entrypoint of your application. Assuming we are still in the top level directory of our project, the execution command would look as follows: diff --git a/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala b/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala index 2b0c62e780..fed8f600f3 100644 --- a/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala +++ b/src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala @@ -21,7 +21,7 @@ object SimonaActorNaming { refFactory.actorOf(props, actorName(props, simonaActorId(actorId))) } - /** Constructs an id for convenience actor naming. Although this is dangerous + /** Constructs an Id for convenience actor naming. Although this is dangerous * as duplicates might be possible, it should be sufficient in our case as * the uniqueness is only required in one actor system * diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala index ad0d6c3b07..f2e78f7c53 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgentController.scala @@ -158,7 +158,7 @@ class GridAgentController( /** Go through all provided input models, build agents for those and group the * resulting actor references for each connection nodes. All participant * agents are also introduced to the agent environment and the scheduler is - * requested to send an initialisation trigger. + * requested to send a initialisation trigger. * * @param participantsConfig * Configuration information for participant models diff --git a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala index c43700466c..8bfcef23da 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala @@ -203,7 +203,7 @@ trait PowerFlowSupport { * p/q values from the provided sweepDataValues and combines them with * updated receivedSlackValues. Normally used in a forward sweep phase of * [[DBFSAlgorithm]] as in this state only voltages are updated and a power - * flow with new voltages but old p/q values is executed afterward. + * flow with new voltages but old p/q values is executed afterwards * * @param receivedSlackValues * new slack voltages provided by the superior grid diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 19eff90211..63784a277f 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -448,8 +448,8 @@ abstract class ParticipantAgent[ case _ => participantStateData.receivedSecondaryDataStore } - /* At least parts of the needed data has been received, or it is an additional activation, that has been triggered. - * Anyway, the calculation routine has also to take care of filling up missing data. */ + /* At least parts of the needed data has been received or it is an additional activation, that has been triggered. + * Anyways, the calculation routine has also to take care of filling up missing data. */ val lastModelState = getLastOrInitialStateData(participantStateData, currentTick) calculatePowerWithSecondaryDataAndGoToIdle( @@ -656,7 +656,7 @@ abstract class ParticipantAgent[ * the agent is meant to replay external primary data: Announce result, add * content to result value store, go to [[Idle]] and answer the scheduler, * that the activity start trigger is fulfilled. 2.2) All secondary data is - * there, go to [[Calculate]] and ask the scheduler to trigger ourselves for + * there, go to [[Calculate]] and ask the scheduler to trigger ourself for * starting the model based calculation 3) Everything is at place and the * [[Activation]] has NOT yet been sent: Stay here and wait * 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 586947b839..40d510f13f 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -388,7 +388,7 @@ protected trait ParticipantAgentFundamentals[ /** Assume we have information, that are available in a fixed resolution after * each full hour (including the full hour), then we have to determine, at - * what first tick this information are available. + * what first tick those information are available. * * @param simulationStartDate * Beginning of the simulation @@ -515,7 +515,7 @@ protected trait ParticipantAgentFundamentals[ val foreseenDataTicks = baseStateData.foreseenDataTicks + (msg.serviceRef -> msg.nextDataTick) - /* Go over to handling this information */ + /* Go over to handling these information */ val nextStateData = DataCollectionStateData( BaseStateData.updateBaseStateData( baseStateData, @@ -538,9 +538,8 @@ protected trait ParticipantAgentFundamentals[ * Announce result, add content to result value store, go to [[Idle]] and * answer the scheduler, that the activity start trigger is fulfilled. 2.2) * All secondary data is there, go to [[Calculate]] and ask the scheduler to - * trigger ourselves for starting the model based calculation 3) Everything - * is at place and the [[Activation]] has NOT yet been sent: Stay here and - * wait + * trigger ourself for starting the model based calculation 3) Everything is + * at place and the [[Activation]] has NOT yet been sent: Stay here and wait * * @param stateData * Apparent state data @@ -646,7 +645,7 @@ protected trait ParticipantAgentFundamentals[ ) } } else { - /* We still have to wait - either for data or activation */ + /* We sill have to wait - either for data or activation */ stay() using stateData } } @@ -1142,7 +1141,7 @@ protected trait ParticipantAgentFundamentals[ baseStateData, ) case (Some(additionalTick), _) => - /* The next activation is additional (either there is no foreseen data tick or it is after the additional tick). + /* The next activation is additional (either there is no foreseen data tick or it is after the additional tick. * Remove the tick from the list of additional activation ticks. */ val upcomingActivationTicks = baseStateData.additionalActivationTicks.rangeFrom(additionalTick + 1) @@ -1160,7 +1159,7 @@ protected trait ParticipantAgentFundamentals[ updatedBaseStateData, ) case (None, None) => - /* We don't know anything about either additional activation nor new incoming data */ + /* We don't know nothing about either additional activation nor new incoming data */ (None, baseStateData) } } @@ -1259,7 +1258,7 @@ protected trait ParticipantAgentFundamentals[ } /** Checks, if a fast reply is possible, when the very same request (in terms - * of tick and nodal voltage) already has been answered. Then an Option on + * of tick and nodal voltage) already has been answered. Then a Option on * stay in the same state with sending an [[AssetPowerUnchangedMessage]] is * given back. If a fast reply is not possible, [[None]] is given back. * Additionally, the listener are informed about the result. @@ -1293,7 +1292,7 @@ protected trait ParticipantAgentFundamentals[ case Some((mostRecentRequestTick, latestProvidedValues)) if mostRecentRequestTick == requestTick => /* A request for this tick has already been answered. Check, if it has been the same request. - * if it has been the same request we want to answer with the same values afterwards, this data MUST always + * if it has been the same request we wanna answer with the same values afterwards, this data MUST always * be available when we already provided data for this tick */ baseStateData match { case externalBaseStateData: FromOutsideBaseStateData[M, PD] => @@ -1754,7 +1753,7 @@ protected trait ParticipantAgentFundamentals[ * @param tick * Tick, the result belongs to * @param result - * The result to build an event for + * The result to build a event for * @param outputConfig * Configuration of the output behaviour */ diff --git a/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala b/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala index 44d092ea0f..da02b9c258 100644 --- a/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala +++ b/src/main/scala/edu/ie3/simona/event/RuntimeEvent.scala @@ -21,7 +21,7 @@ object RuntimeEvent { /** Indicates that the scheduler has finished a pre-defined advancement in * ticks and is ready to carry out the next task. In contrast to the * [[CheckWindowPassed]] event, whenever a [[Ready]] event is scheduled, the - * schedule of [[edu.ie3.simona.scheduler.Scheduler]] will be stopped and + * scheduled of [[edu.ie3.simona.scheduler.Scheduler]] will be stopped and * further commands are necessary to continue the schedule. * * @param tick diff --git a/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala b/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala index b1291f6694..08d109a2a6 100644 --- a/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala +++ b/src/main/scala/edu/ie3/simona/exceptions/WeatherServiceException.scala @@ -45,7 +45,7 @@ object WeatherServiceException { private val cause: Throwable = None.orNull, ) extends WeatherServiceException(msg, cause) - /** Exception to be thrown if the registration of an agent fails + /** Exception to be thrown if the registration of the an agent fails * @param msg * Message to prompt to the end user * @param cause diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index efc70ba0cf..7408c8cbef 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -40,7 +40,7 @@ abstract class SystemComponent( private val elementType: String = this.getClass.getSimpleName - // check if an uuid is provided + // check if a uuid is provided if (Option.apply(uuid).isEmpty) throw new InvalidParameterException( s"Uuid of $elementType $id cannot be null!" diff --git a/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala b/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala index 3d934e21f3..98162db86c 100644 --- a/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala +++ b/src/main/scala/edu/ie3/simona/model/em/PrioritizedFlexStrat.scala @@ -122,7 +122,7 @@ final case class PrioritizedFlexStrat(curtailRegenerative: Boolean) (issueCtrlMsgs, Some(remainingExcessPower)) } else if (remainingExcessPower < flexPotential) { // we cannot cover the excess feed-in with just this flexibility, - // thus use all the available flexibility and continue + // thus use all of the available flexibility and continue ( issueCtrlMsgs :+ (inputModel.getUuid, flexOption.max), Some(remainingExcessPower - flexPotential), @@ -171,7 +171,7 @@ final case class PrioritizedFlexStrat(curtailRegenerative: Boolean) (issueCtrlMsgs, Some(remainingExcessPower)) } else if (remainingExcessPower > flexPotential) { // we cannot cover the excess load with just this flexibility, - // thus use all the available flexibility and continue + // thus use all of the available flexibility and continue ( issueCtrlMsgs :+ (inputModel.getUuid, flexOption.min), Some(remainingExcessPower - flexPotential), diff --git a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala index 16285b9317..ea60caa44d 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala @@ -332,7 +332,7 @@ object GridModel { } /** This checks whether the provided grid model graph is connected, that means - * if every node can be reached from every other node through a sequence of + * if every node can be reached from every other node trough a sequence of * edges. Also checks for referenced nodes that are missing. This check * considers the state (enabled/disabled) of the elements. * @@ -605,7 +605,7 @@ object GridModel { /** Check and validates the grid. Especially the consistency of the grid * model the connectivity of the grid model if there is InitData for - * superior or inferior GridGates if there exists voltage measurements for + * superior or inferior GridGates if there exits voltage measurements for * transformerControlGroups */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala b/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala index d9a6090601..40319e699a 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala @@ -153,7 +153,7 @@ final case class RefSystem private ( /** Converts a provided voltage value from physical SI value into p.u. value * * @param vInSi - * real or imaginary part of an unreferenced physical SI value + * real or imaginary part of a unreferenced physical SI value * @return * referenced voltage value in p.u. */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala index d199923de8..2806aa159d 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTapping.scala @@ -17,7 +17,7 @@ import tech.units.indriya.quantity.Quantities * necessary to override updateTapPos (e.g. in [[Transformer3wModel]]). The * provided [[TransformerTappingModel]] *should* be protected and not be * accessible from outside to prevent direct access to internal functions! - * Instead, all the functions provided here should be used for tap position + * Instead all the functions provided here should be used for tap position * manipulation. */ trait TransformerTapping { diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index 0588f7abee..8f6d8dd5bc 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -194,7 +194,7 @@ final case class EvcsModel( state.evs } - /** Charge the given EV under consideration an applicable schedule + /** Charge the given EV under consideration a applicable schedule * * @param ev * Electric vehicle to charge @@ -271,7 +271,7 @@ final case class EvcsModel( /* Filter for entries, that end after the last schedule application and that start before the current tick. Entries that end at lastTick are not included because schedule - intervals are open on the right hand side. + intervals are open at the right hand side. Entries that start at currentTick are not included because these will be calculated with the next state. */ diff --git a/src/main/scala/edu/ie3/simona/service/SimonaService.scala b/src/main/scala/edu/ie3/simona/service/SimonaService.scala index 75a1813f0a..1b41b30400 100644 --- a/src/main/scala/edu/ie3/simona/service/SimonaService.scala +++ b/src/main/scala/edu/ie3/simona/service/SimonaService.scala @@ -30,7 +30,7 @@ object SimonaService { /** Service initialization data can sometimes only be constructed once the * service actor is created (e.g. - * [[edu.ie3.simona.service.ev.ExtEvDataService]]). Thus, we need an extra + * [[edu.ie3.simona.service.ev.ExtEvDataService]]. Thus, we need an extra * initialization message. */ final case class Create[+I <: InitializeServiceStateData]( diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala index 838608a514..478226755f 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala @@ -269,7 +269,7 @@ case class PrimaryServiceProxy( unhandled(x) } - /** Handle the registration request for a covered model. First, try to get an + /** Handle the registration request for a covered model. First, try to get a * already existing worker for this time series, otherwise spin-off a new * one, remember it and forward the request * diff --git a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala index 0db3ded44c..9225f4b340 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/SampleWeatherSource.scala @@ -183,7 +183,7 @@ object SampleWeatherSource { } } - // these lists contain the hourly weather values for each first of the month of 2011 + january + // these lists contain the hourly weather values for each first of the month of 2011 + january of // 2012 at coordinate id 213089 private val diffuseRadiation: Vector[Double] = Vector(0, 0, 0, 0, 0, 1.18179e-12, 4.42315e-11, 0.0585938, 1.94141, 15.1172, 74.8438, 89.0469, diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index edcd0ffe2f..9c6effa859 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -24,8 +24,8 @@ import org.apache.pekko.actor.{ActorRef => ClassicRef} /** Trait that can be used to setup a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending - * [[SimonaStandaloneSetup]] might be considered instead of providing your own - * implementation for all methods. + * [[SimonaStandaloneSetup]] might be considered instead of providing a your + * own implementation for all methods. * * @version 0.1 * @since 01.07.20 diff --git a/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala b/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala index eee647d73f..6097ac1247 100644 --- a/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala +++ b/src/main/scala/edu/ie3/simona/util/ParsableEnumeration.scala @@ -26,7 +26,7 @@ abstract class ParsableEnumeration extends Enumeration { withName(cleanedInput) } - /** Checks, if the given input is an eligible description of an enum value + /** Checks, if the given input is an eligible description of a enum value * * @param input * Input string diff --git a/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala b/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala index 7ccc3b7aa2..b55678ef83 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/QuantityUtil.scala @@ -21,8 +21,9 @@ object QuantityUtil { /** The [[tech.units.indriya.function.DefaultNumberSystem]] is only covering * java [[Number]] children. As [[BigDecimal]] is not related to * [[java.math.BigDecimal]], this causes issues, why the - * [[tech.units.indriya.spi.NumberSystem]] has to be used has to be specified - * to something, that actually is able to handle the scala number system. + * [[tech.units.indriya.spi.NumberSystem]] has to be to be used has to be + * specified to something, that actually is able to handle the scala number + * system. */ def adjustNumberSystem(): Unit = Calculus.setCurrentNumberSystem( diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index c4a3dfa717..861d35a6a7 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -164,7 +164,7 @@ class DBFSAlgorithmCenGridSpec val firstSlackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(firstSweepNo) - // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculations + // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculations // we simulate this behaviour now by doing the same for our three inferior grid agents inferiorGrid11.requestSlackVoltage(centerGridAgent, firstSweepNo) @@ -300,7 +300,7 @@ class DBFSAlgorithmCenGridSpec Kilovolts(374.22694614463d), // 380 kV @ 10° Kilovolts(65.9863075134335d), // 380 kV @ 10° ), - ExchangeVoltage( // this one should currently be ignored anyway + ExchangeVoltage( // this one should currently be ignored anyways supNodeA.getUuid, Kilovolts(380d), Kilovolts(0d), @@ -320,7 +320,7 @@ class DBFSAlgorithmCenGridSpec val secondPowerRequestSender13 = inferiorGrid13.expectGridPowerRequest() - // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculations + // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculations // we simulate this behaviour now by doing the same for our three inferior grid agents inferiorGrid11.requestSlackVoltage(centerGridAgent, secondSweepNo) diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala index 0609a974ec..ce904d0b11 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmFailedPowerFlowSpec.scala @@ -145,7 +145,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val slackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(sweepNo) - // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent inferiorGridAgent.requestSlackVoltage(centerGridAgent, sweepNo) @@ -191,7 +191,7 @@ class DBFSAlgorithmFailedPowerFlowSpec // hence we ask for them and expect a corresponding response superiorGridAgent.requestGridPower(centerGridAgent, sweepNo) - // the requested power is too high for the grid to handle, therefore the superior grid agent + // the requested power is to high for the grid to handle, therefore the superior grid agent // receives a FailedPowerFlow message // wait 30 seconds max for power flow to finish superiorGridAgent.gaProbe.expectMessage(30 seconds, FailedPowerFlow) @@ -229,7 +229,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val slackVoltageRequestSender = superiorGridAgent.expectSlackVoltageRequest(sweepNo) - // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent inferiorGridAgent.requestSlackVoltage(centerGridAgent, sweepNo) @@ -341,7 +341,7 @@ class DBFSAlgorithmFailedPowerFlowSpec val powerRequestSender = hvGridAgent.expectGridPowerRequest() - // normally the inferior grid agents ask for the slack voltage as well to run their power flow calculation + // normally the inferior grid agents ask for the slack voltage as well to do their power flow calculation // we simulate this behaviour now by doing the same for our inferior grid agent hvGridAgent.requestSlackVoltage(slackGridAgent, sweepNo) diff --git a/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala index 7f77f7ca77..4e37001c11 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/RuntimeEventListenerLoggingSpec.scala @@ -29,7 +29,7 @@ import org.apache.pekko.actor.testkit.typed.scaladsl.{ import org.slf4j.event.Level /** Logging must be tested in a separate test, since LoggingTestKit can still - * receive logs from test that it was not enabled for + * receives logs from test that it was not enabled for */ class RuntimeEventListenerLoggingSpec extends ScalaTestWithActorTestKit( diff --git a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala index 032743fa97..4d6fff7060 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/StorageModelSpec.scala @@ -104,7 +104,7 @@ class StorageModelSpec extends UnitSpec with Matchers { // CHANGED STATE // discharged to empty (10.0, -9.0, 3600, 0.0, 0.0, 10.0), - // almost discharged to the lowest allowed charge + // almost discharged to lowest allowed charge (10.0, -9.0, 3590, 0.0, -10.0, 10.0), // charged to mid-level charge (41.0, 10.0, 3600, 0.0, -10.0, 10.0), diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala index d3ab3e97b3..a5fc6ffb82 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala @@ -28,7 +28,7 @@ trait SubGridGateMokka extends MockitoSugar { * @param subnet * Sub net number * @return - * [[NodeInput]] with this information + * [[NodeInput]] with these information */ protected def mockNode(uuid: UUID, subnet: Int): NodeInput = { val node = mock[NodeInput] From 2b63cb0bfbcabcef21b33ed4affa5924192d7241 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:15 +0100 Subject: [PATCH 102/137] Revert "grammar fix it's to its" This reverts commit ef28095779d2e7257fca64f18c661ae6cd0885c1. --- docs/readthedocs/models/hp_model.md | 2 +- src/main/scala/edu/ie3/simona/agent/em/EmAgent.scala | 2 +- .../participant/fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/load/LoadAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/event/Event.scala | 2 +- .../edu/ie3/simona/model/grid/TransformerTappingModel.scala | 2 +- .../edu/ie3/simona/service/primary/PrimaryServiceProxy.scala | 2 +- .../scala/edu/ie3/simona/service/weather/WeatherSource.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala | 2 +- .../ie3/simona/test/common/model/grid/SubGridGateMokka.scala | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/readthedocs/models/hp_model.md b/docs/readthedocs/models/hp_model.md index d0153e7395..0458fffbac 100644 --- a/docs/readthedocs/models/hp_model.md +++ b/docs/readthedocs/models/hp_model.md @@ -17,6 +17,6 @@ Please refer to {doc}`PowerSystemDataModel - HP Model /* As participant agents always return their last known operation point on request, it is sufficient - * to let a fixed load model determine its operation point on: + * to let a fixed load model determine it's operation point on: * 1) The first tick of the simulation * 2) The tick, it turns on (in time-dependent operation) * 3) The tick, it turns off (in time-dependent operation) diff --git a/src/main/scala/edu/ie3/simona/event/Event.scala b/src/main/scala/edu/ie3/simona/event/Event.scala index dad24a314f..2efb82b76e 100644 --- a/src/main/scala/edu/ie3/simona/event/Event.scala +++ b/src/main/scala/edu/ie3/simona/event/Event.scala @@ -7,7 +7,7 @@ package edu.ie3.simona.event /** Trait that should be mixed into each event in [[edu.ie3.simona.event]] to - * provide easy access to its name + * provide an easy access to it's name */ trait Event { diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala index a8534d7b7b..602259cec2 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerTappingModel.scala @@ -114,7 +114,7 @@ final case class TransformerTappingModel( * inverted. * * Furthermore, this method also considers the transformer not being able to - * change its tap position anymore. Hence, 0 is returned, if no change is + * change it's tap position anymore. Hence, 0 is returned, if no change is * possible anymore. * * @param vChangeRequest diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala index 478226755f..ca41a11234 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceProxy.scala @@ -126,7 +126,7 @@ case class PrimaryServiceProxy( } /** Prepare the needed state data by building a - * [[edu.ie3.datamodel.io.source.TimeSeriesMappingSource]], obtain its + * [[edu.ie3.datamodel.io.source.TimeSeriesMappingSource]], obtain it's * information and compile them to state data * * @param primaryConfig diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala index 8cf874a885..30ef9e8ed4 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala @@ -424,7 +424,7 @@ object WeatherSource { * coordinates * * @param weighting - * Mapping from weather coordinate to its weight in averaging + * Mapping from weather coordinate to it's weight in averaging */ private[weather] final case class WeightedCoordinates( weighting: Map[Point, Double] diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index b7805219ce..78a5afeb14 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -46,7 +46,7 @@ trait SetupHelper extends LazyLogging { * Mapping from sub grid number to [[edu.ie3.simona.agent.grid.GridAgent]] * 's [[ActorRef]] * @param gridGates - * [[Set]] of all [[SubGridGate]] s connecting this sub grid with its + * [[Set]] of all [[SubGridGate]] s connecting this sub grid with it's * ancestors and children * @param configRefSystems * Collection of reference systems defined in config diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala b/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala index 137e24a2ce..238668e67a 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ScalaNumberSystem.scala @@ -8,7 +8,7 @@ package edu.ie3.util.scala.quantities import tech.units.indriya.function.DefaultNumberSystem -/** This number system simply delegates the method calls to its parent class. +/** This number system simply delegates the method calls to it's parent class. * The only difference is, that [[BigDecimal]] is transferred to * [[java.math.BigDecimal]] and back upon necessity. Due to its functionality * as an extension of the [[DefaultNumberSystem]] it CANNOT be an object! diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala index a5fc6ffb82..6cf1b682d4 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/SubGridGateMokka.scala @@ -21,7 +21,7 @@ import org.scalatestplus.mockito.MockitoSugar */ trait SubGridGateMokka extends MockitoSugar { - /** Mocks a node with its basic needed information + /** Mocks a node with it's basic needed information * * @param uuid * Unique identifier of the node From d0ab0d7db78f5f5bbc6948314082e07376eb8fbd Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:19 +0100 Subject: [PATCH 103/137] Revert "adding some commas" This reverts commit 8b5e4bf5ff57810f1b59123407db93f19e55f2fe. --- docs/readthedocs/models/two_winding_transformer_model.md | 2 +- src/main/scala/edu/ie3/simona/agent/ValueStore.scala | 2 +- src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala | 2 +- .../scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala | 2 +- .../edu/ie3/simona/agent/participant/ParticipantAgent.scala | 2 +- .../agent/participant/ParticipantAgentFundamentals.scala | 4 ++-- .../scala/edu/ie3/simona/io/result/plain/PlainResult.scala | 4 ++-- src/main/scala/edu/ie3/simona/model/grid/GridModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/StorageModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- .../edu/ie3/simona/model/participant/control/QControl.scala | 2 +- .../scala/edu/ie3/simona/service/weather/WeatherService.scala | 4 ++-- .../scala/edu/ie3/simona/service/weather/WeatherSource.scala | 2 +- src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala | 2 +- src/main/scala/edu/ie3/util/scala/ReflectionTools.scala | 2 +- .../edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala | 2 +- .../edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala | 4 ++-- .../ie3/simona/integration/common/IntegrationSpecCommon.scala | 2 +- .../edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala | 2 +- 19 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/readthedocs/models/two_winding_transformer_model.md b/docs/readthedocs/models/two_winding_transformer_model.md index 768785aaaf..eac989c18d 100644 --- a/docs/readthedocs/models/two_winding_transformer_model.md +++ b/docs/readthedocs/models/two_winding_transformer_model.md @@ -32,7 +32,7 @@ When the load flow calculation asks for the values with regard to the low voltag 3. Main field resistance: $R_{M,LV} = \frac{R_{M}}{\gamma^{2}}$ 4. Main field reactance: $X_{M,LV} = \frac{X_{M}}{\gamma^{2}}$ -Finally, all values are delivered as per unit-values and ready to use in the fundamental $\pi$circuit: +Finally all values are delivered as per unit-values and ready to use in the fundamental $\pi$circuit: 1. Short circuit conductance: $g_{ij} = \frac{Z_{Ref}}{R_{SC}}$ 2. Short circuit susceptance: $b_{ij} = \frac{Z_{Ref}}{X_{SC}}$ diff --git a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala index a1a1190861..a21f7d0f58 100644 --- a/src/main/scala/edu/ie3/simona/agent/ValueStore.scala +++ b/src/main/scala/edu/ie3/simona/agent/ValueStore.scala @@ -129,7 +129,7 @@ object ValueStore { def forResult[D](maxTickSpan: Long, multiplier: Long): ValueStore[D] = new ValueStore[D](maxTickSpan * multiplier) - /** Updates the value store. Additionally, the size of the store is limited to + /** Updates the value store. Additionally the size of the store is limited to * it's defined maximum capacity. Therefore, the oldest entries are removed. * * @param valueStore diff --git a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala index cb8a73294d..9cd9070de8 100644 --- a/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala +++ b/src/main/scala/edu/ie3/simona/agent/em/EmDataCore.scala @@ -260,7 +260,7 @@ object EmDataCore { awaitedConnectedAgents.excl(flexOptions.modelUuid), ) - /** Checks whether all awaited flex options have been received, and we can + /** Checks whether all awaited flex options have been received and we can * continue by calculating flex control. This method does not change the * state of the [[AwaitingFlexOptions]] data core. * @return diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala index 87aa1d8440..0a97764f73 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridResultsSupport.scala @@ -496,7 +496,7 @@ private[grid] trait GridResultsSupport { /** Calculate the current magnitude and the current angle in physical units * based on a provided electric current in p.u. and the nominal referenced * electric current. The arctangent "only" calculates the angle between the - * complex current, and it's real part. This means, that i = (i_real, i_imag) + * complex current and it's real part. This means, that i = (i_real, i_imag) * and i' = (-i_real, -i_imag) will lead to the same angle. However, for * power system simulation, the absolute orientation in the complex plane * with regard to the positive real axis is of interest. Therefore, diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 63784a277f..3506510ff7 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -149,7 +149,7 @@ abstract class ParticipantAgent[ Activation(tick), modelBaseStateData: ParticipantModelBaseStateData[PD, CD, MS, M], ) if modelBaseStateData.services.isEmpty => - /* An activity start trigger is sent and no data is awaited (neither secondary nor primary). Therefore, go straight + /* An activity start trigger is sent and no data is awaited (neither secondary nor primary). Therefore go straight * ahead to calculations */ /* Hold tick, as state transition is needed */ 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 40d510f13f..1a4c474099 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -1070,7 +1070,7 @@ protected trait ParticipantAgentFundamentals[ false } - // If we're completing initialization, and we're EM-managed: + // If we're completing initialization and we're EM-managed: // There is no new tick for the scheduler, // since we are activated by the EmAgent from now on scheduler ! Completion( @@ -1475,7 +1475,7 @@ protected trait ParticipantAgentFundamentals[ determineTickWindow(requestTick, requestValueStore) /* All participants simulation results between the most recent simulation tick BEFORE or at the beginning of the - * averaging window, and it's end (both including) are relevant for averaging the simulated primary data */ + * averaging window and it's end (both including) are relevant for averaging the simulated primary data */ val firstRelevantTick = determineFirstRelevantTick( averagingWindowStart, resultValueStore, diff --git a/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala b/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala index 4a9e9a4c8d..c85cd167af 100644 --- a/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala +++ b/src/main/scala/edu/ie3/simona/io/result/plain/PlainResult.scala @@ -10,8 +10,8 @@ import java.util.UUID /** Results that are sent out with Kafka and avro should use this trait and * corresponding implementing classes, since these give more control over - * attribute types and naming, and they include sim run id. Plain result - * objects can be created by [[PlainWriter]]. + * attribute types and naming and they include sim run id. Plain result objects + * can be created by [[PlainWriter]]. */ sealed trait PlainResult diff --git a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala index ea60caa44d..af90cfc344 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/GridModel.scala @@ -194,7 +194,7 @@ object GridModel { /* Nodes that are connected via a [closed] switch map to the same idx as we fuse them during the power flow. - Therefore, the admittance matrix has to be of the size of the distinct node idxs. + Therefore the admittance matrix has to be of the size of the distinct node idxs. */ val linesAdmittanceMatrix = buildAssetAdmittanceMatrix( nodeUuidToIndexMap, diff --git a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala index 336eef1979..02f82d2670 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala @@ -52,7 +52,7 @@ final case class StorageModel( /** Tolerance for power comparisons. With very small (dis-)charging powers, * problems can occur when calculating the future tick at which storage is * full or empty. For sufficiently large time frames, the maximum Long value - * ([[Long.MaxValue]]) can be exceeded, thus the Long value overflows, and we + * ([[Long.MaxValue]]) can be exceeded, thus the Long value overflows and we * get undefined behavior. * * Thus, small (dis-)charging powers compared to storage capacity have to be diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index 4ecc4e5b5b..8a7eeefcb4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -146,7 +146,7 @@ final case class WecModel( ) } - /** The coefficient is dependent on the wind velocity v. Therefore, use v to + /** The coefficient is dependent on the wind velocity v. Therefore use v to * determine the betz coefficient cₚ. * * @param windVelocity diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index 391d4bca7c..25504c2fff 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -50,7 +50,7 @@ sealed trait QControl { ): Power => ReactivePower } -/** Object to create a [[QControl]]. Currently, the following QControls +/** Object to create a [[QControl]]. Currently the following QControls * characteristics are supported. * - cosine-Phi-Fixed * - cosine-Phi(P) diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala index 0f8039d30d..a75b0c38fd 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherService.scala @@ -269,7 +269,7 @@ final case class WeatherService( serviceStateData case _ => - // actor is not registered, and we don't have data for it + // actor is not registered and we don't have data for it // inform the agentToBeRegistered that the registration failed as we don't have data for it agentToBeRegistered ! RegistrationFailedMessage(self) serviceStateData @@ -303,7 +303,7 @@ final case class WeatherService( // get the weather and send it to the subscribed agents // no sanity check needed here as we can assume that we always have weather available - // when we announce it. Otherwise, the registration would have failed already! + // when we announce it. Otherwise the registration would have failed already! updatedStateData.weatherSource .getWeather(tick, updatedStateData.weightedWeatherCoordinates) .foreach { case coordinate -> weatherResult => diff --git a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala index 30ef9e8ed4..12a26c3f6c 100644 --- a/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala +++ b/src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala @@ -165,7 +165,7 @@ trait WeatherSource { val weightMap = nearestCoordinates .map(coordinateDistance => { /* Maybe some words on the calculus of the weight here: We intend to have a weight, that linear increases - * from zero to one, the closer the coordinate is to the coordinate in question. Therefore, we calculate the + * from zero to one, the closer the coordinate is to the coordinate in question. Therefore we calculate the * proximity of each node as a linear function between 1 at 0m distance to the questioned coordinate to zero * at the sum of all coordinates' distances (1 - d / d_sum). However, summing up this proximity over all * n coordinates brings n*1 from the left part of the sum and -1 as the sum of all distances shares. diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index e90fa8975d..d9f1b7e7c4 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -28,7 +28,7 @@ import scala.jdk.OptionConverters.RichOptional /** Represents the output directory where the results will be materialized. If * new directories are added please remember to add them to the dirsToBeCreated - * Vector if they should be created. Otherwise, they will not be created! + * Vector if they should be created. Otherwise they will not be created! * * @version 0.1 * @since 12.01.20 diff --git a/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala b/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala index be6df1b955..6ed62dc580 100644 --- a/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala +++ b/src/main/scala/edu/ie3/util/scala/ReflectionTools.scala @@ -47,7 +47,7 @@ object ReflectionTools { * @tparam A * type of the object * @return - * a map containing the field method, and it's value of the object instance + * a map containing the field method and it's value of the object instance */ def classFieldToVal[A](a: A)(implicit tt: TypeTag[A], diff --git a/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala b/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala index 82ed0b58bc..e63ec421f5 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/SpecificHeatCapacity.scala @@ -45,7 +45,7 @@ final class SpecificHeatCapacity private ( ) /** Calculates the Energy of a medium with a given specific heat capacity - * based on the temperature delta, and it's volume. + * based on the temperature delta and it's volume. * @param temperatureA * First temperature of the medium (e.g. inlet temperature) * @param temperatureB diff --git a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala index 861d35a6a7..4da922de62 100644 --- a/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala +++ b/src/test/scala/edu/ie3/simona/agent/grid/DBFSAlgorithmCenGridSpec.scala @@ -41,8 +41,8 @@ import scala.language.postfixOps * be able to do if the DBFSAlgorithm is used. The scheduler, the weather * service as well as the inferior and superior [[GridAgent]] s are simulated * by the TestKit. By now this test does NOT cover interactions with generation - * or load asset agents due to unavailability during test development. Hence, - * it would make sense to extend this test in the future to include asset agent + * or load asset agents due to unavailability during test development. Hence it + * would make sense to extend this test in the future to include asset agent * interaction or cover this behaviour by another (integration) test! */ class DBFSAlgorithmCenGridSpec diff --git a/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala b/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala index f98abfd663..eeb0804f77 100644 --- a/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala +++ b/src/test/scala/edu/ie3/simona/integration/common/IntegrationSpecCommon.scala @@ -10,7 +10,7 @@ trait IntegrationSpecCommon { /* ATTENTION: Do not change this file to a path within "input". If you come to this point because the CI * or some of your tests are failing you very likely have altered the vn_simona.conf. This config although - * is NOT meant to be altered. Instead, you should always use a delta config and only override the values and + * is NOT meant to be altered. Instead you should always use a delta config and only override the values and * files of vn_simona/vn_simona.conf. Delta configs can be created by including the config you want to change * parameters from via include (e.g. include "input/samples/vn_simona/vn_simona.conf") at the * beginning of your config file and then just override the parameters you want to change! */ diff --git a/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala b/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala index 2a90b1432d..4a4834fff9 100644 --- a/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/em/ProportionalFlexStratSpec.scala @@ -43,7 +43,7 @@ class ProportionalFlexStratSpec * * Specifically, we use 40% of the flex potential 2 kW - 1 kW = 1 kW of * the first unit and 40% of the flex potential 4 kW - 0 kW = 4 kW of the - * second unit. Thus, we arrive at 1 kW + 40% * 1 kW = 1.4 kW for the + * second unit. Thus we arrive at 1 kW + 40% * 1 kW = 1.4 kW for the * first unit and 0 kW + 40% * 4 kW = 1.6 kW for the second unit. */ From f7e65253fc114652345bcde89809442eb4e5cc4f Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:21 +0100 Subject: [PATCH 104/137] Revert "provide a second dot for all e.g." This reverts commit 548bcb2d4ea93d40a16bd75e6dc7e885df79152c. --- src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala | 2 +- .../edu/ie3/simona/agent/participant/ParticipantAgent.scala | 4 ++-- .../agent/participant/ParticipantAgentFundamentals.scala | 4 ++-- .../simona/agent/participant/evcs/EvcsAgentFundamentals.scala | 2 +- .../fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- .../simona/agent/participant/load/LoadAgentFundamentals.scala | 2 +- .../ie3/simona/agent/participant/pv/PvAgentFundamentals.scala | 2 +- .../simona/agent/participant/wec/WecAgentFundamentals.scala | 2 +- .../ie3/simona/agent/participant/ParticipantAgentMock.scala | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala b/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala index c9bca30ce1..f02d7c36b1 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/GridAgent.scala @@ -57,7 +57,7 @@ object GridAgent extends DBFSAlgorithm { // val initialization val resolution: Long = simonaConfig.simona.powerflow.resolution.get( ChronoUnit.SECONDS - ) // this determines the agents regular time bin it wants to be triggered e.g. one hour + ) // this determines the agents regular time bin it wants to be triggered e.g one hour val simStartTime: ZonedDateTime = TimeUtil.withDefaults .toZonedDateTime(simonaConfig.simona.time.startDateTime) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 3506510ff7..5efc4f053d 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -493,7 +493,7 @@ abstract class ParticipantAgent[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different @@ -533,7 +533,7 @@ abstract class ParticipantAgent[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different 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 1a4c474099..c3459445fd 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -157,7 +157,7 @@ protected trait ParticipantAgentFundamentals[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different @@ -244,7 +244,7 @@ protected trait ParticipantAgentFundamentals[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala index 8894a511ff..69b072e55b 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala @@ -96,7 +96,7 @@ protected trait EvcsAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index d5ace59150..5d3a2d6805 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -92,7 +92,7 @@ protected trait FixedFeedInAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 405a76e6e6..0fc809d85a 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -103,7 +103,7 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala index b3b96970b6..ce152a3d7e 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/pv/PvAgentFundamentals.scala @@ -94,7 +94,7 @@ protected trait PvAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala index 5b43263925..9edf6f2ae8 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/wec/WecAgentFundamentals.scala @@ -89,7 +89,7 @@ protected trait WecAgentFundamentals * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index 8087993f01..a3da7629ca 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -175,7 +175,7 @@ class ParticipantAgentMock( * @param simulationEndDate * Real world time date time, when the simulation ends * @param resolution - * Agents regular time bin it wants to be triggered e.g. one hour + * Agents regular time bin it wants to be triggered e.g one hour * @param requestVoltageDeviationThreshold * Threshold, after which two nodal voltage magnitudes from participant * power requests for the same tick are considered to be different From 4f4cfa0a980d2228515f6e4baef44552e54383d5 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:23 +0100 Subject: [PATCH 105/137] Revert "add some hyphens" This reverts commit 569c42829df9a1820316861b143273fdbbaa390b. --- docs/readthedocs/models/load_model.md | 2 +- .../edu/ie3/simona/agent/grid/PowerFlowSupport.scala | 2 +- .../ie3/simona/agent/participant/ParticipantAgent.scala | 2 +- .../agent/participant/ParticipantAgentFundamentals.scala | 6 +++--- .../agent/participant/load/LoadAgentFundamentals.scala | 4 ++-- src/main/scala/edu/ie3/simona/model/SystemComponent.scala | 2 +- src/main/scala/edu/ie3/simona/model/grid/LineModel.scala | 2 +- src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala | 2 +- .../scala/edu/ie3/simona/model/grid/SwitchModel.scala | 2 +- .../edu/ie3/simona/model/grid/Transformer3wModel.scala | 2 +- .../edu/ie3/simona/model/grid/TransformerModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/BMModel.scala | 4 ++-- .../ie3/simona/model/participant/FixedFeedInModel.scala | 2 +- .../scala/edu/ie3/simona/model/participant/HpModel.scala | 2 +- .../ie3/simona/model/participant/SystemParticipant.scala | 2 +- .../scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- .../edu/ie3/simona/model/participant/evcs/EvcsModel.scala | 2 +- .../simona/model/participant/load/FixedLoadModel.scala | 2 +- .../model/participant/load/profile/LoadProfileStore.scala | 6 +++--- .../model/participant/load/profile/ProfileLoadModel.scala | 2 +- .../model/participant/load/profile/TypeDayProfile.scala | 4 ++-- .../model/participant/load/random/RandomLoadModel.scala | 2 +- .../participant/load/random/RandomLoadParamStore.scala | 4 ++-- .../model/participant/load/random/TypeDayParameters.scala | 8 ++++---- .../scala/edu/ie3/simona/model/thermal/ThermalHouse.scala | 2 +- .../scala/edu/ie3/simona/model/thermal/ThermalSink.scala | 2 +- .../edu/ie3/simona/model/thermal/ThermalStorage.scala | 2 +- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/Irradiance.scala | 2 +- .../scala/edu/ie3/util/scala/quantities/Irradiation.scala | 2 +- .../simona/agent/participant/ParticipantAgentMock.scala | 2 +- .../model/participant/load/LoadProfileStoreSpec.scala | 8 ++++---- .../model/participant/load/RandomLoadModelSpec.scala | 2 +- 33 files changed, 47 insertions(+), 47 deletions(-) diff --git a/docs/readthedocs/models/load_model.md b/docs/readthedocs/models/load_model.md index 798a8b5e97..be2046d717 100644 --- a/docs/readthedocs/models/load_model.md +++ b/docs/readthedocs/models/load_model.md @@ -132,7 +132,7 @@ F_t = -3.92 \cdot 10^{-10} \cdot t^4 + 3.2 \cdot 10^{-7} \cdot t + 1.24 $$ -The factor $F_t$, after calculation, shall be rounded to four decimal places. After multiplication with the profile value for given quarter-hour, the result should again be rounded to one decimal place. +The factor $F_t$, after calculation, shall be rounded to four decimal places. After multiplication with the profile value for given quarter hour, the result should again be rounded to one decimal place. #### Maximum value diff --git a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala index 8bfcef23da..eae1369de4 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/PowerFlowSupport.scala @@ -369,7 +369,7 @@ trait PowerFlowSupport { * from a [[ValidNewtonRaphsonPFResult]] * * @param validResult - * the result that should be converted to a human-readable debug string + * the result that should be converted to a human readable debug string * @param gridModel * the grid model this result comes from * @return diff --git a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala index 5efc4f053d..52e3a53a59 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgent.scala @@ -835,7 +835,7 @@ abstract class ParticipantAgent[ )(implicit outputConfig: NotifierConfig): Unit /** Abstract definition to clean up agent value stores after power flow - * convergence. This is necessary for agents whose results are time-dependent + * convergence. This is necessary for agents whose results are time dependent * e.g. storage agents * * @param baseStateData 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 c3459445fd..8cf02a9e09 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/ParticipantAgentFundamentals.scala @@ -368,7 +368,7 @@ protected trait ParticipantAgentFundamentals[ operationStart: Long, operationEnd: Long, ): SortedSet[Long] = { - /* The profile load model holds values in the specified resolution (e.g. for each full quarter-hour (00:00, + /* The profile load model holds values in the specified resolution (e.g. for each full quarter hour (00:00, * 00:15, ...)). As the simulation might not start at an integer multiple of the resolution, we have to * determine, what the first tick is, in which profile information do exist */ val firstProfileTick = @@ -1244,7 +1244,7 @@ protected trait ParticipantAgentFundamentals[ nodalVoltage, lastNodalVoltage, ).getOrElse { - /* If a fast reply is not possible, determine it the old-fashioned way */ + /* If a fast reply is not possible, determine it the old fashioned way */ determineReply( requestTick, baseStateData, @@ -1851,7 +1851,7 @@ protected trait ParticipantAgentFundamentals[ } /** To clean up agent value stores after power flow convergence. This is - * necessary for agents whose results are time-dependent e.g. storage agents + * necessary for agents whose results are time dependent e.g. storage agents * * @param baseStateData * Basic state data diff --git a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala index 0fc809d85a..89079e33bf 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/load/LoadAgentFundamentals.scala @@ -147,8 +147,8 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[ /* As participant agents always return their last known operation point on request, it is sufficient * to let a fixed load model determine it's operation point on: * 1) The first tick of the simulation - * 2) The tick, it turns on (in time-dependent operation) - * 3) The tick, it turns off (in time-dependent operation) + * 2) The tick, it turns on (in time dependent operation) + * 3) The tick, it turns off (in time dependent operation) * Coinciding ticks are summarized and the last tick is removed, as the change in operation status * doesn't affect anything then */ SortedSet[Long]( diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index 7408c8cbef..623e5a58c3 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -28,7 +28,7 @@ import scala.util.{Failure, Success, Try} * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation */ diff --git a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala index 0a592ccb68..f5b6dd9ca8 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala @@ -28,7 +28,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param nodeAUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala b/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala index af26beb12b..506ea804a1 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/NodeModel.scala @@ -23,7 +23,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param isSlack diff --git a/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala b/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala index 8a947e9ee0..5a5a457a5f 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/SwitchModel.scala @@ -22,7 +22,7 @@ import scala.util.{Failure, Success, Try} * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param nodeAUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala b/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala index 46ce7f3e44..8f61c2a897 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/Transformer3wModel.scala @@ -49,7 +49,7 @@ import scala.math.BigDecimal.RoundingMode * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param hvNodeUuid diff --git a/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala b/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala index 81682693fc..ee03ef837a 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/TransformerModel.scala @@ -33,7 +33,7 @@ import scala.math.BigDecimal.RoundingMode * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param hvNodeUuid diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index e1c9ed715a..19fbe3e601 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -94,7 +94,7 @@ final case class BMModel( applyLoadGradient(pEl) } - /** Calculates first time-dependent factor for heat demand + /** Calculates first time dependent factor for heat demand * @param time * the time * @return @@ -114,7 +114,7 @@ final case class BMModel( } } - /** Calculates second time-dependent factor for heat demand + /** Calculates second time dependent factor for heat demand * @param time * the time * @return diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index d5cd82c731..dbda236e4c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -29,7 +29,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index 993bc276c4..bf26b80fd8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -34,7 +34,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala index f245923356..44c70539d7 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/SystemParticipant.scala @@ -30,7 +30,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index 8a7eeefcb4..bffdd7fdae 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -41,7 +41,7 @@ import scala.collection.SortedSet * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index 8f6d8dd5bc..674e35efd4 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -47,7 +47,7 @@ import scala.collection.immutable.SortedSet * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param simulationStartDate diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala index cc4bc82c65..d1ab4bd657 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/FixedLoadModel.scala @@ -28,7 +28,7 @@ import java.util.UUID * @param uuid * unique identifier * @param id - * human-readable id + * human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index 63e4a0d4a5..f1e7d54f62 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -45,7 +45,7 @@ class LoadProfileStore private (val reader: Reader) { ) /** Returns the load profiles entry (average power consumption for the - * following quarter-hour) for given time and load profile. + * following quarter hour) for given time and load profile. * * @param time * the requested time @@ -77,7 +77,7 @@ class LoadProfileStore private (val reader: Reader) { } } - /** Returns the maximum average power consumption per quarter-hour for a given + /** Returns the maximum average power consumption per quarter hour for a given * load profile, calculated over all seasons and weekday types of given load * profile * @@ -171,7 +171,7 @@ object LoadProfileStore extends LazyLogging { val headerKeys: util.List[String] = parser.getHeaderNames - // skip last column "quarter-hour" + // skip last column "quarter hour" (for (i <- Range(0, headerKeys.size() - 1)) yield { val headerKey = headerKeys.get(i) val profileKey = LoadProfileKey(headerKey) diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala index e94f50867f..5e919a0064 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/ProfileLoadModel.scala @@ -25,7 +25,7 @@ import java.util.UUID * @param uuid * unique identifier * @param id - * human-readable id + * human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala index 22358772b1..dd2fcb6a18 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/TypeDayProfile.scala @@ -26,8 +26,8 @@ final case class TypeDayProfile(private val values: Array[Double]) { "You may only instantiate type day parameters with 96 values." ) - /** Returns a value for given time. If time is not a 15-min step, it is - * rounded up to the next 15-min slice. + /** Returns a value for given time. If time is not a 15 min step, it is + * rounded up to the next 15 min slice. * * @param time * the time diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index 4409d62cf2..a09e9bc8ff 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -33,7 +33,7 @@ import scala.util.Random * @param uuid * unique identifier * @param id - * human-readable id + * human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala index 394732bc4c..36635ae940 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadParamStore.scala @@ -105,7 +105,7 @@ case object RandomLoadParamStore extends LazyLogging { } catch { case e: FileIOException => throw new FileIOException( - s"Cannot determine random load parameters for day type '$dayType' and quarter-hour '$quartHour'", + s"Cannot determine random load parameters for day type '$dayType' and quarter hour '$quartHour'", e, ) } @@ -115,7 +115,7 @@ case object RandomLoadParamStore extends LazyLogging { case (_, quarterHour, randomLoadParameters) => (quarterHour, randomLoadParameters) } // Group entries by day type - .map { // For each day type, sort the parameters by quarter-hour and build a type day parameter object from it + .map { // For each day type, sort the parameters by quarter hour and build a type day parameter object from it case (dayType, quarterHourToParameters) => dayType -> TypeDayParameters( quarterHourToParameters.sortBy(_._1).map(_._2).toArray diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala index 57210c68b2..36360ff600 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/TypeDayParameters.scala @@ -12,8 +12,8 @@ import edu.ie3.simona.model.participant.load.DayType import edu.ie3.util.TimeUtil /** Stores a slice of random load parameters, that comprises a whole day (96 - * quarter-hours). The data describes a typical day, that can unequivocally be - * identified by its [[DayType]]. + * quarter hours). The data describes a typical day, that can unequivocally be + * identified by it's [[DayType]]. * * @param values * 96 quarter-hour values for this day type @@ -26,8 +26,8 @@ final case class TypeDayParameters( s"You may only instantiate type day parameters with 96 values. Apparent: ${values.length}." ) - /** Returns a value for given time. If time is not a 15-min step, it is - * rounded up to the next 15-min slice. + /** Returns a value for given time. If time is not a 15 min step, it is + * rounded up to the next 15 min slice. * * @param time * the time 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 ae933f3f03..71e992c4e0 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -37,7 +37,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala index 2b70983c73..97661b0201 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalSink.scala @@ -17,7 +17,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalBusInput * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala index c7818351b6..5886a4e7f8 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalStorage.scala @@ -19,7 +19,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 78a5afeb14..a18afc9ce9 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -37,7 +37,7 @@ trait SetupHelper extends LazyLogging { /** Build the [[GridAgentInitData]]. This also includes the determination of a * mapping from [[SubGridGate]] to [[ActorRef]] of the representing - * [[edu.ie3.simona.agent.grid.GridAgent]] as well as the look-up of the + * [[edu.ie3.simona.agent.grid.GridAgent]] as well as the look up of the * [[RefSystem]] to use being defined in the config. * * @param subGridContainer diff --git a/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala b/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala index 7476cbe225..2ad522980e 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/Irradiance.scala @@ -31,7 +31,7 @@ final class Irradiance private (val value: Double, val unit: IrradianceUnit) def *(that: Area): Power = Watts( this.toWattsPerSquareMeter * that.toSquareMeters ) - // the Hours(1).toSeconds is to convert watt-hours to watt-seconds which + // the Hours(1).toSeconds is to convert watt hours to watt seconds which // isn't a normal supported type in Squants def *(that: AreaTime): Energy = WattHours( this.toWattsPerSquareMeter * that.toSquareMeterSeconds / Hours(1).toSeconds diff --git a/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala b/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala index 306d2c11f5..5b685fde7e 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/Irradiation.scala @@ -22,7 +22,7 @@ final class Irradiation private (val value: Double, val unit: IrradiationUnit) def *(that: Area): Energy = WattHours( this.toWattHoursPerSquareMeter * that.toSquareMeters ) - // the Hours(1).toSeconds is to convert watt-hours to watt-seconds which + // the Hours(1).toSeconds is to convert watt hours to watt seconds which // isn't a normal supported type in Squants def /(that: Time): Irradiance = WattsPerSquareMeter( diff --git a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala index a3da7629ca..300bfb7e79 100644 --- a/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala +++ b/src/test/scala/edu/ie3/simona/agent/participant/ParticipantAgentMock.scala @@ -311,7 +311,7 @@ class ParticipantAgentMock( FixedRelevantData /** To clean up agent value stores after power flow convergence. This is - * necessary for agents whose results are time-dependent e.g. storage agents + * necessary for agents whose results are time dependent e.g. storage agents * @param baseStateData * Basic state data * @param currentTick diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala index 358da83a31..64701fa993 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/LoadProfileStoreSpec.scala @@ -49,22 +49,22 @@ class LoadProfileStoreSpec "2019-04-01T05:00:00+02:00[Europe/Berlin]", L0, 55.6d, - ), // Weekday, transitional, 20th quarter-hour + ), // Weekday, transitional, 20th quarter hour ( "2019-06-02T00:00:00+02:00[Europe/Berlin]", G0, 68.8d, - ), // Sunday, summer, 0th quarter-hour + ), // Sunday, summer, 0th quarter hour ( "2019-01-05T02:15:00+01:00[Europe/Berlin]", H0, 52.8d, - ), // Saturday, winter, 9th quarter-hour, 5th day -> dynamization factor 1.2473 + ), // Saturday, winter, 9th quarter hour, 5th day -> dynamization factor 1.2473 ( "2019-07-21T01:00:00+02:00[Europe/Berlin]", H0, 58.1d, - ), // Sunday, summer, 4th quarter-hour, 202nd day -> dynamization factor 0.7847 + ), // Sunday, summer, 4th quarter hour, 202nd day -> dynamization factor 0.7847 ) forAll(params) { diff --git a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala index 08457fc4c8..82fa1041e5 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/load/RandomLoadModelSpec.scala @@ -112,7 +112,7 @@ class RandomLoadModelSpec extends UnitSpec with TableDrivenPropertyChecks { loadInput.getCosPhiRated, ActivePower(Watts(268.6)), ) - /* Working day, 61st quarter-hour */ + /* Working day, 61th quarter hour */ val queryDate = TimeUtil.withDefaults.toZonedDateTime("2019-07-19T15:21:00Z") val expectedParams = new RandomLoadParameters( From 94f94b23cc32b18c8d1a9a90b07a30c682929ebb Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:25 +0100 Subject: [PATCH 106/137] Revert "remove brackets" This reverts commit fb6fbfb0fa0b31dc36aac820818a3c43d224ce70. --- src/main/scala/edu/ie3/simona/model/grid/LineModel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala index f5b6dd9ca8..60a2621630 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala @@ -77,7 +77,7 @@ final case class LineModel( * branch conductance g_ij between node A and B of the element in p.u. */ override def gij(): squants.Dimensionless = - super.gij() * amount + super.gij() * (amount) /** see [[PiEquivalentCircuit.g0()]] * From aa13cf05d05fe27d55f1ecc13136cfddded97612 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:34 +0100 Subject: [PATCH 107/137] Revert "Revert "remove brackets"" This reverts commit 94f94b23cc32b18c8d1a9a90b07a30c682929ebb. --- src/main/scala/edu/ie3/simona/model/grid/LineModel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala index 60a2621630..f5b6dd9ca8 100644 --- a/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala +++ b/src/main/scala/edu/ie3/simona/model/grid/LineModel.scala @@ -77,7 +77,7 @@ final case class LineModel( * branch conductance g_ij between node A and B of the element in p.u. */ override def gij(): squants.Dimensionless = - super.gij() * (amount) + super.gij() * amount /** see [[PiEquivalentCircuit.g0()]] * From c1b93bda4b7bb7d53287fec7685877ff04187032 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:44 +0100 Subject: [PATCH 108/137] Revert "more grammar" This reverts commit 379f927dafcbef84b93aa08056c5cd1aec80e234. --- CHANGELOG.md | 2 +- docs/readthedocs/models/chp_model.md | 2 +- docs/readthedocs/models/cts_model.md | 2 +- .../ie3/simona/agent/grid/DBFSAlgorithm.scala | 28 +++++++++---------- .../ie3/simona/config/ConfigFailFast.scala | 8 +++--- .../simona/model/participant/ChpModel.scala | 2 +- .../simona/model/system/Characteristic.scala | 2 +- .../thermal/CylindricalThermalStorage.scala | 2 +- .../edu/ie3/simona/util/CollectionUtils.scala | 2 +- .../edu/ie3/simona/util/ConfigUtil.scala | 4 +-- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04377de7c8..b683cd1327 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -224,7 +224,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for three winding transformers [#63](https://github.com/ie3-institute/simona/issues/63) - Handle incoming slack voltage accordingly - Allow multiple sub grid gates at one node (also allows multiple two winding transformers at one node) - - Perform power flow calculation in the highest grid, if a three winding transformer is apparent + - Perform power flow calculation in highest grid, if a three winding transformer is apparent - Write out results - Fixed broken layout in RTD documentation [#500](https://github.com/ie3-institute/simona/issues/500) - Corrected tests in RefSystemTest [#560](https://github.com/ie3-institute/simona/issues/560) diff --git a/docs/readthedocs/models/chp_model.md b/docs/readthedocs/models/chp_model.md index d7eb8232eb..c5f01364bf 100644 --- a/docs/readthedocs/models/chp_model.md +++ b/docs/readthedocs/models/chp_model.md @@ -6,7 +6,7 @@ This page documents the functionality of the CHP Model (combined heat and power ## Assumptions -The CHP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the CHP unit does not possess a memory. Losses of the heat storage are not considered. +The CHP unit is able to operate either at full load or not at all. Uncovered heat demand of former time-steps is not considered in the following steps, as the CHP unit does not posses a memory. Losses of the heat storage are not considered. ## Parameters diff --git a/docs/readthedocs/models/cts_model.md b/docs/readthedocs/models/cts_model.md index e03fa06563..5750820624 100644 --- a/docs/readthedocs/models/cts_model.md +++ b/docs/readthedocs/models/cts_model.md @@ -3,7 +3,7 @@ This page documents the functionality of the cylindrical thermal storage available in SIMONA. ## Behaviour -This storage model operates on volumes, although the functions it provides for other models all operate with energy. Internally the storage model converts energy to volume and vice versa with formulas specified below. Furthermore, it is assumed that the storage medium is water. Also, the model holds a variable for the current storage level. +This storage model operates on volumes, although the functions it provides for other models all operate with energy. Internally the storage model converts energy to volume and vice versa with formulas specified below. Furthermore it is assumed that the storage medium is water. Also the model holds a variable for the current storage level. ## Attributes, Units and Remarks diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index d0a23ea6da..36abbc1d16 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -197,7 +197,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { case None => // this happens if this agent is either a) the superior grid agent, because it will always get a request for // the next sweep, as it triggers calculations for the next sweep or b) at all other - // (non-last downstream grid agents) in sweep 0 + // (non last downstream grid agents) in sweep 0 ctx.log.debug( "Unable to find slack voltage for nodes '{}' in sweep '{}'. Try to get voltage of previous sweep.", nodeUuids, @@ -386,7 +386,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { // update the sweep value store and clear all received maps // note: normally it is expected that this has to be done after power flow calculations but for the sake - // of having it only once in the code we put this here. Otherwise, it would have to be put before EVERY + // of having it only once in the code we put this here. Otherwise it would have to been put before EVERY // return with a valid power flow result (currently happens already in two situations) val updatedGridAgentBaseData = if (stillPendingRequestAnswers.isEmpty) { @@ -955,13 +955,13 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { } } - /** Checks if all data has been received and if yes checks if there are any - * failed power flow indications from inferior grids. If both == true, then - * no [[Behavior]] change is triggered but the sweep value store is updated - * with a [[FailedPowerFlow]] information as well, the now used data is set - * to [[PowerFlowDoneData]] and this is escalated to the superior grid(s). If - * there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a behavior - * transition to [[handlePowerFlowCalculations]] is triggered. + /** Checks if all data has been received and if yes checks if the there are + * any failed power flow indications from inferior grids. If both == true, + * then no [[Behavior]] change is triggered but the sweep value store is + * updated with a [[FailedPowerFlow]] information as well, the now used data + * is set to [[PowerFlowDoneData]] and this is escalated to the superior + * grid(s). If there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a + * behavior transition to [[handlePowerFlowCalculations]] is triggered. * * If allReceived == false, no [[Behavior]] transition is triggered * @@ -1023,11 +1023,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { /** Normally only reached by the superior (dummy) agent! * - * Checks if all data has been received and if yes checks if there are any - * failed power flow indications from inferior grids. If both == true, then a - * finish simulation is triggered and depending on the configuration this - * step is skipped and the simulation goes on or this leads to a termination - * of the simulation due to a failed power flow calculation. + * Checks if all data has been received and if yes checks if the there are + * any failed power flow indications from inferior grids. If both == true, + * then a finish simulation is triggered and depending on the configuration + * this step is skipped and the simulation goes on or this leads to a + * termination of the simulation due to a failed power flow calculation. * * If there is no [[FailedPowerFlow]] in the [[GridAgentBaseData]] a * [[Behavior]] transition to [[checkPowerDifferences]] is triggered. diff --git a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala index 0eaa7e30ba..20c0d201f9 100644 --- a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala +++ b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala @@ -314,8 +314,8 @@ case object ConfigFailFast extends LazyLogging { ) } - /** Check participants' basic runtime configurations, as well as in default as - * in individual configs. This comprises + /** Check participants's basic runtime configurations, as well as in default + * as in individual configs. This comprises * i.e. uuid and scaling factor */ private def checkBaseRuntimeConfigs( @@ -663,7 +663,7 @@ case object ConfigFailFast extends LazyLogging { } - /** Check the config subtree for output parameterization + /** Check the config sub tree for output parameterization * * @param subConfig * Output sub config tree for participants @@ -685,7 +685,7 @@ case object ConfigFailFast extends LazyLogging { checkIndividualOutputConfigs(subConfig.individualConfigs) } - /** Check the config subtree for output parameterization + /** Check the config sub tree for output parameterization * * @param subConfig * Output sub config tree for participants diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 795c62c9f8..5af1b68236 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -31,7 +31,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operationInterval * Interval, in which the system is in operation * @param qControl diff --git a/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala b/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala index e4b7758b8f..2088ca6cdc 100644 --- a/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala +++ b/src/main/scala/edu/ie3/simona/model/system/Characteristic.scala @@ -14,7 +14,7 @@ import squants.Quantity import scala.collection.SortedSet import scala.reflect.ClassTag -/** Describes a mapping of an x-y-pairs with possibility to interpolate the y +/** Describes a mapping of a x-y-pairs with possibility to interpolate the y * values based on the provided x value */ trait Characteristic[A <: Quantity[A], O <: Quantity[O]] { diff --git a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala index 8cde5ab086..fedea75204 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala @@ -40,7 +40,7 @@ import java.util.UUID * @param uuid * the element's uuid * @param id - * the element's human-readable id + * the element's human readable id * @param operatorInput * Operator input * @param operationTime diff --git a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala index 6f737a0d1b..d73a2755bf 100644 --- a/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala +++ b/src/main/scala/edu/ie3/simona/util/CollectionUtils.scala @@ -98,7 +98,7 @@ object CollectionUtils { * smallest map key is provided. * * @param map - * containing the (k,v) pairs (e.g. x,y pairs) + * containing containing the (k,v) pairs (e.g. x,y pairs) * @param key * the key values are needed for * @return diff --git a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala index a91ff99924..f32b66ed5f 100644 --- a/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala +++ b/src/main/scala/edu/ie3/simona/util/ConfigUtil.scala @@ -73,7 +73,7 @@ object ConfigUtil { * participants config for faster access. * * @param subConfig - * Configuration subtree for the behaviour of system participants + * Configuration sub tree for the behaviour of system participants * @return * a matching config utility */ @@ -124,7 +124,7 @@ object ConfigUtil { * @param defaultConfig * Default config to use, when there is no specific one * @param configs - * Mapping from notifier identifier to its notifier configuration + * Mapping from notifier identifier to it's notifier configuration */ final case class OutputConfigUtil( private val defaultConfig: NotifierConfig, From a2631488ecfaad6e73cd3f0e51b727ecbbe3f0a4 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:46 +0100 Subject: [PATCH 109/137] Revert "adding some commas" This reverts commit 5f11ab02a915a853a6b978192973db4698b6a388. --- src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 4 ++-- .../simona/agent/participant/statedata/BaseStateData.scala | 2 +- .../simona/test/common/model/grid/BasicGridWithSwitches.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index 36abbc1d16..d608d49393 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -737,7 +737,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { gridAgentBaseData.powerFlowParams.sweepTimeout, )(ctx) - // when we don't have inferior grids and no assets both methods return None, and we can skip doing another power + // when we don't have inferior grids and no assets both methods return None and we can skip doing another power // flow calculation otherwise we go back to simulate grid and wait for the answers if (!askForAssetPowersOpt && !askForInferiorGridPowersOpt) { ctx.log.debug( @@ -832,7 +832,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { ) /* Regarding the power flow result of this grid, there are two cases. If this is the "highest" grid in a - * simulation without a three winding transformer, the grid consists of only one node, and we can mock the power + * simulation without a three winding transformer, the grid consists of only one node and we can mock the power * flow results. If there is a three winding transformer apparent, we actually have to perform power flow * calculations, as the high voltage branch of the transformer is modeled here. */ (if (gridModel.gridComponents.transformers3w.isEmpty) { diff --git a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala index 9627ee1578..96758a2d16 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/statedata/BaseStateData.scala @@ -51,7 +51,7 @@ trait BaseStateData[+PD <: PrimaryDataWithApparentPower[PD]] */ val modelUuid: UUID - /** By default, the agent should be triggered in the same tick, where data is + /** By default the agent should be triggered in the same tick, where data is * incoming from primary or secondary sources. However, if there is no other * information needed, we might have the need to schedule ourselves for * activation triggers diff --git a/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala b/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala index 5781848e1b..bd709daa01 100644 --- a/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala +++ b/src/test/scala/edu/ie3/simona/test/common/model/grid/BasicGridWithSwitches.scala @@ -20,7 +20,7 @@ import tech.units.indriya.quantity.Quantities import java.util.UUID -/** Note: the line parameters are NOT adapted. Instead, the line params from +/** Note: the line parameters are NOT adapted. Instead the line params from * [[FiveLinesWithNodes]] are used instead! * * {{{ From d2dfc633958d819249f09bd04b566e35ef6d8a92 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:37:48 +0100 Subject: [PATCH 110/137] Revert "using past participle" This reverts commit 990b1cfbc44faf30d3c6186a4a216169906f9b65. --- .../scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala index d608d49393..5f21b06a39 100644 --- a/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala +++ b/src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala @@ -1153,7 +1153,7 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { * @param askTimeout * a timeout for the request * @return - * true if this grids contains assets or false if no request has been sent + * true if this grids contains assets or false if no request has been send * due to non-existence of assets */ private def askForAssetPowers( @@ -1383,11 +1383,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport { } /** This method uses [[ActorContext.pipeToSelf()]] to send a future message to - * itself. If the future is a [[Success]] the message is sent, else a - * [[WrappedFailure]] with the thrown error is sent. + * itself. If the future is a [[Success]] the message is send, else a + * [[WrappedFailure]] with the thrown error is send. * * @param future - * future message that should be sent to the agent after it was processed + * future message that should be send to the agent after it was processed * @param ctx * [[ActorContext]] of the receiving actor */ From 601c1df597253081bd9a535ca6c3fd28f8393b63 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:42:09 +0100 Subject: [PATCH 111/137] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04377de7c8..8c26eb2c91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -132,6 +132,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) - Fix filter for thermal result checking for lastTick not for currentTick [#1008](https://github.com/ie3-institute/simona/issues/1008) - Fixed `CHANGELOG` entry for issue ([#103](https://github.com/ie3-institute/simona/issues/103)) [#941](https://github.com/ie3-institute/simona/issues/941) +- Fix grammar and spelling in docs and comments [#1022](https://github.com/ie3-institute/simona/issues/1022) ## [3.0.0] - 2023-08-07 From 6d1ae76fe3b36d3d310f1fcf5ce4419fcbd9a3ac Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 10:43:11 +0100 Subject: [PATCH 112/137] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b683cd1327..27b22781d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -132,6 +132,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed ThermalStorageResults having multiple entries [#924](https://github.com/ie3-institute/simona/issues/924) - Fix filter for thermal result checking for lastTick not for currentTick [#1008](https://github.com/ie3-institute/simona/issues/1008) - Fixed `CHANGELOG` entry for issue ([#103](https://github.com/ie3-institute/simona/issues/103)) [#941](https://github.com/ie3-institute/simona/issues/941) +- Fix some minor issues and findings from inspections [#1019](https://github.com/ie3-institute/simona/issues/1019) ## [3.0.0] - 2023-08-07 From ee7fbcccaa565087bdc5a2486d20eed6d548ae02 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 12:54:42 +0100 Subject: [PATCH 113/137] use zeroKW and zeroKWH within thermal unit tests --- .../ThermalGridWithHouseAndStorageSpec.scala | 23 +++++++------- .../ThermalGridWithHouseOnlySpec.scala | 17 +++++----- .../ThermalGridWithStorageOnlySpec.scala | 31 ++++++++++--------- 3 files changed, 37 insertions(+), 34 deletions(-) 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 1ea45a656d..f2829532cd 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala @@ -13,6 +13,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{ HouseTemperatureLowerBoundaryReached, HouseTemperatureUpperBoundaryReached, } +import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH} import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageState import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{ StorageEmpty, @@ -103,15 +104,15 @@ class ThermalGridWithHouseAndStorageSpec testGridAmbientTemperature, ThermalGrid.startingState(thermalGrid), ) - houseDemand.required should approximate(KilowattHours(0d)) + houseDemand.required should approximate(zeroKWH) houseDemand.possible should approximate(KilowattHours(31.05009722d)) storageDemand.required should approximate(KilowattHours(1150d)) storageDemand.possible should approximate(KilowattHours(1150d)) updatedThermalGridState.houseState shouldBe Some( - ThermalHouseState(10800, Kelvin(292.0799935185185), Kilowatts(0d)) + ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW) ) updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d)) + ThermalStorageState(10800, zeroKWH, zeroKW) ) } @@ -136,10 +137,10 @@ class ThermalGridWithHouseAndStorageSpec storageDemand.required should approximate(KilowattHours(1150d)) storageDemand.possible should approximate(KilowattHours(1150d)) updatedThermalGridState.houseState shouldBe Some( - ThermalHouseState(10800, Celsius(15.959996296296296), Kilowatts(0d)) + ThermalHouseState(10800, Celsius(15.959996296296296), zeroKW) ) updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d)) + ThermalStorageState(10800, zeroKWH, zeroKW) ) } } @@ -159,7 +160,7 @@ class ThermalGridWithHouseAndStorageSpec storageState.copy(storedEnergy = initialLoading) ) ) - val externalQDot = Kilowatts(0d) + val externalQDot = zeroKW val (updatedGridState, reachedThreshold) = thermalGrid invokePrivate handleConsumption( @@ -216,7 +217,7 @@ class ThermalGridWithHouseAndStorageSpec ) => houseTick shouldBe 0L innerTemperature should approximate(Celsius(18.9999d)) - qDotHouse should approximate(Kilowatts(0d)) + qDotHouse should approximate(zeroKW) storageTick shouldBe 0L storedEnergy should approximate(initialLoading) @@ -228,7 +229,7 @@ class ThermalGridWithHouseAndStorageSpec } "revising infeed from storage to house" should { - val zeroInflux = Kilowatts(0d) + val zeroInflux = zeroKW val tick = 3600L val ambientTemperature = Celsius(14d) "hand back unaltered information if needed information is missing" in { @@ -371,7 +372,7 @@ class ThermalGridWithHouseAndStorageSpec ( ThermalStorageState( tick, - KilowattHours(0d), + zeroKWH, testGridQDotInfeed, ), Some(StorageEmpty(tick)), @@ -517,7 +518,7 @@ class ThermalGridWithHouseAndStorageSpec .getOrElse(fail("No initial storage state found")) ) - qDotStorage should approximate(Kilowatts(0d)) + qDotStorage should approximate(zeroKW) case _ => fail("Thermal grid state has been calculated wrong.") } @@ -554,7 +555,7 @@ class ThermalGridWithHouseAndStorageSpec ) => houseTick shouldBe 0L innerTemperature should approximate(Celsius(20.99999167d)) - qDotHouse should approximate(Kilowatts(0d)) + qDotHouse should approximate(zeroKW) storageTick shouldBe 0L storedEnergy should approximate( diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala index eb447d0fc4..c0d6226694 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala @@ -13,6 +13,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{ HouseTemperatureLowerBoundaryReached, HouseTemperatureUpperBoundaryReached, } +import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH} import edu.ie3.simona.test.common.UnitSpec import squants.energy._ import squants.thermal.Celsius @@ -90,10 +91,10 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { houseDemand.required should approximate(expectedHouseDemand.required) houseDemand.possible should approximate(expectedHouseDemand.possible) - storageDemand.required should approximate(KilowattHours(0d)) - storageDemand.possible should approximate(KilowattHours(0d)) + storageDemand.required should approximate(zeroKWH) + storageDemand.possible should approximate(zeroKWH) updatedThermalGridState.houseState shouldBe Some( - ThermalHouseState(10800, Kelvin(292.0799935185185), Kilowatts(0d)) + ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW) ) updatedThermalGridState.storageState shouldBe None } @@ -108,7 +109,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { "deliver the house state by just letting it cool down, if just no infeed is given" in { val tick = 0L val gridState = ThermalGrid.startingState(thermalGrid) - val externalQDot = Megawatts(0d) + val externalQDot =zeroKW val (updatedGridState, reachedThreshold) = thermalGrid invokePrivate handleConsumption( @@ -154,7 +155,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { ) => tick shouldBe 0L innerTemperature should approximate(Celsius(18.9999d)) - qDot should approximate(Megawatts(0d)) + qDot should approximate(zeroKW) case _ => fail("Thermal grid state has been calculated wrong.") } reachedThreshold shouldBe Some( @@ -239,7 +240,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { ) => tick shouldBe 0L innerTemperature should approximate(Celsius(18.9999d)) - qDot should approximate(Megawatts(0d)) + qDot should approximate(zeroKW) thresholdTick shouldBe 154285L case _ => fail("Thermal grid state updated failed") } @@ -251,7 +252,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { ThermalGrid.startingState(thermalGrid), testGridAmbientTemperature, testGridAmbientTemperature, - Megawatts(0d), + zeroKW, ) match { case ( ThermalGridState( @@ -262,7 +263,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { ) => tick shouldBe 0L innerTemperature should approximate(Celsius(18.9999d)) - qDot should approximate(Kilowatts(0d)) + qDot should approximate(zeroKW) thresholdTick shouldBe 154285L case _ => fail("Thermal grid state updated failed") } 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 93a45e3180..9ef8dbb424 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala @@ -17,6 +17,7 @@ import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{ StorageFull, } import edu.ie3.simona.test.common.UnitSpec +import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH} import squants.energy._ import squants.thermal.Celsius import squants.{Energy, Power, Temperature} @@ -88,13 +89,13 @@ class ThermalGridWithStorageOnlySpec ThermalGrid.startingState(thermalGrid), ) - houseDemand.required should approximate(KilowattHours(0d)) - houseDemand.possible should approximate(KilowattHours(0d)) + houseDemand.required should approximate(zeroKWH) + houseDemand.possible should approximate(zeroKWH) storageDemand.required should approximate(KilowattHours(1150d)) storageDemand.possible should approximate(KilowattHours(1150d)) updatedThermalGridState.houseState shouldBe None updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d)) + ThermalStorageState(10800, zeroKWH, zeroKW) ) } @@ -108,17 +109,17 @@ class ThermalGridWithStorageOnlySpec testGridAmbientTemperature, ThermalGridState( None, - Some(ThermalStorageState(0L, KilowattHours(575d), Kilowatts(0d))), + Some(ThermalStorageState(0L, KilowattHours(575d), zeroKW)), ), ) - houseDemand.required should approximate(KilowattHours(0d)) - houseDemand.possible should approximate(KilowattHours(0d)) - storageDemand.required should approximate(KilowattHours(0d)) + houseDemand.required should approximate(zeroKWH) + houseDemand.possible should approximate(zeroKWH) + storageDemand.required should approximate(zeroKWH) storageDemand.possible should approximate(KilowattHours(575d)) updatedThermalGridState.houseState shouldBe None updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800L, KilowattHours(575d), Kilowatts(0d)) + ThermalStorageState(10800L, KilowattHours(575d), zeroKW) ) } } @@ -138,7 +139,7 @@ class ThermalGridWithStorageOnlySpec ThermalStorageState( 0L, KilowattHours(200d), - Kilowatts(0d), + zeroKW, ) ) ) @@ -191,7 +192,7 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(0d)) + storedEnergy should approximate(zeroKWH) qDot should approximate(testGridQDotInfeed) case _ => fail("Thermal grid state has been calculated wrong.") } @@ -217,7 +218,7 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(0d)) + storedEnergy should approximate(zeroKWH) qDot should approximate(testGridQDotInfeed) case _ => fail("Thermal grid state updated failed") } @@ -233,7 +234,7 @@ class ThermalGridWithStorageOnlySpec ThermalStorageState( 0L, KilowattHours(200d), - Kilowatts(0d), + zeroKW, ) ) ), @@ -262,7 +263,7 @@ class ThermalGridWithStorageOnlySpec ThermalGrid.startingState(thermalGrid), testGridAmbientTemperature, testGridAmbientTemperature, - Kilowatts(0d), + zeroKW, ) updatedState match { case ( @@ -273,8 +274,8 @@ class ThermalGridWithStorageOnlySpec None, ) => tick shouldBe 0L - storedEnergy should approximate(KilowattHours(0d)) - qDot should approximate(Megawatts(0d)) + storedEnergy should approximate(zeroKWH) + qDot should approximate(zeroKW) case _ => fail("Thermal grid state updated failed") } From bb2f81027a092441a1e9d7a8ce2ea25e11bfeaad Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 12:58:05 +0100 Subject: [PATCH 114/137] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b683cd1327..4a3acbb5d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646) - Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898) - Refactoring of `ThermalGrid.energyGrid` to distinguish between demand of house and storage [#928](https://github.com/ie3-institute/simona/issues/928) +- Refactoring to use zeroKW and zeroKWH in thermal grid unit tests [#1023](https://github.com/ie3-institute/simona/issues/1023) ### Fixed - Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505) From 86fcf1ee5976ff984bb7c6b0929f2369ead3f88c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 12:58:16 +0100 Subject: [PATCH 115/137] fmt --- .../ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala index c0d6226694..d50b1e558a 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala @@ -109,7 +109,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { "deliver the house state by just letting it cool down, if just no infeed is given" in { val tick = 0L val gridState = ThermalGrid.startingState(thermalGrid) - val externalQDot =zeroKW + val externalQDot = zeroKW val (updatedGridState, reachedThreshold) = thermalGrid invokePrivate handleConsumption( From 6892b01ba800ec4715ef852bc16dc3c3c6ff5fcb Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 13:27:36 +0100 Subject: [PATCH 116/137] refactoring zeroKWH to zeroKWh and zeroMWH to zeroMWh --- .../simona/model/participant/ChpModel.scala | 8 ++++---- .../simona/model/participant/HpModel.scala | 2 +- .../model/participant/StorageModel.scala | 2 +- .../model/participant/evcs/EvcsModel.scala | 2 +- .../thermal/CylindricalThermalStorage.scala | 6 +++--- .../simona/model/thermal/ThermalGrid.scala | 10 +++++----- .../simona/model/thermal/ThermalHouse.scala | 6 +++--- .../scala/quantities/DefaultQuantities.scala | 4 ++-- .../ThermalGridWithHouseAndStorageSpec.scala | 10 +++++----- .../ThermalGridWithHouseOnlySpec.scala | 6 +++--- .../ThermalGridWithStorageOnlySpec.scala | 20 +++++++++---------- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 5af1b68236..56bd446412 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -118,7 +118,7 @@ final case class ChpModel( chpData: ChpRelevantData ): ChpRelevantData => ChpState = { val isRunning = chpData.chpState.isRunning - val hasDemand = chpData.heatDemand > DefaultQuantities.zeroKWH + val hasDemand = chpData.heatDemand > DefaultQuantities.zeroKWh val isCovered = isDemandCovered(chpData) (isRunning, hasDemand, isCovered) match { @@ -145,7 +145,7 @@ final case class ChpModel( isRunning = false, chpData.currentTimeTick, DefaultQuantities.zeroKW, - DefaultQuantities.zeroKWH, + DefaultQuantities.zeroKWh, ) /** The demand cannot be covered, therefore this function sets storage level @@ -182,7 +182,7 @@ final case class ChpModel( isRunning = false, chpData.currentTimeTick, DefaultQuantities.zeroKW, - DefaultQuantities.zeroKWH, + DefaultQuantities.zeroKWh, ) } @@ -199,7 +199,7 @@ final case class ChpModel( chpData: ChpRelevantData ): ChpState = { val differenceEnergy = chpEnergy(chpData) - chpData.heatDemand - if (differenceEnergy < zeroKWH) { + if (differenceEnergy < zeroKWh) { // Returned lack is always zero, because demand is covered. storage.tryToTakeAndReturnLack(differenceEnergy * -1) calculateStateRunningSurplus(chpData) diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index bf26b80fd8..8a6963e94a 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -237,7 +237,7 @@ final case class HpModel( val noThermalStorageOrThermalStorageIsEmpty: Boolean = updatedGridState.storageState.isEmpty || updatedGridState.storageState .exists( - _.storedEnergy =~ zeroKWH + _.storedEnergy =~ zeroKWh ) val houseDemand = diff --git a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala index 02f82d2670..742f5d8f68 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/StorageModel.scala @@ -47,7 +47,7 @@ final case class StorageModel( cosPhiRated, ) { - private val minEnergy = zeroKWH + private val minEnergy = zeroKWh /** Tolerance for power comparisons. With very small (dis-)charging powers, * problems can occur when calculating the future tick at which storage is diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index a1d21252ec..4f0e4d9730 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -222,7 +222,7 @@ final case class EvcsModel( tickStop > lastSchedulingTick && tickStart < currentTick } .sortBy(_.tickStart) - .foldLeft(zeroKWH) { case (accumulatedEnergy, scheduleEntry) => + .foldLeft(zeroKWh) { case (accumulatedEnergy, scheduleEntry) => /* Only the timeframe from the start of last scheduling update and current tick must be considered */ val trimmedEntry = trimScheduleEntry( scheduleEntry, diff --git a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala index fedea75204..7640505bb1 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala @@ -143,7 +143,7 @@ final case class CylindricalThermalStorage( override def tryToStoreAndReturnRemainder( addedEnergy: Energy ): Option[Energy] = { - if (addedEnergy > zeroKWH) { + if (addedEnergy > zeroKWh) { _storedEnergy = _storedEnergy + addedEnergy if (_storedEnergy > maxEnergyThreshold) { val surplus = _storedEnergy - maxEnergyThreshold @@ -158,7 +158,7 @@ final case class CylindricalThermalStorage( override def tryToTakeAndReturnLack( takenEnergy: Energy ): Option[Energy] = { - if (takenEnergy > zeroKWH) { + if (takenEnergy > zeroKWh) { _storedEnergy = _storedEnergy - takenEnergy if (_storedEnergy < minEnergyThreshold) { val lack = minEnergyThreshold - _storedEnergy @@ -185,7 +185,7 @@ object CylindricalThermalStorage { */ def apply( input: CylindricalStorageInput, - initialStoredEnergy: Energy = DefaultQuantities.zeroKWH, + initialStoredEnergy: Energy = DefaultQuantities.zeroKWh, ): CylindricalThermalStorage = { val minEnergyThreshold: Energy = CylindricalThermalStorage.volumeToEnergy( diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 0d868e64df..747e694243 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -113,7 +113,7 @@ final case class ThermalGrid( storage.getMaxEnergyThreshold - storedEnergy } else { - zeroMWH + zeroMWh } } @@ -128,7 +128,7 @@ final case class ThermalGrid( } .getOrElse( - ThermalEnergyDemand(zeroMWH, zeroMWH), + ThermalEnergyDemand(zeroMWh, zeroMWh), None, ) } @@ -559,7 +559,7 @@ object ThermalGrid { possible + rhs.possible, ) - def hasRequiredDemand: Boolean = required > zeroMWH + def hasRequiredDemand: Boolean = required > zeroMWh def hasAdditionalDemand: Boolean = possible > required } @@ -586,8 +586,8 @@ object ThermalGrid { } def noDemand: ThermalEnergyDemand = ThermalEnergyDemand( - zeroMWH, - zeroMWH, + zeroMWh, + zeroMWh, ) } } 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 71e992c4e0..aaae60aeab 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala @@ -123,7 +123,7 @@ final case class ThermalHouse( ) ) energy(targetTemperature, currentInnerTemp) else - zeroMWH + zeroMWh val possibleEnergy = if (!isInnerTemperatureTooHigh(currentInnerTemp)) { @@ -131,7 +131,7 @@ final case class ThermalHouse( // there is an amount of optional energy that could be stored energy(upperBoundaryTemperature, currentInnerTemp) } else - zeroMWH + zeroMWh ThermalEnergyDemand(requiredEnergy, possibleEnergy) } @@ -323,7 +323,7 @@ final case class ThermalHouse( qDot: Power, ): Option[Long] = { val flexibleEnergy = energy(higherTemperature, lowerTemperature) - if (flexibleEnergy < zeroMWH) + if (flexibleEnergy < zeroMWh) None else { val duration = Math.round( diff --git a/src/main/scala/edu/ie3/util/scala/quantities/DefaultQuantities.scala b/src/main/scala/edu/ie3/util/scala/quantities/DefaultQuantities.scala index ac401db84c..698f757eff 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/DefaultQuantities.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/DefaultQuantities.scala @@ -17,8 +17,8 @@ object DefaultQuantities { val zeroKVAr: ReactivePower = Kilovars(0d) val zeroMVAr: ReactivePower = Megavars(0d) - val zeroKWH: Energy = KilowattHours(0d) - val zeroMWH: Energy = MegawattHours(0d) + val zeroKWh: Energy = KilowattHours(0d) + val zeroMWh: Energy = MegawattHours(0d) val zeroPU: Dimensionless = Each(0d) 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 f2829532cd..7d8d2c27f1 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseAndStorageSpec.scala @@ -13,7 +13,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{ HouseTemperatureLowerBoundaryReached, HouseTemperatureUpperBoundaryReached, } -import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH} +import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWh} import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageState import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{ StorageEmpty, @@ -104,7 +104,7 @@ class ThermalGridWithHouseAndStorageSpec testGridAmbientTemperature, ThermalGrid.startingState(thermalGrid), ) - houseDemand.required should approximate(zeroKWH) + houseDemand.required should approximate(zeroKWh) houseDemand.possible should approximate(KilowattHours(31.05009722d)) storageDemand.required should approximate(KilowattHours(1150d)) storageDemand.possible should approximate(KilowattHours(1150d)) @@ -112,7 +112,7 @@ class ThermalGridWithHouseAndStorageSpec ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW) ) updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800, zeroKWH, zeroKW) + ThermalStorageState(10800, zeroKWh, zeroKW) ) } @@ -140,7 +140,7 @@ class ThermalGridWithHouseAndStorageSpec ThermalHouseState(10800, Celsius(15.959996296296296), zeroKW) ) updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800, zeroKWH, zeroKW) + ThermalStorageState(10800, zeroKWh, zeroKW) ) } } @@ -372,7 +372,7 @@ class ThermalGridWithHouseAndStorageSpec ( ThermalStorageState( tick, - zeroKWH, + zeroKWh, testGridQDotInfeed, ), Some(StorageEmpty(tick)), diff --git a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala index d50b1e558a..6b14ee3780 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala @@ -13,7 +13,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{ HouseTemperatureLowerBoundaryReached, HouseTemperatureUpperBoundaryReached, } -import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH} +import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWh} import edu.ie3.simona.test.common.UnitSpec import squants.energy._ import squants.thermal.Celsius @@ -91,8 +91,8 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData { houseDemand.required should approximate(expectedHouseDemand.required) houseDemand.possible should approximate(expectedHouseDemand.possible) - storageDemand.required should approximate(zeroKWH) - storageDemand.possible should approximate(zeroKWH) + storageDemand.required should approximate(zeroKWh) + storageDemand.possible should approximate(zeroKWh) updatedThermalGridState.houseState shouldBe Some( ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW) ) 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 9ef8dbb424..ead1ff6b03 100644 --- a/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala +++ b/src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala @@ -17,7 +17,7 @@ import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{ StorageFull, } import edu.ie3.simona.test.common.UnitSpec -import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH} +import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWh} import squants.energy._ import squants.thermal.Celsius import squants.{Energy, Power, Temperature} @@ -89,13 +89,13 @@ class ThermalGridWithStorageOnlySpec ThermalGrid.startingState(thermalGrid), ) - houseDemand.required should approximate(zeroKWH) - houseDemand.possible should approximate(zeroKWH) + houseDemand.required should approximate(zeroKWh) + houseDemand.possible should approximate(zeroKWh) storageDemand.required should approximate(KilowattHours(1150d)) storageDemand.possible should approximate(KilowattHours(1150d)) updatedThermalGridState.houseState shouldBe None updatedThermalGridState.storageState shouldBe Some( - ThermalStorageState(10800, zeroKWH, zeroKW) + ThermalStorageState(10800, zeroKWh, zeroKW) ) } @@ -113,9 +113,9 @@ class ThermalGridWithStorageOnlySpec ), ) - houseDemand.required should approximate(zeroKWH) - houseDemand.possible should approximate(zeroKWH) - storageDemand.required should approximate(zeroKWH) + houseDemand.required should approximate(zeroKWh) + houseDemand.possible should approximate(zeroKWh) + storageDemand.required should approximate(zeroKWh) storageDemand.possible should approximate(KilowattHours(575d)) updatedThermalGridState.houseState shouldBe None updatedThermalGridState.storageState shouldBe Some( @@ -192,7 +192,7 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(zeroKWH) + storedEnergy should approximate(zeroKWh) qDot should approximate(testGridQDotInfeed) case _ => fail("Thermal grid state has been calculated wrong.") } @@ -218,7 +218,7 @@ class ThermalGridWithStorageOnlySpec Some(ThermalStorageState(tick, storedEnergy, qDot)), ) => tick shouldBe 0L - storedEnergy should approximate(zeroKWH) + storedEnergy should approximate(zeroKWh) qDot should approximate(testGridQDotInfeed) case _ => fail("Thermal grid state updated failed") } @@ -274,7 +274,7 @@ class ThermalGridWithStorageOnlySpec None, ) => tick shouldBe 0L - storedEnergy should approximate(zeroKWH) + storedEnergy should approximate(zeroKWh) qDot should approximate(zeroKW) case _ => fail("Thermal grid state updated failed") From 2fd4f451313ad2c80fa08b4f5efc55855ce3950c Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 13:53:14 +0100 Subject: [PATCH 117/137] including reviewers comments --- .../participant/fixedfeedin/FixedFeedInAgentFundamentals.scala | 2 +- src/main/scala/edu/ie3/simona/main/RunSimona.scala | 2 +- src/main/scala/edu/ie3/simona/model/SystemComponent.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala index 233246ca81..0b8845d80c 100644 --- a/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala +++ b/src/main/scala/edu/ie3/simona/agent/participant/fixedfeedin/FixedFeedInAgentFundamentals.scala @@ -132,7 +132,7 @@ protected trait FixedFeedInAgentFundamentals val lastTickInSimulation = simulationEndDate.toTick(simulationStartDate) val dataTicks = /* As participant agents always return their last known operation point on request, it is sufficient - * to let a fixed model determine its operation point on: + * to let a FixedFeedIn-Model determine its operation point on: * 1) The first tick of the simulation * 2) The tick, it turns on (in time-dependent operation) * 3) The tick, it turns off (in time-dependent operation) diff --git a/src/main/scala/edu/ie3/simona/main/RunSimona.scala b/src/main/scala/edu/ie3/simona/main/RunSimona.scala index 9d03f38665..b08db66361 100644 --- a/src/main/scala/edu/ie3/simona/main/RunSimona.scala +++ b/src/main/scala/edu/ie3/simona/main/RunSimona.scala @@ -87,7 +87,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { } /** Method to be implemented to set up everything that is necessary for a - * simulations. This is by creating an instance of [[SimonaSetup]] + * simulation. This is by creating an instance of [[SimonaSetup]] * implementation * * @param args diff --git a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala index efc70ba0cf..7408c8cbef 100644 --- a/src/main/scala/edu/ie3/simona/model/SystemComponent.scala +++ b/src/main/scala/edu/ie3/simona/model/SystemComponent.scala @@ -40,7 +40,7 @@ abstract class SystemComponent( private val elementType: String = this.getClass.getSimpleName - // check if an uuid is provided + // check if a uuid is provided if (Option.apply(uuid).isEmpty) throw new InvalidParameterException( s"Uuid of $elementType $id cannot be null!" From b5b671e14a66d910a7e136efe3ffa27944f13cd8 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 15 Nov 2024 14:06:53 +0100 Subject: [PATCH 118/137] Small changes to comments. --- .../edu/ie3/simona/service/primary/PrimaryServiceWorker.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 60d0056b40..beada9489d 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -159,7 +159,7 @@ final case class PrimaryServiceWorker[V <: Value]( Success(initializedStateData, maybeNextTick) case (Some(tick), _) if tick > 0L => - /* The start of the data needs to be at the first tick of the simulation or before. */ + /* The start of the data needs to be at the first tick of the simulation. */ Failure( new ServiceRegistrationException( s"The data for the timeseries '${source.getTimeSeries.getUuid}' starts after the start of this simulation (tick: $tick)! This is not allowed!" @@ -167,6 +167,7 @@ final case class PrimaryServiceWorker[V <: Value]( ) case _ => + /* No data for the simulation. */ Failure( new ServiceRegistrationException( s"No appropriate data found within simulation time range in timeseries '${source.getTimeSeries.getUuid}'!" From c3efd4fc4904eeb70ebba4b27a0110ec7afff926 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 14:30:55 +0100 Subject: [PATCH 119/137] another one --- src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala index 0d868e64df..6a4b708ea4 100644 --- a/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala +++ b/src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala @@ -446,7 +446,7 @@ final case class ThermalGrid( case _ => (maybeHouseState, maybeStorageState) } - /** Convert the given state of the thermal grid into result models of it's + /** Convert the given state of the thermal grid into result models of its * constituent models * * @param currentTick From 77c7c6cf199854b532fd8ab3531273021c32d885 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 15 Nov 2024 14:34:04 +0100 Subject: [PATCH 120/137] some more grammar --- .../ie3/simona/model/control/TransformerControlGroupModel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/control/TransformerControlGroupModel.scala b/src/main/scala/edu/ie3/simona/model/control/TransformerControlGroupModel.scala index 2354770480..c6d7471787 100644 --- a/src/main/scala/edu/ie3/simona/model/control/TransformerControlGroupModel.scala +++ b/src/main/scala/edu/ie3/simona/model/control/TransformerControlGroupModel.scala @@ -134,7 +134,7 @@ object TransformerControlGroupModel { * Array of all regulation requests * @return * None in case of contrary requests, else the highest or lowest voltage - * depending of the direction for regulation + * depending on the direction for regulation */ private def harmonizeRegulationNeeds( regulationRequests: Array[Dimensionless] From fa36523ce73f8c0074a5ed9bb7fa03f4917690d0 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Fri, 15 Nov 2024 15:08:22 +0100 Subject: [PATCH 121/137] Removing logs in `logs/simona`. --- CHANGELOG.md | 1 + src/main/resources/logback.xml | 8 -------- .../simona/logging/logback/LogbackConfiguration.scala | 11 +++++------ 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a2cb7b066..cb4a719cb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898) - Refactoring of `ThermalGrid.energyGrid` to distinguish between demand of house and storage [#928](https://github.com/ie3-institute/simona/issues/928) - Refactoring to use zeroKW and zeroKWH in thermal grid unit tests [#1023](https://github.com/ie3-institute/simona/issues/1023) +- Removing logs in `logs/simona` [#1017](https://github.com/ie3-institute/simona/issues/1017) ### Fixed - Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index e5abb4e391..3448ebab83 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -18,14 +18,6 @@ - logs/simona/simona.log - - - logs/simona/archive/simona-%d{yyyyMMdd'T'HHmmss}-${bySecond}.log - - 10 - 3GB - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n diff --git a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala index 3d236a1f41..58f982c2c7 100644 --- a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala +++ b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala @@ -43,12 +43,11 @@ object LogbackConfiguration extends LazyLogging { ) ) - rootLogger.iteratorForAppenders().asScala.foreach { - case rf: RollingFileAppender[_] => - rf.getTriggeringPolicy.start() - rf.start() - case appender => appender.start() - } + rootLogger + .iteratorForAppenders() + .asScala + .foreach(appender => appender.start()) + case factory => logger.error( s"Cannot configure simulation run logger! Invalid factory: $factory" From e4e899692b6f7794c4acb106cb12fc68a60808b6 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 18 Nov 2024 12:20:44 +0100 Subject: [PATCH 122/137] Removing pmd --- Jenkinsfile | 5 +---- build.gradle | 2 -- gradle/scripts/pmd.gradle | 7 ------- gradle/scripts/sonarqube.gradle | 2 -- 4 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 gradle/scripts/pmd.gradle diff --git a/Jenkinsfile b/Jenkinsfile index f8320f0960..84b3073e05 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -111,7 +111,7 @@ node { sh 'java -version' - gradle('--refresh-dependencies spotlessCheck pmdMain pmdTest', projectName) + gradle('--refresh-dependencies spotlessCheck test', projectName) sh(script: """set +x && cd $projectName""" + ''' set +x; ./gradlew javadoc''', returnStdout: true) } @@ -421,9 +421,6 @@ def publishReports(String relativeProjectDir) { // publish test reports publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: relativeProjectDir + '/build/reports/tests/allTests', reportFiles: 'index.html', reportName: "${relativeProjectDir}_java_tests_report", reportTitles: '']) - // publish pmd report for main project only - publishHTML([allowMissing: true, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: relativeProjectDir + '/build/reports/pmd', reportFiles: 'main.html', reportName: "${relativeProjectDir}_pmd_report", reportTitles: '']) - // publish scalatest reports for main project only (currently the only one with scala sources!) publishHTML([allowMissing: false, alwaysLinkToLastBuild: true, escapeUnderscores: false, keepAll: true, reportDir: relativeProjectDir + '/build/reports/tests/scalatest', reportFiles: 'index.html', reportName: "${relativeProjectDir}_scala_tests_report", reportTitles: '']) diff --git a/build.gradle b/build.gradle index 01935529d3..f611c25268 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,6 @@ plugins { id 'scala' // scala support id 'signing' id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined) - id 'pmd' // code check, working on source code id 'com.diffplug.spotless' version '6.25.0'// code format id "com.github.ben-manes.versions" version '0.51.0' id "de.undercouch.download" version "5.6.0" // downloads plugin @@ -45,7 +44,6 @@ java { targetCompatibility = javaVersion } -apply from: scriptsLocation + 'pmd.gradle' apply from: scriptsLocation + 'spotless.gradle' apply from: scriptsLocation + 'checkJavaVersion.gradle' apply from: scriptsLocation + 'tscfg.gradle' // config tasks diff --git a/gradle/scripts/pmd.gradle b/gradle/scripts/pmd.gradle deleted file mode 100644 index ca0094c798..0000000000 --- a/gradle/scripts/pmd.gradle +++ /dev/null @@ -1,7 +0,0 @@ -// pmd is a code check tool, working on source code - -pmd { - consoleOutput = true - toolVersion = "6.21.0" - rulesMinimumPriority = 2 -} diff --git a/gradle/scripts/sonarqube.gradle b/gradle/scripts/sonarqube.gradle index 80a9db4fd1..501bbbdc72 100644 --- a/gradle/scripts/sonarqube.gradle +++ b/gradle/scripts/sonarqube.gradle @@ -34,8 +34,6 @@ sonarqube { } // sonarqube task dependencies -project.tasks["sonarqube"].dependsOn "pmdMain" -project.tasks["sonarqube"].dependsOn "pmdTest" project.tasks["sonarqube"].dependsOn "test" project.tasks["sonarqube"].dependsOn "reportScoverage" project.tasks["sonarqube"].dependsOn "checkScoverage" From 96798b1014d60edb4196fd4118bfbb4f235dd5e5 Mon Sep 17 00:00:00 2001 From: Philipp Schmelter Date: Mon, 18 Nov 2024 13:35:11 +0100 Subject: [PATCH 123/137] Implementing GitHub Actions Pipeline (#982) * Testing Checkout * Fixed Syntax * Fixed Syntax * removed unnecessary steps * removed unnecessary steps * Syntax * Syntax * Test SSH * Testing Build ENV * Added wget * ENV * added shell * check java * check java * Created new Docker Image * Added Build and Test stage * Fix * Added right order * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Added Volume * Set clean to false * Set clean to true * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Bind Volume * Fixed Docker Image * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Fix Volume * Fix Volume * Fix Volume * Fix Volume * Combined Checkout and Build * Fix * Fix * Fix Vol * Added Artifact * Added Artifact * Added Artifact * Fix syntax * Debug * Debug * Debug * STOP * test * Volume * Using Cache * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Using artifacts * Changed approach in passing files * Changed approach in passing files * Debug * Fixed Path * Fixed Path * Fixed Path * Fixed Path * Fixed Path * Caching Gradle Dependencies * Removed workdir * Fixes * Fixes * Removed Artifacting Trying Cache * Seperated Build Artifact and Gradle Cache * All jobs in one stage test * Fixed permissions * Test * Test * Test * Changed approach * Added Sonar * Added Sonar * Added sonar credentials * Moved reportScoverage * Moved reportScoverage * Moved reportScoverage * Switched to action * Switched to action * Back to gradle * Removed dependencies from sonarqube.gradle * Added deployment step and sonar quality gate * fixed time format * debug * Added dependencie to sonarqube.gradle and changed workflow * sonar * Switched to action * Added path to binaries * Added path to binaries * Debug * Debug * Debug * Finished Prototype * Finished Prototype * Changed Java-Docs to Scala-Docs * Resolved Conversations * Changed branches * Switched from Sonarqube analysis Action to gradlew * Create Reports and changed path * fetch-depth * Quality-Gate status script * debug * debug * debug * Using reportScoverage * debug path * debug path * debug path * debug path * debug path * Merged some steps * rem debug * switched to sonarqube * Added CheckScov * Remove args * Outcommented sonar stage in jenkins * Testing Sonar * Prototype * Removed DummyCode * Jenkinsfile back to dev version * spotless back in test * Prototype * Resolved conversations * changed fetch depth * seperated spotlessCheck * debug spotless * debug spotless * resolved conversations * Removed PMDS and replaced with test * Added dependencies * fixes * empty line --- .github/workflows/ci.yml | 77 +++++++++++++++++++++++++++++++++ gradle/scripts/sonarqube.gradle | 2 - 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..182819f0a1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +# © 2024. TU Dortmund University, +# Institute of Energy Systems, Energy Efficiency and Energy Economics, +# Research group Distribution grid planning and operation +# + +name: CI + +on: + push: + paths-ignore: + - 'docs/**' + branches: + - main + - dev + - 'hotfix/*' + - 'rel/*' + - 'dependabot/*' + pull_request: + branches: + - main + - dev + +jobs: + buildAndTest: + runs-on: ubuntu-latest + + steps: + - name: Checkout Source + uses: actions/checkout@v4 + with: + fetch-depth: 1 + ref: ${{ github.event.pull_request.head.ref || github.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build Project + run: ./gradlew --refresh-dependencies clean assemble spotlessCheck + + - name: Run Tests + run: ./gradlew test reportScoverage checkScoverage + + - name: Build Scala-Docs + run: ./gradlew scaladoc + + - name: SonarQube + run: | + ./gradlew sonar \ + -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \ + -Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \ + -Dsonar.login=${{ secrets.SONAR_TOKEN }} + + SONAR_STATUS_URL="${{ vars.SONAR_HOST_URL }}/api/qualitygates/project_status?projectKey=${{ vars.SONAR_PROJECT_KEY }}" + QUALITY_GATE_STATUS=$(curl -s -u "${{ secrets.SONAR_TOKEN }}:" "$SONAR_STATUS_URL" | jq -r '.projectStatus.status') + + echo "Quality Gate Status: $QUALITY_GATE_STATUS" + if [ "$QUALITY_GATE_STATUS" != "OK" ]; then + echo "Quality Gate failed!" + exit 1 + fi + + - name: Deploy + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' + run: | + ./gradlew publish\ + -Puser=${{ secrets.MAVENCENTRAL_USER }} \ + -Ppassword=${{ secrets.MAVENCENTRAL_PASS }} \ + -Psigning.keyId=${{ secrets.MAVENCENTRAL_SIGNINGKEYID }} \ + -Psigning.password=${{ secrets.MAVENCENTRAL_SIGNINGPASS }} \ + -Psigning.secretKeyRingFile=${{ secrets.MAVENCENTRAL_SIGNINGKEY }} diff --git a/gradle/scripts/sonarqube.gradle b/gradle/scripts/sonarqube.gradle index 80a9db4fd1..501bbbdc72 100644 --- a/gradle/scripts/sonarqube.gradle +++ b/gradle/scripts/sonarqube.gradle @@ -34,8 +34,6 @@ sonarqube { } // sonarqube task dependencies -project.tasks["sonarqube"].dependsOn "pmdMain" -project.tasks["sonarqube"].dependsOn "pmdTest" project.tasks["sonarqube"].dependsOn "test" project.tasks["sonarqube"].dependsOn "reportScoverage" project.tasks["sonarqube"].dependsOn "checkScoverage" From 30c4c95a9fa0842b0250e8251b518fee786a469f Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 18 Nov 2024 21:06:15 +0100 Subject: [PATCH 124/137] Configurable log level Completely refactored ResultFileHierarchy Signed-off-by: Sebastian Peter --- .../resources/config/config-template.conf | 2 + src/main/resources/logback.xml | 10 +- .../edu/ie3/simona/config/SimonaConfig.scala | 23 ++ .../event/listener/ResultEventListener.scala | 2 +- .../logback/LogbackConfiguration.scala | 59 ++-- .../scala/edu/ie3/simona/main/RunSimona.scala | 4 +- .../ie3/simona/sim/setup/SetupHelper.scala | 9 +- .../ie3/simona/sim/setup/SimonaSetup.scala | 4 +- .../sim/setup/SimonaStandaloneSetup.scala | 3 +- .../ie3/simona/util/ResultFileHierarchy.scala | 283 +++++++++--------- .../listener/ResultEventListenerSpec.scala | 85 +++--- .../integration/RunSimonaStandaloneIT.scala | 12 +- .../io/file/ResultFileHierarchySpec.scala | 64 +--- .../edu/ie3/simona/sim/SimonaSimSpec.scala | 3 +- .../simona/sim/setup/SimonaSetupSpec.scala | 3 +- 15 files changed, 271 insertions(+), 295 deletions(-) diff --git a/src/main/resources/config/config-template.conf b/src/main/resources/config/config-template.conf index 2d6c5c9194..6c9d886711 100644 --- a/src/main/resources/config/config-template.conf +++ b/src/main/resources/config/config-template.conf @@ -292,6 +292,8 @@ simona.output.thermal = { } simona.output.flex = Boolean | false +simona.output.log.level = String | "INFO" + ################################################################## # Runtime Configuration // todo refactor as this naming is misleading ################################################################## diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 3448ebab83..909dc6bda8 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -17,16 +17,8 @@ INFO - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - INFO - - + - \ No newline at end of file diff --git a/src/main/scala/edu/ie3/simona/config/SimonaConfig.scala b/src/main/scala/edu/ie3/simona/config/SimonaConfig.scala index e31ccce104..0790a6efd9 100644 --- a/src/main/scala/edu/ie3/simona/config/SimonaConfig.scala +++ b/src/main/scala/edu/ie3/simona/config/SimonaConfig.scala @@ -1957,6 +1957,7 @@ object SimonaConfig { base: SimonaConfig.Simona.Output.Base, flex: scala.Boolean, grid: SimonaConfig.GridOutputConfig, + log: SimonaConfig.Simona.Output.Log, participant: SimonaConfig.Simona.Output.Participant, sink: SimonaConfig.Simona.Output.Sink, thermal: SimonaConfig.Simona.Output.Thermal, @@ -1997,6 +1998,22 @@ object SimonaConfig { } + final case class Log( + level: java.lang.String + ) + object Log { + def apply( + c: com.typesafe.config.Config, + parentPath: java.lang.String, + $tsCfgValidator: $TsCfgValidator, + ): SimonaConfig.Simona.Output.Log = { + SimonaConfig.Simona.Output.Log( + level = + if (c.hasPathOrNull("level")) c.getString("level") else "INFO" + ) + } + } + final case class Participant( defaultConfig: SimonaConfig.ParticipantBaseOutputConfig, individualConfigs: scala.List[ @@ -2236,6 +2253,12 @@ object SimonaConfig { parentPath + "grid.", $tsCfgValidator, ), + log = SimonaConfig.Simona.Output.Log( + if (c.hasPathOrNull("log")) c.getConfig("log") + else com.typesafe.config.ConfigFactory.parseString("log{}"), + parentPath + "log.", + $tsCfgValidator, + ), participant = SimonaConfig.Simona.Output.Participant( if (c.hasPathOrNull("participant")) c.getConfig("participant") else com.typesafe.config.ConfigFactory.parseString("participant{}"), diff --git a/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala b/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala index 8e7dd12abd..d9c910ef1a 100644 --- a/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala +++ b/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala @@ -88,7 +88,7 @@ object ResultEventListener extends Transformer3wResultSupport { filePathFuture.map { fileName => val finalFileName = - fileName match { + fileName.toString match { case name if name.endsWith(".csv.gz") && enableCompression => name.replace(".gz", "") case name if name.endsWith(".csv") => name diff --git a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala index 58f982c2c7..31c23e4568 100644 --- a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala +++ b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala @@ -10,56 +10,44 @@ import ch.qos.logback.classic.LoggerContext import ch.qos.logback.classic.encoder.PatternLayoutEncoder import ch.qos.logback.classic.filter.ThresholdFilter import ch.qos.logback.classic.spi.ILoggingEvent -import ch.qos.logback.core.rolling.RollingFileAppender import ch.qos.logback.core.FileAppender -import ch.qos.logback.core.filter.Filter import com.typesafe.scalalogging.LazyLogging import org.slf4j.LoggerFactory -import java.io.File -import scala.jdk.CollectionConverters._ +import java.nio.file.Path object LogbackConfiguration extends LazyLogging { - def default(logPath: String): Unit = { + def default(logPath: Path, logLevel: String): Unit = { LoggerFactory.getILoggerFactory match { case loggerContext: LoggerContext => val rootLogger = loggerContext.getLogger("root") - val log = logPath.concat(File.separator).concat("simona.log") - // stop all appenders - rootLogger.iteratorForAppenders().asScala.foreach(_.stop()) - /* Identify the filters of existing rolling file appender */ - val fileLoggerFilterList = rootLogger - .iteratorForAppenders() - .asScala - .find(_.getName == "RF") - .map(_.getCopyOfAttachedFiltersList.asScala.toSeq) + + // Since logback configuration is static + val logFile = logPath.resolve("simona.log") + rootLogger.addAppender( - fileAppender( - log, + createFileAppender( + logFile, + logLevel, "simona-default", - fileLoggerFilterList, loggerContext, ) ) - rootLogger - .iteratorForAppenders() - .asScala - .foreach(appender => appender.start()) - case factory => logger.error( s"Cannot configure simulation run logger! Invalid factory: $factory" ) } - } - private def fileAppender( - logPath: String, + /** Creates a FileAppender that logs to given path + */ + private def createFileAppender( + logPath: Path, + logLevel: String, appenderName: String, - maybeFilterList: Option[Seq[Filter[ILoggingEvent]]], loggerContext: LoggerContext, ): FileAppender[ILoggingEvent] = { @@ -68,23 +56,16 @@ object LogbackConfiguration extends LazyLogging { layoutEncoder.setContext(loggerContext) layoutEncoder.start() + val filter = new ThresholdFilter() + filter.setLevel(logLevel) + filter.start() + val fileAppender = new FileAppender[ILoggingEvent] - fileAppender.setFile(logPath) + fileAppender.setFile(logPath.toString) fileAppender.setEncoder(layoutEncoder) fileAppender.setContext(loggerContext) fileAppender.setName(appenderName) - /* If applicable, apply the filters from existing file logger else log with "INFO"-Level */ - maybeFilterList match { - case Some(filterList) => - if (filterList.isEmpty) { // No filters in appenders -> Empty List - val filter = new ThresholdFilter() - filter.setLevel("INFO") - filter.start() - fileAppender.addFilter(filter) - } else { - filterList.foreach(fileAppender.addFilter) - } - } + fileAppender.addFilter(filter) fileAppender.start() fileAppender diff --git a/src/main/scala/edu/ie3/simona/main/RunSimona.scala b/src/main/scala/edu/ie3/simona/main/RunSimona.scala index c255990a05..9a4e26fdb2 100644 --- a/src/main/scala/edu/ie3/simona/main/RunSimona.scala +++ b/src/main/scala/edu/ie3/simona/main/RunSimona.scala @@ -57,7 +57,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { private def printGoodbye( successful: Boolean, - outputPath: String = "", + logOutputDir: Path, ): Unit = { val myWords = Array( "\"Vielleicht ist heute ein besonders guter Tag zum Sterben.\" - Worf (in Star Trek: Der erste Kontakt)", @@ -78,7 +78,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { // to ensure that the link to the log is printed last Thread.sleep(1000) - val path = Path.of(outputPath).resolve("simona.log").toUri + val path = logOutputDir.resolve("simona.log").toUri logger.error( s"Simulation stopped due to the occurrence of an error! The full log can be found here: $path" diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 535b140798..835a6f2599 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -220,7 +220,7 @@ trait SetupHelper extends LazyLogging { val modelsToWrite = SetupHelper.allResultEntitiesToWrite(simonaConfig.simona.output) - val resultFileHierarchy = ResultFileHierarchy( + ResultFileHierarchy( simonaConfig.simona.output.base.dir, simonaConfig.simona.simulationName, ResultEntityPathConfig( @@ -230,15 +230,10 @@ trait SetupHelper extends LazyLogging { simonaConfig.simona.simulationName, ), ), + config = Some(config), addTimeStampToOutputDir = simonaConfig.simona.output.base.addTimestampToOutputDir, - createDirs = createDirs, ) - - // copy config data to output directory - ResultFileHierarchy.prepareDirectories(config, resultFileHierarchy) - - resultFileHierarchy } } diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index 9c6effa859..4a03b2b905 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -21,6 +21,8 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path + /** Trait that can be used to setup a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending @@ -40,7 +42,7 @@ trait SimonaSetup { /** Directory of the log output. */ - def logOutputDir: String + def logOutputDir: Path /** Creates the runtime event listener * diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala index 65d47863cf..55848d2ced 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala @@ -50,6 +50,7 @@ import org.apache.pekko.actor.typed.scaladsl.adapter.{ } import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path import java.util.UUID import java.util.concurrent.LinkedBlockingQueue import scala.jdk.CollectionConverters._ @@ -68,7 +69,7 @@ class SimonaStandaloneSetup( override val args: Array[String], ) extends SimonaSetup { - override def logOutputDir: String = resultFileHierarchy.logOutputDir + override def logOutputDir: Path = resultFileHierarchy.logOutputDir override def gridAgents( context: ActorContext[_], diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 171c5835a2..aceab43822 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -7,7 +7,7 @@ package edu.ie3.simona.util import java.io.{BufferedWriter, File, FileWriter} -import java.nio.file.{Files, Paths} +import java.nio.file.{Files, Path, Paths} import java.text.SimpleDateFormat import com.typesafe.config.{ConfigRenderOptions, Config => TypesafeConfig} import com.typesafe.scalalogging.LazyLogging @@ -20,130 +20,135 @@ import edu.ie3.simona.exceptions.FileHierarchyException import edu.ie3.simona.io.result.ResultSinkType import edu.ie3.simona.io.result.ResultSinkType.Csv import edu.ie3.simona.logging.logback.LogbackConfiguration -import edu.ie3.simona.util.ResultFileHierarchy.ResultEntityPathConfig import edu.ie3.util.io.FileIOUtils import org.apache.commons.io.FilenameUtils._ import scala.jdk.OptionConverters.RichOptional -/** Represents the output directory where the results will be materialized. If - * new directories are added please remember to add them to the dirsToBeCreated - * Vector if they should be created. Otherwise they will not be created! - * - * @version 0.1 - * @since 12.01.20 +/** Represents the output directory where the results will be materialized. */ -final case class ResultFileHierarchy( - private val outputDir: String, - private val simulationName: String, - private val resultEntityPathConfig: ResultEntityPathConfig, - private val configureLogger: String => Unit = LogbackConfiguration.default, - private val addTimeStampToOutputDir: Boolean = true, - private val createDirs: Boolean = false, -) extends LazyLogging { +final case class ResultFileHierarchy private ( + runOutputDir: Path, + rawOutputDataFilePaths: Map[Class[_ <: ResultEntity], Path], + configOutputDir: Path, + logOutputDir: Path, + tmpDir: Path, + resultSinkType: ResultSinkType, + resultEntitiesToConsider: Set[Class[_ <: ResultEntity]], +) - private val fileSeparator: String = File.separator - - val runStartTimeUTC: String = - new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) - - val baseOutputDir: String = buildBaseOutputDir - - val runOutputDir: String = buildRunOutputDir +object ResultFileHierarchy extends LazyLogging { - val configOutputDir: String = - runOutputDir.concat(fileSeparator).concat("configs") + /** Creates the [[ResultFileHierarchy]] and relevant directories + */ + def apply( + outputDir: String, + simulationName: String, + resultEntityPathConfig: ResultEntityPathConfig, + configureLogger: (Path, String) => Unit = LogbackConfiguration.default, + config: Option[TypesafeConfig] = None, + addTimeStampToOutputDir: Boolean = true, + ): ResultFileHierarchy = { + + val runStartTimeUTC = Option.when(addTimeStampToOutputDir)( + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ) - val rawOutputDataDir: String = - runOutputDir.concat(fileSeparator).concat("rawOutputData") + val baseOutputDir = buildBaseOutputDir(outputDir) - val logOutputDir: String = - runOutputDir.concat(fileSeparator).concat("log") + val runOutputDir = buildRunOutputDir( + baseOutputDir, + simulationName, + runStartTimeUTC, + ) - val resultSinkType: ResultSinkType = resultEntityPathConfig.resultSinkType + val configOutputDir = runOutputDir.resolve("configs") + val rawOutputDataDir = runOutputDir.resolve("rawOutputData") + val logOutputDir = runOutputDir.resolve("log") + val tmpDir = runOutputDir.resolve("tmp") - val resultEntitiesToConsider: Set[Class[_ <: ResultEntity]] = - resultEntityPathConfig.resultEntitiesToConsider + val resultSinkType: ResultSinkType = resultEntityPathConfig.resultSinkType - val rawOutputDataFilePaths: Map[Class[_ <: ResultEntity], String] = { - resultSinkType match { - case csv: Csv => - resultEntityPathConfig.resultEntitiesToConsider - .map(resultEntityClass => - ( - resultEntityClass, - ResultFileHierarchy.buildRawOutputFilePath( + val rawOutputDataFilePaths: Map[Class[_ <: ResultEntity], Path] = { + resultSinkType match { + case csv: Csv => + resultEntityPathConfig.resultEntitiesToConsider + .map(resultEntityClass => + ( resultEntityClass, - csv, - rawOutputDataDir, - fileSeparator, - ), + ResultFileHierarchy.buildRawOutputFilePath( + resultEntityClass, + csv, + rawOutputDataDir, + ), + ) ) - ) - .toMap - case _ => - Map.empty + .toMap + case _ => + Map.empty + } } - } - - val graphOutputDir: String = - runOutputDir.concat(fileSeparator).concat("graphs") - val kpiOutputDir: String = runOutputDir.concat(fileSeparator).concat("kpi") - - val tmpDir: String = runOutputDir.concat(fileSeparator).concat("tmp") + val dirsToBeCreated = Seq( + baseOutputDir, + runOutputDir, + configOutputDir, + rawOutputDataDir, + logOutputDir, + tmpDir, + ) - private val dirsToBeCreated: Vector[String] = Vector( - baseOutputDir, - runOutputDir, - configOutputDir, - rawOutputDataDir, - graphOutputDir, - kpiOutputDir, - tmpDir, - logOutputDir, - ) + val resultFileHierarchy = ResultFileHierarchy( + runOutputDir, + rawOutputDataFilePaths, + configOutputDir, + logOutputDir, + tmpDir, + resultSinkType, + resultEntityPathConfig.resultEntitiesToConsider, + ) + prepareDirectories( + baseOutputDir, + dirsToBeCreated, + resultFileHierarchy, + config, + ) - // needs to be the latest call because otherwise the values are null as they are not initialized yet - if (createDirs) - ResultFileHierarchy.createOutputDirectories(this) + // needs to be done after dir creation + configureLogger(logOutputDir, "INFO") // todo - // needs to be done after dir creation - configureLogger(logOutputDir) + resultFileHierarchy + } - /** Builds the base output directory string + /** Builds the base output directory * * @return - * the filepath string to the directory + * the filepath of the directory */ - private def buildBaseOutputDir: String = { - + private def buildBaseOutputDir( + outputDir: String + ): Path = { // clean file string if necessary val cleanedBaseOutputDir = { val normalizedOutputDir = normalize(outputDir) - (fileSeparator + "$").r.replaceAllIn(normalizedOutputDir, "") + (File.separator + "$").r.replaceAllIn(normalizedOutputDir, "") } - // create base output dir if non-existent - Paths.get(cleanedBaseOutputDir).toFile.getAbsolutePath + Paths.get(cleanedBaseOutputDir) } - /** Builds the output directory string for this specific run - * - * @return + /** Builds the output directory for this specific run */ - private def buildRunOutputDir: String = { + private def buildRunOutputDir( + baseOutputDir: Path, + simulationName: String, + runStartTimeUTC: Option[String], + ): Path = { val optionalSuffix = - if (addTimeStampToOutputDir) s"_$runStartTimeUTC" else "" - baseOutputDir - .concat(fileSeparator) - .concat(simulationName) - .concat(optionalSuffix) - } + runStartTimeUTC.map(pattern => s"_$pattern").getOrElse("") -} - -object ResultFileHierarchy extends LazyLogging { + baseOutputDir.resolve(s"$simulationName$optionalSuffix") + } /** @param resultEntitiesToConsider * [[ResultEntity]] s to consider to be written out @@ -161,8 +166,6 @@ object ResultFileHierarchy extends LazyLogging { * the csv sink type parameters * @param rawOutputDataDir * the directory of the raw output data - * @param fileSeparator - * the file separator to be used * @return * an absolute file path as string for the provided model class incl. file * name + extension @@ -170,9 +173,8 @@ object ResultFileHierarchy extends LazyLogging { private def buildRawOutputFilePath( modelClass: Class[_ <: ResultEntity], csvSink: Csv, - rawOutputDataDir: String, - fileSeparator: String, - ): String = { + rawOutputDataDir: Path, + ): Path = { val fileEnding = if (csvSink.fileFormat.startsWith(".")) csvSink.fileFormat @@ -192,64 +194,72 @@ object ResultFileHierarchy extends LazyLogging { ) } - rawOutputDataDir - .concat(fileSeparator) - .concat(filename.toString) - .concat(fileEnding) + rawOutputDataDir.resolve(s"${filename.toString}$fileEnding") } /** Prepares the output directories to be ready to hold the output data. This * includes creating the run directory with all subsequent directories as * well as copying the simulation configuration to the output dir * - * @param config + * @param baseOutputDir + * The base output directory + * @param dirsToBeCreated + * The directories that need to be created + * @param maybeConfig * the config of the current simulation * @param resultFileHierarchy * the output file hierarchy of the current simulation */ - def prepareDirectories( - config: TypesafeConfig, + private def prepareDirectories( + baseOutputDir: Path, + dirsToBeCreated: Seq[Path], resultFileHierarchy: ResultFileHierarchy, + maybeConfig: Option[TypesafeConfig], ): Unit = { // create output directories if they are not present yet if (!runOutputDirExists(resultFileHierarchy)) - ResultFileHierarchy.createOutputDirectories(resultFileHierarchy) + createOutputDirectories( + baseOutputDir, + dirsToBeCreated, + resultFileHierarchy, + ) - logger.info( - "Processing configs for simulation: {}.", - config.getString("simona.simulationName"), - ) + maybeConfig.foreach { config => + logger.info( + "Processing configs for simulation: {}.", + config.getString("simona.simulationName"), + ) - val outFile = - Paths.get(resultFileHierarchy.configOutputDir, "vn_simona.conf").toFile - val bw = new BufferedWriter(new FileWriter(outFile)) - bw.write( - config - .root() - .render( - ConfigRenderOptions - .defaults() - .setOriginComments(false) - .setComments(false) - ) - ) - bw.close() - logger.info("Config '{}' written to '{}'.", outFile.getPath, outFile) + val outFile = + resultFileHierarchy.configOutputDir.resolve("vn_simona.conf").toFile + val bw = new BufferedWriter(new FileWriter(outFile)) + bw.write( + config + .root() + .render( + ConfigRenderOptions + .defaults() + .setOriginComments(false) + .setComments(false) + ) + ) + bw.close() + logger.info("Config '{}' written to '{}'.", outFile.getPath, outFile) + } } /** Checks if the directory of the current run already exists * - * @param outputFileHierarchy + * @param fileHierarchy * the [[ResultFileHierarchy]] that holds information on the run directory * path * @return * true if it exists, false if not */ - def runOutputDirExists(outputFileHierarchy: ResultFileHierarchy): Boolean = { - new File(outputFileHierarchy.runOutputDir).exists() && new File( - outputFileHierarchy.runOutputDir - ).listFiles().length > 0 + def runOutputDirExists(fileHierarchy: ResultFileHierarchy): Boolean = { + val outputDir = fileHierarchy.runOutputDir.toFile + outputDir.exists() && outputDir.listFiles().length > 0 } /** Creates all output directories of the provided [[ResultFileHierarchy]] @@ -257,11 +267,12 @@ object ResultFileHierarchy extends LazyLogging { * @param outputFileHierarchy * the [[ResultFileHierarchy]] the directories should be created for */ - def createOutputDirectories( - outputFileHierarchy: ResultFileHierarchy + private def createOutputDirectories( + baseOutputDir: Path, + dirsToBeCreated: Seq[Path], + outputFileHierarchy: ResultFileHierarchy, ): Unit = { // try to create base output dir - val baseOutputDir = Paths.get(outputFileHierarchy.baseOutputDir) // / check for existence of the provided baseOutputDir, if not create it if (Files.exists(baseOutputDir) && baseOutputDir.toFile.isFile) { throw new FileHierarchyException( @@ -270,17 +281,17 @@ object ResultFileHierarchy extends LazyLogging { } // check if there is data inside the runOutputDir taking into account the provided FileHandling - val runOutputDir = new File(outputFileHierarchy.runOutputDir) + val runOutputDir = outputFileHierarchy.runOutputDir.toFile if (runOutputDir.exists() && runOutputDir.listFiles().length > 0) { // files inside the runOutputDir -> fail throw new FileHierarchyException( - s"The runOutputDir ${outputFileHierarchy.runOutputDir} already exists and is NOT empty! " + + s"The runOutputDir ${outputFileHierarchy.runOutputDir.toString} already exists and is NOT empty! " + s"Please either delete or empty the directory." ) } // create the output directories for the specific run - outputFileHierarchy.dirsToBeCreated.foreach(createDir) + dirsToBeCreated.foreach(createDir) } @@ -289,8 +300,8 @@ object ResultFileHierarchy extends LazyLogging { * @param dir * the full path where the directory should be created (incl. it's name) */ - private def createDir(dir: String): Unit = { - val dirFile = new File(dir) + private def createDir(dir: Path): Unit = { + val dirFile = dir.toFile if (!dirFile.mkdirs() && !dirFile.exists()) throw new FileHierarchyException( "The output directory path " + dir diff --git a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala index f110feca8e..7498e270dc 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala @@ -84,7 +84,6 @@ class ResultEventListenerSpec classes, resultSinkType, ), - createDirs = true, ) } @@ -122,14 +121,14 @@ class ResultEventListenerSpec ) // after the creation of the listener, it is expected that a corresponding raw result data file is present - val outputFile = new File( - fileHierarchy.rawOutputDataFilePaths.getOrElse( + val outputFile = fileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[PvResult], fail( s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ) + .toFile assert(outputFile.exists) assert(outputFile.isFile) @@ -162,14 +161,14 @@ class ResultEventListenerSpec listenerRef ! ParticipantResultEvent(dummyPvResult) - val outputFile = new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + val outputFile = specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[PvResult], fail( s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ) + .toFile // wait until output file exists (headers are flushed out immediately): awaitCond( @@ -219,39 +218,37 @@ class ResultEventListenerSpec ) val outputFiles = Map( - dummyNodeResultString -> new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + dummyNodeResultString -> specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[NodeResult], fail( s"Cannot get filepath for raw result file of class '${classOf[NodeResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - dummySwitchResultString -> new File( + ), + dummySwitchResultString -> specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( classOf[SwitchResult], fail( s"Cannot get filepath for raw result file of class '${classOf[SwitchResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - dummyLineResultDataString -> new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + ), + dummyLineResultDataString -> specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[LineResult], fail( s"Cannot get filepath for raw result file of class '${classOf[LineResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - dummyTrafo2wResultDataString -> new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + ), + dummyTrafo2wResultDataString -> specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[Transformer2WResult], fail( s"Cannot get filepath for raw result file of class '${classOf[Transformer2WResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - ) + ), + ).map { case (dummyString, path) => + (dummyString, path.toFile) + } // wait until all output files exist (headers are flushed out immediately): awaitCond( @@ -308,14 +305,15 @@ class ResultEventListenerSpec ) ) - val outputFile = new File( - fileHierarchy.rawOutputDataFilePaths.getOrElse( + val outputFile = fileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[Transformer3WResult], fail( s"Cannot get filepath for raw result file of class '${classOf[Transformer3WResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ) + .toFile + /* The result file is created at start up and only contains a head line. */ awaitCond( outputFile.exists(), @@ -386,12 +384,14 @@ class ResultEventListenerSpec val outputFile = new File( ".gz$".r.replaceAllIn( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( - classOf[PvResult], - fail( - s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" - ), - ), + specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( + classOf[PvResult], + fail( + s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" + ), + ) + .toString, "", ) ) @@ -413,26 +413,29 @@ class ResultEventListenerSpec // wait until file exists awaitCond( - new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[PvResult], fail( s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ).exists, + .toFile + .exists, timeoutDuration, ) val resultFileSource = Source.fromInputStream( new GZIPInputStream( new FileInputStream( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( - classOf[PvResult], - fail( - s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" - ), - ) + specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( + classOf[PvResult], + fail( + s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" + ), + ) + .toFile ) ) ) diff --git a/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala b/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala index 4e53f0e078..083b9681e3 100644 --- a/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala +++ b/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala @@ -90,7 +90,7 @@ class RunSimonaStandaloneIT /* check the results */ // check configs - val configOutputDir = new File(resultFileHierarchy.configOutputDir) + val configOutputDir = resultFileHierarchy.configOutputDir.toFile configOutputDir.isDirectory shouldBe true configOutputDir.listFiles.toVector.size shouldBe 1 @@ -118,10 +118,12 @@ class RunSimonaStandaloneIT entityClass: Class[_ <: ResultEntity], ): BufferedSource = { Source.fromFile( - resultFileHierarchy.rawOutputDataFilePaths.getOrElse( - entityClass, - fail(s"Unable to get output path for result entity: $entityClass"), - ) + resultFileHierarchy.rawOutputDataFilePaths + .getOrElse( + entityClass, + fail(s"Unable to get output path for result entity: $entityClass"), + ) + .toFile ) } diff --git a/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala b/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala index 3b89d418f2..c273634fbe 100644 --- a/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala +++ b/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala @@ -51,37 +51,15 @@ class ResultFileHierarchySpec ), ) - val runOutputDirWithDate = - "vn_simona_".concat(validOutputFileHierarchy.runStartTimeUTC) - - relativizePath( - validOutputFileHierarchy.baseOutputDir - ).toString shouldBe baseOutputDir - relativizePath( - validOutputFileHierarchy.runOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate - relativizePath( - validOutputFileHierarchy.tmpDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "tmp" - relativizePath( - validOutputFileHierarchy.configOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "configs" - relativizePath( - validOutputFileHierarchy.rawOutputDataDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "rawOutputData" - relativizePath( - validOutputFileHierarchy.graphOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "graphs" - relativizePath( - validOutputFileHierarchy.kpiOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "kpi" - - relativizePath( - validOutputFileHierarchy.rawOutputDataFilePaths(classOf[PvResult]) - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "rawOutputData" + fileSeparator + "pref_pv_res_suff.csv" + validOutputFileHierarchy.tmpDir.toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "tmp" + validOutputFileHierarchy.configOutputDir.toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "configs" + validOutputFileHierarchy.logOutputDir.toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "log" + + validOutputFileHierarchy + .rawOutputDataFilePaths(classOf[PvResult]) + .toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "rawOutputData" + fileSeparator + "pref_pv_res_suff.csv" } - "not write directories automatically on instantiation" in {} // todo "write directories automatically on instantiation when requested so" in { // delete file if they exist @@ -97,7 +75,6 @@ class ResultFileHierarchySpec Set(classOf[PvResult]), ResultSinkType.Csv("csv", "pref", "suff"), ), - createDirs = true, ) // check for existence of run output dir @@ -106,26 +83,13 @@ class ResultFileHierarchySpec ) shouldBe true // check for existence of other folders - assert( - Files.exists(new File(validOutputFileHierarchy.baseOutputDir).toPath) - ) - assert(Files.exists(new File(validOutputFileHierarchy.tmpDir).toPath)) - assert( - Files.exists(new File(validOutputFileHierarchy.configOutputDir).toPath) - ) - assert( - Files.exists(new File(validOutputFileHierarchy.rawOutputDataDir).toPath) - ) - assert( - Files.exists(new File(validOutputFileHierarchy.graphOutputDir).toPath) - ) - assert( - Files.exists(new File(validOutputFileHierarchy.kpiOutputDir).toPath) - ) + assert(Files.exists(validOutputFileHierarchy.configOutputDir)) + assert(Files.exists(validOutputFileHierarchy.logOutputDir)) + assert(Files.exists(validOutputFileHierarchy.tmpDir)) // check if tmp directory can be deleted by output file hierarchy ResultFileHierarchy.deleteTmpDir(validOutputFileHierarchy) - assert(!Files.exists(new File(validOutputFileHierarchy.tmpDir).toPath)) + assert(!Files.exists(validOutputFileHierarchy.tmpDir)) } @@ -133,10 +97,8 @@ class ResultFileHierarchySpec } - private def relativizePath(fullPath: String): Path = { - new File(new File("").getAbsolutePath).toPath - .relativize(new File(fullPath).toPath) - } + private def relativizePath(fullPath: Path): Path = + new File(new File("").getAbsolutePath).toPath.relativize(fullPath) // todo output model path config compression should always be disabled -> test for this diff --git a/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala b/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala index 63be126c0f..9d1140be17 100644 --- a/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala +++ b/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala @@ -34,6 +34,7 @@ import org.apache.pekko.actor.typed.scaladsl.{ActorContext, Behaviors} import org.apache.pekko.actor.typed.{ActorRef, Behavior} import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path import java.util.UUID class SimonaSimSpec extends ScalaTestWithActorTestKit with UnitSpec { @@ -398,7 +399,7 @@ object SimonaSimSpec { override val args: Array[String] = Array.empty[String] - override def logOutputDir: String = throw new NotImplementedError() + override def logOutputDir: Path = throw new NotImplementedError() override def runtimeEventListener( context: ActorContext[_] diff --git a/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala b/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala index 7fa3ab3469..0428ed765b 100644 --- a/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala +++ b/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala @@ -26,13 +26,14 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path import java.util.UUID class SimonaSetupSpec extends UnitSpec with SimonaSetup with SubGridGateMokka { override val args: Array[String] = Array.empty[String] - override def logOutputDir: String = throw new NotImplementedError() + override def logOutputDir: Path = throw new NotImplementedError() override def runtimeEventListener( context: ActorContext[_] From 835582369b958a5db96f1fad3acebc69777a1f52 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 18 Nov 2024 21:14:11 +0100 Subject: [PATCH 125/137] Refactoring ResultFileHierarchy Signed-off-by: Sebastian Peter --- .../event/listener/ResultEventListener.scala | 2 +- .../logback/LogbackConfiguration.scala | 10 +- .../scala/edu/ie3/simona/main/RunSimona.scala | 4 +- .../ie3/simona/sim/setup/SetupHelper.scala | 9 +- .../ie3/simona/sim/setup/SimonaSetup.scala | 4 +- .../sim/setup/SimonaStandaloneSetup.scala | 3 +- .../ie3/simona/util/ResultFileHierarchy.scala | 283 +++++++++--------- .../listener/ResultEventListenerSpec.scala | 85 +++--- .../integration/RunSimonaStandaloneIT.scala | 12 +- .../io/file/ResultFileHierarchySpec.scala | 64 +--- .../edu/ie3/simona/sim/SimonaSimSpec.scala | 3 +- .../simona/sim/setup/SimonaSetupSpec.scala | 3 +- 12 files changed, 230 insertions(+), 252 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala b/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala index 8e7dd12abd..d9c910ef1a 100644 --- a/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala +++ b/src/main/scala/edu/ie3/simona/event/listener/ResultEventListener.scala @@ -88,7 +88,7 @@ object ResultEventListener extends Transformer3wResultSupport { filePathFuture.map { fileName => val finalFileName = - fileName match { + fileName.toString match { case name if name.endsWith(".csv.gz") && enableCompression => name.replace(".gz", "") case name if name.endsWith(".csv") => name diff --git a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala index 3d236a1f41..9f95df1c2c 100644 --- a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala +++ b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala @@ -16,16 +16,16 @@ import ch.qos.logback.core.filter.Filter import com.typesafe.scalalogging.LazyLogging import org.slf4j.LoggerFactory -import java.io.File +import java.nio.file.Path import scala.jdk.CollectionConverters._ object LogbackConfiguration extends LazyLogging { - def default(logPath: String): Unit = { + def default(logPath: Path): Unit = { LoggerFactory.getILoggerFactory match { case loggerContext: LoggerContext => val rootLogger = loggerContext.getLogger("root") - val log = logPath.concat(File.separator).concat("simona.log") + val log = logPath.resolve("simona.log") // stop all appenders rootLogger.iteratorForAppenders().asScala.foreach(_.stop()) /* Identify the filters of existing rolling file appender */ @@ -58,7 +58,7 @@ object LogbackConfiguration extends LazyLogging { } private def fileAppender( - logPath: String, + logPath: Path, appenderName: String, maybeFilterList: Option[Seq[Filter[ILoggingEvent]]], loggerContext: LoggerContext, @@ -70,7 +70,7 @@ object LogbackConfiguration extends LazyLogging { layoutEncoder.start() val fileAppender = new FileAppender[ILoggingEvent] - fileAppender.setFile(logPath) + fileAppender.setFile(logPath.toString) fileAppender.setEncoder(layoutEncoder) fileAppender.setContext(loggerContext) fileAppender.setName(appenderName) diff --git a/src/main/scala/edu/ie3/simona/main/RunSimona.scala b/src/main/scala/edu/ie3/simona/main/RunSimona.scala index b08db66361..3ba0c8f9aa 100644 --- a/src/main/scala/edu/ie3/simona/main/RunSimona.scala +++ b/src/main/scala/edu/ie3/simona/main/RunSimona.scala @@ -57,7 +57,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { private def printGoodbye( successful: Boolean, - outputPath: String = "", + logOutputDir: Path, ): Unit = { val myWords = Array( "\"Vielleicht ist heute ein besonders guter Tag zum Sterben.\" - Worf (in Star Trek: Der erste Kontakt)", @@ -78,7 +78,7 @@ trait RunSimona[T <: SimonaSetup] extends LazyLogging { // to ensure that the link to the log is printed last Thread.sleep(1000) - val path = Path.of(outputPath).resolve("simona.log").toUri + val path = logOutputDir.resolve("simona.log").toUri logger.error( s"Simulation stopped due to the occurrence of an error! The full log can be found here: $path" diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index d5b21a99a7..23fe9e1997 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -220,7 +220,7 @@ trait SetupHelper extends LazyLogging { val modelsToWrite = SetupHelper.allResultEntitiesToWrite(simonaConfig.simona.output) - val resultFileHierarchy = ResultFileHierarchy( + ResultFileHierarchy( simonaConfig.simona.output.base.dir, simonaConfig.simona.simulationName, ResultEntityPathConfig( @@ -230,15 +230,10 @@ trait SetupHelper extends LazyLogging { simonaConfig.simona.simulationName, ), ), + config = Some(config), addTimeStampToOutputDir = simonaConfig.simona.output.base.addTimestampToOutputDir, - createDirs = createDirs, ) - - // copy config data to output directory - ResultFileHierarchy.prepareDirectories(config, resultFileHierarchy) - - resultFileHierarchy } } diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala index 4a2d8abd42..4c452a4c3c 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaSetup.scala @@ -21,6 +21,8 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path + /** Trait that can be used to set up a customized simona simulation by providing * implementations for all setup information required by a * [[edu.ie3.simona.sim.SimonaSim]]. Most of the time, using or extending @@ -40,7 +42,7 @@ trait SimonaSetup { /** Directory of the log output. */ - def logOutputDir: String + def logOutputDir: Path /** Creates the runtime event listener * diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala b/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala index 65d47863cf..55848d2ced 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala @@ -50,6 +50,7 @@ import org.apache.pekko.actor.typed.scaladsl.adapter.{ } import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path import java.util.UUID import java.util.concurrent.LinkedBlockingQueue import scala.jdk.CollectionConverters._ @@ -68,7 +69,7 @@ class SimonaStandaloneSetup( override val args: Array[String], ) extends SimonaSetup { - override def logOutputDir: String = resultFileHierarchy.logOutputDir + override def logOutputDir: Path = resultFileHierarchy.logOutputDir override def gridAgents( context: ActorContext[_], diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 3c1028be2b..3dc207d350 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -7,7 +7,7 @@ package edu.ie3.simona.util import java.io.{BufferedWriter, File, FileWriter} -import java.nio.file.{Files, Paths} +import java.nio.file.{Files, Path, Paths} import java.text.SimpleDateFormat import com.typesafe.config.{ConfigRenderOptions, Config => TypesafeConfig} import com.typesafe.scalalogging.LazyLogging @@ -20,130 +20,135 @@ import edu.ie3.simona.exceptions.FileHierarchyException import edu.ie3.simona.io.result.ResultSinkType import edu.ie3.simona.io.result.ResultSinkType.Csv import edu.ie3.simona.logging.logback.LogbackConfiguration -import edu.ie3.simona.util.ResultFileHierarchy.ResultEntityPathConfig import edu.ie3.util.io.FileIOUtils import org.apache.commons.io.FilenameUtils._ import scala.jdk.OptionConverters.RichOptional -/** Represents the output directory where the results will be materialized. If - * new directories are added please remember to add them to the dirsToBeCreated - * Vector if they should be created. Otherwise, they will not be created! - * - * @version 0.1 - * @since 12.01.20 +/** Represents the output directory where the results will be materialized. */ -final case class ResultFileHierarchy( - private val outputDir: String, - private val simulationName: String, - private val resultEntityPathConfig: ResultEntityPathConfig, - private val configureLogger: String => Unit = LogbackConfiguration.default, - private val addTimeStampToOutputDir: Boolean = true, - private val createDirs: Boolean = false, -) extends LazyLogging { +final case class ResultFileHierarchy private ( + runOutputDir: Path, + rawOutputDataFilePaths: Map[Class[_ <: ResultEntity], Path], + configOutputDir: Path, + logOutputDir: Path, + tmpDir: Path, + resultSinkType: ResultSinkType, + resultEntitiesToConsider: Set[Class[_ <: ResultEntity]], +) - private val fileSeparator: String = File.separator - - val runStartTimeUTC: String = - new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) - - val baseOutputDir: String = buildBaseOutputDir - - val runOutputDir: String = buildRunOutputDir +object ResultFileHierarchy extends LazyLogging { - val configOutputDir: String = - runOutputDir.concat(fileSeparator).concat("configs") + /** Creates the [[ResultFileHierarchy]] and relevant directories + */ + def apply( + outputDir: String, + simulationName: String, + resultEntityPathConfig: ResultEntityPathConfig, + configureLogger: Path => Unit = LogbackConfiguration.default, + config: Option[TypesafeConfig] = None, + addTimeStampToOutputDir: Boolean = true, + ): ResultFileHierarchy = { + + val runStartTimeUTC = Option.when(addTimeStampToOutputDir)( + new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new java.util.Date()) + ) - val rawOutputDataDir: String = - runOutputDir.concat(fileSeparator).concat("rawOutputData") + val baseOutputDir = buildBaseOutputDir(outputDir) - val logOutputDir: String = - runOutputDir.concat(fileSeparator).concat("log") + val runOutputDir = buildRunOutputDir( + baseOutputDir, + simulationName, + runStartTimeUTC, + ) - val resultSinkType: ResultSinkType = resultEntityPathConfig.resultSinkType + val configOutputDir = runOutputDir.resolve("configs") + val rawOutputDataDir = runOutputDir.resolve("rawOutputData") + val logOutputDir = runOutputDir.resolve("log") + val tmpDir = runOutputDir.resolve("tmp") - val resultEntitiesToConsider: Set[Class[_ <: ResultEntity]] = - resultEntityPathConfig.resultEntitiesToConsider + val resultSinkType: ResultSinkType = resultEntityPathConfig.resultSinkType - val rawOutputDataFilePaths: Map[Class[_ <: ResultEntity], String] = { - resultSinkType match { - case csv: Csv => - resultEntityPathConfig.resultEntitiesToConsider - .map(resultEntityClass => - ( - resultEntityClass, - ResultFileHierarchy.buildRawOutputFilePath( + val rawOutputDataFilePaths: Map[Class[_ <: ResultEntity], Path] = { + resultSinkType match { + case csv: Csv => + resultEntityPathConfig.resultEntitiesToConsider + .map(resultEntityClass => + ( resultEntityClass, - csv, - rawOutputDataDir, - fileSeparator, - ), + ResultFileHierarchy.buildRawOutputFilePath( + resultEntityClass, + csv, + rawOutputDataDir, + ), + ) ) - ) - .toMap - case _ => - Map.empty + .toMap + case _ => + Map.empty + } } - } - - val graphOutputDir: String = - runOutputDir.concat(fileSeparator).concat("graphs") - val kpiOutputDir: String = runOutputDir.concat(fileSeparator).concat("kpi") - - val tmpDir: String = runOutputDir.concat(fileSeparator).concat("tmp") + val dirsToBeCreated = Seq( + baseOutputDir, + runOutputDir, + configOutputDir, + rawOutputDataDir, + logOutputDir, + tmpDir, + ) - private val dirsToBeCreated: Vector[String] = Vector( - baseOutputDir, - runOutputDir, - configOutputDir, - rawOutputDataDir, - graphOutputDir, - kpiOutputDir, - tmpDir, - logOutputDir, - ) + val resultFileHierarchy = ResultFileHierarchy( + runOutputDir, + rawOutputDataFilePaths, + configOutputDir, + logOutputDir, + tmpDir, + resultSinkType, + resultEntityPathConfig.resultEntitiesToConsider, + ) + prepareDirectories( + baseOutputDir, + dirsToBeCreated, + resultFileHierarchy, + config, + ) - // needs to be the latest call because otherwise the values are null as they are not initialized yet - if (createDirs) - ResultFileHierarchy.createOutputDirectories(this) + // needs to be done after dir creation + configureLogger(logOutputDir) - // needs to be done after dir creation - configureLogger(logOutputDir) + resultFileHierarchy + } - /** Builds the base output directory string + /** Builds the base output directory * * @return - * the filepath string to the directory + * the filepath of the directory */ - private def buildBaseOutputDir: String = { - + private def buildBaseOutputDir( + outputDir: String + ): Path = { // clean file string if necessary val cleanedBaseOutputDir = { val normalizedOutputDir = normalize(outputDir) - (fileSeparator + "$").r.replaceAllIn(normalizedOutputDir, "") + (File.separator + "$").r.replaceAllIn(normalizedOutputDir, "") } - // create base output dir if non-existent - Paths.get(cleanedBaseOutputDir).toFile.getAbsolutePath + Paths.get(cleanedBaseOutputDir) } - /** Builds the output directory string for this specific run - * - * @return + /** Builds the output directory for this specific run */ - private def buildRunOutputDir: String = { + private def buildRunOutputDir( + baseOutputDir: Path, + simulationName: String, + runStartTimeUTC: Option[String], + ): Path = { val optionalSuffix = - if (addTimeStampToOutputDir) s"_$runStartTimeUTC" else "" - baseOutputDir - .concat(fileSeparator) - .concat(simulationName) - .concat(optionalSuffix) - } + runStartTimeUTC.map(pattern => s"_$pattern").getOrElse("") -} - -object ResultFileHierarchy extends LazyLogging { + baseOutputDir.resolve(s"$simulationName$optionalSuffix") + } /** @param resultEntitiesToConsider * [[ResultEntity]] s to consider to be written out @@ -161,8 +166,6 @@ object ResultFileHierarchy extends LazyLogging { * the csv sink type parameters * @param rawOutputDataDir * the directory of the raw output data - * @param fileSeparator - * the file separator to be used * @return * an absolute file path as string for the provided model class incl. file * name + extension @@ -170,9 +173,8 @@ object ResultFileHierarchy extends LazyLogging { private def buildRawOutputFilePath( modelClass: Class[_ <: ResultEntity], csvSink: Csv, - rawOutputDataDir: String, - fileSeparator: String, - ): String = { + rawOutputDataDir: Path, + ): Path = { val fileEnding = if (csvSink.fileFormat.startsWith(".")) csvSink.fileFormat @@ -192,64 +194,72 @@ object ResultFileHierarchy extends LazyLogging { ) } - rawOutputDataDir - .concat(fileSeparator) - .concat(filename.toString) - .concat(fileEnding) + rawOutputDataDir.resolve(s"${filename.toString}$fileEnding") } /** Prepares the output directories to be ready to hold the output data. This * includes creating the run directory with all subsequent directories as * well as copying the simulation configuration to the output dir * - * @param config + * @param baseOutputDir + * The base output directory + * @param dirsToBeCreated + * The directories that need to be created + * @param maybeConfig * the config of the current simulation * @param resultFileHierarchy * the output file hierarchy of the current simulation */ - def prepareDirectories( - config: TypesafeConfig, + private def prepareDirectories( + baseOutputDir: Path, + dirsToBeCreated: Seq[Path], resultFileHierarchy: ResultFileHierarchy, + maybeConfig: Option[TypesafeConfig], ): Unit = { // create output directories if they are not present yet if (!runOutputDirExists(resultFileHierarchy)) - ResultFileHierarchy.createOutputDirectories(resultFileHierarchy) + createOutputDirectories( + baseOutputDir, + dirsToBeCreated, + resultFileHierarchy, + ) - logger.info( - "Processing configs for simulation: {}.", - config.getString("simona.simulationName"), - ) + maybeConfig.foreach { config => + logger.info( + "Processing configs for simulation: {}.", + config.getString("simona.simulationName"), + ) - val outFile = - Paths.get(resultFileHierarchy.configOutputDir, "vn_simona.conf").toFile - val bw = new BufferedWriter(new FileWriter(outFile)) - bw.write( - config - .root() - .render( - ConfigRenderOptions - .defaults() - .setOriginComments(false) - .setComments(false) - ) - ) - bw.close() - logger.info("Config '{}' written to '{}'.", outFile.getPath, outFile) + val outFile = + resultFileHierarchy.configOutputDir.resolve("vn_simona.conf").toFile + val bw = new BufferedWriter(new FileWriter(outFile)) + bw.write( + config + .root() + .render( + ConfigRenderOptions + .defaults() + .setOriginComments(false) + .setComments(false) + ) + ) + bw.close() + logger.info("Config '{}' written to '{}'.", outFile.getPath, outFile) + } } /** Checks if the directory of the current run already exists * - * @param outputFileHierarchy + * @param fileHierarchy * the [[ResultFileHierarchy]] that holds information on the run directory * path * @return * true if it exists, false if not */ - def runOutputDirExists(outputFileHierarchy: ResultFileHierarchy): Boolean = { - new File(outputFileHierarchy.runOutputDir).exists() && new File( - outputFileHierarchy.runOutputDir - ).listFiles().length > 0 + def runOutputDirExists(fileHierarchy: ResultFileHierarchy): Boolean = { + val outputDir = fileHierarchy.runOutputDir.toFile + outputDir.exists() && outputDir.listFiles().length > 0 } /** Creates all output directories of the provided [[ResultFileHierarchy]] @@ -257,11 +267,12 @@ object ResultFileHierarchy extends LazyLogging { * @param outputFileHierarchy * the [[ResultFileHierarchy]] the directories should be created for */ - def createOutputDirectories( - outputFileHierarchy: ResultFileHierarchy + private def createOutputDirectories( + baseOutputDir: Path, + dirsToBeCreated: Seq[Path], + outputFileHierarchy: ResultFileHierarchy, ): Unit = { // try to create base output dir - val baseOutputDir = Paths.get(outputFileHierarchy.baseOutputDir) // / check for existence of the provided baseOutputDir, if not create it if (Files.exists(baseOutputDir) && baseOutputDir.toFile.isFile) { throw new FileHierarchyException( @@ -270,17 +281,17 @@ object ResultFileHierarchy extends LazyLogging { } // check if there is data inside the runOutputDir taking into account the provided FileHandling - val runOutputDir = new File(outputFileHierarchy.runOutputDir) + val runOutputDir = outputFileHierarchy.runOutputDir.toFile if (runOutputDir.exists() && runOutputDir.listFiles().length > 0) { // files inside the runOutputDir -> fail throw new FileHierarchyException( - s"The runOutputDir ${outputFileHierarchy.runOutputDir} already exists and is NOT empty! " + + s"The runOutputDir ${outputFileHierarchy.runOutputDir.toString} already exists and is NOT empty! " + s"Please either delete or empty the directory." ) } // create the output directories for the specific run - outputFileHierarchy.dirsToBeCreated.foreach(createDir) + dirsToBeCreated.foreach(createDir) } @@ -289,8 +300,8 @@ object ResultFileHierarchy extends LazyLogging { * @param dir * the full path where the directory should be created (incl. it's name) */ - private def createDir(dir: String): Unit = { - val dirFile = new File(dir) + private def createDir(dir: Path): Unit = { + val dirFile = dir.toFile if (!dirFile.mkdirs() && !dirFile.exists()) throw new FileHierarchyException( "The output directory path " + dir diff --git a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala index 26c3145945..68caa1706b 100644 --- a/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala +++ b/src/test/scala/edu/ie3/simona/event/listener/ResultEventListenerSpec.scala @@ -84,7 +84,6 @@ class ResultEventListenerSpec classes, resultSinkType, ), - createDirs = true, ) } @@ -122,14 +121,14 @@ class ResultEventListenerSpec ) // after the creation of the listener, it is expected that a corresponding raw result data file is present - val outputFile = new File( - fileHierarchy.rawOutputDataFilePaths.getOrElse( + val outputFile = fileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[PvResult], fail( s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ) + .toFile assert(outputFile.exists) assert(outputFile.isFile) @@ -162,14 +161,14 @@ class ResultEventListenerSpec listenerRef ! ParticipantResultEvent(dummyPvResult) - val outputFile = new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + val outputFile = specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[PvResult], fail( s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ) + .toFile // wait until output file exists (headers are flushed out immediately): awaitCond( @@ -219,39 +218,37 @@ class ResultEventListenerSpec ) val outputFiles = Map( - dummyNodeResultString -> new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + dummyNodeResultString -> specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[NodeResult], fail( s"Cannot get filepath for raw result file of class '${classOf[NodeResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - dummySwitchResultString -> new File( + ), + dummySwitchResultString -> specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( classOf[SwitchResult], fail( s"Cannot get filepath for raw result file of class '${classOf[SwitchResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - dummyLineResultDataString -> new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + ), + dummyLineResultDataString -> specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[LineResult], fail( s"Cannot get filepath for raw result file of class '${classOf[LineResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - dummyTrafo2wResultDataString -> new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + ), + dummyTrafo2wResultDataString -> specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[Transformer2WResult], fail( s"Cannot get filepath for raw result file of class '${classOf[Transformer2WResult].getSimpleName}' from outputFileHierarchy!'" ), - ) - ), - ) + ), + ).map { case (dummyString, path) => + (dummyString, path.toFile) + } // wait until all output files exist (headers are flushed out immediately): awaitCond( @@ -308,14 +305,15 @@ class ResultEventListenerSpec ) ) - val outputFile = new File( - fileHierarchy.rawOutputDataFilePaths.getOrElse( + val outputFile = fileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[Transformer3WResult], fail( s"Cannot get filepath for raw result file of class '${classOf[Transformer3WResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ) + .toFile + /* The result file is created at start up and only contains a headline. */ awaitCond( outputFile.exists(), @@ -386,12 +384,14 @@ class ResultEventListenerSpec val outputFile = new File( ".gz$".r.replaceAllIn( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( - classOf[PvResult], - fail( - s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" - ), - ), + specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( + classOf[PvResult], + fail( + s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" + ), + ) + .toString, "", ) ) @@ -413,26 +413,29 @@ class ResultEventListenerSpec // wait until file exists awaitCond( - new File( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( + specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( classOf[PvResult], fail( s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" ), ) - ).exists, + .toFile + .exists, timeoutDuration, ) val resultFileSource = Source.fromInputStream( new GZIPInputStream( new FileInputStream( - specificOutputFileHierarchy.rawOutputDataFilePaths.getOrElse( - classOf[PvResult], - fail( - s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" - ), - ) + specificOutputFileHierarchy.rawOutputDataFilePaths + .getOrElse( + classOf[PvResult], + fail( + s"Cannot get filepath for raw result file of class '${classOf[PvResult].getSimpleName}' from outputFileHierarchy!'" + ), + ) + .toFile ) ) ) diff --git a/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala b/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala index 4e53f0e078..083b9681e3 100644 --- a/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala +++ b/src/test/scala/edu/ie3/simona/integration/RunSimonaStandaloneIT.scala @@ -90,7 +90,7 @@ class RunSimonaStandaloneIT /* check the results */ // check configs - val configOutputDir = new File(resultFileHierarchy.configOutputDir) + val configOutputDir = resultFileHierarchy.configOutputDir.toFile configOutputDir.isDirectory shouldBe true configOutputDir.listFiles.toVector.size shouldBe 1 @@ -118,10 +118,12 @@ class RunSimonaStandaloneIT entityClass: Class[_ <: ResultEntity], ): BufferedSource = { Source.fromFile( - resultFileHierarchy.rawOutputDataFilePaths.getOrElse( - entityClass, - fail(s"Unable to get output path for result entity: $entityClass"), - ) + resultFileHierarchy.rawOutputDataFilePaths + .getOrElse( + entityClass, + fail(s"Unable to get output path for result entity: $entityClass"), + ) + .toFile ) } diff --git a/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala b/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala index 3b89d418f2..c273634fbe 100644 --- a/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala +++ b/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala @@ -51,37 +51,15 @@ class ResultFileHierarchySpec ), ) - val runOutputDirWithDate = - "vn_simona_".concat(validOutputFileHierarchy.runStartTimeUTC) - - relativizePath( - validOutputFileHierarchy.baseOutputDir - ).toString shouldBe baseOutputDir - relativizePath( - validOutputFileHierarchy.runOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate - relativizePath( - validOutputFileHierarchy.tmpDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "tmp" - relativizePath( - validOutputFileHierarchy.configOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "configs" - relativizePath( - validOutputFileHierarchy.rawOutputDataDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "rawOutputData" - relativizePath( - validOutputFileHierarchy.graphOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "graphs" - relativizePath( - validOutputFileHierarchy.kpiOutputDir - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "kpi" - - relativizePath( - validOutputFileHierarchy.rawOutputDataFilePaths(classOf[PvResult]) - ).toString shouldBe baseOutputDir + fileSeparator + runOutputDirWithDate + fileSeparator + "rawOutputData" + fileSeparator + "pref_pv_res_suff.csv" + validOutputFileHierarchy.tmpDir.toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "tmp" + validOutputFileHierarchy.configOutputDir.toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "configs" + validOutputFileHierarchy.logOutputDir.toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "log" + + validOutputFileHierarchy + .rawOutputDataFilePaths(classOf[PvResult]) + .toString shouldBe validOutputFileHierarchy.runOutputDir.toString + fileSeparator + "rawOutputData" + fileSeparator + "pref_pv_res_suff.csv" } - "not write directories automatically on instantiation" in {} // todo "write directories automatically on instantiation when requested so" in { // delete file if they exist @@ -97,7 +75,6 @@ class ResultFileHierarchySpec Set(classOf[PvResult]), ResultSinkType.Csv("csv", "pref", "suff"), ), - createDirs = true, ) // check for existence of run output dir @@ -106,26 +83,13 @@ class ResultFileHierarchySpec ) shouldBe true // check for existence of other folders - assert( - Files.exists(new File(validOutputFileHierarchy.baseOutputDir).toPath) - ) - assert(Files.exists(new File(validOutputFileHierarchy.tmpDir).toPath)) - assert( - Files.exists(new File(validOutputFileHierarchy.configOutputDir).toPath) - ) - assert( - Files.exists(new File(validOutputFileHierarchy.rawOutputDataDir).toPath) - ) - assert( - Files.exists(new File(validOutputFileHierarchy.graphOutputDir).toPath) - ) - assert( - Files.exists(new File(validOutputFileHierarchy.kpiOutputDir).toPath) - ) + assert(Files.exists(validOutputFileHierarchy.configOutputDir)) + assert(Files.exists(validOutputFileHierarchy.logOutputDir)) + assert(Files.exists(validOutputFileHierarchy.tmpDir)) // check if tmp directory can be deleted by output file hierarchy ResultFileHierarchy.deleteTmpDir(validOutputFileHierarchy) - assert(!Files.exists(new File(validOutputFileHierarchy.tmpDir).toPath)) + assert(!Files.exists(validOutputFileHierarchy.tmpDir)) } @@ -133,10 +97,8 @@ class ResultFileHierarchySpec } - private def relativizePath(fullPath: String): Path = { - new File(new File("").getAbsolutePath).toPath - .relativize(new File(fullPath).toPath) - } + private def relativizePath(fullPath: Path): Path = + new File(new File("").getAbsolutePath).toPath.relativize(fullPath) // todo output model path config compression should always be disabled -> test for this diff --git a/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala b/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala index 63be126c0f..9d1140be17 100644 --- a/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala +++ b/src/test/scala/edu/ie3/simona/sim/SimonaSimSpec.scala @@ -34,6 +34,7 @@ import org.apache.pekko.actor.typed.scaladsl.{ActorContext, Behaviors} import org.apache.pekko.actor.typed.{ActorRef, Behavior} import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path import java.util.UUID class SimonaSimSpec extends ScalaTestWithActorTestKit with UnitSpec { @@ -398,7 +399,7 @@ object SimonaSimSpec { override val args: Array[String] = Array.empty[String] - override def logOutputDir: String = throw new NotImplementedError() + override def logOutputDir: Path = throw new NotImplementedError() override def runtimeEventListener( context: ActorContext[_] diff --git a/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala b/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala index 7fa3ab3469..0428ed765b 100644 --- a/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala +++ b/src/test/scala/edu/ie3/simona/sim/setup/SimonaSetupSpec.scala @@ -26,13 +26,14 @@ import org.apache.pekko.actor.typed.ActorRef import org.apache.pekko.actor.typed.scaladsl.ActorContext import org.apache.pekko.actor.{ActorRef => ClassicRef} +import java.nio.file.Path import java.util.UUID class SimonaSetupSpec extends UnitSpec with SimonaSetup with SubGridGateMokka { override val args: Array[String] = Array.empty[String] - override def logOutputDir: String = throw new NotImplementedError() + override def logOutputDir: Path = throw new NotImplementedError() override def runtimeEventListener( context: ActorContext[_] From 6e821bf84454aafc298b7059a7e15254f852892e Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Mon, 18 Nov 2024 21:15:44 +0100 Subject: [PATCH 126/137] Adding to changelog Signed-off-by: Sebastian Peter --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cef76459a..4ea36f463e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898) - Refactoring of `ThermalGrid.energyGrid` to distinguish between demand of house and storage [#928](https://github.com/ie3-institute/simona/issues/928) - Refactoring to use zeroKW and zeroKWH in thermal grid unit tests [#1023](https://github.com/ie3-institute/simona/issues/1023) +- Refactor `ResultFileHierarchy` [#1031](https://github.com/ie3-institute/simona/issues/1031) ### Fixed - Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505) From dbe1df5e8c7c581ba934581a4038749eb8aa1467 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:53:59 +0100 Subject: [PATCH 127/137] Bump sphinx-hoverxref from 1.4.1 to 1.4.2 in /docs/readthedocs (#1033) Bumps [sphinx-hoverxref](https://github.com/readthedocs/sphinx-hoverxref) from 1.4.1 to 1.4.2. - [Changelog](https://github.com/readthedocs/sphinx-hoverxref/blob/main/CHANGELOG.rst) - [Commits](https://github.com/readthedocs/sphinx-hoverxref/compare/1.4.1...1.4.2) --- updated-dependencies: - dependency-name: sphinx-hoverxref dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/readthedocs/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/readthedocs/requirements.txt b/docs/readthedocs/requirements.txt index fcef71943b..4b84f2dcf4 100644 --- a/docs/readthedocs/requirements.txt +++ b/docs/readthedocs/requirements.txt @@ -3,5 +3,5 @@ sphinx-rtd-theme==3.0.2 sphinxcontrib-plantuml==0.30 myst-parser==4.0.0 markdown-it-py==3.0.0 -sphinx-hoverxref==1.4.1 +sphinx-hoverxref==1.4.2 sphinxcontrib-bibtex==2.6.3 From 0fbb91ee73432b9e959deaf3b59e34278231096b Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 19 Nov 2024 09:51:49 +0100 Subject: [PATCH 128/137] Update src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala --- .../edu/ie3/simona/service/primary/PrimaryServiceWorker.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index 6689b82889..a8fb5e55b4 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -145,7 +145,7 @@ final case class PrimaryServiceWorker[V <: Value]( ).pop (maybeNextTick, furtherActivationTicks) match { - case (maybeNextTick @ Some(tick), furtherActivationTicks) + case (Some(tick), furtherActivationTicks) if tick == 0L => /* Set up the state data and determine the next activation tick. */ val initializedStateData = From 3ecce788e5f4633ab625ca481fe1139f9162aa79 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 19 Nov 2024 09:55:45 +0100 Subject: [PATCH 129/137] spotless Signed-off-by: Sebastian Peter --- .../edu/ie3/simona/service/primary/PrimaryServiceWorker.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala index a8fb5e55b4..b20fdd834c 100644 --- a/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala +++ b/src/main/scala/edu/ie3/simona/service/primary/PrimaryServiceWorker.scala @@ -145,8 +145,7 @@ final case class PrimaryServiceWorker[V <: Value]( ).pop (maybeNextTick, furtherActivationTicks) match { - case (Some(tick), furtherActivationTicks) - if tick == 0L => + case (Some(tick), furtherActivationTicks) if tick == 0L => /* Set up the state data and determine the next activation tick. */ val initializedStateData = PrimaryServiceInitializedStateData( From c0d45979ffb8b7ad2e4f8adad516435e63adefb1 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 19 Nov 2024 10:52:46 +0100 Subject: [PATCH 130/137] Addressing reviewer's comments Signed-off-by: Sebastian Peter --- src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala | 8 ++------ .../edu/ie3/simona/io/file/ResultFileHierarchySpec.scala | 3 --- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 05a6f0ffd5..1b2d2df7e7 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -202,17 +202,13 @@ trait SetupHelper extends LazyLogging { /** Build the result file hierarchy based on the provided configuration file. * The provided type safe config must be able to be parsed as * [[SimonaConfig]], otherwise an exception is thrown + * * @param config * the configuration file - * @param createDirs - * if directories of the result file hierarchy should be created or not * @return * the resulting result file hierarchy */ - def buildResultFileHierarchy( - config: TypesafeConfig, - createDirs: Boolean = true, - ): ResultFileHierarchy = { + def buildResultFileHierarchy(config: TypesafeConfig): ResultFileHierarchy = { val simonaConfig = SimonaConfig(config) diff --git a/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala b/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala index c273634fbe..6ddc02a059 100644 --- a/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala +++ b/src/test/scala/edu/ie3/simona/io/file/ResultFileHierarchySpec.scala @@ -97,9 +97,6 @@ class ResultFileHierarchySpec } - private def relativizePath(fullPath: Path): Path = - new File(new File("").getAbsolutePath).toPath.relativize(fullPath) - // todo output model path config compression should always be disabled -> test for this } From 9bdec0da846e7907c068a1f0471533fcf975f57c Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 19 Nov 2024 11:09:49 +0100 Subject: [PATCH 131/137] Addressing reviewer's comments. --- .../simona/model/participant/BMModel.scala | 6 +++--- .../simona/model/participant/ChpModel.scala | 2 +- .../model/participant/FixedFeedInModel.scala | 2 +- .../simona/model/participant/HpModel.scala | 6 +++--- .../simona/model/participant/PvModel.scala | 7 ++++--- .../simona/model/participant/WecModel.scala | 2 +- .../model/participant/control/QControl.scala | 4 ++-- .../participant/evcs/EvModelWrapper.scala | 20 ++++++++++--------- .../model/participant/evcs/EvcsModel.scala | 2 +- .../model/participant/load/LoadModel.scala | 2 +- .../load/profile/LoadProfileStore.scala | 1 - .../load/random/RandomLoadModel.scala | 2 +- .../util/scala/quantities/ApparentPower.scala | 2 +- 13 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala index ac25324c1f..6f93742eeb 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/BMModel.scala @@ -195,9 +195,9 @@ final case class BMModel( isCostControlled && avgOpex.value.doubleValue() < feedInTariff.value .doubleValue() ) - sRated.toPower(cosPhiRated) * -1 + sRated.toActivePower(cosPhiRated) * -1 else - sRated.toPower(cosPhiRated) * usage * eff * -1 + sRated.toActivePower(cosPhiRated) * usage * eff * -1 } /** Applies the load gradient to the electrical output @@ -212,7 +212,7 @@ final case class BMModel( _lastPower match { case None => pEl case Some(lastPowerVal) => - val pElDeltaMaxAbs = sRated.toPower(cosPhiRated) * loadGradient + val pElDeltaMaxAbs = sRated.toActivePower(cosPhiRated) * loadGradient pEl - lastPowerVal match { case pElDelta if pElDelta > pElDeltaMaxAbs => diff --git a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala index 7bba620f63..e48909bd91 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala @@ -68,7 +68,7 @@ final case class ChpModel( ) with ApparentPowerParticipant[ChpRelevantData, ConstantState.type] { - val pRated: Power = sRated.toPower(cosPhiRated) + val pRated: Power = sRated.toActivePower(cosPhiRated) /** As this is a state-full model (with respect to the current operation * condition and its thermal storage), the power calculation operates on the diff --git a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index 396bfec08d..0501fcb025 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -71,7 +71,7 @@ final case class FixedFeedInModel( override def calculateActivePower( modelState: ConstantState.type, data: FixedRelevantData.type = FixedRelevantData, - ): Power = sRated.toPower(cosPhiRated) * -1 + ): Power = sRated.toActivePower(cosPhiRated) * -1 override def determineFlexOptions( data: FixedRelevantData.type, diff --git a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala index f5c6c7e66e..98d18d9ce3 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/HpModel.scala @@ -74,7 +74,7 @@ final case class HpModel( ) with ApparentPowerAndHeatParticipant[HpRelevantData, HpState] { - private val pRated: Power = sRated.toPower(cosPhiRated) + private val pRated: Power = sRated.toActivePower(cosPhiRated) /** As this is a state-full model (with respect to the current operation * condition and inner temperature), the power calculation operates on the @@ -312,7 +312,7 @@ final case class HpModel( updatedHpState.activePower val upperBoundary = if (canOperate) - sRated.toPower(cosPhiRated) + sRated.toActivePower(cosPhiRated) else zeroKW @@ -347,7 +347,7 @@ final case class HpModel( setPower: Power, ): (HpState, FlexChangeIndicator) = { /* If the setpoint value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */ - val turnOn = setPower > (sRated.toPower(cosPhiRated) * 0.5) + val turnOn = setPower > (sRated.toActivePower(cosPhiRated) * 0.5) val updatedHpState = calcState( lastState, diff --git a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala index f6103aa1c3..5d83478da0 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/PvModel.scala @@ -57,12 +57,13 @@ final case class PvModel private ( override val sMax: ApparentPower = sRated * 1.1 /** Permissible maximum active power feed in (therefore negative) */ - protected val pMax: Power = sMax.toPower(cosPhiRated) * -1d + protected val pMax: Power = sMax.toActivePower(cosPhiRated) * -1d /** Reference yield at standard testing conditions (STC) */ private val yieldSTC = WattsPerSquareMeter(1000d) - private val activationThreshold = sRated.toPower(cosPhiRated) * 0.001 * -1d + private val activationThreshold = + sRated.toActivePower(cosPhiRated) * 0.001 * -1d /** Calculate the active power behaviour of the model * @@ -691,7 +692,7 @@ final case class PvModel private ( /* Calculate the foreseen active power output without boundary condition adaptions */ val proposal = - sRated.toPower(cosPhiRated) * -1 * (actYield / irradiationSTC) + sRated.toActivePower(cosPhiRated) * -1 * (actYield / irradiationSTC) /* Do sanity check, if the proposed feed in is above the estimated maximum to be apparent active power of the plant */ if (proposal < pMax) diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index f1ca6258a0..50f26708e7 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -96,7 +96,7 @@ final case class WecModel( wecData: WecRelevantData, ): Power = { val activePower = determinePower(wecData) - val pMax = sMax.toPower(cosPhiRated) + val pMax = sMax.toActivePower(cosPhiRated) (if (activePower > pMax) { logger.warn( diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index aa6f7e77eb..aced18487d 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -175,7 +175,7 @@ object QControl { ): Power => ReactivePower = { activePower: Power => val qMaxFromP = Megavars( sqrt( - pow(sRated.toPower(1.0).toMegawatts, 2) - + pow(sRated.toActivePower(1.0).toMegawatts, 2) - pow(activePower.toMegawatts, 2) ) ) @@ -252,7 +252,7 @@ object QControl { ): Power => ReactivePower = { activePower: Power => /* cosphi( P / P_N ) = cosphi( P / (S_N * cosphi_rated) ) */ val pInPu = - activePower / sRated.toPower(cosPhiRated) + activePower / sRated.toActivePower(cosPhiRated) val instantCosPhi = cosPhi(Each(pInPu)) _cosPhiMultiplication(instantCosPhi.value.doubleValue, activePower) } diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala index 3c9f1077c6..7883557dbe 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvModelWrapper.scala @@ -10,7 +10,7 @@ import edu.ie3.simona.api.data.ev.model.EvModel import edu.ie3.util.quantities.PowerSystemUnits._ import edu.ie3.util.quantities.QuantityUtils.RichQuantityDouble import squants.Power -import squants.energy.{KilowattHours, Kilowatts} +import squants.energy.{Energy, KilowattHours, Kilowatts} import java.util.UUID @@ -27,21 +27,23 @@ import java.util.UUID * The wrapped [[EvModel]] */ final case class EvModelWrapper( - storedEnergy: squants.Energy, + storedEnergy: Energy, private val original: EvModel, ) { def uuid: UUID = original.getUuid def id: String = original.getId - lazy val pRatedAc: Power = - Kilowatts( - original.getSRatedAC.to(KILOWATT).getValue.doubleValue - ) - lazy val pRatedDc: squants.Power = - Kilowatts(original.getSRatedDC.to(KILOWATT).getValue.doubleValue) - lazy val eStorage: squants.Energy = KilowattHours( + + lazy val pRatedAc: Power = Kilowatts( + original.getSRatedAC.to(KILOWATT).getValue.doubleValue + ) + lazy val pRatedDc: Power = Kilowatts( + original.getSRatedDC.to(KILOWATT).getValue.doubleValue + ) + lazy val eStorage: Energy = KilowattHours( original.getEStorage.to(KILOWATTHOUR).getValue.doubleValue ) + def departureTick: Long = original.getDepartureTick /** Unwrapping the original [[EvModel]] while also updating the diff --git a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala index d85d9c584c..30b3f0a249 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/evcs/EvcsModel.scala @@ -506,7 +506,7 @@ final case class EvcsModel( ev.pRatedDc } /* Limit the charging power to the minimum of ev's and evcs' permissible power */ - evPower.min(sRated.toPower(1.0)) + evPower.min(sRated.toActivePower(1.0)) } override def calculatePower( diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala index bbb7f19063..6eb5a6fd0d 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/LoadModel.scala @@ -96,7 +96,7 @@ object LoadModel extends LazyLogging { .getValue .doubleValue ) - val pRated = sRated.toPower(inputModel.getCosPhiRated) + val pRated = sRated.toActivePower(inputModel.getCosPhiRated) val referenceScalingFactor = activePower / pRated sRated * referenceScalingFactor * safetyFactor } diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala index 270b044037..209d9349c8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/profile/LoadProfileStore.scala @@ -17,7 +17,6 @@ import edu.ie3.simona.model.participant.load.profile.LoadProfileStore.{ initializeTypeDayValues, } import edu.ie3.simona.model.participant.load.{DayType, profile} -import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} import org.apache.commons.csv.CSVFormat import squants.Power import squants.energy.{KilowattHours, Watts} diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index 9488102135..200e94465c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -169,7 +169,7 @@ object RandomLoadModel { * active power. * * @return - * Reference apparent power to use for later model calculations + * Reference active power to use for later model calculations */ private val randomMaxPower: Power = Watts(159d) diff --git a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala index eeec8fd219..2fe765ce9b 100644 --- a/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala +++ b/src/main/scala/edu/ie3/util/scala/quantities/ApparentPower.scala @@ -40,7 +40,7 @@ final class ApparentPower private ( * @return * the resulting active power */ - def toPower(cosPhi: Double): Power = Watts(toVoltamperes * cosPhi) + def toActivePower(cosPhi: Double): Power = Watts(toVoltamperes * cosPhi) /** Method to convert this apparent power into a [[ReactivePower]] using a * given cosPhi. From adbb3f557b92ecf549e297b9ba8120fe6116d5ff Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 19 Nov 2024 12:02:57 +0100 Subject: [PATCH 132/137] Validation of log level config Actually using the configuration Signed-off-by: Sebastian Peter --- .../ie3/simona/config/ConfigFailFast.scala | 52 ++++++++++++++----- .../logback/LogbackConfiguration.scala | 2 +- .../ie3/simona/sim/setup/SetupHelper.scala | 3 ++ .../ie3/simona/util/ResultFileHierarchy.scala | 4 +- .../simona/config/ConfigFailFastSpec.scala | 22 ++++++++ 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala index 0eaa7e30ba..c3b16d2ca7 100644 --- a/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala +++ b/src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala @@ -47,7 +47,7 @@ import scala.util.{Failure, Success, Try} * missing config parameters where at least one is needed or check for invalid * or contradicting parameters */ -case object ConfigFailFast extends LazyLogging { +object ConfigFailFast extends LazyLogging { def check(typeSafeConfig: Config, simonaConfig: SimonaConfig): Unit = { check(typeSafeConfig) @@ -139,18 +139,7 @@ case object ConfigFailFast extends LazyLogging { /* Check if the provided combination of data source and parameters are valid */ checkWeatherDataSource(simonaConfig.simona.input.weather.datasource) - /* check if at least one data sink is defined */ - checkDataSink(simonaConfig.simona.output.sink) - - /* Check all output configurations for participant models */ - checkParticipantsOutputConfig( - simonaConfig.simona.output.participant - ) - - /* Check all output configurations for thermal models */ - checkThermalOutputConfig( - simonaConfig.simona.output.thermal - ) + checkOutputConfig(simonaConfig.simona.output) /* Check power flow resolution configuration */ checkPowerFlowResolutionConfiguration(simonaConfig.simona.powerflow) @@ -162,6 +151,28 @@ case object ConfigFailFast extends LazyLogging { checkStoragesConfig(simonaConfig.simona.runtime.participant.storage) } + /** Checks for valid output configuration + * + * @param outputConfig + * the output configuration that should be checked + */ + private def checkOutputConfig( + outputConfig: SimonaConfig.Simona.Output + ): Unit = { + + /* check if at least one data sink is defined */ + checkDataSink(outputConfig.sink) + + /* Check all output configurations for participant models */ + checkParticipantsOutputConfig(outputConfig.participant) + + /* Check all output configurations for thermal models */ + checkThermalOutputConfig(outputConfig.thermal) + + /* Check output configurations for log */ + checkLogOutputConfig(outputConfig.log) + } + /** Checks for valid sink configuration * * @param sink @@ -698,6 +709,21 @@ case object ConfigFailFast extends LazyLogging { checkIndividualOutputConfigs(subConfig.individualConfigs) } + /** Check the config subtree for log output parameterization + * + * @param subConfig + * Output sub config tree for log + */ + private def checkLogOutputConfig( + subConfig: SimonaConfig.Simona.Output.Log + ): Unit = { + val validLogLevels = Seq("TRACE", "DEBUG", "INFO", "WARN", "ERROR") + if (!validLogLevels.contains(subConfig.level)) + throw new InvalidConfigParameterException( + s"Invalid log level \"${subConfig.level}\". Valid log levels: ${validLogLevels.mkString(", ")}" + ) + } + /** Checks resolution of power flow calculation * * @param powerFlow diff --git a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala index 31c23e4568..b28499074f 100644 --- a/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala +++ b/src/main/scala/edu/ie3/simona/logging/logback/LogbackConfiguration.scala @@ -18,7 +18,7 @@ import java.nio.file.Path object LogbackConfiguration extends LazyLogging { - def default(logPath: Path, logLevel: String): Unit = { + def default(logLevel: String)(logPath: Path): Unit = { LoggerFactory.getILoggerFactory match { case loggerContext: LoggerContext => val rootLogger = loggerContext.getLogger("root") diff --git a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala index 1b2d2df7e7..9b06f604da 100644 --- a/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala +++ b/src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala @@ -20,6 +20,7 @@ import edu.ie3.simona.config.SimonaConfig import edu.ie3.simona.exceptions.InitializationException import edu.ie3.simona.exceptions.agent.GridAgentInitializationException import edu.ie3.simona.io.result.ResultSinkType +import edu.ie3.simona.logging.logback.LogbackConfiguration import edu.ie3.simona.model.grid.RefSystem import edu.ie3.simona.util.ConfigUtil.{GridOutputConfigUtil, OutputConfigUtil} import edu.ie3.simona.util.ResultFileHierarchy.ResultEntityPathConfig @@ -226,6 +227,8 @@ trait SetupHelper extends LazyLogging { simonaConfig.simona.simulationName, ), ), + configureLogger = + LogbackConfiguration.default(simonaConfig.simona.output.log.level), config = Some(config), addTimeStampToOutputDir = simonaConfig.simona.output.base.addTimestampToOutputDir, diff --git a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala index 2020d74743..bb371308a6 100644 --- a/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala +++ b/src/main/scala/edu/ie3/simona/util/ResultFileHierarchy.scala @@ -45,7 +45,7 @@ object ResultFileHierarchy extends LazyLogging { outputDir: String, simulationName: String, resultEntityPathConfig: ResultEntityPathConfig, - configureLogger: (Path, String) => Unit = LogbackConfiguration.default, + configureLogger: Path => Unit = LogbackConfiguration.default("INFO"), config: Option[TypesafeConfig] = None, addTimeStampToOutputDir: Boolean = true, ): ResultFileHierarchy = { @@ -115,7 +115,7 @@ object ResultFileHierarchy extends LazyLogging { ) // needs to be done after dir creation - configureLogger(logOutputDir, "INFO") // todo + configureLogger(logOutputDir) resultFileHierarchy } diff --git a/src/test/scala/edu/ie3/simona/config/ConfigFailFastSpec.scala b/src/test/scala/edu/ie3/simona/config/ConfigFailFastSpec.scala index ae7bfae423..f86b0b47c0 100644 --- a/src/test/scala/edu/ie3/simona/config/ConfigFailFastSpec.scala +++ b/src/test/scala/edu/ie3/simona/config/ConfigFailFastSpec.scala @@ -897,6 +897,28 @@ class ConfigFailFastSpec extends UnitSpec with ConfigTestData { } } + "Checking log config" should { + val checkLogOutputConfig = + PrivateMethod[Unit](Symbol("checkLogOutputConfig")) + + "identify an unknown log level" in { + val invalidLogConfig = SimonaConfig.Simona.Output.Log("INVALID") + + intercept[InvalidConfigParameterException] { + ConfigFailFast invokePrivate checkLogOutputConfig(invalidLogConfig) + }.getMessage shouldBe "Invalid log level \"INVALID\". Valid log levels: TRACE, DEBUG, INFO, WARN, ERROR" + } + + "let valid log output configuration pass" in { + val validLogConfig = SimonaConfig.Simona.Output.Log("WARN") + + noException shouldBe thrownBy { + ConfigFailFast invokePrivate checkLogOutputConfig(validLogConfig) + } + } + + } + "Checking grid data sources" should { "identify a faulty csv separator" in { val csvParams = From 5c0750c58e8fd29e4d45b2f3e8590e670fb86060 Mon Sep 17 00:00:00 2001 From: Sebastian Peter Date: Tue, 19 Nov 2024 12:05:32 +0100 Subject: [PATCH 133/137] Also setting the log level in example grid, because most people will look there Signed-off-by: Sebastian Peter --- input/samples/vn_simona/vn_simona.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/input/samples/vn_simona/vn_simona.conf b/input/samples/vn_simona/vn_simona.conf index 3a795e7cb5..b911acf2c1 100644 --- a/input/samples/vn_simona/vn_simona.conf +++ b/input/samples/vn_simona/vn_simona.conf @@ -101,6 +101,8 @@ simona.output.thermal = { ] } +simona.output.log.level = "INFO" + ################################################################## # Runtime Configuration // todo refactor as this naming is misleading and partly unneeded ################################################################## From 840cf76abdcf64fa358b775cd2eaa3ea3e20cec2 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 19 Nov 2024 12:08:40 +0100 Subject: [PATCH 134/137] Improving code. --- .../edu/ie3/simona/model/participant/control/QControl.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index aced18487d..06ea4b98d7 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -173,11 +173,9 @@ object QControl { cosPhiRated: Double, nodalVoltage: Dimensionless, ): Power => ReactivePower = { activePower: Power => + // Q = sqrt(S^2 - P^2) val qMaxFromP = Megavars( - sqrt( - pow(sRated.toActivePower(1.0).toMegawatts, 2) - - pow(activePower.toMegawatts, 2) - ) + sqrt(pow(sRated.toMegavoltamperes, 2) - pow(activePower.toMegawatts, 2)) ) val qFromCharacteristic = q( From 0a90ee1e52f89e4d8ac3fe05d8841adc9edf312d Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Tue, 19 Nov 2024 15:16:58 +0100 Subject: [PATCH 135/137] Implementing reviewer's comments. --- .../edu/ie3/simona/model/participant/control/QControl.scala | 2 +- .../simona/model/participant/load/random/RandomLoadModel.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala index 06ea4b98d7..7c998cbc4e 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/control/QControl.scala @@ -180,7 +180,7 @@ object QControl { val qFromCharacteristic = q( nodalVoltage, - Megavars(sRated.toReactivePower(cosPhiRated).toMegavars), + sRated.toReactivePower(cosPhiRated), ) qMaxPossible(qMaxFromP, qFromCharacteristic) } diff --git a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala index 200e94465c..bb0d95a9c8 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/load/random/RandomLoadModel.scala @@ -17,7 +17,7 @@ import edu.ie3.simona.model.participant.load.random.RandomLoadModel.RandomReleva import edu.ie3.simona.model.participant.load.{DayType, LoadModel, LoadReference} import edu.ie3.util.TimeUtil import edu.ie3.util.scala.OperationInterval -import edu.ie3.util.scala.quantities.{ApparentPower, Voltamperes} +import edu.ie3.util.scala.quantities.ApparentPower import squants.Power import squants.energy.{KilowattHours, Kilowatts, Watts} From 28d23371cdb8a7a71e85e73a5227642e9e408ec6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 12:45:03 +0000 Subject: [PATCH 136/137] Bump org.sonarqube from 5.1.0.4882 to 6.0.0.5145 (#1037) --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index f611c25268..2b7b87ffe4 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ plugins { id "de.undercouch.download" version "5.6.0" // downloads plugin id "kr.motd.sphinx" version "2.10.1" // documentation generation id "com.github.johnrengelman.shadow" version "8.1.1" // fat jar - id "org.sonarqube" version "5.1.0.4882" // sonarqube + id "org.sonarqube" version "6.0.0.5145" // sonarqube id "org.scoverage" version "8.1" // scala code coverage scoverage id "com.github.maiflai.scalatest" version "0.32" // run scalatest without specific spec task id 'org.hidetake.ssh' version '2.11.2' From 741a2b2b5a7c54b7e59c1a9c71931f1eedb02e33 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 07:27:31 +0100 Subject: [PATCH 137/137] Bump tech.units:indriya from 2.2 to 2.2.1 (#1039) Bumps [tech.units:indriya](https://github.com/unitsofmeasurement/indriya) from 2.2 to 2.2.1. - [Release notes](https://github.com/unitsofmeasurement/indriya/releases) - [Commits](https://github.com/unitsofmeasurement/indriya/compare/2.2...2.2.1) --- updated-dependencies: - dependency-name: tech.units:indriya dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 2b7b87ffe4..a69e01e63d 100644 --- a/build.gradle +++ b/build.gradle @@ -145,7 +145,7 @@ dependencies { implementation 'org.apache.commons:commons-math3:3.6.1' // apache commons math3 implementation 'org.apache.poi:poi-ooxml:5.3.0' // used for FilenameUtils implementation 'javax.measure:unit-api:2.2' - implementation 'tech.units:indriya:2.2' // quantities + implementation 'tech.units:indriya:2.2.1' // quantities implementation "org.typelevel:squants_${scalaVersion}:1.8.3" implementation 'org.apache.commons:commons-csv:1.12.0' implementation 'org.scalanlp:breeze_2.13:2.1.0' // scientific calculations (http://www.scalanlp.org/)