Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into df/#856-tap-water
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
danielfeismann committed Aug 5, 2024
2 parents 8ba11b0 + f6ea63f commit 33a2be9
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 65 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrote FixedLoadModelTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Rewrote SystemComponentTest from groovy to scala [#646](https://github.com/ie3-institute/simona/issues/646)
- Converting remaining rst files to markdown [#838](https://github.com/ie3-institute/simona/issues/838)
- Merging both `FixedFeedInModelSpec` tests [#870](https://github.com/ie3-institute/simona/issues/870)

### Fixed
- Removed a repeated line in the documentation of vn_simona config [#658](https://github.com/ie3-institute/simona/issues/658)
Expand All @@ -86,6 +87,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Finally fixing `RuntimeEventListenerSpec` [#849](https://github.com/ie3-institute/simona/issues/849)
- Fixed result output for thermal houses and cylindrical storages [#844](https://github.com/ie3-institute/simona/issues/844)
- Fixed FixedFeedModelSpec [#861](https://github.com/ie3-institute/simona/issues/861)
- Fixing duration calculation in result events [#801](https://github.com/ie3-institute/simona/issues/801)
- Fixed Hp results leading to overheating house and other effects [#827](https://github.com/ie3-institute/simona/issues/827)
- Fixed thermal storage getting recharged when empty [#827](https://github.com/ie3-institute/simona/issues/827)

Expand Down
22 changes: 14 additions & 8 deletions src/main/scala/edu/ie3/simona/io/runtime/RuntimeEventLogSink.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import edu.ie3.util.TimeUtil
import org.slf4j.Logger

import java.time.ZonedDateTime
import scala.concurrent.duration.DurationLong

/** Runtime event sink that just logs all received events.
*
Expand All @@ -26,6 +27,7 @@ import java.time.ZonedDateTime
final case class RuntimeEventLogSink(
simulationStartDate: ZonedDateTime,
log: Logger,
private var last: Long = 0L,
) extends RuntimeEventSink {

override def handleRuntimeEvent(
Expand All @@ -43,13 +45,15 @@ final case class RuntimeEventLogSink(

case CheckWindowPassed(tick, duration) =>
log.info(
s"******* Simulation until ${calcTime(tick)} completed. ${durationAndMemoryString(duration)} ******"
s"******* Simulation until ${calcTime(tick)} completed. ${durationAndMemoryString(duration - last)} ******"
)
last = duration

case Ready(tick, duration) =>
log.info(
s"******* Switched from 'Simulating' to 'Ready'. Last simulated time: ${calcTime(tick)}. ${durationAndMemoryString(duration)} ******"
s"******* Switched from 'Simulating' to 'Ready'. Last simulated time: ${calcTime(tick)}. ${durationAndMemoryString(duration - last)} ******"
)
last = duration

case Simulating(startTick, endTick) =>
log.info(
Expand Down Expand Up @@ -84,12 +88,14 @@ final case class RuntimeEventLogSink(
}

private def convertDuration(duration: Long): String = {
val durationInSeconds = duration / 1000

val hours = durationInSeconds / 3600
val minutes = (durationInSeconds / 60) % 60
val seconds = durationInSeconds % 60
s"${hours}h : ${minutes}m : ${seconds}s"
val time = duration.milliseconds

val hours = time.toHours
val minutes = time.toMinutes % 60
val seconds = time.toSeconds % 60
val milliseconds =
(time - hours.hours - minutes.minutes - seconds.seconds).toMillis
s"${hours}h : ${minutes}m : ${seconds}s : ${milliseconds}ms"
}

private def durationAndMemoryString(duration: Long) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class RuntimeEventListenerLoggingSpec
(
InitComplete(0L),
Level.INFO,
s"Initialization complete. (duration: 0h : 0m : 0s )",
s"Initialization complete. (duration: 0h : 0m : 0s : 0ms )",
),
(
Ready(currentTick, 0L),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import edu.ie3.simona.model.participant.load.{LoadModelBehaviour, LoadReference}
import edu.ie3.simona.test.common.input.FixedFeedInputTestData
import edu.ie3.simona.test.common.{DefaultTestData, UnitSpec}
import edu.ie3.simona.util.ConfigUtil
import edu.ie3.util.quantities.PowerSystemUnits
import edu.ie3.util.quantities.PowerSystemUnits.MEGAVOLTAMPERE
import org.scalatest.PrivateMethodTester
import squants.energy.{Kilowatts, Megawatts, Watts}
Expand Down Expand Up @@ -69,5 +70,35 @@ class FixedFeedInModelSpec
cosPhiRated shouldBe fixedFeedInput.getCosPhiRated
}
}

"return approximately correct power calculations" in {
val expectedPower = Kilowatts(
fixedFeedInput
.getsRated()
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue() * -1 * fixedFeedInput.getCosPhiRated
)

val actualModel = new FixedFeedInModel(
fixedFeedInput.getUuid,
fixedFeedInput.getId,
defaultOperationInterval,
QControl.apply(fixedFeedInput.getqCharacteristics()),
Kilowatts(
fixedFeedInput
.getsRated()
.to(PowerSystemUnits.KILOWATT)
.getValue
.doubleValue()
),
fixedFeedInput.getCosPhiRated,
)

actualModel.calculateActivePower(
ModelState.ConstantState,
CalcRelevantData.FixedRelevantData,
) shouldBe expectedPower
}
}
}

This file was deleted.

0 comments on commit 33a2be9

Please sign in to comment.