Skip to content

Commit

Permalink
Merge branch 'jb/#494-rename-chpdata' into jb/#83-implement-chp-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-bao committed Mar 24, 2023
2 parents aa26840 + 506d967 commit c0835b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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 Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
id 'com.diffplug.spotless' version '6.17.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
Expand All @@ -32,7 +32,7 @@ ext {
tscfgVersion = '1.0.0'
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,7 +101,7 @@ 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'
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 @@ -55,7 +55,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 @@ -80,22 +80,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 @@ -113,11 +113,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 @@ -140,7 +140,7 @@ final case class ChpModel(
* next [[ChpState]]
*/
private def calculateStateNotRunningNoDemand(
chpData: ChpData
chpData: ChpRelevantData
): ChpState =
ChpState(
isRunning = false,
Expand All @@ -158,7 +158,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 @@ -175,7 +175,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 @@ -197,7 +197,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 @@ -222,7 +222,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 @@ -251,7 +251,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 @@ -265,12 +265,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 @@ -283,11 +283,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 @@ -319,10 +319,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 @@ -331,7 +331,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 @@ -90,7 +90,7 @@ class ChpModelTest extends Specification {
}

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

static def buildThermalStorage(CylindricalStorageInput storageInput, Double storageLvl) {
Expand Down

0 comments on commit c0835b5

Please sign in to comment.