Skip to content

Commit

Permalink
Merge branch 'dev' into df/#930-refactor-handleInfeed
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfeismann committed Nov 15, 2024
2 parents 9fb1523 + 9d780a7 commit 94397ee
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 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 @@ -243,7 +243,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 @@ -143,7 +143,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 @@ -158,7 +158,7 @@ final case class CylindricalThermalStorage(
override def tryToTakeAndReturnLack(
takenEnergy: Energy
): Option[Energy] = {
if (takenEnergy > zeroKWH) {
if (takenEnergy > zeroKWh) {
_storedEnergy = _storedEnergy - takenEnergy
if (_storedEnergy < minEnergyThreshold) {
val lack = minEnergyThreshold - _storedEnergy
Expand All @@ -185,7 +185,7 @@ object CylindricalThermalStorage {
*/
def apply(
input: CylindricalStorageInput,
initialStoredEnergy: Energy = DefaultQuantities.zeroKWH,
initialStoredEnergy: Energy = DefaultQuantities.zeroKWh,
): CylindricalThermalStorage = {
val minEnergyThreshold: Energy =
CylindricalThermalStorage.volumeToEnergy(
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 @@ -114,7 +114,7 @@ final case class ThermalGrid(
storage.getMaxEnergyThreshold - storedEnergy

} else {
zeroMWH
zeroMWh
}
}

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

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

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

def hasAdditionalDemand: Boolean = possible > required
}
Expand All @@ -797,8 +797,8 @@ object ThermalGrid {
}

def noDemand: ThermalEnergyDemand = ThermalEnergyDemand(
zeroMWH,
zeroMWH,
zeroMWh,
zeroMWh,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,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 @@ -323,7 +323,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 @@ -13,7 +13,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 @@ -104,15 +104,15 @@ class ThermalGridWithHouseAndStorageSpec
testGridAmbientTemperature,
ThermalGrid.startingState(thermalGrid),
)
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))
updatedThermalGridState.houseState shouldBe Some(
ThermalHouseState(10800, Kelvin(292.0799935185185), zeroKW)
)
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, zeroKWH, zeroKW)
ThermalStorageState(10800, zeroKWh, zeroKW)
)
}

Expand Down Expand Up @@ -140,7 +140,7 @@ class ThermalGridWithHouseAndStorageSpec
ThermalHouseState(10800, Celsius(15.959996296296296), zeroKW)
)
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, zeroKWH, zeroKW)
ThermalStorageState(10800, zeroKWh, zeroKW)
)
}
}
Expand Down Expand Up @@ -372,7 +372,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 @@ -13,7 +13,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.test.common.UnitSpec
import squants.energy._
import squants.thermal.Celsius
Expand Down Expand Up @@ -91,8 +91,8 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {

houseDemand.required should approximate(expectedHouseDemand.required)
houseDemand.possible should approximate(expectedHouseDemand.possible)
storageDemand.required should approximate(zeroKWH)
storageDemand.possible should approximate(zeroKWH)
storageDemand.required should approximate(zeroKWh)
storageDemand.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 @@ -17,7 +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 edu.ie3.util.scala.quantities.DefaultQuantities.{zeroKW, zeroKWh}
import squants.energy._
import squants.thermal.Celsius
import squants.{Energy, Power, Temperature}
Expand Down Expand Up @@ -89,13 +89,13 @@ class ThermalGridWithStorageOnlySpec
ThermalGrid.startingState(thermalGrid),
)

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))
updatedThermalGridState.houseState shouldBe None
updatedThermalGridState.storageState shouldBe Some(
ThermalStorageState(10800, zeroKWH, zeroKW)
ThermalStorageState(10800, zeroKWh, zeroKW)
)
}

Expand All @@ -113,9 +113,9 @@ class ThermalGridWithStorageOnlySpec
),
)

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))
updatedThermalGridState.houseState shouldBe None
updatedThermalGridState.storageState shouldBe Some(
Expand Down Expand Up @@ -194,7 +194,7 @@ class ThermalGridWithStorageOnlySpec
Some(ThermalStorageState(tick, storedEnergy, qDot)),
) =>
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 @@ -222,7 +222,7 @@ class ThermalGridWithStorageOnlySpec
Some(ThermalStorageState(tick, storedEnergy, qDot)),
) =>
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 @@ -282,7 +282,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 94397ee

Please sign in to comment.