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 @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote PVModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Making configuration of `RefSystem` via config optional [#769](https://github.com/ie3-institute/simona/issues/769)
- Updated PSDM to version 5.1.0 [#835](https://github.com/ie3-institute/simona/issues/835)
- Rewrote 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,58 @@
/*
* © 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 {

val expectedPower = Kilowatts(
fixedFeedInput
.getsRated()
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue() * -1 * fixedFeedInput.getCosPhiRated
)
Comment on lines +24 to +30
Copy link
Member

Choose a reason for hiding this comment

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

Just a format thing, since this expected power belongs to the test return approx correct power calculations just move it down there. Maybe at a later time there will be additional tests here and the expected power should only be valid where it belongs to.


"The fixed feed model" should {
"return approximately correct power calculations" in {
val actualModel = new FixedFeedInModel(
fixedFeedInput.getUuid,
fixedFeedInput.getId,
defaultOperationInterval,
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
}
}

}
}