Python Tutorials

The ladder, worked in Python.

Each tutorial starts from the one before and adds exactly one new thing. Work through them in order; each is a complete runnable script rather than a fragment.

  1. Your first simulation. A source and a resistor. The shape of a script, and how to read a result back.
  2. Adding dynamics. An inductor, the transient it produces, and how to choose a time step.
  3. A network, and where it starts from. A line between two buses, and initializing the dynamic run from a powerflow.
  4. Applying a fault. Switching during a run, and why clearing a fault needs more care than applying one.
  5. The same circuit in two domains. Waveforms against envelopes, and what the envelope buys.
  6. Adding a machine. A synchronous generator, initializing it correctly, and what the model order changes.
  7. Exchanging data with another tool. Handing a value out of a running simulation, and where the boundary lies.

A rung on converters and their control belongs between the last two and is not written yet.

What you need

DPsim importable from Python. If it is not, see install or build.

Reading results back and plotting them uses the data processing package the example notebooks also use. It is separate from DPsim and is imported as villas.dataprocessing.


Your First Simulation

Build a network in Python, run it, and read the results back.

Adding Dynamics

An element that stores energy, the transient it produces, and how to choose a time step.

A Network, and Where It Starts From

A line between two buses, and initializing the dynamic run from a powerflow.

Applying a Fault

Switching during a run, and why clearing a fault needs more care than applying one.

The Same Circuit in Two Domains

Running one circuit as waveforms and as envelopes, and comparing the two.

Adding a Machine

A synchronous generator, initializing it correctly, and what the model order changes.

Exchanging Data With Another Tool

Handing a value out of a running simulation, and where the boundary lies.