Skip to content

Commit

Permalink
Merge branch 'df/#1023-zeroKW-and-kWh-in-test' into df/#930-refactor-…
Browse files Browse the repository at this point in the history
…handleInfeed

# Conflicts:
#	src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithHouseOnlySpec.scala
#	src/test/scala/edu/ie3/simona/model/thermal/ThermalGridWithStorageOnlySpec.scala
  • Loading branch information
danielfeismann committed Nov 15, 2024
2 parents 95d0562 + 86fcf1e commit 30e4318
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote StorageModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Updated `ExtEvSimulationClasses` [#898](https://github.com/ie3-institute/simona/issues/898)
- Refactoring of `ThermalGrid.energyGrid` to distinguish between demand of house and storage [#928](https://github.com/ie3-institute/simona/issues/928)
- Refactoring to use zeroKW and zeroKWH in thermal grid unit tests [#1023](https://github.com/ie3-institute/simona/issues/1023)

### Fixed
- Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{
HouseTemperatureLowerBoundaryReached,
HouseTemperatureUpperBoundaryReached,
}
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageState
import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{
StorageEmpty,
Expand Down Expand Up @@ -103,15 +104,15 @@ class ThermalGridWithHouseAndStorageSpec
testGridAmbientTemperature,
ThermalGrid.startingState(thermalGrid),
)
houseDemand.required should approximate(KilowattHours(0d))
houseDemand.required should approximate(zeroKWH)
houseDemand.possible should approximate(KilowattHours(31.05009722d))
storageDemand.required should approximate(KilowattHours(1150d))
storageDemand.possible should approximate(KilowattHours(1150d))
updatedThermalGridState.houseState shouldBe Some(
ThermalHouseState(10800, Kelvin(292.0799935185185), Kilowatts(0d))
ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW)
)
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d))
ThermalStorageState(10800, zeroKWH, zeroKW)
)
}

Expand All @@ -136,10 +137,10 @@ class ThermalGridWithHouseAndStorageSpec
storageDemand.required should approximate(KilowattHours(1150d))
storageDemand.possible should approximate(KilowattHours(1150d))
updatedThermalGridState.houseState shouldBe Some(
ThermalHouseState(10800, Celsius(15.959996296296296), Kilowatts(0d))
ThermalHouseState(10800, Celsius(15.959996296296296), zeroKW)
)
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d))
ThermalStorageState(10800, zeroKWH, zeroKW)
)
}
}
Expand All @@ -159,7 +160,7 @@ class ThermalGridWithHouseAndStorageSpec
storageState.copy(storedEnergy = initialLoading)
)
)
val externalQDot = Kilowatts(0d)
val externalQDot = zeroKW

val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
Expand Down Expand Up @@ -216,7 +217,7 @@ class ThermalGridWithHouseAndStorageSpec
) =>
houseTick shouldBe 0L
innerTemperature should approximate(Celsius(18.9999d))
qDotHouse should approximate(Kilowatts(0d))
qDotHouse should approximate(zeroKW)

storageTick shouldBe 0L
storedEnergy should approximate(initialLoading)
Expand All @@ -228,7 +229,7 @@ class ThermalGridWithHouseAndStorageSpec
}

"revising infeed from storage to house" should {
val zeroInflux = Kilowatts(0d)
val zeroInflux = zeroKW
val tick = 3600L
val ambientTemperature = Celsius(14d)
"hand back unaltered information if needed information is missing" in {
Expand Down Expand Up @@ -371,7 +372,7 @@ class ThermalGridWithHouseAndStorageSpec
(
ThermalStorageState(
tick,
KilowattHours(0d),
zeroKWH,
testGridQDotInfeed,
),
Some(StorageEmpty(tick)),
Expand Down Expand Up @@ -519,7 +520,7 @@ class ThermalGridWithHouseAndStorageSpec
.getOrElse(fail("No initial storage state found"))
)

qDotStorage should approximate(Kilowatts(0d))
qDotStorage should approximate(zeroKW)

case _ => fail("Thermal grid state has been calculated wrong.")
}
Expand Down Expand Up @@ -558,7 +559,7 @@ class ThermalGridWithHouseAndStorageSpec
) =>
houseTick shouldBe 0L
innerTemperature should approximate(Celsius(20.99999167d))
qDotHouse should approximate(Kilowatts(0d))
qDotHouse should approximate(zeroKW)

storageTick shouldBe 0L
storedEnergy should approximate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{
HouseTemperatureLowerBoundaryReached,
HouseTemperatureUpperBoundaryReached,
}
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
import edu.ie3.simona.test.common.UnitSpec
import squants.energy._
import squants.thermal.Celsius
Expand Down Expand Up @@ -90,10 +91,10 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {

houseDemand.required should approximate(expectedHouseDemand.required)
houseDemand.possible should approximate(expectedHouseDemand.possible)
storageDemand.required should approximate(KilowattHours(0d))
storageDemand.possible should approximate(KilowattHours(0d))
storageDemand.required should approximate(zeroKWH)
storageDemand.possible should approximate(zeroKWH)
updatedThermalGridState.houseState shouldBe Some(
ThermalHouseState(10800, Kelvin(292.0799935185185), Kilowatts(0d))
ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW)
)
updatedThermalGridState.storageState shouldBe None
}
Expand All @@ -108,7 +109,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
"deliver the house state by just letting it cool down, if just no infeed is given" in {
val tick = 0L
val gridState = ThermalGrid.startingState(thermalGrid)
val externalQDot = Megawatts(0d)
val externalQDot = zeroKW

val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
Expand Down Expand Up @@ -154,7 +155,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
) =>
tick shouldBe 0L
innerTemperature should approximate(Celsius(18.9999d))
qDot should approximate(Megawatts(0d))
qDot should approximate(zeroKW)
case _ => fail("Thermal grid state has been calculated wrong.")
}
reachedThreshold shouldBe Some(
Expand Down Expand Up @@ -245,7 +246,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
) =>
tick shouldBe 0L
innerTemperature should approximate(Celsius(18.9999d))
qDot should approximate(Megawatts(0d))
qDot should approximate(zeroKW)
thresholdTick shouldBe 154285L
case _ => fail("Thermal grid state updated failed")
}
Expand All @@ -258,7 +259,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
testGridAmbientTemperature,
testGridAmbientTemperature,
isNotRunning,
Megawatts(0d),
zeroKW,
onlyThermalDemandOfHouse,
) match {
case (
Expand All @@ -270,7 +271,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
) =>
tick shouldBe 0L
innerTemperature should approximate(Celsius(18.9999d))
qDot should approximate(Kilowatts(0d))
qDot should approximate(zeroKW)
thresholdTick shouldBe 154285L
case _ => fail("Thermal grid state updated failed")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{
StorageFull,
}
import edu.ie3.simona.test.common.UnitSpec
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
import squants.energy._
import squants.thermal.Celsius
import squants.{Energy, Power, Temperature}
Expand Down Expand Up @@ -88,13 +89,13 @@ class ThermalGridWithStorageOnlySpec
ThermalGrid.startingState(thermalGrid),
)

houseDemand.required should approximate(KilowattHours(0d))
houseDemand.possible should approximate(KilowattHours(0d))
houseDemand.required should approximate(zeroKWH)
houseDemand.possible should approximate(zeroKWH)
storageDemand.required should approximate(KilowattHours(1150d))
storageDemand.possible should approximate(KilowattHours(1150d))
updatedThermalGridState.houseState shouldBe None
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, KilowattHours(0d), Kilowatts(0d))
ThermalStorageState(10800, zeroKWH, zeroKW)
)
}

Expand All @@ -108,17 +109,17 @@ class ThermalGridWithStorageOnlySpec
testGridAmbientTemperature,
ThermalGridState(
None,
Some(ThermalStorageState(0L, KilowattHours(575d), Kilowatts(0d))),
Some(ThermalStorageState(0L, KilowattHours(575d), zeroKW)),
),
)

houseDemand.required should approximate(KilowattHours(0d))
houseDemand.possible should approximate(KilowattHours(0d))
storageDemand.required should approximate(KilowattHours(0d))
houseDemand.required should approximate(zeroKWH)
houseDemand.possible should approximate(zeroKWH)
storageDemand.required should approximate(zeroKWH)
storageDemand.possible should approximate(KilowattHours(575d))
updatedThermalGridState.houseState shouldBe None
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800L, KilowattHours(575d), Kilowatts(0d))
ThermalStorageState(10800L, KilowattHours(575d), zeroKW)
)
}
}
Expand All @@ -138,7 +139,7 @@ class ThermalGridWithStorageOnlySpec
ThermalStorageState(
0L,
KilowattHours(200d),
Kilowatts(0d),
zeroKW,
)
)
)
Expand Down Expand Up @@ -193,7 +194,7 @@ class ThermalGridWithStorageOnlySpec
Some(ThermalStorageState(tick, storedEnergy, qDot)),
) =>
tick shouldBe 0L
storedEnergy should approximate(KilowattHours(0d))
storedEnergy should approximate(zeroKWH)
qDot should approximate(testGridQDotInfeed)
case _ => fail("Thermal grid state has been calculated wrong.")
}
Expand Down Expand Up @@ -221,7 +222,7 @@ class ThermalGridWithStorageOnlySpec
Some(ThermalStorageState(tick, storedEnergy, qDot)),
) =>
tick shouldBe 0L
storedEnergy should approximate(KilowattHours(0d))
storedEnergy should approximate(zeroKWH)
qDot should approximate(testGridQDotInfeed)
case _ => fail("Thermal grid state updated failed")
}
Expand All @@ -237,7 +238,7 @@ class ThermalGridWithStorageOnlySpec
ThermalStorageState(
0L,
KilowattHours(200d),
Kilowatts(0d),
zeroKW,
)
)
),
Expand Down Expand Up @@ -269,7 +270,7 @@ class ThermalGridWithStorageOnlySpec
testGridAmbientTemperature,
testGridAmbientTemperature,
isRunning,
Kilowatts(0d),
zeroKW,
noThermalDemand,
)
updatedState match {
Expand All @@ -281,8 +282,8 @@ class ThermalGridWithStorageOnlySpec
None,
) =>
tick shouldBe 0L
storedEnergy should approximate(KilowattHours(0d))
qDot should approximate(Megawatts(0d))
storedEnergy should approximate(zeroKWH)
qDot should approximate(zeroKW)

case _ => fail("Thermal grid state updated failed")
}
Expand Down

0 comments on commit 30e4318

Please sign in to comment.