diff --git a/CHANGELOG.md b/CHANGELOG.md index ad7101b5ba..ce6e71377f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated PSDM to version 5.1.0 [#835](https://github.com/ie3-institute/simona/issues/835) - Refactor `WeatherSource` and `WeatherSourceWrapper` [#180](https://github.com/ie3-institute/simona/issues/180) - Remove unnecessary dependency `pekko-connectors-csv` [#857](https://github.com/ie3-institute/simona/issues/857) +- 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) diff --git a/src/test/groovy/edu/ie3/simona/model/grid/RefSystemTest.groovy b/src/test/groovy/edu/ie3/simona/model/grid/RefSystemTest.groovy deleted file mode 100644 index 9ca17976a5..0000000000 --- a/src/test/groovy/edu/ie3/simona/model/grid/RefSystemTest.groovy +++ /dev/null @@ -1,74 +0,0 @@ -/* - * © 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 edu.ie3.util.scala.quantities.Sq -import spock.lang.Specification -import squants.Dimensionless -import squants.Each$ -import squants.electro.Amperes$ -import squants.electro.ElectricPotential -import squants.electro.Kilovolts$ -import squants.electro.Ohms$ -import squants.electro.Volts$ -import squants.energy.Megawatts$ -import squants.energy.Watts$ -import squants.energy.Power - - -class RefSystemTest extends Specification { - - def "A RefSystem with nominal power and nominal voltage should provide corresponding nominal current and nominal impedance "() { - - given: "the nominal power and the nominal voltage" - - double nominalPower = 600000 // in voltampere - double nominalVoltage = 10000 // in volt - - Power nominalPowerAsSquant = Sq.create(nominalPower, Watts$.MODULE$) - ElectricPotential nominalVoltageAsSquant = Sq.create(nominalVoltage, Volts$.MODULE$) - - when: - RefSystem refSystem = RefSystem.apply(nominalPowerAsSquant, nominalVoltageAsSquant) - - then: "the nominal current and the nominal power should be calculated accordingly" - refSystem.nominalPower() == Sq.create(600000d, Watts$.MODULE$) - refSystem.nominalVoltage() == Sq.create(10000d, Volts$.MODULE$) - refSystem.nominalCurrent() =~ Sq.create(34.64101615137754774109785366023500d, Amperes$.MODULE$) - refSystem.nominalImpedance() =~ Sq.create (166.6666666666666666666666666666666d, Ohms$.MODULE$) - } - - def "A dimensionless impedance is transferred correctly between reference systems"() { - given: - RefSystem from = RefSystem.apply(Sq.create(60d, Megawatts$.MODULE$), Sq.create(110d, Kilovolts$.MODULE$)) - RefSystem to = RefSystem.apply(Sq.create(40d, Megawatts$.MODULE$), Sq.create(110d, Kilovolts$.MODULE$)) - Dimensionless impedance = Sq.create(0.1d, Each$.MODULE$) - Dimensionless expected = Sq.create(0.06666666666666667d, Each$.MODULE$) - - when: - Dimensionless actual = RefSystem.transferImpedance(impedance, from, to) - - then: - actual =~ expected - } - - def "A dimensionless admittance is transferred correctly between reference systems"() { - given: - RefSystem from = RefSystem.apply(Sq.create(60d, Megawatts$.MODULE$), Sq.create(110d, Kilovolts$.MODULE$)) - RefSystem to = RefSystem.apply(Sq.create(40d, Megawatts$.MODULE$), Sq.create(110d, Kilovolts$.MODULE$)) - Dimensionless admittance = Sq.create(0.1d, Each$.MODULE$) - Dimensionless expected = Sq.create(0.15000000000000002d, Each$.MODULE$) - - when: - Dimensionless actual = RefSystem.transferAdmittance(admittance, from, to) - - then: - - actual =~ expected - } -} diff --git a/src/test/scala/edu/ie3/simona/model/grid/RefSystemSpec.scala b/src/test/scala/edu/ie3/simona/model/grid/RefSystemSpec.scala new file mode 100644 index 0000000000..38aed79d1d --- /dev/null +++ b/src/test/scala/edu/ie3/simona/model/grid/RefSystemSpec.scala @@ -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 nominalPower: Power = Kilowatts(600) + val nominalVoltage: ElectricPotential = Kilovolts(10) + + val refSystem = RefSystem(nominalPower, nominalVoltage) + + refSystem.nominalPower should be(nominalPower) + refSystem.nominalVoltage should be(nominalVoltage) + 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) + } +}