-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/dev' into df/#856-tap-water
# Conflicts: # CHANGELOG.md
- Loading branch information
Showing
6 changed files
with
133 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 0 additions & 129 deletions
129
src/test/groovy/edu/ie3/simona/model/thermal/ThermalHouseTest.groovy
This file was deleted.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
src/test/scala/edu/ie3/simona/model/thermal/ThermalHouseSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters