Small, runnable scripts that show how to build risk models with prophys
prophys is a Python library by RhineQC for models that combine geometry, physics and uncertainty in one differentiable graph. You write the model once and then sample it, calibrate it against measurements and optimise a design with the same gradient. Every number comes back with its error bar.
This repository holds a set of examples that use the public API only. They start with a model of a few lines and build up step by step to calibration, sensitivity analysis, stochastic processes and design optimisation. Every example stays within the free tier, so it runs without a license.
pip install -r requirements.txtThis installs prophys, NumPy and Matplotlib. prophys needs Python 3.11 or newer and brings JAX with it.
python examples/01_first_model.pyEach script prints its results and writes its figure to assets as a light and a dark PNG on a transparent background. Every example runs in a few seconds on a laptop CPU.
| Script | What it shows |
|---|---|
| 01_first_model | Houses, turbines and an uncertain acceptance drop in one compiled model |
| 02_symbolic_expressions | Parameters, expressions and exact gradients through jax.grad |
| 03_distributions | Five distribution families and a maximum likelihood fit with fit_distribution |
| 04_geometry | Frames, polygons and grids with signed distances and smooth containment |
| 05_monte_carlo_risk | A flood damage model with quantiles, tail risk and Monte Carlo errors |
| 06_calibration | Fitting a cooling law with standard errors, propagation and a profile likelihood |
| 07_design_optimization | Placing turbines inside a permitted area with constraints on spacing |
| 08_sensitivity | Local elasticities, Sobol indices and a response surface of a beam |
| 09_terrain_route_3d | A road over a raster Field, optimised to trade climb against length |
| 10_plume_dispersion | A Gaussian plume under uncertain wind and a map of exceedance probability |
| 11_time_series_process | An Ornstein Uhlenbeck process fitted to data and a path dependent quantity |
| 12_power_grid_network | DC power flow under uncertain wind with line reinforcement as binary decisions |
|
|
|
|
|
|
|
|
|
|
|
|
The example scripts and figures in this repository are released under the MIT License, see LICENSE.
prophys itself is proprietary software by RhineQC GmbH. It includes a free tier for models of up to 250 structural objects, such as points, polygon vertices, raster cells and network nodes. Monte Carlo samples, observations and optimiser steps never count towards that limit. Larger models need a signed license from RhineQC.