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
  • Loading branch information
staudtMarius authored Apr 11, 2023
2 parents 603a6e1 + 41dda45 commit 6024730
Show file tree
Hide file tree
Showing 21 changed files with 92 additions and 109 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updating `CONTRIBUTING.md` [#201](https://github.com/ie3-institute/simona/issues/201)
- Speeding up additionalActivationTicks in participant's BaseStateData [#421](https://github.com/ie3-institute/simona/pull/421)
- 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)

### Fixed
- Location of `vn_simona` test grid (was partially in Berlin and Dortmund) [#72](https://github.com/ie3-institute/simona/issues/72)
Expand All @@ -89,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed groovy formatting [#110](https://github.com/ie3-institute/simona/issues/110)
- Fixed configuration reference in user's guide [#224](https://github.com/ie3-institute/simona/issues/224)
- Fixed ResultEventListener exiting too early with high volumes of results [#350](https://github.com/ie3-institute/simona/issues/350)
- Fixed tests that unreliably fail [#359](https://github.com/ie3-institute/simona/issues/359)

### Removed
- Remove workaround for tscfg tmp directory [#178](https://github.com/ie3-institute/simona/issues/178)
Expand Down
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ 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.16.0'// code format
id 'com.diffplug.spotless' version '6.18.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.46.0'
id "de.undercouch.download" version "5.3.1" // downloads plugin
id "de.undercouch.download" version "5.4.0" // 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 "4.0.0.2929" // sonarqube
id "org.scoverage" version "7.0.1" // 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.0'
id 'org.hidetake.ssh' version '2.11.2'
id 'net.thauvin.erik.gradle.semver' version '1.0.4' // semantic versioning
}

Expand All @@ -32,7 +32,7 @@ ext {
tscfgVersion = '1.0.2'
scapegoatVersion = '1.4.17'

testContainerVersion = '0.40.12'
testContainerVersion = '0.40.14'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator // location of script plugins
}
Expand Down Expand Up @@ -101,12 +101,12 @@ dependencies {

/* logging */
implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:3.9.5" // akka scala logging
implementation "ch.qos.logback:logback-classic:1.4.5"
implementation "ch.qos.logback:logback-classic:1.4.6"

/* testing */
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
testImplementation 'org.scalatestplus:mockito-3-4_2.13:3.2.10.0'
implementation 'org.mockito:mockito-core:5.1.1' // mocking framework
implementation 'org.mockito:mockito-core:5.2.0' // mocking framework
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.15"
testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.64.0' //scalatest html output
testImplementation group: 'org.pegdown', name: 'pegdown', version: '1.6.0'
Expand Down Expand Up @@ -149,7 +149,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.0"
implementation "com.sksamuel.avro4s:avro4s-core_${scalaVersion}:4.1.1"

implementation 'org.apache.commons:commons-math3:3.6.1' // apache commons math3
implementation 'org.apache.poi:poi-ooxml:5.2.3' // used for FilenameUtils
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==6.1.3
sphinx-rtd-theme==1.2.0
sphinxcontrib-plantuml==0.24.1
myst-parser==0.18.1
sphinxcontrib-plantuml==0.25
myst-parser==1.0.0
markdown-it-py==2.2.0
sphinx-hoverxref==1.3.0
sphinxcontrib-bibtex==2.5.0
1 change: 0 additions & 1 deletion gradle/scripts/mavenCentralPublish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ if (project.hasProperty('user') && project.hasProperty('password') && project.ha
from components.java
artifact sourcesJar
artifact javadocJar

}
}
repositories {
Expand Down
1 change: 0 additions & 1 deletion gradle/scripts/sonarqube.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ sonarqube {
property 'sonar.exclusions', [
"src/main/scala/edu/ie3/simona/config/SimonaConfig.scala"
]

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package edu.ie3.simona.event.listener

import akka.actor._
import akka.pattern.pipe
import akka.stream.Materializer
import edu.ie3.datamodel.io.processor.result.ResultEntityProcessor
import edu.ie3.datamodel.models.result.{NodeResult, ResultEntity}
import edu.ie3.simona.agent.grid.GridResultsSupport.PartialTransformer3wResult
Expand Down Expand Up @@ -94,8 +93,6 @@ object ResultEventListener extends Transformer3wResultSupport {
*/
private def initializeSinks(
resultFileHierarchy: ResultFileHierarchy
)(implicit
materializer: Materializer
): Iterable[Future[(Class[_], ResultEntitySink)]] = {
resultFileHierarchy.resultSinkType match {
case _: ResultSinkType.Csv =>
Expand Down Expand Up @@ -177,8 +174,6 @@ class ResultEventListener(
with SimonaFSMActorLogging
with Stash {

implicit private val materializer: Materializer = Materializer(context)

override def preStart(): Unit = {
log.debug("Starting initialization!")
resultFileHierarchy.resultSinkType match {
Expand Down Expand Up @@ -321,6 +316,10 @@ class ResultEventListener(
stash()
stay()

case Event(StopMessage(_), _) =>
stash()
stay()

case Event(Init, _) =>
Future
.sequence(
Expand All @@ -341,6 +340,7 @@ class ResultEventListener(

case Event(Status.Failure(ex), _) =>
throw new InitializationException("Unable to setup SimonaSim.", ex)

}

when(Idle) {
Expand Down
50 changes: 25 additions & 25 deletions src/main/scala/edu/ie3/simona/model/participant/ChpModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final case class ChpModel(
cosPhiRated: Double,
pThermal: ComparableQuantity[Power],
storage: ThermalStorage with MutableStorage
) extends SystemParticipant[ChpData](
) extends SystemParticipant[ChpRelevantData](
uuid,
id,
operationInterval,
Expand All @@ -77,22 +77,22 @@ final case class ChpModel(
* active power
*/
override protected def calculateActivePower(
chpData: ChpData
chpData: ChpRelevantData
): ComparableQuantity[Power] =
chpData.chpState.activePower

/** Given a [[ChpData]] object, containing the [[ChpState]], the heat demand
* and the current time tick, this function calculates the CHPs next state
* while trying to cover the demand. To get the actual active power of this
* state please use [[calculateActivePower]] with the generated state
/** Given a [[ChpRelevantData]] object, containing the [[ChpState]], the heat
* demand and the current time tick, this function calculates the CHPs next
* state while trying to cover the demand. To get the actual active power of
* this state please use [[calculateActivePower]] with the generated state
*
* @param chpData
* state of the chp and heat demand
* @return
* next [[ChpState]]
*/
def calculateNextState(
chpData: ChpData
chpData: ChpRelevantData
): ChpState = generateStateCalculation(chpData)(chpData)

/** Depending on the input, this function returns a fitting 'calculateState'
Expand All @@ -110,11 +110,11 @@ final case class ChpModel(
* @param chpData
* state of the chp and heat demand
* @return
* partially applied function taking a [[ChpData]] object
* partially applied function taking a [[ChpRelevantData]] object
*/
private def generateStateCalculation(
chpData: ChpData
): ChpData => ChpState = {
chpData: ChpRelevantData
): ChpRelevantData => ChpState = {
val isRunning = chpData.chpState.isRunning
val hasDemand = chpData.heatDemand.isGreaterThan(DefaultQuantities.zeroKWH)
val isCovered = isDemandCovered(chpData)
Expand All @@ -137,7 +137,7 @@ final case class ChpModel(
* next [[ChpState]]
*/
private def calculateStateNotRunningNoDemand(
chpData: ChpData
chpData: ChpRelevantData
): ChpState =
ChpState(
isRunning = false,
Expand All @@ -155,7 +155,7 @@ final case class ChpModel(
* next [[ChpState]]
*/
private def calculateStateDemandNotCovered(
chpData: ChpData
chpData: ChpRelevantData
): ChpState = {
val energy = chpEnergy(chpData)
// ChpModel ignores possible lack of energy from prior time steps.
Expand All @@ -172,7 +172,7 @@ final case class ChpModel(
* next [[ChpState]]
*/
private def calculateStateNotRunningDemandCovered(
chpData: ChpData
chpData: ChpRelevantData
): ChpState = {
// Returned lack is always zero, because demand is covered.
storage.tryToTakeAndReturnLack(chpData.heatDemand)
Expand All @@ -194,7 +194,7 @@ final case class ChpModel(
* next [[ChpState]]
*/
private def calculateStateRunningDemandCovered(
chpData: ChpData
chpData: ChpRelevantData
): ChpState = {
val differenceEnergy = chpEnergy(chpData).subtract(chpData.heatDemand)
if (differenceEnergy.isLessThan(DefaultQuantities.zeroKWH)) {
Expand All @@ -219,7 +219,7 @@ final case class ChpModel(
* total energy minus surplus energy
*/
private def calculateStateRunningSurplus(
chpData: ChpData,
chpData: ChpRelevantData,
surplus: Option[ComparableQuantity[Energy]] = None
): ChpState = {
surplus match {
Expand Down Expand Up @@ -248,7 +248,7 @@ final case class ChpModel(
* energy
*/
private def powerToEnergy(
chpData: ChpData,
chpData: ChpRelevantData,
power: ComparableQuantity[Power]
): ComparableQuantity[Energy] =
power.multiply(timeRunning(chpData)).asType(classOf[Energy])
Expand All @@ -262,12 +262,12 @@ final case class ChpModel(
* @return
* is demand covered
*/
private def isDemandCovered(chpData: ChpData) =
private def isDemandCovered(chpData: ChpRelevantData) =
storage.isDemandCoveredByStorage(chpData.heatDemand) || totalUsableEnergy(
chpData
).isGreaterThanOrEqualTo(chpData.heatDemand)

private def chpEnergy(chpData: ChpData): ComparableQuantity[Energy] =
private def chpEnergy(chpData: ChpRelevantData): ComparableQuantity[Energy] =
powerToEnergy(chpData, pThermal)

/** Returns the storage mediums total usable plus the CHP thermal output
Expand All @@ -280,11 +280,11 @@ final case class ChpModel(
* total usable energy
*/
private def totalUsableEnergy(
chpData: ChpData
chpData: ChpRelevantData
): ComparableQuantity[Energy] =
storage.usableThermalEnergy.add(chpEnergy(chpData))

private def timeRunning(chpData: ChpData): ComparableQuantity[Time] =
private def timeRunning(chpData: ChpRelevantData): ComparableQuantity[Time] =
getQuantity(
chpData.currentTimeTick - chpData.chpState.lastTimeTick,
Units.SECOND
Expand Down Expand Up @@ -316,10 +316,10 @@ case object ChpModel {
)

/** Main data required for simulation/calculation, containing a [[ChpState]],
* the heat demand and the current time tick. <p> [[ChpData.currentTimeTick]]
* and [[ChpState.lastTimeTick]] form a time interval for the current state
* calculation. One time tick represents one second (3600 time ticks = 1
* hour).
* the heat demand and the current time tick. <p>
* [[ChpRelevantData.currentTimeTick]] and [[ChpState.lastTimeTick]] form a
* time interval for the current state calculation. One time tick represents
* one second (3600 time ticks = 1 hour).
*
* @param chpState
* a [[ChpState]]
Expand All @@ -328,7 +328,7 @@ case object ChpModel {
* @param currentTimeTick
* contains current time tick
*/
final case class ChpData(
final case class ChpRelevantData(
chpState: ChpState,
heatDemand: ComparableQuantity[Energy],
currentTimeTick: Long
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class ChpModelTest extends Specification {
thermalStorage)
}

static def buildChpData(ChpState chpState, Double heatDemand) {
return new ChpModel.ChpData(chpState, getQuantity(heatDemand, KILOWATTHOUR), 7200)
static def buildChpRelevantData(ChpState chpState, Double heatDemand) {
return new ChpModel.ChpRelevantData(chpState, getQuantity(heatDemand, KILOWATTHOUR), 7200)
}

static def buildThermalStorage(CylindricalStorageInput storageInput, Double storageLvl) {
Expand All @@ -102,7 +102,7 @@ class ChpModelTest extends Specification {
@Unroll
def "Check active power after calculating next state with #chpState and heat demand #heatDemand kWh:"() {
given:
def chpData = buildChpData(chpState, heatDemand)
def chpData = buildChpRelevantData(chpState, heatDemand)
def thermalStorage = buildThermalStorage(storageInput, storageLvl)
def chpModel = buildChpModel(thermalStorage)

Expand All @@ -129,7 +129,7 @@ class ChpModelTest extends Specification {
@Unroll
def "Check total energy after calculating next state with #chpState and heat demand #heatDemand kWh:"() {
given:
def chpData = buildChpData(chpState, heatDemand)
def chpData = buildChpRelevantData(chpState, heatDemand)
def thermalStorage = buildThermalStorage(storageInput, storageLvl)
def chpModel = buildChpModel(thermalStorage)

Expand Down Expand Up @@ -157,7 +157,7 @@ class ChpModelTest extends Specification {

def "Check storage level after calculating next state with #chpState and heat demand #heatDemand kWh:"() {
given:
def chpData = buildChpData(chpState, heatDemand)
def chpData = buildChpRelevantData(chpState, heatDemand)
def thermalStorage = buildThermalStorage(storageInput, storageLvl)
def chpModel = buildChpModel(thermalStorage)

Expand Down Expand Up @@ -185,7 +185,7 @@ class ChpModelTest extends Specification {

def "Check time tick and running status after calculating next state with #chpState and heat demand #heatDemand kWh:"() {
given:
def chpData = buildChpData(chpState, heatDemand)
def chpData = buildChpRelevantData(chpState, heatDemand)
def thermalStorage = buildThermalStorage(storageInput, storageLvl)
def chpModel = buildChpModel(thermalStorage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,5 @@ class EvcsModelTest extends Specification {
50d | 25d | 50d | 25d | 1800L || 100d | 50d | 50d // with non-zero start
50d | 45d | 50d | 35d | 3600L || 20d | 50d | 50d
200d | 25d | 50d | 50d | 3600L || 25d | 50d | 50d

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class HpModelTest extends Specification {
new HpState(true, 0, getQuantity(95, KILOWATT), getQuantity(18, CELSIUS)) || 7200 | true | 95 // tests case (true, false, false)
new HpState(true, 0, getQuantity(95, KILOWATT), getQuantity(22, CELSIUS)) || 7200 | true | 95 // tests case (true, false, false)
new HpState(true, 0, getQuantity(95, KILOWATT), getQuantity(23, CELSIUS)) || 7200 | false | 0 // tests case (true, true, false)

}

def "Check new inner temperature after calculating next state with #hpState:"() {
Expand Down Expand Up @@ -145,7 +144,6 @@ class HpModelTest extends Specification {
new HpState(true, 0, getQuantity(95, KILOWATT), getQuantity(20, CELSIUS)) || 21 // tests case (false, false, false)
new HpState(true, 0, getQuantity(95, KILOWATT), getQuantity(22, CELSIUS)) || 22.6 // tests case (true, false, false)
new HpState(true, 0, getQuantity(95, KILOWATT), getQuantity(23, CELSIUS)) || 20.4 // tests case (true, true, false)

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class PvModelIT extends Specification implements PvModelITHelper {

modelI++
}

}

then: "we expect the calculated result to be quasi equal the provided results data"
Expand Down
Loading

0 comments on commit 6024730

Please sign in to comment.