Example i43: Computing Dipole Parameters from a Potential field

Computes dipole parameters using a precomputed potential field.


The comfile run by this example is as follows:


$OPTIM_MAGN=0;
$OPTIM_POTL=1;
$OPTIM_BOTH=0;

$TSTART="1.0";
$TEND="3.1";
$TSTEP=1;
# only works for 1 because of CALC_SAMPLE_FROM_TIME/GETDIPOLE 
# differences in UPOPTI/MAGSOL
$FREQ=1;


$EXPORT=1;
$DIPOLE=1;

$OUT="output";
$FORMAT="binary";

$MAGOFFSET=20000;
$POTOFFSET=30000;

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

fem def para;r;$example/torso_dipole
fem def coor 3,1;
fem def base;r;$example/bicubic_bilinear;

fem def node;r;$example/skin;
fem def elem;r;$example/skin_lin;


if($EXPORT)
{
    fem export node;$OUT/torso as torso;
    fem export elem;$OUT/skin  as skin;
}


#
# Group nodes
#
fem group node 29      as FIXEDNODE;
fem group node 1,290   as SURFENDS;
fem group node 2..289  as SURFNORM;
$COMPNODES="1..290"

fem def equa;r;$example/laplace_nr1 reg all;
fem def mate;r;$example/mate_nr1    reg all;
fem def init;r;$example/noflux_nr1  reg all;
fem def sour;r;$example/dipole_guess reg $DIPOLE;
fem def solv;r;$example/static_nr1 reg all;


#
# Data points
#
#
# Electrodes
#
fem def data;r;$example/electrodes_mag field num_field 3;
fem exp data;$OUT/electrodes_mag as electrodes_mag offset $MAGOFFSET;
fem def xi;c close;


#
# Read in recorded/known solutions
#
fem read matr;$example/mfi nss 1      # magnetic fields at sensors
fem read matr;$example/phi             # potential fields at electrodes

Additional testing commands:


if($OPTIM_MAGN)
{
  fem def sour;r;$example/dipole_guess reg $DIPOLE;
  $FREQ=1 

  list time
  for ($TIME=$TSTART;$TIME<$TEND;$TIME+=$TSTEP)
  {
    print "\n\n\n\n"
    print "*****************************************\n"
    print "Current Time in Optimisation Loop = $TIME\n"
    print "*****************************************\n"

    fem def opti;r;$example/opti_mag reg $DIPOLE time $TIME
    cmiss("optimise time $TIME reg $DIPOLE")
    fem eva resid wrt magnetic list 1 tstart $TIME tend $TIME freq $FREQ
    print "\n\n"
    list time
    fem li source
    print "End Optimisation Loop = $TIME\n"
    print "*****************************************\n\n\n\n"
  } 
}

if($OPTIM_POTL)
{
  fem def sour;r;$example/dipole_guess reg $DIPOLE;

  list time
  #for $TIME ($TSTART..$TEND)
  for ($TIME=$TSTART;$TIME<$TEND;$TIME+=$TSTEP)
  {
    print "\n\n\n\n"
    print "*****************************************\n"
    print "Current Time in Optimisation Loop = $TIME\n"
    print "*****************************************\n"

    fem def opti;r;$example/opti_pot reg $DIPOLE time $TIME
    cmiss("optimise time $TIME reg $DIPOLE")
    fem eva resid wrt magnetic list 1 tstart $TIME tend $TIME freq $FREQ
    print "\n\n"
    list time
    fem li source
    print "End Optimisation Loop = $TIME\n"
    print "*****************************************\n\n\n\n"
  } 
}


if($OPTIM_BOTH)
{
  fem def sour;r;$example/dipole_guess reg $DIPOLE;

  list time
  #for ($TIME=$TSTART;$TIME<=$TEND;$TIME+=$TSTEP)
  #for $TIME ($TSTART..$TEND)
  for ($TIME=$TSTART;$TIME<$TEND;$TIME+=$TSTEP)
  {
    print "\n\n\n\n"
    print "*****************************************\n"
    print "Current Time in Optimisation Loop = $TIME\n"
    print "*****************************************\n"

    fem def opti;r;$example/opti_both reg $DIPOLE time $TIME
    cmiss("optimise time $TIME reg $DIPOLE")
    fem eva res wrt magnetic list 1 tstart $TIME tend $TIME freq $FREQ
    print "\n\n"
    list time
    fem li source
    print "End Optimisation Loop = $TIME\n"
    print "*****************************************\n\n\n\n"
  }
}


Files used by this example are:

Name                     Modified     Size

example_i43.com 09-Dec-2002 1.3k bicubic_bilinear.ipbase 09-Dec-2002 7.8k dipole_guess.ipsour 09-Dec-2002 1.2k electrodes_mag.ipdata 09-Dec-2002 522 laplace_nr1.ipequa 26-May-2003 1.3k mate_nr1.ipmate 09-Dec-2002 859 mfi.ipmatr 09-Dec-2002 3.0k noflux_nr1.ipinit 09-Dec-2002 575 opti_both.ipopti 09-Dec-2002 1.5k opti_mag.ipopti 09-Dec-2002 1.5k opti_pot.ipopti 09-Dec-2002 1.5k phi.ipmatr 09-Dec-2002 1.1k skin.ipnode 09-Dec-2002 258k skin_lin.ipelem 09-Dec-2002 118k static_nr1.ipsolv 13-Apr-2007 1.2k test_output.com 16-Feb-2004 2.1k torso_dipole.ippara 21-Feb-2003 5.9k

Download the entire example:

Name                      Modified     Size

examples_i_i4_i43.tar.gz 14-Apr-2007 75k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmSuccessSun Mar 6 00:09:24 201616
cm-debugSuccessSat Mar 5 01:06:12 201651
mips-irix
cmSuccessSun Aug 19 05:24:14 2007242
cm-debugSuccessWed Aug 15 04:22:39 2007804
cm-debug-clear-mallocSuccessSat Aug 18 05:27:18 2007863
cm-debug-clear-malloc7SuccessMon Aug 20 05:00:33 2007821
cm64SuccessSun Aug 19 06:14:12 2007276
cm64-debugSuccessTue Aug 14 06:09:06 2007977
cm64-debug-clear-mallocSuccessThu Apr 1 12:43:08 2004394
rs6000-aix
cmSuccessWed Mar 4 01:17:56 200917
cm-debugSuccessMon Mar 2 01:37:41 2009182
cm64SuccessWed Mar 4 01:18:36 200920
cm64-debugSuccessTue Mar 3 01:47:11 2009201
x86_64-linux
cmSuccessSun Mar 6 00:01:27 20166
cm-debugSuccessSat Mar 5 00:05:14 201629

Testing status by file:


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

Input last modified: Fri Apr 13 10:43:37 2007


CMISS Help / Examples / i / i4 / i43