Skip to content

Commit

Permalink
Merge branch 'dev' into df/#1131-EmAggregate-powerLimits
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
danielfeismann committed Feb 7, 2025
2 parents e9fa787 + 3ae0665 commit d02375d
Show file tree
Hide file tree
Showing 17 changed files with 510 additions and 201 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote PvModelIT from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Fix negative required energy demand for thermalHouse [#1127](https://github.com/ie3-institute/simona/issues/1127)
- Refactored EM messages [#1138](https://github.com/ie3-institute/simona/issues/1138)
- `OperationInterval` should extend `RightOpenInterval` [#1142](https://github.com/ie3-institute/simona/issues/1142)
- Enhance EmAggregate of SelfOpt to cope with other targetLimits [#1131](https://github.com/ie3-institute/simona/issues/1131)

### Fixed
Expand Down Expand Up @@ -169,6 +170,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed ignored EM strategy [#1091](https://github.com/ie3-institute/simona/issues/1091)
- EM should output flex option results even if it has no parent [#1112](https://github.com/ie3-institute/simona/issues/1112)
- Rename `PrimaryDataWithApparentPower` to `PrimaryDataWithComplexPower` [#1140](https://github.com/ie3-institute/simona/issues/1140)
- Refactoring of `ThermalGrid.handleInfeed` to fix thermal storage recharge correctly when empty [#930](https://github.com/ie3-institute/simona/issues/930)
- Move `ScheduleServiceActivation` out of `RegistrationResponseMessage` [#1143](https://github.com/ie3-institute/simona/issues/1143)

## [3.0.0] - 2023-08-07

Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/edu/ie3/simona/api/ExtSimAdapter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package edu.ie3.simona.api

import org.apache.pekko.actor.typed.scaladsl.adapter.ClassicActorRefOps
import org.apache.pekko.actor.{Actor, ActorRef, PoisonPill, Props}
import edu.ie3.simona.api.ExtSimAdapter.{Create, ExtSimAdapterStateData, Stop}
import edu.ie3.simona.api.data.ontology.ScheduleDataServiceMessage
import edu.ie3.simona.api.simulation.ExtSimAdapterData
Expand All @@ -18,15 +16,17 @@ import edu.ie3.simona.api.simulation.ontology.{
CompletionMessage => ExtCompletionMessage,
}
import edu.ie3.simona.logging.SimonaActorLogging
import edu.ie3.simona.ontology.messages.Activation
import edu.ie3.simona.ontology.messages.SchedulerMessage.{
Completion,
ScheduleActivation,
}
import edu.ie3.simona.ontology.messages.services.ServiceMessage.RegistrationResponseMessage.ScheduleServiceActivation
import edu.ie3.simona.ontology.messages.Activation
import edu.ie3.simona.ontology.messages.services.ServiceMessage.ScheduleServiceActivation
import edu.ie3.simona.scheduler.ScheduleLock
import edu.ie3.simona.scheduler.ScheduleLock.ScheduleKey
import edu.ie3.simona.util.SimonaConstants.INIT_SIM_TICK
import org.apache.pekko.actor.typed.scaladsl.adapter.ClassicActorRefOps
import org.apache.pekko.actor.{Actor, ActorRef, PoisonPill, Props}

import scala.jdk.OptionConverters._

Expand Down
54 changes: 39 additions & 15 deletions src/main/scala/edu/ie3/simona/model/participant/HpModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ final case class HpModel(
)

// Updating the HpState
val updatedState =
calcState(lastHpState, relevantData, turnOn)
(canOperate, canBeOutOfOperation, updatedState)
val updatedHpState =
calcState(lastHpState, relevantData, turnOn, thermalDemandWrapper)
(canOperate, canBeOutOfOperation, updatedHpState)
}

/** Depending on the input, this function decides whether the heat pump will
Expand Down Expand Up @@ -212,40 +212,54 @@ final case class HpModel(
* data of heat pump including state of the heat pump
* @param isRunning
* determines whether the heat pump is running or not
* @param demandWrapper
* holds the thermal demands of the thermal units (house, storage)
* @return
* next [[HpState]]
*/
private def calcState(
lastState: HpState,
relevantData: HpRelevantData,
isRunning: Boolean,
demandWrapper: ThermalDemandWrapper,
): HpState = {
val lastStateStorageQDot = lastState.thermalGridState.storageState
.map(_.qDot)
.getOrElse(zeroKW)

val (newActivePower, newThermalPower) =
val (newActivePowerHp, newThermalPowerHp, qDotIntoGrid) = {
if (isRunning)
(pRated, pThermal)
(pRated, pThermal, pThermal)
else if (lastStateStorageQDot < zeroKW)
(zeroKW, lastStateStorageQDot * -1)
else (zeroKW, zeroKW)
(zeroKW, zeroKW, lastStateStorageQDot * (-1))
else if (
lastStateStorageQDot == zeroKW && (demandWrapper.houseDemand.hasRequiredDemand || demandWrapper.heatStorageDemand.hasRequiredDemand)
)
(
zeroKW,
zeroKW,
thermalGrid.storage.map(_.getChargingPower: squants.Power).get,
)
else (zeroKW, zeroKW, zeroKW)
}

/* Push thermal energy to the thermal grid and get its updated state in return */
val (thermalGridState, maybeThreshold) =
thermalGrid.updateState(
relevantData,
lastState.thermalGridState,
lastState.ambientTemperature.getOrElse(relevantData.ambientTemperature),
newThermalPower,
isRunning,
qDotIntoGrid,
demandWrapper,
)

HpState(
isRunning,
relevantData.currentTick,
Some(relevantData.ambientTemperature),
newActivePower,
newThermalPower,
newActivePowerHp,
newThermalPowerHp,
thermalGridState,
maybeThreshold,
)
Expand Down Expand Up @@ -285,7 +299,7 @@ final case class HpModel(
* operating state and give back the next tick in which something will
* change.
*
* @param data
* @param relevantData
* Relevant data for model calculation
* @param lastState
* The last known model state
Expand All @@ -296,17 +310,27 @@ final case class HpModel(
* options will change next
*/
override def handleControlledPowerChange(
data: HpRelevantData,
relevantData: HpRelevantData,
lastState: HpState,
setPower: Power,
): (HpState, FlexChangeIndicator) = {
/* If the set point value is above 50 % of the electrical power, turn on the heat pump otherwise turn it off */
val turnOn = setPower > (sRated.toActivePower(cosPhiRated) * 0.5)

val (
thermalDemandWrapper,
_,
) =
thermalGrid.energyDemandAndUpdatedState(
relevantData,
lastState,
)

val updatedHpState = calcState(
lastState,
data,
relevantData,
turnOn,
thermalDemandWrapper,
)

(
Expand Down Expand Up @@ -378,9 +402,9 @@ object HpModel {
* @param ambientTemperature
* Optional ambient temperature, if available
* @param activePower
* result active power
* result active power of heat pump
* @param qDot
* result heat power
* result heat power of heat pump
* @param thermalGridState
* applicable state of the thermal grid
* @param maybeThermalThreshold
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,10 @@ object CylindricalThermalStorage {
input: CylindricalStorageInput,
initialStoredEnergy: Energy = DefaultQuantities.zeroKWh,
): CylindricalThermalStorage = {
val minEnergyThreshold: Energy =
CylindricalThermalStorage.volumeToEnergy(
CubicMeters(
input.getStorageVolumeLvlMin
.to(Units.CUBIC_METRE)
.getValue
.doubleValue
),
KilowattHoursPerKelvinCubicMeters(
input.getC
.to(PowerSystemUnits.KILOWATTHOUR_PER_KELVIN_TIMES_CUBICMETRE)
.getValue
.doubleValue
),
Celsius(input.getInletTemp.to(Units.CELSIUS).getValue.doubleValue()),
Celsius(input.getReturnTemp.to(Units.CELSIUS).getValue.doubleValue()),
)
val minEnergyThreshold: Energy = {
// Temporary fix until changes in PSDM are released, Some minimumEnergyThreshold would lead to non-plausible behaviour
zeroKWh
}

val maxEnergyThreshold: Energy =
CylindricalThermalStorage.volumeToEnergy(
Expand Down
Loading

0 comments on commit d02375d

Please sign in to comment.