Example i28: Tangential Dipole with Varying Radius

Computes the magnetic field due to a radial dipole in a sphere of radius 2, 3 and 5 mm. The magnetic field should be independent of the radius of the sphere (the Sarvas formula does not have a radius term). The full magnetic field is compared to the analytic solution given in Sarvas 1987. The magnetic fields are evaluated on the edges of a cube with vertices located at +/- 5 mm and should be identical to those produced by examples i26. Error plots for using different radii are presented below:


The comfile run by this example is as follows:

#Example i21

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

$resolution = '8x8';
$interpolation = 'cubic';
#$interpolation = 'linear';

for $RADIUS ("2","3","5")
{

    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)
    {
	#
	# Create the ipnode/ipelem files
	#
	fem def mesh;r;sphere_${resolution}_r$RADIUS;
	fem def node;w;sphere_${resolution}_r$RADIUS;
	fem def elem;w;sphere_${resolution}_r$RADIUS;
	fem export node;$OUT/sphere as sphere;
	fem export elem;$OUT/sphere as sphere;

    } else
    {
	fem define node;r;$example/sphere_${resolution}_r$RADIUS reg 1;
	fem define elem;r;$example/sphere_${resolution}_r$RADIUS 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 li sour;
	
	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;
	
	
	fem eval solu magnet grid elem 551 iy 1 both;
	
	$DXFILENAME="tmp_x";
	$DYFILENAME="tmp_y";
	$DZFILENAME="tmp_z";
	$OUTPUTNAME="$OUT/H_$RADIUS";
	
	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);
    }
} # radius

quit
    

Files used by this example are:

Name                       Modified     Size

example_i28.com 30-Jan-2009 2.5k README.txt 30-Jan-2009 1.9k bicubic.ipbase 30-Jan-2009 6.8k bilinear.ipbase 30-Jan-2009 5.7k cube.ipelem 30-Jan-2009 447 cube.ipgrid 30-Jan-2009 601 cube.ipnode 30-Jan-2009 2.1k dipole.ipsour 30-Jan-2009 297 draw.com 30-Jan-2009 3.0k eccentricdipole.ipanal 30-Jan-2009 720 laplace.ipmate 30-Jan-2009 54 laplace_bem_cubic.ipequa 30-Jan-2009 1.3k laplace_bem_linear.ipequa 30-Jan-2009 1.3k laplace_grid.ipequa 30-Jan-2009 1.2k nosalu_cubic.ipsolv 30-Jan-2009 1.3k nosalu_linear.ipsolv 30-Jan-2009 1.2k perl.com 30-Jan-2009 2.4k sphere_8x8_r2.ipelem 30-Jan-2009 21k sphere_8x8_r2.ipmesh 30-Jan-2009 983 sphere_8x8_r2.ipnode 30-Jan-2009 51k sphere_8x8_r3.ipelem 30-Jan-2009 21k sphere_8x8_r3.ipmesh 30-Jan-2009 983 sphere_8x8_r3.ipnode 30-Jan-2009 51k sphere_8x8_r5.ipelem 30-Jan-2009 21k sphere_8x8_r5.ipmesh 30-Jan-2009 983 sphere_8x8_r5.ipnode 30-Jan-2009 51k torsotimedep.ippara 30-Jan-2009 5.9k two.ipregi 30-Jan-2009 93

Download the entire example:

Name                      Modified     Size

examples_i_i2_i28.tar.gz 03-Feb-2009 28k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:03:23 20162
cm-debugSuccessSat Mar 5 00:12:40 20165
rs6000-aix
cmSuccessTue Jan 18 11:04:03 20113
cm-debugSuccessTue Jan 18 11:04:17 20113
cm64SuccessTue Jan 18 11:04:05 20113
cm64-debugSuccessTue Jan 18 11:04:11 20113
x86_64-linux
cmSuccessSun Mar 6 00:01:09 20161
cm-debugSuccessSat Mar 5 00:01:56 20163

Testing status by file:


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

Input last modified: Mon Feb 2 12:19:52 2009


CMISS Help / Examples / i / i2 / i28