Skip to content

Commit

Permalink
Merge branch 'dev' into df/#965-compression-at-resultEventListener
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
danielfeismann committed Oct 28, 2024
2 parents 13b14f1 + 0d2f064 commit 3515945
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote SystemParticipantTest and MockParticipant from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- 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)
- Move compression of output files into `ResultEventListener`[#965](https://github.com/ie3-institute/simona/issues/965)

### Fixed
Expand Down Expand Up @@ -123,6 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
- 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)

## [3.0.0] - 2023-08-07

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ trait HpAgentFundamentals
)

val accompanyingResults = baseStateData.model.thermalGrid.results(
updatedState.thermalGridState
tick,
updatedState.thermalGridState,
)(baseStateData.startDate)
val result = AccompaniedSimulationResult(power, accompanyingResults)

Expand Down Expand Up @@ -252,7 +253,8 @@ trait HpAgentFundamentals
relevantData,
)
val accompanyingResults = baseStateData.model.thermalGrid.results(
lastModelState.thermalGridState
currentTick,
lastModelState.thermalGridState,
)(baseStateData.startDate)
val result = AccompaniedSimulationResult(power, accompanyingResults)

Expand Down
28 changes: 19 additions & 9 deletions src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ final case class ThermalGrid(

/** Determine the energy demand of the total grid at the given instance in
* time
*
* @param tick
* Questioned instance in time
* @param ambientTemperature
Expand Down Expand Up @@ -101,6 +102,7 @@ final case class ThermalGrid(
}

/** Update the current state of the grid
*
* @param tick
* Instance in time
* @param state
Expand Down Expand Up @@ -133,6 +135,7 @@ final case class ThermalGrid(

/** Handles the case, when a grid has infeed. First, heat up all the houses to
* their maximum temperature, then fill up the storages
*
* @param tick
* Current tick
* @param lastAmbientTemperature
Expand Down Expand Up @@ -328,6 +331,7 @@ final case class ThermalGrid(
* <li>the house has reached it's lower temperature boundary,</li> <li>there
* is no infeed from external and</li> <li>the storage is not empty
* itself</li> </ul>
*
* @param tick
* The current tick
* @param maybeHouseState
Expand Down Expand Up @@ -399,40 +403,45 @@ final case class ThermalGrid(

/** Convert the given state of the thermal grid into result models of it's
* constituent models
*
* @param currentTick
* Actual simulation tick
* @param state
* State to be converted
* @param startDateTime
* Start date time of the simulation
* @return
* A [[Seq]] of results of the constituent thermal model
*/
def results(
state: ThermalGridState
)(implicit startDateTime: ZonedDateTime): Seq[ResultEntity] = {
val houseResults = house
def results(currentTick: Long, state: ThermalGridState)(implicit
startDateTime: ZonedDateTime
): Seq[ResultEntity] = {

val maybeHouseResult = house
.zip(state.houseState)
.filter { case (_, state) => state.tick == currentTick }
.map {
case (
thermalHouse,
ThermalHouseState(tick, innerTemperature, thermalInfeed),
) =>
Seq.empty[ResultEntity] :+ new ThermalHouseResult(
new ThermalHouseResult(
tick.toDateTime,
thermalHouse.uuid,
thermalInfeed.toMegawatts.asMegaWatt,
innerTemperature.toKelvinScale.asKelvin,
)
}
.getOrElse(Seq.empty[ResultEntity])

storage
val maybeStorageResult = storage
.zip(state.storageState)
.filter { case (_, state) => state.tick == currentTick }
.map {
case (
storage: CylindricalThermalStorage,
ThermalStorageState(tick, storedEnergy, qDot),
) =>
houseResults :+ new CylindricalStorageResult(
new CylindricalStorageResult(
tick.toDateTime,
storage.uuid,
storedEnergy.toMegawattHours.asMegaWattHour,
Expand All @@ -444,7 +453,8 @@ final case class ThermalGrid(
s"Result handling for storage type '${storage.getClass.getSimpleName}' not supported."
)
}
.getOrElse(houseResults)

Seq(maybeHouseResult, maybeStorageResult).flatten
}
}

Expand Down
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.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,
Expand Down Expand Up @@ -50,17 +51,13 @@ class ChpModelSpec
ChpState(isRunning = false, 0, Kilowatts(0), KilowattHours(0))
val chpStateRunning: ChpState =
ChpState(isRunning = true, 0, Kilowatts(0), KilowattHours(0))
var storageInput: CylindricalStorageInput = _
var chpInput: ChpInput = _

override def beforeAll(): Unit = {
setupSpec()
}
val (storageInput, chpInput) = setupSpec()

def setupSpec(): Unit = {
def setupSpec(): (CylindricalStorageInput, ChpInput) = {
val thermalBus = new ThermalBusInput(UUID.randomUUID(), "thermal bus")

storageInput = new CylindricalStorageInput(
val storageInput = new CylindricalStorageInput(
UUID.randomUUID(),
"ThermalStorage",
thermalBus,
Expand All @@ -84,10 +81,10 @@ class ChpModelSpec
getQuantity(0, KILOWATT),
)

chpInput = new ChpInput(
val chpInput = new ChpInput(
UUID.randomUUID(),
"ChpInput",
null,
OperatorInput.NO_OPERATOR_ASSIGNED,
OperationTime.notLimited(),
TestObjectFactory
.buildNodeInput(false, GermanVoltageLevelUtils.MV_10KV, 0),
Expand All @@ -98,6 +95,8 @@ class ChpModelSpec
null,
false,
)

(storageInput, chpInput)
}

def buildChpModel(thermalStorage: CylindricalThermalStorage): ChpModel = {
Expand Down

0 comments on commit 3515945

Please sign in to comment.