Skip to content

Commit

Permalink
Merge branch 'dev' into sp/#204-EmAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter committed Aug 26, 2022
2 parents 8d3e024 + 8049bc8 commit 801fbeb
Show file tree
Hide file tree
Showing 19 changed files with 81 additions and 70 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ 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.9.1'// code format
id 'com.diffplug.spotless' version '6.10.0'// code format
id 'com.github.onslip.gradle-one-jar' version '1.0.6' // pack a self contained jar
id "com.github.ben-manes.versions" version '0.42.0'
id "de.undercouch.download" version "5.1.1" // downloads plugin
id "de.undercouch.download" version "5.1.2" // downloads plugin
id "kr.motd.sphinx" version "2.10.1" // documentation generation
id "com.github.johnrengelman.shadow" version "7.1.2" // fat jar
id "org.sonarqube" version "3.4.0.2513" // sonarqube
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/edu/ie3/simona/agent/grid/GridAgentData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ object GridAgentData {
.find { case (_, receivedPowerMessages) =>
receivedPowerMessages.exists { case (ref, maybePowerResponse) =>
ref == senderRef &&
(if (!replace)
maybePowerResponse.isEmpty
else
maybePowerResponse.isDefined)
(if (!replace)
maybePowerResponse.isEmpty
else
maybePowerResponse.isDefined)
}
}
.map { case (uuid, _) => uuid }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import java.time.Duration
* the maximum allowed power deviation until convergence in the
* backward-forward-sweep algorithm is reached
* @param epsilon
* Permissible deviation between actual (given) use of the grid (P, Q,
* |V|) and those values determined during iterative solving of the system of
* equations
* Permissible deviation between actual (given) use of the grid (P, Q, |V|)
* and those values determined during iterative solving of the system of
* equations
* @param maxIterations
* Maximum amount of iterations in a [[edu.ie3.powerflow.NewtonRaphsonPF]]
* @param sweepTimeout
Expand Down
7 changes: 3 additions & 4 deletions src/main/scala/edu/ie3/simona/config/ArgsParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

package edu.ie3.simona.config

import java.io.File
import java.nio.file.Paths

import com.typesafe.config.{ConfigFactory, Config => TypesafeConfig}
import com.typesafe.scalalogging.LazyLogging
import edu.ie3.simona.event.listener.SimonaListenerCompanion
import edu.ie3.util.scala.ReflectionTools
import scopt.{OptionParser => scoptOptionParser}

import java.io.File
import java.nio.file.Paths
import scala.jdk.CollectionConverters._

object ArgsParser extends LazyLogging {
Expand Down Expand Up @@ -237,7 +236,7 @@ object ArgsParser extends LazyLogging {
|simona.runtime_configuration {
| selected_subnets = [${parsedArgs.selectedSubnets.getOrElse("")}]
| selected_volt_lvls = [${parsedArgs.selectedVoltLvls
.getOrElse("")}]
.getOrElse("")}]
|}
|""".stripMargin
)
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/edu/ie3/simona/config/ConfigFailFast.scala
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ case object ConfigFailFast extends LazyLogging {
if (!LoadModelBehaviour.isEligibleInput(loadModelConfig.modelBehaviour))
throw new InvalidConfigParameterException(
s"The load model behaviour '${loadModelConfig.modelBehaviour}' for the loads with UUIDs '${loadModelConfig.uuids
.mkString(",")}' is invalid."
.mkString(",")}' is invalid."
)

if (
Expand All @@ -401,7 +401,7 @@ case object ConfigFailFast extends LazyLogging {
)
throw new InvalidConfigParameterException(
s"The standard load profile reference '${loadModelConfig.reference}' for the loads with UUIDs '${loadModelConfig.uuids
.mkString(",")}' is invalid."
.mkString(",")}' is invalid."
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/edu/ie3/simona/io/grid/GridProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object GridProvider {
case _ =>
throw new RuntimeException(
s"No provision of a GridDataSource is not allowed! Please choose from one of the following parameters ${GridSourceType.values
.mkString(", ")}."
.mkString(", ")}."
)
}

Expand Down
8 changes: 3 additions & 5 deletions src/main/scala/edu/ie3/simona/model/grid/GridModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

package edu.ie3.simona.model.grid

import java.time.ZonedDateTime
import java.util.UUID

import breeze.linalg.DenseMatrix
import breeze.math.Complex
import edu.ie3.datamodel.exceptions.InvalidGridException
import edu.ie3.datamodel.models.input.NodeInput
import edu.ie3.datamodel.models.input.connector._
import edu.ie3.datamodel.models.input.container.SubGridContainer
import edu.ie3.simona.exceptions.GridInconsistencyException
Expand All @@ -28,6 +24,8 @@ import org.jgrapht.Graph
import org.jgrapht.alg.connectivity.ConnectivityInspector
import org.jgrapht.graph.{DefaultEdge, SimpleGraph}

import java.time.ZonedDateTime
import java.util.UUID
import scala.collection.immutable.ListSet
import scala.jdk.CollectionConverters._

Expand Down Expand Up @@ -481,7 +479,7 @@ case object GridModel {
if (switchVector.diff(uniqueSwitchNodeIds).nonEmpty) {
throw new InvalidGridException(
s"The grid model for subnet ${gridModel.subnetNo} has nodes with multiple switches. This is not supported yet! Duplicates are located @ nodes: ${switchVector
.diff(uniqueSwitchNodeIds)}"
.diff(uniqueSwitchNodeIds)}"
)
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/scala/edu/ie3/simona/model/grid/LineModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package edu.ie3.simona.model.grid

import java.time.ZonedDateTime
import java.util.UUID
import breeze.math.Complex
import com.typesafe.scalalogging.LazyLogging
import edu.ie3.datamodel.exceptions.InvalidGridException
Expand All @@ -16,18 +14,20 @@ import edu.ie3.simona.model.SystemComponent
import edu.ie3.simona.util.SimonaConstants
import edu.ie3.util.quantities.PowerSystemUnits._
import edu.ie3.util.scala.OperationInterval
import tech.units.indriya.ComparableQuantity
import tech.units.indriya.quantity.Quantities
import tech.units.indriya.unit.Units
import tech.units.indriya.unit.Units._

import java.time.ZonedDateTime
import java.util.UUID
import javax.measure.Quantity
import javax.measure.quantity.{
Dimensionless,
ElectricConductance,
ElectricCurrent,
ElectricResistance
}
import tech.units.indriya.ComparableQuantity
import tech.units.indriya.quantity.Quantities
import tech.units.indriya.unit.Units
import tech.units.indriya.unit.Units._

/** This model represents an electric wire or overhead line
*
Expand Down Expand Up @@ -239,7 +239,7 @@ case object LineModel extends LazyLogging {
)
throw new InvalidGridException(
s"Line ${lineInput.getUuid} (${lineInput.getId}) has a rated voltage of ${lineType
.getvRated()} but is connected to node A (${lineInput.getNodeA.getUuid} / ${lineInput.getNodeA.getId}), which has a rated voltage of $vRatedNodeA."
.getvRated()} but is connected to node A (${lineInput.getNodeA.getUuid} / ${lineInput.getNodeA.getId}), which has a rated voltage of $vRatedNodeA."
)
else if (
lineType
Expand All @@ -248,7 +248,7 @@ case object LineModel extends LazyLogging {
)
throw new InvalidGridException(
s"Line ${lineInput.getUuid} (${lineInput.getId}) has a rated voltage of ${lineType
.getvRated()} but is connected to node B (${lineInput.getNodeB.getUuid} / ${lineInput.getNodeB.getId}), which has a rated voltage of $vRatedNodeB."
.getvRated()} but is connected to node B (${lineInput.getNodeB.getUuid} / ${lineInput.getNodeB.getId}), which has a rated voltage of $vRatedNodeB."
)
else if (
lineType
Expand All @@ -257,7 +257,7 @@ case object LineModel extends LazyLogging {
)
logger.warn(
s"Line ${lineInput.getUuid} (${lineInput.getId}) has a rated voltage of ${lineType
.getvRated()} but is connected to node A (${lineInput.getNodeA.getUuid} / ${lineInput.getNodeA.getId}), which has a lower rated voltage of $vRatedNodeA."
.getvRated()} but is connected to node A (${lineInput.getNodeA.getUuid} / ${lineInput.getNodeA.getId}), which has a lower rated voltage of $vRatedNodeA."
)
else if (
lineType
Expand All @@ -266,7 +266,7 @@ case object LineModel extends LazyLogging {
)
logger.warn(
s"Line ${lineInput.getUuid} (${lineInput.getId}) has a rated voltage of ${lineType
.getvRated()} but is connected to node B (${lineInput.getNodeB.getUuid} / ${lineInput.getNodeB.getId}), which has a lower rated voltage of $vRatedNodeB."
.getvRated()} but is connected to node B (${lineInput.getNodeB.getUuid} / ${lineInput.getNodeB.getId}), which has a lower rated voltage of $vRatedNodeB."
)

// length
Expand Down
30 changes: 18 additions & 12 deletions src/main/scala/edu/ie3/simona/model/grid/PiEquivalentCircuit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

package edu.ie3.simona.model.grid

import java.util.UUID

import breeze.numerics.pow
import com.typesafe.scalalogging.LazyLogging
import edu.ie3.util.quantities.PowerSystemUnits._
import javax.measure.quantity.Dimensionless
import tech.units.indriya.ComparableQuantity
import tech.units.indriya.quantity.Quantities

import java.util.UUID
import javax.measure.quantity.Dimensionless

/** Provides methods to calculate the branch and phase-to-ground susceptance as
* well as conductance of a grid asset to be represented by π equivalent
* circuit.
Expand Down Expand Up @@ -48,11 +48,14 @@ trait PiEquivalentCircuit extends LazyLogging {

private val bVal: Double = b.to(PU).getValue.doubleValue()

/** Computes the branch conductance of the grid element. Formula: y = 1 / (r +
* j*x)
* = (r - j*x) / (r² + x²)
* = (r / (r² + x²)) + j*(-x / (r² + x²))
* -> g = r / (r² + x²)
/** Computes the branch conductance of the grid element. Formula:
*
* {{{
* y = 1 / (r + j*x)
* = (r - j*x) / (r² + x²)
* = (r / (r² + x²)) + j*(-x / (r² + x²))
* -> g = r / (r² + x²)
* }}}
*
* @return
* branch conductance g_ij between node i and j of the element in p.u.
Expand All @@ -68,10 +71,13 @@ trait PiEquivalentCircuit extends LazyLogging {

/** Computes the branch susceptance of the grid element.
*
* Formula: y = 1 / (r + j*x)
* = (r - j*x) / (r² + x²)
* = (r / (r² + x²)) + j*(-x / (r² + x²))
* -> b = -x / (r² + x²)
* Formula:
* {{{
* y = 1 / (r + j*x)
* = (r - j*x) / (r² + x²)
* = (r / (r² + x²)) + j*(-x / (r² + x²))
* -> b = -x / (r² + x²)
* }}}
*
* @return
* branch susceptance b_ij between node i and j of the element in p.u.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,12 @@ object PrimaryServiceProxy {
case Some(x) =>
throw new InvalidConfigParameterException(
s"Invalid configuration '$x' for a time series source.\nAvailable types:\n\t${supportedSources
.mkString("\n\t")}"
.mkString("\n\t")}"
)
case None =>
throw new InvalidConfigParameterException(
s"No configuration for a time series mapping source provided.\nPlease provide one of the available sources:\n\t${supportedSources
.mkString("\n\t")}"
.mkString("\n\t")}"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ object WeatherSource {
if (!WeatherScheme.isEligibleInput(weatherDataSourceCfg.scheme))
throw new InvalidConfigParameterException(
s"The weather data scheme '${weatherDataSourceCfg.scheme}' is not supported. Supported schemes:\n\t${WeatherScheme.values
.mkString("\n\t")}"
.mkString("\n\t")}"
)

// check weather source parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ import edu.ie3.simona.service.weather.WeatherSourceWrapper.WeightSum
import edu.ie3.simona.service.weather.{WeatherSource => SimonaWeatherSource}
import edu.ie3.simona.util.TickUtil
import edu.ie3.simona.util.TickUtil.TickLong
import edu.ie3.util.DoubleUtils.ImplicitDouble
import edu.ie3.util.exceptions.EmptyQuantityException
import edu.ie3.util.interval.ClosedInterval
import edu.ie3.util.DoubleUtils.ImplicitDouble
import tech.units.indriya.quantity.Quantities
import tech.units.indriya.unit.Units

Expand Down Expand Up @@ -341,7 +341,7 @@ private[weather] object WeatherSourceWrapper extends LazyLogging {
case Failure(exception) =>
throw new InitializationException(
s"Error while initializing WeatherFactory for weather source wrapper: '$scheme' is not a weather scheme. Supported schemes:\n\t${WeatherScheme.values
.mkString("\n\t")}'",
.mkString("\n\t")}'",
exception
)
case Success(WeatherScheme.ICON) =>
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/edu/ie3/simona/model/grid/GridSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

package edu.ie3.simona.model.grid

import java.util.UUID

import breeze.linalg.DenseMatrix
import breeze.math.Complex
import breeze.numerics.abs
Expand All @@ -22,6 +20,8 @@ import edu.ie3.simona.test.common.model.grid.{
}
import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec}

import java.util.UUID

class GridSpec extends UnitSpec with LineInputTestData with DefaultTestData {

private val _printAdmittanceMatrixOnMismatch
Expand All @@ -40,7 +40,7 @@ class GridSpec extends UnitSpec with LineInputTestData with DefaultTestData {
)
logger.debug(
s"Mismatch in ($rowIdx, $colIdx): Actual = ${actualMatrix
.valueAt(rowIdx, colIdx)}, expected = ${expectedMatrix.valueAt(rowIdx, colIdx)}"
.valueAt(rowIdx, colIdx)}, expected = ${expectedMatrix.valueAt(rowIdx, colIdx)}"
)
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/scala/edu/ie3/simona/model/grid/LineSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@

package edu.ie3.simona.model.grid

import java.util.UUID

import breeze.math.Complex
import edu.ie3.datamodel.exceptions.InvalidGridException
import edu.ie3.simona.test.common.UnitSpec
import edu.ie3.simona.test.common.input.LineInputTestData
import edu.ie3.simona.test.common.model.grid.FiveLinesWithNodes
import edu.ie3.util.quantities.PowerSystemUnits._
import edu.ie3.util.scala.OperationInterval
import javax.measure.quantity.ElectricCurrent
import tech.units.indriya.ComparableQuantity
import tech.units.indriya.quantity.Quantities
import tech.units.indriya.unit.Units._

import java.util.UUID
import javax.measure.quantity.ElectricCurrent

/** Test class for [[LineModel]]
*/
class LineSpec extends UnitSpec with LineInputTestData {
Expand Down Expand Up @@ -124,7 +124,7 @@ class LineSpec extends UnitSpec with LineInputTestData {
}

exception.getMessage shouldBe s"Line ${lineInputWithTooHighVoltLvlA.getUuid} (${lineInputWithTooHighVoltLvlA.getId}) has a rated voltage of ${lineInputWithTooHighVoltLvlA.getType
.getvRated()} but is connected to node A (${lineInputWithTooHighVoltLvlA.getNodeA.getUuid} / ${lineInputWithTooHighVoltLvlA.getNodeA.getId}), which has a rated voltage of ${lineInputWithTooHighVoltLvlA.getNodeA.getVoltLvl.getNominalVoltage}."
.getvRated()} but is connected to node A (${lineInputWithTooHighVoltLvlA.getNodeA.getUuid} / ${lineInputWithTooHighVoltLvlA.getNodeA.getId}), which has a rated voltage of ${lineInputWithTooHighVoltLvlA.getNodeA.getVoltLvl.getNominalVoltage}."
}

"throw a InvalidGridException if voltage of NodeB does not fit to its nominal line voltage" in {
Expand All @@ -133,7 +133,7 @@ class LineSpec extends UnitSpec with LineInputTestData {
}

exception.getMessage shouldBe s"Line ${lineInputWithTooHighVoltLvlB.getUuid} (${lineInputWithTooHighVoltLvlB.getId}) has a rated voltage of ${lineInputWithTooHighVoltLvlB.getType
.getvRated()} but is connected to node B (${lineInputWithTooHighVoltLvlB.getNodeB.getUuid} / ${lineInputWithTooHighVoltLvlB.getNodeB.getId}), which has a rated voltage of ${lineInputWithTooHighVoltLvlB.getNodeB.getVoltLvl.getNominalVoltage}."
.getvRated()} but is connected to node B (${lineInputWithTooHighVoltLvlB.getNodeB.getUuid} / ${lineInputWithTooHighVoltLvlB.getNodeB.getId}), which has a rated voltage of ${lineInputWithTooHighVoltLvlB.getNodeB.getVoltLvl.getNominalVoltage}."
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ class WeatherSourceSpec extends UnitSpec {
coordinateDistances.corresponds(expectedCoordinateDistances) {
case (a: CoordinateDistance, b: CoordinateDistance) =>
a.getCoordinateA.equalsExact(b.getCoordinateA, 1e-6) &&
a.getCoordinateB.equalsExact(b.getCoordinateB, 1e-6) &&
QuantityUtil.isEquivalentAbs(a.getDistance, b.getDistance, 1e-4)
a.getCoordinateB.equalsExact(b.getCoordinateB, 1e-6) &&
QuantityUtil.isEquivalentAbs(a.getDistance, b.getDistance, 1e-4)
} shouldBe true
case Failure(exception) =>
fail(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ import scala.jdk.CollectionConverters._

/** Contains a valid GridInputModel with the following structure
*
* {{{
* (6) / / trafo (5) /
* | /
* | / (0)--(15)S2(16)-----(3)-----(4)
* | (17) S3 (18)
* | (1)--(13)S1(14)-----(2)
* }}}
*
* Reference System: 400 kVA @ 10 kV
*/
Expand Down
Loading

0 comments on commit 801fbeb

Please sign in to comment.