|
1 | 1 |
|
2 | 2 | # **Problem Description** |
3 | 3 |
|
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). |
5 | 5 |
|
6 | | -## Introduction |
| 6 | +# svZeroDSolver |
7 | 7 |
|
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. |
9 | 9 |
|
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. |
11 | 11 |
|
| 12 | +# Enable using the svZeroDSolver |
12 | 13 |
|
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 |
15 | 15 | ``` |
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> |
21 | 23 | ``` |
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`. |
31 | 26 |
|
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). |
33 | 27 |
|
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. |
35 | 30 |
|
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. |
37 | 32 |
|
38 | | -``` |
39 | | - <Couple_to_svZeroD type="SI"> |
40 | | - </Couple_to_svZeroD> |
41 | | -``` |
| 33 | +# Coupling a boundary condition to the svZeroDSolver |
42 | 34 |
|
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 |
44 | 36 |
|
45 | 37 | ``` |
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> |
58 | 43 | ``` |
| 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 |
59 | 47 |
|
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 |
138 | 48 |
|
139 | | -External coupling block initial pressures (one number is provided, it is applied to all coupling blocks): |
140 | | -0.0 |
141 | | -``` |
0 commit comments