Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into df/#856-tap-water
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
danielfeismann committed Aug 12, 2024
2 parents 3615ec4 + 24100a7 commit 93ae513
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ updates:
target-branch: dev
reviewers:
- t-ober
- sensarmad
- sebastian-peter
- danielfeismann
- jo-bao
ignore:
- dependency-name: org.scalatest:scalatest_2.13
versions:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote SystemComponentTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Converting remaining rst files to markdown [#838](https://github.com/ie3-institute/simona/issues/838)
- Merging both `FixedFeedInModelSpec` tests [#870](https://github.com/ie3-institute/simona/issues/870)
- Rewrote ThermalHouseTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Updated dependabot reviewers [#888](https://github.com/ie3-institute/simona/issues/888)
- Merged `HpModelTestData` with `HpTestData` to `HpInputTestData` [#872](https://github.com/ie3-institute/simona/issues/872)
- Prepare ThermalStorageTestData for Storage without storageVolumeLvlMin [#894](https://github.com/ie3-institute/simona/issues/894)

Expand Down
12 changes: 6 additions & 6 deletions src/main/scala/edu/ie3/simona/model/thermal/ThermalHouse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ final case class ThermalHouse(
* @return
* new inner temperature
*/
private def newInnerTemperature(
def newInnerTemperature(
thermalPower: Power,
duration: Time,
currentInnerTemperature: Temperature,
Expand Down Expand Up @@ -394,7 +394,7 @@ final case class ThermalHouse(
* @return
* new inner temperature
*/
private def calcNewInnerTemperature(
def calcNewInnerTemperature(
oldInnerTemperature: Temperature,
temperatureChange: Temperature,
): Temperature =
Expand All @@ -408,7 +408,7 @@ final case class ThermalHouse(
* @return
* temperature change
*/
private def calcInnerTemperatureChange(
def calcInnerTemperatureChange(
thermalEnergyChange: Energy
): Temperature = {
thermalEnergyChange / ethCapa
Expand All @@ -423,7 +423,7 @@ final case class ThermalHouse(
* @return
* thermal energy change
*/
private def calcThermalEnergyChange(
def calcThermalEnergyChange(
thermalEnergyGain: Energy,
thermalEnergyLoss: Energy,
): Energy =
Expand All @@ -438,7 +438,7 @@ final case class ThermalHouse(
* @return
* resulting thermal energy gain
*/
private def calcThermalEnergyGain(
def calcThermalEnergyGain(
pThermal: Power,
time: Time,
): Energy = pThermal * time
Expand All @@ -455,7 +455,7 @@ final case class ThermalHouse(
* @return
* resulting thermal energy loss
*/
private def calcThermalEnergyLoss(
def calcThermalEnergyLoss(
innerTemperature: Temperature,
ambientTemperature: Temperature,
time: Time,
Expand Down
129 changes: 0 additions & 129 deletions src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy

This file was deleted.

123 changes: 123 additions & 0 deletions src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/

package edu.ie3.simona.model.thermal

import edu.ie3.simona.test.common.UnitSpec
import edu.ie3.simona.test.common.input.HpInputTestData
import edu.ie3.util.scala.quantities.WattsPerKelvin
import org.scalatest.prop.TableFor3
import squants.energy._
import squants.thermal._
import squants.time._
import squants.{Energy, Temperature}

class ThermalHouseSpec extends UnitSpec with HpInputTestData {

implicit val tolerance: Temperature = Celsius(1e-4)
implicit val energyTolerance: Energy = KilowattHours(1e-4)

"ThermalHouse" should {
"Functions testing inner temperature work as expected" in {

val thermalHouseTest = thermalHouse(18, 22)

val testCases: TableFor3[Double, Boolean, Boolean] = Table(
("Inner Temperature (C)", "Is Too High", "Is Too Low"),
(17d, false, true),
(17.98d, false, true),
(18d, false, true),
(20d, false, false),
(22d, true, false),
(22.02d, true, false),
(23d, true, false),
)

testCases.foreach { case (innerTemperature, isTooHigh, isTooLow) =>
val innerTemp = Temperature(innerTemperature, Celsius)
val isHigher = thermalHouseTest.isInnerTemperatureTooHigh(innerTemp)
val isLower = thermalHouseTest.isInnerTemperatureTooLow(innerTemp)

isHigher shouldBe isTooHigh
isLower shouldBe isTooLow
}
}

"Calculation of thermal energy change and new inner temperature is performed correctly" in {
val thermalHouseTest = thermalHouse(18, 22)
val innerTemperature = Temperature(20, Celsius)

val thermalEnergyGain =
thermalHouseTest.calcThermalEnergyGain(Kilowatts(100), Seconds(3600))
val thermalEnergyLoss = thermalHouseTest.calcThermalEnergyLoss(
innerTemperature,
Temperature(10, Celsius),
Seconds(3600),
)
val thermalEnergyChange = thermalHouseTest.calcThermalEnergyChange(
thermalEnergyGain,
thermalEnergyLoss,
)
val innerTemperatureChange =
thermalHouseTest.calcInnerTemperatureChange(thermalEnergyChange)
val newInnerTemperature = thermalHouseTest.calcNewInnerTemperature(
innerTemperature,
innerTemperatureChange,
)

thermalEnergyGain should approximate(KilowattHours(100))
thermalEnergyLoss should approximate(KilowattHours(10))
thermalEnergyChange should approximate(KilowattHours(90))
innerTemperatureChange should approximate(Kelvin(9.0))
newInnerTemperature should approximate(Celsius(29.0))
}

"Comprising function to calculate new inner temperature works as expected" in {
val thermalHouseTest = thermalHouse(18, 22)
val thermalPower = Kilowatts(100)
val duration = Seconds(3600)
val currentInnerTemperature = Temperature(20, Celsius)
val ambientTemperature = Temperature(10, Celsius)

val newInnerTemperature = thermalHouseTest.newInnerTemperature(
thermalPower,
duration,
currentInnerTemperature,
ambientTemperature,
)

newInnerTemperature should approximate(Temperature(29, Celsius))
}

"Check build method" in {

val thermalTestHouse = thermalHouse(18, 22)
val thermalHouseInput = defaultThermalHouse

thermalTestHouse.id shouldBe thermalHouseInput.getId
thermalTestHouse.operatorInput shouldBe thermalHouseInput.getOperator
thermalTestHouse.operationTime shouldBe thermalHouseInput.getOperationTime
thermalTestHouse.bus shouldBe null
thermalTestHouse.ethLosses shouldBe WattsPerKelvin(1000.0)
(thermalTestHouse.ethCapa * Temperature(
1,
Kelvin,
)) shouldBe KilowattHours(10.0)
thermalTestHouse.lowerBoundaryTemperature should approximate(
Temperature(
18,
Celsius,
)
)
thermalTestHouse.upperBoundaryTemperature should approximate(
Temperature(
22,
Celsius,
)
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ trait HpInputTestData extends NodeInputTestData with ThermalGridTestData {
)
protected val defaultThermalHouse = new ThermalHouseInput(
UUID.fromString("91940626-bdd0-41cf-96dd-47c94c86b20e"),
"thermal house",
"Thermal house",
thermalBusInput,
Quantities.getQuantity(0.325, StandardUnits.THERMAL_TRANSMISSION),
Quantities.getQuantity(75, StandardUnits.HEAT_CAPACITY),
Expand Down

0 comments on commit 93ae513

Please sign in to comment.