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

Rewrote RefSystemTest from groovy to scala. #839

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote PVModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Making configuration of `RefSystem` via config optional [#769](https://github.com/ie3-institute/simona/issues/769)
- Updated PSDM to version 5.1.0 [#835](https://github.com/ie3-institute/simona/issues/835)
- Rewrote RefSystemTest 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
74 changes: 0 additions & 74 deletions src/test/groovy/edu/ie3/simona/model/grid/RefSystemTest.groovy

This file was deleted.

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

package edu.ie3.simona.model.grid

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers
import squants.{Dimensionless, Each}
import squants.electro.{Amperes, ElectricPotential, Kilovolts, Ohms}
import squants.energy.{Megawatts, Power, Kilowatts}

class RefSystemSpec extends AnyFlatSpec with Matchers {

"A RefSystem with nominal power and nominal voltage" should "provide corresponding nominal current and nominal impedance" in {

val nominalPowerAsSquant: Power = Kilowatts(600)
val nominalVoltageAsSquant: ElectricPotential = Kilovolts(10)
danielfeismann marked this conversation as resolved.
Show resolved Hide resolved

val refSystem = RefSystem(nominalPowerAsSquant, nominalVoltageAsSquant)

refSystem.nominalPower should be(nominalPowerAsSquant)
refSystem.nominalVoltage should be(nominalVoltageAsSquant)
refSystem.nominalCurrent should be(
Amperes(34.64101615137754774109785366023500d)
)
refSystem.nominalImpedance should be(
Ohms(166.6666666666666666666666666666666d)
)
}

"A dimensionless impedance" should "be transferred correctly between reference systems" in {
val from = RefSystem(Megawatts(60d), Kilovolts(110d))
val to = RefSystem(Megawatts(40d), Kilovolts(110d))
val impedance = Each(0.1d)
val expected = Each(0.06666666666666667d)

val actual: Dimensionless = RefSystem.transferImpedance(impedance, from, to)

actual should be(expected)
}

"A dimensionless admittance" should "be transferred correctly between reference systems" in {
val from = RefSystem(Megawatts(60d), Kilovolts(110d))
val to = RefSystem(Megawatts(40d), Kilovolts(110d))
val admittance = Each(0.1d)
val expected = Each(0.15000000000000002d)

val actual: Dimensionless =
RefSystem.transferAdmittance(admittance, from, to)

actual should be(expected)
}
}