Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FixedfeedModelSpec-convert-groovy-tests-to-scalatest #832

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote PVModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Making configuration of `RefSystem` via config optional [#769](https://github.com/ie3-institute/simona/issues/769)
- Updated PSDM to version 5.1.0 [#835](https://github.com/ie3-institute/simona/issues/835)
- Rewrote 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* © 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.datamodel.models.OperationTime
import edu.ie3.datamodel.models.input.{NodeInput, 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.simona.test.common.UnitSpec
import edu.ie3.util.TimeUtil
import edu.ie3.util.quantities.PowerSystemUnits
import edu.ie3.util.scala.quantities.Sq
import org.scalatest.prop.TableDrivenPropertyChecks
import squants.energy.{Kilowatts, Power, Watts}
import tech.units.indriya.quantity.Quantities

import java.util.UUID

class FixedFeedModelSpec extends UnitSpec with TableDrivenPropertyChecks {
implicit val tolerance: Power = Watts(1d)
"Having a fixed feed model" when {
val 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, PowerSystemUnits.PU),
false,
NodeInput.DEFAULT_GEO_POSITION,
GermanVoltageLevelUtils.LV,
-1,
),
new CosPhiFixed("cosPhiFixed:{(0.0,0.95)}"),
null,
Quantities.getQuantity(282.74d, PowerSystemUnits.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.getOperationTime,
)
pierrepetersmeier marked this conversation as resolved.
Show resolved Hide resolved

val expectedPower = Sq.create(
fixedFeedInput
.getsRated()
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue() * -1 * fixedFeedInput.getCosPhiRated * 1.0,
Kilowatts,
)
pierrepetersmeier marked this conversation as resolved.
Show resolved Hide resolved

"The fixed feed model" should {
"return approximately correct power calculations" in {
val actualModel = new FixedFeedInModel(
fixedFeedInput.getUuid,
fixedFeedInput.getId,
foreSeenOperationInterval,
QControl.apply(fixedFeedInput.getqCharacteristics()),
Sq.create(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please refactor this Sq. here as well :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was marked as resolved accidentially by me. Sorry, please use Kilowatts() here

fixedFeedInput
.getsRated()
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue(),
Kilowatts,
),
fixedFeedInput.getCosPhiRated,
)

actualModel.calculateActivePower(
ModelState.ConstantState,
CalcRelevantData.FixedRelevantData,
) =~ expectedPower
}
}

}
}