Examples

Runnable notebooks and C++ examples.

If you are starting out, start with the tutorials instead. They work through one idea at a time in order, each as a complete script. This page is the inventory of what else the repository carries, which is the right thing once you know what you are looking for.

The examples come in both languages. The Python notebooks run a scenario and plot the result in one place, so they are the better way to see a complete study. The C++ examples are the better reference for using DPsim as a library, and are what the real time and co-simulation scenarios are written in.

Where each kind fits

If you want toGo to
Learn how a simulation is put togetherTutorials
See a complete study with plotsNotebooks, below
Use DPsim from an applicationC++ examples, below
Look up what a model doesConcepts

Notebooks

Run them in the browser with no local installation:

Binder

Locally, they live under examples/Notebooks and need the Python package on the path, as described in the build section.

CategoryContents
Quickstart GuideA single notebook covering a first simulation end to end
CircuitsSmall networks exercising one modelling aspect at a time
ComponentsOne component at a time, often comparing domains against each other
GridsPublished test systems such as the WSCC 9 bus and CIGRE networks
FeaturesCross-cutting capabilities rather than a specific network
PerformanceTiming and scaling comparisons
StateSpaceState-space extraction from a running simulation

Understanding_DP.ipynb is worth reading early if dynamic phasors are new to you, since it builds the intuition the concepts section then formalises.

Continuing from a tutorial

Each tutorial ends at the point where the notebooks take over, so a category is usually the natural next step from the rung that introduced the idea.

After this tutorialThese notebooks go further
Adding dynamicsCircuits, for larger passive networks
Two-bus networkGrids, for published test systems solved the same way
Comparing domainsComponents, which compare one model across domains
Adding a machineCircuits, for the SMIB and multi-machine fault studies
Exchanging dataThe co-simulation examples below

C++ examples

Under dpsim/examples/cxx, built as part of a normal build and produced as executables in the build directory.

DirectoryContents
CircuitsNetworks assembled directly in C++
ComponentsSingle component scenarios
CIMReading network data from CIM and CGMES files
StateSpaceState-space extraction
RealTimeScenarios run against the wall clock
DAE, signals, timerSmaller scenarios for the DAE solver, signal models and timing

The target name is the source file name without its extension, regardless of which directory the source sits in, and the executables are written flat into the build tree. So to build and run a single example from your build directory:

cmake --build . --target DP_VS_RL1
./dpsim/examples/cxx/DP_VS_RL1

Co-simulation

The dpsim-villas examples exchange data with other simulators or with hardware through VILLASnode. These need WITH_VILLAS enabled and are therefore not available on Windows. See interfaces for how the coupling works and real time for running them against the wall clock.