OpenAPI-aligned process safety analysis package with materials, source, dispersion, fire, relief, and hazard-evaluation services
Project description
Deep Safety
Deep Safety is a foundational process-safety layer for physics-driven, verifiable consequence analysis.
It gives teams one model contract that can be used across:
- Python notebooks
- FastAPI services
- GitHub Pages browser-local workflows
- MCP/agent tooling
- Docker deployments
The goal is simple: keep the physics explicit and reusable so decision systems can rely on the same source-term, dispersion, fire/explosion, and effect logic.
Quick Start
$ pip install deepsafety
$ deepsafety-api
$ python -m deepsafety
Typing-style cue:
user@plant:~$ pip install deepsafety
Collecting deepsafety ...
Successfully installed deepsafety
user@plant:~$ deepsafety-api --host 0.0.0.0 --port 8000
Deep Safety API ready at http://0.0.0.0:8000 _
# Optional notebook stack
$ pip install "deepsafety[jupyter]"
Why Deep Safety
- Physics-first model chain: materials -> source -> dispersion/effects -> hazard evaluation
- Verifiable formulas: equations are documented and exposed in API metadata
- Transparent constants: physical meaning and source are documented
- Cross-platform integration: same model vocabulary in API, notebooks, app, and MCP tools
- Sensitivity-friendly design: constants can be overridden per request
Model Chain
- Materials and operating conditions define the basis.
- Scenario and source models calculate release rate, duration, and phase.
- Dispersion, fire/explosion, and effect models compute consequence metrics.
- Hazard-evaluation workflows consume the same outputs in HAZOP/FMEA/What-If style studies.
Data Provenance
Starter registries are packaged as JSON data (not hard-coded in model logic):
deepsafety/data/materials_registry.jsondeepsafety/data/toxic_criteria_registry.jsondeepsafety/data/constants_registry.json
This keeps assumptions inspectable and easier to govern.
Constants Override Example
Constants can be overridden request-by-request for sensitivity studies.
{
"model_type": "jet_fire",
"inputs": {
"release_rate_kg_s": 2.5,
"heat_of_combustion_kj_kg": 46000,
"distance_m": 35
},
"constants": {
"fire.default_radiative_fraction": 0.4
}
}
from deepsafety import DeepSafetyClient
client = DeepSafetyClient("http://127.0.0.1:8000")
result = client.calculate(
"fire.point_source_heat_flux",
{
"distance_m": 35,
"burning_rate_kg_s": 2.5,
"heat_of_combustion_kj_kg": 46000,
},
constants={"fire.default_radiative_fraction": 0.4},
)
API Surface
Core service and metadata:
GET /modelsGET /models/{model_id}POST /models/{model_id}/calculateGET /constantsGET /constants/{model_id}GET /service-catalog
Materials and health:
GET /materialsGET /materials/{materialId}GET /materials/{materialId}/toxicityGET /materials/{materialId}/flammabilityGET /materials/{materialId}/reactivityPOST /health/convert-concentrationPOST /health/probit/evaluatePOST /health/exposure/twaPOST /health/exposure/compliancePOST /industrial-hygiene/ventilation/dilutionPOST /industrial-hygiene/ventilation/local-exhaustPOST /industrial-hygiene/liquid-pool/evaporation
Scenario and source:
POST /scenario-engine/defineGET /scenario-library/templatesPOST /source-models/liquid-holePOST /source-models/tank-holePOST /source-models/liquid-pipePOST /source-models/gas-holePOST /source-models/gas-pipePOST /source-models/flashing-liquidPOST /source-models/scenario/selectPOST /source-models/conservative-analysisPOST /source-models/solve
Dispersion, fire/explosion, effects:
POST /dispersion/gaussian-plumePOST /dispersion/gaussian-puffPOST /dispersion/dense-gasPOST /dispersion/isoplethPOST /dispersion/toxic-endpoints/evaluatePOST /dispersion/prevention-mitigationPOST /dispersion-models/solvePOST /fire-explosion/flammability/mixturePOST /fire-explosion/locPOST /fire-explosion/ignition-energyPOST /fire-explosion/tnt-equivalencyPOST /fire-explosion/multi-energyPOST /fire-explosion/vcePOST /fire-explosion/blevePOST /fire-explosion-models/solvePOST /effect-models/solvePOST /toxic-criteria/lookup
Prevention, reactivity, relief, hazard evaluation:
POST /prevention/inerting/purgePOST /prevention/static-electricity/riskPOST /prevention/area-classificationPOST /prevention/fire-protection/strategyPOST /reactivity/calorimetry/interpretPOST /reactivity/screeningPOST /reactivity/controlPOST /relief/devices/selectPOST /relief/system/analyzePOST /relief/effluent-handling/selectPOST /relief/sizing/liquidPOST /relief/sizing/gas-vaporPOST /relief/sizing/two-phasePOST /relief/sizing/deflagration-ventPOST /relief/sizing/external-firePOST /relief/sizing/thermal-expansionPOST /hazard-evaluation/checklistPOST /hazard-evaluation/safety-reviewPOST /hazard-evaluation/inherent-safety-reviewPOST /hazard-evaluation/preliminary-hazard-analysisPOST /hazard-evaluation/relative-rankingPOST /hazard-evaluation/hazopPOST /hazard-evaluation/fmeaPOST /hazard-evaluation/what-ifPOST /hazard-evaluation/what-if-checklistPOST /hazard-evaluation/information-requirements/validatePOST /prevention-response-models/solve
GIS, visualization, and sign analysis:
POST /visualization/solvePOST /signs/analyzePOST /gis/scenarios/evaluatePOST /gis/impact-zones
GitHub Pages Structure
docs/index.html-> documentation landing pagedocs/api-docs.html-> endpoint and formula referencedocs/tutorials.html-> guided training and incident walkthroughsdocs/use-cases.html-> interactive/app + notebook entry pointsdocs/app.html-> interactive map app (with consequence rings)docs/readme.html-> web copy of this README
Notebook Entry Points
notebooks/all_endpoints_tutorial_workbook.ipynbnotebooks/deepsafety_explorer.ipynbnotebooks/buncefield_tutorial.ipynbnotebooks/csb_incident_tutorial.ipynb
Runtime Options
# Local API
python -m uvicorn deepsafety.api:app --host 127.0.0.1 --port 8000
# Docker
docker build -t deepsafety .
docker run --rm -p 8000:8000 deepsafety
# Compose
docker compose up --build
CI/CD and PyPI Publishing
Deep Safety now publishes through GitHub Actions:
CIworkflow:- runs tests
- builds
sdistandwheel - runs
twine checkon artifacts
Publish PyPIworkflow (.github/workflows/publish-pypi.yml):- triggers on tags matching
v*and on manual dispatch - reruns tests and package checks before publish
- publishes artifacts to PyPI
- triggers on tags matching
Required repository configuration:
- Add
PYPI_API_TOKENin GitHub secrets (repository orpypienvironment secret) - Optional fallback secret name:
PYPI_TOKEN - Optional org/repo-specific fallback:
DEEPSAFETYPYPI - Configure a
pypienvironment in GitHub if you want protected release approvals
Release flow:
git tag v1.0.1
git push origin v1.0.1
MCP
deepsafety-mcp exposes Deep Safety operations for tool-driven and agent-driven workflows against the same API model chain.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepsafety-1.0.1.tar.gz.
File metadata
- Download URL: deepsafety-1.0.1.tar.gz
- Upload date:
- Size: 70.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7694d8f4869b03714c1b4cc8527f183089461c63cf00639efaf98a03c2825b3
|
|
| MD5 |
1bfc0e0679d2818444c45749f5ff333a
|
|
| BLAKE2b-256 |
91905084f537076ecf34d563400a032a87a35a6b592ae6ca01cdbed69b2a3e29
|
File details
Details for the file deepsafety-1.0.1-py3-none-any.whl.
File metadata
- Download URL: deepsafety-1.0.1-py3-none-any.whl
- Upload date:
- Size: 73.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4fcc3747fd06b361d6756feca8761f3e20238877a9486855ebd5321da52f5a1
|
|
| MD5 |
238c712de31d4ea3314c9831d140b0bd
|
|
| BLAKE2b-256 |
73db3659f7e862ba57427db52ea5db7ef4131c617b104a717bada3cd6afb1f26
|