-
Notifications
You must be signed in to change notification settings - Fork 48
sv0D unit conversion factor #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
aabrown100-git
wants to merge
3
commits into
SimVascular:main
from
aabrown100-git:svZeroD_unit_conversion_factor
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -352,11 +352,13 @@ void init_svZeroD(ComMod& com_mod, const CmMod& cm_mod) | |||||||||||
| interface->return_ydot(last_state_ydot); | ||||||||||||
| for (int s = 0; s < numCoupledSrfs; ++s) { | ||||||||||||
| if (init_flow_flag == 1) { | ||||||||||||
| lpn_state_y[sol_IDs[2 * s]] = init_flow; | ||||||||||||
| // Apply flowrate conversion when initializing state | ||||||||||||
| lpn_state_y[sol_IDs[2 * s]] = init_flow * solver_interface.flowrate_conversion; | ||||||||||||
| cplBC.fa[s].y = lpn_state_y[sol_IDs[2 * s]]; | ||||||||||||
| } | ||||||||||||
| if (init_press_flag == 1) { | ||||||||||||
| lpn_state_y[sol_IDs[2 * s + 1]] = init_press; | ||||||||||||
| // Apply pressure conversion when initializing state | ||||||||||||
|
||||||||||||
| // Apply pressure conversion when initializing state | |
| // Apply pressure conversion when initializing state. | |
| // init_press is expected to be in 3D units (e.g., dyn/cm^2 or mmHg). | |
| // The solver expects pressure in 0D units. | |
| // Multiplying by solver_interface.pressure_conversion converts from 3D to 0D units. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # pipe_RCR_sv0D_units | ||
|
|
||
| This test is identical to `fluid/pipe_RCR_sv0D` but uses mixed units: | ||
|
|
||
| - solver.xml: cgs units (dynes/cm^2, cm^3/s) | ||
| - svZeroD JSON: clinical units (mmHg, mL/s) | ||
|
|
||
| The `svZeroDSolver_interface` specifies conversion factors so that values are converted automatically: | ||
|
|
||
| - `Pressure_conversion_factor = 0.00075006157584566` (dynes/cm^2 -> mmHg) | ||
| - `Flowrate_conversion_factor = 1.0` (cm^3/s -> mL/s) | ||
|
|
||
| Mesh and inflow files are referenced from the original test directory `pipe_RCR_sv0D/` to avoid duplication. | ||
| Also, the reference result `result_002.vtu` in `pipe_RCR_sv0D/` is used for comparison. |
111 changes: 111 additions & 0 deletions
111
tests/cases/fluid/pipe_RCR_sv0D_different_units/solver.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <svMultiPhysicsFile version="0.1"> | ||
|
|
||
| <GeneralSimulationParameters> | ||
|
|
||
| <Continue_previous_simulation> false </Continue_previous_simulation> | ||
| <Number_of_spatial_dimensions> 3 </Number_of_spatial_dimensions> | ||
| <Number_of_time_steps> 2 </Number_of_time_steps> | ||
| <Time_step_size> 0.005 </Time_step_size> | ||
| <Spectral_radius_of_infinite_time_step> 0.50 </Spectral_radius_of_infinite_time_step> | ||
| <Searched_file_name_to_trigger_stop> STOP_SIM </Searched_file_name_to_trigger_stop> | ||
|
|
||
| <Save_results_to_VTK_format> 1 </Save_results_to_VTK_format> | ||
| <Name_prefix_of_saved_VTK_files> result </Name_prefix_of_saved_VTK_files> | ||
| <Increment_in_saving_VTK_files> 1 </Increment_in_saving_VTK_files> | ||
| <Start_saving_after_time_step> 1 </Start_saving_after_time_step> | ||
|
|
||
| <Increment_in_saving_restart_files> 200 </Increment_in_saving_restart_files> | ||
| <Convert_BIN_to_VTK_format> 0 </Convert_BIN_to_VTK_format> | ||
|
|
||
| <Verbose> 1 </Verbose> | ||
| <Warning> 0 </Warning> | ||
| <Debug> 0 </Debug> | ||
|
|
||
| </GeneralSimulationParameters> | ||
|
|
||
| <Add_mesh name="msh" > | ||
|
|
||
| <Mesh_file_path> ../pipe_RCR_sv0D/mesh-complete/mesh-complete.mesh.vtu </Mesh_file_path> | ||
|
|
||
| <Add_face name="lumen_inlet"> | ||
| <Face_file_path> ../pipe_RCR_sv0D/mesh-complete/mesh-surfaces/lumen_inlet.vtp </Face_file_path> | ||
| </Add_face> | ||
|
|
||
| <Add_face name="lumen_outlet"> | ||
| <Face_file_path> ../pipe_RCR_sv0D/mesh-complete/mesh-surfaces/lumen_outlet.vtp </Face_file_path> | ||
| </Add_face> | ||
|
|
||
| <Add_face name="lumen_wall"> | ||
| <Face_file_path> ../pipe_RCR_sv0D/mesh-complete/mesh-surfaces/lumen_wall.vtp </Face_file_path> | ||
| </Add_face> | ||
|
|
||
| </Add_mesh> | ||
|
|
||
| <Add_equation type="fluid" > | ||
| <Coupled> 1 </Coupled> | ||
| <Min_iterations> 3 </Min_iterations> | ||
| <Max_iterations> 10 </Max_iterations> | ||
| <Tolerance> 1e-3 </Tolerance> | ||
| <Backflow_stabilization_coefficient> 0.2 </Backflow_stabilization_coefficient> | ||
|
|
||
| <Density> 1.06 </Density> <!-- g/cm^3 --> | ||
| <Viscosity model="Constant" > | ||
| <Value> 0.04 </Value> <!-- poise --> | ||
| </Viscosity> | ||
|
|
||
| <Output type="Spatial" > | ||
| <Velocity> true </Velocity> | ||
| <Pressure> true </Pressure> | ||
| <Traction> true </Traction> | ||
| <WSS> true </WSS> | ||
| <Vorticity> true </Vorticity> | ||
| <Divergence> true </Divergence> | ||
| </Output> | ||
|
|
||
| <LS type="NS" > | ||
| <Linear_algebra type="fsils" > | ||
| <Preconditioner> fsils </Preconditioner> | ||
| </Linear_algebra> | ||
| <Max_iterations> 10 </Max_iterations> | ||
| <NS_GM_max_iterations> 3 </NS_GM_max_iterations> | ||
| <NS_CG_max_iterations> 500 </NS_CG_max_iterations> | ||
| <Tolerance> 1e-3 </Tolerance> | ||
| <NS_GM_tolerance> 1e-3 </NS_GM_tolerance> | ||
| <NS_CG_tolerance> 1e-3 </NS_CG_tolerance> | ||
| <Krylov_space_dimension> 50 </Krylov_space_dimension> | ||
| </LS> | ||
|
|
||
| <svZeroDSolver_interface> | ||
| <Coupling_type> semi-implicit </Coupling_type> | ||
| <Configuration_file> svzerod_3Dcoupling.json </Configuration_file> | ||
| <Shared_library> ../../../../svZeroDSolver/build/src/interface/libsvzero_interface.dylib </Shared_library> | ||
| <Initial_flows> 0.0 </Initial_flows> | ||
| <Initial_pressures> 0.0 </Initial_pressures> | ||
| <Pressure_conversion_factor> 0.00075006157584566 </Pressure_conversion_factor> <!-- dyn/cm^2 to mmHg --> | ||
| <Flowrate_conversion_factor> 1.0 </Flowrate_conversion_factor> <!-- cm^3/s to ml/s --> | ||
| </svZeroDSolver_interface> | ||
|
|
||
| <Add_BC name="lumen_inlet" > | ||
| <Type> Dir </Type> | ||
| <Time_dependence> Unsteady </Time_dependence> | ||
| <Temporal_values_file_path> ../pipe_RCR_sv0D/lumen_inlet.flw</Temporal_values_file_path> | ||
| <Zero_out_perimeter> true </Zero_out_perimeter> | ||
| <Impose_flux> true </Impose_flux> | ||
| </Add_BC> | ||
|
|
||
| <Add_BC name="lumen_outlet" > | ||
| <Type> Neu </Type> | ||
| <Time_dependence> Coupled </Time_dependence> | ||
| <svZeroDSolver_block> RCR_coupling </svZeroDSolver_block> | ||
| </Add_BC> | ||
|
|
||
| <Add_BC name="lumen_wall" > | ||
| <Type> Dir </Type> | ||
| <Time_dependence> Steady </Time_dependence> | ||
| <Value> 0.0 </Value> | ||
| </Add_BC> | ||
|
|
||
| </Add_equation> | ||
|
|
||
| </svMultiPhysicsFile> |
36 changes: 36 additions & 0 deletions
36
tests/cases/fluid/pipe_RCR_sv0D_different_units/svzerod_3Dcoupling.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| { | ||
| "simulation_parameters": { | ||
| "coupled_simulation": true, | ||
| "number_of_time_pts": 100, | ||
| "output_all_cycles": true, | ||
| "steady_initial": false | ||
| }, | ||
| "boundary_conditions": [ | ||
| { | ||
| "bc_name": "RCR", | ||
| "bc_type": "RCR", | ||
| "bc_values": { | ||
| "_comment": "Clinical units. R: mmHg.s/mL, C: mL/mmHg, Pd: mmHg", | ||
| "Rp": 0.09075745067, | ||
| "Rd": 0.90907462992, | ||
| "C": 0.19998358112, | ||
| "Pd": 0.0 | ||
| } | ||
| } | ||
| ], | ||
| "external_solver_coupling_blocks": [ | ||
| { | ||
| "name": "RCR_coupling", | ||
| "type": "FLOW", | ||
| "location": "inlet", | ||
| "connected_block": "RCR", | ||
| "periodic": false, | ||
| "values": { | ||
| "t": [0.0, 1.0], | ||
| "Q": [1.0, 1.0] | ||
| } | ||
| } | ||
| ], | ||
| "junctions": [], | ||
| "vessels": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment indicates conversion is applied when initializing state, but doesn't explain the direction. The README states the conversion factor transforms 3D units to 0D units (e.g., dyn/cm² → mmHg), but init_flow is a 3D value being stored in lpn_state_y (0D state). Consider clarifying whether init_flow should be in 3D or 0D units, and if the conversion direction is correct here.