Example i26: Tangential Dipole in a Sphere - Convergence

Computes the magnetic field due to a tangential dipole in a sphere of radius 2 mm. The full magnetic field is compared with the analytic solution given in Sarvas 1987. 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 i26

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

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

if(0)
{
    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;
    quit;
} 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("\n");
    printf("*** Evalutating Magnetic Field from $TYPE\n");

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

    $DXFILENAME="tmp_x";
    $DYFILENAME="tmp_y";
    $DZFILENAME="tmp_z";
    $OUTPUTNAME="$OUT/H_$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
    #
    
    &WriteGradPhiExelem($DXFILENAME,$DYFILENAME,$DZFILENAME,$OUTPUTNAME);
}


Files used by this example are:

Name                       Modified     Size

example_i26.com 27-Jan-2009 2.5k README.txt 27-Jan-2009 3.4k 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 297 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_i26.tar.gz 31-Jan-2009 44k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:02:53 20161
cm-debugSuccessSat Mar 5 00:04:56 20162
rs6000-aix
cmSuccessTue Jan 18 10:57:49 20111
cm-debugSuccessTue Jan 18 10:58:08 20111
cm64SuccessTue Jan 18 10:57:53 20111
cm64-debugSuccessTue Jan 18 10:58:02 20111
x86_64-linux
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:15:56 2009


CMISS Help / Examples / i / i2 / i26