Circuit#

class popo.network.Circuit(dss=None)#

Bases: object

The circuit currently compiled in OpenDSS.

Examples

>>> circuit = Circuit.load("feeder/Master.dss")
>>> circuit.converged
True
>>> pd.DataFrame(circuit.lines).head()
>>> circuit.bus_voltages().query("bus != @circuit.source_bus")["vmag_pu"].min()
classmethod load(master, solve=True, dss=None)#

Clear the engine, compile master and optionally solve it.

Parameters:
  • master (str | Path) – The OpenDSS master file, the one a script would Redirect to. Files it redirects to are followed.

  • solve (bool) – Run a snapshot power flow after compiling.

  • dss (Any) – As in Circuit.

Return type:

Circuit

Returns:

A handle on the compiled circuit.

property dss: Any#

The opendssdirect module, for anything this class does not cover.

command(text)#

Run an OpenDSS command and return its text result.

The result is what a ? query or an export reports, e.g. the path written. opendssdirect leaves it in Text.Result() rather than returning it, so it is read back here.

Return type:

str

solve()#

Run a power flow in the current solution mode.

Return type:

None

property converged: bool#

Whether the last solve converged.

property bus_names: list[str]#

Every bus in the circuit.

property source_bus: str#

The slack bus. See popo.powerflow.results.source_bus().

property lines: Iterator[Line]#

Every line, in circuit order.

property loads: Iterator[Load]#

Every load, in circuit order.

property transformers: Iterator[Transformer]#

Every transformer, as the record popo.network.read_transformers() produces.

The secondary is the second winding: its bus is where customers connect and its voltage is what separates a distribution transformer from one further upstream.

property pvsystems: Iterator[PVSystem]#

Every PV system, in circuit order.

property storage_units: Iterator[StorageUnit]#

Every storage unit, in circuit order.

opendssdirect exposes only a storage unit’s name, state and state of charge, so the ratings are read with a ? property query.

bus_voltages()#

Per-phase bus voltages. See popo.powerflow.results.bus_voltages().

Return type:

DataFrame

line_currents()#

Per-phase line currents. See popo.powerflow.results.line_currents().

Return type:

DataFrame

line_losses()#

Per-line losses. See popo.powerflow.results.line_losses().

Return type:

DataFrame

element_powers(element_type)#

Per-phase powers of one element type. See popo.powerflow.results.element_powers().

Return type:

DataFrame

summary()#

A one-line health check. See popo.powerflow.results.circuit_summary().

Return type:

dict[str, Any]

solve_time_series(horizon, transformers=None, **kwargs)#

Step the circuit over time. See popo.powerflow.solve_time_series().

Parameters:
  • horizon (int) – Number of steps to solve.

  • transformers (Sequence[Transformer] | DataFrame | None) – Transformers to monitor; defaults to every transformer in the circuit.

  • **kwargs (Any) – Passed through, e.g. start_step or buses.

Return type:

SolveReport

Returns:

The popo.powerflow.SolveReport of the run.