0001 function [solf,solp] = inverse_solver(I,voltage,tol,mat_ref,vtx,simp,elec,no_pl,zc,perm_sym,gnd_ind,tfac,Reg,it);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 tol = 1e-4;
0024
0025 sol_upd = mat_ref;
0026
0027 solp = zeros(size(simp,1),1);
0028
0029 Ib = I(size(vtx,1)+1:end,:);
0030
0031 el_no = size(elec,1);
0032
0033 if it==1
0034 disp('A linear solution will be calculated')
0035 end
0036
0037
0038 for i=1:it
0039
0040 [E,D,Ela,pp] = fem_master_full(vtx,simp,sol_upd,gnd_ind,elec,zc,perm_sym);
0041
0042 if i==1
0043
0044 [V] = forward_solver(E,I,tol,pp);
0045 [viH,viV,indH,indV,df] = get_3d_meas(elec,vtx,V,Ib,no_pl);
0046 dfv = df(1:2:end);
0047 vi = viH;
0048
0049 [v_f] = m_3d_fields(vtx,el_no,indH,E,tol,gnd_ind);
0050 else
0051
0052 [V] = forward_solver(E,I,tol,pp,V);
0053 [viH,viV,indH,indV,df] = get_3d_meas(elec,vtx,V,Ib,no_pl);
0054 dfv = df(1:2:end);
0055 vi = viH;
0056
0057 [v_f] = m_3d_fields(vtx,el_no,indH,E,tol,gnd_ind,v_f);
0058 end
0059
0060 [J] = jacobian_3d(I,elec,vtx,simp,gnd_ind,sol_upd,zc,v_f,dfv,tol,perm_sym);
0061
0062 sol = (J.'*J + tfac*Reg.'*Reg)\ (J.' * (voltage - vi));
0063
0064 sol_upd = sol_upd + sol;
0065 solp = solp + sol;
0066
0067 h1 = figure;
0068 set(h1,'NumberTitle','off');
0069 set(h1,'Name','Reconstructed conductivity distribution');
0070 subplot(2,3,1); [fc] = slicer_plot_n(2.63,sol_upd,vtx,simp); view(2); grid; colorbar; axis off; title('z=2.63');
0071 subplot(2,3,2); [fc] = slicer_plot_n(2.10,sol_upd,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=2.10');
0072 subplot(2,3,3); [fc] = slicer_plot_n(1.72,sol_upd,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.72');
0073 subplot(2,3,4); [fc] = slicer_plot_n(1.10,sol_upd,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=1.10');
0074 subplot(2,3,5); [fc] = slicer_plot_n(0.83,sol_upd,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.83');
0075 subplot(2,3,6); [fc] = slicer_plot_n(0.10,sol_upd,vtx,simp,fc); view(2); grid; colorbar; axis off; title('z=0.10');
0076 drawnow;
0077
0078
0079 sprintf('Error norm at iteration %d is %f',i,norm(voltage - vi))
0080
0081 end
0082
0083 solf = sol_upd;
0084
0085
0086
0087
0088
0089
0090
0091
0092