Skip to content

Commit

Permalink
Merge pull request #780 from ie3-institute/ms/#769-make-passing-of-re…
Browse files Browse the repository at this point in the history
…fSystem-via-config-optional

Making passing of `RefSystem` via config optional.
  • Loading branch information
danielfeismann committed Apr 24, 2024
2 parents 0cdf811 + 34c4629 commit 8f73349
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 97 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Validation of grid will throw exception instead of just logging errors [#463](https://github.com/ie3-institute/simona/issues/463)
- 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)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
Expand Down
22 changes: 15 additions & 7 deletions docs/readthedocs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,28 @@ Tba:

## Grid configuration

The reference system contains a list of voltage levels. Each element includes the nominal apparent power, the nominal
voltage and the separate configuration of each voltage level. The voltage level configuration is composed of the identifier
and the nominal voltage.

The configuration of a reference system is optional. If no configuration is provided by the user, the default
[reference system](models/reference_system) that includes all common german voltage levels is used. For those users
who need other voltage levels than the common german voltage levels or different nominal apparent powers, they can configure
their reference systems as shown below.

The reference system can be configured as follows:

```
simona.gridConfig.refSystems = [
{sNom = "100 kVA", vNom = "0.4 kV", voltLvls = [{id = "NS", vNom = "0.4 kV"}]},
{sNom = "60 MVA", vNom = "20 kV", voltLvls = [{id = "MS", vNom = "20 kV"}]},
{sNom = "600 MVA", vNom = "110 kV", voltLvls = [{id = "HS", vNom = "110 kV"}]},
{sNom = "1000 MVA", vNom = "380 kV", voltLvls = [{id = "HoeS", vNom = "380 kV"}]}
{sNom = "100 kVA", vNom = "0.4 kV", voltLvls = [{id = "LV", vNom = "0.4 kV"}]},
{sNom = "60 MVA", vNom = "20 kV", voltLvls = [{id = "MV", vNom = "20 kV"}]},
{sNom = "600 MVA", vNom = "110 kV", voltLvls = [{id = "HV", vNom = "110 kV"}]},
{sNom = "1000 MVA", vNom = "380 kV", voltLvls = [{id = "EHV", vNom = "380 kV"}]}
]
```

The reference system contains a list of voltage levels. Each element includes the nominal apparent power, the nominal voltage and the separate configuration of each voltage level. The voltage level configuration is composed of the identifier and the nominal voltage.

Further typical voltage levels which can be used in the simulation and the configuration of individual reference systems are described in the documentation of [reference system](models/reference_system).
Further typical voltage levels which can be used in the simulation and the configuration of individual reference systems
are described in the documentation of [reference system](models/reference_system).

## Power flow configuration

Expand Down
56 changes: 45 additions & 11 deletions docs/readthedocs/models/reference_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,58 @@

The reference system is built up by specifying the included voltage levels. The following table describes typical network levels and the corresponding parameterization.

## Typical voltage levels
## Default reference system

```{eval-rst}
.. list-table::
:widths: 33 33 33
:header-rows: 0
* - Voltage level (id)
- Nominal voltage (vNom)
- Apparent power (sNom)
* - LV
- 0.4 kV
- 100 kVA
* - MV
- 10 kV
- 40 MVA
* - MV
- 20 kV
- 60 MVA
* - MV
- 30 kV
- 150 MVA
* - HV
- 110 kV
- 600 MVA
* - EHV
- 220 kV
- 800 MVA
* - EHV
- 380 kV
- 1000 MVA
```

| voltage level (id) | nominal voltage (vNom) | apparent power (sNom) |
|--------------------|------------------------|-----------------------|
| NS | 0.4 kV | 100 kVA |
| MS | 20 kV | 60 MVA |
| HS | 110 kV | 600 MVA |
| HoeS | 380 kV | 1000 MVA |

## Configuration of the reference system

To configure the reference system, the voltage levels listed in the table above must be selected and integrated into the reference system with the nominal apparent power (sNom), the nominal voltage (vNom), and the individual voltage level configuration (voltLvls) according to the example below. Each voltage level is composed of the identifier and the nominal voltage.

```
simona.gridConfig.refSystems = [
{sNom = "100 kVA", vNom = "0.4 kV", voltLvls = [{id = "NS", vNom = "0.4 kV"}]},
{sNom = "60 MVA", vNom = "20 kV", voltLvls = [{id = "MS", vNom = "20 kV"}]},
{sNom = "600 MVA", vNom = "110 kV", voltLvls = [{id = "HS", vNom = "110 kV"}]},
{sNom = "1000 MVA", vNom = "380 kV", voltLvls = [{id = "HoeS", vNom = "380 kV"}]}
{sNom = "100 kVA", vNom = "0.4 kV", voltLvls = [{id = "LV", vNom = "0.4 kV"}]},
{sNom = "60 MVA", vNom = "20 kV", voltLvls = [{id = "MV", vNom = "20 kV"}]},
{sNom = "600 MVA", vNom = "110 kV", voltLvls = [{id = "HV", vNom = "110 kV"}]},
{sNom = "1000 MVA", vNom = "380 kV", voltLvls = [{id = "EHV", vNom = "380 kV"}]}
]
```
8 changes: 4 additions & 4 deletions input/samples/vn_simona/vn_simona.conf
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ simona.event.listener = []
##################################################################

simona.gridConfig.refSystems = [
{sNom = "100 kVA", vNom = "0.4 kV", voltLvls = [{id = "NS", vNom = "0.4 kV"}]},
{sNom = "60 MVA", vNom = "20 kV", voltLvls = [{id = "MS", vNom = "20 kV"}]},
{sNom = "600 MVA", vNom = "110 kV", voltLvls = [{id = "HS", vNom = "110 kV"}]},
{sNom = "1000 MVA", vNom = "380 kV", voltLvls = [{id = "HoeS", vNom = "380 kV"}]}
{sNom = "100 kVA", vNom = "0.4 kV", voltLvls = [{id = "LV", vNom = "0.4 kV"}]},
{sNom = "60 MVA", vNom = "20 kV", voltLvls = [{id = "MV", vNom = "20 kV"}]},
{sNom = "600 MVA", vNom = "110 kV", voltLvls = [{id = "HV", vNom = "110 kV"}]},
{sNom = "1000 MVA", vNom = "380 kV", voltLvls = [{id = "EHV", vNom = "380 kV"}]}
]

##################################################################
Expand Down
152 changes: 95 additions & 57 deletions src/main/scala/edu/ie3/simona/config/RefSystemParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@

package edu.ie3.simona.config

import edu.ie3.datamodel.models.voltagelevels.VoltageLevel
import edu.ie3.datamodel.models.voltagelevels.{
GermanVoltageLevelUtils,
VoltageLevel,
}
import edu.ie3.simona.exceptions.InvalidConfigParameterException
import edu.ie3.simona.model.grid.RefSystem
import edu.ie3.simona.util.CollectionUtils
import edu.ie3.util.quantities.PowerSystemUnits
import squants.electro.{Kilovolts, Volts}
import squants.energy.{Kilowatts, Megawatts}

/** Parser to parse [[RefSystem]] provided via [[SimonaConfig]]
*/
object RefSystemParser {

final case class ConfigRefSystems(
private val gridIdRefSystems: Map[Int, RefSystem],
private val voltLvLRefSystems: Map[VoltageLevel, RefSystem],
Expand Down Expand Up @@ -54,72 +58,106 @@ object RefSystemParser {
configRefSystems: List[SimonaConfig.RefSystemConfig]
): ConfigRefSystems = {

// units for parsing are not initialized by default
// hence we call them manually
new PowerSystemUnits
if (configRefSystems.isEmpty) {
// if no config was provided, the default refSystems are used
ConfigRefSystems(
Map.empty,
Map(
GermanVoltageLevelUtils.LV -> RefSystem(Kilowatts(100), Volts(400)),
GermanVoltageLevelUtils.MV_10KV -> RefSystem(
Megawatts(40),
Kilovolts(10),
),
GermanVoltageLevelUtils.MV_20KV -> RefSystem(
Megawatts(60),
Kilovolts(20),
),
GermanVoltageLevelUtils.MV_30KV -> RefSystem(
Megawatts(150),
Kilovolts(30),
),
GermanVoltageLevelUtils.HV -> RefSystem(
Megawatts(600),
Kilovolts(110),
),
GermanVoltageLevelUtils.EHV_220KV -> RefSystem(
Megawatts(800),
Kilovolts(220),
),
GermanVoltageLevelUtils.EHV_380KV -> RefSystem(
Megawatts(1000),
Kilovolts(380),
),
),
)
} else {
// units for parsing are not initialized by default
// hence we call them manually
new PowerSystemUnits

val refSystems = configRefSystems.map { configRefSystem =>
(configRefSystem, RefSystem(configRefSystem.sNom, configRefSystem.vNom))
}

val refSystems = configRefSystems.map { configRefSystem =>
(configRefSystem, RefSystem(configRefSystem.sNom, configRefSystem.vNom))
}
val gridIdRefSystems = refSystems.flatMap {
case (configRefSystem, parsedRefSystem) =>
configRefSystem.gridIds
.map {
_.flatMap { gridId =>
{
val allGridIds = gridId match {
case ConfigConventions.gridIdDotRange(from, to) =>
from.toInt to to.toInt
case ConfigConventions.gridIdMinusRange(from, to) =>
from.toInt to to.toInt
case ConfigConventions.singleGridId(singleGridId) =>
Seq(singleGridId.toInt)
case unknownGridIdFormat =>
throw new InvalidConfigParameterException(
s"Unknown gridId format $unknownGridIdFormat provided for refSystem $configRefSystem"
)
}

val gridIdRefSystems = refSystems.flatMap {
case (configRefSystem, parsedRefSystem) =>
configRefSystem.gridIds
.map {
_.flatMap { gridId =>
{
val allGridIds = gridId match {
case ConfigConventions.gridIdDotRange(from, to) =>
from.toInt to to.toInt
case ConfigConventions.gridIdMinusRange(from, to) =>
from.toInt to to.toInt
case ConfigConventions.singleGridId(singleGridId) =>
Seq(singleGridId.toInt)
case unknownGridIdFormat =>
throw new InvalidConfigParameterException(
s"Unknown gridId format $unknownGridIdFormat provided for refSystem $configRefSystem"
)
allGridIds.map(gridId => (gridId, parsedRefSystem))
}

allGridIds.map(gridId => (gridId, parsedRefSystem))
}
}
}
.getOrElse(Seq.empty[(Int, RefSystem)])
}
.getOrElse(Seq.empty[(Int, RefSystem)])
}

val voltLvlRefSystems = refSystems.flatMap {
case (configRefSystem, parsedRefSystem) =>
configRefSystem.voltLvls
.map {
_.map { voltLvlDef =>
(VoltLvlParser.from(voltLvlDef), parsedRefSystem)
val voltLvlRefSystems = refSystems.flatMap {
case (configRefSystem, parsedRefSystem) =>
configRefSystem.voltLvls
.map {
_.map { voltLvlDef =>
(VoltLvlParser.from(voltLvlDef), parsedRefSystem)
}
}
}
.getOrElse(Seq.empty[(VoltageLevel, RefSystem)])
}
.getOrElse(Seq.empty[(VoltageLevel, RefSystem)])
}

// check for duplicates of gridIds and voltLevels which will be the key for the following map conversion
if (
CollectionUtils.listHasDuplicates(
gridIdRefSystems.map { case (gridId, _) => gridId }
// check for duplicates of gridIds and voltLevels which will be the key for the following map conversion
if (
CollectionUtils.listHasDuplicates(
gridIdRefSystems.map { case (gridId, _) => gridId }
)
)
)
throw new InvalidConfigParameterException(
s"The provided gridIds in simona.gridConfig.refSystems contains duplicates. " +
s"Please check if there are either duplicate entries or overlapping ranges!"
)
if (
CollectionUtils.listHasDuplicates(
voltLvlRefSystems.map { case (voltLvl, _) => voltLvl }
)
)
throw new InvalidConfigParameterException(
s"The provided voltLvls in simona.gridConfig.refSystems contains duplicates. " +
s"Please check your configuration for duplicates in voltLvl entries!"
throw new InvalidConfigParameterException(
s"The provided gridIds in simona.gridConfig.refSystems contains duplicates. " +
s"Please check if there are either duplicate entries or overlapping ranges!"
)
if (
CollectionUtils.listHasDuplicates(
voltLvlRefSystems.map { case (voltLvl, _) => voltLvl }
)
)
throw new InvalidConfigParameterException(
s"The provided voltLvls in simona.gridConfig.refSystems contains duplicates. " +
s"Please check your configuration for duplicates in voltLvl entries!"
)

ConfigRefSystems(gridIdRefSystems.toMap, voltLvlRefSystems.toMap)
ConfigRefSystems(gridIdRefSystems.toMap, voltLvlRefSystems.toMap)
}
}

}
1 change: 0 additions & 1 deletion src/main/scala/edu/ie3/simona/config/VoltLvlParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import edu.ie3.datamodel.models.voltagelevels.{
GermanVoltageLevelUtils,
VoltageLevel,
}
import edu.ie3.simona.config.SimonaConfig.VoltLvlConfig
import edu.ie3.simona.exceptions.InvalidConfigParameterException
import edu.ie3.util.quantities.QuantityUtil
import javax.measure.quantity.ElectricPotential
Expand Down

0 comments on commit 8f73349

Please sign in to comment.