Skip to content

Commit

Permalink
Started implementation of power flow test with switches
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter committed Mar 21, 2023
1 parent b8083f9 commit fca3a94
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package edu.ie3.simona.agent.grid

import akka.event.LoggingAdapter
import breeze.math.Complex
import edu.ie3.powerflow.NewtonRaphsonPF
import edu.ie3.powerflow.model.NodeData.{PresetData, StateData}
Expand All @@ -32,7 +33,8 @@ import scala.util.{Failure, Success, Try}
* [[edu.ie3.powerflow]]
*/
trait PowerFlowSupport {
this: GridAgent =>

protected val log: LoggingAdapter

/** Composes the current operation point needed by
* [[edu.ie3.powerflow.NewtonRaphsonPF.calculate()]]
Expand Down
108 changes: 108 additions & 0 deletions src/test/scala/edu/ie3/simona/agent/grid/PowerFlowSupportSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* © 2023. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/

package edu.ie3.simona.agent.grid

import akka.event.{LoggingAdapter, NoLogging}
import edu.ie3.simona.model.grid.GridModel
import edu.ie3.simona.ontology.messages.VoltageMessage.ProvideSlackVoltageMessage.ExchangeVoltage
import edu.ie3.simona.test.common.UnitSpec
import edu.ie3.simona.test.common.model.grid.BasicGridWithSwitches
import tech.units.indriya.quantity.Quantities
import edu.ie3.util.quantities.PowerSystemUnits._

class PowerFlowSupportSpec
extends UnitSpec
with BasicGridWithSwitches
with PowerFlowSupport {

override val log: LoggingAdapter = NoLogging

"PowerFlowSupport" when {
"switches are closed" must {
"calculate power flow correctly" in {

val gridModel = createGridCopy()

val receivedValuesStore = ReceivedValuesStore
.empty(Map.empty, Map.empty, Vector.empty)
.copy(
nodeToReceivedSlackVoltage = Map(
node6.uuid -> Some(
ExchangeVoltage(
node6.uuid,
Quantities.getQuantity(110, KILOVOLT),
Quantities.getQuantity(0, KILOVOLT)
)
)
)
)

val (operatingPoint, slackNodeVoltages) =
composeOperatingPoint(
gridModel.gridComponents.nodes,
gridModel.gridComponents.transformers,
gridModel.gridComponents.transformers3w,
gridModel.nodeUuidToIndexMap,
receivedValuesStore,
gridModel.mainRefSystem
)

val result = newtonRaphsonPF(
gridModel,
3,
operatingPoint,
slackNodeVoltages
)(Vector(1e-12))

// TODO investigate result
}
}

"switches are opened" must {
"calculate power flow correctly" in {

val gridModel = createGridCopy()
gridModel.gridComponents.switches.foreach(_.open())
GridModel.updateUuidToIndexMap(gridModel)

val receivedValuesStore = ReceivedValuesStore
.empty(Map.empty, Map.empty, Vector.empty)
.copy(
nodeToReceivedSlackVoltage = Map(
node6.uuid -> Some(
ExchangeVoltage(
node6.uuid,
Quantities.getQuantity(110, KILOVOLT),
Quantities.getQuantity(0, KILOVOLT)
)
)
)
)

val (operatingPoint, slackNodeVoltages) =
composeOperatingPoint(
gridModel.gridComponents.nodes,
gridModel.gridComponents.transformers,
gridModel.gridComponents.transformers3w,
gridModel.nodeUuidToIndexMap,
receivedValuesStore,
gridModel.mainRefSystem
)

val result = newtonRaphsonPF(
gridModel,
50,
operatingPoint,
slackNodeVoltages
)(Vector(1e-12))

// TODO investigate result
}
}
}

}

0 comments on commit fca3a94

Please sign in to comment.