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

Adding conversion of pv plants into PvInputs. #254

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@ testData/download
!testData/download/targetFolderExistsAndIsFile.zip

# Downloader productive folder
inputData/download
input/download
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Conversion of pv plants into actual PvInputs [#253](https://github.com/ie3-institute/simBench2psdm/issues/253)


## [1.0.0] - 2021-08-03
### Added
- Basic functionality to convert SimBench data sets to [PowerSystemDataModel](https://github.com/ie3-institute/powersystemdatamodel)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext {

scalaVersion = '2.13'
scalaBinaryVersion = '2.13.14'
tscfgVersion = '0.9.986'
tscfgVersion = '1.0.0'
slf4jVersion = '2.0.13'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
Expand Down Expand Up @@ -87,8 +87,8 @@ dependencies {
implementation 'org.mockito:mockito-core:5.12.0' // mocking framework

// config //
implementation 'com.typesafe:config:+'
implementation "com.github.carueda:tscfg_2.13:${tscfgVersion}"
implementation 'com.typesafe:config:1.4.3'
implementation "com.github.carueda:tscfg_2.13:$tscfgVersion"

// cmd args parser //
implementation "com.github.scopt:scopt_${scalaVersion}:+"
Expand Down
2 changes: 1 addition & 1 deletion gradle/scripts/tscfg.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ task genConfigClass {
doLast {
def tscfgJarFile = project.file('build/tscfg-' + tscfgVersion + '.jar')
if (!tscfgJarFile.exists() || !tscfgJarFile.isFile()) {
download {
download.run {
src 'https://github.com/carueda/tscfg/releases/download/v' + tscfgVersion + '/tscfg-' + tscfgVersion + '.jar'
dest buildDir
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions src/main/resources/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ io {
simbenchCodes = ["String"]
input {
download.baseUrl = "String" | "http://141.51.193.167/simbench/gui/usecase/download"
download.folder = "String" | "inputData/download/"
download.folder = "String" | "input/download/"
download.failOnExistingFiles = "Boolean" | false
csv = CsvConfig
}
output {
csv = CsvConfig
targetFolder = "String" | "convertedData"
targetFolder = "String" | "output"
compress = "Boolean" | true
}
}
conversion {
removeSwitches = "Boolean" | false
convertPv = "Boolean" | false
}
15 changes: 8 additions & 7 deletions src/main/scala/edu/ie3/simbench/config/SimbenchConfig.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// generated by tscfg 0.9.986 on Mon Aug 09 20:12:24 CEST 2021
// generated by tscfg 1.0.0 on Mon Jul 08 11:40:43 CEST 2024
// source: src/main/resources/config-template.conf

package edu.ie3.simbench.config
Expand Down Expand Up @@ -38,6 +38,7 @@ object SimbenchConfig {
}

final case class Conversion(
convertPv: scala.Boolean,
removeSwitches: scala.Boolean
)
object Conversion {
Expand All @@ -47,9 +48,9 @@ object SimbenchConfig {
$tsCfgValidator: $TsCfgValidator
): SimbenchConfig.Conversion = {
SimbenchConfig.Conversion(
removeSwitches = c.hasPathOrNull("removeSwitches") && c.getBoolean(
"removeSwitches"
)
convertPv = c.hasPathOrNull("convertPv") && c.getBoolean("convertPv"),
removeSwitches =
c.hasPathOrNull("removeSwitches") && c.getBoolean("removeSwitches")
)
}
}
Expand Down Expand Up @@ -86,7 +87,7 @@ object SimbenchConfig {
),
folder =
if (c.hasPathOrNull("folder")) c.getString("folder")
else "inputData/download/"
else "input/download/"
)
}
}
Expand Down Expand Up @@ -134,7 +135,7 @@ object SimbenchConfig {
),
targetFolder =
if (c.hasPathOrNull("targetFolder")) c.getString("targetFolder")
else "convertedData"
else "output"
)
}
}
Expand Down Expand Up @@ -208,7 +209,7 @@ object SimbenchConfig {
java.lang.String.valueOf(cv.unwrapped())
}

private final class $TsCfgValidator {
final class $TsCfgValidator {
private val badPaths =
scala.collection.mutable.ArrayBuffer[java.lang.String]()

Expand Down
39 changes: 29 additions & 10 deletions src/main/scala/edu/ie3/simbench/convert/GridConverter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ import edu.ie3.simbench.convert.NodeConverter.AttributeOverride.{
JoinOverride,
SubnetOverride
}
import edu.ie3.simbench.convert.ResConverter.ConvertedRes
import edu.ie3.simbench.convert.types.{
LineTypeConverter,
Transformer2wTypeConverter
}
import edu.ie3.simbench.exception.ConversionException
import edu.ie3.simbench.io.ParticipantToInput
import edu.ie3.simbench.model.datamodel._

import scala.annotation.tailrec
Expand All @@ -51,14 +53,18 @@ case object GridConverter extends LazyLogging {
* Total grid input model to be converted
* @param removeSwitches
* Whether or not to remove switches from the grid structure
* @param participantToInput
* Whether or not to convert a given type of participant into actual input
* models
* @return
* A converted [[JointGridContainer]], a [[Vector]] of
* [[IndividualTimeSeries]] as well as a [[Vector]] of [[NodeResult]]s
*/
def convert(
simbenchCode: String,
gridInput: GridModel,
removeSwitches: Boolean
removeSwitches: Boolean,
participantToInput: ParticipantToInput
): (
JointGridContainer,
Vector[IndividualTimeSeries[_ <: PValue]],
Expand All @@ -73,7 +79,7 @@ case object GridConverter extends LazyLogging {
s"Converting system participants and their time series of '${gridInput.simbenchCode}'"
)
val (systemParticipants, timeSeries, timeSeriesMapping) =
convertParticipants(gridInput, nodeConversion)
convertParticipants(gridInput, nodeConversion, participantToInput)

logger.debug(
s"Converting power flow results of '${gridInput.simbenchCode}'"
Expand Down Expand Up @@ -601,13 +607,17 @@ case object GridConverter extends LazyLogging {
* Total grid input model to convert
* @param nodeConversion
* Already known conversion mapping of nodes
* @param participantToInput
* Whether or not to convert a given type of participant into actual input
* models
* @return
* A collection of converted system participants and their individual time
* series
*/
def convertParticipants(
gridInput: GridModel,
nodeConversion: Map[Node, NodeInput]
nodeConversion: Map[Node, NodeInput],
participantToInput: ParticipantToInput
): (
SystemParticipants,
Vector[IndividualTimeSeries[_ <: PValue]],
Expand All @@ -626,14 +636,14 @@ case object GridConverter extends LazyLogging {
logger.debug(
s"Done converting ${gridInput.powerPlants.size} power plants including time series"
)
val resToTimeSeries = convertRes(gridInput, nodeConversion)
val res = convertRes(gridInput, nodeConversion, participantToInput)
logger.debug(
s"Done converting ${gridInput.res.size} RES including time series"
)

/* Map participant uuid onto time series */
val participantsToTimeSeries =
loadsToTimeSeries ++ powerPlantsToTimeSeries ++ resToTimeSeries
loadsToTimeSeries ++ powerPlantsToTimeSeries ++ res.fixedFeedInInput
val mapping = participantsToTimeSeries.map { case (model, timeSeries) =>
new TimeSeriesMappingSource.MappingEntry(
model.getUuid,
Expand All @@ -649,10 +659,10 @@ case object GridConverter extends LazyLogging {
Set.empty[ChpInput].asJava,
Set.empty[EvcsInput].asJava,
Set.empty[EvInput].asJava,
(powerPlantsToTimeSeries.keySet ++ resToTimeSeries.keySet).asJava,
(powerPlantsToTimeSeries.keySet ++ res.fixedFeedInInput.keySet).asJava,
Set.empty[HpInput].asJava,
loadsToTimeSeries.keySet.asJava,
Set.empty[PvInput].asJava,
res.pvInput.asJava,
Set.empty[StorageInput].asJava,
Set.empty[WecInput].asJava
),
Expand Down Expand Up @@ -709,16 +719,25 @@ case object GridConverter extends LazyLogging {
* Total grid input model to convert
* @param nodeConversion
* Already known conversion mapping of nodes
* @param participantToInput
* Whether or not to convert a given type of participant into actual input
* models
* @return
* A mapping from renewable energy source system to their assigned,
* specific time series
*/
def convertRes(
gridInput: GridModel,
nodeConversion: Map[Node, NodeInput]
): Map[FixedFeedInInput, IndividualTimeSeries[PValue]] = {
nodeConversion: Map[Node, NodeInput],
participantToInput: ParticipantToInput
): ConvertedRes = {
val resProfiles =
gridInput.resProfiles.map(profile => profile.profileType -> profile).toMap
ResConverter.convert(gridInput.res, nodeConversion, resProfiles)
ResConverter.convert(
gridInput.res,
nodeConversion,
resProfiles,
participantToInput
)
}
}
Loading