Skip to content

Commit

Permalink
Merge branch 'dev' into sp/#719-trailing-commas
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala
  • Loading branch information
danielfeismann committed Feb 9, 2024
2 parents c3f3f5a + 48fde60 commit 8d93ad9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed `CsvDataSourceAdapter` workaround [#702](https://github.com/ie3-institute/simona/issues/702)
- Logging wrong duration in the first simulation hour [#705](https://github.com/ie3-institute/simona/issues/705)
- Fixed some compiler warnings [#657](https://github.com/ie3-institute/simona/issues/657)
- Fixing false negative in ref system voltage validation [#706](https://github.com/ie3-institute/simona/issues/706)

## [3.0.0] - 2023-08-07

Expand Down
75 changes: 36 additions & 39 deletions src/main/scala/edu/ie3/simona/model/grid/RefSystem.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ package edu.ie3.simona.model.grid
import breeze.math.Complex
import edu.ie3.util.quantities.PowerSystemUnits
import edu.ie3.util.scala.quantities.{ReactivePower, Vars}
import squants.Each
import squants.electro.Kilovolts
import squants.electro._
import squants.energy.{Megawatts, Watts}
import squants.{Dimensionless, Each, Power}
import tech.units.indriya.quantity.Quantities

import javax.measure.quantity.{ElectricPotential, Power}

/** Provides the values a [[GridModel]] is referenced to as well as functions to
* reference some standard parameters to the nominal impedance.
*/

final case class RefSystem private (
nominalVoltage: squants.electro.ElectricPotential,
nominalCurrent: squants.electro.ElectricCurrent,
nominalPower: squants.Power,
nominalImpedance: squants.electro.ElectricalResistance,
nominalVoltage: ElectricPotential,
nominalCurrent: ElectricCurrent,
nominalPower: Power,
nominalImpedance: ElectricalResistance,
) {

/** Calculates the referenced resistance r (real part of impedance z) of a
Expand All @@ -36,8 +33,8 @@ final case class RefSystem private (
* referenced resistance r in p.u.
*/
def rInPu(
r: squants.electro.ElectricalResistance
): squants.Dimensionless = {
r: ElectricalResistance
): Dimensionless = {
Each(r.toOhms / nominalImpedance.toOhms)
}

Expand All @@ -50,8 +47,8 @@ final case class RefSystem private (
* referenced reactance x in p.u.
*/
def xInPu(
x: squants.electro.ElectricalResistance
): squants.Dimensionless =
x: ElectricalResistance
): Dimensionless =
rInPu(x)

/** Calculates the referenced susceptance b (imaginary part of admittance y)
Expand All @@ -63,8 +60,8 @@ final case class RefSystem private (
* referenced susceptance b in p.u.
*/
def bInPu(
b: squants.electro.ElectricalConductance
): squants.Dimensionless = {
b: ElectricalConductance
): Dimensionless = {
Each(b.toSiemens * nominalImpedance.toOhms)
}

Expand All @@ -77,8 +74,8 @@ final case class RefSystem private (
* referenced conductance g in p.u.
*/
def gInPu(
g: squants.electro.ElectricalConductance
): squants.Dimensionless =
g: ElectricalConductance
): Dimensionless =
bInPu(g)

/** Converts a provided referenced active power value from p.u. into physical
Expand All @@ -89,10 +86,10 @@ final case class RefSystem private (
* @return
* unreferenced active power value in Watt
*/
def pInSi(pInPu: squants.Dimensionless): squants.Power =
def pInSi(pInPu: Dimensionless): Power =
Watts(nominalPower.toWatts * pInPu.toEach)

def pInSi(pInPu: Double): squants.Power =
def pInSi(pInPu: Double): Power =
pInSi(Each(pInPu))

/** Converts a provided active power value from physical SI to referenced p.u.
Expand All @@ -102,7 +99,7 @@ final case class RefSystem private (
* @return
* referenced active power value in p.u.
*/
def pInPu(pInSi: squants.Power): squants.Dimensionless =
def pInPu(pInSi: Power): Dimensionless =
Each(pInSi.toWatts / nominalPower.toWatts)

/** Converts a provided reactive power value from p.u. into physical SI value
Expand All @@ -112,7 +109,7 @@ final case class RefSystem private (
* @return
* unreferenced active power value in Var
*/
def qInSi(qInPu: squants.Dimensionless): ReactivePower =
def qInSi(qInPu: Dimensionless): ReactivePower =
Vars(nominalPower.toWatts * qInPu.toEach)

def qInSi(qInPu: Double): ReactivePower =
Expand All @@ -126,7 +123,7 @@ final case class RefSystem private (
* @return
* referenced active power value in p.u.
*/
def qInPu(qInSi: ReactivePower): squants.Dimensionless =
def qInPu(qInSi: ReactivePower): Dimensionless =
Each(qInSi.toVars / nominalPower.toWatts)

/** Converts a provided voltage value from p.u. into physical SI value
Expand All @@ -137,16 +134,16 @@ final case class RefSystem private (
* unreferenced voltage value in Volt
*/
def vInSi(
vInPu: squants.Dimensionless
): squants.electro.ElectricPotential =
vInPu: Dimensionless
): ElectricPotential =
Kilovolts(nominalVoltage.toKilovolts * vInPu.toEach)

def vInSi(vInPu: Double): squants.electro.ElectricPotential =
def vInSi(vInPu: Double): ElectricPotential =
vInSi(Each(vInPu))

def vInSi(vInPu: Complex): (
squants.electro.ElectricPotential,
squants.electro.ElectricPotential,
ElectricPotential,
ElectricPotential,
) =
(
vInSi(Each(vInPu.real)),
Expand All @@ -161,22 +158,22 @@ final case class RefSystem private (
* referenced voltage value in p.u.
*/
def vInPu(
vInSi: squants.electro.ElectricPotential
): squants.Dimensionless =
vInSi: ElectricPotential
): Dimensionless =
Each(vInSi.toVolts / nominalVoltage.toVolts)
}

case object RefSystem {

def apply(
nominalPower: squants.Power,
nominalVoltage: squants.electro.ElectricPotential,
nominalPower: Power,
nominalVoltage: ElectricPotential,
): RefSystem = {

val nominalCurrent: squants.electro.ElectricCurrent =
val nominalCurrent: ElectricCurrent =
nominalPower / (nominalVoltage * Math.sqrt(3))

val nominalImpedance: squants.electro.ElectricalResistance =
val nominalImpedance: ElectricalResistance =
nominalVoltage / (nominalCurrent * Math.sqrt(3))

new RefSystem(
Expand All @@ -197,15 +194,15 @@ case object RefSystem {
val sNom = Megawatts(
Quantities
.getQuantity(nominalPower)
.asType(classOf[Power])
.asType(classOf[javax.measure.quantity.Power])
.to(PowerSystemUnits.MEGAVOLTAMPERE)
.getValue
.doubleValue()
)
val vNom = Kilovolts(
Quantities
.getQuantity(nominalVoltage)
.asType(classOf[ElectricPotential])
.asType(classOf[javax.measure.quantity.ElectricPotential])
.to(PowerSystemUnits.KILOVOLT)
.getValue
.doubleValue()
Expand All @@ -225,10 +222,10 @@ case object RefSystem {
* Dimensionless impedance with regard the to target reference system
*/
def transferImpedance(
impedance: squants.Dimensionless,
impedance: Dimensionless,
from: RefSystem,
to: RefSystem,
): squants.Dimensionless = {
): Dimensionless = {
val ratio = from.nominalImpedance.toOhms / to.nominalImpedance.toOhms
Each(impedance.toEach * ratio)
}
Expand All @@ -246,10 +243,10 @@ case object RefSystem {
* Dimensionless admittance with regard the to target reference system
*/
def transferAdmittance(
admittance: squants.Dimensionless,
admittance: Dimensionless,
from: RefSystem,
to: RefSystem,
): squants.Dimensionless = {
): Dimensionless = {
val ratio = to.nominalImpedance.toOhms / from.nominalImpedance.toOhms

Each(admittance.toEach * ratio)
Expand Down
20 changes: 12 additions & 8 deletions src/main/scala/edu/ie3/simona/sim/setup/SetupHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

package edu.ie3.simona.sim.setup

import org.apache.pekko.actor.ActorRef
import com.typesafe.config.{Config => TypesafeConfig}
import com.typesafe.scalalogging.LazyLogging
import edu.ie3.datamodel.graph.SubGridGate
Expand All @@ -24,6 +23,9 @@ import edu.ie3.simona.model.grid.RefSystem
import edu.ie3.simona.util.ConfigUtil.{GridOutputConfigUtil, OutputConfigUtil}
import edu.ie3.simona.util.ResultFileHierarchy.ResultEntityPathConfig
import edu.ie3.simona.util.{EntityMapperUtil, ResultFileHierarchy}
import edu.ie3.util.quantities.PowerSystemUnits
import org.apache.pekko.actor.ActorRef
import squants.electro.Kilovolts

/** Methods to support the setup of a simona simulation
*
Expand Down Expand Up @@ -180,15 +182,17 @@ trait SetupHelper extends LazyLogging {
)
)

if (
!refSystem.nominalVoltage.equals(
subGridContainer.getPredominantVoltageLevel.getNominalVoltage
)
val containerPotential = Kilovolts(
subGridContainer.getPredominantVoltageLevel.getNominalVoltage
.to(PowerSystemUnits.KILOVOLT)
.getValue
.doubleValue
)

if (refSystem.nominalVoltage != containerPotential)
logger.warn(
s"The configured RefSystem for subGrid ${subGridContainer.getSubnet} differs in its nominal voltage (${refSystem.nominalVoltage}) from the grids" +
s"predominant voltage level nominal voltage (${subGridContainer.getPredominantVoltageLevel.getNominalVoltage}). If this is by intention and still valid, this " +
s"warning can be just ignored!"
s"predominant voltage level nominal voltage ($containerPotential). If this is by intention and still valid, this warning can be just ignored!"
)

refSystem
Expand Down Expand Up @@ -237,7 +241,7 @@ trait SetupHelper extends LazyLogging {
}
}

case object SetupHelper {
object SetupHelper {

/** Determine a comprehensive collection of all [[ResultEntity]] classes, that
* will have to be considered
Expand Down

0 comments on commit 8d93ad9

Please sign in to comment.