Simulator
Endpoint: simulator/simulate-scenario
To simulate an existing scenario in a user's workspace or a built-in scenario, you can use the simulator/simulate-scenario
endpoint.
Simply supply the scenario's id and include any additional simulation parameters, such as time step length, lateral resolution or number of simulation runs as json data in the POST request.
Note
Every scenario specifies the allowable range of values for time_step_length
and lateral_resolution
(see allowed_time_step_lengths
and allowed_lateral_resolutions
of a scenario).
When specifying values for the simulator, it is important to ensure that they fall within the acceptable range for the selected scenario.
When the SESAM API receives a simulation request, it will initiate a background task to conduct the simulation.
You'll receive a status url in response (see simulator/simulate_scenario-status/{result_id}
endpoint), which you can use to track the status of the simulation workflow and retrieve the logs for each simulation run.
Note
It's important to understand that a simulation often comprises multiple runs with different seed values for the random number generator, forming what we refer to as a "simulation workflow". Through the status url, you can conveniently access the state and log output of each individual run within a workflow.
sequenceDiagram
participant C as Client
participant S as SESAM API
Note over C,S: Login to retrieve token
C->>+S: Login (username, password)
S->>-C: Token
Note over C,S: Simulate scenario
C->>+S: POST simuator/simulate-scenario {...}
S->>-C: OK, status_url
loop until state == SUCCESS
C->>+S: GET status_url
S->>-C: workflow_state, logs, ...
end
Here is an example python code to show the simulation of a scenario.
The outputs of each simulation run can be retrieved with the workspace/simulation-run-zip endpoint.
Endpoint: simulator/simulate-builtin-scenario
The simulator/simulate-builtin-scenario/{scenario_id}
endpoint functions similarly to the simulator/simulate-scenario
endpoint described earlier.
The key difference is that the former allows users to simulate a built-in scenario by supplying its id, while the latter is limited to user-created scenarios only.