Skip to content

Commit

Permalink
Merge branch 'dev' into df/#922-Fix-activation-of-Hp-when-not-under-c…
Browse files Browse the repository at this point in the history
…ontrol-of-an-EM

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
danielfeismann committed Aug 29, 2024
2 parents ec4ef6c + b870fe7 commit db67a3f
Show file tree
Hide file tree
Showing 12 changed files with 428 additions and 275 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,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)
- Rewrote BMModelTest 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)
Expand All @@ -101,6 +102,7 @@ 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)
- 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)

## [3.0.0] - 2023-08-07
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
pekkoVersion = '1.0.3'
jtsVersion = '1.19.0'
confluentKafkaVersion = '7.4.0'
tscfgVersion = '1.0.0'
tscfgVersion = '1.1.3'
scapegoatVersion = '3.0.0'

testContainerVersion = '0.41.4'
Expand Down Expand Up @@ -103,7 +103,7 @@ dependencies {
/* testing */
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'org.scalatestplus:mockito-3-4_2.13:3.2.10.0'
testImplementation 'org.mockito:mockito-core:5.12.0' // mocking framework
testImplementation 'org.mockito:mockito-core:5.13.0' // mocking framework
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.19"
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.8' //scalatest html output
testImplementation group: 'org.pegdown', name: 'pegdown', version: '1.6.0'
Expand Down
18 changes: 9 additions & 9 deletions src/main/scala/edu/ie3/simona/model/participant/BMModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final case class BMModel(

/** Saves power output of last cycle. Needed for load gradient
*/
private var _lastPower: Option[Power] = None
var _lastPower: Option[Power] = None

override def calculatePower(
tick: Long,
Expand All @@ -73,7 +73,7 @@ final case class BMModel(
* @return
* Active power
*/
override protected def calculateActivePower(
override def calculateActivePower(
modelState: ConstantState.type,
data: BMCalcRelevantData,
): Power = {
Expand All @@ -100,7 +100,7 @@ final case class BMModel(
* @return
* factor k1
*/
private def calculateK1(time: ZonedDateTime): Double = {
def calculateK1(time: ZonedDateTime): Double = {
val weekendCorr = Vector(0.98, 0.985, 0.982, 0.982, 0.97, 0.96, 0.95, 0.93,
0.925, 0.95, 0.98, 1.01, 1.018, 1.01, 1.01, 0.995, 1, 0.995, 0.99, 0.985,
0.99, 0.98, 0.975, 0.99)
Expand All @@ -120,7 +120,7 @@ final case class BMModel(
* @return
* factor k2
*/
private def calculateK2(time: ZonedDateTime): Double = {
def calculateK2(time: ZonedDateTime): Double = {
time.getDayOfYear match {
case x if x < 150 || x > 243 =>
1.03 // correction factor in heating season
Expand All @@ -138,7 +138,7 @@ final case class BMModel(
* @return
* heat demand in Megawatt
*/
private def calculatePTh(
def calculatePTh(
temp: Temperature,
k1: Double,
k2: Double,
Expand All @@ -158,7 +158,7 @@ final case class BMModel(
* @return
* usage
*/
private def calculateUsage(pTh: Power): Double = {
def calculateUsage(pTh: Power): Double = {
// if demand exceeds capacity -> activate peak load boiler (no effect on electrical output)
val maxHeat = Megawatts(43.14)
val usageUnchecked = pTh / maxHeat
Expand All @@ -173,7 +173,7 @@ final case class BMModel(
* @return
* efficiency
*/
private def calculateEff(usage: Double): Double =
def calculateEff(usage: Double): Double =
min(0.18 * pow(usage, 3) - 0.595 * pow(usage, 2) + 0.692 * usage + 0.724, 1)

/** Calculates electrical output from usage and efficiency
Expand All @@ -184,7 +184,7 @@ final case class BMModel(
* @return
* electrical output as Power
*/
private def calculateElOutput(
def calculateElOutput(
usage: Double,
eff: Double,
): Power = {
Expand All @@ -206,7 +206,7 @@ final case class BMModel(
* @return
* electrical output after load gradient has been applied
*/
private def applyLoadGradient(
def applyLoadGradient(
pEl: Power
): Power = {
_lastPower match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ final case class HpModel(
relevantData.currentTick,
state.thermalGridState,
state.ambientTemperature.getOrElse(relevantData.ambientTemperature),
relevantData.ambientTemperature,
newThermalPower,
)

Expand Down
35 changes: 29 additions & 6 deletions src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ final case class ThermalGrid(
* Instance in time
* @param state
* Currently applicable state
* @param lastAmbientTemperature
* Ambient temperature valid up until (not including) the current tick
* @param ambientTemperature
* Ambient temperature
* Current ambient temperature
* @param qDot
* Thermal energy balance
* @return
Expand All @@ -115,19 +117,28 @@ final case class ThermalGrid(
def updateState(
tick: Long,
state: ThermalGridState,
lastAmbientTemperature: Temperature,
ambientTemperature: Temperature,
qDot: Power,
): (ThermalGridState, Option[ThermalThreshold]) = if (qDot > zeroKW)
handleInfeed(tick, ambientTemperature, state, qDot)
handleInfeed(tick, lastAmbientTemperature, ambientTemperature, state, qDot)
else
handleConsumption(tick, ambientTemperature, state, qDot)
handleConsumption(
tick,
lastAmbientTemperature,
ambientTemperature,
state,
qDot,
)

/** 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
* Ambient temperature valid up until (not including) the current tick
* @param ambientTemperature
* Ambient temperature
* Current ambient temperature
* @param state
* Current state of the houses
* @param qDot
Expand All @@ -137,6 +148,7 @@ final case class ThermalGrid(
*/
private def handleInfeed(
tick: Long,
lastAmbientTemperature: Temperature,
ambientTemperature: Temperature,
state: ThermalGridState,
qDot: Power,
Expand All @@ -163,6 +175,7 @@ final case class ThermalGrid(
thermalHouse.determineState(
tick,
lastHouseState,
lastAmbientTemperature,
ambientTemperature,
qDot,
)
Expand All @@ -177,6 +190,7 @@ final case class ThermalGrid(
thermalHouse.determineState(
tick,
lastHouseState,
lastAmbientTemperature,
ambientTemperature,
zeroKW,
)
Expand Down Expand Up @@ -248,8 +262,10 @@ final case class ThermalGrid(
*
* @param tick
* Current tick
* @param lastAmbientTemperature
* Ambient temperature valid up until (not including) the current tick
* @param ambientTemperature
* Ambient temperature
* Current ambient temperature
* @param state
* Current state of the houses
* @param qDot
Expand All @@ -259,6 +275,7 @@ final case class ThermalGrid(
*/
private def handleConsumption(
tick: Long,
lastAmbientTemperature: Temperature,
ambientTemperature: Temperature,
state: ThermalGridState,
qDot: Power,
Expand All @@ -269,6 +286,7 @@ final case class ThermalGrid(
house.determineState(
tick,
houseState,
lastAmbientTemperature,
ambientTemperature,
zeroMW,
)
Expand All @@ -287,6 +305,7 @@ final case class ThermalGrid(
maybeUpdatedStorageState,
state.houseState,
state.storageState,
lastAmbientTemperature,
ambientTemperature,
qDot,
)
Expand Down Expand Up @@ -319,8 +338,10 @@ final case class ThermalGrid(
* Previous thermal house state before a first update was performed
* @param formerStorageState
* Previous thermal storage state before a first update was performed
* @param lastAmbientTemperature
* Ambient temperature valid up until (not including) the current tick
* @param ambientTemperature
* Ambient temperature
* Current ambient temperature
* @param qDot
* Thermal influx
* @return
Expand All @@ -334,6 +355,7 @@ final case class ThermalGrid(
],
formerHouseState: Option[ThermalHouseState],
formerStorageState: Option[ThermalStorageState],
lastAmbientTemperature: Temperature,
ambientTemperature: Temperature,
qDot: Power,
): (
Expand Down Expand Up @@ -367,6 +389,7 @@ final case class ThermalGrid(
"Impossible to find no house state"
)
),
lastAmbientTemperature,
ambientTemperature,
thermalStorage.getChargingPower,
)
Expand Down
13 changes: 8 additions & 5 deletions src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,22 @@ final case class ThermalHouse(
/** Update the current state of the house
*
* @param tick
* current instance in time
* Current instance in time
* @param state
* currently applicable state
* Currently applicable state
* @param lastAmbientTemperature
* Ambient temperature valid up until (not including) the current tick
* @param ambientTemperature
* Ambient temperature
* Current ambient temperature
* @param qDot
* new thermal influx
* New thermal influx
* @return
* Updated state and the tick in which the next threshold is reached
*/
def determineState(
tick: Long,
state: ThermalHouseState,
lastAmbientTemperature: Temperature,
ambientTemperature: Temperature,
qDot: Power,
): (ThermalHouseState, Option[ThermalThreshold]) = {
Expand All @@ -319,7 +322,7 @@ final case class ThermalHouse(
state.qDot,
duration,
state.innerTemperature,
ambientTemperature,
lastAmbientTemperature,
)

/* Calculate the next given threshold */
Expand Down
Loading

0 comments on commit db67a3f

Please sign in to comment.