Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hp thermal storage refill #860

Draft
wants to merge 92 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
339b43a
add tests for determine flex potential at thermal grid state with ful…
danielfeismann Jun 4, 2024
ff868bb
add tests for determine flex potential at thermal grid state with hou…
danielfeismann Jun 4, 2024
e202c18
changelog
danielfeismann Jun 4, 2024
e8b02bf
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Jul 5, 2024
6f53562
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Jul 5, 2024
93ba17d
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Jul 12, 2024
420bb1d
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Jul 17, 2024
891ab88
add maybeThermalThreshold to nextActivationTicks
danielfeismann Jul 17, 2024
5b9f652
changelog
danielfeismann Jul 17, 2024
989b7b6
provide heat pump the latest entry of weather data
danielfeismann Jul 17, 2024
8b41023
adapt handleInfeed to check for lastState qDot
danielfeismann Jul 17, 2024
e4457dc
fix energyDemand evaluation for demand only below target temperature
danielfeismann Jul 19, 2024
374a2ee
format and exception
danielfeismann Jul 19, 2024
280fed5
Revert "format and exception"
danielfeismann Jul 19, 2024
f51dd61
format and exception
danielfeismann Jul 19, 2024
a297697
refactor handleInfeed to comply with case where thermal storage has b…
danielfeismann Jul 19, 2024
77941f9
fix HpModelSpec to check for targetTemperature
danielfeismann Jul 19, 2024
cde52e4
adapt HpModelSpec to check for targetTemperature
danielfeismann Jul 19, 2024
6244e79
fmt
danielfeismann Jul 19, 2024
81ef30d
refactor energyDemand
danielfeismann Jul 19, 2024
ab0806c
refactor EmAgentIT
danielfeismann Jul 19, 2024
8c6aed6
rollback HpModelSpec
danielfeismann Jul 22, 2024
44873d2
fix energyDemand
danielfeismann Jul 22, 2024
ec7d3f7
update EmAgentIT
danielfeismann Jul 22, 2024
5dcc230
adapt EmAgentIT
danielfeismann Jul 22, 2024
3cc1aa6
Merge branch 'refs/heads/dev' into df/#827_fix_hp_overheating_house
danielfeismann Jul 22, 2024
a3959cb
rollback EmAgentIT changes
danielfeismann Jul 22, 2024
07574aa
Revert "rollback EmAgentIT changes"
danielfeismann Jul 22, 2024
1d7ae94
adapt EmAgentIT comments
danielfeismann Jul 22, 2024
fd1630e
use actual state when determine energyDemand for next period
danielfeismann Jul 22, 2024
9cd94e8
only charge storage if it has still available capacity
danielfeismann Jul 22, 2024
a001dc0
use the actual result tick for thermalhouse and thermal storage results
danielfeismann Jul 22, 2024
ae8185e
use the actual result tick for thermalhouse and thermal storage resul…
danielfeismann Jul 22, 2024
0624794
Merge branch 'dev' into df/#729-additional-tests-thermal-house
danielfeismann Jul 22, 2024
43d114b
fmt
danielfeismann Jul 22, 2024
d1edeab
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Jul 23, 2024
402b858
refactor determining the energyDemand to recharge storage
danielfeismann Jul 23, 2024
901f444
split energyDemand of ThermalGrid into demand of house and of storage
danielfeismann Jul 23, 2024
ba75a19
changelog
danielfeismann Jul 23, 2024
a65f25a
fix condition for handleInfeed in case qdot should be used first for …
danielfeismann Jul 23, 2024
b655165
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Jul 25, 2024
9c3dc92
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Jul 26, 2024
22a7743
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Jul 26, 2024
dc8ce19
Refactor ThermalGrid, distinguishes between house supply and storage
danielfeismann Jul 26, 2024
923702f
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Jul 26, 2024
84fe44c
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Jul 31, 2024
b90a71e
use should approximate for HpModelSpec
danielfeismann Jul 31, 2024
1d6dbea
add thermal house model to rtd
danielfeismann Jul 31, 2024
cc0a0b8
fix label
danielfeismann Jul 31, 2024
3e2070d
fix hyperlinks at rtd
danielfeismann Jul 31, 2024
b7770b6
fix 2 hyperlinks at rtd
danielfeismann Jul 31, 2024
62a5f38
codacy fmt
danielfeismann Jul 31, 2024
cf448e0
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Aug 5, 2024
0f9aaff
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 7, 2024
e3a534b
codacy
danielfeismann Aug 7, 2024
3d43014
fix condition if hp should be turned on in next tick
danielfeismann Aug 7, 2024
27b94e9
Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin
danielfeismann Aug 8, 2024
d9609da
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Aug 8, 2024
5a89c3d
Merge remote-tracking branch 'refs/remotes/origin/df/#894-storage-zer…
danielfeismann Aug 8, 2024
8563328
finalise ThermalGridIT
danielfeismann Aug 8, 2024
68075ac
fmt
danielfeismann Aug 8, 2024
105f143
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 8, 2024
22a7bc9
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Aug 12, 2024
11709ff
add case for testing flex potential by hp when thermal houses got ex…
danielfeismann Aug 13, 2024
d3e8188
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 13, 2024
ff16555
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Aug 13, 2024
7cdb54f
Merge branch 'dev' into df/#729-additional-tests-thermal-house
danielfeismann Aug 13, 2024
1949907
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 15, 2024
e6544dc
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 19, 2024
f279b89
converting hyperlinks to markdown
danielfeismann Aug 19, 2024
b9aafd1
Revert "converting hyperlinks to markdown"
danielfeismann Aug 19, 2024
b858b50
fix hyperlinks
danielfeismann Aug 19, 2024
cc312ad
Update src/test/scala/edu/ie3/simona/model/participant/HpModelSpec.scala
danielfeismann Aug 19, 2024
a502267
add explanatory comments
danielfeismann Aug 19, 2024
440019c
correct name of variable
danielfeismann Aug 19, 2024
8f3d05a
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 19, 2024
f912f30
Merge branch 'refs/heads/dev' into df/#729-additional-tests-thermal-h…
danielfeismann Aug 21, 2024
e74c5dd
Merge remote-tracking branch 'origin/df/#729-additional-tests-thermal…
danielfeismann Aug 21, 2024
6c9e988
Merge branch 'refs/heads/dev' into df/#827_fix_hp_storage_refill
danielfeismann Aug 21, 2024
fe7f1b2
Merge remote-tracking branch 'refs/remotes/origin/df/#729-additional-…
danielfeismann Aug 21, 2024
95d4907
fix merge conflict
danielfeismann Aug 21, 2024
c1891a0
remove storage min lvl in HpInputTestData
danielfeismann Aug 21, 2024
0886111
move operation conditions of hp into operatesInNextState and adapt Hp…
danielfeismann Aug 21, 2024
441dfdb
adapt condition for hasAdditionalDemand
danielfeismann Aug 21, 2024
8ee3b77
refactor ThermalEnergyDemand
danielfeismann Aug 21, 2024
ced3b55
fmt
danielfeismann Aug 21, 2024
b07c1f8
Revert "adapt condition for hasAdditionalDemand"
danielfeismann Aug 21, 2024
3696479
Merge remote-tracking branch 'refs/remotes/origin/df/#917-Refactor-Th…
danielfeismann Aug 21, 2024
8321411
remove broken test
danielfeismann Aug 21, 2024
3ed4fed
remove demand of heat storage from condtion for checking when hp can …
danielfeismann Aug 21, 2024
a4895ae
fix HpModelSpec
danielfeismann Aug 21, 2024
1f829e6
codacy
danielfeismann Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enhanced Newton-Raphson-PowerFlow failures with more information [#815](https://github.com/ie3-institute/simona/issues/815)
- 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)

### Changed
- Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435)
Expand Down Expand Up @@ -76,6 +77,7 @@ 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)
- Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin [#894](https://github.com/ie3-institute/simona/issues/894)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
Expand All @@ -100,6 +102,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed FixedFeedModelSpec [#861](https://github.com/ie3-institute/simona/issues/861)
- Fixing duration calculation in result events [#801](https://github.com/ie3-institute/simona/issues/801)
- Handle MobSim requests for current prices [#892](https://github.com/ie3-institute/simona/issues/892)
- Fixed Hp results leading to overheating house and other effects [#827](https://github.com/ie3-institute/simona/issues/827)
- Fixed thermal storage getting recharged when empty [#827](https://github.com/ie3-institute/simona/issues/827)

## [3.0.0] - 2023-08-07

Expand Down
1 change: 1 addition & 0 deletions docs/readthedocs/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ models/two_winding_transformer_model
models/three_winding_transformer_model
models/reference_system
models/thermal_grid_model
models/thermal_house_model
```

## System Participant Related Models
Expand Down
2 changes: 2 additions & 0 deletions docs/readthedocs/models/thermal_grid_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

The Thermal Grid Model introduces a coupling point to thermal system, equivalent to an electrical node. It can be used to interconnect thermal units to a thermal heat network.

A Thermal Grid Model consists of a {ref}`thermal_house_model` and / or a {ref}`cts_model` which are supplied by a thermal source like a {ref}`hp_model`.

## Attributes, Units and Remarks

Please refer to {doc}`PowerSystemDataModel - Thermal Bus <psdm:models/input/thermal/thermalbus>` for Attributes and Units used in this Model.
13 changes: 13 additions & 0 deletions docs/readthedocs/models/thermal_house_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(thermal_house_model)=

# Thermal House Model

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.

## Attributes, Units and Remarks

Please refer to {doc}`PowerSystemDataModel - Thermal House Model <psdm:models/input/thermal/thermalhouse>` for Attributes and Units used in this Model.
2 changes: 1 addition & 1 deletion src/main/scala/edu/ie3/simona/agent/ValueStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,26 @@
currentTick,
updatedState,
)
val updatedBaseStateData =
baseStateData.copy(stateDataStore = updatedStateDataStore)

val updatedBaseStateData = {
updatedState.maybeThermalThreshold match {
case Some(nextThreshold)
if baseStateData.foreseenDataTicks.headOption.exists {
case (_, Some(tick)) => nextThreshold.tick < tick
case _ => false
} =>
baseStateData.copy(
stateDataStore = updatedStateDataStore,
additionalActivationTicks =
baseStateData.additionalActivationTicks + nextThreshold.tick,
)
case _ =>
baseStateData.copy(
stateDataStore = updatedStateDataStore
)
}
}

updateValueStoresInformListenersAndGoToIdleWithUpdatedBaseStateData(
scheduler,
updatedBaseStateData,
Expand Down Expand Up @@ -293,7 +311,11 @@
calcRelevantData: HpRelevantData,
nodalVoltage: squants.Dimensionless,
model: HpModel,
): HpState = model.determineState(modelState, calcRelevantData)
): HpState = {
val (canOperate, canBeOutOfOperation, state) =

Check warning on line 315 in src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala

View check run for this annotation

SonarQubeGithubPRChecks / simona Sonarqube Results

src/main/scala/edu/ie3/simona/agent/participant/hp/HpAgentFundamentals.scala#L315

Unnecessary store before return.
model.determineState(modelState, calcRelevantData)
state
}

/** Abstract definition, individual implementations found in individual agent
* fundamental classes
Expand Down Expand Up @@ -385,25 +407,44 @@
tick: Long,
): HpRelevantData = {
/* extract weather data from secondary data, which should have been requested and received before */
val weatherData =
baseStateData.receivedSecondaryDataStore
val weatherData = {
val currentWeatherData = baseStateData.receivedSecondaryDataStore
.last(tick)
.flatMap { case (receivedTick, receivedValues) =>
if (receivedTick != tick)
log.debug(
s"The model ${baseStateData.model.getUuid} needs to do calculations with values received " +
s"in tick $receivedTick, as no weather data has been received in tick $tick."
)
receivedValues.collectFirst {
// filter secondary data for weather data
case (_, data: WeatherData) => data
if (receivedTick == tick) {
receivedValues.collectFirst { case (_, data: WeatherData) =>
data
}
} else None
}

// If current weather data is not found, fallback to the latest entry where the map is not empty
currentWeatherData
.orElse {
val latestEntry =
baseStateData.receivedSecondaryDataStore.store.toSeq.findLast {
case (_, receivedValues) => receivedValues.nonEmpty
}

latestEntry.flatMap { case (receivedTick, receivedValues) =>
if (tick - receivedTick > 3600) {
log.warning(
s"The model ${baseStateData.model.getUuid} is using weather data from tick $receivedTick, " +
s"but there is a discrepancy of ${tick - receivedTick} seconds compared to the current tick $tick."
)
}

receivedValues.collectFirst { case (_, data: WeatherData) =>
data
}
}
}
.getOrElse(
.getOrElse {
throw new InconsistentStateException(
s"The model ${baseStateData.model} was not provided with needed weather data."
)
)
}
}

HpRelevantData(
tick,
Expand Down
122 changes: 88 additions & 34 deletions src/main/scala/edu/ie3/simona/model/participant/HpModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ 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.energy.{Energy, KilowattHours, Kilowatts}
import squants.{Power, Temperature}

import java.time.ZonedDateTime
Expand Down Expand Up @@ -116,19 +118,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
Expand All @@ -142,18 +148,42 @@ 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, ThermalEnergyDemand, ThermalEnergyDemand) = {
val (demandHouse, demandStorage, updatedState) =
thermalGrid.energyDemandAndUpdatedState(
relevantData.currentTick,
relevantData.ambientTemperature,
state.thermalGridState,
)
implicit val tolerance: Energy = KilowattHours(1e-3)
val noStorageOrStorageIsEmpty: Boolean =
updatedState.storageState.isEmpty || updatedState.storageState.exists(
_.storedEnergy =~ zeroKWH
)

val turnHpOn: Boolean = {
(demandHouse.hasRequiredDemand && noStorageOrStorageIsEmpty) || demandStorage.hasRequiredDemand || (state.isRunning && demandHouse.hasAdditionalDemand) || (state.isRunning && demandStorage.hasAdditionalDemand)
}

val canOperate =
demandHouse.hasRequiredDemand || demandHouse.hasAdditionalDemand ||
demandStorage.hasRequiredDemand || demandStorage.hasAdditionalDemand
val canBeOutOfOperation =
!(demandHouse.hasRequiredDemand && noStorageOrStorageIsEmpty)

(
turnHpOn,
canOperate,
canBeOutOfOperation,
demandHouse,
demandStorage,
)
demand.hasRequiredDemand || (state.isRunning && demand.hasAdditionalDemand)
}

/** Calculate state depending on whether heat pump is needed or not. Also
Expand All @@ -166,18 +196,30 @@ 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 houseDemand
* determines if the thermal house has heat demand
* @param storageDemand
* determines if the thermal storage has heat demand
* @return
* next [[HpState]]
*/
private def calcState(
state: HpState,
relevantData: HpRelevantData,
isRunning: Boolean,
houseDemand: ThermalEnergyDemand,
storageDemand: ThermalEnergyDemand,
): 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) =
Expand All @@ -186,6 +228,8 @@ final case class HpModel(
state.thermalGridState,
state.ambientTemperature.getOrElse(relevantData.ambientTemperature),
newThermalPower,
houseDemand,
storageDemand,
)

HpState(
Expand All @@ -204,23 +248,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
Expand All @@ -229,7 +264,7 @@ final case class HpModel(

ProvideMinMaxFlexOptions(
uuid,
updatedState.activePower,
updatedHpState.activePower,
lowerBoundary,
upperBoundary,
)
Expand Down Expand Up @@ -259,13 +294,32 @@ 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,
data.ambientTemperature,
lastState.thermalGridState,
)

val updatedHpState: HpState =
calcState(
lastState,
data,
turnOn,
thermalEnergyDemandHouse,
thermalEnergyDemandStorage,
)

(
updatedState,
updatedHpState,
FlexChangeIndicator(
changesAtNextActivation = true,
updatedState.maybeThermalThreshold.map(_.tick),
updatedHpState.maybeThermalThreshold.map(_.tick),
),
)
}
Expand Down
Loading