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
  • Loading branch information
danielfeismann committed Jul 29, 2024
2 parents c1f6e2e + 40ff38e commit 308255c
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 138 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote RefSystemTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Rewrote FixedFeedModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Rewrote WecModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Rewrote FixedLoadModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)

### 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 @@ -72,7 +72,7 @@ final case class FixedLoadModel(
* @return
* Active power
*/
override protected def calculateActivePower(
override def calculateActivePower(
modelState: ConstantState.type,
data: FixedLoadRelevantData.type = FixedLoadRelevantData,
): Power = activePower
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* © 2024. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/

package edu.ie3.simona.model.participant.load

import edu.ie3.simona.model.SystemComponent
import edu.ie3.simona.model.participant.ModelState
import edu.ie3.simona.model.participant.control.QControl
import edu.ie3.simona.model.participant.load.LoadReference.{
ActivePower,
EnergyConsumption,
}
import edu.ie3.simona.test.common.input.LoadInputTestData
import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec}
import edu.ie3.util.quantities.PowerSystemUnits
import org.scalatest.prop.TableDrivenPropertyChecks
import squants.Power
import squants.energy.{KilowattHours, Kilowatts, Watts}

class FixedLoadModelSpec
extends UnitSpec
with LoadInputTestData
with DefaultTestData
with TableDrivenPropertyChecks {

private implicit val tolerance: Power = Watts(1d)

"A fixed load model" should {

val defaultOperationInterval =
SystemComponent.determineOperationInterval(
defaultSimulationStart,
defaultSimulationEnd,
loadInput.getOperationTime,
)

"be instantiated from valid input correctly" in {
val testData = Table(
("reference", "expectedReferenceActivePower"),
(ActivePower(Watts(268.6)), Watts(268.6)),
(EnergyConsumption(KilowattHours(3000d)), Watts(342.24)),
)

forAll(testData) { (reference, expectedReferenceActivePower: Power) =>
val actual = new FixedLoadModel(
loadInput.getUuid,
loadInput.getId,
defaultOperationInterval,
QControl.apply(loadInput.getqCharacteristics),
Kilowatts(
loadInput.getsRated
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue()
),
loadInput.getCosPhiRated,
reference,
)

val calculatedPower = actual
.calculateActivePower(
ModelState.ConstantState,
FixedLoadModel.FixedLoadRelevantData,
)

calculatedPower should approximate(expectedReferenceActivePower)
}
}

"return approximately the same power in 10,000 calculations" in {

val testData = Table(
("reference", "expectedPower"),
(ActivePower(Watts(268.6)), Watts(268.6)),
(EnergyConsumption(KilowattHours(3000d)), Watts(342.24)),
)

forAll(testData) { (reference, expectedPower: Power) =>
val dut = new FixedLoadModel(
loadInput.getUuid,
loadInput.getId,
defaultOperationInterval,
QControl.apply(loadInput.getqCharacteristics),
Kilowatts(
loadInput.getsRated
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue()
),
loadInput.getCosPhiRated,
reference,
)

for (_ <- 0 until 10000) {
val calculatedPower = dut
.calculateActivePower(
ModelState.ConstantState,
FixedLoadModel.FixedLoadRelevantData,
)

calculatedPower should approximate(expectedPower)
}
}
}

"consider the (global) scaling factor correctly" in {
val testData = Table(
("reference", "expectedPower"),
(ActivePower(Watts(268.6d)), Watts(268.6)),
(EnergyConsumption(KilowattHours(3000d)), Watts(342.24)),
)

forAll(testData) { (reference, expectedPower: Power) =>
val relevantData = FixedLoadModel.FixedLoadRelevantData

var scale = 0.0
while (scale <= 2) {
val scaledSRated = Kilowatts(
loadInput.getsRated
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue() * scale
)
val dut = new FixedLoadModel(
loadInput.getUuid,
loadInput.getId,
defaultOperationInterval,
QControl.apply(loadInput.getqCharacteristics),
scaledSRated,
loadInput.getCosPhiRated,
reference,
)

val calculatedPower = dut
.calculateActivePower(
ModelState.ConstantState,
relevantData,
) * scale
val expectedScaledPower = expectedPower * scale

calculatedPower should approximate(expectedScaledPower)

scale += 0.1
}
}
}
}
}

0 comments on commit 308255c

Please sign in to comment.