Skip to content

Commit 4ced092

Browse files
committed
Extending doctest.
1 parent e47d15d commit 4ced092

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

docs/source/quickstart.rst

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ subclass the appropriate model base class and implement ``equations``:
174174
.. testcode::
175175

176176
import monee.model as mm
177+
from monee import run_energy_flow
177178

178179
@mm.model
179180
class FlexibleLoad(mm.PowerLoad):
@@ -194,10 +195,36 @@ subclass the appropriate model base class and implement ``equations``:
194195
pn = mm.Network(mm.PowerGrid(name="power", sn_mva=1))
195196

196197
child_id = pn.child(FlexibleLoad(c=0.5))
197-
node_id = pn.node(mm.Bus(base_kv=1), grid=mm.EL) # slack
198+
node_id = pn.node(mm.Bus(base_kv=1), child_ids=[pn.child(mm.ExtPowerGrid(p_mw=1, q_mvar=1))], grid=mm.EL) # slack
198199
node_load = pn.node(mm.Bus(base_kv=1), child_ids=[child_id], grid=mm.EL) # load bus
199200
pn.branch(mm.PowerLine(length_m=100, r_ohm_per_m=1e-4, x_ohm_per_m=1e-4, parallel=1),
200201
from_node_id=node_id, to_node_id=node_load, grid=mm.EL)
202+
print(run_energy_flow(pn))
203+
204+
.. testoutput::
205+
206+
SolverResult
207+
208+
Bus (2 instances)
209+
────────────────────────────────────────────────────────────────────
210+
id base_kv vm_pu vm_pu_squared va_radians va_degree p_mw q_mvar
211+
0 1 1 1 1.887e-05 0 -0.003774 -1.424e-07
212+
1 1 1 1 -1.887e-05 -0.001081 0.003773 0
213+
214+
FlexibleLoad (1 instance)
215+
────────────────────────────────────────────────────────────────────
216+
id regulation p_mw q_mvar node_id
217+
0 1 0.003773 0 1
218+
219+
ExtPowerGrid (1 instance)
220+
────────────────────────────────────────────────────────────────────
221+
id regulation p_mw q_mvar vm_pu va_degree node_id
222+
1 1 -0.003774 -1.424e-07 1 0 0
223+
224+
PowerLine (1 instance)
225+
────────────────────────────────────────────────────────────────────
226+
id tap shift br_r br_x g_fr b_fr g_to b_to max_i_ka backup on_off p_from_mw q_from_mvar i_from_ka loading_from_percent p_to_mw q_to_mvar i_to_ka loading_to_percent length_m r_ohm_per_m x_ohm_per_m parallel
227+
(0, 1, 0) 1 0 0.01 0.01 0 0 0 0 3.19 False 1 0.003774 1.424e-07 8.222e-06 2.577e-06 -0.003773 0 8.221e-06 2.577e-06 100 0.0001 0.0001 1
201228

202229
Read the :doc:`concepts/data_model` concept page for the full model contract
203230
and how to implement custom branches and nodes.

src/monee/model/network.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ def branch(
658658
to_node = self.node_by_id_or_create(
659659
to_node_id, auto_node_creator=auto_node_creator, auto_grid_key=auto_grid_key
660660
)
661+
if grid is not None:
662+
grid = self._or_default(grid)
661663
branch = Branch(
662664
model,
663665
from_node_id,

0 commit comments

Comments
 (0)