Skip to content

Commit f2b59e0

Browse files
committed
address PR comments
1 parent 491141a commit f2b59e0

File tree

9 files changed

+343
-338
lines changed

9 files changed

+343
-338
lines changed

documentation/rom_simulation.html

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,17 @@ <h4 class="skipTo 1d-solver">1D Solver</h4>
185185
<div>
186186
<h4 class="skipTo 0d-solver">0D Solver</h4>
187187
<div>
188+
<p class="skipTo 0d-solver-theory">Theory</p>
189+
<p class="skipTo 0d-solver-install">Installing svZeroDSolver</p>
188190
<p class="skipTo 0d-solver-user-guide">User Guide</p>
191+
<div style="margin-bottom: -10px;">
192+
<p class="skipTo 0d-solver-user-guide-run">Running svZeroDSolver</p>
193+
<p class="skipTo 0d-solver-user-guide-input">Input File Format</p>
194+
<p class="skipTo 0d-solver-user-guide-output">Simulation Outputs</p>
195+
</div>
189196
<p class="skipTo 0d-solver-calibrator">svZeroDCalibrator</p>
190197
<p class="skipTo 0d-solver-visualization">svZeroDVisualization</p>
191198
<p class="skipTo 0d-solver-gui">svZeroDGUI</p>
192-
<p class="skipTo 0d-solver-theory">Theory</p>
193199
<p class="skipTo 0d-solver-developer">Developer Guide</p>
194200
<p class="skipTo 0d-solver-refs">References</p>
195201
</div>
@@ -262,9 +268,24 @@ <h4 class="skipTo 0d-solver">0D Solver</h4>
262268
<span id="0d-solver">
263269
<zero-md src="rom_simulation/0d-solver/solver/readme.md" no-shadow></zero-md>
264270
</span>
271+
<span id="0d-solver-theory">
272+
<zero-md src="rom_simulation/0d-solver/theory/readme.md" no-shadow></zero-md>
273+
</span>
274+
<span id="0d-solver-install">
275+
<zero-md src="rom_simulation/0d-solver/install/readme.md" no-shadow></zero-md>
276+
</span>
265277
<span id="0d-solver-user-guide">
266278
<zero-md src="rom_simulation/0d-solver/user-guide/readme.md" no-shadow></zero-md>
267279
</span>
280+
<span id="0d-solver-user-guide-run">
281+
<zero-md src="rom_simulation/0d-solver/user-guide-run/readme.md" no-shadow></zero-md>
282+
</span>
283+
<span id="0d-solver-user-guide-input">
284+
<zero-md src="rom_simulation/0d-solver/user-guide-input/readme.md" no-shadow></zero-md>
285+
</span>
286+
<span id="0d-solver-user-guide-output">
287+
<zero-md src="rom_simulation/0d-solver/user-guide-output/readme.md" no-shadow></zero-md>
288+
</span>
268289
<span id="0d-solver-calibrator">
269290
<zero-md src="rom_simulation/0d-solver/calibrator/readme.md" no-shadow></zero-md>
270291
</span>
@@ -274,9 +295,6 @@ <h4 class="skipTo 0d-solver">0D Solver</h4>
274295
<span id="0d-solver-gui">
275296
<zero-md src="rom_simulation/0d-solver/gui/readme.md" no-shadow></zero-md>
276297
</span>
277-
<span id="0d-solver-theory">
278-
<zero-md src="rom_simulation/0d-solver/theory/readme.md" no-shadow></zero-md>
279-
</span>
280298
<span id="0d-solver-developer">
281299
<zero-md src="rom_simulation/0d-solver/developer/readme.md" no-shadow></zero-md>
282300
</span>

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@ boundary conditions. This application is especially valuable for users who lack
1414
3D models or seek an efficient alternative to manual file generation, making the model creation
1515
process both faster and more user-friendly.
1616

17-
### Architecture
18-
19-
svZeroDGUI is built using a robust architecture that includes:
20-
* Frontend: The frontend is developed with HTML, CSS, and JavaScript to create a
21-
responsive and user-friendly interface. It utilizes Cytoscape.js, a popular package for creating
22-
interactive elements and graphical networks.
23-
24-
* Backend: Flask app, Node.js for server-side logic, and Cypress for testing.
25-
This architecture supports an intuitive user experience for
26-
generating and managing 0D input files through a graphical interface.
27-
2817
### How to Use
2918
1. Create a virtual environment with the required `flask` dependency. If using `conda`, use the below commands:
3019
```bash
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Installation
2+
3+
There are three ways to install svZeroDSolver:
4+
5+
1. Download an installer from [SimTK Simvascular Downloads](https://simtk.org/frs/?group_id=188).
6+
2. Install using pip. This is the recommended method for using the Python API.
7+
3. Build using CMake. This is the recommended method for using the C++ interface.
8+
9+
Instructions on the pip and CMake installation methods are below.
10+
11+
### Using pip
12+
13+
For a pip installation, simply run the following command
14+
(cloning of the repository is not required):
15+
16+
```bash
17+
pip install git+https://github.com/simvascular/svZeroDSolver.git
18+
```
19+
20+
### Using CMake
21+
22+
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:
24+
25+
```bash
26+
mkdir Release
27+
cd Release
28+
cmake -DCMAKE_BUILD_TYPE=Release ..
29+
cmake --build .
30+
```
31+
<br/>
32+
<details>
33+
<summary><mark><b>Note: Building on Sherlock for Stanford users</b></mark></summary>
34+
35+
```bash
36+
module load cmake/3.23.1 gcc/14.2.0 binutils/2.38
37+
mkdir Release
38+
cd Release
39+
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/share/software/user/open/gcc/14.2.0/bin/g++ -DCMAKE_C_COMPILER=/share/software/user/open/gcc/14.2.0/bin/gcc ..
40+
cmake --build .
41+
```
42+
</details>
43+
<br/>

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

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,6 @@ interactively select nodes to view simulation results.
1616
drawing the network on an easy-to-use GUI. This provides an alternative to manually
1717
creating files and is useful for users without access to a 3D model.
1818

19-
## Installation
20-
21-
svZeroDSolver can be installed in two different ways. For using the Python API, an installation via pip is recommended.
22-
23-
### Using pip
24-
25-
For a pip installation, simply run the following command
26-
(cloning of the repository is not required):
27-
28-
```bash
29-
pip install git+https://github.com/simvascular/svZeroDSolver.git
30-
```
31-
32-
### Using CMake
33-
34-
If you want to build svZeroDSolver manually from source, clone the repository
35-
and run the following commands from the top directory of the project:
36-
37-
```bash
38-
mkdir Release
39-
cd Release
40-
cmake -DCMAKE_BUILD_TYPE=Release ..
41-
cmake --build .
42-
```
43-
<br/>
44-
<details>
45-
<summary><mark><b>Note: Building on Sherlock for Stanford users</b></mark></summary>
46-
47-
```bash
48-
module load cmake/3.23.1 gcc/14.2.0 binutils/2.38
49-
mkdir Release
50-
cd Release
51-
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/share/software/user/open/gcc/14.2.0/bin/g++ -DCMAKE_C_COMPILER=/share/software/user/open/gcc/14.2.0/bin/gcc ..
52-
cmake --build .
53-
```
54-
</details>
55-
<br/>
56-
5719
## Blocks
5820

5921
The modular architecture of svZeroDSolver relies on "blocks", such as blood vessels, junctions, valves, boundary conditions, etc. Users can assemble and connect these blocks together in a variety of ways to create extensive and customizable 0D circulation models.
@@ -67,6 +29,6 @@ The main categories of blocks implemented in svZeroDSolver are:
6729
<li>Heart valves</li>
6830
</ul>
6931

70-
An overview of all currently implemented blocks can be found [here](https://simvascular.github.io/svZeroDSolver/class_block.html). This collection of building blocks allows to model extensive and complex vascular networks. Many examples of vascular networks can be found [here](https://github.com/simvascular/svZeroDSolver/tree/master/tests/cases). The assembly of these blocks is specified in the `.json` configuration file. The user guide below provides details.
32+
An overview of all currently implemented blocks can be found [here](https://simvascular.github.io/svZeroDSolver/class_block.html). This collection of building blocks allows to model extensive and complex vascular networks. Many examples of vascular networks can be found [here](https://github.com/simvascular/svZeroDSolver/tree/master/tests/cases). The assembly of these blocks is specified in the `.json` configuration file. The <a href="#0d-solver-user-guide">User Guide</a> below provides details.
7133

7234
We are always interested in adding new blocks to expand the funcitonality of svZeroDSolver. For developers interested in contributing, please read the [Developer Guide](https://simvascular.github.io/svZeroDSolver/developer_guide.html).
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
### Input File Format
2+
3+
svZeroDSolver is configured using either a JSON file or a Python dictionary. JSON is a convenient file format to represent a dictionary-like object. More details can be found [here](https://stackoverflow.blog/2022/06/02/a-beginners-guide-to-json-the-data-format-for-the-internet/).
4+
5+
The top-level structure of both is:
6+
7+
```python
8+
{
9+
"simulation_parameters": {...},
10+
"vessels": [...],
11+
"junctions": [...],
12+
"boundary_conditions": [...]
13+
}
14+
```
15+
16+
In the following sections, the individual categories are described in more
17+
detail.
18+
19+
#### Simulation parameters
20+
21+
The svZeroDSolver can be configured with the following options in the
22+
`simulation_parameters` section of the input file. Parameters without a
23+
default value must be specified.
24+
25+
|Parameter key | Description | Default value |
26+
|-----------------------------------------------|------------------------------------------------------------ | --------------|
27+
|`number_of_cardiac_cycles` &emsp; | Number of cardiac cycles to simulate &emsp; | - |
28+
|`number_of_time_pts_per_cardiac_cycle` &emsp; | Number of time steps per cardiac cycle &emsp; | - |
29+
|`absolute_tolerance` &emsp; | Absolute tolerance for time integration &emsp; | $10^{-8}$ |
30+
|`maximum_nonlinear_iterations` &emsp; | Maximum number of nonlinear iterations for time integration &emsp; | $30$ |
31+
|`steady_initial` &emsp; | Toggle whether to use the steady solution as the initial condition for the simulation &emsp; | true |
32+
|`output_variable_based` &emsp; | Output solution based on variables (i.e. flow and pressure at nodes and internal variables) &emsp; | false |
33+
|`output_interval` &emsp; | The frequency of writing timesteps to the output (1 means every timestep is written) &emsp; | $1$ |
34+
|`output_mean_only` &emsp; | Write only the mean values over every timestep to output file &emsp; | false |
35+
|`output_derivative` &emsp; | Write time derivatives to output file &emsp; | false |
36+
|`output_all_cycles` &emsp; | Write all cardiac cycles to output file &emsp; | false |
37+
|`use_cycle_to_cycle_error` &emsp; | Use cycle-to-cycle error to determine number of cycles for convergence &emsp; | false |
38+
|`sim_cycle_to_cycle_percent_error` &emsp; | Percentage error threshold for cycle-to-cycle pressure and flow difference &emsp; | 1.0 |
39+
40+
The option `use_cycle_to_cycle_error` allows the solver to change the number of cardiac cycles it runs depending on the cycle-to-cycle convergence of the simulation. For simulations with no RCR boundary conditions, the simulation will add extra cardiac cycles until the difference between the mean pressure and flow in consecutive cycles is below the threshold set by `sim_cycle_to_cycle_percent_error` at all inlets and outlets of the model. If there is at least one RCR boundary condition, the number of cycles is determined based on equation 21 of <a href="#0d-Pfaller2021">Pfaller et al. (2021)</a>, using the RCR boundary condition with the largest time constant.
41+
42+
43+
<style>
44+
table{
45+
border-collapse: collapse;
46+
border-spacing: 100000px;
47+
border:1px solid #000000;
48+
}
49+
50+
th{
51+
border:0.1px dotted #000000;
52+
padding: 15px;
53+
}
54+
55+
td{
56+
border:0.1px dotted #000000;
57+
padding: 5px;
58+
}
59+
</style>
60+
61+
#### Vessels
62+
63+
More information about the vessels can be found in their respective class references. Below is a template vessel block with boundary conditions, `INFLOW` and `OUT`, at its inlet and outlet respectively.
64+
65+
```python
66+
{
67+
"boundary_conditions": {
68+
"inlet": "INFLOW", # Optional: Name of inlet boundary condition
69+
"outlet": "OUT", # Optional: Name of outlet boundary condition
70+
},
71+
"vessel_id": 0, # ID of the vessel
72+
"vessel_name": "branch0_seg0", # Name of vessel
73+
"zero_d_element_type": "BloodVessel", # Type of vessel
74+
"zero_d_element_values": {...} # Values for configuration parameters
75+
}
76+
```
77+
78+
| Description | Class | `zero_d_element_type` &emsp; | `zero_d_element_values` &emsp; |
79+
| ---------------------------------------- | --------------------------- | --------------------- | ------------------------|
80+
| Blood vessel with optional stenosis &emsp; | BloodVessel &emsp; | `BloodVessel` &emsp; | `C`: Capacitance <br> `L`: Inductance <br> `R_poiseuille`: Poiseuille resistance <br> `stenosis_coefficient`: Stenosis coefficient &emsp; |
81+
82+
83+
#### Junctions
84+
85+
More information about the junctions can be found in their respective class references. Below is a template junction block that connects vessel ID 0 with vessel IDs 1 and 2.
86+
87+
```python
88+
{
89+
"junction_name": "J0", # Name of the junction
90+
"junction_type": "BloodVesselJunction", # Type of the junction
91+
"inlet_vessels": [0], # List of vessel IDs connected to the inlet
92+
"outlet_vessels": [1, 2], # List of vessel IDs connected to the inlet
93+
"junction_values": {...} # Values for configuration parameters
94+
}
95+
```
96+
97+
Description &emsp; | Class &emsp; | `junction_type` &emsp; | `junction_values` &emsp;
98+
------------------------------------- | ---------------------| --------------------- | -----------
99+
Purely mass conserving junction &emsp; | Junction &emsp; | `NORMAL_JUNCTION` &emsp; | - &emsp;
100+
Resistive junction &emsp; | ResistiveJunction &emsp; | `resistive_junction` &emsp; | `R`: Ordered list of resistances for all inlets and outlets &emsp;
101+
Blood vessel junction &emsp; | BloodVesselJunction &emsp; | `BloodVesselJunction` &emsp; | Same as for `BloodVessel` element but as ordered list for each inlet and outlet &emsp;
102+
103+
#### Boundary conditions
104+
105+
More information about the boundary conditions can be found in their respective class references. Below is a template `FLOW` boundary condition.
106+
107+
```python
108+
{
109+
"bc_name": "INFLOW", # Name of the boundary condition
110+
"bc_type": "FLOW", # Type of the boundary condition
111+
"bc_values": {...} # Values for configuration parameters
112+
},
113+
```
114+
115+
Description &emsp; | Class &emsp; | `bc_type` &emsp; | `bc_values` &emsp;
116+
------------------------------------- | ---------------------- | --------------------- | ----------
117+
Prescribed (transient) flow &emsp; | FlowReferenceBC &emsp; | `FLOW` &emsp; | `Q`: Time-dependent flow values <br> `t`: Time steps &emsp;
118+
Prescribed (transient) pressure &emsp; | PressureReferenceBC &emsp; | `PRESSURE` &emsp; | `P`: Time-dependent pressure values <br> `t`: Time steps &emsp;
119+
Resistance &emsp; | ResistanceBC &emsp; | `RESISTANCE` &emsp; | `R`: Resistance <br> `Pd`: Time-dependent distal pressure <br> `t`: Time stamps &emsp;
120+
Windkessel or RCR &emsp; | WindkesselBC &emsp; | `RCR` &emsp; | `Rp`: Proximal resistance <br> `C`: Capacitance <br> `Rd`: Distal resistance <br> `Pd`: Distal pressure &emsp;
121+
Coronary outlet &emsp; | OpenLoopCoronaryBC &emsp; | `CORONARY` &emsp; | `Ra`: Proximal resistance <br> `Ram`: Microvascular resistance <br> `Rv`: Venous resistance <br> `Ca`: Small artery capacitance <br> `Cim`: Intramyocardial capacitance <br> `Pim`: Intramyocardial pressure <br> `Pv`: Venous pressure &emsp;
122+
123+
The above table describes the most commonly used boundary conditions. In addition, svZeroDSolver includes various closed-loop boundary conditions. See <a href="#0d-Menon2023">Menon et al. (2023)</a> for details of a closed-loop 0D model. Examples can also be found in `svZeroDSolver/tests/cases`.
124+
125+
Values of the boundary condition can be specified as a function of time as follow:
126+
```python
127+
{
128+
"bc_name": "INFLOW", # Name of the boundary condition
129+
"bc_type": "FLOW", # Type of the boundary condition
130+
"bc_values": {
131+
"Q": [ ..., ..., ... ], # Comma-separated list of values
132+
"t": [ ..., ..., ... ] # Comma-separated list of corresponding time stamps
133+
}
134+
},
135+
```
136+
See `svZeroDSolver/tests/cases/pulsatileFlow_R_RCR.json` for an example.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
### Simulation Outputs
2+
3+
The simulation outputs will be saved in the specified CSV file (`<name_of_output_file>.csv`) when running `svZeroDSolver` from the command line as follows:
4+
```bash
5+
svzerodsolver <name_of_configuration_file>.json <name_of_output_file>.csv
6+
```
7+
If the name of the CSV file is not specified, the default is `output.csv`. The format of the file depends on the user-specified configuration within the `simulation_parameters` block of the JSON configuration file.
8+
9+
If `output_variable_based` is set to `true`, the CSV file will contain all the degrees-of-freedom in the simulation. Otherwise, only the flow and pressure at the inlets and outlets of vessels is written.
10+
11+
The degrees-of-freedom (DOFs) follow the following naming scheme:
12+
13+
- Flow DOFs are labelled `flow:<name_of_upstream_block>:<name_of_downstream_block>`.
14+
- Pressure DOFs are labelled `pressure:<name_of_upstream_block>:<name_of_downstream_block>`.
15+
- Internal DOFs (i.e., variables internal to a block and not connected to upstream/downstream blocks) are labelled `<variable_name>:<block_name>`. The internal variables for each block are listed in the blocks' [class documentation](https://simvascular.github.io/svZeroDSolver/annotated.html).
16+
17+
When the outputs are written in the variable-based and vessel-based forms, the user can specify whether they want outputs written for all cardiac cycles or just the last cardiac cycle using the `output_all_cycles` option. By default, only the last cycle is written. This makes the simulation more efficient.
18+
19+
The number of timesteps between each time the output is written is specified by `output_interval`. By default, output is written at every time step.

0 commit comments

Comments
 (0)