This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Core Tasks

Description of typical simulation and development tasks.

Each task should give the user

  • The prerequisites for this task, if any (this can be specified at the top of a multi-task page if they’re the same for all the page’s tasks. “All these tasks assume that you understand….and that you have already….”).
  • What this task accomplishes.
  • Instructions for the task. If it involves editing a file, running a command, or writing code, provide code-formatted example snippets to show the user what to do! If there are multiple steps, provide them as a numbered list.
  • If appropriate, links to related concept, tutorial, or example pages.

1 - Add New Model

Extending the simulator with new component or control models.

Add a Component Model

In this section we will show the implementation of a new component model by means a three-phase dynamic phasor inductor model.

C++ OOP

DPsim implements component models in a sub project called CPowerSystems (CPS) that is located in the models folder. This folder is added to the DPsim CMake project. Every component in DPsim is represented by a C++ class.

DPsim supports different types of solvers (MNA, DAE, NRP). Each solver requires certain member functions in the component class to be implemented. These functions are specified by the solver interface classes: MNAInterface.h, DAEInterface.h, etc.

Directory / Namespace Structure

For the implementation of the new component, we add two new files

  • models/Source/DP/DP_Ph3_Inductor.cpp
  • models/Include/DP/DP_Ph3_Inductor.h

In these files, we will implement a new C++ class with the name CPS::DP::Ph3::Inductor. The general structure looks as follows.

Directories:

DPsim
 |
 |- Source
 |- Include
  \ models
      |- Source
          |- DP
          |- EMT
          |- Static
            \ Signal
      |- Include
          |- DP
          |- EMT
          |- Static
            \ Signal

Namespaces:

CPS::{DP,EMT,Static,Signal}::{Ph1,Ph3}::{Name}

Attributes

Each components has a list of attributes, which has to be specified when creating the components class.

TODO: explain attribute system

Tasks for Pre/Post-step Functions

TODO: add example task dependency graph

Adding the new Component to DPsim

After finishing the implementation of the new component, it needs to be added to the following files:

  • models/Include/cps/Components.h
  • models/Source/CMakeLists.txt
  • Sources/Python/Module.cpp

2 - Create New Simulation

Using DPsim for a new simulation scenario.

Here, we will show the implementation of a new simulation scenario defined in C++, which is using DPsim as a library.

Directory Structure

In the end, your directory structure should look like as follows:

my-project
  |- CMakeLists.txt
  |- source
      |- my-scenario.cpp
  |- dpsim (as submodule)

CMake File

Your CMakeLists could look like this:

cmake_minimum_required(VERSION 3.5)
project(my-project CXX)

add_subdirectory(dpsim)

add_executable(my-scenario source/my-scenario.cpp)
  target_link_libraries(my-scenario dpsim)

Build the Project

The build process is similar to the one of DPsim:

$ cd my-project
$ mkdir build && cd build
$ cmake ..
$ make my-scenario