Commit 1e82c92a authored by Markus Mirz's avatar Markus Mirz
Browse files

remove notebook output

parent 64ee4e17
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="123.83142mm"
height="41.120247mm"
viewBox="0 0 123.83142 41.120247"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="RLC_circuit.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="321.86982"
inkscape:cy="72.321811"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1680"
inkscape:window-height="987"
inkscape:window-x="1672"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-22.555731,-31.264548)">
<g
id="g4265"
transform="translate(-47.813988,-36.739285)"
style="stroke-width:0.92604166;stroke-miterlimit:4;stroke-dasharray:none">
<circle
r="7.4083333"
cy="90.625008"
cx="78.241074"
id="circle1914-3"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.92604166;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 78.241084,98.03333 v 3.70417"
id="path1916-7"
inkscape:connector-curvature="0" />
<path
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="M 78.241084,83.21667 V 79.5125"
id="path1918-4"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1940-0"
d="M 78.241084,96.18125 V 87.38386"
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.92604166;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path1942-9"
d="m 78.241084,85.06875 -1.38907,2.77813 h 2.77813 z"
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.92604166;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
</g>
<path
id="path3970-9"
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 57.830354,61.161753 v -2.77813 l 1.85209,-0.92604 -3.70417,-1.85208 3.70417,-1.85209 -3.70417,-1.85208 3.70417,-1.85208 -3.70417,-1.85209 1.85208,-0.92604 v -2.778121"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
<path
inkscape:connector-curvature="0"
id="path4203-7"
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 102.38816,63.307556 v -2.84293 c 4.3389,-0.008 4.3389,-2.84721 0,-2.84294 4.33891,-0.005 4.32349,-2.85142 0,-2.84292 4.35431,-6e-5 4.35431,-2.85154 0,-2.84294 4.32348,6e-5 4.3389,-2.83866 0,-2.84293 4.3389,-0.008 4.3389,-2.82534 0,-2.82534 v -2.86052"
sodipodi:nodetypes="cccccccc" />
<g
id="g1579-6"
transform="matrix(0,0.26458333,-0.26458333,0,321.34984,-49.764094)"
style="stroke-width:3.5;stroke-miterlimit:4;stroke-dasharray:none">
<path
sodipodi:nodetypes="cc"
id="path2791-3"
d="m 322,899.41665 v 14"
style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="cc"
id="path2793-4"
d="m 322,920.41665 v 14"
style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path2795-3"
d="m 335.99999,913.41665 h -28"
style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:nodetypes="cc" />
<path
inkscape:connector-curvature="0"
id="path2797-9"
d="m 335.99999,920.41665 h -28"
style="fill:none;stroke:#000000;stroke-width:3.5;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
sodipodi:nodetypes="cc" />
</g>
<path
id="path3970-9-8"
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 131.61168,61.618015 v -2.77813 l 1.85209,-0.92604 -3.70417,-1.85208 3.70417,-1.852091 -3.70417,-1.85208 3.70417,-1.85208 -3.70417,-1.85209 1.85208,-0.92604 v -2.778121"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 30.427096,42.810174 V 35.46254"
id="path4387"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 57.830354,44.443345 v -8.82764"
id="path4387-4"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 57.830354,71.332363 V 61.281545"
id="path4387-6"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 30.427096,71.915179 V 63.939881"
id="path4387-1"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 102.38816,71.282854 V 63.307556"
id="path4387-0"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 102.38816,43.407036 V 35.431738"
id="path4387-8"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 131.40232,35.431738 H 83.665249"
id="path4387-16"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 73.914571,35.46254 H 30.427096"
id="path4387-16-6"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 131.60563,71.915179 H 30.500788"
id="path4387-16-6-8"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 131.61168,44.864785 V 35.454826"
id="path4387-8-4"
inkscape:connector-curvature="0" />
<path
style="fill:none;stroke:#000000;stroke-width:0.92604166;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 131.61168,71.796656 V 61.716573"
id="path4387-8-7"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888903px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="42.362221"
y="55.729675"
id="text5292"><tspan
sodipodi:role="line"
id="tspan5290"
x="42.362221"
y="55.729675"
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.46666622px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Italic';stroke-width:0.26458332">I</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888903px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="63.876995"
y="55.787552"
id="text5292-9"><tspan
sodipodi:role="line"
id="tspan5290-6"
x="63.876995"
y="55.787552"
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.46666622px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Italic';stroke-width:0.26458332">R1</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888903px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="83.254036"
y="44.827801"
id="text5292-6"><tspan
sodipodi:role="line"
id="tspan5290-3"
x="83.254036"
y="44.827801"
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.46666622px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Italic';stroke-width:0.26458332">C</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888903px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="137.24249"
y="55.787552"
id="text5292-8"><tspan
sodipodi:role="line"
id="tspan5290-1"
x="137.24249"
y="55.787552"
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.46666622px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Italic';stroke-width:0.26458332">R2</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888903px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, ';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
x="110.7828"
y="55.729675"
id="text5292-89"><tspan
sodipodi:role="line"
id="tspan5290-4"
x="110.7828"
y="55.729675"
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:8.46666622px;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman, Italic';stroke-width:0.26458332">L</tspan></text>
</g>
</svg>
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id: tags:
# Asynchronous execution
%% Cell type:markdown id: tags:
DPsim integrates well with event loop implementation like [asyncio](https://docs.python.org/3/library/asyncio.html).
This allows the user to run simulations as a coroutine asynchronously in the background.
%% Cell type:markdown id: tags:
## Example 1
%% Cell type:markdown id: tags:
We start by defining a very simple simulation:
%% Cell type:code id: tags:
``` python
import time
import asyncio
import dpsim
from dpsim.EventChannel import Event
# Nodes
gnd = dpsim.dp.Node.GND()
n1 = dpsim.dp.Node("n1")
# Components
v1 = dpsim.dp.ph1.VoltageSource("v_1", [gnd, n1], V_ref=complex(345,0))
sys = dpsim.SystemTopology(50, [gnd, n1], [v1])
```
%% Cell type:markdown id: tags:
The <code>dpsim.Simulation</code> class has a function called `coro simulate()` which returns a coroutine.
this co-routine can be started in the background via:
%% Cell type:code id: tags:
``` python
sims = []
for i in range(1, 4):
sim = dpsim.RealTimeSimulation("async_demo_%d" % i, sys, timestep=i*1e-3, duration=3*i+5, pbar=True)
sim.start()
sims += [sim]
for i in range(1, 6):
print("Doing something different: %d" % i)
await asyncio.sleep(1)
_ = await asyncio.wait([ s.wait(Event.done) for s in sims ])
```
%% Output
Doing something different: 1
Doing something different: 2
Doing something different: 3
Doing something different: 4
Doing something different: 5
......
This diff is collapsed.
%% Cell type:markdown id: tags:
# Progressbars
%% Cell type:markdown id: tags:
During long running or real-time simulations it is useful to have a feedback from the running simulation about its current state.
DPsim can show its current progress
%% Cell type:markdown id: tags:
## Example 1
%% Cell type:code id: tags:
``` python
import dpsim
# Nodes
gnd = dpsim.dp.Node.GND()
n1 = dpsim.dp.Node("n1")
n2 = dpsim.dp.Node("n2")
n3 = dpsim.dp.Node("n3")
n4 = dpsim.dp.Node("n4")
# Components
v1 = dpsim.dp.ph1.VoltageSource("v_1", [gnd, n1], V_ref=complex(345,0))
r1 = dpsim.dp.ph1.Resistor("r1", [n1, n2], R=5)
c1 = dpsim.dp.ph1.Capacitor("c_1", [n2, gnd], C=0.002)
rL1 = dpsim.dp.ph1.Resistor("r_load1", [n2, n4], R=6.4)
l1 = dpsim.dp.ph1.Inductor("l_1", [n4, n3], L=0.186)
c2 = dpsim.dp.ph1.Capacitor("c_2", [n3, gnd], C=0.002)
rL2 = dpsim.dp.ph1.Resistor("r_load2", [n3, gnd], R=150)
sys = dpsim.SystemTopology(50, [gnd, n1, n2, n3, n4], [v1, r1, c1, rL1, l1, c2, rL2])
sim = dpsim.Simulation("progress_demo1", sys, duration=20, timestep=0.0005)
```
%% Cell type:code id: tags:
``` python
sim.show_progressbar()
```
%% Output
%% Cell type:code id: tags:
``` python
await sim.simulate()
```
%% Cell type:markdown id: tags:
## Example 2
%% Cell type:markdown id: tags:
Progressbars are also supported for simulations which are executed as a co-routine
%% Cell type:code id: tags:
``` python
import asyncio
async def dummy():
for i in range(1,10):
await asyncio.sleep(1)
print('Doing something different:', i)
sim2 = dpsim.Simulation("progress_demo2", sys, duration=20, timestep=0.00005)
sim2.show_progressbar()
await asyncio.gather(sim2.simulate(), dummy())
```
%% Output
Doing something different: 1
Doing something different: 2
Doing something different: 3
Doing something different: 4
Doing something different: 5
Doing something different: 6
Doing something different: 7