Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Math.floor when calcNextEventTick for charging entities #1257

Merged
merged 6 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactor external simulation setup [#1136](https://github.com/ie3-institute/simona/issues/1136)
- Use new tick retrieval methods from PSDM [#920](https://github.com/ie3-institute/simona/issues/920)
- Refactor input and output configs [#1175](https://github.com/ie3-institute/simona/issues/1175)
- Use `Math.floor` when calcNextEventTick for charging entities [#1256](https://github.com/ie3-institute/simona/issues/1256)

### Fixed
- Fix rendering of references in documentation [#505](https://github.com/ie3-institute/simona/issues/505)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ object ChargingHelper {

// calculate the tick from time span
maybeTimeSpan.map { timeSpan =>
val timeSpanTicks = Math.round(timeSpan.toSeconds)
val timeSpanTicks = Math.floor(timeSpan.toSeconds).toLong
currentTick + timeSpanTicks
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ final case class CylindricalThermalStorage(
val nextThreshold =
if (qDot > zeroKW) {
val duration = (maxEnergyThreshold - updatedEnergy) / qDot
val durationInTicks = Math.round(duration.toSeconds)
val durationInTicks = Math.floor(duration.toSeconds).toLong
if (durationInTicks <= 0L)
None
else
Some(StorageFull(tick + durationInTicks))
} else if (qDot < zeroKW) {
val duration = updatedEnergy / qDot * (-1)
val durationInTicks = Math.round(duration.toSeconds)
val durationInTicks = Math.floor(duration.toSeconds).toLong
if (durationInTicks <= 0L)
None
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,11 @@ final case class ThermalHouse(
if (flexibleEnergy < zeroMWh)
None
else {
val duration = Math.round(
(flexibleEnergy / (qDot * math.signum(qDot.toWatts))).toSeconds
)
val duration = Math
.floor(
(flexibleEnergy / (qDot * math.signum(qDot.toWatts))).toSeconds
)
.toLong
Some(tick + duration)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/edu/ie3/simona/agent/em/EmAgentIT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,22 @@ class EmAgentIT
emResult.getQ should equalWithTolerance(0.0000882855367.asMegaVar)
}

scheduler.expectMessage(Completion(emAgentActivation, Some(13247)))
scheduler.expectMessage(Completion(emAgentActivation, Some(13246)))

/* TICK 13247
/* TICK 13246
LOAD: 0.269 kW (unchanged)
PV: -3.715 kW (unchanged)
STORAGE: SOC 100 %
-> charge with 0 kW
-> remaining -3.447 kW
*/

emAgentActivation ! Activation(13247)
emAgentActivation ! Activation(13246)

resultListener.expectMessageType[ParticipantResultEvent] match {
case ParticipantResultEvent(emResult: EmResult) =>
emResult.getInputModel shouldBe emInput.getUuid
emResult.getTime shouldBe 13247.toDateTime
emResult.getTime shouldBe 13246.toDateTime
emResult.getP should equalWithTolerance(
-0.0034468567291.asMegaWatt
)
Expand Down
Loading