Skip to content

Commit

Permalink
Merge branch 'df/#1023-zeroKW-and-kWh-in-test' into df/#856-tap-water
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/scala/edu/ie3/simona/model/thermal/CylindricalThermalStorage.scala
#	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 378f2f6 + 507f282 commit 29dedaa
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final case class ChpModel(
chpData: ChpRelevantData
): ChpRelevantData => ChpState = {
val isRunning = chpData.chpState.isRunning
val hasDemand = chpData.heatDemand > DefaultQuantities.zeroKWH
val hasDemand = chpData.heatDemand > DefaultQuantities.zeroKWh
val isCovered = isDemandCovered(chpData)

(isRunning, hasDemand, isCovered) match {
Expand All @@ -145,7 +145,7 @@ final case class ChpModel(
isRunning = false,
chpData.currentTimeTick,
DefaultQuantities.zeroKW,
DefaultQuantities.zeroKWH,
DefaultQuantities.zeroKWh,
)

/** The demand cannot be covered, therefore this function sets storage level
Expand Down Expand Up @@ -182,7 +182,7 @@ final case class ChpModel(
isRunning = false,
chpData.currentTimeTick,
DefaultQuantities.zeroKW,
DefaultQuantities.zeroKWH,
DefaultQuantities.zeroKWh,
)
}

Expand All @@ -199,7 +199,7 @@ final case class ChpModel(
chpData: ChpRelevantData
): ChpState = {
val differenceEnergy = chpEnergy(chpData) - chpData.heatDemand
if (differenceEnergy < zeroKWH) {
if (differenceEnergy < zeroKWh) {
// Returned lack is always zero, because demand is covered.
storage.tryToTakeAndReturnLack(differenceEnergy * -1)
calculateStateRunningSurplus(chpData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ final case class HpModel(
val noThermalStorageOrThermalStorageIsEmpty: Boolean =
updatedGridState.storageState.isEmpty || updatedGridState.storageState
.exists(
_.storedEnergy =~ zeroKWH
_.storedEnergy =~ zeroKWh
)

val houseDemand =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final case class StorageModel(
cosPhiRated,
) {

private val minEnergy = zeroKWH
private val minEnergy = zeroKWh

/** Tolerance for power comparisons. With very small (dis-)charging powers,
* problems can occur when calculating the future tick at which storage is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ final case class EvcsModel(
tickStop > lastSchedulingTick && tickStart < currentTick
}
.sortBy(_.tickStart)
.foldLeft(zeroKWH) { case (accumulatedEnergy, scheduleEntry) =>
.foldLeft(zeroKWh) { case (accumulatedEnergy, scheduleEntry) =>
/* Only the timeframe from the start of last scheduling update and current tick must be considered */
val trimmedEntry = trimScheduleEntry(
scheduleEntry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ final case class CylindricalThermalStorage(
override def tryToStoreAndReturnRemainder(
addedEnergy: Energy
): Option[Energy] = {
if (addedEnergy > zeroKWH) {
if (addedEnergy > zeroKWh) {
_storedEnergy = _storedEnergy + addedEnergy
if (_storedEnergy > maxEnergyThreshold) {
val surplus = _storedEnergy - maxEnergyThreshold
Expand All @@ -153,7 +153,7 @@ final case class CylindricalThermalStorage(
override def tryToTakeAndReturnLack(
takenEnergy: Energy
): Option[Energy] = {
if (takenEnergy > zeroKWH) {
if (takenEnergy > zeroKWh) {
_storedEnergy = _storedEnergy - takenEnergy
if (_storedEnergy < zeroKWH) {
val lack = zeroKWH - _storedEnergy
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/edu/ie3/simona/model/thermal/ThermalGrid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final case class ThermalGrid(
storage.getMaxEnergyThreshold - storedEnergy

} else {
zeroMWH
zeroMWh
}
}

Expand All @@ -156,7 +156,7 @@ final case class ThermalGrid(

}
.getOrElse(
ThermalEnergyDemand(zeroMWH, zeroMWH),
ThermalEnergyDemand(zeroMWh, zeroMWh),
None,
)
}
Expand Down Expand Up @@ -1534,7 +1534,7 @@ object ThermalGrid {
possible + rhs.possible,
)

def hasRequiredDemand: Boolean = required > zeroMWH
def hasRequiredDemand: Boolean = required > zeroMWh

def hasAdditionalDemand: Boolean = possible > zeroMWH
}
Expand Down Expand Up @@ -1564,8 +1564,8 @@ object ThermalGrid {
}

def noDemand: ThermalEnergyDemand = ThermalEnergyDemand(
zeroMWH,
zeroMWH,
zeroMWh,
zeroMWh,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ final case class ThermalHouse(
)
) energy(targetTemperature, currentInnerTemp)
else
zeroMWH
zeroMWh

val possibleEnergy =
if (!isInnerTemperatureTooHigh(currentInnerTemp)) {
// if upper boundary has not been reached,
// there is an amount of optional energy that could be stored
energy(upperBoundaryTemperature, currentInnerTemp)
} else
zeroMWH
zeroMWh
ThermalEnergyDemand(requiredEnergy, possibleEnergy)
}

Expand Down Expand Up @@ -533,7 +533,7 @@ final case class ThermalHouse(
qDot: Power,
): Option[Long] = {
val flexibleEnergy = energy(higherTemperature, lowerTemperature)
if (flexibleEnergy < zeroMWH)
if (flexibleEnergy < zeroMWh)
None
else {
val duration = Math.round(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ object DefaultQuantities {
val zeroKVAr: ReactivePower = Kilovars(0d)
val zeroMVAr: ReactivePower = Megavars(0d)

val zeroKWH: Energy = KilowattHours(0d)
val zeroMWH: Energy = MegawattHours(0d)
val zeroKWh: Energy = KilowattHours(0d)
val zeroMWh: Energy = MegawattHours(0d)

val zeroPU: Dimensionless = Each(0d)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{
HouseTemperatureLowerBoundaryReached,
HouseTemperatureUpperBoundaryReached,
}
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
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 @@ -140,7 +140,7 @@ class ThermalGridWithHouseAndStorageSpec
defaultSimulationStart,
houseInhabitants,
)
houseDemand.required should approximate(zeroKWH)
houseDemand.required should approximate(zeroKWh)
houseDemand.possible should approximate(KilowattHours(31.05009722d))
storageDemand.required should approximate(KilowattHours(1150d))
storageDemand.possible should approximate(KilowattHours(1150d))
Expand All @@ -150,7 +150,7 @@ class ThermalGridWithHouseAndStorageSpec
ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW)
)
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, zeroKWH, zeroKW)
ThermalStorageState(10800, zeroKWh, zeroKW)
)
updatedThermalGridState.domesticHotWaterStorageState shouldBe Some(
ThermalStorageState(
Expand Down Expand Up @@ -235,7 +235,7 @@ class ThermalGridWithHouseAndStorageSpec
ThermalHouseState(10800, Celsius(15.959996296296296), zeroKW)
)
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, zeroKWH, zeroKW)
ThermalStorageState(10800, zeroKWh, zeroKW)
)
updatedThermalGridState.domesticHotWaterStorageState shouldBe Some(
ThermalStorageState(
Expand Down Expand Up @@ -566,7 +566,7 @@ class ThermalGridWithHouseAndStorageSpec
(
ThermalStorageState(
tick,
zeroKWH,
zeroKWh,
testGridQDotInfeed,
),
Some(StorageEmpty(tick)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{
StorageEmpty,
StorageFull,
}
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWh}
import edu.ie3.simona.test.common.UnitSpec
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
import squants.energy._
Expand Down Expand Up @@ -135,10 +135,10 @@ class ThermalGridWithHouseOnlySpec

houseDemand.required should approximate(expectedHouseDemand.required)
houseDemand.possible should approximate(expectedHouseDemand.possible)
storageDemand.required should approximate(zeroKWH)
storageDemand.possible should approximate(zeroKWH)
domesticHotWaterDemand.required should approximate(KilowattHours(0d))
domesticHotWaterDemand.possible should approximate(KilowattHours(0d))
storageDemand.required should approximate(zeroKWh)
storageDemand.possible should approximate(zeroKWh)
domesticHotWaterDemand.required should approximate(zeroKWh)
domesticHotWaterDemand.possible should approximate(zeroKWh)
updatedThermalGridState.houseState shouldBe Some(
ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageThreshold.{
StorageFull,
}
import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec}
import edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWH}
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 @@ -105,15 +105,15 @@ class ThermalGridWithStorageOnlySpec
houseInhabitants,
)

houseDemand.required should approximate(zeroKWH)
houseDemand.possible should approximate(zeroKWH)
houseDemand.required should approximate(zeroKWh)
houseDemand.possible should approximate(zeroKWh)
storageDemand.required should approximate(KilowattHours(1150d))
storageDemand.possible should approximate(KilowattHours(1150d))
waterStorageDemand.required should approximate(zeroKWH)
waterStorageDemand.possible should approximate(zeroKWH)
updatedThermalGridState.houseState shouldBe None
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, zeroKWH, zeroKW)
ThermalStorageState(10800, zeroKWh, zeroKW)
)
updatedThermalGridState.domesticHotWaterStorageState shouldBe None
}
Expand All @@ -140,9 +140,9 @@ class ThermalGridWithStorageOnlySpec
houseInhabitants,
)

houseDemand.required should approximate(zeroKWH)
houseDemand.possible should approximate(zeroKWH)
storageDemand.required should approximate(zeroKWH)
houseDemand.required should approximate(zeroKWh)
houseDemand.possible should approximate(zeroKWh)
storageDemand.required should approximate(zeroKWh)
storageDemand.possible should approximate(KilowattHours(575d))
waterStorageDemand.required should approximate(zeroKWH)
waterStorageDemand.possible should approximate(zeroKWH)
Expand Down Expand Up @@ -232,7 +232,7 @@ class ThermalGridWithStorageOnlySpec
None,
) =>
tick shouldBe 0L
storedEnergy should approximate(zeroKWH)
storedEnergy should approximate(zeroKWh)
qDot should approximate(testGridQDotInfeed)
case _ => fail("Thermal grid state has been calculated wrong.")
}
Expand Down Expand Up @@ -265,7 +265,7 @@ class ThermalGridWithStorageOnlySpec
None,
) =>
tick shouldBe 0L
storedEnergy should approximate(zeroKWH)
storedEnergy should approximate(zeroKWh)
qDot should approximate(testGridQDotInfeed)
case _ => fail("Thermal grid state updated failed")
}
Expand Down Expand Up @@ -335,7 +335,7 @@ class ThermalGridWithStorageOnlySpec
None,
) =>
tick shouldBe 0L
storedEnergy should approximate(zeroKWH)
storedEnergy should approximate(zeroKWh)
qDot should approximate(zeroKW)

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

0 comments on commit 29dedaa

Please sign in to comment.