# sogno-platform/dpsim architecture

> Architecture diagram of the GitHub repository sogno-platform/dpsim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sogno-platform/dpsim
- Repository: https://github.com/sogno-platform/dpsim

## Overview

DPsim is a C++ power-system simulation library with EMT and dynamic-phasor simulation, power-flow solving, Python access, CIM/CGMES model loading, and real-time/protocol interfaces. The principal workflow is to define or import a network, configure a simulation, solve it over time, and expose results or exchange values externally. The graph combines README-documented capabilities with sampled source; several solver and model internals were not sampled, so their detailed links are omitted.

Main entry points: [`dpsim/include/dpsim/Simulation.h`](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/Simulation.h) (Simulation control), [`dpsim/include/dpsim/MNASolverFactory.h`](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/MNASolverFactory.h) (Solver selection), [`dpsim-models/src/CIM/Reader.cpp`](https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/CIM/Reader.cpp) (CIM reader), [`dpsim/include/dpsim/InterfaceWorker.h`](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/InterfaceWorker.h) (Interface worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_models["Network models"]
  node_components["Grid components<br/>[Components.h]"]
  node_topology["System topology<br/>[SystemTopology.cpp]"]
  node_controllers["VSI controllers"]
  node_voltage_controller["Voltage control"]
end

subgraph group_runtime["Simulation runtime"]
  node_simulation["Simulation control<br/>[Simulation.h]"]
  node_factory["Solver selection<br/>[MNASolverFactory.h]"]
  node_mna["MNA solver<br/>[MNASolver.cpp]"]
  node_state_space["State-space coupling"]
  node_powerflow["Power-flow solver<br/>[PFSolver.cpp]"]
  node_results["Simulation results<br/>[Simulation.h]"]
end

subgraph group_interfaces["Import and interfaces"]
  node_cim["CIM reader<br/>[Reader.cpp]"]
  node_interface_worker["Interface worker<br/>[InterfaceWorker.h]"]
  node_villas["VILLAS interface"]
end

subgraph group_api["Python API"]
  node_matpower["MATPOWER reader<br/>[matpower.py]"]
  node_bindings["Python bindings<br/>[main.cpp]"]
end

node_engineer(("Simulation user"))

node_engineer -->|"configures and runs"| node_simulation
node_engineer -->|"loads network"| node_cim
node_cim -.->|"builds topology"| node_topology
node_engineer -->|"imports case"| node_matpower
node_matpower -->|"uses components"| node_bindings
node_simulation -->|"creates solvers"| node_factory
node_factory -.->|"selects solver"| node_mna
node_simulation -.->|"initializes by power flow"| node_powerflow
node_simulation -.->|"extracts state space"| node_state_space
node_simulation -.->|"logs results"| node_results
node_simulation -.->|"exchanges values"| node_interface_worker
node_interface_worker -->|"specializes interface"| node_villas
node_engineer -->|"connects protocols"| node_villas
node_controllers -.->|"models inverter control"| node_components
node_voltage_controller -.->|"models voltage control"| node_components

click node_cim "https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/CIM/Reader.cpp"
click node_matpower "https://github.com/sogno-platform/dpsim/blob/master/python/src/dpsim/matpower.py"
click node_bindings "https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/pybind/main.cpp"
click node_components "https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/include/dpsim-models/Components.h"
click node_topology "https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/SystemTopology.cpp"
click node_controllers "https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/Signal/PowerControllerVSI.cpp"
click node_voltage_controller "https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/Signal/VoltageControllerVSI.cpp"
click node_simulation "https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/Simulation.h"
click node_factory "https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/MNASolverFactory.h"
click node_mna "https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/MNASolver.cpp"
click node_state_space "https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/MNAStateSpaceContributor.cpp"
click node_powerflow "https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/PFSolver.cpp"
click node_interface_worker "https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/InterfaceWorker.h"
click node_villas "https://github.com/sogno-platform/dpsim/blob/master/dpsim-villas/src/InterfaceWorkerVillas.cpp"
click node_results "https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/Simulation.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_components,node_topology,node_controllers,node_voltage_controller,node_engineer toneBlue
class node_simulation,node_factory,node_mna,node_state_space,node_powerflow,node_results toneAmber
class node_cim,node_interface_worker,node_villas toneMint
class node_matpower,node_bindings toneRose
```

## Components

### Network models

- [Grid components](https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/include/dpsim-models/Components.h): `dpsim-models/include/dpsim-models/Components.h`
- [System topology](https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/SystemTopology.cpp): `dpsim-models/src/SystemTopology.cpp`
- [VSI controllers](https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/Signal/PowerControllerVSI.cpp): `dpsim-models/src/Signal/PowerControllerVSI.cpp`
- [Voltage control](https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/Signal/VoltageControllerVSI.cpp): `dpsim-models/src/Signal/VoltageControllerVSI.cpp`

### Simulation runtime

- [Simulation control](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/Simulation.h): `dpsim/include/dpsim/Simulation.h`
- [Solver selection](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/MNASolverFactory.h): `dpsim/include/dpsim/MNASolverFactory.h`
- [MNA solver](https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/MNASolver.cpp): `dpsim/src/MNASolver.cpp`
- [State-space coupling](https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/MNAStateSpaceContributor.cpp): `dpsim/src/MNAStateSpaceContributor.cpp`
- [Power-flow solver](https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/PFSolver.cpp): `dpsim/src/PFSolver.cpp`
- [Simulation results](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/Simulation.h): `dpsim/include/dpsim/Simulation.h`

### Import and interfaces

- [CIM reader](https://github.com/sogno-platform/dpsim/blob/master/dpsim-models/src/CIM/Reader.cpp): `dpsim-models/src/CIM/Reader.cpp`
- [Interface worker](https://github.com/sogno-platform/dpsim/blob/master/dpsim/include/dpsim/InterfaceWorker.h): `dpsim/include/dpsim/InterfaceWorker.h`
- [VILLAS interface](https://github.com/sogno-platform/dpsim/blob/master/dpsim-villas/src/InterfaceWorkerVillas.cpp): `dpsim-villas/src/InterfaceWorkerVillas.cpp`

### Python API

- [MATPOWER reader](https://github.com/sogno-platform/dpsim/blob/master/python/src/dpsim/matpower.py): `python/src/dpsim/matpower.py`
- [Python bindings](https://github.com/sogno-platform/dpsim/blob/master/dpsim/src/pybind/main.cpp): `dpsim/src/pybind/main.cpp`

### Other components

- **Simulation user**

## Connections

- Simulation user → Simulation control: configures and runs (evidence: `README.md`)
- Simulation user → CIM reader: loads network (evidence: `README.md`)
- CIM reader → System topology: builds topology
- Simulation user → MATPOWER reader: imports case (evidence: `python/src/dpsim/matpower.py`)
- MATPOWER reader → Python bindings: uses components (evidence: `python/src/dpsim/matpower.py`)
- Simulation control → Solver selection: creates solvers (evidence: `dpsim/include/dpsim/Simulation.h`)
- Solver selection → MNA solver: selects solver
- Simulation control → Power-flow solver: initializes by power flow
- Simulation control → State-space coupling: extracts state space
- Simulation control → Simulation results: logs results (evidence: `dpsim/include/dpsim/Simulation.h`)
- Simulation control → Interface worker: exchanges values
- Interface worker → VILLAS interface: specializes interface (evidence: `dpsim-villas/src/InterfaceWorkerVillas.cpp`)
- Simulation user → VILLAS interface: connects protocols (evidence: `README.md`)
- VSI controllers → Grid components: models inverter control
- Voltage control → Grid components: models voltage control
