dm_2d_circ_pt_elecs

PURPOSE ^

DM_2D_CIRC_PT_ELECS: Create circle mesh (or radius 1) refined with electrodes

SYNOPSIS ^

function fmdl = dm_2d_circ_pt_elecs( elec_pts, pfix, spacing);

DESCRIPTION ^

 DM_2D_CIRC_PT_ELECS: Create circle mesh (or radius 1) refined with electrodes
 fmdl = dm_2d_circ_pt_elecs( elec_pts, pfix, spacing);
     at points on the electrodes
 fmdl = dm_2d_circ_pt_elecs( elec_pts, pfix, ...
               [base_spacing, refine_ratio, gradient]);
 elec_pts = cell fcn of N x [x,y,{z}] for each electrode
    normally only two points are specified (at start and end of electrode)
    eg elec_pts{1} = [-.1,1;.1,1];
 pfix = any fixed points to provide to the model (default = [])
 param(1) = base_spacing - edge length away from refined nodes (eg 0.1)
 param(2) = refine_ratio - relative refinement near points (eg. 10)
 param(3) = gradient     - transition slope of refinement (eg 0.1)

 Example: Three electrodes 2 on boundary and one internal
  elec_pts = {[1,0],[0,1;sin(0.2),cos(0.2)],[0.5,0.5]};
  fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [0.15,10,0.05] );

 Example:
  n_elecs= 14; elec_width= 0.1; hw= elec_width/2;
  th = linspace(0,2*pi,n_elecs+1); th(end)=[];
  for i=1:n_elecs;
     ti = th(i) + [hw;-hw];
     elec_pts{i} = [sin(ti),cos(ti)];
  end
  fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [0.10,10,0.02] );

 See also: dm_2d_pt_elecs

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function fmdl = dm_2d_circ_pt_elecs( elec_pts, pfix, spacing);
0002 % DM_2D_CIRC_PT_ELECS: Create circle mesh (or radius 1) refined with electrodes
0003 % fmdl = dm_2d_circ_pt_elecs( elec_pts, pfix, spacing);
0004 %     at points on the electrodes
0005 % fmdl = dm_2d_circ_pt_elecs( elec_pts, pfix, ...
0006 %               [base_spacing, refine_ratio, gradient]);
0007 % elec_pts = cell fcn of N x [x,y,{z}] for each electrode
0008 %    normally only two points are specified (at start and end of electrode)
0009 %    eg elec_pts{1} = [-.1,1;.1,1];
0010 % pfix = any fixed points to provide to the model (default = [])
0011 % param(1) = base_spacing - edge length away from refined nodes (eg 0.1)
0012 % param(2) = refine_ratio - relative refinement near points (eg. 10)
0013 % param(3) = gradient     - transition slope of refinement (eg 0.1)
0014 %
0015 % Example: Three electrodes 2 on boundary and one internal
0016 %  elec_pts = {[1,0],[0,1;sin(0.2),cos(0.2)],[0.5,0.5]};
0017 %  fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [0.15,10,0.05] );
0018 %
0019 % Example:
0020 %  n_elecs= 14; elec_width= 0.1; hw= elec_width/2;
0021 %  th = linspace(0,2*pi,n_elecs+1); th(end)=[];
0022 %  for i=1:n_elecs;
0023 %     ti = th(i) + [hw;-hw];
0024 %     elec_pts{i} = [sin(ti),cos(ti)];
0025 %  end
0026 %  fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [0.10,10,0.02] );
0027 %
0028 % See also: dm_2d_pt_elecs
0029 
0030 % (C) 2009 Andy Adler. License: GPL version 2 or version 3
0031 % $Id: dm_2d_circ_pt_elecs.m 5463 2017-05-07 15:21:37Z aadler $
0032 
0033 
0034 if ischar(elec_pts) && strcmp(elec_pts,'UNIT_TEST'); do_unit_test; return; end
0035 if ischar(elec_pts) && strcmp(elec_pts,'CALIBRATE'); do_calibrate; return; end
0036 
0037 copt.cache_obj = {elec_pts, spacing};
0038 copt.fstr = 'dm_2d_circ_pt_elecs';
0039 fmdl = eidors_cache(@do_circ_pt_elecs,{elec_pts, pfix, spacing}, copt);
0040 
0041 function fmdl = do_circ_pt_elecs( elec_pts, pfix, spacing )
0042 params.base_spacing = spacing(1);
0043 params.refine_ratio = spacing(2);
0044 params.gradient     = spacing(3);
0045 
0046 bbox= [-1,-1;1,1];
0047 
0048 eidors_cache('boost_priority',-4);
0049 fmdl= dm_2d_pt_elecs( elec_pts, [], params, @circle, [-1,-1;1,1] );
0050 eidors_cache('boost_priority',+4);
0051 
0052 fmdl.name = sprintf('dm_2d_circ_pt_elec');
0053 fmdl.normalize_measurements = 0; %default
0054 
0055 function d= circle(p,params);
0056   d = sqrt(sum(p.^2,2)) - 1; 
0057 
0058 %%%%%%%%%%%%%%%%%%%%%%%%%%%% TESTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0059 
0060 function do_unit_test
0061    elec_pts = {[1,0],[0,1;sin(0.2),cos(0.2)],[0.5,0.5]};
0062    fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [0.15,10,0.05] );
0063    subplot(221); show_fem(fmdl);
0064 
0065 % Example:
0066    n_elecs= 14; elec_width= 0.1; hw= elec_width/2;
0067    th = linspace(0,2*pi,n_elecs+1); th(end)=[];
0068    for i=1:n_elecs;
0069       ti = th(i) + [hw;-hw];
0070       elec_pts{i} = [sin(ti),cos(ti)];
0071    end
0072    fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [0.10,10,0.02] );
0073    subplot(222); show_fem(fmdl)
0074    eidors_msg('CHECK FIGURE',0);
0075 
0076 % find example models that work well with the values defined in mk_common_model
0077 function do_calibrate
0078 
0079 % meas = calc_range(0.05*([1,1.1,1.2,1.4,1.6,2.0,2.5,3,4,5,7,10,15,20]),0,1)
0080   meas = calc_range(0.02,3,0.10),%- level 1
0081 % meas = calc_range(0.03,10,0.05),%- level 3
0082 
0083 % meas = calc_range(0.02,10,0.05),%- level 3
0084 % meas = calc_range(0.02,20,0.05),%- level 3
0085  % As a start, set p2 = 1. This is uniform, and we can choose the
0086  % target refinement levels, and calculate the centre mesh density
0087  % OR setting p3=1 also gives uniform
0088 
0089 function meas = calc_range(p1range,p2,p3)
0090   n_elecs= 8; elec_width= 0.1; hw= elec_width/2;
0091   th = linspace(0,2*pi,n_elecs+1); th(end)=[];
0092   for i=1:n_elecs;
0093      ti = th(i) + [hw;-hw];
0094      elec_pts{i} = [sin(ti),cos(ti)];
0095   end
0096 
0097   for i = 1:length(p1range)
0098      p1 = p1range(i);
0099      fmdl= dm_2d_circ_pt_elecs( elec_pts, [], [p1,p2,p3]);
0100      nd= fmdl.nodes; nn= size(nd,1);
0101      ne= size(fmdl.elems,1);
0102      nc= sum( nd(:,1).^2 + nd(:,2).^2 < 0.5^2);
0103      nl= sum( (nd(:,1)-1).^2 + nd(:,2).^2 < 0.2^2);
0104      meas(i,:) = [p1,p2,p3,[nn,ne,nc,nl]/1000];
0105 
0106   end;
0107 show_fem(fmdl)
0108

Generated on Wed 21-Jun-2017 09:29:07 by m2html © 2005