Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
Power System Simulation and Optimization
DPsim
DPsim
Commits
561c284b
Commit
561c284b
authored
Jul 09, 2019
by
Markus Mirz
Browse files
update quickstart notebook
parent
74d3b67e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Examples/Notebooks/Quickstart Guide.ipynb
View file @
561c284b
...
...
@@ -60,15 +60,26 @@
"metadata": {},
"outputs": [],
"source": [
"# Nodes\n",
"gnd = dpsim.dp.Node.GND()\n",
"n0 = dpsim.dp.Node(\"n0\")\n",
"n1 = dpsim.dp.Node(\"n1\")\n",
"n2 = dpsim.dp.Node(\"n2\")\n",
"\n",
"v_s = dpsim.dp.ph1.VoltageSource(\"v_s\", [n0, gnd], V_ref=10000+0j)\n",
"r_line = dpsim.dp.ph1.Resistor(\"r_line\", [n0, n1], R=1)\n",
"l_line = dpsim.dp.ph1.Inductor(\"l_line\", [n1, n2], L=1)\n",
"r_load = dpsim.dp.ph1.Resistor(\"r_load\", [n2, gnd], R=1000)"
"v_s = dpsim.dp.ph1.VoltageSource(\"v_s\")\n",
"v_s.V_ref = 10000+0j\n",
"r_line = dpsim.dp.ph1.Resistor(\"r_line\")\n",
"r_line.R = 1\n",
"l_line = dpsim.dp.ph1.Inductor(\"l_line\")\n",
"l_line.L = 1\n",
"r_load = dpsim.dp.ph1.Resistor(\"r_load\")\n",
"r_load.R = 1000\n",
"\n",
"# Connections \n",
"v_s.connect([n0, gnd])\n",
"r_line.connect([n0, n1])\n",
"l_line.connect([n1, n2])\n",
"r_load.connect([n2, gnd])"
]
},
{
...
...
@@ -143,7 +154,7 @@
"<!-- v_s -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>v_s</title>\n",
"<g id=\"a_node4\"><a xlink:title=\"Attributes: V_ref: 1e+04+0i f_src: 0.000000 i_
comp: 0+0i i_
intf: (0,0) name: v_s
priority: 0
right_vector: uid: v_s v_
comp: 0+0i v_
intf: (0,0)\">\n",
"<g id=\"a_node4\"><a xlink:title=\"Attributes: V_ref: 1e+04+0i f_src: 0.000000 i_intf: (0,0) name: v_s right_vector: uid: v_s v_intf: (0,0)\">\n",
"<path fill=\"#ededed\" stroke=\"#000000\" stroke-width=\"2\" d=\"M105,-462.3963C105,-462.3963 12,-462.3963 12,-462.3963 6,-462.3963 0,-456.3963 0,-450.3963 0,-450.3963 0,-438.3963 0,-438.3963 0,-432.3963 6,-426.3963 12,-426.3963 12,-426.3963 105,-426.3963 105,-426.3963 111,-426.3963 117,-432.3963 117,-438.3963 117,-438.3963 117,-450.3963 117,-450.3963 117,-456.3963 111,-462.3963 105,-462.3963\"/>\n",
"<text text-anchor=\"start\" x=\"49\" y=\"-446.1963\" font-family=\"Times,serif\" font-weight=\"bold\" font-size=\"14.00\" fill=\"#000000\">v_s</text>\n",
"<text text-anchor=\"start\" x=\"8\" y=\"-435.3963\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#474747\">DP::Ph1::VoltageSource</text>\n",
...
...
@@ -158,7 +169,7 @@
"<!-- r_line -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>r_line</title>\n",
"<g id=\"a_node5\"><a xlink:title=\"Attributes: R: 1.000000 i_
comp: 0+0i i_
intf: (0,0) name: r_line
priority: 0
right_vector: uid: r_line v_
comp: 0+0i v_
intf: (0,0)\">\n",
"<g id=\"a_node5\"><a xlink:title=\"Attributes: R: 1.000000 i_intf: (0,0) name: r_line right_vector: uid: r_line v_intf: (0,0)\">\n",
"<path fill=\"#ededed\" stroke=\"#000000\" stroke-width=\"2\" d=\"M122.2728,-321.3449C122.2728,-321.3449 56.2728,-321.3449 56.2728,-321.3449 50.2728,-321.3449 44.2728,-315.3449 44.2728,-309.3449 44.2728,-309.3449 44.2728,-297.3449 44.2728,-297.3449 44.2728,-291.3449 50.2728,-285.3449 56.2728,-285.3449 56.2728,-285.3449 122.2728,-285.3449 122.2728,-285.3449 128.2728,-285.3449 134.2728,-291.3449 134.2728,-297.3449 134.2728,-297.3449 134.2728,-309.3449 134.2728,-309.3449 134.2728,-315.3449 128.2728,-321.3449 122.2728,-321.3449\"/>\n",
"<text text-anchor=\"start\" x=\"72.2728\" y=\"-305.1449\" font-family=\"Times,serif\" font-weight=\"bold\" font-size=\"14.00\" fill=\"#000000\">r_line</text>\n",
"<text text-anchor=\"start\" x=\"52.2728\" y=\"-294.3449\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#474747\">DP::Ph1::Resistor</text>\n",
...
...
@@ -178,7 +189,7 @@
"<!-- l_line -->\n",
"<g id=\"node6\" class=\"node\">\n",
"<title>l_line</title>\n",
"<g id=\"a_node6\"><a xlink:title=\"Attributes: L: 1.000000 i_
comp: 0+0i i_
intf: (0,0) name: l_line
priority: 0
right_vector: uid: l_line v_
comp: 0+0i v_
intf: (0,0)\">\n",
"<g id=\"a_node6\"><a xlink:title=\"Attributes: L: 1.000000 i_intf: (0,0) name: l_line right_vector: uid: l_line v_intf: (0,0)\">\n",
"<path fill=\"#ededed\" stroke=\"#000000\" stroke-width=\"2\" d=\"M125.0731,-176.9688C125.0731,-176.9688 57.0731,-176.9688 57.0731,-176.9688 51.0731,-176.9688 45.0731,-170.9688 45.0731,-164.9688 45.0731,-164.9688 45.0731,-152.9688 45.0731,-152.9688 45.0731,-146.9688 51.0731,-140.9688 57.0731,-140.9688 57.0731,-140.9688 125.0731,-140.9688 125.0731,-140.9688 131.0731,-140.9688 137.0731,-146.9688 137.0731,-152.9688 137.0731,-152.9688 137.0731,-164.9688 137.0731,-164.9688 137.0731,-170.9688 131.0731,-176.9688 125.0731,-176.9688\"/>\n",
"<text text-anchor=\"start\" x=\"75.0731\" y=\"-160.7688\" font-family=\"Times,serif\" font-weight=\"bold\" font-size=\"14.00\" fill=\"#000000\">l_line</text>\n",
"<text text-anchor=\"start\" x=\"53.0731\" y=\"-149.9688\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#474747\">DP::Ph1::Inductor</text>\n",
...
...
@@ -198,7 +209,7 @@
"<!-- r_load -->\n",
"<g id=\"node7\" class=\"node\">\n",
"<title>r_load</title>\n",
"<g id=\"a_node7\"><a xlink:title=\"Attributes: R: 1000.000000 i_
comp: 0+0i i_
intf: (0,0) name: r_load
priority: 0
right_vector: uid: r_load v_
comp: 0+0i v_
intf: (0,0)\">\n",
"<g id=\"a_node7\"><a xlink:title=\"Attributes: R: 1000.000000 i_intf: (0,0) name: r_load right_vector: uid: r_load v_intf: (0,0)\">\n",
"<path fill=\"#ededed\" stroke=\"#33a02c\" stroke-width=\"2\" d=\"M93.3894,-36C93.3894,-36 27.3894,-36 27.3894,-36 21.3894,-36 15.3894,-30 15.3894,-24 15.3894,-24 15.3894,-12 15.3894,-12 15.3894,-6 21.3894,0 27.3894,0 27.3894,0 93.3894,0 93.3894,0 99.3894,0 105.3894,-6 105.3894,-12 105.3894,-12 105.3894,-24 105.3894,-24 105.3894,-30 99.3894,-36 93.3894,-36\"/>\n",
"<text text-anchor=\"start\" x=\"41.3894\" y=\"-19.8\" font-family=\"Times,serif\" font-weight=\"bold\" font-size=\"14.00\" fill=\"#000000\">r_load</text>\n",
"<text text-anchor=\"start\" x=\"23.3894\" y=\"-9\" font-family=\"Times,serif\" font-size=\"10.00\" fill=\"#474747\">DP::Ph1::Resistor</text>\n",
...
...
@@ -214,7 +225,7 @@
"</svg>\n"
],
"text/plain": [
"<dpsim.SystemTopology at 0x7f
70586ff69
0>"
"<dpsim.SystemTopology at 0x7f
6b200da5d
0>"
]
},
"execution_count": 4,
...
...
@@ -241,7 +252,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
26da414a22984f469062adcdcff187b6
",
"model_id": "
b159510288004681b4903e28490d3d5f
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -255,7 +266,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
eaecb9697d3142949459c42e9aaa52a1
",
"model_id": "
f6d8252b1fee4828a2f292d2025651da
",
"version_major": 2,
"version_minor": 0
},
...
...
@@ -338,10 +349,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L 0 3.5 \n",
"\" id=\"m
d64af4dccb
\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m
286bd4e6c9
\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_1\">\n",
...
...
@@ -387,7 +398,7 @@
" <g id=\"xtick_2\">\n",
" <g id=\"line2d_2\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"110.192188\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"110.192188\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_2\">\n",
...
...
@@ -430,7 +441,7 @@
" <g id=\"xtick_3\">\n",
" <g id=\"line2d_3\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"165.992188\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"165.992188\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_3\">\n",
...
...
@@ -462,7 +473,7 @@
" <g id=\"xtick_4\">\n",
" <g id=\"line2d_4\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"221.792188\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"221.792188\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_4\">\n",
...
...
@@ -479,7 +490,7 @@
" <g id=\"xtick_5\">\n",
" <g id=\"line2d_5\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"277.592188\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"277.592188\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_5\">\n",
...
...
@@ -522,7 +533,7 @@
" <g id=\"xtick_6\">\n",
" <g id=\"line2d_6\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"333.392187\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"333.392187\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_6\">\n",
...
...
@@ -539,7 +550,7 @@
" <g id=\"xtick_7\">\n",
" <g id=\"line2d_7\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"389.192188\" xlink:href=\"#m
d64af4dccb
\" y=\"224.64\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"389.192188\" xlink:href=\"#m
286bd4e6c9
\" y=\"224.64\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_7\">\n",
...
...
@@ -594,10 +605,10 @@
" <defs>\n",
" <path d=\"M 0 0 \n",
"L -3.5 0 \n",
"\" id=\"m
1a7f54610e
\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
"\" id=\"m
53a5268afa
\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n",
" </defs>\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"214.756364\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"214.756364\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_8\">\n",
...
...
@@ -623,7 +634,7 @@
" <g id=\"ytick_2\">\n",
" <g id=\"line2d_9\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"190.047273\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"190.047273\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_9\">\n",
...
...
@@ -651,7 +662,7 @@
" <g id=\"ytick_3\">\n",
" <g id=\"line2d_10\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"165.338182\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"165.338182\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_10\">\n",
...
...
@@ -668,7 +679,7 @@
" <g id=\"ytick_4\">\n",
" <g id=\"line2d_11\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"140.629091\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"140.629091\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_11\">\n",
...
...
@@ -685,7 +696,7 @@
" <g id=\"ytick_5\">\n",
" <g id=\"line2d_12\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"115.92\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"115.92\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_12\">\n",
...
...
@@ -698,7 +709,7 @@
" <g id=\"ytick_6\">\n",
" <g id=\"line2d_13\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"91.210909\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"91.210909\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_13\">\n",
...
...
@@ -714,7 +725,7 @@
" <g id=\"ytick_7\">\n",
" <g id=\"line2d_14\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"66.501818\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"66.501818\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_14\">\n",
...
...
@@ -730,7 +741,7 @@
" <g id=\"ytick_8\">\n",
" <g id=\"line2d_15\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"41.792727\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"41.792727\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_15\">\n",
...
...
@@ -746,7 +757,7 @@
" <g id=\"ytick_9\">\n",
" <g id=\"line2d_16\">\n",
" <g>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
1a7f54610e
\" y=\"17.083636\"/>\n",
" <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"54.392188\" xlink:href=\"#m
53a5268afa
\" y=\"17.083636\"/>\n",
" </g>\n",
" </g>\n",
" <g id=\"text_16\">\n",
...
...
@@ -762,7 +773,7 @@
" </g>\n",
" </g>\n",
" <g id=\"line2d_17\">\n",
" <path clip-path=\"url(#p
3b08348014
)\" d=\"M 54.392188 214.756364 \n",
" <path clip-path=\"url(#p
968b20db9a
)\" d=\"M 54.392188 214.756364 \n",
"L 56.624188 214.561333 \n",
"L 58.856188 213.977009 \n",
"L 61.088188 213.0057 \n",
...
...
@@ -874,7 +885,7 @@
"\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_18\">\n",
" <path clip-path=\"url(#p
3b08348014
)\" d=\"M 54.392188 214.751658 \n",
" <path clip-path=\"url(#p
968b20db9a
)\" d=\"M 54.392188 214.751658 \n",
"L 56.624188 214.539568 \n",
"L 58.856188 213.941354 \n",
"L 61.088188 212.958817 \n",
...
...
@@ -986,7 +997,7 @@
"\" style=\"fill:none;stroke:#ff7f0e;stroke-linecap:square;stroke-width:2;\"/>\n",
" </g>\n",
" <g id=\"line2d_19\">\n",
" <path clip-path=\"url(#p
3b08348014
)\" d=\"M 54.392188 120.625216 \n",
" <path clip-path=\"url(#p
968b20db9a
)\" d=\"M 54.392188 120.625216 \n",
"L 56.624188 137.685144 \n",
"L 58.856188 151.575882 \n",
"L 59.972188 157.494395 \n",
...
...
@@ -1346,7 +1357,7 @@
" </g>\n",
" </g>\n",
" <defs>\n",
" <clipPath id=\"p
3b08348014
\">\n",
" <clipPath id=\"p
968b20db9a
\">\n",
" <rect height=\"217.44\" width=\"334.8\" x=\"54.392188\" y=\"7.2\"/>\n",
" </clipPath>\n",
" </defs>\n",
...
...
@@ -1390,6 +1401,13 @@
"!cat logs/Example1_MNA.log"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
%% Cell type:markdown id: tags:
Quickstart Guide
================
This guides demonstrates the basic usage of DPsim as a
[
Python module
](
https://dpsim.fein-aachen.org/doc/development/sphinx/Python.html
)
.
(Please note that DPsim also provides a
[
C++ API
](
https://dpsim.fein-aachen.org/doc/development/doxygen
)
.)
The first simulation
--------------------
As a first simple, test we will simulate the following static network:

The network consists of 4 nodes and 4 elements:
| Component | Type | Python Class | Node A | Node B | Paramter |
| :---------| :---- | :---------------------------------------- | :----- | :----- | :------- |
| v_s | Voltage Source |
`dpsim.dp.ph1.VoltageSource`
| 0 | GND | 10 kV |
| r_line | Line Resistance |
`dpsim.dp.ph1.Resistor`
| 0 | 1 | 1 Ohm |
| l_line | Line Inductance |
`dpsim.dp.ph1.Inductor`
| 1 | 2 | 1 Henry |
| r_load | Load |
`dpsim.dp.ph1.Resistor`
| 2 | GND | 1 kOhm |
%% Cell type:markdown id: tags:
Before we can start, we must import the DPsim Python module.
We also add
`dp`
as an alias for the dynamic phasor components.
%% Cell type:code id: tags:
```
python
import
dpsim
```
%% Cell type:markdown id: tags:
Next, we can define the model by creating a couple of components.
Each component is identified by a name which is passed as the first argument.
Following arguments are used to define the topology by assigning the component to a specific node / bus or to pass parameters.
%% Cell type:code id: tags:
```
python
# Nodes
gnd
=
dpsim
.
dp
.
Node
.
GND
()
n0
=
dpsim
.
dp
.
Node
(
"n0"
)
n1
=
dpsim
.
dp
.
Node
(
"n1"
)
n2
=
dpsim
.
dp
.
Node
(
"n2"
)
v_s
=
dpsim
.
dp
.
ph1
.
VoltageSource
(
"v_s"
,
[
n0
,
gnd
],
V_ref
=
10000
+
0j
)
r_line
=
dpsim
.
dp
.
ph1
.
Resistor
(
"r_line"
,
[
n0
,
n1
],
R
=
1
)
l_line
=
dpsim
.
dp
.
ph1
.
Inductor
(
"l_line"
,
[
n1
,
n2
],
L
=
1
)
r_load
=
dpsim
.
dp
.
ph1
.
Resistor
(
"r_load"
,
[
n2
,
gnd
],
R
=
1000
)
v_s
=
dpsim
.
dp
.
ph1
.
VoltageSource
(
"v_s"
)
v_s
.
V_ref
=
10000
+
0j
r_line
=
dpsim
.
dp
.
ph1
.
Resistor
(
"r_line"
)
r_line
.
R
=
1
l_line
=
dpsim
.
dp
.
ph1
.
Inductor
(
"l_line"
)
l_line
.
L
=
1
r_load
=
dpsim
.
dp
.
ph1
.
Resistor
(
"r_load"
)
r_load
.
R
=
1000
# Connections
v_s
.
connect
([
n0
,
gnd
])
r_line
.
connect
([
n0
,
n1
])
l_line
.
connect
([
n1
,
n2
])
r_load
.
connect
([
n2
,
gnd
])
```
%% Cell type:markdown id: tags:
Next, we have to create a simulation object:
%% Cell type:code id: tags:
```
python
sys
=
dpsim
.
SystemTopology
(
50
,
[
n0
,
n1
,
n2
],
[
v_s
,
r_line
,
l_line
,
r_load
])
```
%% Cell type:markdown id: tags:
We can also visualize the system topology:
%% Cell type:code id: tags:
```
python
sys
```
%% Output
<dpsim.SystemTopology at 0x7f
70586ff69
0>
<dpsim.SystemTopology at 0x7f
6b200da5d
0>
%% Cell type:markdown id: tags:
Finally, we can start the simulation and wait for its completion:
%% Cell type:code id: tags:
```
python
sim
=
dpsim
.
Simulation
(
"Example1"
,
sys
,
timestep
=
1e-4
,
duration
=
0.03
,
pbar
=
True
)
log
=
dpsim
.
Logger
(
"Example1"
)
for
n
in
sys
.
nodes
:
log
.
log_attribute
(
sys
.
nodes
[
n
],
"v"
)
sim
.
add_logger
(
log
)
await
sim
.
simulate
()
```
%% Output
%% Cell type:markdown id: tags:
Results can be analyzed and plotted by the
`villas.dataprocessing`
package:
%% Cell type:code id: tags:
```
python
%
matplotlib
inline
%
config
InlineBackend
.
figure_format
=
'svg'
%
config
InlineBackend
.
rc
=
{
'font.size'
:
10
,
'figure.figsize'
:
(
6.0
,
4.0
),
'figure.facecolor'
:
'white'
,
'savefig.dpi'
:
72
,
'figure.subplot.bottom'
:
0.125
,
'figure.edgecolor'
:
'white'
}
import
matplotlib.pyplot
as
plt
import
villas.dataprocessing.plottools
as
pt
import
villas.dataprocessing.readtools
as
rt
import
villas.dataprocessing.timeseries
as
ts
results
=
rt
.
read_timeseries_dpsim
(
'logs/Example1.csv'
)
results_emt
=
[
results
[
series
].
frequency_shift
(
50
)
for
series
in
results
]
for
series
in
results_emt
:
pt
.
plot_timeseries
(
'Results EMT'
,
series
)
plt
.
show
()
```
%% Output
column number: 3
results length: 301
real column names: []
complex column names: ['n0.v', 'n1.v', 'n2.v']
%% Cell type:code id: tags:
```
python
!
cat
logs
/
Example1_MNA
.
log
```
%% Cell type:code id: tags:
```
python
``
`
%%
Cell
type
:
code
id
:
tags
:
```
python
```
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment