Skip to content

Commit 924dcb4

Browse files
authored
Merge pull request #80 from ncdorn/update-svzerod-docs
Add 3D-0D coupling documentation take 2
2 parents 9218880 + 871acfb commit 924dcb4

File tree

8 files changed

+125
-12
lines changed

8 files changed

+125
-12
lines changed

.DS_Store

0 Bytes
Binary file not shown.

documentation/.DS_Store

0 Bytes
Binary file not shown.

documentation/multi_physics/solver-input-file/svzerodsolver_interface_parameters/readme.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<h3 id="svzerodsolver_interface_subsection"> svZeroDSolver Interface Subsection </h3>
66
The <i>svZeroDSolver Interface Subsection</i> of the <i>Equation Section</i> defines the parameters needed by the svMultiPhysics solver to interface with the svZeroDSolver.
77

8-
The SimVascular <a href="/documentation/rom_simulation.html#0d-solver"> svZeroDSolver </a> simulates bulk cardiovascular flow rates and pressures using an arbitrary zero-dimensional (0D) lumped parameter model (LPM) of a discrete network of components analogous to electrical circuits. It provides an Application Programming Interface (API) that allows it to communicate and interact with external software applications directly using function calls to programmatically define custom inflow and outflow boundary conditions for a CFD simulation. The svMultiPhysics solver can directly access the svZeroDSolver API by loading the svZeroDSolver as a shared (dynamic) library available after installing the svZeroDSolver.
8+
The SimVascular <a href="/documentation/rom_simulation.html#0d-solver"> svZeroDSolver </a> simulates bulk cardiovascular flow rates and pressures using an arbitrary zero-dimensional (0D) lumped parameter model (LPM) of a discrete network of components analogous to electrical circuits. It provides an Application Programming Interface (API) that allows it to communicate and interact with external software applications directly using function calls to programmatically define custom inflow and outflow boundary conditions for a CFD simulation. The svMultiPhysics solver can directly access the svZeroDSolver API by loading the svZeroDSolver as a shared (dynamic) library available after installing the svZeroDSolver. In order to couple svMultiPhysics with the svZeroDSolver, you will need to provide a json file containing the LPN to couple the 3D domain to. Documentation on how to structure this json file can be found in the <a href="/documentation/rom_simulation.html#0d-solver-user-guide-svMP-coupling"> svZeroDSolver documentation </a>
99

1010
The <i>svZeroDSolver Interface Subsection </i> is organized as follows
1111
<div style="background-color: #F0F0F0; padding: 10px; border: 1px solid #d0d0d0; border-left: 1px solid #d0d0d0">
@@ -18,8 +18,6 @@ The <i>svZeroDSolver Interface Subsection </i> is organized as follows
1818
The <strong>svZeroDSolver_interface</strong> keyword activates coupling for boundary conditions with the
1919
&lt;<strong>Time_dependence</strong>&gt; Coupled &lt;<strong>&#47;Time_dependence</strong>&gt; keyword for the enclosing equation coupled boundary condition.
2020

21-
The value of <i>svzerodsolver_interface_name</i> can be any string name and is not currently used.
22-
2321
<!-- ------------------------------------------- -->
2422
<!-- ---- svZeroDSolver_interface parameters --- -->
2523
<!-- ------------------------------------------- -->

documentation/rom_simulation.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ <h4 class="skipTo 0d-solver">0D Solver</h4>
192192
<p class="skipTo 0d-solver-user-guide-run">Running svZeroDSolver</p>
193193
<p class="skipTo 0d-solver-user-guide-input">Input File Format</p>
194194
<p class="skipTo 0d-solver-user-guide-output">Simulation Outputs</p>
195+
<p class="skipTo 0d-solver-user-guide-svMP-coupling">Coupling to svMultiPhysics</p>
195196
</div>
196197
<p class="skipTo 0d-solver-calibrator">svZeroDCalibrator</p>
197198
<p class="skipTo 0d-solver-visualization">svZeroDVisualization</p>
@@ -286,6 +287,9 @@ <h4 class="skipTo 0d-solver">0D Solver</h4>
286287
<span id="0d-solver-user-guide-output">
287288
<zero-md src="rom_simulation/0d-solver/user-guide-output/readme.md" no-shadow></zero-md>
288289
</span>
290+
<span id="0d-solver-user-guide-svMP-coupling">
291+
<zero-md src="rom_simulation/0d-solver/user-guide-svmp-coupling/readme.md" no-shadow></zero-md>
292+
</span>
289293
<span id="0d-solver-calibrator">
290294
<zero-md src="rom_simulation/0d-solver/calibrator/readme.md" no-shadow></zero-md>
291295
</span>

documentation/rom_simulation/0d-solver/install/readme.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
There are three ways to install svZeroDSolver:
44

5-
1. Download an installer from [SimTK Simvascular Downloads](https://simtk.org/frs/?group_id=188).
5+
1. Download an installer from [SimTK Simvascular Downloads](https://simtk.org/frs/?group_id=188). This will download an executable based on the most recent release.
6+
7+
However, in order to have access to the most up-to-date code, it is recommended to install directly from the github source code using one of the following options:
68
2. Install using pip. This is the recommended method for using the Python API.
79
3. Build using CMake. This is the recommended method for using the C++ interface.
810

@@ -17,10 +19,29 @@ For a pip installation, simply run the following command
1719
pip install git+https://github.com/simvascular/svZeroDSolver.git
1820
```
1921

22+
If you would like to clone the repository in order to develop or inspect the source code, you can do the following:
23+
24+
```bash
25+
git clone https://github.com/simvascular/svZeroDSolver.git
26+
cd svZeroDSolver
27+
pip install -e .
28+
```
29+
30+
<br/>
31+
<details>
32+
<summary><mark><b>Note: installing via pip on HPC cluster</b></mark></summary>
33+
34+
When installing the svzerodsolver via pip on an HPC cluster, ensure that you are on an interactive node with at least 8GB of memory. For example, on the Sherlock HPC cluster (where the default memory for an interactive node is 4GB) you would request a node with adequate memory using
35+
```bash
36+
sdev -m 8GB
37+
```
38+
</details>
39+
<br/>
40+
2041
### Using CMake
2142

2243
If you want to build svZeroDSolver manually from source, clone the repository
23-
and run the following commands from the top directory of the project:
44+
and run the following commands from the top directory of the svZeroDSolver project:
2445

2546
```bash
2647
mkdir Release

documentation/rom_simulation/0d-solver/user-guide-input/readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ The top-level structure of both is:
1616
In the following sections, the individual categories are described in more
1717
detail.
1818

19+
Examples of how blocks may be specified in a json configuration file can be found within each block's respective class documentation [here](https://simvascular.github.io/svZeroDSolver/annotated.html)
20+
1921
#### Simulation parameters
2022

2123
The svZeroDSolver can be configured with the following options in the
2224
`simulation_parameters` section of the input file. Parameters without a
23-
default value must be specified.
25+
default value must be specified. an example of the simulation parameters in a json configuration file can be found [here](https://simvascular.github.io/svZeroDSolver/struct_simulation_parameters.html)
2426

2527
|Parameter key | Description | Default value |
2628
|-----------------------------------------------|------------------------------------------------------------ | --------------|

documentation/rom_simulation/0d-solver/user-guide-run/readme.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
### Run svZeroDSolver from the command line
22

33
svZeroDSolver can be executed from the command line using a JSON configuration
4-
file.
4+
file. In this case we will use the test case ```steadyFlow_RLC_R.json```. Once you have cloned the svZeroDSolver Github repository and built svZeroDSolver, navigate to the top level of the svZeroDSolver repository and run the following command.
55

66
```bash
77
svzerodsolver tests/cases/steadyFlow_RLC_R.json result_steadyFlow_RLC_R.csv
88
```
99

10-
The result will be written to a CSV file.
10+
The result will be written to a CSV file at the path specified.
1111

1212
### Run svZeroDSolver from other programs
1313

@@ -28,15 +28,15 @@ in the test cases at `svZeroDSolver/tests/test_interface`.
2828
#### In Python
2929

3030
Please make sure that
31-
you installed svZerodSolver via pip to enable this feature. We start by
31+
you have installed svZerodSolver via pip to enable this feature. We start by
3232
importing pysvzerod:
3333

3434
```python
3535
>>> import pysvzerod
3636
```
3737

3838
Next, we create a solver from our configuration. The configuration can
39-
be specified by either a path to a JSON file:
39+
be specified by either a path to a JSON file. In this case we are using the test case ```steadyFlow_RLC_R.json```. if you have are running this code from the top level of the svZeroDSolver directory, use the following path. Otherwise, adjust the path to reflect the directory you are currently in.
4040

4141
```python
4242
>>> solver = pysvzerod.Solver("tests/cases/steadyFlow_RLC_R.json")
@@ -45,11 +45,12 @@ be specified by either a path to a JSON file:
4545
or as a Python dictionary:
4646

4747
```python
48-
>>> my_config = {...}
48+
>>> import json
49+
>>> my_config = json.load(open("tests/cases/steadyFlow_RLC_R.json"))
4950
>>> solver = pysvzerod.Solver(my_config)
5051
```
5152

52-
To run the simulation we add:
53+
To run the simulation we run:
5354

5455
```python
5556
>>> solver.run()
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
### Coupling svZeroDSolver to svMultiPhysics
2+
3+
svZeroDSolver can be coupled to svMultiPhysics to prescribe lumped parameter network (LPN) boundary conditions at the outlet of the 3D domain. This provides a powerful, modular multi-fidelity framework where we can implement and assign different types of boundary conditions, with many options spanning from the standard Windkessel boundary conditions to fully closed-loop circulation models.
4+
5+
#### svMultiPhysics file format
6+
7+
To activate the coupling from the svMultiPhysics side, add an `svZeroDSolver_interface` block inside the equation definition and mark the corresponding boundary conditions as `Coupled`. A minimal XML excerpt looks like this:
8+
9+
```xml
10+
<Add_equation type="fluid">
11+
...
12+
<svZeroDSolver_interface>
13+
<Coupling_type> semi-implicit </Coupling_type>
14+
<Configuration_file> svzerod_3Dcoupling.json </Configuration_file>
15+
<Shared_library> ../../../../svZeroDSolver/build/src/interface/libsvzero_interface.dylib </Shared_library>
16+
<Initial_flows> 0.0 </Initial_flows>
17+
<Initial_pressures> 0.0 </Initial_pressures>
18+
</svZeroDSolver_interface>
19+
20+
<Add_BC name="lumen_outlet">
21+
<Type>Neu</Type>
22+
<Time_dependence>Coupled</Time_dependence>
23+
<svZeroDSolver_block> RCR_coupling </svZeroDSolver_block>
24+
</Add_BC>
25+
</Add_equation>
26+
```
27+
28+
Where:
29+
- `Configuration_file` points to the 3D-0D coupling JSON file
30+
- `Shared_library` points to the svZeroDSolver interface in your svZeroDSolver build directory.
31+
- Each `Add_BC` `svZeroDSolver_block` should correspond to one `external_solver_coupling_block` listed in the svZeroDSolver JSON, enabling the 3D face to exchange data with the matching 0D block.
32+
33+
#### svZeroDSolver file format
34+
35+
We only need to add one additional key to the top level structure of the svZeroDSolver json file:
36+
37+
```python
38+
{
39+
"simulation_parameters": {...},
40+
"vessels": [...],
41+
"junctions": [...],
42+
"boundary_conditions": [...],
43+
"external_solver_coupling_blocks": [...]
44+
}
45+
```
46+
47+
The `simulation_parameters` block reuses the standard svZeroDSolver keys, but a few fields are essential for 3D–0D coupling. The most common options are listed below.
48+
49+
| Parameter key &emsp; | Required &emsp; | Description |
50+
|----------------------|-----------------|-------------|
51+
| `coupled_simulation` &emsp; | Yes &emsp; | Must be set to `true` so the solver exchanges interface data with svMultiPhysics. |
52+
| `number_of_time_pts` &emsp; | Yes &emsp; | Number of discrete points for which the svZeroDSolver will integrate the 0D model between 3D timesteps. |
53+
| `steady_initial` &emsp; | Optional &emsp; | Starts the coupled run from a steady-state solution when `true`; set to `false` if transient start-up data are provided by svMultiPhysics. `false` is preferred in most cases |
54+
55+
Other general svZeroDSolver <a href="/documentation/rom_simulation.html#0d-solver-user-guide-input"> simulation parameters </a> (e.g. tolerances or error controls) can also be included as needed and behave the same as in standalone 0D simulations.
56+
57+
each `external_solver_coupling_block` will connect some block in the 0D model to a boundary of the 3D model. The structure of each `external_solver_coupling_block` is as follows:
58+
59+
```python
60+
{
61+
"name": "sample_block",
62+
"type": "FLOW",
63+
"location": "inlet",
64+
"connected_block": "boundary_condition_1",
65+
"periodic": false,
66+
"values": {
67+
"t": [
68+
0.0,
69+
1.0
70+
],
71+
"Q": [
72+
1.0,
73+
1.0
74+
]
75+
}
76+
}
77+
```
78+
The keys inside an `external_solver_coupling_block` control how a 3D boundary exchanges data with the 0D model.
79+
80+
| Parameter key &emsp; | Required &emsp; | Description |
81+
|----------------------|-----------------|-------------|
82+
| `name` &emsp; | Yes &emsp; | Unique identifier for the coupling block; used to label exchanged interface results. |
83+
| `type` &emsp; | Yes &emsp; | Quantity sent from the 0D solver to the 3D solver; currently `FLOW` or `PRESSURE` are supported. |
84+
| `location` &emsp; | Yes &emsp; | Boundary location **with respect to the 0D model** (`inlet`, `outlet`) that the coupling block represents. For example, an outlet BC for the 3D model would use an `inlet` coupling block. |
85+
| `connected_block` &emsp; | Yes &emsp; | `name` of the svZeroDSolver boundary condition or block that supplies the coupled data. |
86+
| `periodic` &emsp; | Optional &emsp; | Set `true` if the provided waveform should repeat when the 3D solver requests multiple cycles. |
87+
| `values` &emsp; | Yes &emsp; | Populated by the solver for data handling between 3D and 0D simulation, leave at default values {"t": [0.0, 1.0], "Q": [1.0, 1.0]} |

0 commit comments

Comments
 (0)