From fb3012aebaf51d1e46d2263ad88d92d3397b800a Mon Sep 17 00:00:00 2001 From: jghoskins <32715900+jghoskins@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:14:21 -0500 Subject: [PATCH] helm_axi_all fixed, polished and killed helm_axi --- chunkie/+chnk/+axissymhelm2d/green.m | 2 +- chunkie/+chnk/+axissymhelm2d/green_neu_all.m | 3 +- chunkie/+chnk/+axissymhelm2d/helm_axi.m | 97 ------ chunkie/+chnk/+axissymhelm2d/helm_axi_all.m | 324 ++++++++---------- .../+axissymhelm2d/helm_axi_close_table.m | 9 +- .../+chnk/+axissymhelm2d/helm_axi_smooth.m | 54 ++- 6 files changed, 206 insertions(+), 283 deletions(-) delete mode 100644 chunkie/+chnk/+axissymhelm2d/helm_axi.m diff --git a/chunkie/+chnk/+axissymhelm2d/green.m b/chunkie/+chnk/+axissymhelm2d/green.m index 469b2af..fe57615 100644 --- a/chunkie/+chnk/+axissymhelm2d/green.m +++ b/chunkie/+chnk/+axissymhelm2d/green.m @@ -61,7 +61,7 @@ r = (rt + origin(1))*kabs; dz = dz*kabs; dr = (rs-rt)*kabs; -dout = chnk.axissymhelm2d.helm_axi(r, dr, dz, ifun, asym_tables); +dout = chnk.axissymhelm2d.helm_axi_all(r, dr, dz, asym_tables,ifun); int = dout.int; intdz = dout.intdz; intdq = dout.intdq; diff --git a/chunkie/+chnk/+axissymhelm2d/green_neu_all.m b/chunkie/+chnk/+axissymhelm2d/green_neu_all.m index 64dcc6b..7916326 100644 --- a/chunkie/+chnk/+axissymhelm2d/green_neu_all.m +++ b/chunkie/+chnk/+axissymhelm2d/green_neu_all.m @@ -33,7 +33,8 @@ r = (rt + origin(1))*kabs; dz = dz*kabs; dr = (rs-rt)*kabs; -[doutk, doutik, doutdiff] = chnk.axissymhelm2d.helm_axi_all(r, dr, dz, asym_tables); +ifun = 4; +[doutk, doutik, doutdiff] = chnk.axissymhelm2d.helm_axi_all(r, dr, dz, asym_tables,ifun); pfac = over2pi * kabs; gfac = pfac * kabs; diff --git a/chunkie/+chnk/+axissymhelm2d/helm_axi.m b/chunkie/+chnk/+axissymhelm2d/helm_axi.m deleted file mode 100644 index ff65406..0000000 --- a/chunkie/+chnk/+axissymhelm2d/helm_axi.m +++ /dev/null @@ -1,97 +0,0 @@ -function [ds,varargout] = helm_axi(rs,drs,dzs,ifun,htables) - - r0s = sqrt(rs.^2+(rs+drs).^2+dzs.^2); - alphs = (drs.^2+dzs.^2)./r0s.^2; - - int = zeros(size(alphs)); - kerns = int; - kernsdk = int; - kernsda = int; - kernsdkk = int; - kernsdak = int; - kernsdaa = int; - - iclose = find(alphs<0.2); - ifar = 1:numel(alphs); - ifar(iclose) = []; - - alph_far = alphs(ifar); - r0s_far = r0s(ifar); - [i_mid] = find((1-alph_far).*r0s_far < 150); - imid = ifar(i_mid); - ifar(i_mid) = []; - - alph_mid = alphs(imid); - r0s_mid = r0s(imid); - [i_midnear] = find((1-alph_mid).*r0s_mid < 40); - imidnear = imid(i_midnear); - imid(i_midnear) = []; - - alph_midnear = alphs(imidnear); - r0s_midnear = r0s(imidnear); - [i_midnearnear] = find((1-alph_midnear).*r0s_midnear < 40); - imidnearnear = imidnear(i_midnearnear); - imidnear(i_midnearnear) = []; - - - [kc,kcdk,kcda,kcdkk,kcdak,kcdaa] ... - = chnk.axissymhelm2d.helm_axi_close_table(r0s(iclose),alphs(iclose),ifun,htables); - kerns(iclose) = kc; - kernsda(iclose) = kcda; - kernsdk(iclose) = kcdk; - kernsdkk(iclose) = kcdkk; - kernsdak(iclose) = kcdak; - kernsdaa(iclose) = kcdaa; - - [kf,kfda,kfdk,kfdaa,kfdak,kfdkk] ... - = chnk.axissymhelm2d.helm_axi_smooth(r0s(imidnearnear),alphs(imidnearnear),... - ifun,htables.xlege_midnear,htables.wlege_midnear); - - kerns(imidnearnear) = kf; - kernsda(imidnearnear) = kfda; - kernsdk(imidnearnear) = kfdk; - kernsdaa(imidnearnear)= kfdaa; - kernsdak(imidnearnear)= kfdak; - kernsdkk(imidnearnear)= kfdkk; - - [kf,kfda,kfdk,kfdaa,kfdak,kfdkk] ... - = chnk.axissymhelm2d.helm_axi_smooth(r0s(imidnear),alphs(imidnear),... - ifun,htables.xlege_midnear,htables.wlege_midnear); - - kerns(imidnear) = kf; - kernsda(imidnear) = kfda; - kernsdk(imidnear) = kfdk; - kernsdaa(imidnear)= kfdaa; - kernsdak(imidnear)= kfdak; - kernsdkk(imidnear)= kfdkk; - - [kf,kfda,kfdk,kfdaa,kfdak,kfdkk] ... - = chnk.axissymhelm2d.helm_axi_smooth(r0s(imid),alphs(imid),... - ifun,htables.xlege_mid,htables.wlege_mid); - - kerns(imid) = kf; - kernsda(imid) = kfda; - kernsdk(imid) = kfdk; - kernsdaa(imid)= kfdaa; - kernsdak(imid)= kfdak; - kernsdkk(imid)= kfdkk; - - - [kf,kfda,kfdk,kfdaa,kfdak,kfdkk] ... - = chnk.axissymhelm2d.helm_axi_smooth(r0s(ifar),alphs(ifar),... - ifun,htables.xlege,htables.wlege); - - kerns(ifar) = kf; - kernsda(ifar) = kfda; - kernsdk(ifar) = kfdk; - kernsdaa(ifar)= kfdaa; - kernsdak(ifar)= kfdak; - kernsdkk(ifar)= kfdkk; - - [dout] = chnk.axissymhelm2d.der_ak_to_grad(rs,drs,dzs,kerns,kernsda,kernsdk,... - kernsdaa,kernsdak,kernsdkk); - [ds] = chnk.axissymhelm2d.div_by_kap(rs,drs,dzs,dout); - ds.intdrz = -ds.intdrz; - ds.intdzz = -ds.intdzz; -end - diff --git a/chunkie/+chnk/+axissymhelm2d/helm_axi_all.m b/chunkie/+chnk/+axissymhelm2d/helm_axi_all.m index 0ea8f0e..a5dd026 100644 --- a/chunkie/+chnk/+axissymhelm2d/helm_axi_all.m +++ b/chunkie/+chnk/+axissymhelm2d/helm_axi_all.m @@ -1,32 +1,34 @@ -function [dsk, dsik, dsdiff] = helm_axi_all(rs,drs,dzs,htables) +function [varargout] = helm_axi_all(rs,drs,dzs,htables,ifun) r0s = sqrt(rs.^2+(rs+drs).^2+dzs.^2); alphs = (drs.^2+dzs.^2)./r0s.^2; int = zeros(size(alphs)); - kerns_k = int; - kernsdk_k = int; - kernsda_k = int; - kernsdkk_k = int; - kernsdak_k = int; - kernsdaa_k = int; - - kerns_ik = int; - kernsdk_ik = int; - kernsda_ik = int; - kernsdkk_ik = int; - kernsdak_ik = int; - kernsdaa_ik = int; - - - kerns_diff = int; - kernsdk_diff = int; - kernsda_diff = int; - kernsdkk_diff = int; - kernsdak_diff = int; - kernsdaa_diff = int; - + iflag_rk = (ifun == 1 || ifun == 4); + iflag_ik = (ifun == 2 || ifun == 4); + iflag_dk = (ifun == 3 || ifun == 4); + + if (iflag_rk) + rk = cell(6); + for ii=1:6 + rk{ii} = int; + end + end + + if (iflag_ik) + ik = cell(6); + for ii=1:6 + ik{ii} = int; + end + end + + if (iflag_dk) + dk = cell(6); + for ii=1:6 + dk{ii} = int; + end + end iclose = find(alphs<0.2); ifar = 1:numel(alphs); @@ -51,172 +53,146 @@ imidnear(i_midnearnear) = []; - [kc,kcdk,kcda,kcdkk,kcdak,kcdaa] ... + if (iflag_rk) + s ... = chnk.axissymhelm2d.helm_axi_close_table(r0s(iclose),alphs(iclose),1,htables); - kerns_k(iclose) = kc; - kernsda_k(iclose) = kcda; - kernsdk_k(iclose) = kcdk; - kernsdkk_k(iclose) = kcdkk; - kernsdak_k(iclose) = kcdak; - kernsdaa_k(iclose) = kcdaa; - - - [kc,kcdk,kcda,kcdkk,kcdak,kcdaa] ... + for ii=1:6 + rk{ii}(iclose) = s{ii}; + end + end + + if (iflag_ik) + s ... = chnk.axissymhelm2d.helm_axi_close_table(r0s(iclose),alphs(iclose),2,htables); - kerns_ik(iclose) = kc; - kernsda_ik(iclose) = kcda; - kernsdk_ik(iclose) = kcdk; - kernsdkk_ik(iclose) = kcdkk; - kernsdak_ik(iclose) = kcdak; - kernsdaa_ik(iclose) = kcdaa; - - - [kc,kcdk,kcda,kcdkk,kcdak,kcdaa] ... + for ii=1:6 + ik{ii}(iclose) = s{ii}; + end + end + + if (iflag_dk) + s ... = chnk.axissymhelm2d.helm_axi_close_table(r0s(iclose),alphs(iclose),3,htables); - kerns_diff(iclose) = kc; - kernsda_diff(iclose) = kcda; - kernsdk_diff(iclose) = kcdk; - kernsdkk_diff(iclose) = kcdkk; - kernsdak_diff(iclose) = kcdak; - kernsdaa_diff(iclose) = kcdaa; + for ii=1:6 + dk{ii}(iclose) = s{ii}; + end + end - ifun = 4; - [kf_k,kfda_k,kfdk_k,kfdaa_k,kfdak_k,kfdkk_k, ... - kf_ik,kfda_ik,kfdk_ik,kfdaa_ik,kfdak_ik,kfdkk_ik] ... + s ... = chnk.axissymhelm2d.helm_axi_smooth(r0s(imidnearnear),alphs(imidnearnear),... ifun,htables.xlege_midnear,htables.wlege_midnear); - kerns_k(imidnearnear) = kf_k; - kernsda_k(imidnearnear) = kfda_k; - kernsdk_k(imidnearnear) = kfdk_k; - kernsdaa_k(imidnearnear)= kfdaa_k; - kernsdak_k(imidnearnear)= kfdak_k; - kernsdkk_k(imidnearnear)= kfdkk_k; - - - kerns_ik(imidnearnear) = kf_ik; - kernsda_ik(imidnearnear) = kfda_ik; - kernsdk_ik(imidnearnear) = kfdk_ik; - kernsdaa_ik(imidnearnear)= kfdaa_ik; - kernsdak_ik(imidnearnear)= kfdak_ik; - kernsdkk_ik(imidnearnear)= kfdkk_ik; - - - kerns_diff(imidnearnear) = kf_k - kf_ik; - kernsda_diff(imidnearnear) = kfda_k - kfda_ik; - kernsdk_diff(imidnearnear) = kfdk_k - kfdk_ik; - kernsdaa_diff(imidnearnear)= kfdaa_k - kfdaa_ik; - kernsdak_diff(imidnearnear)= kfdak_k - kfdak_ik; - kernsdkk_diff(imidnearnear)= kfdkk_k - kfdkk_ik; - - ifun = 4; - [kf_k,kfda_k,kfdk_k,kfdaa_k,kfdak_k,kfdkk_k, ... - kf_ik,kfda_ik,kfdk_ik,kfdaa_ik,kfdak_ik,kfdkk_ik] ... + if (iflag_rk) + for ii=1:6 + rk{ii}(imidnearnear) = s.rk{ii}; + end + end + + if(iflag_ik) + for ii=1:6 + ik{ii}(imidnearnear) = s.ik{ii}; + end + end + + if(iflag_dk) + for ii=1:6 + dk{ii}(imidnearnear) = s.dk{ii}; + end + end + + s ... = chnk.axissymhelm2d.helm_axi_smooth(r0s(imidnear),alphs(imidnear),... ifun,htables.xlege_midnear,htables.wlege_midnear); - kerns_k(imidnear) = kf_k; - kernsda_k(imidnear) = kfda_k; - kernsdk_k(imidnear) = kfdk_k; - kernsdaa_k(imidnear)= kfdaa_k; - kernsdak_k(imidnear)= kfdak_k; - kernsdkk_k(imidnear)= kfdkk_k; - - - kerns_ik(imidnear) = kf_ik; - kernsda_ik(imidnear) = kfda_ik; - kernsdk_ik(imidnear) = kfdk_ik; - kernsdaa_ik(imidnear)= kfdaa_ik; - kernsdak_ik(imidnear)= kfdak_ik; - kernsdkk_ik(imidnear)= kfdkk_ik; - - - kerns_diff(imidnear) = kf_k - kf_ik; - kernsda_diff(imidnear) = kfda_k - kfda_ik; - kernsdk_diff(imidnear) = kfdk_k - kfdk_ik; - kernsdaa_diff(imidnear)= kfdaa_k - kfdaa_ik; - kernsdak_diff(imidnear)= kfdak_k - kfdak_ik; - kernsdkk_diff(imidnear)= kfdkk_k - kfdkk_ik; - - ifun = 4; - [kf_k,kfda_k,kfdk_k,kfdaa_k,kfdak_k,kfdkk_k, ... - kf_ik,kfda_ik,kfdk_ik,kfdaa_ik,kfdak_ik,kfdkk_ik] ... + if (iflag_rk) + for ii=1:6 + rk{ii}(imidnear) = s.rk{ii}; + end + end + + if (iflag_ik) + for ii=1:6 + ik{ii}(imidnear) = s.ik{ii}; + end + end + + if (iflag_dk) + for ii=1:6 + dk{ii}(imidnear) = s.dk{ii}; + end + end + + s ... = chnk.axissymhelm2d.helm_axi_smooth(r0s(imid),alphs(imid),... ifun,htables.xlege_mid,htables.wlege_mid); - - kerns_k(imid) = kf_k; - kernsda_k(imid) = kfda_k; - kernsdk_k(imid) = kfdk_k; - kernsdaa_k(imid)= kfdaa_k; - kernsdak_k(imid)= kfdak_k; - kernsdkk_k(imid)= kfdkk_k; - - kerns_ik(imid) = kf_ik; - kernsda_ik(imid) = kfda_ik; - kernsdk_ik(imid) = kfdk_ik; - kernsdaa_ik(imid)= kfdaa_ik; - kernsdak_ik(imid)= kfdak_ik; - kernsdkk_ik(imid)= kfdkk_ik; - - - kerns_diff(imid) = kf_k - kf_ik; - kernsda_diff(imid) = kfda_k - kfda_ik; - kernsdk_diff(imid) = kfdk_k - kfdk_ik; - kernsdaa_diff(imid)= kfdaa_k - kfdaa_ik; - kernsdak_diff(imid)= kfdak_k - kfdak_ik; - kernsdkk_diff(imid)= kfdkk_k - kfdkk_ik; - - ifun = 4; - [kf_k,kfda_k,kfdk_k,kfdaa_k,kfdak_k,kfdkk_k, ... - kf_ik,kfda_ik,kfdk_ik,kfdaa_ik,kfdak_ik,kfdkk_ik] ... + + if(iflag_rk) + for ii=1:6 + rk{ii}(imid) = s.rk{ii}; + end + end + + if (iflag_ik) + for ii=1:6 + ik{ii}(imid) = s.ik{ii}; + end + end + + if (iflag_dk) + for ii=1:6 + dk{ii}(imid) = s.dk{ii}; + end + end + + s ... = chnk.axissymhelm2d.helm_axi_smooth(r0s(ifar),alphs(ifar),... ifun,htables.xlege,htables.wlege); - - kerns_k(ifar) = kf_k; - kernsda_k(ifar) = kfda_k; - kernsdk_k(ifar) = kfdk_k; - kernsdaa_k(ifar)= kfdaa_k; - kernsdak_k(ifar)= kfdak_k; - kernsdkk_k(ifar)= kfdkk_k; - - - kerns_ik(ifar) = kf_ik; - kernsda_ik(ifar) = kfda_ik; - kernsdk_ik(ifar) = kfdk_ik; - kernsdaa_ik(ifar)= kfdaa_ik; - kernsdak_ik(ifar)= kfdak_ik; - kernsdkk_ik(ifar)= kfdkk_ik; - - - kerns_diff(ifar) = kf_k - kf_ik; - kernsda_diff(ifar) = kfda_k - kfda_ik; - kernsdk_diff(ifar) = kfdk_k - kfdk_ik; - kernsdaa_diff(ifar)= kfdaa_k - kfdaa_ik; - kernsdak_diff(ifar)= kfdak_k - kfdak_ik; - kernsdkk_diff(ifar)= kfdkk_k - kfdkk_ik; - - - [doutk] = chnk.axissymhelm2d.der_ak_to_grad(rs,drs,dzs,kerns_k,kernsda_k,kernsdk_k,... - kernsdaa_k,kernsdak_k,kernsdkk_k); - [dsk] = chnk.axissymhelm2d.div_by_kap(rs,drs,dzs,doutk); - dsk.intdrz = -dsk.intdrz; - dsk.intdzz = -dsk.intdzz; - - - [doutik] = chnk.axissymhelm2d.der_ak_to_grad(rs,drs,dzs,kerns_ik,kernsda_ik,kernsdk_ik,... - kernsdaa_ik,kernsdak_ik,kernsdkk_ik); - [dsik] = chnk.axissymhelm2d.div_by_kap(rs,drs,dzs,doutik); - dsik.intdrz = -dsik.intdrz; - dsik.intdzz = -dsik.intdzz; - - - - [doutdiff] = chnk.axissymhelm2d.der_ak_to_grad(rs,drs,dzs,kerns_diff,kernsda_diff,kernsdk_diff,... - kernsdaa_diff,kernsdak_diff,kernsdkk_diff); - [dsdiff] = chnk.axissymhelm2d.div_by_kap(rs,drs,dzs,doutdiff); - dsdiff.intdrz = -dsdiff.intdrz; - dsdiff.intdzz = -dsdiff.intdzz; + + if (iflag_rk) + for ii=1:6 + rk{ii}(ifar) = s.rk{ii}; + end + end + + if (iflag_ik) + for ii=1:6 + ik{ii}(ifar) = s.ik{ii}; + end + end + + if (iflag_dk) + for ii=1:6 + dk{ii}(ifar) = s.dk{ii}; + end + end + + + + if(iflag_rk) + [dsk] = proc_kerns(rs,drs,dzs,rk); + varargout{1} = dsk; + if (ifun == 4) + [dsik] = proc_kerns(rs,drs,dzs,ik); + [dsdiff] = proc_kerns(rs,drs,dzs,dk); + varargout{2} = dsik; + varargout{3} = dsdiff; + end + end + if(ifun == 2) + [dsik] = proc_kerns(rs,drs,dzs,ik); + varargout{1} = dsik; + end + if(ifun==3) + [dsdiff] = proc_kerns(rs,drs,dzs,dk); + varargout{1} = dsdiff; + end end +function [ds] = proc_kerns(rs,drs,dzs,s) + [dout] = chnk.axissymhelm2d.der_ak_to_grad(rs,drs,dzs,s{1},s{2},... + s{3},s{6},s{5},s{4}); + [ds] = chnk.axissymhelm2d.div_by_kap(rs,drs,dzs,dout); + ds.intdrz = -ds.intdrz; + ds.intdzz = -ds.intdzz; +end \ No newline at end of file diff --git a/chunkie/+chnk/+axissymhelm2d/helm_axi_close_table.m b/chunkie/+chnk/+axissymhelm2d/helm_axi_close_table.m index 1641270..feefa3c 100644 --- a/chunkie/+chnk/+axissymhelm2d/helm_axi_close_table.m +++ b/chunkie/+chnk/+axissymhelm2d/helm_axi_close_table.m @@ -1,4 +1,4 @@ -function [kerns,kernsdk,kernsda,kernsdkk,kernsdak,kernsdaa] ... +function [sout] ... = helm_axi_close_table(r0s,alphs,ifun,htables) int = zeros(size(alphs)); kerns = int; @@ -71,6 +71,13 @@ end + sout = {}; + sout{1} = kerns; + sout{3} = kernsdk; + sout{2} = kernsda; + sout{4} = kernsdkk; + sout{5} = kernsdak; + sout{6} = kernsdaa; end diff --git a/chunkie/+chnk/+axissymhelm2d/helm_axi_smooth.m b/chunkie/+chnk/+axissymhelm2d/helm_axi_smooth.m index e188d23..740631f 100644 --- a/chunkie/+chnk/+axissymhelm2d/helm_axi_smooth.m +++ b/chunkie/+chnk/+axissymhelm2d/helm_axi_smooth.m @@ -1,8 +1,20 @@ -function [kerns,kernsda,kernsdk,kernsdaa,kernsdak,kernsdkk,... - varargout] ... +function [sout] ... = helm_axi_smooth(r0s,alphs,ifun,xlege,wlege) +%%%% +% +% On output, a cell array with entries +% *kerns +% *kernsda +% *kernsdk +% *kernsdkk +% *kernsdak +% *kernsdaa +% +%%%% + + [alp,xle] = meshgrid(alphs,xlege); xle = cos(xle); [r0t,wle] = meshgrid(r0s,wlege); @@ -48,6 +60,24 @@ kernsdkk = kernsdkk + kern2dkk_v; end + s ={}; + s{1} = kerns; + s{3} = kernsdk; + s{2} = kernsda; + s{5} = kernsdak; + s{6} = kernsdaa; + s{4} = kernsdkk; + + if (ifun == 1 || ifun==4) + sout.rk = s; + end + if (ifun ==2) + sout.ik = s; + end + if (ifun ==3) + sout.dk = s; + end + if (ifun == 4) r0t = r0t*1i; efac = exp(1i*r0t.*rts)./rts.*wle; @@ -60,14 +90,20 @@ kern2dak_v = sum(asymintdak_v(xle,rts,r0t,efac),1); kern2dkk_v = sum(asymintdkk_v(xle,rts,r0t,efac),1); - if (nargout == 12) - varargout{1} = kern2_v; - varargout{2} = kern2da_v; - varargout{3} = 1i*kern2dk_v; - varargout{4} = kern2daa_v; - varargout{5} = 1i*kern2dak_v; - varargout{6} = -kern2dkk_v; + ik = {}; + ik{1} = kern2_v; + ik{2} = kern2da_v; + ik{3} = 1i*kern2dk_v; + ik{6} = kern2daa_v; + ik{5} = 1i*kern2dak_v; + ik{4} = -kern2dkk_v; + sout.ik = ik; + + dk = {}; + for ii=1:6 + dk{ii} = sout.rk{ii}-sout.ik{ii}; end + sout.dk = dk; end end