Skip to content

Commit 064c07d

Browse files
authored
Fix Solver Tests (#166)
1 parent cc7d196 commit 064c07d

File tree

63 files changed

+2120
-1921
lines changed

Some content is hidden

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

63 files changed

+2120
-1921
lines changed

src/model/ClosedLoopHeartPulmonary.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ class ClosedLoopHeartPulmonary : public Block {
198198
private:
199199
// Below variables change every timestep and are then combined with
200200
// expressions that are updated with solution
201-
double AA; // Atrial activation function
202-
double Elv; // LV elastance
203-
double Erv; // RV elastance
201+
double AA = 0.0; // Atrial activation function
202+
double Elv = 0.0; // LV elastance
203+
double Erv = 0.0; // RV elastance
204204
double psi_ra, psi_la, psi_ra_derivative,
205205
psi_la_derivative; // Expressions for atrial activation
206206
double valves[16];

tests/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Testing Guide
2+
3+
[Integration testing](https://en.wikipedia.org/wiki/Integration_testing) is an essential part of software development. It is performed when integrating code changes into the main development branch to verify that the code works as expected. The following sections describe how to run and add integration tests used to the svMultiPhysics program.
4+
5+
6+
# Build svZeroDSolver
7+
8+
Running a test case requires you to [build svZeroDSolver](https://simvascular.github.io/documentation/rom_simulation.html#0d-solver-install) and install with pip in order to run test cases using `pytest`
9+
10+
# Running tests using pytest
11+
12+
to run the full set of svZeroDSolver test cases, navigate to the `tests/` directory and run `pytest` from the terminal
13+
14+
## Create a new solver test
15+
16+
In order to create a new test for the solver, complete the following steps:
17+
18+
1. Create a svZeroDSolver json file for the test (e.g. `pulsatileFlow_R_RCR.json`) in the `tests/cases` directory
19+
2. Verify the results. If possible, verify against an analystical solution. If this is not feasible, find some way to verify that the test results are correct. For example, you might use reference solutions from other codes, manufactured solutions, convergence analysis, or something of that variety.
20+
3. Compute a reference solution for the test by navigating to the `tests` directory and running `python compute_ref_sol.py <your_test_case_name..json>` from the terminal. This should create a resultant `result_your_test_case_name.json` file in the `tests/cases/results` directory. Verify the result is there.
21+
4. Add your test case to the `pytest` parametrization in `test_solver.py`. simply add the name of your test `json` to the list of strings after the `@pytest.mark.parametrize` decorator.
22+
5. Verify that the test runs properly by running `pytest` from the terminal while in the `tests` directory.
23+
24+
25+

tests/cases/chamber_elastance_inductor.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
{
22
"description": {
3-
"description of test case" : "pulsatile pressure -> valve -> chamber -> valve -> RC -> R",
4-
"analytical results" : [
5-
"Boundary conditions:",
6-
"inlet:",
7-
"pressure = sinusoid from 0 to 10 over 0.17s, then 0 for the rest of cycle",
8-
"outlet:",
9-
"Resistance: Rd = 1000, Pd = 64"
10-
]
3+
"description of test case": "pulsatile pressure -> valve -> chamber -> valve -> RC -> R",
4+
"analytical results": [
5+
"Boundary conditions:",
6+
"inlet:",
7+
"pressure = sinusoid from 0 to 10 over 0.17s, then 0 for the rest of cycle",
8+
"outlet:",
9+
"Resistance: Rd = 1000, Pd = 64"
10+
]
1111
},
1212
"simulation_parameters": {
1313
"number_of_cardiac_cycles": 30,
1414
"number_of_time_pts_per_cardiac_cycle": 101,
15+
"absolute_tolerance": 1e-09,
1516
"output_all_cycles": false,
16-
"output_variable_based":true
17+
"output_variable_based": true
1718
},
1819
"boundary_conditions": [
1920
{
@@ -295,4 +296,4 @@
295296
"initial_condition": {
296297
"Vc:ventricle": 96.07
297298
}
298-
}
299+
}
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
{
22
"description": {
3-
"description of test case" : "Closed-loop circulation with one vessel (aorta) connected on either side to the heart model."
3+
"description of test case": "Closed-loop circulation with one vessel (aorta) connected on either side to the heart model."
44
},
55
"simulation_parameters": {
6-
"number_of_cardiac_cycles": 1,
7-
"number_of_time_pts_per_cardiac_cycle": 10000,
6+
"number_of_cardiac_cycles": 10,
7+
"number_of_time_pts_per_cardiac_cycle": 100,
8+
"absolute_tolerance": 1e-8,
89
"steady_initial": false
910
},
1011
"boundary_conditions": [
1112
{
1213
"bc_name": "RCR_aorta",
1314
"bc_type": "ClosedLoopRCR",
1415
"bc_values": {
15-
"_comment_": "R_total = 1.570879*0.948914 = 1.490629075",
16-
"_comment_": "Rp = 0.09*R_total",
17-
"_comment_": "Rd = 0.91*R_total",
16+
"_comment_": "C = 0.228215*1.044637, R_total = 1.570879*0.948914 = 1.490629075, Rp = 0.09*R_total, Rd = 0.91*R_total",
1817
"Rp": 0.134156617,
1918
"Rd": 1.356472458,
20-
"_comment_": "C = 0.228215*1.044637",
2119
"C": 0.238401833,
2220
"closed_loop_outlet": true
2321
}
@@ -34,9 +32,8 @@
3432
"vessel_length": 10.0,
3533
"zero_d_element_type": "BloodVessel",
3634
"zero_d_element_values": {
37-
"_comment_": "R = 4.464119/1333.34",
35+
"_comment_": "L = 5.25/1333.34, R = 4.464119/1333.34",
3836
"R_poiseuille": 0.003348073,
39-
"_comment_": "L = 5.25/1333.34",
4037
"L": 0.004
4138
}
4239
}
@@ -47,37 +44,29 @@
4744
"branch0_seg0"
4845
],
4946
"closed_loop_type": "ClosedLoopHeartAndPulmonary",
50-
"cardiac_cycle_period": 1.0169,
47+
"cardiac_cycle_period": 1.0169,
5148
"parameters": {
52-
"Tsa": 0.407420,
49+
"_comment_": "Lrv_a = 0.249155/pConv, Rrv_a = 0.993637 * this->Rrv_base /pConv, Lra_v = 0.289378/pConv, Rra_v = 10.516664/pConv, Lla_v = 0.469052/pConv, Rla_v = 7.081136/pConv, Rlv_ao = 0.972624 * this->Rlv_base /pConv, Llv_a = 0.147702/pConv, Rpd = 1.120725 * this->Rpd_base /pConv",
50+
"Tsa": 0.40742,
5351
"tpwave": 8.976868,
5452
"Erv_s": 2.125279,
5553
"Elv_s": 3.125202,
5654
"iml": 0.509365,
5755
"imr": 0.806369,
58-
"_comment_": "Lrv_a = 0.249155/pConv",
5956
"Lrv_a": 0.000186865,
60-
"_comment_": "Rrv_a = 0.993637 * this->Rrv_base /pConv",
6157
"Rrv_a": 0.035061704,
62-
"_comment_": "Lra_v = 0.289378/pConv",
6358
"Lra_v": 0.000217032,
64-
"_comment_": "Rra_v = 10.516664/pConv",
6559
"Rra_v": 0.007887459,
66-
"_comment_": "Lla_v = 0.469052/pConv",
6760
"Lla_v": 0.000351787,
68-
"_comment_": "Rla_v = 7.081136/pConv",
6961
"Rla_v": 0.005310825,
70-
"_comment_": "Rlv_ao = 0.972624 * this->Rlv_base /pConv",
7162
"Rlv_ao": 0.034320234,
72-
"_comment_": "Llv_a = 0.147702/pConv",
7363
"Llv_a": 0.000110776,
7464
"Vrv_u": 9.424629,
7565
"Vlv_u": 5.606007,
76-
"_comment_": "Rpd = 1.120725 * this->Rpd_base /pConv",
7766
"Rpd": 0.098865401,
7867
"Cp": 1.090989,
7968
"Cpa": 0.556854,
80-
"Kxp_ra": 9.222440,
69+
"Kxp_ra": 9.22244,
8170
"Kxv_ra": 0.004837,
8271
"Emax_ra": 0.208858,
8372
"Vaso_ra": 4.848742,
@@ -95,4 +84,4 @@
9584
"V_LV:CLH": 96.07,
9685
"P_pul:CLH": 8.0
9786
}
98-
}
87+
}
Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,45 @@
11
{
22
"description": {
3-
"description of test case" : "Closed-loop circulation with two RCR outlets and two coronary outlets"
3+
"description of test case": "Closed-loop circulation with two RCR outlets and two coronary outlets"
44
},
55
"simulation_parameters": {
6-
"number_of_cardiac_cycles": 1,
7-
"number_of_time_pts_per_cardiac_cycle": 10000,
6+
"number_of_cardiac_cycles": 10,
7+
"number_of_time_pts_per_cardiac_cycle": 100,
8+
"absolute_tolerance": 1e-09,
89
"steady_initial": false
910
},
1011
"boundary_conditions": [
1112
{
1213
"bc_name": "LCA",
1314
"bc_type": "ClosedLoopCoronaryLeft",
1415
"bc_values": {
15-
"_comment_": "Ra_total = 67.540250*0.361748 = 24.432550357",
16-
"_comment_": "Ra = (0.32/0.84)*Ra_total",
17-
"_comment_": "Ram = (0.52/0.84)*Ra_total",
16+
"_comment_": "Ra_total = 67.540250*0.361748 = 24.432550357, Ra = (0.32/0.84)*Ra_total, Ram = (0.52/0.84)*Ra_total, Ca = 0.000110*5.022065, Rv = 12.864810*2.586199, Cim = 0.000890*4.198904",
1817
"Ra": 9.307638231,
1918
"Ram": 15.124912126,
20-
"_comment_": "Rv = 12.864810*2.586199",
2119
"Rv": 33.270958757,
22-
"_comment_": "Cim = 0.000890*4.198904",
2320
"Cim": 0.003737025,
24-
"_comment_": "Ca = 0.000110*5.022065",
2521
"Ca": 0.000552427
2622
}
2723
},
2824
{
2925
"bc_name": "RCA",
3026
"bc_type": "ClosedLoopCoronaryRight",
3127
"bc_values": {
32-
"_comment_": "Ra_total = 41.778304*0.361748 = 15.113217915",
33-
"_comment_": "Ra = (0.32/0.84)*Ra_total",
34-
"_comment_": "Ram = (0.52/0.84)*Ra_total",
28+
"_comment_": "Ra_total = 41.778304*0.361748 = 15.113217915, Ra = (0.32/0.84)*Ra_total, Ram = (0.52/0.84)*Ra_total, Ca = 0.000110*9.599613, Rv = 7.957772*2.586199, Cim = 0.000890*3.891162",
3529
"Ra": 5.757416349,
3630
"Ram": 9.355801566,
37-
"_comment_": "Rv = 7.957772*2.586199",
3831
"Rv": 20.580381989,
39-
"_comment_": "Cim = 0.000890*3.891162",
4032
"Cim": 0.003463134,
41-
"_comment_": "Ca = 0.000110*9.599613",
4233
"Ca": 0.001055957
4334
}
4435
},
4536
{
4637
"bc_name": "RCR_aorta",
4738
"bc_type": "ClosedLoopRCR",
4839
"bc_values": {
49-
"_comment_": "R_total = 1.570879*0.948914 = 1.490629075",
50-
"_comment_": "Rp = 0.09*R_total",
51-
"_comment_": "Rd = 0.91*R_total",
40+
"_comment_": "R_total = 1.570879*0.948914 = 1.490629075, Rp = 0.09*R_total, Rd = 0.91*R_total, C = 0.228215*1.044637",
5241
"Rp": 0.134156617,
5342
"Rd": 1.356472458,
54-
"_comment_": "C = 0.228215*1.044637",
5543
"C": 0.238401833,
5644
"closed_loop_outlet": true
5745
}
@@ -60,12 +48,9 @@
6048
"bc_name": "RCR_aorta_br",
6149
"bc_type": "ClosedLoopRCR",
6250
"bc_values": {
63-
"_comment_": "R_total = 6.922824*0.948914 = 6.569164613",
64-
"_comment_": "Rp = 0.09*R_total",
65-
"_comment_": "Rd = 0.91*R_total",
51+
"_comment_": "R_total = 6.922824*0.948914 = 6.569164613, Rp = 0.09*R_total, Rd = 0.91*R_total, C = 0.051785*1.044637",
6652
"Rp": 0.591224815,
6753
"Rd": 5.977939798,
68-
"_comment_": "C = 0.051785*1.044637",
6954
"C": 0.054096527,
7055
"closed_loop_outlet": true
7156
}
@@ -82,9 +67,8 @@
8267
"vessel_name": "branch0_seg0",
8368
"zero_d_element_type": "BloodVessel",
8469
"zero_d_element_values": {
85-
"_comment_": "R = 4.464119/1333.34",
70+
"_comment_": "R = 4.464119/1333.34, L = 5.25/1333.34",
8671
"R_poiseuille": 0.003348073,
87-
"_comment_": "L = 5.25/1333.34",
8872
"L": 0.00393748
8973
}
9074
},
@@ -98,9 +82,8 @@
9882
"vessel_name": "branch1_seg0",
9983
"zero_d_element_type": "BloodVessel",
10084
"zero_d_element_values": {
101-
"_comment_": "R = 111.152028/1333.34",
85+
"_comment_": "R = 111.152028/1333.34, L = 5.25/1333.34",
10286
"R_poiseuille": 0.083363604,
103-
"_comment_": "L = 5.25/1333.34",
10487
"L": 0.00393748
10588
}
10689
},
@@ -114,9 +97,8 @@
11497
"vessel_name": "branch2_seg0",
11598
"zero_d_element_type": "BloodVessel",
11699
"zero_d_element_values": {
117-
"_comment_": "R = 5855.832840/1333.34",
100+
"_comment_": "R = 5855.832840/1333.34, L = 10.0/1333.34",
118101
"R_poiseuille": 4.391852671,
119-
"_comment_": "L = 10.0/1333.34",
120102
"L": 0.007499963
121103
}
122104
},
@@ -130,9 +112,8 @@
130112
"vessel_name": "branch3_seg0",
131113
"zero_d_element_type": "BloodVessel",
132114
"zero_d_element_values": {
133-
"_comment_": "R = 3013.987966/1333.34",
115+
"_comment_": "R = 3013.987966/1333.34, L = 10.0/1333.34",
134116
"R_poiseuille": 2.260479672,
135-
"_comment_": "L = 10.0/1333.34",
136117
"L": 0.007499963
137118
}
138119
}
@@ -146,37 +127,29 @@
146127
"branch3_seg0"
147128
],
148129
"closed_loop_type": "ClosedLoopHeartAndPulmonary",
149-
"cardiac_cycle_period": 1.0169,
130+
"cardiac_cycle_period": 1.0169,
150131
"parameters": {
151-
"Tsa": 0.407420,
132+
"_comment_": "Lrv_a = 0.249155/pConv, Rrv_a = 0.993637 * this->Rrv_base /pConv, Lra_v = 0.289378/pConv, Rra_v = 10.516664/pConv, Lla_v = 0.469052/pConv, Rla_v = 7.081136/pConv, Rlv_ao = 0.972624 * this->Rlv_base /pConv, Llv_a = 0.147702/pConv, Rpd = 1.120725 * this->Rpd_base /pConv",
133+
"Tsa": 0.40742,
152134
"tpwave": 8.976868,
153135
"Erv_s": 2.125279,
154136
"Elv_s": 3.125202,
155137
"iml": 0.509365,
156138
"imr": 0.806369,
157-
"_comment_": "Lrv_a = 0.249155/pConv",
158139
"Lrv_a": 0.000186865,
159-
"_comment_": "Rrv_a = 0.993637 * this->Rrv_base /pConv",
160140
"Rrv_a": 0.035061704,
161-
"_comment_": "Lra_v = 0.289378/pConv",
162141
"Lra_v": 0.000217032,
163-
"_comment_": "Rra_v = 10.516664/pConv",
164142
"Rra_v": 0.007887459,
165-
"_comment_": "Lla_v = 0.469052/pConv",
166143
"Lla_v": 0.000351787,
167-
"_comment_": "Rla_v = 7.081136/pConv",
168144
"Rla_v": 0.005310825,
169-
"_comment_": "Rlv_ao = 0.972624 * this->Rlv_base /pConv",
170145
"Rlv_ao": 0.034320234,
171-
"_comment_": "Llv_a = 0.147702/pConv",
172146
"Llv_a": 0.000110776,
173147
"Vrv_u": 9.424629,
174148
"Vlv_u": 5.606007,
175-
"_comment_": "Rpd = 1.120725 * this->Rpd_base /pConv",
176149
"Rpd": 0.098865401,
177150
"Cp": 1.090989,
178151
"Cpa": 0.556854,
179-
"Kxp_ra": 9.222440,
152+
"Kxp_ra": 9.22244,
180153
"Kxv_ra": 0.004837,
181154
"Emax_ra": 0.208858,
182155
"Vaso_ra": 4.848742,
@@ -194,4 +167,4 @@
194167
"V_LV:CLH": 96.07,
195168
"P_pul:CLH": 8.0
196169
}
197-
}
170+
}

0 commit comments

Comments
 (0)