diff --git a/CHANGELOG.md b/CHANGELOG.md index ce6e71377f..a7819c5e72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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) +- Rewrote FixedFeedModelTest 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/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala index c50b2f6211..dbda236e4c 100644 --- a/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala +++ b/src/main/scala/edu/ie3/simona/model/participant/FixedFeedInModel.scala @@ -68,7 +68,7 @@ final case class FixedFeedInModel( * @return * Active power */ - override protected def calculateActivePower( + override def calculateActivePower( modelState: ConstantState.type, data: FixedRelevantData.type = FixedRelevantData, ): Power = diff --git a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy b/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy deleted file mode 100644 index 268323d95f..0000000000 --- a/src/test/groovy/edu/ie3/simona/model/participant/FixedFeedModelTest.groovy +++ /dev/null @@ -1,79 +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 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.FixedFeedInInput -import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed -import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils -import edu.ie3.simona.model.SystemComponent -import edu.ie3.simona.model.participant.control.QControl -import edu.ie3.util.TimeUtil -import edu.ie3.util.scala.quantities.Sq -import spock.lang.Specification -import squants.energy.* -import tech.units.indriya.quantity.Quantities - -class FixedFeedModelTest extends Specification { - - def fixedFeedInput = new FixedFeedInInput( - UUID.fromString("4eeaf76a-ec17-4fc3-872d-34b7d6004b03"), - "testFixedFeed", - OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited(), - new NodeInput( - UUID.fromString("e5c1cde5-c161-4a4f-997f-fcf31fecbf57"), - "TestNodeInputModel", - OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited(), - Quantities.getQuantity(1d, PU), - false, - NodeInput.DEFAULT_GEO_POSITION, - GermanVoltageLevelUtils.LV, - -1 - ), - new CosPhiFixed("cosPhiFixed:{(0.0,0.95)}"), - null, - Quantities.getQuantity(282.74d, VOLTAMPERE), - 0.95 - ) - def simulationStartDate = TimeUtil.withDefaults.toZonedDateTime("2020-01-01T00:00:00Z") - def simulationEndDate = TimeUtil.withDefaults.toZonedDateTime("2020-12-31T23:59:00Z") - def foreSeenOperationInterval = - SystemComponent.determineOperationInterval( - simulationStartDate, - simulationEndDate, - fixedFeedInput.operationTime - ) - - def expectedPower = Sq.create(fixedFeedInput.sRated.value.doubleValue() * -1 * fixedFeedInput.cosPhiRated * 1.0, Kilowatts$.MODULE$) - - def "A fixed feed model should return approximately correct power calculations"() { - when: - def actualModel = new FixedFeedInModel( - fixedFeedInput.uuid, - fixedFeedInput.id, - foreSeenOperationInterval, - QControl.apply(fixedFeedInput.qCharacteristics), - Sq.create( - fixedFeedInput.sRated - .to(KILOWATT) - .value.doubleValue() - .doubleValue(), - Kilowatts$.MODULE$ - ), - fixedFeedInput.cosPhiRated - ) - - then: - actualModel.calculateActivePower(ModelState.ConstantState$.MODULE$, CalcRelevantData.FixedRelevantData$.MODULE$) =~ expectedPower - } -} diff --git a/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala new file mode 100644 index 0000000000..1de88e0918 --- /dev/null +++ b/src/test/scala/edu/ie3/simona/model/participant/FixedFeedModelSpec.scala @@ -0,0 +1,57 @@ +/* + * © 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 edu.ie3.simona.model.participant.control.QControl +import edu.ie3.simona.test.common.UnitSpec +import edu.ie3.simona.test.common.input.FixedFeedInputTestData +import edu.ie3.util.quantities.PowerSystemUnits +import edu.ie3.util.scala.quantities.Sq +import org.scalatest.prop.TableDrivenPropertyChecks +import squants.energy.{Kilowatts, Power, Watts} + +class FixedFeedModelSpec + extends UnitSpec + with FixedFeedInputTestData + with TableDrivenPropertyChecks { + implicit val tolerance: Power = Watts(1d) + "Having a fixed feed model" when { + + "The fixed feed model" should { + "return approximately correct power calculations" in { + val expectedPower = Kilowatts( + fixedFeedInput + .getsRated() + .to(PowerSystemUnits.KILOWATT) + .getValue + .doubleValue() * -1 * fixedFeedInput.getCosPhiRated + ) + + val actualModel = new FixedFeedInModel( + fixedFeedInput.getUuid, + fixedFeedInput.getId, + defaultOperationInterval, + QControl.apply(fixedFeedInput.getqCharacteristics()), + Kilowatts( + fixedFeedInput + .getsRated() + .to(PowerSystemUnits.KILOWATT) + .getValue + .doubleValue() + ), + fixedFeedInput.getCosPhiRated, + ) + + actualModel.calculateActivePower( + ModelState.ConstantState, + CalcRelevantData.FixedRelevantData, + ) =~ expectedPower + } + } + + } +}