Skip to content

Commit

Permalink
Merge branch 'dev' into sp/#959-new-participant-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter authored Jan 13, 2025
2 parents 9be9d4e + cdcbd30 commit a622294
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 60 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Create `CITATION.cff` [#1035](https://github.com/ie3-institute/simona/issues/1035)
- Introduce ThermalDemandWrapper [#1049](https://github.com/ie3-institute/simona/issues/1049)
- Added Marius Staudt to list of reviewers [#1057](https://github.com/ie3-institute/simona/issues/1057)
- Throw exception if the slack node is not directly conected to a transformer. [#525](https://github.com/ie3-institute/simona/issues/525)

### Changed
- Adapted to changed data source in PSDM [#435](https://github.com/ie3-institute/simona/issues/435)
Expand Down Expand Up @@ -113,6 +114,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed Deployment stage from Jenkinsfile [#1063](https://github.com/ie3-institute/simona/issues/1063)
- Prepare 'ChpModelSpec' and 'CylindricalThermalStorageSpec' for Storage without storageVolumeLvlMin [#1012](https://github.com/ie3-institute/simona/issues/1012)
- Fixed SonarQube quality gate using the correct parameter '-Dsonar.qualitygate.wait=true' [#1072](https://github.com/ie3-institute/simona/issues/1072)
- Updated `simonaAPI` to version `0.6.0` [#1080](https://github.com/ie3-institute/simona/issues/1080)
- Enhanced title in `CITATION.cff` [#1088](https://github.com/ie3-institute/simona/issues/1088)

### Fixed
- Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505)
Expand Down Expand Up @@ -155,6 +158,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Correct wrong use of term "wall clock time" [#727](https://github.com/ie3-institute/simona/issues/727)
- Fixed Deployment of `simona` to `Maven Central` in new GHA Pipeline [#1029](https://github.com/ie3-institute/simona/issues/1029)
- Fixed SonarQube quality gate using the right link for PRs or Branches [#1061](https://github.com/ie3-institute/simona/issues/1061)
- Fixed ignored EM strategy [#1091](https://github.com/ie3-institute/simona/issues/1091)

## [3.0.0] - 2023-08-07

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cff-version: 1.2.0
title: SIMONA
title: "SIMONA - A Discrete-Event Distribution Grid Simulation Environment"
message: "If you use this software, please cite it as below."
type: software
authors:
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ext {

scalaVersion = '2.13'
scalaBinaryVersion = '2.13.15'
pekkoVersion = '1.1.2'
pekkoVersion = '1.1.3'
jtsVersion = '1.20.0'
confluentKafkaVersion = '7.4.0'
tscfgVersion = '1.2.1'
Expand Down Expand Up @@ -88,7 +88,7 @@ dependencies {
exclude group: 'edu.ie3'
}

implementation('com.github.ie3-institute:simonaAPI:0.5.0') {
implementation('com.github.ie3-institute:simonaAPI:0.6.0') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
Expand Down Expand Up @@ -144,11 +144,11 @@ dependencies {
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.3.0' // used for FilenameUtils
implementation 'org.apache.poi:poi-ooxml:5.4.0' // used for FilenameUtils
implementation 'javax.measure:unit-api:2.2'
implementation 'tech.units:indriya:2.2.2' // quantities
implementation "org.typelevel:squants_${scalaVersion}:1.8.3"
implementation 'org.apache.commons:commons-csv:1.12.0'
implementation 'org.apache.commons:commons-csv:1.13.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)
implementation 'org.jgrapht:jgrapht-core:1.5.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,7 @@ class GridAgentController(
emInput,
modelConfiguration,
outputConfig,
maybeControllingEm
.map(_ => "PRIORITIZED")
.getOrElse("PROPORTIONAL"),
emInput.getControlStrategy,
simulationStartDate,
maybeControllingEm.toRight(
environmentRefs.scheduler
Expand Down
22 changes: 22 additions & 0 deletions src/main/scala/edu/ie3/simona/io/grid/GridProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package edu.ie3.simona.io.grid

import com.typesafe.scalalogging.LazyLogging
import edu.ie3.datamodel.exceptions.{InvalidGridException, SourceException}
import edu.ie3.datamodel.io.naming.FileNamingStrategy
import edu.ie3.datamodel.io.source.csv.{
CsvJointGridContainerSource,
Expand Down Expand Up @@ -51,6 +52,27 @@ object GridProvider extends LazyLogging {
// checks the grid container and throws exception if there is an error
ValidationUtils.check(jointGridContainer)

// check slack node location
val slackSubGrid = jointGridContainer.getSubGridTopologyGraph
.vertexSet()
.asScala
.filter(_.getRawGrid.getNodes.asScala.exists(_.isSlack))
.maxByOption(
_.getPredominantVoltageLevel.getNominalVoltage.getValue
.doubleValue()
)
.getOrElse(
throw new InvalidGridException(
"There is no slack node present in the grid."
)
)

if (slackSubGrid.getRawGrid.getNodes.size() > 1) {
throw new SourceException(
"There are too many nodes in the slack grid. This is currently not support."
)
}

jointGridContainer
case None =>
throw new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ final case class EvModelWrapper(
def id: String = original.getId

lazy val pRatedAc: Power = Kilowatts(
original.getSRatedAC.to(KILOWATT).getValue.doubleValue
original.getPRatedAC.to(KILOWATT).getValue.doubleValue
)
lazy val pRatedDc: Power = Kilowatts(
original.getSRatedDC.to(KILOWATT).getValue.doubleValue
original.getPRatedDC.to(KILOWATT).getValue.doubleValue
)
lazy val eStorage: Energy = KilowattHours(
original.getEStorage.to(KILOWATTHOUR).getValue.doubleValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package edu.ie3.simona.service.ev

import edu.ie3.simona.api.data.ev.ExtEvData
import edu.ie3.simona.api.data.ev.ExtEvDataConnection
import edu.ie3.simona.api.data.ev.model.EvModel
import edu.ie3.simona.api.data.ev.ontology._
import edu.ie3.simona.api.data.ontology.DataMessageFromExt
Expand Down Expand Up @@ -46,7 +46,7 @@ object ExtEvDataService {
)

final case class ExtEvStateData(
extEvData: ExtEvData,
extEvData: ExtEvDataConnection,
uuidToActorRef: Map[UUID, ActorRef] = Map.empty[UUID, ActorRef],
extEvMessage: Option[EvDataMessageFromExt] = None,
freeLots: ReceiveDataMap[UUID, Int] = ReceiveDataMap.empty,
Expand All @@ -55,7 +55,7 @@ object ExtEvDataService {
) extends ServiceBaseStateData

final case class InitExtEvData(
extEvData: ExtEvData
extEvData: ExtEvDataConnection
) extends InitializeServiceStateData

}
Expand Down
30 changes: 13 additions & 17 deletions src/main/scala/edu/ie3/simona/sim/setup/SimonaStandaloneSetup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import edu.ie3.simona.agent.EnvironmentRefs
import edu.ie3.simona.agent.grid.GridAgent
import edu.ie3.simona.agent.grid.GridAgentMessages.CreateGridAgent
import edu.ie3.simona.api.ExtSimAdapter
import edu.ie3.simona.api.data.ExtData
import edu.ie3.simona.api.data.ev.{ExtEvData, ExtEvSimulation}
import edu.ie3.simona.api.data.ExtDataConnection
import edu.ie3.simona.api.data.ev.ExtEvDataConnection
import edu.ie3.simona.api.simulation.ExtSimAdapterData
import edu.ie3.simona.config.{ArgsParser, RefSystemParser, SimonaConfig}
import edu.ie3.simona.event.listener.{ResultEventListener, RuntimeEventListener}
Expand Down Expand Up @@ -219,34 +219,30 @@ class SimonaStandaloneSetup(
)

// setup data services that belong to this external simulation
val (extData, extDataInit): (
Iterable[ExtData],
Iterable[(Class[_ <: SimonaService[_]], ClassicRef)],
) =
extLink.getExtDataSimulations.asScala.zipWithIndex.map {
case (_: ExtEvSimulation, dIndex) =>
extLink.setup(extSimAdapterData)
val extSim = extLink.getExtSimulation

val extDataInit
: Iterable[(Class[_ <: SimonaService[_]], ClassicRef)] =
extSim.getDataConnections.asScala.zipWithIndex.map {
case (evConnection: ExtEvDataConnection, dIndex) =>
val extEvDataService = context.toClassic.simonaActorOf(
ExtEvDataService.props(scheduler.toClassic),
s"$index-$dIndex",
)
val extEvData = new ExtEvData(extEvDataService, extSimAdapter)
evConnection.setActorRefs(extEvDataService, extSimAdapter)

extEvDataService ! SimonaService.Create(
InitExtEvData(extEvData),
InitExtEvData(evConnection),
ScheduleLock.singleKey(
context,
scheduler,
INIT_SIM_TICK,
),
)

(extEvData, (classOf[ExtEvDataService], extEvDataService))
}.unzip

extLink.getExtSimulation.setup(
extSimAdapterData,
extData.toList.asJava,
)
(classOf[ExtEvDataService], extEvDataService)
}

// starting external simulation
new Thread(extLink.getExtSimulation, s"External simulation $index")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public String getId() {
}

@Override
public ComparableQuantity<Power> getSRatedAC() {
public ComparableQuantity<Power> getPRatedAC() {
return sRatedAC;
}

@Override
public ComparableQuantity<Power> getSRatedDC() {
public ComparableQuantity<Power> getPRatedDC() {
return sRatedDC;
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1363,9 +1363,9 @@ class EvcsAgentModelCalculationSpec
resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) =>
flexResult.getInputModel shouldBe evcsInputModelQv.getUuid
flexResult.getTime shouldBe 900.toDateTime
flexResult.getpRef should beEquivalentTo(ev900.unwrap().getSRatedAC)
flexResult.getpMin should beEquivalentTo(ev900.unwrap().getSRatedAC)
flexResult.getpMax should beEquivalentTo(ev900.unwrap().getSRatedAC)
flexResult.getpRef should beEquivalentTo(ev900.unwrap().getPRatedAC)
flexResult.getpMin should beEquivalentTo(ev900.unwrap().getPRatedAC)
flexResult.getpMax should beEquivalentTo(ev900.unwrap().getPRatedAC)
}

emAgent.send(evcsAgent, IssueNoControl(900))
Expand All @@ -1377,7 +1377,7 @@ class EvcsAgentModelCalculationSpec
Kilowatts(
ev900
.unwrap()
.getSRatedAC
.getPRatedAC
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue
Expand Down Expand Up @@ -1431,7 +1431,7 @@ class EvcsAgentModelCalculationSpec
case ParticipantResultEvent(result: EvResult)
if result.getTime.equals(900.toDateTime) =>
result.getInputModel shouldBe ev900.uuid
result.getP should beEquivalentTo(ev900.unwrap().getSRatedAC)
result.getP should beEquivalentTo(ev900.unwrap().getPRatedAC)
result.getQ should beEquivalentTo(0d.asMegaVar)
result.getSoc should beEquivalentTo(0d.asPercent)
case ParticipantResultEvent(result: EvResult)
Expand All @@ -1446,7 +1446,7 @@ class EvcsAgentModelCalculationSpec
case ParticipantResultEvent(result: EvcsResult) =>
result.getInputModel shouldBe evcsInputModelQv.getUuid
result.getTime shouldBe 900.toDateTime
result.getP should beEquivalentTo(ev900.unwrap().getSRatedAC)
result.getP should beEquivalentTo(ev900.unwrap().getPRatedAC)
result.getQ should beEquivalentTo(0d.asMegaVar)
}

Expand Down Expand Up @@ -1480,9 +1480,9 @@ class EvcsAgentModelCalculationSpec
resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) =>
flexResult.getInputModel shouldBe evcsInputModelQv.getUuid
flexResult.getTime shouldBe 4500.toDateTime
flexResult.getpRef should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpMin should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpMax should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpRef should beEquivalentTo(ev4500.unwrap().getPRatedAC)
flexResult.getpMin should beEquivalentTo(ev4500.unwrap().getPRatedAC)
flexResult.getpMax should beEquivalentTo(ev4500.unwrap().getPRatedAC)
}

emAgent.send(evcsAgent, IssueNoControl(4500))
Expand Down Expand Up @@ -1530,9 +1530,9 @@ class EvcsAgentModelCalculationSpec
resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) =>
flexResult.getInputModel shouldBe evcsInputModelQv.getUuid
flexResult.getTime shouldBe 9736.toDateTime
flexResult.getpRef should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpRef should beEquivalentTo(ev4500.unwrap().getPRatedAC)
flexResult.getpMin should beEquivalentTo(0d.asKiloWatt)
flexResult.getpMax should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpMax should beEquivalentTo(ev4500.unwrap().getPRatedAC)
}

emAgent.send(evcsAgent, IssuePowerControl(9736, Kilowatts(10.0)))
Expand Down Expand Up @@ -1595,7 +1595,7 @@ class EvcsAgentModelCalculationSpec
emAgent.send(evcsAgent, FlexActivation(11700))

val combinedChargingPower =
ev11700.unwrap().getSRatedAC.add(ev4500.unwrap().getSRatedAC)
ev11700.unwrap().getPRatedAC.add(ev4500.unwrap().getPRatedAC)
val combinedChargingPowerSq = Kilowatts(
combinedChargingPower.to(PowerSystemUnits.KILOWATT).getValue.doubleValue
)
Expand All @@ -1620,7 +1620,7 @@ class EvcsAgentModelCalculationSpec
flexResult.getTime shouldBe 11700.toDateTime
flexResult.getpRef should beEquivalentTo(combinedChargingPower)
flexResult.getpMin should beEquivalentTo(
ev4500.unwrap().getSRatedAC.multiply(-1)
ev4500.unwrap().getPRatedAC.multiply(-1)
)
flexResult.getpMax should beEquivalentTo(combinedChargingPower)
}
Expand Down Expand Up @@ -1772,7 +1772,7 @@ class EvcsAgentModelCalculationSpec
flexResult.getpMin should beEquivalentTo(
ev4500
.unwrap()
.getSRatedAC
.getPRatedAC
.multiply(
-1
)
Expand Down Expand Up @@ -1965,9 +1965,9 @@ class EvcsAgentModelCalculationSpec
resultListener.expectMsgPF() { case FlexOptionsResultEvent(flexResult) =>
flexResult.getInputModel shouldBe evcsInputModelQv.getUuid
flexResult.getTime shouldBe 36000.toDateTime
flexResult.getpRef should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpRef should beEquivalentTo(ev4500.unwrap().getPRatedAC)
flexResult.getpMin should beEquivalentTo(0.asKiloWatt)
flexResult.getpMax should beEquivalentTo(ev4500.unwrap().getSRatedAC)
flexResult.getpMax should beEquivalentTo(ev4500.unwrap().getPRatedAC)
}

emAgent.send(evcsAgent, IssuePowerControl(36000, Kilowatts(4.0)))
Expand Down
Loading

0 comments on commit a622294

Please sign in to comment.