Skip to content

Part II - Adding events to a simulation

Download the jupyter notebook

Simulation with events💡

In the previous notebook we showed you how to start a 3Di simulation. In this notebook we'll continue with the simulation by adding several events:

  • Initial water levels
  • rain
  • breaches
  • laterals

Let's quickly build a simulation again:

from datetime import datetime
from getpass import getpass
from threedi_api_client.api import ThreediApi
from threedi_api_client.versions import V3Api

# Provide authentication details
USERNAME = input("Username")
PASSWORD = getpass("Password")

config = {

api_client: V3Api = ThreediApi(config=config)

# Specify the threedi-model and organisation
organisation_uuid = "b08433fa47c1401eb9cbd4156034c679"
threedimodel = api_client.threedimodels_list(name__icontains='v2_bergermeer').results[0]

simulation = api_client.simulations_create(
        "name": "my simulation with events",
        "organisation": organisation_uuid,
        "duration": 3600  # in seconds, so we simulate for 1 hour


Now that we have created a simulation again, we can start adding some interesting events to the simulation before starting it.

Initial water levels💡

Let's set the water level to 0.5m

waterlevel = api_client.simulations_initial1d_water_level_constant_create(, data={"value": 0.5}


Let's create variable rainfall: every 15 minutes it will decrease in intensity.

rain = api_client.simulations_events_rain_timeseries_create(, data={
        'values': [[0, 0.005], [900, 0.002], [1800, 0.001], [2700, 0.0005], [3600, 0]],
        'units': 'm/s'}


Breaches are dependent on the selected model. So let's first see if the model has any breaches configured and if so use the first one.

potential_breaches = api_client.threedimodels_potentialbreaches_list(

# Let's pick the first potential breach
breach = potential_breaches.results[0]

breach_event = api_client.simulations_events_breaches_create(, data={
        "duration_till_max_depth": 1800,
        "initial_width": 0.5,
        "offset": 1800


We'll add a lateral by specifying a connection_node on which we want the lateral to apply.

lateral = api_client.simulations_events_lateral_constant_create(, data={
        "offset": 900,
        "connection_node": 4,
        "value": 0.001,
        "duration": 300,
        "units": "m3/s"

Events overview💡

To get an overview of all our created events on this simulation:

events = api_client.simulations_events(

Now let's start the simulation:

api_client.simulations_actions_create(, data={"name": "start"})


And eventually the simulation will finish!