Example 9831: Creating a ladder model of the pulmonary acinus

This example demonstrates how to create a multibranching 'ladder' model of the pulmonary acinus and how to solve blood flow equations within it. It reads in an arterial mesh and demonstrates how to create a matching venous mesh that is offset from the original mesh with arteries and veins connected at each generation 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 (red cylinders)

Veins (blue cylinders)

Capillary sheets (rainbow lines)

To create an image in order to visualise the results of this simulation, use draw.com.

The comfile run by this example is as follows:

# 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
#Vessel node fields
$num_node_fields=3; #number of node fields
## Set up problem
fem de param;r;blood_flow;
fem de coor 3,1;
fem de base;r;blood_flow;

##create an arterial mesh from file, add a nodal field
##for the vessel radius, refine the mesh once 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;r;test_vessels as resp field refine 1 efield lpm_field 1 value 0;
fem evaluate order; #evaluate Strahler order of arteries

##append the mesh with another (veins) that matches the original but is
## offset by x=1,y=0,z=0 and join arteries and veins by capillaries in a 
## ladder stucture

fem de mesh;c matching offset 1 0 0 ladder_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 24 as terminal_nodes;
fem group elem 23 as terminal;#

##Group elements for diameter calculations (and eventual output)
fem group elem 1..22 as artery;
fem group elem 23..44 as vein;
fem group elem 45..61 as capillary;
fem group elem all as vessels;

##set up radii (unstrained)
fem update mesh geometry element 1 radius_field $radius constant 0.05;
fem update mesh geometry element artery radius_field $radius Rd_strahler ratio_diameter 1.5;
fem update mesh geometry element 23 radius_field $radius constant 0.03;
fem update mesh geometry start_elem 23 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=0.0;  #.0
$entry_pressure=1961.2;#Inlet pressure (arterial)
$exit_pressure=1176.7; #Outlet pressure (venous)
$ptrans=4.25;  # Make sure this is +vwwwe - when acting outwards
fem de init;c lung node inlet_node fixed pressure transpulmonary $ptrans; #sets value for ptrans
fem update init node inlet_node constant $entry_pressure inlet_ref_node 1; # Pa
fem de;add init;c lung node terminal_nodes fixed pressure Palv 0;
fem update init node terminal_nodes constant $exit_pressure inlet_ref_node 1; # Pa 
fem de values;r;blood_flow;

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 quit;

Files used by this example are:

Name                   Modified     Size

example_9831.com 17-Feb-2011 4.1k arteries.exelem 17-Feb-2011 4.8k 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.ipmesh 17-Feb-2011 418 blood_flow.ippara 17-Feb-2011 5.7k blood_flow.ipsolv 17-Feb-2011 1.8k blood_flow.ipvalu 17-Feb-2011 1.7k capillaries.exelem 17-Feb-2011 4.2k ctlung.snhist 17-Feb-2011 13 differences.diff 17-Feb-2011 6.5k draw.com 17-Feb-2011 541 element_fields.ipfiel 17-Feb-2011 19k flow.exelem 17-Feb-2011 4.8k micro_flow_sheet.out 17-Feb-2011 3.0k outlet.exelem 17-Feb-2011 1.3k outlet.exnode 17-Feb-2011 450 test_vessels.ipmesh 17-Feb-2011 1.2k vein.exelem 17-Feb-2011 4.8k vessels.exnode 17-Feb-2011 29k

Download the entire example:

Name                           Modified     Size

examples_9_98_983_9831.tar.gz 18-Feb-2011 49k

Testing status by version:

StatusTestedReal time (s)
cmFailureSun Mar 6 00:05:13 20160
last breakSun Feb 20 01:46:00 20111
cm-debugFailureSun Mar 6 00:05:13 20160
last breakSat Feb 19 01:36:00 20111
cmFailureSun Mar 6 00:01:25 20160
last breakSun Feb 20 01:10:00 20112
cm-debugFailureSun Mar 6 00:01:25 20160
last breakSat Feb 19 01:08:00 20111

Testing status by file:

Html last generated: Sun Mar 6 05:50:36 2016

Input last modified: Fri Feb 18 10:22:49 2011

CMISS Help / Examples / 9 / 98 / 983 / 9831