Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge HpTestData and HpModelTestData #873

Merged
merged 7 commits into from
Aug 12, 2024
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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)
- 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)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import edu.ie3.simona.ontology.messages.services.WeatherMessage.{
WeatherData,
}
import edu.ie3.simona.test.ParticipantAgentSpec
import edu.ie3.simona.test.common.model.participant.HpTestData
import edu.ie3.simona.test.common.DefaultTestData
import edu.ie3.simona.test.common.input.HpInputTestData
import edu.ie3.simona.util.ConfigUtil
import edu.ie3.simona.util.SimonaConstants.INIT_SIM_TICK
import edu.ie3.util.scala.quantities.{
Expand All @@ -61,7 +62,6 @@ import squants.thermal.Celsius
import squants.{Dimensionless, Each}

import java.io.File
import java.time.ZonedDateTime
import java.util.concurrent.TimeUnit
import scala.collection.SortedMap

Expand All @@ -76,10 +76,11 @@ class HpAgentModelCalculationSpec
""".stripMargin),
)
)
with HpTestData
with HpInputTestData
with IntegrationSpecCommon
with PrivateMethodTester {
implicit val simulationStart: ZonedDateTime = defaultSimulationStart
with PrivateMethodTester
with DefaultTestData {

implicit val receiveTimeOut: Timeout = Timeout(10, TimeUnit.SECONDS)
implicit val noReceiveTimeOut: Timeout = Timeout(1, TimeUnit.SECONDS)

Expand Down Expand Up @@ -188,7 +189,7 @@ class HpAgentModelCalculationSpec
ApparentPowerAndHeat,
](
inputModel = hpInput,
thermalGrid = thermalGrid,
thermalGrid = defaultThermalGrid,
modelConfig = modelConfig,
secondaryDataServices = services,
simulationStartDate = defaultSimulationStart,
Expand Down Expand Up @@ -250,7 +251,10 @@ class HpAgentModelCalculationSpec
outputConfig,
_,
) =>
inputModel shouldBe WithHeatInputContainer(hpInput, thermalGrid)
inputModel shouldBe WithHeatInputContainer(
hpInput,
defaultThermalGrid,
)
modelConfig shouldBe modelConfig
secondaryDataServices shouldBe services
defaultSimulationStart shouldBe this.defaultSimulationStart
Expand All @@ -270,7 +274,7 @@ class HpAgentModelCalculationSpec

/* Expect a registration message */
weatherService.expectMsg(
RegisterForWeatherMessage(51.4843281, 7.4116482)
RegisterForWeatherMessage(52.02083574, 7.40110716)
)

/* ... as well as corresponding state and state data */
Expand Down Expand Up @@ -371,7 +375,7 @@ class HpAgentModelCalculationSpec

/* Expect a registration message */
weatherService.expectMsg(
RegisterForWeatherMessage(51.4843281, 7.4116482)
RegisterForWeatherMessage(52.02083574, 7.40110716)
)
weatherService.send(
hpAgent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import edu.ie3.simona.model.thermal.ThermalHouse.ThermalHouseThreshold.{
import edu.ie3.simona.model.thermal.ThermalStorage.ThermalStorageState
import edu.ie3.simona.ontology.messages.flex.MinMaxFlexibilityMessage.ProvideMinMaxFlexOptions
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.TableDrivenPropertyChecks
import squants.energy.{KilowattHours, Kilowatts, Watts}
Expand All @@ -25,7 +26,7 @@ import squants.{Kelvin, Power, Temperature}
class HpModelSpec
extends UnitSpec
with TableDrivenPropertyChecks
with HpModelTestData {
with HpInputTestData {

implicit val tempTolerance: Temperature = Kelvin(1e-3)
implicit val powerTolerance: Power = Watts(1e-3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import java.util.UUID

trait ThermalGridTestData {
protected val thermalBusInput = new ThermalBusInput(
UUID.randomUUID(),
UUID.fromString("48fa6e8d-c07f-45cd-9ad7-094a1f2a7489"),
"Thermal Bus",
OperatorInput.NO_OPERATOR_ASSIGNED,
OperationTime.notLimited(),
)
protected val testGridambientTemperature: Temperature = Celsius(12d)
protected val testGridAmbientTemperature: Temperature = Celsius(12d)
protected val testGridQDotInfeed: Power = Kilowatts(15d)
protected val testGridQDotConsumption: Power = Kilowatts(-42d)
protected val testGridQDotConsumptionHigh: Power = Kilowatts(-200d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ThermalGridWithHouseAndStorageSpec

val gridDemand = thermalGrid.energyDemand(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
ThermalGrid.startingState(thermalGrid),
)

Expand All @@ -114,7 +114,7 @@ class ThermalGridWithHouseAndStorageSpec
val startingState = ThermalGrid.startingState(thermalGrid)
val gridDemand = thermalGrid.energyDemand(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
startingState.copy(houseState =
startingState.houseState.map(
_.copy(innerTemperature = Celsius(16d))
Expand All @@ -132,7 +132,7 @@ class ThermalGridWithHouseAndStorageSpec
val startingState = ThermalGrid.startingState(thermalGrid)
val gridDemand = thermalGrid.energyDemand(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
startingState.copy(houseState =
startingState.houseState.map(
_.copy(innerTemperature = Celsius(3d))
Expand Down Expand Up @@ -164,7 +164,7 @@ class ThermalGridWithHouseAndStorageSpec
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
externalQDot,
)
Expand Down Expand Up @@ -200,7 +200,7 @@ class ThermalGridWithHouseAndStorageSpec
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
externalQDot,
)
Expand Down Expand Up @@ -253,7 +253,7 @@ class ThermalGridWithHouseAndStorageSpec
maybeStorageState,
maybeHouseState.map(_._1),
None,
testGridambientTemperature,
testGridAmbientTemperature,
testGridQDotConsumption,
) match {
case (maybeRevisedHouseState, maybeRevisedStorageState) =>
Expand Down Expand Up @@ -486,7 +486,7 @@ class ThermalGridWithHouseAndStorageSpec
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleInfeed(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
initialGridState,
externalQDot,
)
Expand Down Expand Up @@ -531,7 +531,7 @@ class ThermalGridWithHouseAndStorageSpec
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleInfeed(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
externalQDot,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
val tick = 10800 // after three house
val houseDemand = thermalHouse.energyDemand(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
expectedHouseStartingState,
)

val gridDemand = thermalGrid.energyDemand(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
ThermalGrid.startingState(thermalGrid),
)

Expand All @@ -105,7 +105,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
externalQDot,
)
Expand All @@ -132,7 +132,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
testGridQDotConsumption,
)
Expand Down Expand Up @@ -166,7 +166,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleInfeed(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
testGridQDotInfeed,
)
Expand All @@ -192,7 +192,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
thermalGrid.updateState(
0L,
ThermalGrid.startingState(thermalGrid),
testGridambientTemperature,
testGridAmbientTemperature,
testGridQDotInfeed,
) match {
case (
Expand All @@ -214,7 +214,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
thermalGrid.updateState(
0L,
ThermalGrid.startingState(thermalGrid),
testGridambientTemperature,
testGridAmbientTemperature,
testGridQDotConsumption,
) match {
case (
Expand All @@ -236,7 +236,7 @@ class ThermalGridWithHouseOnlySpec extends UnitSpec with ThermalHouseTestData {
thermalGrid.updateState(
0L,
ThermalGrid.startingState(thermalGrid),
testGridambientTemperature,
testGridAmbientTemperature,
Megawatts(0d),
) match {
case (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ThermalGridWithStorageOnlySpec

val gridDemand = thermalGrid.energyDemand(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
ThermalGrid.startingState(thermalGrid),
)

Expand Down Expand Up @@ -114,7 +114,7 @@ class ThermalGridWithStorageOnlySpec
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleConsumption(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
testGridQDotConsumptionHigh,
)
Expand Down Expand Up @@ -146,7 +146,7 @@ class ThermalGridWithStorageOnlySpec
val (updatedGridState, reachedThreshold) =
thermalGrid invokePrivate handleInfeed(
tick,
testGridambientTemperature,
testGridAmbientTemperature,
gridState,
testGridQDotInfeed,
)
Expand All @@ -170,7 +170,7 @@ class ThermalGridWithStorageOnlySpec
val (updatedState, nextThreshold) = thermalGrid.updateState(
0L,
ThermalGrid.startingState(thermalGrid),
testGridambientTemperature,
testGridAmbientTemperature,
testGridQDotInfeed,
)

Expand Down Expand Up @@ -202,7 +202,7 @@ class ThermalGridWithStorageOnlySpec
)
)
),
testGridambientTemperature,
testGridAmbientTemperature,
testGridQDotConsumptionHigh,
) match {
case (
Expand All @@ -224,7 +224,7 @@ class ThermalGridWithStorageOnlySpec
val updatedState = thermalGrid.updateState(
0L,
ThermalGrid.startingState(thermalGrid),
testGridambientTemperature,
testGridAmbientTemperature,
Kilowatts(0d),
)
updatedState match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import edu.ie3.datamodel.models.{OperationTime, StandardUnits}
import edu.ie3.simona.config.SimonaConfig
import edu.ie3.simona.event.notifier.NotifierConfig
import edu.ie3.simona.model.participant.load.{LoadModelBehaviour, LoadReference}
import edu.ie3.simona.test.common.model.participant.HpTestData
import edu.ie3.simona.util.ConfigUtil
import edu.ie3.util.quantities.PowerSystemUnits._
import squants.energy.Kilowatts
Expand All @@ -40,7 +39,7 @@ trait EmInputTestData
extends NodeInputTestData
with PvInputTestData
with LoadInputTestData
with HpTestData {
with HpInputTestData {

protected val emInput = new EmInput(
UUID.randomUUID(),
Expand Down Expand Up @@ -129,7 +128,7 @@ trait EmInputTestData
"test hp",
OperatorInput.NO_OPERATOR_ASSIGNED,
OperationTime.notLimited(),
nodeInput,
nodeInputNoSlackNs04KvA,
thermalBusInput,
ReactivePowerCharacteristic.parse("cosPhiFixed:{(0.00,0.98)}"),
emInput,
Expand Down
Loading