Skip to content

Commit

Permalink
Merge branch 'dev' into ms/#666-convert-GridAgent-and-DBFSAlgorithm-t…
Browse files Browse the repository at this point in the history
…o-pekko-typed

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
staudtMarius committed Feb 8, 2024
2 parents d52819e + a93808a commit e9b04f9
Show file tree
Hide file tree
Showing 23 changed files with 940 additions and 565 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Replaced akka with pekko [#641](https://github.com/ie3-institute/simona/issues/641)
- Use `ThermalGrid` to calculate thermal environment of a heat pump [#315](https://github.com/ie3-institute/simona/issues/315)
- Enable windows path as config parameters [#549](https://github.com/ie3-institute/simona/issues/549)
- Unified consideration of scaling factor when simulating system participants [#81](https://github.com/ie3-institute/simona/issues/81)
- Converting the `GridAgent` and the `DBFSAlgorithm` to `pekko typed` [#666](https://github.com/ie3-institute/simona/issues/666)

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,18 @@ protected trait LoadAgentFundamentals[LD <: LoadRelevantData, LM <: LoadModel[
inputModel.electricalInputModel.getOperationTime
)
val reference = LoadReference(inputModel.electricalInputModel, modelConfig)
buildModel(inputModel.electricalInputModel, operationInterval, reference)
buildModel(
inputModel.electricalInputModel,
operationInterval,
modelConfig,
reference
)
}

protected def buildModel(
inputModel: LoadInput,
operationInterval: OperationInterval,
modelConfig: LoadRuntimeConfig,
reference: LoadReference
): LM

Expand Down Expand Up @@ -295,12 +301,15 @@ case object LoadAgentFundamentals {
override def buildModel(
inputModel: LoadInput,
operationInterval: OperationInterval,
modelConfig: LoadRuntimeConfig,
reference: LoadReference
): FixedLoadModel = {
val model = FixedLoadModel(inputModel, operationInterval, 1d, reference)
model.enable()
model
}
): FixedLoadModel =
FixedLoadModel(
inputModel,
modelConfig.scaling,
operationInterval,
reference
)

/** Partial function, that is able to transfer
* [[ParticipantModelBaseStateData]] (holding the actual calculation model)
Expand Down Expand Up @@ -336,12 +345,15 @@ case object LoadAgentFundamentals {
override def buildModel(
inputModel: LoadInput,
operationInterval: OperationInterval,
modelConfig: LoadRuntimeConfig,
reference: LoadReference
): ProfileLoadModel = {
val model = ProfileLoadModel(inputModel, operationInterval, 1d, reference)
model.enable()
model
}
): ProfileLoadModel =
ProfileLoadModel(
inputModel,
operationInterval,
modelConfig.scaling,
reference
)

/** Partial function, that is able to transfer
* [[ParticipantModelBaseStateData]] (holding the actual calculation model)
Expand Down Expand Up @@ -374,12 +386,15 @@ case object LoadAgentFundamentals {
override def buildModel(
inputModel: LoadInput,
operationInterval: OperationInterval,
modelConfig: LoadRuntimeConfig,
reference: LoadReference
): RandomLoadModel = {
val model = RandomLoadModel(inputModel, operationInterval, 1d, reference)
model.enable()
model
}
): RandomLoadModel =
RandomLoadModel(
inputModel,
operationInterval,
modelConfig.scaling,
reference
)

/** Partial function, that is able to transfer
* [[ParticipantModelBaseStateData]] (holding the actual calculation model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait ApparentPowerAndHeatParticipant[CD <: CalcRelevantData] {
val apparentPower = calculateApparentPower(tick, voltage, data)
val heat =
if (isInOperation(tick))
calculateHeat(tick, data)
calculateHeat(tick, data) * scalingFactor
else
Megawatts(0d)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final case class BMModel(
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhi: Double,
Expand Down
35 changes: 27 additions & 8 deletions src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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
import edu.ie3.simona.model.SystemComponent
import edu.ie3.simona.model.participant.ChpModel._
import edu.ie3.simona.model.participant.control.QControl
import edu.ie3.simona.model.thermal.{MutableStorage, ThermalStorage}
Expand All @@ -19,6 +20,8 @@ import squants.{Energy, Power, Seconds, Time}

import java.util.UUID

import java.time.ZonedDateTime

/** Model of a combined heat and power plant (CHP) with a [[ThermalStorage]]
* medium and its current [[ChpState]].
*
Expand All @@ -45,7 +48,7 @@ final case class ChpModel(
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhiRated: Double,
Expand Down Expand Up @@ -333,26 +336,38 @@ case object ChpModel {
*
* @param chpInput
* instance of [[ChpInput]] this chp model should be built from
* @param operationInterval
* operation interval of the simulation
* @param simulationStartDate
* Simulation time at which the simulation starts
* @param simulationEndDate
* Simulation time at which the simulation ends
* @param qControl
* (no usage)
* Strategy to control the reactive power output
* @param scalingFactor
* Scale the output of this asset by the given factor
* @param thermalStorage
* instance of [[ThermalStorage]] used as thermal storage
* @return
* a ready-to-use [[ChpModel]] with referenced electric parameters
*/
def apply(
chpInput: ChpInput,
operationInterval: OperationInterval,
simulationStartDate: ZonedDateTime,
simulationEndDate: ZonedDateTime,
qControl: QControl,
scalingFactor: Double,
thermalStorage: ThermalStorage with MutableStorage
): ChpModel =
new ChpModel(
): ChpModel = {
val operationInterval = SystemComponent.determineOperationInterval(
simulationStartDate,
simulationEndDate,
chpInput.getOperationTime
)

val model = new ChpModel(
chpInput.getUuid,
chpInput.getId,
operationInterval,
scalingFactor = 1.0,
scalingFactor,
qControl,
Kilowatts(
chpInput.getType.getsRated
Expand All @@ -369,4 +384,8 @@ case object ChpModel {
),
thermalStorage
)

model.enable()
model
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final case class EvcsModel(
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: squants.Power,
cosPhiRated: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final case class FixedFeedInModel(
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhiRated: Double
Expand All @@ -69,7 +69,7 @@ final case class FixedFeedInModel(
override protected def calculateActivePower(
data: FixedRelevantData.type = FixedRelevantData
): Power =
sRated * (-1) * cosPhiRated * scalingFactor
sRated * (-1) * cosPhiRated
}

case object FixedFeedInModel extends LazyLogging {
Expand Down
28 changes: 20 additions & 8 deletions src/main/scala/edu/ie3/simona/model/participant/HpModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final case class HpModel(
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhiRated: Double,
Expand All @@ -72,7 +72,7 @@ final case class HpModel(
with ApparentPowerAndHeatParticipant[HpRelevantData] {

private val pRated: Power =
sRated * cosPhiRated * scalingFactor
sRated * cosPhiRated

/** As this is a state-full model (with respect to the current operation
* condition and inner temperature), the power calculation operates on the
Expand Down Expand Up @@ -158,7 +158,7 @@ final case class HpModel(
private def calcState(hpData: HpRelevantData, isRunning: Boolean): HpState = {
val (newActivePower, newThermalPower) =
if (isRunning)
(pRated, pThermal * scalingFactor)
(pRated, pThermal)
else (DefaultQuantities.zeroKW, DefaultQuantities.zeroKW)
/* Push thermal energy to the thermal grid and get it's updated state in return */
val thermalGridState = hpData match {
Expand Down Expand Up @@ -275,26 +275,38 @@ case object HpModel {
*
* @param hpInput
* instance of [[HpInput]] this chp model should be built from
* @param operationInterval
* operation interval of the simulation
* @param simulationStartDate
* Simulation time at which the simulation starts
* @param simulationEndDate
* Simulation time at which the simulation ends
* @param qControl
* (no usage)
* Strategy to control the reactive power output
* @param scalingFactor
* Scale the output of this asset by the given factor
* @param thermalGrid
* thermal grid, defining the behaviour of the connected sinks and storages
* @return
* a ready-to-use [[HpModel]] with referenced electric parameters
*/
def apply(
hpInput: HpInput,
operationInterval: OperationInterval,
simulationStartDate: ZonedDateTime,
simulationEndDate: ZonedDateTime,
qControl: QControl,
scalingFactor: Double,
thermalGrid: ThermalGrid
): HpModel = {
val operationInterval = SystemComponent.determineOperationInterval(
simulationStartDate,
simulationEndDate,
hpInput.getOperationTime
)

val model = new HpModel(
hpInput.getUuid,
hpInput.getId,
operationInterval,
scalingFactor = 1.0,
scalingFactor,
qControl,
Kilowatts(
hpInput.getType.getsRated
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/edu/ie3/simona/model/participant/PvModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final case class PvModel private (
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhiRated: Double,
Expand Down Expand Up @@ -141,7 +141,7 @@ final case class PvModel private (
eTotal,
data.dateTime,
irraditionSTC
) * scalingFactor
)
}

/** Calculates the position of the earth in relation to the sun (day angle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class SystemParticipant[
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhiRated: Double
Expand Down Expand Up @@ -101,7 +101,10 @@ abstract class SystemParticipant[
val activePower = calculateActivePower(data)
val reactivePower =
calculateReactivePower(activePower, voltage)
ApparentPower(activePower, reactivePower)
ApparentPower(
activePower * scalingFactor,
reactivePower * scalingFactor
)
} else {
ApparentPower(
DefaultQuantities.zeroMW,
Expand Down Expand Up @@ -131,7 +134,7 @@ abstract class SystemParticipant[
nodalVoltage: Dimensionless
): Power => ReactivePower =
qControl.activeToReactivePowerFunc(
sRated * scalingFactor,
sRated,
cosPhiRated,
nodalVoltage
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ final case class WecModel(
uuid: UUID,
id: String,
operationInterval: OperationInterval,
scalingFactor: Double,
override val scalingFactor: Double,
qControl: QControl,
sRated: Power,
cosPhiRated: Double,
Expand Down
Loading

0 comments on commit e9b04f9

Please sign in to comment.