Skip to content

Commit

Permalink
Merge branch 'dev' into ms/#188-consider-none-equivalent-value-for-mi…
Browse files Browse the repository at this point in the history
…ssing-data-pints-in-weather

# Conflicts:
#	src/main/scala/edu/ie3/simona/ontology/messages/services/WeatherMessage.scala
#	src/main/scala/edu/ie3/simona/service/weather/WeatherSource.scala
#	src/test/scala/edu/ie3/simona/service/weather/WeatherSourceSpec.scala
  • Loading branch information
staudtMarius committed Sep 28, 2023
2 parents 4e68320 + 0899335 commit 369d0d9
Show file tree
Hide file tree
Showing 155 changed files with 4,737 additions and 4,003 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed format of example grid `vn_simona` [#216](https://github.com/ie3-institute/simona/issues/216)
- Renamed ChpData to ChpRelevantData [#494](https://github.com/ie3-institute/simona/issues/494)
- Updated gradle to 8.2.1, cleaned up `build.gradle` and `Jenkinsfile` [#572](https://github.com/ie3-institute/simona/issues/572)
- Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435)
- Improved initialization of weather based agents [#145](https://github.com/ie3-institute/simona/issues/145)

### Fixed
- Location of `vn_simona` test grid (was partially in Berlin and Dortmund) [#72](https://github.com/ie3-institute/simona/issues/72)
Expand Down
17 changes: 9 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ plugins {
id 'signing'
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
id 'pmd' // code check, working on source code
id 'com.diffplug.spotless' version '6.20.0'// code format
id "com.github.ben-manes.versions" version '0.47.0'
id "de.undercouch.download" version "5.4.0" // downloads plugin
id 'com.diffplug.spotless' version '6.21.0'// code format
id "com.github.ben-manes.versions" version '0.48.0'
id "de.undercouch.download" version "5.5.0" // downloads plugin
id "kr.motd.sphinx" version "2.10.1" // documentation generation
id "com.github.johnrengelman.shadow" version "8.1.1" // fat jar
id "org.sonarqube" version "4.3.0.3225" // sonarqube
id "org.sonarqube" version "4.3.1.3277" // sonarqube
id "org.scoverage" version "8.0.3" // scala code coverage scoverage
id "com.github.maiflai.scalatest" version "0.32" // run scalatest without specific spec task
id 'org.hidetake.ssh' version '2.11.2'
Expand All @@ -29,9 +29,9 @@ ext {
jtsVersion = '1.19.0'
confluentKafkaVersion = '7.4.0'
tscfgVersion = '1.0.2'
scapegoatVersion = '2.1.2'
scapegoatVersion = '2.1.3'

testContainerVersion = '0.40.17'
testContainerVersion = '0.41.0'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator // location of script plugins
}
Expand Down Expand Up @@ -77,7 +77,7 @@ dependencies {
/* Exclude our own nested dependencies */
exclude group: 'com.github.ie3-institute'
}
implementation('com.github.ie3-institute:PowerSystemDataModel:3.0.0') {
implementation('com.github.ie3-institute:PowerSystemDataModel:4.0.0') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
Expand Down Expand Up @@ -105,7 +105,7 @@ dependencies {
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'org.scalatestplus:mockito-3-4_2.13:3.2.10.0'
testImplementation 'org.mockito:mockito-core:5.5.0' // mocking framework
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.16"
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.17"
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.8' //scalatest html output
testImplementation group: 'org.pegdown', name: 'pegdown', version: '1.6.0'
testImplementation "com.typesafe.akka:akka-testkit_${scalaVersion}:${akkaVersion}" // akka testkit
Expand Down Expand Up @@ -153,6 +153,7 @@ dependencies {
implementation 'org.apache.poi:poi-ooxml:5.2.3' // used for FilenameUtils
implementation 'javax.measure:unit-api:2.2'
implementation 'tech.units:indriya:2.2' // quantities
implementation "org.typelevel:squants_${scalaVersion}:1.8.3"
implementation 'org.apache.commons:commons-csv:1.10.0'
implementation 'org.scalanlp:breeze_2.13:2.1.0' // scientific calculations (http://www.scalanlp.org/)
implementation 'de.lmu.ifi.dbs.elki:elki:0.7.5' // Statistics (for random load model)
Expand Down
2 changes: 2 additions & 0 deletions docs/readthedocs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ simona.input.weather.datasource = {
scheme = "icon"
sampleParams.use = true
coordinateSource.sampleParams.use = true
maxCoordinateDistance = 50000
}
```

Expand All @@ -69,6 +70,7 @@ simona.input.weather.datasource = {

- The sample values should only be used to test the functionality. The performance of a reasonable simulation with sensitive results should be based on real weather data.
- Supported weather data sources are: influxdb1x, csv, sql, couchbase, sample
- The parameter `maxCoordinateDistance` is used to specify the radius in which weather data should be searched in. The given distance should be in meter.

Further model classes which can be used to parse a data set as input to power system simulations are described in [PSDM](https://powersystemdatamodel.readthedocs.io/en/latest/models/models.html#time-series).
Data sources and data sinks are explained in the [I/O-capabilities](https://powersystemdatamodel.readthedocs.io/en/latest/io/basiciousage.html) section of the PSDM.
Expand Down
6 changes: 3 additions & 3 deletions docs/readthedocs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sphinx==5.3.0
sphinx-rtd-theme==1.1.1
sphinxcontrib-plantuml==0.25
sphinx-rtd-theme==1.3.0
sphinxcontrib-plantuml==0.26
myst-parser==1.0.0
markdown-it-py==2.2.0
sphinx-hoverxref==1.3.0
sphinxcontrib-bibtex==2.5.0
sphinxcontrib-bibtex==2.6.1
1 change: 1 addition & 0 deletions input/samples/vn_simona/vn_simona.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ simona.input.weather.datasource = {
scheme = "icon"
sampleParams.use = true
coordinateSource.sampleParams.use = true
maxCoordinateDistance = 50000
}

##################################################################
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/config/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ simona.input.weather.datasource = {
timestampPattern = string
#@optional
resolution = long
maxCoordinateDistance = double | 50000
#@optional
csvParams = BaseCsvParams
#@optional
Expand Down Expand Up @@ -197,6 +198,14 @@ simona.input.weather.datasource = {
sampleParams = {
use: "boolean" | true # dummy parameter to allow sample data
}
#@optional
sqlParams = {
jdbcUrl: string
userName: string
password: string
tableName: string
schemaName: string | "public"
}
}
}
##################################################################
Expand Down
8 changes: 3 additions & 5 deletions src/main/scala/edu/ie3/simona/agent/ValueStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
package edu.ie3.simona.agent

import edu.ie3.simona.util.SimonaConstants
import tech.units.indriya.ComparableQuantity

import javax.measure.quantity.Dimensionless
import squants.Dimensionless

/** Represents a value store to hold data of former ticks
*
Expand Down Expand Up @@ -94,8 +92,8 @@ case object ValueStore {
*/
def forVoltage(
maxTickSpan: Long,
initialPerUnit: ComparableQuantity[Dimensionless]
): ValueStore[ComparableQuantity[Dimensionless]] =
initialPerUnit: Dimensionless
): ValueStore[Dimensionless] =
new ValueStore(
maxTickSpan,
Map(SimonaConstants.FIRST_TICK_IN_SIMULATION -> initialPerUnit)
Expand Down
41 changes: 21 additions & 20 deletions src/main/scala/edu/ie3/simona/agent/grid/DBFSAlgorithm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ import edu.ie3.simona.ontology.messages.VoltageMessage.{
}
import edu.ie3.simona.ontology.trigger.Trigger._
import edu.ie3.simona.util.TickUtil._
import edu.ie3.util.quantities.PowerSystemUnits._
import tech.units.indriya.quantity.Quantities
import edu.ie3.util.scala.quantities.Megavars
import edu.ie3.util.scala.quantities.SquantsUtils.RichElectricPotential
import squants.Each
import squants.energy.Megawatts

import java.time.{Duration, ZonedDateTime}
import java.util.UUID
import javax.measure.quantity.ElectricPotential
import scala.concurrent.{ExecutionContext, Future}

/** Trait that is normally mixed into every [[GridAgent]] to enable distributed
Expand Down Expand Up @@ -213,8 +214,8 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport {
currentSweepNo - 1
)

val refSystemVUnit =
gridAgentBaseData.gridEnv.gridModel.mainRefSystem.nominalVoltage.getUnit
val refSystem =
gridAgentBaseData.gridEnv.gridModel.mainRefSystem

/* Determine the slack node voltage under consideration of the target voltage set point */
val vTarget =
Expand All @@ -223,17 +224,13 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport {
uuid == nodeUuid && isSlack
}
.map(_.vTarget)
.getOrElse(Quantities.getQuantity(1d, PU))
val vSlack = vTarget
.multiply(
gridAgentBaseData.gridEnv.gridModel.mainRefSystem.nominalVoltage
)
.asType(classOf[ElectricPotential])
.to(refSystemVUnit)
.getOrElse(Each(1d))
val vSlack =
refSystem.nominalVoltage.multiplyWithDimensionles(vTarget)

(
vSlack,
Quantities.getQuantity(0, refSystemVUnit)
refSystem.vInSi(0d)
)
} match {
case (slackE, slackF) =>
Expand Down Expand Up @@ -327,14 +324,14 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport {
// To model the exchanged power from the superior grid's point of view, -1 has to be multiplied.
// (Inferior grid is a feed in facility to superior grid, which is negative then). Analogously for load case.
(
refSystem.pInSi(pInPu).multiply(-1),
refSystem.qInSi(qInPu).multiply(-1)
refSystem.pInSi(pInPu) * (-1),
refSystem.qInSi(qInPu) * (-1)
)
case _ =>
/* TODO: As long as there are no multiple slack nodes, provide "real" power only for the slack node */
(
Quantities.getQuantity(0d, MEGAWATT),
Quantities.getQuantity(0d, MEGAVAR)
Megawatts(0d),
Megavars(0d)
)
}
.getOrElse {
Expand All @@ -344,7 +341,11 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport {
}
}
.map { case (nodeUuid, (p, q)) =>
ProvideGridPowerMessage.ExchangePower(nodeUuid, p, q)
ProvideGridPowerMessage.ExchangePower(
nodeUuid,
p,
q
)
}

/* Determine the remaining replies */
Expand Down Expand Up @@ -1100,8 +1101,8 @@ trait DBFSAlgorithm extends PowerFlowSupport with GridResultsSupport {
)
case None =>
(
Quantities.getQuantity(1, PU),
Quantities.getQuantity(0, PU)
Each(1d),
Each(0d)
)
}

Expand Down
Loading

0 comments on commit 369d0d9

Please sign in to comment.