Skip to content

Commit

Permalink
Merge branch 'dev' into sh/#688-rewrite-pv-model
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/scala/edu/ie3/simona/model/participant/PvModel.scala
  • Loading branch information
SimonHuette committed Mar 5, 2024
2 parents 8e8549e + 32b4808 commit 88d1062
Show file tree
Hide file tree
Showing 341 changed files with 19,051 additions and 11,264 deletions.
4 changes: 4 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version = 3.7.3
runner.dialect = scala213

rewrite.trailingCommas.style = multiple
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Instantiation of Heat Pump Agents [#253](https://github.com/ie3-institute/simona/issues/253)
- Output of accompanying thermal result models
- Added JDK installation, Scala Plugin + SDK in usersguide [#324](https://github.com/ie3-institute/simona/issues/324)
- Squants scalatest matchers [#715](https://github.com/ie3-institute/simona/issues/715)
- Energy Management capabilities:
- Added capability of SystemParticipants to handle flexibility [#308](https://github.com/ie3-institute/simona/issues/308)
- Added smart charging logic [#31](https://github.com/ie3-institute/simona/issues/31) and flex calculation in `EvcsAgent` [#332](https://github.com/ie3-institute/simona/issues/332)
- Enhance output quotes of `RunSimona` [#743](https://github.com/ie3-institute/simona/issues/743)
- Printing logs of failed tests [#747](https://github.com/ie3-institute/simona/issues/747)
- Models for measurements within the grid structure [#89](https://github.com/ie3-institute/simona/issues/89)
- Config possibility for transformer control groups [#90](https://github.com/ie3-institute/simona/issues/90)

### Changed
- Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435)
Expand All @@ -26,13 +34,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adapting to simonaAPI 0.3.0 (adapted message protocol)
- Schedule lock [#651](https://github.com/ie3-institute/simona/issues/651)
- New scheduling protocol [#650](https://github.com/ie3-institute/simona/issues/650)
- Small improvements to the code [#696](https://github.com/ie3-institute/simona/issues/696)
- Replaced akka with pekko [#641](https://github.com/ie3-institute/simona/issues/641)
- Use `ThermalGrid` to calculate thermal environment of a heat pump [#315](https://github.com/ie3-institute/simona/issues/315)
- Enable windows path as config parameters [#549](https://github.com/ie3-institute/simona/issues/549)
- Unified consideration of scaling factor when simulating system participants [#81](https://github.com/ie3-institute/simona/issues/81)
- Small improvements in `ResultEventListener` [#738](https://github.com/ie3-institute/simona/issues/738)
- Converting `SimonaSim` to pekko typed/terminating SimonSim when initialization fails [#210](https://github.com/ie3-institute/simona/issues/210)
- Converting the `GridAgent` and the `DBFSAlgorithm` to `pekko typed` [#666](https://github.com/ie3-institute/simona/issues/666)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
- Removed version number "2.0" from the logo printed to console [#642](https://github.com/ie3-institute/simona/issues/642)
- Fixed PV Model documentation [#684](https://github.com/ie3-institute/simona/issues/684), [#686](https://github.com/ie3-institute/simona/issues/686)
- 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)
- Fixing randomly failing test in `RuntimeEventListenerSpec` etc. [#709](https://github.com/ie3-institute/simona/issues/709)

## [3.0.0] - 2023-08-07

Expand Down
29 changes: 12 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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.23.3'// code format
id "com.github.ben-manes.versions" version '0.50.0'
id "de.undercouch.download" version "5.5.0" // downloads plugin
id 'com.diffplug.spotless' version '6.25.0'// code format
id "com.github.ben-manes.versions" version '0.51.0'
id "de.undercouch.download" version "5.6.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.4.1.3373" // sonarqube
Expand All @@ -24,14 +24,14 @@ ext {
javaVersion = JavaVersion.VERSION_17

scalaVersion = '2.13'
scalaBinaryVersion = '2.13.12'
pekkoVersion = '1.0.1'
scalaBinaryVersion = '2.13.13'
pekkoVersion = '1.0.2'
jtsVersion = '1.19.0'
confluentKafkaVersion = '7.4.0'
tscfgVersion = '1.0.2'
scapegoatVersion = '2.1.3'
tscfgVersion = '1.0.0'
scapegoatVersion = '2.1.5'

testContainerVersion = '0.41.0'
testContainerVersion = '0.41.3'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator // location of script plugins
}
Expand Down Expand Up @@ -67,11 +67,6 @@ repositories {
}

dependencies {
constraints {
implementation( 'com.fasterxml.jackson.core:jackson-databind:2.16.0+' ){
because "[CVE-2020-25649] CWE-611: Improper Restriction of XML External Entity Reference ('XXE')"
}
}

// ie³ internal repository
implementation('com.github.ie3-institute:PowerSystemUtils:2.0') {
Expand Down Expand Up @@ -102,13 +97,13 @@ dependencies {

/* logging */
implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:3.9.5" // pekko scala logging
implementation "ch.qos.logback:logback-classic:1.4.14"
implementation "ch.qos.logback:logback-classic:1.5.3"

/* testing */
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.8.0' // mocking framework
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.17"
testImplementation 'org.mockito:mockito-core:5.11.0' // mocking framework
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.18"
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.8' //scalatest html output
testImplementation group: 'org.pegdown', name: 'pegdown', version: '1.6.0'
testImplementation "org.apache.pekko:pekko-testkit_${scalaVersion}:${pekkoVersion}" // pekko testkit
Expand Down Expand Up @@ -147,7 +142,7 @@ dependencies {
/* Kafka */
implementation "org.apache.kafka:kafka-clients:${confluentKafkaVersion}-ccs"
implementation "io.confluent:kafka-streams-avro-serde:${confluentKafkaVersion}"
implementation "com.sksamuel.avro4s:avro4s-core_${scalaVersion}:4.1.1"
implementation "com.sksamuel.avro4s:avro4s-core_${scalaVersion}:4.1.2"

implementation 'org.apache.commons:commons-math3:3.6.1' // apache commons math3
implementation 'org.apache.poi:poi-ooxml:5.2.5' // used for FilenameUtils
Expand Down
39 changes: 39 additions & 0 deletions docs/readthedocs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,42 @@ Secondary convergence criterion for the power flow calculation is the number of
Resolution of the power flow calculation:

`simona.powerflow.resolution = "3600s"`

## Transformer Control Group configuration

It's possible to add a voltage control function to a transformer or group of transformers. This requires measurements within the network to be under voltage control and at least one corresponding transformer.
The voltage control will attempt to adjust the voltage by changing the tap position of the corresponding transformer. If changing the tap position would cause a voltage limit to be exceeded, the initial voltage deviation cannot be reduced by the voltage control system.

Transformer control groups must contain at least one transformer and one measurement. And can be configured as shown in this example for two transformer control groups:
```
simona.control.transformer = [
{
transformers = ["31a2b9bf-e785-4475-aa44-1c34646e8c79"],
measurements = ["923f2d69-3093-4198-86e4-13d2d1c220f8"],
vMin = 0.98,
vMax = 1.02
}
, {
transformers = ["1132dbf4-e8a1-44ae-8415-f42d4497aa1d"],
measurements = ["7686b818-a0ba-465c-8e4e-f7d3c4e171fc"],
vMin = 0.98,
vMax = 1.02
}
]
```

UUID of transformer in control group:

`transformers = ["31a2b9bf-e785-4475-aa44-1c34646e8c79"]`

UUID of measurement in control group:

`measurements = ["923f2d69-3093-4198-86e4-13d2d1c220f8"]`

Minimum Voltage Limit in p.u.:

`vMin = 0.98`

Maximum Voltage Limit in p.u.:

`vMax = 1.02`
8 changes: 8 additions & 0 deletions docs/readthedocs/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ models/load_model
models/pv_model
models/wec_model
```

## Measurement and Control
```{toctree}
---
maxdepth: 1
---
models/measurement_control
```
2 changes: 1 addition & 1 deletion docs/readthedocs/models/cts_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This storage model operates on volumes, although the functions it provides for o

## Attributes, Units and Remarks

Please refer to {doc}`PowerSystemDataModel - CTS Model <psdm:models/input/participant/cylindricalstorage>` for Attributes and Units used in this Model.
Please refer to {doc}`PowerSystemDataModel - CTS Model <psdm:models/input/thermal/cylindricalstorage>` for Attributes and Units used in this Model.

## Calculations
### Maximal storage capacity
Expand Down
5 changes: 5 additions & 0 deletions docs/readthedocs/models/measurement_control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(measurement_control)=

# Transformer Control Groups

Transformer control group can be used to implement control functionalities like long-range control for active voltage stability. For this purpose, network areas and transformers can be logically linked to a control group via measuring points. If a deviation from the target voltage magnitude is detected at one of the measuring points, the transformer is switched to the appropriate tap position to solve the deviation, provided that no limit values are violated at other measuring points. This requires that only measuring points are included in control groups that can also be influenced by the associated transformer.
2 changes: 1 addition & 1 deletion docs/readthedocs/models/thermal_grid_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ The Thermal Grid Model introduces a coupling point to thermal system, equivalent

## Attributes, Units and Remarks

Please refer to {doc}`PowerSystemDataModel - Thermal Bus <psdm:models/input/participant/thermalbus>` for Attributes and Units used in this Model.
Please refer to {doc}`PowerSystemDataModel - Thermal Bus <psdm:models/input/thermal/thermalbus>` for Attributes and Units used in this Model.
4 changes: 2 additions & 2 deletions docs/readthedocs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Sphinx==7.2.6
sphinx-rtd-theme==2.0.0
sphinxcontrib-plantuml==0.27
sphinxcontrib-plantuml==0.28
myst-parser==2.0.0
markdown-it-py==3.0.0
sphinx-hoverxref==1.3.0
sphinxcontrib-bibtex==2.6.1
sphinxcontrib-bibtex==2.6.2
2 changes: 1 addition & 1 deletion gradle/scripts/scoverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://github.com/scoverage/gradle-scoverage/issues/109 for details

scoverage {
scoverageVersion = "2.0.11"
scoverageVersion = "2.1.0"
scoverageScalaVersion = scalaBinaryVersion
coverageOutputHTML = false
coverageOutputXML = true
Expand Down
2 changes: 1 addition & 1 deletion gradle/scripts/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ spotless {

//sets a license header, removes unused imports and formats conforming to the scala fmt formatter
scala {
scalafmt()
scalafmt().configFile(".scalafmt.conf")
licenseHeader ie3LicHead, "package.*\\n"
}

Expand Down
14 changes: 14 additions & 0 deletions input/samples/vn_simona/vn_simona.conf
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,17 @@ simona.powerflow.newtonraphson.epsilon = [1E-12]
simona.powerflow.newtonraphson.iterations = 50
simona.powerflow.resolution = "3600s"
simona.powerflow.stopOnFailure = true

simona.control.transformer = [
{
transformers = ["31a2b9bf-e785-4475-aa44-1c34646e8c79"],
measurements = ["923f2d69-3093-4198-86e4-13d2d1c220f8"],
vMin = 0.98,
vMax = 1.02
}, {
transformers = ["1132dbf4-e8a1-44ae-8415-f42d4497aa1d"],
measurements = ["7686b818-a0ba-465c-8e4e-f7d3c4e171fc"],
vMin = 0.98,
vMax = 1.02
}
]
20 changes: 20 additions & 0 deletions src/main/resources/config/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ WecRuntimeConfig {
EvcsRuntimeConfig {
baseRuntimeConfig: BaseRuntimeConfig # this entry is ignored by the config generator,
# but cannot removed bc otherwise EvcsRuntimeConfig is handled as String
chargingStrategy: String | "maxPower" # can be one of maxPower, constantPower, gridOrientedScheduling or marketOrientedScheduling
lowestEvSoc: Double | 0.2 # Defines the lowest possible state of charge (SoC) that an EV is allowed to uncharge in vehicle to grid (V2G) mode
}

#@define extends BaseRuntimeConfig
Expand Down Expand Up @@ -111,6 +113,7 @@ SimpleOutputConfig {
ParticipantBaseOutputConfig {
base: BaseOutputConfig
powerRequestReply: boolean # Inform listeners about power request replies
flexResult: boolean | false
}

#@define
Expand All @@ -123,6 +126,14 @@ GridOutputConfig {
transformers3w: boolean | false
}

#@define
TransformerControlGroup {
measurements: [string]
transformers: [string]
vMax: Double
vMin: Double
}

##################################################################
# Agentsim
##################################################################
Expand Down Expand Up @@ -257,6 +268,7 @@ simona.output.thermal = {
defaultConfig = SimpleOutputConfig
individualConfigs = [SimpleOutputConfig]
}
simona.output.flex = Boolean | false

##################################################################
# Runtime Configuration // todo refactor as this naming is misleading
Expand Down Expand Up @@ -329,3 +341,11 @@ simona.event.listener = [
eventsToProcess = [string]
}
]

##################################################################
# Configuration of Control Schemes
##################################################################
#@optional
simona.control = {
transformer = [TransformerControlGroup]
}
2 changes: 1 addition & 1 deletion src/main/scala/edu/ie3/simona/actor/ActorUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.apache.pekko.actor.typed.scaladsl.{ActorContext, Behaviors}
object ActorUtil {
def stopOnError[M](
ctx: ActorContext[M],
msg: String
msg: String,
): Behavior[M] = {
ctx.log.error(s"$msg. Stopping.")
Behaviors.stopped
Expand Down
20 changes: 15 additions & 5 deletions src/main/scala/edu/ie3/simona/actor/SimonaActorNaming.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

package edu.ie3.simona.actor

import org.apache.pekko.actor.{ActorRef, ActorRefFactory, Props}
import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.typed.scaladsl.adapter.TypedActorRefOps
import org.apache.pekko.actor.{ActorRefFactory, Props, ActorRef => ClassicRef}

import java.util.UUID

Expand All @@ -15,10 +17,10 @@ object SimonaActorNaming {
implicit class RichActorRefFactory(private val refFactory: ActorRefFactory)
extends AnyVal {

def simonaActorOf(props: Props, actorId: String): ActorRef =
def simonaActorOf(props: Props, actorId: String): ClassicRef =
refFactory.actorOf(props, actorName(props, actorId))

def simonaActorOf(props: Props): ActorRef =
def simonaActorOf(props: Props): ClassicRef =
refFactory.actorOf(props, actorName(props, simonaActorUuid))
}

Expand Down Expand Up @@ -62,13 +64,13 @@ object SimonaActorNaming {
def actorName(typeName: String, actorId: String): String =
s"${typeName}_${cleanActorIdForPekko(actorId)}"

/** Extracts the actor name from given [[ActorRef]]. Cluster singletons are
/** Extracts the actor name from given [[ClassicRef]]. Cluster singletons are
* taken care of separately.
*
* @return
* the actor name extract from the ActorRef
*/
def actorName(actorRef: ActorRef): String =
def actorName(actorRef: ClassicRef): String =
actorRef.path.name match {
case "singleton" =>
// singletons end in /${actorName}/singleton
Expand All @@ -77,6 +79,14 @@ object SimonaActorNaming {
other
}

/** Extracts the actor name from given [[ActorRef]]. Cluster singletons are
* taken care of separately.
*
* @return
* the actor name extract from the ActorRef
*/
def actorName(actorRef: ActorRef[_]): String = actorName(actorRef.toClassic)

/** Constructs the type name from given props.
*
* @return
Expand Down
15 changes: 9 additions & 6 deletions src/main/scala/edu/ie3/simona/agent/EnvironmentRefs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

package edu.ie3.simona.agent

import org.apache.pekko.actor.ActorRef
import edu.ie3.simona.event.RuntimeEvent
import edu.ie3.simona.ontology.messages.SchedulerMessage
import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.{ActorRef => ClassicRef}

/** Container class, that gather together reference to relevant entities, that
* represent the environment in the simulation
Expand All @@ -23,9 +26,9 @@ import org.apache.pekko.actor.ActorRef
* Reference to the EV data service, if existing
*/
final case class EnvironmentRefs(
scheduler: ActorRef,
runtimeEventListener: ActorRef,
primaryServiceProxy: ActorRef,
weather: ActorRef,
evDataService: Option[ActorRef]
scheduler: ActorRef[SchedulerMessage],
runtimeEventListener: ActorRef[RuntimeEvent],
primaryServiceProxy: ClassicRef,
weather: ClassicRef,
evDataService: Option[ClassicRef],
)
2 changes: 1 addition & 1 deletion src/main/scala/edu/ie3/simona/agent/SimonaAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait SimonaAgent[D]
case Event(Status.Failure(ex), _) =>
log.error(
ex,
"Received a failure status message with following exception."
"Received a failure status message with following exception.",
)
self ! PoisonPill
stay()
Expand Down
Loading

0 comments on commit 88d1062

Please sign in to comment.