This example demonstrates how to create a full pulmonary circuit model and how to solve blood flow equations within it. It reads in an arterial mesh and demonstrates how to create a matching venous mesh with arteries and veins connected at the terminal level by a capillary sheet. It then solves a static blood flow problem with each extra-capillary vessel treated as an elastic tube and each capillary connection treated as a lumped parameter sheet of capillaries.
Created by Alys Clark, 02/2011.
![]() |
Arteries (cylinders) Capillary sheets (spheres) |
To create an image in order to visualise the results of this simulation, use draw.com.
# Example 962 # Evaluate airway flows using compliance-resistance model. # If the example path is not set, default to current directory if (! defined $example) { $example = "./"; } # Drop off the trailing / in the example path $chopped = chop $example; if ($chopped ne "/") { $example .= $chopped; } #================================= #Vessel element fields $num_elem_fields=5; $flow=2; $resistance=3; $elem_rad=4; $velocity=5; $lpm_field=1; #------- #Vessel node fields $num_node_fields=3; #number of node fields $radius=1; $pressure=2; $unstressed_radius=3; #================================= ## Set up problem fem de param;r;blood_flow; fem de coor 3,1; fem de base;r;blood_flow; #================================= ## Read in nodes and elements to form arterial geometry fem de node;r;test_vessels as arteries; fem de elem;r;test_vessels 1d as arteries; fem update scale_factor normalise; ##create a mesh from the existing nodes and elements, add a nodal field ##for the vessel radius and create an element field ##which tells cmiss when to use the lumped parameter model (lpm_field) ##(we assign the field value 0 in the arteries and cmiss makes it 1 in ##capillaries and 2 in the veins) fem de mesh;c airway field efield lpm_field 1 value 0; fem evaluate ordering; #evaluate Strahler order of arteries ##append the mesh with another (veins) that matches the original and is ## joined by capillaries at terminal vessels fem de mesh;c matching terminal_mesh efield; #================================= ##Define inlet and outlet vessels as boundary conditions fem group node 1 as inlet_node; fem group elem 1 as inlet_elem; fem group node 19 as terminal_nodes; fem group elem 18 as terminal;# ##Group elements for diameter calculations (and eventual output) fem group elem 1..17 as artery; fem group elem 18..34 as vein; fem group elem 35..43 as capillary; fem group elem all as vessels; #================================= ##set up radii (unstrained) fem update mesh geometry element 1 radius_field $radius constant 1.0; fem update mesh geometry element artery radius_field $radius Rd_strahler ratio_diameter 1.5; fem update mesh geometry element 18 radius_field $radius constant 1.0; fem update mesh geometry start_elem 18 element vein radius_field $radius Rd_strahler ratio_diameter 1.5; #================================= ##Set up default node and element fields fem de;add field;d field_variable $num_node_fields;# fem de;add field;d elements field_variables $num_elem_fields flow_field $flow resistance_field $resistance radius $elem_rad velocity $velocity; fem update field $elem_rad elements from radius; fem define element;d;full_mesh field; #================================= ##Set up equation & material parameters $scale_turbulence=0.0; #This removes any turbulence scaling and reduces to Poiseuille flow equations fem de equ;r;blood_flow compliance vessel SCALE_TURBULENCE $scale_turbulence; fem de mate;r;blood_flow; #================================= ##Set initial conditions: PRESSURE BCS# $gravfactor=1.0; #(mm^3/s) $inlet_flow=1;#Inlet /outlet flow $exit_pressure=500; #Outlet pressure (venous) (Pa) $ptrans=4.25; fem de init;c lung elem inlet_elem fixed flow transpulmonary $ptrans; #define inlet flow and Ppl fem update init elem inlet_elem constant $inlet_flow; #set fixed inlet flow as above fem de;add init;c lung node terminal_nodes fixed pressure Palv 0; fem update init node terminal_nodes constant $exit_pressure gravity $gravfactor position supine inlet_ref_node 1; #set LAP fem de values;r;blood_flow; #================================= ##Solve fem de solve;r;blood_flow; fem solve from 0 to 1 delta_t 1.0; #================================= #Update fields fem update field $elem_rad elements from radius; fem update field $flow elements from solution to 2; fem update field $velocity elements velocity; #must update after updating flow fem update field from solution to $pressure; #================================= ##Export some results fem de field;w;element_fields elements; fem export node;vessels as vessels; fem export elem;arteries as arteries elem artery; fem export elem;vein as vein elem vein; fem export elem;capillaries as capillaries elem capillary; fem export properties;flow as solution field index $flow name flow; fem export properties;flow_cap as solution field index $flow name flow elem capillary; fem quit;
Name Modified Size
example_9832.com 17-Feb-2011 4.3k arteries.exelem 17-Feb-2011 4.1k blood_flow.ipbase 17-Feb-2011 1.1k blood_flow.ipequa 17-Feb-2011 1.9k blood_flow.ipmate 17-Feb-2011 476 blood_flow.ippara 17-Feb-2011 5.7k blood_flow.ipsolv 17-Feb-2011 1.8k blood_flow.ipvalu 10-Mar-2011 1.7k capillaries.exelem 17-Feb-2011 3.0k ctlung.snhist 17-Feb-2011 13 draw.com 17-Feb-2011 497 element_fields.ipfiel 10-Mar-2011 14k flow.exelem 17-Feb-2011 3.5k flow_cap.exelem 17-Feb-2011 897 fort.12 17-Feb-2011 1.1k micro_flow_ladder.out 10-Mar-2011 16k micro_flow_unit.out 10-Mar-2011 1.3k test_vessels.ipelem 17-Feb-2011 5.3k test_vessels.ipnode 17-Feb-2011 6.8k vein.exelem 17-Feb-2011 4.1k vessels.exelem 17-Feb-2011 43k vessels.exnode 10-Mar-2011 12k
Name Modified Size
examples_9_98_983_9832.tar.gz 11-Mar-2011 80k
Status | Tested | Real time (s) | |
i686-linux | |||
cm | Failure | Sun Mar 6 00:05:14 2016 | 0 |
last break | Sun Feb 20 01:46:00 2011 | 1 | |
cm-debug | Failure | Sun Mar 6 00:05:14 2016 | 0 |
last break | Sat Feb 19 01:36:00 2011 | 1 | |
x86_64-linux | |||
cm | Failure | Sun Mar 6 00:01:25 2016 | 0 |
last break | Sun Feb 20 01:10:00 2011 | 2 | |
cm-debug | Failure | Sun Mar 6 00:01:25 2016 | 0 |
last break | Sat Feb 19 01:08:00 2011 | 0 |
i686-linux | |||
1 | cm: | error exit status 1. | |
1 | cm-debug: | error exit status 1. | |
x86_64-linux | |||
1 | cm: | error exit status 1. | |
1 | cm-debug: | error exit status 1. |
Html last generated: Sun Mar 6 05:50:36 2016
Input last modified: Thu Mar 10 09:49:20 2011