Skip to content

Commit f4bc108

Browse files
committed
Merge remote-tracking branch 'origin/master' into claude/gallant-yonath-faecaa
2 parents a3a5164 + 5295b23 commit f4bc108

71 files changed

Lines changed: 8310 additions & 9 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/gui.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
- name: Install Flask dependencies
3434
# The GUI only needs Flask, not the compiled pysvzerod extension.
35-
run: uv sync --no-install-project --group gui
35+
run: uv sync --no-install-project --no-default-groups --group gui
3636

3737
- name: Start Flask Application
3838
run: |

.github/workflows/test.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
- name: Build and test
3030
run: |
31-
uv sync
31+
uv sync --no-default-groups --group dev
3232
cd tests
3333
uv run pytest -v --durations=0 --ignore=test_dirgraph.py
3434
@@ -98,11 +98,10 @@ jobs:
9898
-DENABLE_DISTRIBUTION=ON
9999
uv run --no-sync cmake --build $build --parallel 2
100100
101-
# build installer
102-
choco install nsis -y
103-
echo "C:\Program Files (x86)\NSIS\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
101+
# Build a portable package on CI. This avoids the flaky Chocolatey
102+
# NSIS install path while still producing a Windows artifact.
104103
cd $build
105-
cpack -C Release
104+
cpack -G ZIP -C Release
106105
Copy-Item distribution\svZeroDSolver_* -Destination ..\
107106
108107
- name: Upload installer

.github/workflows/test_visualization.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
# The dirgraph test only needs the Python dev tooling, not the compiled
2424
# pysvzerod extension, so skip building the project.
25-
run: uv sync --no-install-project
25+
run: uv sync --no-install-project --no-default-groups --group dev
2626

2727
- name: Install Graphviz
2828
if: runner.os == 'Linux'

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ build*/
3939
# Node modules (for directed graph visualization)
4040
node_modules/
4141

42+
# Allow csv for target files in svZeroDTuner examples
43+
!applications/svZeroDTuner/examples/**/targets/**/*.csv
44+
4245
# Virtual environments
4346
venv/
4447
.venv/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ You can find more information under the following links:
1515

1616
* [**Documentation**](https://simvascular.github.io/svZeroDSolver)
1717
* [**Developer Guide**](https://simvascular.github.io/svZeroDSolver/developer_guide.html)
18+
* [**svZeroDTuner Guide**](https://simvascular.github.io/svZeroDSolver/tuner.html)
1819
* [**Bug Reports**](https://github.com/simvascular/svZeroDSolver/issues)
1920
* [**Forum**](https://github.com/simvascular/svZeroDSolver/discussions)
2021
* [**About SimVascular**](https://simvascular.github.io)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
baseline_results/
2+
optimization_results*/
3+
sensitivity_results/
4+
reference_codes/
5+
6+
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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

Comments
 (0)