Example i25: Radial Dipole in a Sphere - Convergence

Computes the magnetic field due to a radial dipole in a sphere of radius 2 mm. The full magnetic field should be zero as the magnetic field from the dipole should exactly cancel that produced by the volume conductor. The magnetic fields are evaluated on the edges of a cube with vertices located at +/- 5 mm. Convergence plots for using different basis functions and element refinement are shown below:

The comfile run by this example is as follows:

# Example i25

if(!defined $example) 
    $example='.' ;
    $OUT="output"; unless (-d $OUT) {mkdir $OUT};
} else{

#$resolution = '16x16'
#$resolution = '4x4';
$resolution = '8x8'

#$interpolation = 'cubic';
$interpolation = 'linear';

fem define para;r;$example/torsotimedep;
fem define coor 3,1;
fem define regi;r;$example/two;
fem define base;r;$example/bi$interpolation;

    fem def mesh;r;sphere_$resolution;
    fem def node;w;sphere_$resolution;
    fem def elem;w;sphere_$resolution;
    fem export node;$OUT/sphere as sphere;
    fem export elem;$OUT/sphere as sphere;
} else
    fem define node;r;$example/sphere_$resolution reg 1;
    fem define elem;r;$example/sphere_$resolution reg 1;
    fem export node;$OUT/sphere as sphere;
    fem export elem;$OUT/sphere as sphere;

fem define node;r;$example/cube reg 2;
fem define elem;r;$example/cube reg 2;

# Export geometry
fem export node;$OUT/cube   as cube reg 2;
fem export elem;$OUT/cube   as cube reg 2;

fem define grid;r;$example/cube   reg 2;
fem update grid geometr            reg 2;
fem define equa;r;$example/laplace_bem_$interpolation reg 1 class 1 lock;
fem define mate;r;$example/laplace reg 1 class 1;
fem define sour;r;$example/dipole  reg 1 class 1;
fem de anal;r;$example/eccentricdipole reg 1 cl 1;
fem de init;g reg 1 cl 1;
fem define solv;r;$example/nosalu_$interpolation reg 1 class 1;
fem define equa;r;$example/laplace_grid reg 2 class 2 lock;

# Solve and export potential due to a dipole
fem solve reg 1 class 1;
fem export node;$OUT/sphere_pot as sphere field;
fem export elem;$OUT/sphere_pot as sphere field;

# Read in perl subroutine: WriteGradPhiExelem
#  which combines 3 scalar exelem files into a vector field
read com;$example/perl;

# Full magnetic field

fem li sour;
fem export source;$OUT/dipole as dipole;

for $TYPE ("dipole","volume","both")
    printf("*** Evalutating Magnetic Field from $TYPE\n");

    fem eval solu magnet grid elem 551 iy 1 $TYPE;


    fem export elem;$DXFILENAME as cube field reg 2 class 2 iy 2 grid_numbers;
    fem export elem;$DYFILENAME as cube field reg 2 class 2 iy 3;
    fem export elem;$DZFILENAME as cube field reg 2 class 2 iy 4;

    # Combine the 3 scalar field into a single vector field

Files used by this example are:

Name                       Modified     Size

example_i25.com 27-Jan-2009 2.5k README.txt 27-Jan-2009 3.0k bicubic.ipbase 27-Jan-2009 6.8k bilinear.ipbase 27-Jan-2009 5.7k cube.ipelem 27-Jan-2009 447 cube.ipgrid 27-Jan-2009 601 cube.ipnode 27-Jan-2009 2.1k dipole.ipsour 27-Jan-2009 301 draw.com 27-Jan-2009 3.0k eccentricdipole.ipanal 27-Jan-2009 720 laplace.ipmate 27-Jan-2009 54 laplace_bem_cubic.ipequa 27-Jan-2009 1.3k laplace_bem_linear.ipequa 27-Jan-2009 1.3k laplace_grid.ipequa 27-Jan-2009 1.2k nosalu_cubic.ipsolv 27-Jan-2009 1.3k nosalu_linear.ipsolv 27-Jan-2009 1.2k perl.com 27-Jan-2009 2.4k sphere_16x16.ipelem 27-Jan-2009 84k sphere_16x16.ipmesh 27-Jan-2009 985 sphere_16x16.ipnode 27-Jan-2009 211k sphere_4x4.ipelem 27-Jan-2009 5.7k sphere_4x4.ipmesh 27-Jan-2009 983 sphere_4x4.ipnode 27-Jan-2009 12k sphere_8x8.ipelem 27-Jan-2009 21k sphere_8x8.ipmesh 27-Jan-2009 983 sphere_8x8.ipnode 27-Jan-2009 51k torsotimedep.ippara 27-Jan-2009 5.9k two.ipregi 27-Jan-2009 93

Download the entire example:

Name                      Modified     Size

examples_i_i2_i25.tar.gz 31-Jan-2009 43k

Testing status by version:

StatusTestedReal time (s)
cmSuccessSun Mar 6 00:02:52 20161
cm-debugSuccessSat Mar 5 00:05:25 20161
cmSuccessMon Jan 17 11:33:19 20111
cm-debugSuccessTue Jan 18 10:56:24 20111
cm64SuccessMon Jan 17 11:32:41 20111
cm64-debugSuccessTue Jan 18 10:56:38 20111
cmSuccessSun Mar 6 00:01:08 20160
cm-debugSuccessSat Mar 5 00:01:39 20161

Testing status by file:

Html last generated: Sun Mar 6 05:51:38 2016

Input last modified: Fri Jan 30 12:10:09 2009

CMISS Help / Examples / i / i2 / i25