|
| 1 | +# closed_loop_Regazzoni example |
| 2 | + |
| 3 | +For full svZeroDTuner usage and configuration guidance, see the svZeroDTuner guide on the docs site: <https://simvascular.github.io/svZeroDSolver/tuner.html>. |
| 4 | + |
| 5 | +This example tunes a four-chamber closed-loop heart model (based on Regazzoni et al.) with |
| 6 | +systemic and pulmonary circulations. Scalar hemodynamic targets are used — systemic arterial |
| 7 | +pressure and left-ventricular ejection fraction. |
| 8 | + |
| 9 | +All inputs and targets are in SI units: |
| 10 | + |
| 11 | +- Pressure: Pa |
| 12 | +- Flow: m³/s |
| 13 | +- Resistance: Pa·s/m³ |
| 14 | +- Compliance: m³/Pa |
| 15 | + |
| 16 | +## Model |
| 17 | + |
| 18 | +- Four `LinearElastanceChamber` blocks (LV, RV, LA, RA) with `piecewise_cosine` activation |
| 19 | +- Systemic circuit: aortic valve → systemic arteries (`AR_SYS`) → systemic veins (`VEN_SYS`) |
| 20 | +- Pulmonary circuit: pulmonary valve → pulmonary arteries (`AR_PUL`) → pulmonary veins (`VEN_PUL`) |
| 21 | + |
| 22 | +Tunable parameters include cardiac elastances (`LV.Emax`, `RV.Emax`), vascular resistances |
| 23 | +(`AR_SYS.R_poiseuille`), and systemic arterial compliance (`AR_SYS.C`). |
| 24 | + |
| 25 | +## Tuning configurations |
| 26 | + |
| 27 | +| File | Description | |
| 28 | +|---|---| |
| 29 | +| `tuning_nelder_mead.yaml` | Nelder-Mead; scalar systemic pressure + LV EF targets | |
| 30 | +| `tuning_differential_evolution.yaml` | Differential evolution; same targets | |
| 31 | +| `tuning_time_series_target.yaml` | Time-series aortic pressure target (`targets/target_pressure_ar_sys.csv`) | |
| 32 | +| `tuning_complex.yaml` | Larger parameter set with log/max scaling | |
| 33 | + |
| 34 | +## Quick start |
| 35 | + |
| 36 | +Install the package once from the repository root: |
| 37 | + |
| 38 | +```bash |
| 39 | +pip install -e . |
| 40 | +``` |
| 41 | + |
| 42 | +Then run from this directory: |
| 43 | + |
| 44 | +1. Baseline inspection: |
| 45 | + |
| 46 | + ```bash |
| 47 | + python -c 'from main import run_baseline; run_baseline("model.json")' |
| 48 | + ``` |
| 49 | + |
| 50 | + Writes `baseline_results/` with time-series CSV, summary CSV, and plots. |
| 51 | + |
| 52 | +2. (Optional) Sensitivity screening to identify influential parameters: |
| 53 | + |
| 54 | + ```bash |
| 55 | + svzerodtuner sensitivity-analysis sensitivity.yaml |
| 56 | + ``` |
| 57 | + |
| 58 | + Writes `sensitivity_results/` with correlation scores and a ranked bar plot. |
| 59 | + |
| 60 | +3. Optimization: |
| 61 | + |
| 62 | + ```bash |
| 63 | + svzerodtuner optimize tuning_nelder_mead.yaml |
| 64 | + ``` |
| 65 | + |
| 66 | +## Example outputs |
| 67 | + |
| 68 | +### target_comparison.csv |
| 69 | + |
| 70 | +Each row reports how closely the optimized model matches one target: |
| 71 | + |
| 72 | +| Name | Target | Simulated | Target range | % Error | |
| 73 | +|---|---|---|---|---| |
| 74 | +| Systemic arterial max pressure | 13 065 Pa | ~13 065 Pa | ±10% | ~0 | |
| 75 | +| Systemic arterial min pressure | 7 066 Pa | ~7 066 Pa | ±10% | ~0 | |
| 76 | +| LV ejection fraction | 0.50 | ~0.50 | ±5% | ~0 | |
| 77 | + |
| 78 | +### optimization_history/ |
| 79 | + |
| 80 | +| File | Contents | |
| 81 | +|---|---| |
| 82 | +| `objective_history.png` | Objective vs. iteration — confirm the curve flattens before termination | |
| 83 | +| `parameter_evolution.png` | Per-parameter trajectories — flag parameters that converge against a bound | |
| 84 | +| `history.csv` | Full numerical record for post-processing | |
| 85 | + |
| 86 | +### sensitivity_results/ |
| 87 | + |
| 88 | +When sensitivity analysis is run first, `sensitivity_results/` contains: |
| 89 | + |
| 90 | +| File | Contents | |
| 91 | +|---|---| |
| 92 | +| `sensitivity_scores.csv` | First-order correlation scores for each parameter × QoI pair | |
| 93 | +| `sensitivity_bar_<qoi>.png` | Ranked bar chart showing which parameters drive each quantity most | |
| 94 | + |
| 95 | +High-scoring parameters are the best candidates to include in the optimization; low-scoring |
| 96 | +parameters can be fixed at baseline values to reduce the search space. |
| 97 | + |
| 98 | +### optimized_simulation/ |
| 99 | + |
| 100 | +| File | Contents | |
| 101 | +|---|---| |
| 102 | +| `pressures.png` | Pressure waveforms at key junctions over the final cardiac cycle | |
| 103 | +| `flows.png` | Flow waveforms through key vessels | |
| 104 | +| `volumes.png` | Chamber volume waveforms (LV, RV, LA, RA) | |
| 105 | +| `optimized_results.csv` | Full time-series for every output variable | |
| 106 | +| `optimized_summary.csv` | Min / max / mean / std for every output variable | |
0 commit comments