Skip to content

Commit

Permalink
Merge pull request #495 from ie3-institute/jb/#494-rename-chpdata
Browse files Browse the repository at this point in the history
Replaced ChpData
  • Loading branch information
danielfeismann authored Apr 6, 2023
2 parents ed4f7dc + 9bcb232 commit 41dda45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 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
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

0 comments on commit 41dda45

Please sign in to comment.