From d083b2c7d95580be50c1e295826c459e0b957ad6 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 18 Mar 2024 15:55:39 +0100 Subject: [PATCH 01/31] First Structure for WecModelSpec.scala --- .../simona/model/participant/WecModel.scala | 2 +- .../model/participant/WecModelSpec.scala | 95 +++++++++++++++++++ 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index 9b02f1dd05..d5000940b6 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -89,7 +89,7 @@ final case class WecModel( * @return * active power output */ - override protected def calculateActivePower( + override def calculateActivePower( modelState: ConstantState.type, wecData: WecRelevantData, ): Power = { diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala new file mode 100644 index 0000000000..bdfd12e2bf --- /dev/null +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -0,0 +1,95 @@ +/* + * © 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 + +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static edu.ie3.datamodel.models.StandardUnits.* +import static edu.ie3.simona.model.participant.WecModel.WecRelevantData +import static tech.units.indriya.quantity.Quantities.getQuantity + +import edu.ie3.datamodel.models.OperationTime +import edu.ie3.datamodel.models.input.NodeInput +import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.system.WecInput +import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed +import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput +import edu.ie3.datamodel.models.input.system.type.WecTypeInput +import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils +import edu.ie3.util.TimeUtil +import edu.ie3.util.scala.quantities.Sq +import scala.Option +import scala.Some +import spock.lang.Shared +import spock.lang.Specification +import spock.lang.Unroll +import squants.Each$ +import squants.motion.MetersPerSecond$ +import squants.motion.Pascals$ + +import squants.energy.Kilowatts$ +import squants.space.SquareMeters$ +import squants.thermal.Celsius$ + +class WecModelSpec extends UnitSpec with DefaultTestData { + +val TOLERANCE: Double = 1e-5 + + def setupSpec(): Unit = { + val nodeInput = new NodeInput( + UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), + "NodeInput", + OperatorInput.NO_OPERATOR_ASSIGNED, + OperationTime.notLimited(), + Sq(1d), + false, + NodeInput.DEFAULT_GEO_POSITION, + GermanVoltageLevelUtils.LV, + -1 + ) + + val typeInput = new WecTypeInput( + UUID.randomUUID(), + "WecTypeInput", + Sq(1000, Kilowatts), + Sq(1000, Kilowatts), + Sq(1200, Kilowatts), + 0.95, + "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + + "(5.0,0.430345211), (6.0,0.45944023), (7.0,0.479507331), (8.0,0.492113623), " + + "(9.0,0.500417188), (10.0,0.488466547), (11.0,0.420415054), (12.0,0.354241299), " + + "(13.0,0.288470591), (14.0,0.230965702), (15.0,0.18778367), (16.0,0.154728976), " + + "(17.0,0.128998552), (18.0,0.108671106), (19.0,0.09239975), (20.0,0.079221236), " + + "(21.0,0.068434282), (22.0,0.059520087), (23.0,0.052089249), (24.0,0.045845623), " + + "(25.0,0.040561273), (26.0,0.036058824), (27.0,0.032198846), (28.0,0.016618264), " + + "(29.0,0.010330976), (30.0,0.006091519), (31.0,0.003331177), (32.0,0.001641637), " + + "(33.0,0.000705423), (34.0,0.000196644), (35.0,0.0), (36.0,0.0), (37.0,0.0), (38.0,0.0), " + + "(39.0,0.0), (40.0,0.0), (41.0,0.0), (42.0,0.0), (43.0,0.0), (44.0,0.0), (45.0,0.0), " + + "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" + ) + + val inputModel = new WecInput( + UUID.randomUUID(), + "WecInput", + new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), + OperationTime.notLimited(), + nodeInput, + CosPhiFixed.CONSTANT_CHARACTERISTIC, + null, + typeInput, + false + ) + } + + def buildWecModel(): WecModel = { + WecModel.apply(inputModel, 1, + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z")) + } + + + +} From 487140f43e041b4d3f673a1162ab116b4d15e482 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Fri, 31 May 2024 10:20:44 +0200 Subject: [PATCH 02/31] fixing some import and other issues --- .../model/participant/WecModelSpec.scala | 95 +++++++++---------- 1 file changed, 43 insertions(+), 52 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index bdfd12e2bf..80772a6518 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -6,37 +6,26 @@ package edu.ie3.simona.model.participant -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static edu.ie3.datamodel.models.StandardUnits.* -import static edu.ie3.simona.model.participant.WecModel.WecRelevantData -import static tech.units.indriya.quantity.Quantities.getQuantity - import edu.ie3.datamodel.models.OperationTime -import edu.ie3.datamodel.models.input.NodeInput -import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.WecInput -import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed -import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput -import edu.ie3.datamodel.models.input.system.type.WecTypeInput +import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput +import edu.ie3.datamodel.models.input.system.characteristic.{ + ReactivePowerCharacteristic, + WecCharacteristicInput, +} +import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils +import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil -import edu.ie3.util.scala.quantities.Sq -import scala.Option -import scala.Some -import spock.lang.Shared -import spock.lang.Specification -import spock.lang.Unroll -import squants.Each$ -import squants.motion.MetersPerSecond$ -import squants.motion.Pascals$ +import edu.ie3.util.quantities.PowerSystemUnits +import tech.units.indriya.quantity.Quantities +import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} -import squants.energy.Kilowatts$ -import squants.space.SquareMeters$ -import squants.thermal.Celsius$ +import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { -val TOLERANCE: Double = 1e-5 + val TOLERANCE: Double = 1e-5 def setupSpec(): Unit = { val nodeInput = new NodeInput( @@ -44,52 +33,54 @@ val TOLERANCE: Double = 1e-5 "NodeInput", OperatorInput.NO_OPERATOR_ASSIGNED, OperationTime.notLimited(), - Sq(1d), + Quantities.getQuantity(1, PowerSystemUnits.PU), false, NodeInput.DEFAULT_GEO_POSITION, GermanVoltageLevelUtils.LV, - -1 + -1, ) val typeInput = new WecTypeInput( UUID.randomUUID(), "WecTypeInput", - Sq(1000, Kilowatts), - Sq(1000, Kilowatts), - Sq(1200, Kilowatts), + Quantities.getQuantity(1000, PowerSystemUnits.EURO), + Quantities.getQuantity(1000, PowerSystemUnits.EURO_PER_MEGAWATTHOUR), + Quantities.getQuantity(1200, PowerSystemUnits.KILOWATT), 0.95, - "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + - "(5.0,0.430345211), (6.0,0.45944023), (7.0,0.479507331), (8.0,0.492113623), " + - "(9.0,0.500417188), (10.0,0.488466547), (11.0,0.420415054), (12.0,0.354241299), " + - "(13.0,0.288470591), (14.0,0.230965702), (15.0,0.18778367), (16.0,0.154728976), " + - "(17.0,0.128998552), (18.0,0.108671106), (19.0,0.09239975), (20.0,0.079221236), " + - "(21.0,0.068434282), (22.0,0.059520087), (23.0,0.052089249), (24.0,0.045845623), " + - "(25.0,0.040561273), (26.0,0.036058824), (27.0,0.032198846), (28.0,0.016618264), " + - "(29.0,0.010330976), (30.0,0.006091519), (31.0,0.003331177), (32.0,0.001641637), " + - "(33.0,0.000705423), (34.0,0.000196644), (35.0,0.0), (36.0,0.0), (37.0,0.0), (38.0,0.0), " + - "(39.0,0.0), (40.0,0.0), (41.0,0.0), (42.0,0.0), (43.0,0.0), (44.0,0.0), (45.0,0.0), " + - "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" + // Using the characteristics of the Enercon E-82 wind turbine. + new WecCharacteristicInput( + "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + + "(5.0,0.430345211), (6.0,0.45944023), (7.0,0.479507331), (8.0,0.492113623), " + + "(9.0,0.500417188), (10.0,0.488466547), (11.0,0.420415054), (12.0,0.354241299), " + + "(13.0,0.288470591), (14.0,0.230965702), (15.0,0.18778367), (16.0,0.154728976), " + + "(17.0,0.128998552), (18.0,0.108671106), (19.0,0.09239975), (20.0,0.079221236), " + + "(21.0,0.068434282), (22.0,0.059520087), (23.0,0.052089249), (24.0,0.045845623), " + + "(25.0,0.040561273), (26.0,0.036058824), (27.0,0.032198846), (28.0,0.016618264), " + + "(29.0,0.010330976), (30.0,0.006091519), (31.0,0.003331177), (32.0,0.001641637), " + + "(33.0,0.000705423), (34.0,0.000196644), (35.0,0.0), (36.0,0.0), (37.0,0.0), (38.0,0.0), " + + "(39.0,0.0), (40.0,0.0), (41.0,0.0), (42.0,0.0), (43.0,0.0), (44.0,0.0), (45.0,0.0), " + + "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" + ), + Quantities.getQuantity(15, PERCENT), + Quantities.getQuantity(5281, SQUARE_METRE), + Quantities.getQuantity(20, METRE), ) - val inputModel = new WecInput( + val wecInput = new WecInput( UUID.randomUUID(), - "WecInput", - new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), - OperationTime.notLimited(), + "WecTypeInput", nodeInput, - CosPhiFixed.CONSTANT_CHARACTERISTIC, + ReactivePowerCharacteristic.parse("cosPhiFixed:{(0.00,0.95)}"), null, typeInput, - false + false, ) - } - def buildWecModel(): WecModel = { - WecModel.apply(inputModel, 1, + val wecModel = WecModel.apply( + wecInput, + 1, TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z")) + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), + ) } - - - } From 0eed6c0b7d7c5efe41ac064f56953c0991aa1aa0 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 6 Jun 2024 20:41:19 +0200 Subject: [PATCH 03/31] Delete Groovy test. Implement Scala test. --- .../model/participant/WecModelTest.groovy | 217 ------------------ .../model/participant/WecModelSpec.scala | 110 ++++++++- 2 files changed, 98 insertions(+), 229 deletions(-) delete mode 100644 src/test/groovy/edu/ie3/simona/model/participant/WecModelTest.groovy diff --git a/src/test/groovy/edu/ie3/simona/model/participant/WecModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/WecModelTest.groovy deleted file mode 100644 index 45c6a8ad0a..0000000000 --- a/src/test/groovy/edu/ie3/simona/model/participant/WecModelTest.groovy +++ /dev/null @@ -1,217 +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.participant - -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static edu.ie3.datamodel.models.StandardUnits.* -import static edu.ie3.simona.model.participant.WecModel.WecRelevantData -import static tech.units.indriya.quantity.Quantities.getQuantity - -import edu.ie3.datamodel.models.OperationTime -import edu.ie3.datamodel.models.input.NodeInput -import edu.ie3.datamodel.models.input.OperatorInput -import edu.ie3.datamodel.models.input.system.WecInput -import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed -import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput -import edu.ie3.datamodel.models.input.system.type.WecTypeInput -import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils -import edu.ie3.util.TimeUtil -import edu.ie3.util.scala.quantities.Sq -import scala.Option -import scala.Some -import spock.lang.Shared -import spock.lang.Specification -import spock.lang.Unroll -import squants.Each$ -import squants.motion.MetersPerSecond$ -import squants.motion.Pascals$ - -import squants.energy.Kilowatts$ -import squants.space.SquareMeters$ -import squants.thermal.Celsius$ - - -class WecModelTest extends Specification { - - @Shared - WecInput inputModel - @Shared - static final Double TOLERANCE = 1e-5 - - def setupSpec() { - def nodeInput = new NodeInput( - UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), - "NodeInput", - OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited(), - getQuantity(1d, PU), - false, - NodeInput.DEFAULT_GEO_POSITION, - GermanVoltageLevelUtils.LV, - -1) - - def typeInput = new WecTypeInput( - UUID.randomUUID(), - "WecTypeInput", - getQuantity(1000, EURO), - getQuantity(1000, ENERGY_PRICE), - getQuantity(1200, S_RATED), - 0.95, - //Using the characteristics of the Enercon E-82 wind turbine. - new WecCharacteristicInput( - "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + - "(5.0,0.430345211), (6.0,0.45944023), (7.0,0.479507331), (8.0,0.492113623), " + - "(9.0,0.500417188), (10.0,0.488466547), (11.0,0.420415054), (12.0,0.354241299), " + - "(13.0,0.288470591), (14.0,0.230965702), (15.0,0.18778367), (16.0,0.154728976), " + - "(17.0,0.128998552), (18.0,0.108671106), (19.0,0.09239975), (20.0,0.079221236), " + - "(21.0,0.068434282), (22.0,0.059520087), (23.0,0.052089249), (24.0,0.045845623), " + - "(25.0,0.040561273), (26.0,0.036058824), (27.0,0.032198846), (28.0,0.016618264), " + - "(29.0,0.010330976), (30.0,0.006091519), (31.0,0.003331177), (32.0,0.001641637), " + - "(33.0,0.000705423), (34.0,0.000196644), (35.0,0.0), (36.0,0.0), (37.0,0.0), (38.0,0.0), " + - "(39.0,0.0), (40.0,0.0), (41.0,0.0), (42.0,0.0), (43.0,0.0), (44.0,0.0), (45.0,0.0), " + - "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" - ), - getQuantity(15, EFFICIENCY), - getQuantity(5281, ROTOR_AREA), - getQuantity(20, HUB_HEIGHT)) - - inputModel = new WecInput( - UUID.randomUUID(), - "WecInput", - new OperatorInput(UUID.randomUUID(), "NO_OPERATOR"), - OperationTime.notLimited(), - nodeInput, - CosPhiFixed.CONSTANT_CHARACTERISTIC, - null, - typeInput, - false) - } - - def buildWecModel() { - return WecModel.apply(inputModel, 1, - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z")) - } - - @Unroll - def "Check build method of companion object"() { - when: - def wecModel = buildWecModel() - then: - wecModel.uuid() == inputModel.uuid - wecModel.id() == inputModel.id - wecModel.sRated() == Sq.create(inputModel.type.sRated.value.doubleValue(), Kilowatts$.MODULE$) - wecModel.cosPhiRated() == inputModel.type.cosPhiRated - wecModel.rotorArea() == Sq.create(inputModel.type.rotorArea.value.doubleValue(), SquareMeters$.MODULE$) - wecModel.betzCurve() == new WecModel.WecCharacteristic$().apply(inputModel.type.cpCharacteristic) - } - - @Unroll - def "Check active power output depending on velocity #velocity m/s"() { - given: - def wecModel = buildWecModel() - def wecData = new WecRelevantData( - Sq.create(velocity, MetersPerSecond$.MODULE$), - Sq.create(20, Celsius$.MODULE$), - new Some (Sq.create(101325d, Pascals$.MODULE$))) - - when: - def result = wecModel.calculateActivePower(ModelState.ConstantState$.MODULE$, wecData) - - then: - Math.abs((result.toWatts() - power.doubleValue())) < TOLERANCE - - where: - velocity || power - 1.0d || 0 - 2.0d || -2948.80958 - 3.0d || -24573.41320 - 7.0d || -522922.23257 - 9.0d || -1140000 - 13.0d || -1140000 - 15.0d || -1140000 - 19.0d || -1140000 - 23.0d || -1140000 - 27.0d || -1140000 - 34.0d || -24573.39638 - 40.0d || 0 - } - - @Unroll - def "Check active power output depending on temperature #temperature Celsius"() { - given: - def wecModel = buildWecModel() - def wecData = new WecRelevantData(Sq.create(3.0d, MetersPerSecond$.MODULE$), - Sq.create(temperature, Celsius$.MODULE$), new Some( Sq.create(101325d, Pascals$.MODULE$))) - - when: - def result = wecModel.calculateActivePower(ModelState.ConstantState$.MODULE$, wecData) - - then: - result.toWatts() =~ power - - where: - temperature || power - 35d || -23377.23862d - 20d || -24573.41320d - -25d || -29029.60338d - } - - @Unroll - def "Check determineBetzCoefficient method with wind velocity #velocity m/s:"() { - given: - def wecModel = buildWecModel() - def windVel = Sq.create(velocity, MetersPerSecond$.MODULE$) - - when: - def betzFactor = wecModel.determineBetzCoefficient(windVel) - def expected = Sq.create(betzResult, Each$.MODULE$) - - then: - betzFactor == expected - - where: - velocity || betzResult - 2d || 0.115933516d - 2.5d || 0.2010945555d - 18d || 0.108671106d - 27d || 0.032198846d - 34d || 0.000196644d - 40d || 0.0d - } - - @Unroll - def "Check calculateAirDensity method with temperature #temperature degrees Celsius and air pressure #pressure Pascal:"() { - given: - def wecModel = buildWecModel() - def temperatureV = Sq.create(temperature, Celsius$.MODULE$) - def pressureV = Option.empty() - - when: - if (pressure > 0) { - pressureV = new Some(Sq.create(pressure, Pascals$.MODULE$)) - } - def airDensity = wecModel.calculateAirDensity(temperatureV, pressureV).toKilogramsPerCubicMeter() - - then: - Math.abs(airDensity - densityResult) < TOLERANCE - - where: - temperature | pressure || densityResult - -15d | 100129.44d || 1.35121d - -5d | 99535.96d || 1.29311d - 0d | 99535.96d || 1.26944d - 5d | 100129.44d || 1.25405d - 20d | 100129.44d || 1.18988d - 25d | 100427.25d || 1.17341d - 37d | 100427.25d || 1.12801d - // test case, where no air pressure is given (see WecModel.calculateAirDensity) - 0d | -1.0d || 1.2041d - 5d | -1.0d || 1.2041d - 40d | -1.0d || 1.2041d - } -} diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 80772a6518..05446736ad 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -9,21 +9,28 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ - ReactivePowerCharacteristic, - WecCharacteristicInput, -} +import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils +import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.scala.quantities.Sq +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers +import shapeless.syntax.std.tuple.productTupleOps +import squants.Each +import squants.energy.Kilowatts +import squants.motion.{MetersPerSecond, Pascals} +import squants.space.SquareMeters +import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID -class WecModelSpec extends UnitSpec with DefaultTestData { +class WecModelSpec extends AnyFlatSpec with Matchers { val TOLERANCE: Double = 1e-5 @@ -66,7 +73,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { Quantities.getQuantity(20, METRE), ) - val wecInput = new WecInput( + val inputModel = new WecInput( UUID.randomUUID(), "WecTypeInput", nodeInput, @@ -76,11 +83,90 @@ class WecModelSpec extends UnitSpec with DefaultTestData { false, ) - val wecModel = WecModel.apply( - wecInput, - 1, - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), - ) + def buildWecModel(): WecModel = { + WecModel.apply( + inputModel, + 1, + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), + ) + } + + /** "WecModel" should "build correctly from input model" in { val wecModel = + * buildWecModel() wecModel.uuid() shouldBe inputModel.uuid wecModel.id() + * shouldBe inputModel.id wecModel.sRated() shouldBe + * Sq.create(inputModel.getType.sRated.getValue.doubleValue(), Kilowatts) + * wecModel.cosPhiRated() shouldBe inputModel.getType.cosPhiRated + * wecModel.rotorArea() shouldBe + * Sq.create(inputModel.getType.rotorArea.getValue.doubleValue(), + * SquareMeters) wecModel.betzCurve() shouldBe new + * WecModel.WecCharacteristic().apply(inputModel.getType.cpCharacteristic) + * } + */ + + "WecModel" should "calculate active power output depending on velocity" in { + val wecModel = buildWecModel() + val velocities = + Seq(1.0, 2.0, 3.0, 7.0, 9.0, 13.0, 15.0, 19.0, 23.0, 27.0, 34.0, 40.0) + val expectedPowers = + Seq(0, -2948.80958, -24573.41320, -522922.23257, -1140000, -1140000, + -1140000, -1140000, -1140000, -1140000, -24573.39638, 0) + + velocities.zip(expectedPowers).foreach { case (velocity, power) => + val wecData = new WecRelevantData( + Sq.create(velocity, MetersPerSecond), + Sq.create(20, Celsius), + Some(Sq.create(101325d, Pascals)), + ) + val result = + wecModel.calculateActivePower(ModelState.ConstantState, wecData) + math.abs(result.toWatts - power) should be < TOLERANCE + } + } + + "WecModel" should "calculate active power output depending on temperature" in { + val wecModel = buildWecModel() + val temperatures = Seq(35.0, 20.0, -25.0) + val expectedPowers = Seq(-23377.23862, -24573.41320, -29029.60338) + + temperatures.zip(expectedPowers).foreach { case (temperature, power) => + val wecData = new WecRelevantData( + Sq.create(3.0, MetersPerSecond), + Sq.create(temperature, Celsius), + Some(Sq.create(101325d, Pascals)), + ) + val result = + wecModel.calculateActivePower(ModelState.ConstantState, wecData) + result.toWatts shouldEqual power +- TOLERANCE + } + } + + /** "WecModel" should "determine Betz coefficient correctly" in { val + * wecModel = buildWecModel() val velocities = Seq(2.0, 2.5, 18.0, 27.0, + * 34.0, 40.0) val expectedBetzResults = Seq(0.115933516, 0.2010945555, + * 0.108671106, 0.032198846, 0.000196644, 0.0) + * + * velocities.zip(expectedBetzResults).foreach { case (velocity, + * betzResult) => val windVel = Sq.create(velocity, MetersPerSecond) val + * betzFactor = wecModel.determineBetzCoefficient(windVel) val expected = + * Sq.create(betzResult, Each) betzFactor shouldEqual expected } } + */ + + /** "WecModel" should "calculate air density correctly" in { val wecModel = + * buildWecModel() val testCases = Seq( ( -15.0, 100129.44, 1.35121 ), ( + * -5.0, 99535.96, 1.29311 ), ( 0.0, 99535.96, 1.26944 ), ( 5.0, 100129.44, + * 1.25405 ), ( 20.0, 100129.44, 1.18988 ), ( 25.0, 100427.25, 1.17341 ), ( + * 37.0, 100427.25, 1.12801 ), // test cases where no air pressure is given + * ( 0.0, -1.0, 1.2041 ), ( 5.0, -1.0, 1.2041 ), ( 40.0, -1.0, 1.2041 ) ) + * + * testCases.foreach { case (temperature, pressure, densityResult) => val + * temperatureV = Sq.create(temperature, Celsius) val pressureV = if + * (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty + * + * val airDensity = wecModel.calculateAirDensity(temperatureV, + * pressureV).toKilogramsPerCubicMeter math.abs(airDensity - densityResult) + * should be < TOLERANCE } } + */ + } } From d01763d3bd1f3ed2156d65c4202b770734c95125 Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Wed, 12 Jun 2024 14:18:08 +0200 Subject: [PATCH 04/31] spotless --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 05446736ad..e75b506df8 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -9,7 +9,10 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} +import edu.ie3.datamodel.models.input.system.characteristic.{ + ReactivePowerCharacteristic, + WecCharacteristicInput, +} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.model.participant.WecModel.WecRelevantData From 45ea956f8ff5cb612eb1417d03efe2c560d669c0 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Wed, 12 Jun 2024 22:05:30 +0200 Subject: [PATCH 05/31] WecModelSpec.scala and Wecmodel.scala --- .../simona/model/participant/WecModel.scala | 4 +- .../model/participant/WecModelSpec.scala | 221 +++++++++--------- 2 files changed, 115 insertions(+), 110 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index d07cd6c2fc..8cc0e9ec88 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -154,7 +154,7 @@ final case class WecModel( * @return * betz coefficient cₚ */ - private def determineBetzCoefficient( + def determineBetzCoefficient( windVelocity: Velocity ): Dimensionless = { betzCurve.interpolateXy(windVelocity) match { @@ -174,7 +174,7 @@ final case class WecModel( * current air pressure * @return */ - private def calculateAirDensity( + def calculateAirDensity( temperature: Temperature, airPressure: Option[Pressure], ): Density = { diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index e75b506df8..465fbbc313 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -1,113 +1,119 @@ /* - * © 2024. TU Dortmund University, + * © 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.participant + +import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ - ReactivePowerCharacteristic, - WecCharacteristicInput, -} +import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils -import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil -import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.util.scala.quantities.Sq -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers -import shapeless.syntax.std.tuple.productTupleOps import squants.Each -import squants.energy.Kilowatts import squants.motion.{MetersPerSecond, Pascals} -import squants.space.SquareMeters import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID - -class WecModelSpec extends AnyFlatSpec with Matchers { +class WecModelSpec extends UnitSpec with DefaultTestData { val TOLERANCE: Double = 1e-5 - def setupSpec(): Unit = { - val nodeInput = new NodeInput( - UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), - "NodeInput", - OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited(), - Quantities.getQuantity(1, PowerSystemUnits.PU), - false, - NodeInput.DEFAULT_GEO_POSITION, - GermanVoltageLevelUtils.LV, - -1, + val nodeInput = new NodeInput( + UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), + "NodeInput", + OperatorInput.NO_OPERATOR_ASSIGNED, + OperationTime.notLimited(), + Quantities.getQuantity(1, PowerSystemUnits.PU), + false, + NodeInput.DEFAULT_GEO_POSITION, + GermanVoltageLevelUtils.LV, + -1, + ) + + val typeInput = new WecTypeInput( + UUID.randomUUID(), + "WecTypeInput", + Quantities.getQuantity(1000, PowerSystemUnits.EURO), + Quantities.getQuantity(1000, PowerSystemUnits.EURO_PER_MEGAWATTHOUR), + Quantities.getQuantity(1200, PowerSystemUnits.KILOWATT), + 0.95, + new WecCharacteristicInput( + "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + + "(5.0,0.430345211), (6.0,0.45944023), (7.0,0.479507331), (8.0,0.492113623), " + + "(9.0,0.500417188), (10.0,0.488466547), (11.0,0.420415054), (12.0,0.354241299), " + + "(13.0,0.288470591), (14.0,0.230965702), (15.0,0.18778367), (16.0,0.154728976), " + + "(17.0,0.128998552), (18.0,0.108671106), (19.0,0.09239975), (20.0,0.079221236), " + + "(21.0,0.068434282), (22.0,0.059520087), (23.0,0.052089249), (24.0,0.045845623), " + + "(25.0,0.040561273), (26.0,0.036058824), (27.0,0.032198846), (28.0,0.016618264), " + + "(29.0,0.010330976), (30.0,0.006091519), (31.0,0.003331177), (32.0,0.001641637), " + + "(33.0,0.000705423), (34.0,0.000196644), (35.0,0.0), (36.0,0.0), (37.0,0.0), (38.0,0.0), " + + "(39.0,0.0), (40.0,0.0), (41.0,0.0), (42.0,0.0), (43.0,0.0), (44.0,0.0), (45.0,0.0), " + + "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" + ), + Quantities.getQuantity(15, PERCENT), + Quantities.getQuantity(5281, SQUARE_METRE), + Quantities.getQuantity(20, METRE), + ) + + val inputModel = new WecInput( + UUID.randomUUID(), + "WecTypeInput", + nodeInput, + ReactivePowerCharacteristic.parse("cosPhiFixed:{(0.00,0.95)}"), + null, + typeInput, + false, + ) + + def buildWecModel(): WecModel = { + WecModel.apply( + inputModel, + 1, + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), + TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), ) + } - val typeInput = new WecTypeInput( - UUID.randomUUID(), - "WecTypeInput", - Quantities.getQuantity(1000, PowerSystemUnits.EURO), - Quantities.getQuantity(1000, PowerSystemUnits.EURO_PER_MEGAWATTHOUR), - Quantities.getQuantity(1200, PowerSystemUnits.KILOWATT), - 0.95, - // Using the characteristics of the Enercon E-82 wind turbine. - new WecCharacteristicInput( - "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + - "(5.0,0.430345211), (6.0,0.45944023), (7.0,0.479507331), (8.0,0.492113623), " + - "(9.0,0.500417188), (10.0,0.488466547), (11.0,0.420415054), (12.0,0.354241299), " + - "(13.0,0.288470591), (14.0,0.230965702), (15.0,0.18778367), (16.0,0.154728976), " + - "(17.0,0.128998552), (18.0,0.108671106), (19.0,0.09239975), (20.0,0.079221236), " + - "(21.0,0.068434282), (22.0,0.059520087), (23.0,0.052089249), (24.0,0.045845623), " + - "(25.0,0.040561273), (26.0,0.036058824), (27.0,0.032198846), (28.0,0.016618264), " + - "(29.0,0.010330976), (30.0,0.006091519), (31.0,0.003331177), (32.0,0.001641637), " + - "(33.0,0.000705423), (34.0,0.000196644), (35.0,0.0), (36.0,0.0), (37.0,0.0), (38.0,0.0), " + - "(39.0,0.0), (40.0,0.0), (41.0,0.0), (42.0,0.0), (43.0,0.0), (44.0,0.0), (45.0,0.0), " + - "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" - ), - Quantities.getQuantity(15, PERCENT), - Quantities.getQuantity(5281, SQUARE_METRE), - Quantities.getQuantity(20, METRE), - ) + "WecModel" should { - val inputModel = new WecInput( - UUID.randomUUID(), - "WecTypeInput", - nodeInput, - ReactivePowerCharacteristic.parse("cosPhiFixed:{(0.00,0.95)}"), - null, - typeInput, - false, - ) + "check build method of companion object" in { + val wecModel = buildWecModel() - def buildWecModel(): WecModel = { - WecModel.apply( - inputModel, - 1, - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z"), - TimeUtil.withDefaults.toZonedDateTime("2020-01-01T01:00:00Z"), - ) + wecModel.uuid shouldBe inputModel.getUuid + wecModel.id shouldBe inputModel.getId + wecModel.rotorArea shouldBe typeInput.getRotorArea + wecModel.cosPhiRated shouldBe typeInput.getCosPhiRated + wecModel.sRated shouldBe typeInput.getsRated() + wecModel.betzCurve shouldBe } - /** "WecModel" should "build correctly from input model" in { val wecModel = - * buildWecModel() wecModel.uuid() shouldBe inputModel.uuid wecModel.id() - * shouldBe inputModel.id wecModel.sRated() shouldBe - * Sq.create(inputModel.getType.sRated.getValue.doubleValue(), Kilowatts) - * wecModel.cosPhiRated() shouldBe inputModel.getType.cosPhiRated - * wecModel.rotorArea() shouldBe - * Sq.create(inputModel.getType.rotorArea.getValue.doubleValue(), - * SquareMeters) wecModel.betzCurve() shouldBe new - * WecModel.WecCharacteristic().apply(inputModel.getType.cpCharacteristic) - * } - */ - - "WecModel" should "calculate active power output depending on velocity" in { + + "determine Betz coefficient correctly" in { + val wecModel = buildWecModel() + val velocities = Seq(2.0, 2.5, 18.0, 27.0, 34.0, 40.0) + val expectedBetzResults = Seq(0.115933516, 0.2010945555, 0.108671106, 0.032198846, 0.000196644, 0.0) + + velocities.zip(expectedBetzResults).foreach { case (velocity, betzResult) => + val windVel = Sq.create(velocity, MetersPerSecond) + val betzFactor = wecModel.determineBetzCoefficient(windVel) + val expected = Sq.create(betzResult, Each) + betzFactor shouldEqual expected + } + } + + + "calculate active power output depending on velocity" in { val wecModel = buildWecModel() val velocities = Seq(1.0, 2.0, 3.0, 7.0, 9.0, 13.0, 15.0, 19.0, 23.0, 27.0, 34.0, 40.0) @@ -127,7 +133,34 @@ class WecModelSpec extends AnyFlatSpec with Matchers { } } - "WecModel" should "calculate active power output depending on temperature" in { + "calculate air density correctly" in { + val wecModel = buildWecModel() + val testCases = Seq( + (-15.0, 100129.44, 1.35121), + (-5.0, 99535.96, 1.29311), + (0.0, 99535.96, 1.26944), + (5.0, 100129.44, 1.25405), + (20.0, 100129.44, 1.18988), + (25.0, 100427.25, 1.17341), + (37.0, 100427.25, 1.12801), + // test cases where no air pressure is given + (0.0, -1.0, 1.2041), + (5.0, -1.0, 1.2041), + (40.0, -1.0, 1.2041) + ) + + testCases.foreach { case (temperature, pressure, densityResult) => + val temperatureV = Sq.create(temperature, Celsius) + val pressureV = if (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty + + val airDensity = wecModel.calculateAirDensity(temperatureV, pressureV).toKilogramsPerCubicMeter + math.abs(airDensity - densityResult) should be < TOLERANCE + } + } + + + + "calculate active power output depending on temperature" in { val wecModel = buildWecModel() val temperatures = Seq(35.0, 20.0, -25.0) val expectedPowers = Seq(-23377.23862, -24573.41320, -29029.60338) @@ -143,33 +176,5 @@ class WecModelSpec extends AnyFlatSpec with Matchers { result.toWatts shouldEqual power +- TOLERANCE } } - - /** "WecModel" should "determine Betz coefficient correctly" in { val - * wecModel = buildWecModel() val velocities = Seq(2.0, 2.5, 18.0, 27.0, - * 34.0, 40.0) val expectedBetzResults = Seq(0.115933516, 0.2010945555, - * 0.108671106, 0.032198846, 0.000196644, 0.0) - * - * velocities.zip(expectedBetzResults).foreach { case (velocity, - * betzResult) => val windVel = Sq.create(velocity, MetersPerSecond) val - * betzFactor = wecModel.determineBetzCoefficient(windVel) val expected = - * Sq.create(betzResult, Each) betzFactor shouldEqual expected } } - */ - - /** "WecModel" should "calculate air density correctly" in { val wecModel = - * buildWecModel() val testCases = Seq( ( -15.0, 100129.44, 1.35121 ), ( - * -5.0, 99535.96, 1.29311 ), ( 0.0, 99535.96, 1.26944 ), ( 5.0, 100129.44, - * 1.25405 ), ( 20.0, 100129.44, 1.18988 ), ( 25.0, 100427.25, 1.17341 ), ( - * 37.0, 100427.25, 1.12801 ), // test cases where no air pressure is given - * ( 0.0, -1.0, 1.2041 ), ( 5.0, -1.0, 1.2041 ), ( 40.0, -1.0, 1.2041 ) ) - * - * testCases.foreach { case (temperature, pressure, densityResult) => val - * temperatureV = Sq.create(temperature, Celsius) val pressureV = if - * (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty - * - * val airDensity = wecModel.calculateAirDensity(temperatureV, - * pressureV).toKilogramsPerCubicMeter math.abs(airDensity - densityResult) - * should be < TOLERANCE } } - */ - } } From 7365732685224fe7ea3b7029e85d37406f87b67f Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 13 Jun 2024 13:22:38 +0200 Subject: [PATCH 06/31] betzCurve in "check build method of companion object" SpotlessApply --- .../model/participant/WecModelSpec.scala | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 465fbbc313..1692ee77a1 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -6,13 +6,15 @@ package edu.ie3.simona.model.participant - import edu.ie3.util.quantities.PowerSystemUnits import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} +import edu.ie3.datamodel.models.input.system.characteristic.{ + ReactivePowerCharacteristic, + WecCharacteristicInput, +} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} @@ -66,7 +68,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { Quantities.getQuantity(20, METRE), ) - val inputModel = new WecInput( + val inputModel = new WecInput( UUID.randomUUID(), "WecTypeInput", nodeInput, @@ -89,30 +91,28 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "check build method of companion object" in { val wecModel = buildWecModel() - wecModel.uuid shouldBe inputModel.getUuid wecModel.id shouldBe inputModel.getId wecModel.rotorArea shouldBe typeInput.getRotorArea wecModel.cosPhiRated shouldBe typeInput.getCosPhiRated - wecModel.sRated shouldBe typeInput.getsRated() - wecModel.betzCurve shouldBe + wecModel.sRated shouldBe typeInput.getsRated + wecModel.betzCurve shouldBe typeInput.getCpCharacteristic } - "determine Betz coefficient correctly" in { val wecModel = buildWecModel() val velocities = Seq(2.0, 2.5, 18.0, 27.0, 34.0, 40.0) - val expectedBetzResults = Seq(0.115933516, 0.2010945555, 0.108671106, 0.032198846, 0.000196644, 0.0) - - velocities.zip(expectedBetzResults).foreach { case (velocity, betzResult) => - val windVel = Sq.create(velocity, MetersPerSecond) - val betzFactor = wecModel.determineBetzCoefficient(windVel) - val expected = Sq.create(betzResult, Each) - betzFactor shouldEqual expected + val expectedBetzResults = Seq(0.115933516, 0.2010945555, 0.108671106, + 0.032198846, 0.000196644, 0.0) + velocities.zip(expectedBetzResults).foreach { + case (velocity, betzResult) => + val windVel = Sq.create(velocity, MetersPerSecond) + val betzFactor = wecModel.determineBetzCoefficient(windVel) + val expected = Sq.create(betzResult, Each) + betzFactor shouldEqual expected } } - "calculate active power output depending on velocity" in { val wecModel = buildWecModel() val velocities = @@ -146,20 +146,21 @@ class WecModelSpec extends UnitSpec with DefaultTestData { // test cases where no air pressure is given (0.0, -1.0, 1.2041), (5.0, -1.0, 1.2041), - (40.0, -1.0, 1.2041) + (40.0, -1.0, 1.2041), ) testCases.foreach { case (temperature, pressure, densityResult) => val temperatureV = Sq.create(temperature, Celsius) - val pressureV = if (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty + val pressureV = + if (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty - val airDensity = wecModel.calculateAirDensity(temperatureV, pressureV).toKilogramsPerCubicMeter + val airDensity = wecModel + .calculateAirDensity(temperatureV, pressureV) + .toKilogramsPerCubicMeter math.abs(airDensity - densityResult) should be < TOLERANCE } } - - "calculate active power output depending on temperature" in { val wecModel = buildWecModel() val temperatures = Seq(35.0, 20.0, -25.0) From 6b607ee07016df4052727948c0ca5a6859713866 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 13 Jun 2024 14:08:19 +0200 Subject: [PATCH 07/31] =?UTF-8?q?=205281.0=20m=C2=B2=20was=20not=20equal?= =?UTF-8?q?=20to=205281=20m=C2=B2=20(WecModelSpec.scala:96)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 1692ee77a1..1daf28e498 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -64,7 +64,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "(46.0,0.0), (47.0,0.0), (48.0,0.0), (49.0,0.0), (50.0,0.0)}" ), Quantities.getQuantity(15, PERCENT), - Quantities.getQuantity(5281, SQUARE_METRE), + Quantities.getQuantity(5281.0, SQUARE_METRE), Quantities.getQuantity(20, METRE), ) From 0e1d8bed6e1170a127e5da7b8221569cc5507fff Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 13 Jun 2024 14:32:22 +0200 Subject: [PATCH 08/31] Sonarqube --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 1daf28e498..f16ad68c14 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -29,7 +29,7 @@ import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { - val TOLERANCE: Double = 1e-5 + val tolerance: Double = 1e-5 val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), From 7d99ee93a22abc6eedaf2a3a372280aa23df5c66 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 13 Jun 2024 14:40:17 +0200 Subject: [PATCH 09/31] Sonarqube2 --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index f16ad68c14..1daf28e498 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -29,7 +29,7 @@ import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { - val tolerance: Double = 1e-5 + val TOLERANCE: Double = 1e-5 val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), From c9a6880a4368daec4d89150a660d6b0ed634a84e Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:41:08 +0200 Subject: [PATCH 10/31] powerTolerance --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 1daf28e498..8302b984da 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -29,7 +29,7 @@ import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { - val TOLERANCE: Double = 1e-5 + private implicit val powerTolerance: Power Watts(1e-5) val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), @@ -129,7 +129,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - math.abs(result.toWatts - power) should be < TOLERANCE + math.abs(result.toWatts - power) should be < powerTolerance } } @@ -157,7 +157,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val airDensity = wecModel .calculateAirDensity(temperatureV, pressureV) .toKilogramsPerCubicMeter - math.abs(airDensity - densityResult) should be < TOLERANCE + math.abs(airDensity - densityResult) should be < powerTolerance } } @@ -174,7 +174,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - result.toWatts shouldEqual power +- TOLERANCE + result.toWatts shouldEqual power +- powerTolerance } } } From c0abb5fdeeba922ee921dbfab84384fecc880cb0 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:20:07 +0200 Subject: [PATCH 11/31] squants, spotlessApply --- .../ie3/simona/model/participant/WecModelSpec.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 8302b984da..13bfd5d38c 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -20,7 +20,8 @@ import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil import edu.ie3.util.scala.quantities.Sq -import squants.Each +import squants.{Each, Power} +import squants.energy.{Power, Watts} import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities @@ -29,7 +30,7 @@ import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { - private implicit val powerTolerance: Power Watts(1e-5) + private implicit val powerTolerance: Power = Watts(1e-5) val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), @@ -129,7 +130,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - math.abs(result.toWatts - power) should be < powerTolerance + math.abs(result.toWatts - power) should be < powerTolerance } } @@ -157,7 +158,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val airDensity = wecModel .calculateAirDensity(temperatureV, pressureV) .toKilogramsPerCubicMeter - math.abs(airDensity - densityResult) should be < powerTolerance + math.abs(airDensity - densityResult) should be < powerTolerance } } @@ -174,7 +175,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - result.toWatts shouldEqual power +- powerTolerance + result.toWatts shouldEqual Watts(power) +- powerTolerance } } } From a94498f1fef7d94b0ff5bec3074eb8c4580f01ff Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:20:50 +0200 Subject: [PATCH 12/31] import --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 13bfd5d38c..43b243d7e8 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -21,7 +21,7 @@ import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil import edu.ie3.util.scala.quantities.Sq import squants.{Each, Power} -import squants.energy.{Power, Watts} +import squants.energy.Watts import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities From a73dab6030c8fcacbe74013b1796dea3e2e2ec4f Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:33:20 +0200 Subject: [PATCH 13/31] densityTolerance --- .../ie3/simona/model/participant/WecModelSpec.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 43b243d7e8..0c201b3971 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -11,10 +11,7 @@ import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ - ReactivePowerCharacteristic, - WecCharacteristicInput, -} +import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} @@ -22,6 +19,7 @@ import edu.ie3.util.TimeUtil import edu.ie3.util.scala.quantities.Sq import squants.{Each, Power} import squants.energy.Watts +import squants.mass.{Density, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities @@ -30,6 +28,8 @@ import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { + + private implicit val densityTolerance: Density = KilogramsPerCubicMeter(1e-5) private implicit val powerTolerance: Power = Watts(1e-5) val nodeInput = new NodeInput( @@ -130,7 +130,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - math.abs(result.toWatts - power) should be < powerTolerance + math.abs(result.toWatts - Watts(power)) should be < powerTolerance } } @@ -158,7 +158,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val airDensity = wecModel .calculateAirDensity(temperatureV, pressureV) .toKilogramsPerCubicMeter - math.abs(airDensity - densityResult) should be < powerTolerance + math.abs(airDensity - densityResult) should be < densityTolerance } } From ef1820c349aec88856297d366c52c2277e8d2101 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:37:05 +0200 Subject: [PATCH 14/31] spotlessApply --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 0c201b3971..69a311cad8 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -11,7 +11,10 @@ import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} +import edu.ie3.datamodel.models.input.system.characteristic.{ + ReactivePowerCharacteristic, + WecCharacteristicInput, +} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} @@ -28,7 +31,6 @@ import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { - private implicit val densityTolerance: Density = KilogramsPerCubicMeter(1e-5) private implicit val powerTolerance: Power = Watts(1e-5) From a4190923dc4bc2668b7860de7723657384c0f38c Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:41:43 +0200 Subject: [PATCH 15/31] watts --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 69a311cad8..62a7f36384 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -132,7 +132,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - math.abs(result.toWatts - Watts(power)) should be < powerTolerance + math.abs(result.toWatts - Watts) should be < powerTolerance } } From 048b40196fcba6f0ff64faab71a6e2f76033fa46 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:49:06 +0200 Subject: [PATCH 16/31] densityTolerance --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 62a7f36384..43a866ec65 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -157,10 +157,8 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val pressureV = if (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty - val airDensity = wecModel - .calculateAirDensity(temperatureV, pressureV) - .toKilogramsPerCubicMeter - math.abs(airDensity - densityResult) should be < densityTolerance + val airDensity = wecModel.calculateAirDensity(temperatureV, pressureV).toKilogramsPerCubicMeter + math.abs(airDensity - densityResult) should be < densityTolerance.toKilogramsPerCubicMeter } } From a9553a529bdcae65912b917c2648e05da4cb4a6a Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:51:00 +0200 Subject: [PATCH 17/31] spotlessApply --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 43a866ec65..74eac80b65 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -157,8 +157,12 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val pressureV = if (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty - val airDensity = wecModel.calculateAirDensity(temperatureV, pressureV).toKilogramsPerCubicMeter - math.abs(airDensity - densityResult) should be < densityTolerance.toKilogramsPerCubicMeter + val airDensity = wecModel + .calculateAirDensity(temperatureV, pressureV) + .toKilogramsPerCubicMeter + math.abs( + airDensity - densityResult + ) should be < densityTolerance.toKilogramsPerCubicMeter } } From 97c11cab0e3381ed742711117d4333f4ce641068 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 18:58:46 +0200 Subject: [PATCH 18/31] velocity,spotlessApply --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 74eac80b65..f1216ed047 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -132,7 +132,10 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - math.abs(result.toWatts - Watts) should be < powerTolerance + val expectedPower = Watts(power) + math.abs( + result.toWatts - expectedPower.toWatts + ) should be < powerTolerance.toWatts } } From faa810b3f1568845b9e8b4509ff3287c1db09fdc Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Mon, 17 Jun 2024 19:26:51 +0200 Subject: [PATCH 19/31] tolerance, spotlessApply --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index f1216ed047..d9332d3e60 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -24,6 +24,7 @@ import squants.{Each, Power} import squants.energy.Watts import squants.mass.{Density, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pascals} +import squants.space.SquareMeters import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} @@ -32,7 +33,8 @@ import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { private implicit val densityTolerance: Density = KilogramsPerCubicMeter(1e-5) - private implicit val powerTolerance: Power = Watts(1e-5) + val rotorAreaTolerance = SquareMeters(1e-5) + private implicit val powerTolerance: Power = Watts(1e-2) val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), @@ -96,7 +98,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val wecModel = buildWecModel() wecModel.uuid shouldBe inputModel.getUuid wecModel.id shouldBe inputModel.getId - wecModel.rotorArea shouldBe typeInput.getRotorArea + wecModel.rotorArea shouldBe (typeInput.getRotorArea === rotorAreaTolerance) wecModel.cosPhiRated shouldBe typeInput.getCosPhiRated wecModel.sRated shouldBe typeInput.getsRated wecModel.betzCurve shouldBe typeInput.getCpCharacteristic From 684ccee349d1c46b0d1c72f20d15e11dc0ac7dfc Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Wed, 26 Jun 2024 14:12:44 +0200 Subject: [PATCH 20/31] betzCurve --- .../simona/model/participant/WecModel.scala | 2 +- .../model/participant/WecModelSpec.scala | 20 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index 8cc0e9ec88..bca7fd63b0 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -214,7 +214,7 @@ object WecModel { /** This class is initialized with a [[WecCharacteristicInput]], which * contains the needed betz curve. */ - final case class WecCharacteristic private ( + final case class WecCharacteristic ( override val xyCoordinates: SortedSet[ XYPair[Velocity, Dimensionless] ] diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index d9332d3e60..dfb153bfed 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -11,10 +11,7 @@ import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ - ReactivePowerCharacteristic, - WecCharacteristicInput, -} +import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} @@ -24,17 +21,16 @@ import squants.{Each, Power} import squants.energy.Watts import squants.mass.{Density, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pascals} -import squants.space.SquareMeters import squants.thermal.Celsius import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} import java.util.UUID + class WecModelSpec extends UnitSpec with DefaultTestData { private implicit val densityTolerance: Density = KilogramsPerCubicMeter(1e-5) - val rotorAreaTolerance = SquareMeters(1e-5) - private implicit val powerTolerance: Power = Watts(1e-2) + private implicit val powerTolerance: Power = Watts(1e-5) val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), @@ -53,7 +49,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "WecTypeInput", Quantities.getQuantity(1000, PowerSystemUnits.EURO), Quantities.getQuantity(1000, PowerSystemUnits.EURO_PER_MEGAWATTHOUR), - Quantities.getQuantity(1200, PowerSystemUnits.KILOWATT), + Quantities.getQuantity(1200.0, PowerSystemUnits.KILOVOLTAMPERE), 0.95, new WecCharacteristicInput( "cP:{(0.0,0.0), (1.0,0.0), (2.0,0.115933516), (3.0,0.286255595), (4.0,0.39610618), " + @@ -98,10 +94,10 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val wecModel = buildWecModel() wecModel.uuid shouldBe inputModel.getUuid wecModel.id shouldBe inputModel.getId - wecModel.rotorArea shouldBe (typeInput.getRotorArea === rotorAreaTolerance) + wecModel.rotorArea.toSquareMeters shouldBe (typeInput.getRotorArea.toSystemUnit.getValue.doubleValue() +- 1e-5) wecModel.cosPhiRated shouldBe typeInput.getCosPhiRated - wecModel.sRated shouldBe typeInput.getsRated - wecModel.betzCurve shouldBe typeInput.getCpCharacteristic + wecModel.sRated.toWatts shouldBe (typeInput.getsRated.toSystemUnit.getValue.doubleValue() +- 1e-5) + wecModel.betzCurve shouldBe new WecModel.WecCharacteristic.apply(inputModel.getType.getCpCharacteristic) } "determine Betz coefficient correctly" in { @@ -184,7 +180,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - result.toWatts shouldEqual Watts(power) +- powerTolerance + result.toWatts shouldBe power.doubleValue() +- powerTolerance.toWatts } } } From 589189be45891afd1eb377f874e4dcd362336861 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Wed, 26 Jun 2024 15:02:21 +0200 Subject: [PATCH 21/31] Rewrote WecModelTest from groovy to scala --- CHANGELOG.md | 1 + .../simona/model/participant/WecModelSpec.scala | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c05424bddc..ea597be5e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refactoring of `GridAgent` messages [#736](https://github.com/ie3-institute/simona/issues/736) - 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) +- Rewrote WecModelTest 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/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index dfb153bfed..ff8d00af46 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -11,7 +11,10 @@ import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} +import edu.ie3.datamodel.models.input.system.characteristic.{ + ReactivePowerCharacteristic, + WecCharacteristicInput, +} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} @@ -94,10 +97,14 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val wecModel = buildWecModel() wecModel.uuid shouldBe inputModel.getUuid wecModel.id shouldBe inputModel.getId - wecModel.rotorArea.toSquareMeters shouldBe (typeInput.getRotorArea.toSystemUnit.getValue.doubleValue() +- 1e-5) + wecModel.rotorArea.toSquareMeters shouldBe (typeInput.getRotorArea.toSystemUnit.getValue + .doubleValue() +- 1e-5) wecModel.cosPhiRated shouldBe typeInput.getCosPhiRated - wecModel.sRated.toWatts shouldBe (typeInput.getsRated.toSystemUnit.getValue.doubleValue() +- 1e-5) - wecModel.betzCurve shouldBe new WecModel.WecCharacteristic.apply(inputModel.getType.getCpCharacteristic) + wecModel.sRated.toWatts shouldBe (typeInput.getsRated.toSystemUnit.getValue + .doubleValue() +- 1e-5) + wecModel.betzCurve shouldBe WecModel.WecCharacteristic.apply( + inputModel.getType.getCpCharacteristic + ) } "determine Betz coefficient correctly" in { From 442287f5d9b03f6835f8895c13fcd80b4bd5eb4d Mon Sep 17 00:00:00 2001 From: danielfeismann Date: Mon, 1 Jul 2024 11:03:46 +0200 Subject: [PATCH 22/31] fmt --- src/main/scala/edu/ie3/simona/model/participant/WecModel.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala index bca7fd63b0..bffdd7fdae 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/WecModel.scala @@ -214,7 +214,7 @@ object WecModel { /** This class is initialized with a [[WecCharacteristicInput]], which * contains the needed betz curve. */ - final case class WecCharacteristic ( + final case class WecCharacteristic( override val xyCoordinates: SortedSet[ XYPair[Velocity, Dimensionless] ] From 89203cfc1b5910c41be83b179c0c9a8f973e37d8 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Wed, 10 Jul 2024 14:27:44 +0200 Subject: [PATCH 23/31] Refactor Scalatests to replace Sq.create() with direct units. --- .../model/participant/WecModelSpec.scala | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index ff8d00af46..27829fc651 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -6,25 +6,21 @@ package edu.ie3.simona.model.participant -import edu.ie3.util.quantities.PowerSystemUnits -import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ - ReactivePowerCharacteristic, - WecCharacteristicInput, -} +import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils +import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil -import edu.ie3.util.scala.quantities.Sq -import squants.{Each, Power} +import edu.ie3.util.quantities.PowerSystemUnits import squants.energy.Watts import squants.mass.{Density, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius +import squants.{Each, Power} import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} @@ -114,9 +110,9 @@ class WecModelSpec extends UnitSpec with DefaultTestData { 0.032198846, 0.000196644, 0.0) velocities.zip(expectedBetzResults).foreach { case (velocity, betzResult) => - val windVel = Sq.create(velocity, MetersPerSecond) + val windVel = MetersPerSecond(velocity) val betzFactor = wecModel.determineBetzCoefficient(windVel) - val expected = Sq.create(betzResult, Each) + val expected = Each(betzResult) betzFactor shouldEqual expected } } @@ -131,9 +127,9 @@ class WecModelSpec extends UnitSpec with DefaultTestData { velocities.zip(expectedPowers).foreach { case (velocity, power) => val wecData = new WecRelevantData( - Sq.create(velocity, MetersPerSecond), - Sq.create(20, Celsius), - Some(Sq.create(101325d, Pascals)), + MetersPerSecond(velocity), + Celsius(20), + Some(Pascals(101325d)), ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) @@ -161,9 +157,9 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) testCases.foreach { case (temperature, pressure, densityResult) => - val temperatureV = Sq.create(temperature, Celsius) + val temperatureV = Celsius(temperature) val pressureV = - if (pressure > 0) Some(Sq.create(pressure, Pascals)) else Option.empty + if (pressure > 0) Some(Pascals(pressure)) else Option.empty val airDensity = wecModel .calculateAirDensity(temperatureV, pressureV) @@ -181,9 +177,9 @@ class WecModelSpec extends UnitSpec with DefaultTestData { temperatures.zip(expectedPowers).foreach { case (temperature, power) => val wecData = new WecRelevantData( - Sq.create(3.0, MetersPerSecond), - Sq.create(temperature, Celsius), - Some(Sq.create(101325d, Pascals)), + MetersPerSecond(3.0), + Celsius(temperature), + Some(Pascals(101325d)), ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) From 9929d49acd9970b137cb0713fd1f9cdcc6a302d1 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Wed, 10 Jul 2024 14:39:25 +0200 Subject: [PATCH 24/31] fmt --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 27829fc651..cdaedb879b 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -9,7 +9,10 @@ package edu.ie3.simona.model.participant import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.system.WecInput import edu.ie3.datamodel.models.input.system.`type`.WecTypeInput -import edu.ie3.datamodel.models.input.system.characteristic.{ReactivePowerCharacteristic, WecCharacteristicInput} +import edu.ie3.datamodel.models.input.system.characteristic.{ + ReactivePowerCharacteristic, + WecCharacteristicInput, +} import edu.ie3.datamodel.models.input.{NodeInput, OperatorInput} import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.simona.model.participant.WecModel.WecRelevantData From 27b820ccad1a2c4333e0771654888b402ba151f4 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Thu, 25 Jul 2024 12:59:41 +0200 Subject: [PATCH 25/31] remove towatts() in test "calculate active power output depending on velocity" --- .../edu/ie3/simona/model/participant/WecModelSpec.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index cdaedb879b..81262fbfd0 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -19,6 +19,8 @@ import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers import squants.energy.Watts import squants.mass.{Density, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pascals} @@ -137,9 +139,8 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) val expectedPower = Watts(power) - math.abs( - result.toWatts - expectedPower.toWatts - ) should be < powerTolerance.toWatts + + (result - expectedPower) should be < powerTolerance } } From e52a689d60e41676f482baee21ee7373b36f6c41 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:14:29 +0200 Subject: [PATCH 26/31] Update src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 81262fbfd0..993bf55bd3 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -140,7 +140,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { wecModel.calculateActivePower(ModelState.ConstantState, wecData) val expectedPower = Watts(power) - (result - expectedPower) should be < powerTolerance + result should be(expectedPower) } } From a9c448d424f33de4ba63d93b8621401075416a41 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:20:08 +0200 Subject: [PATCH 27/31] Update src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index 993bf55bd3..c246fcaa63 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -187,7 +187,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { ) val result = wecModel.calculateActivePower(ModelState.ConstantState, wecData) - result.toWatts shouldBe power.doubleValue() +- powerTolerance.toWatts + result shouldBe power } } } From 06d7bd1bc22695caeee4ca9752e6535002587cb8 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier <155652256+pierrepetersmeier@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:20:39 +0200 Subject: [PATCH 28/31] Update src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala Co-authored-by: Daniel Feismann <98817556+danielfeismann@users.noreply.github.com> --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index c246fcaa63..a88f9c92ff 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -168,9 +168,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val airDensity = wecModel .calculateAirDensity(temperatureV, pressureV) .toKilogramsPerCubicMeter - math.abs( - airDensity - densityResult - ) should be < densityTolerance.toKilogramsPerCubicMeter + airDensity should be (densityResult) } } From d34721bfaba56937a063dbf6887bbaa573e21a10 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Fri, 26 Jul 2024 10:27:11 +0200 Subject: [PATCH 29/31] fix decimals failure in test "calculate active power output depending on temperature" --- .../model/participant/WecModelSpec.scala | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index a88f9c92ff..f5bfbf9bf7 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -19,13 +19,10 @@ import edu.ie3.simona.model.participant.WecModel.WecRelevantData import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec} import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.PowerSystemUnits -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers import squants.energy.Watts -import squants.mass.{Density, KilogramsPerCubicMeter} import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius -import squants.{Each, Power} +import squants.Each import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} @@ -33,9 +30,6 @@ import java.util.UUID class WecModelSpec extends UnitSpec with DefaultTestData { - private implicit val densityTolerance: Density = KilogramsPerCubicMeter(1e-5) - private implicit val powerTolerance: Power = Watts(1e-5) - val nodeInput = new NodeInput( UUID.fromString("ad39d0b9-5ad6-4588-8d92-74c7d7de9ace"), "NodeInput", @@ -127,8 +121,8 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val velocities = Seq(1.0, 2.0, 3.0, 7.0, 9.0, 13.0, 15.0, 19.0, 23.0, 27.0, 34.0, 40.0) val expectedPowers = - Seq(0, -2948.80958, -24573.41320, -522922.23257, -1140000, -1140000, - -1140000, -1140000, -1140000, -1140000, -24573.39638, 0) + Seq(0, -2948.8095851378266, -24573.41320418286, -522922.2325710509, -1140000, -1140000, + -1140000, -1140000, -1140000, -1140000, -24573.39638823692, 0) velocities.zip(expectedPowers).foreach { case (velocity, power) => val wecData = new WecRelevantData( @@ -140,20 +134,20 @@ class WecModelSpec extends UnitSpec with DefaultTestData { wecModel.calculateActivePower(ModelState.ConstantState, wecData) val expectedPower = Watts(power) - result should be(expectedPower) + result should be (expectedPower) } } "calculate air density correctly" in { val wecModel = buildWecModel() val testCases = Seq( - (-15.0, 100129.44, 1.35121), - (-5.0, 99535.96, 1.29311), - (0.0, 99535.96, 1.26944), - (5.0, 100129.44, 1.25405), - (20.0, 100129.44, 1.18988), - (25.0, 100427.25, 1.17341), - (37.0, 100427.25, 1.12801), + (-15.0, 100129.44, 1.3512151548083537), + (-5.0, 99535.96, 1.2931147269065832), + (0.0, 99535.96, 1.2694443127219486), + (5.0, 100129.44, 1.25405785444464), + (20.0, 100129.44, 1.1898897909390296), + (25.0, 100427.25, 1.1734149214121568), + (37.0, 100427.25, 1.1280143763309192), // test cases where no air pressure is given (0.0, -1.0, 1.2041), (5.0, -1.0, 1.2041), @@ -175,7 +169,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { "calculate active power output depending on temperature" in { val wecModel = buildWecModel() val temperatures = Seq(35.0, 20.0, -25.0) - val expectedPowers = Seq(-23377.23862, -24573.41320, -29029.60338) + val expectedPowers = Seq(-23377.23862017266 , -24573.41320, -29029.60338) temperatures.zip(expectedPowers).foreach { case (temperature, power) => val wecData = new WecRelevantData( From bd78f7e4da9f1dd3f9f6c8a12b732c547872dc4c Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Fri, 26 Jul 2024 10:58:05 +0200 Subject: [PATCH 30/31] add unit in test "calculate active power output depending on temperature" --- .../model/participant/WecModelSpec.scala | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index f5bfbf9bf7..a88231c035 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -23,6 +23,7 @@ import squants.energy.Watts import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius import squants.Each +import squants.mass.Mass import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE} @@ -121,8 +122,9 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val velocities = Seq(1.0, 2.0, 3.0, 7.0, 9.0, 13.0, 15.0, 19.0, 23.0, 27.0, 34.0, 40.0) val expectedPowers = - Seq(0, -2948.8095851378266, -24573.41320418286, -522922.2325710509, -1140000, -1140000, - -1140000, -1140000, -1140000, -1140000, -24573.39638823692, 0) + Seq(0, -2948.8095851378266, -24573.41320418286, -522922.2325710509, + -1140000, -1140000, -1140000, -1140000, -1140000, -1140000, + -24573.39638823692, 0) velocities.zip(expectedPowers).foreach { case (velocity, power) => val wecData = new WecRelevantData( @@ -134,7 +136,7 @@ class WecModelSpec extends UnitSpec with DefaultTestData { wecModel.calculateActivePower(ModelState.ConstantState, wecData) val expectedPower = Watts(power) - result should be (expectedPower) + result should be(expectedPower) } } @@ -162,14 +164,16 @@ class WecModelSpec extends UnitSpec with DefaultTestData { val airDensity = wecModel .calculateAirDensity(temperatureV, pressureV) .toKilogramsPerCubicMeter - airDensity should be (densityResult) + + airDensity should be(densityResult) } } "calculate active power output depending on temperature" in { val wecModel = buildWecModel() val temperatures = Seq(35.0, 20.0, -25.0) - val expectedPowers = Seq(-23377.23862017266 , -24573.41320, -29029.60338) + val expectedPowers = + Seq(-23377.23862017266, -24573.41320418286, -29029.60338829823) temperatures.zip(expectedPowers).foreach { case (temperature, power) => val wecData = new WecRelevantData( @@ -177,9 +181,11 @@ class WecModelSpec extends UnitSpec with DefaultTestData { Celsius(temperature), Some(Pascals(101325d)), ) - val result = + val result = { wecModel.calculateActivePower(ModelState.ConstantState, wecData) - result shouldBe power + } + val expectedPower = Watts(power) + result shouldBe expectedPower } } } From da88d5c30281cc5da62450d1fcc07863dc1bcf74 Mon Sep 17 00:00:00 2001 From: pierrepetersmeier Date: Fri, 26 Jul 2024 11:44:02 +0200 Subject: [PATCH 31/31] fmt --- .../scala/edu/ie3/simona/model/participant/WecModelSpec.scala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala index a88231c035..8933819773 100644 --- a/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala +++ b/src/test/scala/edu/ie3/simona/model/participant/WecModelSpec.scala @@ -23,7 +23,6 @@ import squants.energy.Watts import squants.motion.{MetersPerSecond, Pascals} import squants.thermal.Celsius import squants.Each -import squants.mass.Mass import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units.{METRE, PERCENT, SQUARE_METRE}