Tutorials

Incident-based walkthroughs with runnable notebooks.

These tutorials are designed to be practical, reproducible, and physics transparent. Each one links to a notebook that can be run locally with the same API and constants system used in production integrations.

API Reference Tutorials Use Cases README

Quick Start

From installation to first consequence result

Install the package, load materials, create a persisted scenario, start an analysis job, and inspect the completed workflow resources.

pip install deepsafety

from deepsafety import DeepSafetyClient

client = DeepSafetyClient("http://127.0.0.1:8000")
materials = client.list_materials("gasoline")
scenario = client.create_scenario({
    "name": "Gasoline storage case",
    "model_profile": {"domain": "integrated_consequence"},
    "inputs": {
        "inventory_mass_kg": {"kind": "scalar", "value": 5000},
        "release_duration_s": {"kind": "scalar", "value": 300}
    }
})
analysis = client.create_analysis({
    "scenario_id": scenario["id"],
    "analysis_type": "integrated_consequence"
})

Scenario Logic

Deterministic vs triplet vs probabilistic runs

Deep Safety keeps scenario mode explicit so teams can compare outcomes instead of embedding assumptions inside an opaque controller.

Mode Intent Typical use
deterministic Single best-estimate operating state Operational planning and day-to-day risk decisions
scenario_triplet Best / realistic / worst input ranges Structured assumption reviews and bounded studies
probabilistic Distributions and Monte Carlo-ready inputs Sensitivity studies and uncertainty-aware decision support

Incident Walkthrough

Buncefield-style vapor cloud workflow

This notebook shows how to configure a tank-overfill style release, build source and dispersion screening outputs, and evaluate blast proxy metrics with explicit assumptions and constants.

Source -> dispersion -> VCE screening
W_TNT = m_fuel * DeltaH_c * eta / DeltaH_TNT
Z = R / W_TNT^(1/3)

Incident Walkthrough

CSB-style toxic release and effect workflow

This notebook demonstrates a toxic release chain using source, Gaussian dispersion, toxic criteria lookup, and probit-based effect estimation for population screening.

Toxic load and response
L_toxic = C^n * t
Y = a + b * ln(L_toxic)
Pr = 0.5 * [1 + erf((Y - 5) / sqrt(2))]

Verification

Change a constant and measure the impact

The tutorial notebooks include a sensitivity section where one constant is overridden per request to show how outputs shift in a controlled and auditable way.

{
  "constants": {
    "fire.default_radiative_fraction": 0.4
  }
}

This pattern is useful for design-margin studies and assumption reviews without forking model code.

Endpoint Workbook

One notebook tour across the full API endpoint surface

A single realistic workbook that starts with the workflow API: create scenarios, validate them, launch analyses and simulations, then continue into source terms, dispersion, fire and explosion, health and hygiene, prevention/reactivity/relief, hazard evaluation, and GIS/sign integration.