Skip to content

Commit b7420d8

Browse files
authored
Update test pipe rcr sv0 d readme 393 (SimVascular#402)
* Change file name. * Update text. * Update README.md Rewrite this for the new XML svZeroDSolver_interface keyword. * Update README.md Tidy up a bit. * Update README.md Modify for new interface. * Update README.md Clean up a bit. * Update README.md Update for new xml interface.
1 parent f4445d2 commit b7420d8

File tree

3 files changed

+111
-298
lines changed

3 files changed

+111
-298
lines changed
Lines changed: 28 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,48 @@
11

22
# **Problem Description**
33

4-
Solve the same problem as in [fluid/pipe_RCR_3d](../pipe_RCR_3D). Instead of using the RCR within the `svFSIplus` solver, this example demonstrates how to set up RCR boundary condition in a more generalized framework using sv0DSolver.
4+
Solve the same problem as in [fluid/pipe_RCR_3d](https://github.com/SimVascular/svMultiPhysics/tree/main/tests/cases/fluid/pipe_RCR_3d) replacing the RCR boundary condition with a resistance computed using the SimVascular [svZeroDSolver](https://simvascular.github.io/documentation/rom_simulation.html#0d-solver).
55

6-
## Introduction
6+
# svZeroDSolver
77

8-
Both sv0DSolver and genBC (see [pipe_RCR_genBC](../pipe_RCR_genBC)) provide a framework to programmatically define custom inflow and outflow boundary conditions for a CFD simulation. The framework allows users to create an arbitrary lumped parameter network (LPN, or 0D model) layout suitable for their application. Some common examples include a lumped parameter heart model that models contraction of the heart chambers to use as an inlet boundary condition, sophisticated models of the downstream circulation for various areas of the body such as the legs and upper body, or a closed-loop formulation where all outflow of the SimVascular model returns back to the inflow after passing through the veins, heart, and pulmonary arteries.
8+
The svZeroDSolver 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. The svMultiPhysics solver can directly access the svZeroDSolver API by loading the svZeroDSolver as a shared (dynamic) library available after installing it from [SimTK](https://simtk.org/frs/?group_id=188) or building it from source.
99

10-
**Essentially, sv0D and genBC are two different implementations of the same functionality, and sv0D is the preferred choice.** genBC is a legacy code developed for [svSolver](https://github.com/SimVascular/svSolver) and requires direct input of a system of equations. sv0DSolver has pre-defined blocks with associated equations and is more user-friendly. Still, `svFSIplus` provides backward compatibility for genBC so that svSolver users can migrate to the new solver easily.
10+
The svZeroDSolver application is built from source as part of the continuous integration (CI) testing. The shared library **libsvzero_interface.dylib** is created as part of the build.
1111

12+
# Enable using the svZeroDSolver
1213

13-
### Build svZeroDSolver
14-
Importantly, to automatically run test cases with `pytest` (see below), you need to build `svZeroDSolver` in the folder
14+
The svMultiPhysics solver XML `svZeroDSolver_interface` subsection under `Add_equation` enables using the svZeroDSolver. The following `svZeroDSolver_interface` parameters are used for this test
1515
```
16-
./svZeroDSolver/build
17-
```
18-
in the repository root.
19-
20-
To do so, you can run the following in the svFSIplus repository root:
16+
<svZeroDSolver_interface>
17+
<Coupling_type> semi-implicit </Coupling_type>
18+
<Configuration_file> svzerod_3Dcoupling.json </Configuration_file>
19+
<Shared_library> ../../../../svZeroDSolver/build/src/interface/libsvzero_interface.dylib </Shared_library>
20+
<Initial_flows> 0.0 </Initial_flows>
21+
<Initial_pressures> 0.0 </Initial_pressures>
22+
</svZeroDSolver_interface>
2123
```
22-
git clone https://github.com/SimVascular/svZeroDSolver.git
23-
cd svZeroDSolver
24-
mkdir build
25-
cd build
26-
cmake ..
27-
make -j2
28-
```
29-
30-
## Configuration of sv0DSolver
24+
For more detailed documentation see the [Solver Parameter Input File](https://simvascular.github.io/documentation/multi_physics.html#solver-input-file
25+
) `Equation / svZeroDSolver Interface Subsection`.
3126

32-
The following files require user's attention: [svFSI.xml](./svFSI.xml), [svzerod_3Dcoupling.json](./svzerod_3Dcoupling.json) and [svZeroD_interface.dat](./svZeroD_interface.dat).
3327

34-
### svFSI.xml
28+
# Configuration file
29+
The **svzerod_3Dcoupling.json** file is used to configure a svZeroDSolver simulation. It contains information describing the blocks (elements) of the LPM used to create the values for the resistance boundary condition communicated to the svMultiPhysics solver.
3530

36-
The input file [svFSI_genBC.xml](./svFSI.xml) follows the master input file as a template. Some specific input options are discussed below:
31+
The `external_solver_coupling_blocks` section of the `svzerod_3Dcoupling.json` file identifies the names of the blocks (`name:` field) used in the svMultiPhysics solver XML file `Add_BC` keyword for boundary conditions coupled to the svZeroDSolver. A single block named **RCR_coupling** is used for this test.
3732

38-
```
39-
<Couple_to_svZeroD type="SI">
40-
</Couple_to_svZeroD>
41-
```
33+
# Coupling a boundary condition to the svZeroDSolver
4234

43-
This tells the solver that the 0d models will be calculated through sv0DSolver. Options to couple 0D codes with svFSI are `N`: none; `I`: implicit; `SI`: semi-implicit; `E`: explicit.
35+
An RCR boundary condition is defined for the **lumen_outlet** outlet face using the `Add_BC` keyword
4436

4537
```
46-
<Add_BC name="lumen_inlet" >
47-
<Type> Dir </Type>
48-
<Time_dependence> Unsteady </Time_dependence>
49-
<Temporal_values_file_path> lumen_inlet.flw</Temporal_values_file_path>
50-
<Zero_out_perimeter> true </Zero_out_perimeter>
51-
<Impose_flux> true </Impose_flux>
52-
</Add_BC>
53-
54-
<Add_BC name="lumen_outlet" >
55-
<Type> Neu </Type>
56-
<Time_dependence> Coupled </Time_dependence>
57-
</Add_BC>
38+
<Add_BC name="lumen_outlet" >
39+
<Type> Neu </Type>
40+
<Time_dependence> Coupled </Time_dependence>
41+
<svZeroDSolver_block> RCR_coupling </svZeroDSolver_block>
42+
</Add_BC>
5843
```
44+
where
45+
- `Time_dependence` set to `Coupled` identifies this boundary condition as being coupled to the svZeroDSolver
46+
- `svZeroDSolver_block` identifies the svZeroDSolver block used to generate values for this boiundary condition
5947

60-
In this example, we use the LPN for just the outlet RCR boundary condition and use a file to specify the inlet flow conditions.
61-
62-
### svzerod_3Dcoupling.json
63-
64-
This is the configuration file for sv0DSolver and contains the elements of the 0D model being coupled to the 3D simulation.
65-
66-
For more information on the available parameters and elements, documentation is available here: [svZeroDSolver](https://github.com/SimVascular/svZeroDSolver)
67-
68-
**The following are necessary in "simulation_parameters" for a coupled simulation:**
69-
"coupled_simulation": true,
70-
"steady_initial": false
71-
72-
The external coupling block is what connects the 3D element to the 0D model. sv0D allows you to create a name for this element and specify its type (in this case, we are interested in **flow** out of the pipe). It is connected at the **inlet** of the block with the name **RCR**. Values of **time** (t) are set to the beginning and end of a cardiac cycle (0.0 to 1.0 s) and the corresponding **flow values** (Q) are set to 1.0, as this flow will be received from the 3D simulation.
73-
74-
The RCR boundary condition block sets up the RCR element with the desired resistance and pressure values.
75-
76-
```
77-
{
78-
"simulation_parameters": {
79-
"coupled_simulation": true,
80-
"number_of_time_pts": 100,
81-
"output_all_cycles": true,
82-
"steady_initial": false
83-
},
84-
"boundary_conditions": [
85-
{
86-
"bc_name": "RCR",
87-
"bc_type": "RCR",
88-
"bc_values": {
89-
"Rp": 121.0,
90-
"Rd": 1212.0,
91-
"C": 1.5e-4,
92-
"Pd": 0.0
93-
}
94-
}
95-
],
96-
"external_solver_coupling_blocks": [
97-
{
98-
"name": "RCR_coupling",
99-
"type": "FLOW",
100-
"location": "inlet",
101-
"connected_block": "RCR",
102-
"periodic": false,
103-
"values": {
104-
"t": [0.0, 1.0],
105-
"Q": [1.0, 1.0]
106-
}
107-
}
108-
],
109-
"junctions": [],
110-
"vessels": []
111-
}
112-
```
113-
114-
### svZeroD_interface.dat
115-
116-
This file sets up the interface between svFSIplus and sv0DSolver. It requires the path of the dynamic library for svZeroDSolver and the input file (svzerod_3Dcoupling.json) discussed above.
117-
118-
This file also matches the external coupling blocks in the 0D model to the coupled surfaces in svFSIplus:
119-
The first element in each line should be the name of the block from the json file and the second element should be the index of the coupled surface in svFSIplus. In this case, there is only one coupled surface with index 0.
120-
121-
```
122-
svZeroD external coupling block names to surface IDs (where surface IDs are from *.svpre file):
123-
RCR_coupling 0
124-
```
125-
126-
The next lines initialize the pressure and flow of these coupled surfaces in the 0D model:
127-
0 indicates that the values will not be initialized, and 1 indicates that they will be initialized to the value provided afterwards.
128-
129-
```
130-
Initialize external coupling block flows:
131-
0
132-
133-
External coupling block initial flows (one number is provided, it is applied to all coupling blocks):
134-
0.0
135-
136-
Initialize external coupling block pressures:
137-
1
13848

139-
External coupling block initial pressures (one number is provided, it is applied to all coupling blocks):
140-
0.0
141-
```
Lines changed: 40 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,33 @@
1-
This test case simulates an idealized left ventricle (LV) with a NeoHookean material model
2-
coupled to a lumped-parameter network (LPN), implemented in sv0DSolver. The LPN consists of a large pressure source and large resistor, which together produce an approximately constant flowrate into
3-
the LV. This inflates the LV at an approximately constant rate of change of volume.
1+
# Problem Description
2+
This test case simulates an idealized model of a left ventricle (LV) using a NeoHookean material. The LV is inflated at an approximately constant rate of change of volume using a boundary condition coupled to the SimVascular [svZeroDSolver](https://simvascular.github.io/documentation/rom_simulation.html#0d-solver).
43

5-
### Build svZeroDSolver
6-
Importantly, to automatically run test cases with `pytest` (see below), you need to build `svZeroDSolver` in the folder
7-
```
8-
./svZeroDSolver/build
9-
```
10-
in the repository root.
11-
12-
To do so, you can run the following in the svFSIplus repository root:
13-
```
14-
git clone https://github.com/SimVascular/svZeroDSolver.git
15-
cd svZeroDSolver
16-
mkdir build
17-
cd build
18-
cmake ..
19-
make -j2
20-
```
21-
22-
## Configuration of sv0DSolver
4+
# svZeroDSolver
5+
The svZeroDSolver 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. The svMultiPhysics solver can directly access the svZeroDSolver by loading the svZeroDSolver as a shared (dynamic) library available after installing it from [SimTK](https://simtk.org/frs/?group_id=188) or building it from source.
236

24-
The following files require user's attention: [svFSI.xml](./svFSI.xml), [svzerod_3Dcoupling.json](./svzerod_3Dcoupling.json) and [svZeroD_interface.dat](./svZeroD_interface.dat).
25-
26-
### svFSI.xml
27-
28-
The input file [svFSI_genBC.xml](./svFSI.xml) follows the master input file as a template, but with coupling to sv0DSolver specified in the options:
7+
The svZeroDSolver application is built from source as part of the continuous integration (CI) testing. The shared library **libsvzero_interface.dylib** is created as part of the build.
298

9+
# Enable using the svZeroDSolver
10+
The svMultiPhysics solver XML `svZeroDSolver_interface` subsection under `Add_equation` enables using the svZeroDSolver. The following `svZeroDSolver_interface` parameters are used for this test
3011
```
31-
<Couple_to_svZeroD type="SI">
32-
</Couple_to_svZeroD>
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>
3319
```
20+
For more detailed documentation see the [Solver Parameter Input File](https://simvascular.github.io/documentation/multi_physics.html#solver-input-file
21+
) `Equation / svZeroDSolver Interface Subsection`.
3422

35-
This tells the solver that the 0d models will be calculated through sv0DSolver. Options to couple 0D codes with svFSI are `N`: none; `I`: implicit; `SI`: semi-implicit; `E`: explicit.
36-
37-
```
38-
<Add_BC name="top" >
39-
<Type> Dirichlet </Type>
40-
<Value> 0.0 </Value>
41-
</Add_BC>
42-
43-
<Add_BC name="endo" >
44-
<Type> Neu </Type>
45-
<Time_dependence> Coupled </Time_dependence>
46-
<Follower_pressure_load> true </Follower_pressure_load>
47-
</Add_BC>
48-
```
49-
50-
In this example, we use the LPN for the flow into the endocardial surface.
51-
52-
### svzerod_3Dcoupling.json
53-
54-
This is the configuration file for sv0DSolver and contains the elements of the 0D model being coupled to the 3D simulation.
5523

56-
For more information on the available parameters and elements, documentation is available here: [svZeroDSolver](https://github.com/SimVascular/svZeroDSolver)
24+
# Configuration file
25+
The **svzerod_3Dcoupling.json** file is used to configure a svZeroDSolver simulation. It contains information describing the blocks (elements) of the LPM used to create the values for the resistance boundary condition communicated to the svMultiPhysics solver.
5726

58-
**The following are necessary in "simulation_parameters" for a coupled simulation:**
59-
"coupled_simulation": true,
60-
"steady_initial": false
61-
62-
The boundary condition "P_SOURCE" defines the pressure source, starting with a ramp from 0.0 to 1.0E7 and then a plateau.
63-
64-
The large resistor is defined as a blood vessel block that receives pressure from "P_SOURCE" and has resistance 1.0E5.
65-
66-
The external coupling block "LV_IN" specifies the connection between the 0D model and the coupled surface from svFSIplus. Here, we indicate that it will receive values of flow (type: FLOW) from the outlet (location: outlet) of the resistor block (connected_block: branch0_seg0).
27+
The `external_solver_coupling_blocks` section of the `svzerod_3Dcoupling.json` file identifies the names of the blocks (`name:` field) used in the svMultiPhysics solver XML file `Add_BC` keyword for boundary conditions coupled to the svZeroDSolver. A single block named **LV_IN** is used for this test.
6728

29+
The `boundary_conditions` section of the **svzerod_3Dcoupling.json** file
6830
```
69-
{
70-
"simulation_parameters": {
71-
"coupled_simulation": true,
72-
"number_of_time_pts": 100,
73-
"output_all_cycles": true,
74-
"steady_initial": false
75-
},
7631
"boundary_conditions": [
7732
{
7833
"bc_name": "P_SOURCE",
@@ -83,20 +38,11 @@ The external coupling block "LV_IN" specifies the connection between the 0D mode
8338
}
8439
}
8540
],
86-
"external_solver_coupling_blocks": [
87-
{
88-
"name": "LV_IN",
89-
"type": "FLOW",
90-
"location": "outlet",
91-
"connected_block": "branch0_seg0",
92-
"periodic": false,
93-
"values": {
94-
"Q": [1.0, 1.0],
95-
"t": [0.0, 1.0]
96-
}
97-
}
98-
],
99-
"junctions": [],
41+
```
42+
defines a **P_SOURCE** pressure boundary condition that ramps from 0.0 to 1.0E7 and plateaus at 1.0E7 for the time period **t**.
43+
44+
The `vessels` section
45+
```
10046
"vessels": [
10147
{
10248
"boundary_conditions": {
@@ -111,17 +57,23 @@ The external coupling block "LV_IN" specifies the connection between the 0D mode
11157
}
11258
}
11359
]
114-
}
11560
```
61+
defines a blood vessel block used as a large resistor. It receives pressure from **P_SOURCE** and has a **R_poiseuille** resistance of 1.0E5.
11662

117-
### svZeroD_interface.dat
118-
119-
This file sets up the interface between svFSIplus and sv0DSolver. It requires the path of the dynamic library for svZeroDSolver and the input file (svzerod_3Dcoupling.json) discussed above.
120-
121-
This file also matches the external coupling blocks in the 0D model to the coupled surfaces in svFSIplus:
122-
The first element in each line should be the name of the block from the json file and the second element should be the index of the coupled surface in svFSIplus. In this case, there is only one coupled surface with index 0.
63+
# Coupling a boundary condition to the svZeroDSolver
64+
The LV is inflated using a boundary condition on the endocardium, the innermost layer of the LV model, defined as an LPM consisting of a large pressure source and large resistor computed using the svZeroDSolver.
12365

66+
The boundary condition is defined for the **endo** endocardium surface using the `Add_BC` keyword
12467
```
125-
svZeroD external coupling block names to surface IDs (where surface IDs are from *.svpre file):
126-
LV_IN 0
68+
<Add_BC name="endo" >
69+
<Type> Neu </Type>
70+
<Time_dependence> Coupled </Time_dependence>
71+
<Follower_pressure_load> true </Follower_pressure_load>
72+
<svZeroDSolver_block> LV_IN </svZeroDSolver_block>
73+
</Add_BC>
12774
```
75+
where
76+
- `Time_dependence` set to `Coupled` identifies this boundary condition as being coupled to the svZeroDSolver
77+
- `svZeroDSolver_block` identifies the svZeroDSolver block used to generate values for this boiundary condition
78+
79+

0 commit comments

Comments
 (0)