Commit 9ecc35fc authored by Markus Mirz's avatar Markus Mirz
Browse files

update intro notebooks

parent 50c19364
%% Cell type:markdown id: tags:
<img src="Figures/dpsim.png" width="120" align="right" style="margin: 15px">
# DPsim
DPsim is a real-time capable power system simulator that operates in the dynamic phasor (DP) and EMT domain. This solver primarily targets co-simulation and large-scale scenarios since dynamic phasor variables do not require sampling rates as high as EMT simulations. Due to the frequency shift introduced by the DP approach, the sampling rate and rate of data exchange between simulators can be reduced. Thus, it is also possible to simulate high frequencies introduced by power electronics with lower sampling rates than in EMT simulations.
DPsim is a real-time capable power system simulator that supports dynamic phasor and electromagnetic transient simulation as well as continuous powerflow. It primarily targets large-scale scenarios on commercial off-the-sheld hardware that require deterministic time steps in the range of micro- to milliseconds.
DPsim supports the CIM format as native input for the description of electrical network topologies, component parameters and load flow data, which is used for initialization. For this purpose, CIM++ is integrated in DPsim. Users interact with the simulation kernel via Python bindings, which can be used to script the execution, schedule events, change parameters and retrieve results. Supported by the availability of existing Python frameworks like Numpy, Pandas and Matplotlib, Python scripts have been proven as an easy and flexible way to codify the complete workflow of a simulation from modelling to analysis and plotting, for example in Jupyter notebooks.
DPsim supports the CIM format as native input for the description of electrical network topologies, component parameters and load flow data, which is used for initialization. For this purpose, CIM++ is integrated in DPsim. Users interact with the C++ simulation kernel via Python bindings, which can be used to script the execution, schedule events, change parameters and retrieve results. Supported by the availability of existing Python frameworks like Numpy, Pandas and Matplotlib, Python scripts have been proven as an easy and flexible way to codify the complete workflow of a simulation from modelling to analysis and plotting, for example in Jupyter notebooks.
The DPsim simulation kernel is implemented in C++ and uses the Eigen linear algebra library. By using a system programming language like C++ and a highly optimized math library, optimal performance and real-time execution can be guaranteed.
The integration into the [VILLASframework](http://fein-aachen.org/projects/villas-framework/) allows DPsim to be used in large-scale co-simulations.
The DPsim simulation kernel is implemented in C++ and uses the Eigen linear algebra library. By using a system programming language like C++ and a highly optimized math library, optimal performance and real-time execution can be guaranteed. The integration into the VILLASframework allows DPsim to be used in large-scale co-simulations.
## Examples
Welcome to the examples collection of DPsim. These examples are a good way to start using DPsim.
They cover DPsim's feature from [simple circuits](./Notebooks/Circuits/CS_R2CL.ipynb) and to more complex benchmarks models like the [IEEE/WSCC 9-bus system](./Notebooks/Grids/WSCC_9-bus_dyn_switch_python.ipynb).
Welcome to the examples collection of DPsim. These examples are a good way to start using DPsim. \
They cover DPsim's feature from [simple circuits](./Notebooks/Circuits/CS_R2CL.ipynb) and to more complex benchmarks models like the [IEEE/WSCC 9-bus system](./Notebooks/Grids/WSCC_9-bus_dyn_switch_python.ipynb). \
A good place to start is the [Quickstart Guide](./Notebooks/Quickstart%20Guide.ipynb).
## [Quickstart Guide](./Notebooks/Quickstart%20Guide.ipynb)
## Project Website
On our [project website](https://fein-aachen.org/projects/dpsim) you find links to the source code, published papers, licensing information and more.
## Documentation
- [User Documentation](https://dpsim.fein-aachen.org/doc/development/sphinx/)
- [Developer Documentation](https://dpsim.fein-aachen.org/doc/development/doxygen/)
## Downloads
- [Source Code](https://git.rwth-aachen.de/acs/public/simulation/dpsim)
- [Docker Image](https://cloud.docker.com/u/rwthacs/repository/docker/rwthacs/dpsim)
For further question please consider joining our Slack channel: [FEIN e.V. Slack](https://join.slack.com/t/feinev/shared_invite/enQtNTE1NjY5MTg5NTY4LWM4MWI5ZTVkNDgzZTgyNmY5NWY2N2M3MjdjYzQxY2E0MmRlNjBkYTc3ODNlMDliY2M5YzllNjE4YTY3ODBjM2M).
## Publications
DPsim is presented and/or used by the following publications:
- M. Mirz, S. Vogel, G. Reinke, A. Monti, "[DPsim—A dynamic phasor real-time simulator for power systems](https://www.sciencedirect.com/science/article/pii/S2352711018302760)," _SoftwareX_, Volume 10, July–December 2019, 100253.
- M. Mirz, A. Estebsari, F. Arrigo, E. Bompard and A. Monti, "[Dynamic phasors to enable distributed real-time simulation](http://ieeexplore.ieee.org/document/8004805/)," _2017 6th International Conference on Clean Electrical Power (ICCEP)_, Santa Margherita Ligure, 2017, pp. 139-144.
- M. Mirz, A. Monti, A. Estebsari, F. Arrigo, E. Bompard, "[Functionality of the releases of the real time solver V1](http://re-serve.eu/files/reserve/Content/Deliverables/D4.2.pdf)," _RESERVE Library_, 2017.
- M. Mirz, S. Vogel, A. Monti, "[First Interconnection test of the nodes in pan-European simulation platform](http://re-serve.eu/files/reserve/Content/Deliverables/D4.4.pdf)," _RESERVE Library_, 2017.
- S. Vogel, M. Mirz, L. Razik, A. Monti, "[An Open Solution for Next-generation Real-time Power System Simulation](https://ieeexplore.ieee.org/document/8245739)," _1st IEEE Conference on Energy Internet and Energy System Integration (IEEE-EI^2)_, Beijing, 2017.
## Copyright
2017-2019, Institute for Automation of Complex Power Systems, EONERC
## Licensing
<img alt="GPLv3 logo" src="https://www.fein-aachen.org/img/logos/gplv3.png" width="120" align="right">
__DPsim__ is released as open source software under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html).
Other licensing options available upon request.
Please contact [Prof. Antonello Monti](mailto:amonti@eonerc.rwth-aachen.de) for further details.
## Contact
[![EONERC ACS Logo](Figures/eonerc.png)](http://www.acs.eonerc.rwth-aachen.de)
- Markus Mirz (<mmirz@eonerc.rwth-aachen.de>)
- Jan Dinkelbach (<jdinkelbach@eonerc.rwth-aachen.de>)
[Institute for Automation of Complex Power Systems (ACS)](http://www.acs.eonerc.rwth-aachen.de)
[EON Energy Research Center (EONERC)](http://www.eonerc.rwth-aachen.de)
[RWTH University Aachen, Germany](http://www.rwth-aachen.de)
On our [project website](https://dpsim.fein-aachen.org/) you find links to the source code, documentation, published papers, licensing information and more.
%% Cell type:code id: tags:
``` python
```
......
%% 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).)
This guides demonstrates the basic usage of DPsim as a Python module. Please note that DPsim also provides a C++ API.
The first simulation
--------------------
As a first simple, test we will simulate the following static network:
![](Figures/rl_circuit.svg)
The network consists of 4 nodes and 4 elements:
As a first simple, test we will simulate a small 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")
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
```
%% 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()
```
%% 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(freq=50) for series in results ]
for series in results_emt:
pt.plot_timeseries('Results EMT', series)
plt.show()
```
%% Cell type:code id: tags:
``` python
!cat logs/Example1_Solver.log
```
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment