Commit b781b3e6 authored by Lore, Jeremy's avatar Lore, Jeremy
Browse files

update efit routines

parent 489cf838
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
function alpha_deg = calc_Bangle_g(g,R,Z)


v2 = [0,0,1];
for i = 1:length(R)
    v1 = [R(i),Z(i),0];
    vn = cross(v1,v2);
    vn = vn./norm(vn);
    b = bfield_geq_bicub(g,R(i),Z(i),0);
    b = [b.br,b.bz,b.bphi];
    b = b./norm(b);
    alpha_deg(i) = 90 - acos(dot(vn,b))*180/pi;
end




end
 No newline at end of file
+13 −9
Original line number Diff line number Diff line
@@ -10,17 +10,13 @@ if nargin < 4
    linewid = 1;
end

%(run_path,g,newfig,plotit,sep_file_name,rguess,zguess,de,SECOND_SEP,save_in_dir)



clip_at_glim = 1;

if newfig == 1
    figure; hold on;   
end


DEBUG = 0;

box_r = [g.r(1),g.r(g.mw),g.r(g.mw),g.r(1),g.r(1)];
box_z = [g.z(1),g.z(1),g.z(g.mh),g.z(g.mh),g.z(1)];
@@ -28,6 +24,10 @@ box_z = [g.z(1),g.z(1),g.z(g.mh),g.z(g.mh),g.z(1)];
[pathstr,fn,ext] = fileparts(g.filename);
fname = fullfile(pathstr,strcat(fn,ext,'_sep'));

if DEBUG 
    figure; hold on;
end

fid = fopen(fname,'r');
if fid == -1
    disp(['Did not find sep. data file: ',fname])
@@ -36,8 +36,10 @@ if fid == -1
    lim_r = g.lim(1,g.lim(1,:) > 0);
    lim_z = g.lim(2,g.lim(1,:) > 0);
    
%     plot(box_r,box_z,'c-')
%     plot(lim_r,lim_z,'r-')
    if DEBUG 
        plot(box_r,box_z,'c-')
        plot(lim_r,lim_z,'r-')
    end
    xpt_info = find_xpt_jl(g,1,1,1e-8,0);
    xr1 = xpt_info.rx;
    xz1 = xpt_info.zx;
@@ -77,7 +79,9 @@ if fid == -1
        if ii == maxtries
            error('increase maxtries')
        end      
%         plot(rsep0,zsep0,'g')
        if DEBUG
            plot(rsep0,zsep0,'g')
        end
        if idir == 1
            rsep1 = rsep0;
            zsep1 = zsep0;
+6 −1
Original line number Diff line number Diff line
@@ -6,8 +6,9 @@ if nargin < 2
end

% Version identifies changes to routine that may require re-creating .mat file
version_ = 3;
version_ = 4;
% v3: Changed outputs to row vectors and added bicub inverse
% v4: Added aminor and nGW

if isempty(filename)
    g = [];
@@ -53,6 +54,10 @@ for i = 0:g.mh-1
end

if ~isempty(g.qpsi)  % Do not postprocess truncated file
    
    g.aminor = (max(g.bdry(1,:))-min(g.bdry(1,:)))/2;
    g.nGW = g.cpasma/1e6/pi/g.aminor^2*1e20;
    
    g.ip_sign = -sign(g.cpasma);
    
    g.bicub_coeffs = get_psi_bicub_coeffs(g);
+6 −4
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ plot_glim = 0;

fname_psimin = []; fname_psimin2 = []; gfile_name =[];

if 1
if 0
%    run_path = '/home/jjl/util-library/fortran/poincare/examples/M3DC1_14170'; suffix = 'test'; mytitle = 'test';
   run_path = '/home/jjl/util-library/fortran/poincare/examples/M3DC1_14170'; suffix = 'm3dc1_test'; mytitle = 'test';
end
@@ -65,18 +65,20 @@ if 0
    gfile_name = 'C:\Work\DIII-D\165274\kinetic\g165274.02120';
end

if 0
if 1
    %     run_path = 'C:\Work\fortran\test_poincare\W7-X\OP2\22kA\bmw\'; suffix = '60surf';mytitle = 'bmw';
    % run_path = 'C:\Work\fortran\test_poincare\W7-X\OP2\22kA\mfbe\'; suffix = '60surf';mytitle = 'mfbe';
    % run_path = 'C:\Work\fortran\test_poincare\W7-X\OP2\22kA\extender\'; suffix = '40surf_v2';mytitle = 'extender';
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP2\22kA\extender\'; suffix = '60surf';mytitle = 'extender';
    % run_path = 'C:\Work\fortran\test_poincare\W7-X\OP2\22kA\bmw\'; suffix = '40surf_18deg';mytitle = 'bmw';
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP2\22kA_altern\'; suffix = '0deg_200tran_60surf';mytitle = 'extender';
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\22kA_mimic\'; suffix = '0deg_200tran_60surf';mytitle = 'extender';% 1.75 parts
%     run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\22kA_mimic'; suffix = '0deg_200tran_60surf';mytitle = 'extender';% 1.75 parts
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\22kA_mimic\'; suffix = '-160.75_200tran_60surf';mytitle = 'extender'; % 16.75 parts
    
    run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\43kA_mimic\'; suffix = '-145.75_200tran_100surf';mytitle = '43kA mimic';  Zfac = -1;
    
    % MPM scan
    run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\0kA_mimic\'; suffix = '15.2deg_test1';mytitle = '';
%     run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\0kA_mimic\'; suffix = '15.2deg_test1';mytitle = '';
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\11kA_mimic\'; suffix = '15.2deg_test1';mytitle = '11kA';
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\22kA_mimic\'; suffix = '15.2deg_test1';mytitle = '';
    % run_path = 'C:\Work_archive\fortran\test_poincare\W7-X\OP12a\32kA_mimic\'; suffix = '15.2deg_test1';mytitle = '32kA';