From 2aa44587b4e9dcf0d4011f881b64f39caaa8b3e6 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Wed, 16 Jun 2021 16:00:11 +0200 Subject: [PATCH 001/134] update matlab routines --- Utilities/matlabtools/SPEC_Namelist.m | 1772 +++++++++++++++++ Utilities/matlabtools/compare_spec_outputs.m | 18 +- Utilities/matlabtools/contra2cov.m | 18 +- Utilities/matlabtools/get_full_field.m | 17 +- Utilities/matlabtools/get_spec_Bgrid.m | 24 +- .../matlabtools/get_spec_R_derivatives.m | 40 +- Utilities/matlabtools/get_spec_area.m | 10 +- Utilities/matlabtools/get_spec_beta.m | 33 +- Utilities/matlabtools/get_spec_energy_slab.m | 11 +- .../matlabtools/get_spec_helicity_slab.m | 65 +- Utilities/matlabtools/get_spec_jacobian.m | 11 +- Utilities/matlabtools/get_spec_length.m | 9 +- Utilities/matlabtools/get_spec_magfield.m | 66 +- Utilities/matlabtools/get_spec_metric.m | 14 +- .../matlabtools/get_spec_metric_contrav.m | 25 +- Utilities/matlabtools/get_spec_modB.m | 15 +- Utilities/matlabtools/get_spec_polflux.m | 15 +- .../matlabtools/get_spec_polynomial_basis.m | 119 ++ Utilities/matlabtools/get_spec_radius.m | 11 +- .../get_spec_regularisation_factor.m | 88 +- Utilities/matlabtools/get_spec_rtarr.m | 47 +- Utilities/matlabtools/get_spec_rzarr.m | 26 +- .../matlabtools/get_spec_surface_current.m | 15 +- .../matlabtools/get_spec_torcurr_kam_net.m | 19 +- Utilities/matlabtools/get_spec_torflux.m | 14 +- Utilities/matlabtools/get_spec_vecpot.m | 69 +- Utilities/matlabtools/get_spec_volume.m | 9 +- .../matlabtools/get_spec_volume_current.m | 15 +- Utilities/matlabtools/plot_spec_Bfield.m | 10 +- Utilities/matlabtools/plot_spec_Bgrid.m | 30 +- Utilities/matlabtools/plot_spec_Ivolume.m | 40 +- .../matlabtools/plot_spec_current_profile.m | 87 + Utilities/matlabtools/plot_spec_grid.m | 9 +- Utilities/matlabtools/plot_spec_hessian.m | 15 +- Utilities/matlabtools/plot_spec_iota.m | 58 +- Utilities/matlabtools/plot_spec_iotakam.m | 19 +- Utilities/matlabtools/plot_spec_jacobian.m | 22 +- Utilities/matlabtools/plot_spec_kam.m | 13 +- Utilities/matlabtools/plot_spec_modB.m | 16 +- .../matlabtools/plot_spec_modB_boundary.m | 20 +- Utilities/matlabtools/plot_spec_outfluxfun.m | 17 +- Utilities/matlabtools/plot_spec_poincare.m | 119 +- Utilities/matlabtools/plot_spec_polflux.m | 13 +- Utilities/matlabtools/plot_spec_pressure.m | 24 +- Utilities/matlabtools/plot_spec_surfcurent.m | 8 +- Utilities/matlabtools/plot_spec_torflux.m | 18 +- Utilities/matlabtools/plot_spec_wall.m | 5 + Utilities/matlabtools/produce_spec_movie.m | 14 +- Utilities/matlabtools/read_hdf5.m | 6 + Utilities/matlabtools/read_spec.m | 8 +- Utilities/matlabtools/read_spec_hessian.m | 6 + Utilities/matlabtools/write_spec_input_L0.m | 5 + Utilities/matlabtools/write_spec_input_L1.m | 5 + Utilities/matlabtools/write_spec_input_L3.m | 7 +- Utilities/matlabtools/write_spec_rzdata.m | 5 + Utilities/matlabtools/write_spec_rzgrid.m | 18 +- 56 files changed, 2671 insertions(+), 541 deletions(-) create mode 100644 Utilities/matlabtools/SPEC_Namelist.m create mode 100644 Utilities/matlabtools/get_spec_polynomial_basis.m create mode 100644 Utilities/matlabtools/plot_spec_current_profile.m diff --git a/Utilities/matlabtools/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist.m new file mode 100644 index 00000000..4f2a5021 --- /dev/null +++ b/Utilities/matlabtools/SPEC_Namelist.m @@ -0,0 +1,1772 @@ +classdef SPEC_Namelist + properties (Access=public) + lists + physicslist + numericlist + locallist + globallist + diagnosticslist + screenlist + initial_guess + end + + methods (Access=public) + + % ===================================================================== + % Class constructor + function obj = SPEC_Namelist(inputfile, varargin) + + if( ~isempty(varargin) ) + input_category = varargin{1}; + end + + fid = fopen(inputfile,'r'); % open template file + tline = fgetl(fid); + + obj.lists = {'physicslist', 'numericlist', 'locallist', ... + 'globallist', 'diagnosticslist', 'screenlist'}; + + for ii=numel(obj.lists) + list = obj.lists{ii}; + obj.(list) = struct; + end + category = ''; + + boundary.Rbc = []; boundary.Rbs = []; boundary.Zbc = []; boundary.Zbs = []; ib=0; bm = []; bn = []; + wall.Rwc = []; wall.Rws = []; wall.Zwc = []; wall.Zws = []; iw=0; wm = []; wn = []; + Nfield.Vns = []; Nfield.Vnc = []; Nfield.Bnc = []; Nfield.Bns = []; iv=0; vm = []; vn = []; + + iline = 0; + while ~isempty(tline) || feof(fid) + + % Remove trailing and leading spaces + tline = strtrim(tline); + + if feof(fid) + break; + end + + iline = iline + 1 ; + % jump / lines between categories. + if strcmp(tline, '/') + if strcmp(category,'screenlist') + break; % end of file, ignore geometry initial guess + else + tline = fgetl(fid); + continue; + end + end + + % read category + if strcmp(tline(end-3:end),'list') + category = tline(2:end); + tline = fgetl(fid); + continue; + end + + + % Field + try + field = extractBefore(tline,'='); %read field + field = char(field); + field = field(~isspace(field)); %remove spaces + catch + disp(['Error in field reading at line ', num2str(iline)]) + disp(['Field is ', field]) + end + + + % Content + if length(field)<3 + + try + content_str = extractAfter(tline,'='); + content = char(content_str); + content = content(~isspace(content)); + if strcmp(content,'F') + content = false; + elseif strcmp(content,'T') + content = true; + else + content = str2num(char(content_str)); + end + + % Store in structure + obj.(category).(field) = content; + + catch + error(['Error reading line ', tline]) + + end + + + else + if strcmp(field(1:3),'Rbc') %need to split Rbc, Rbs, Zbc, Zbs + ib = ib + 1; + [n, m] = obj.get_nm_from_field(field); + + [value, field] = obj.extract_4_values(tline, n, m, 'Rbc', 'Zbs', 'Rbs', 'Zbc'); + + boundary.Rbc(ib) = 0.0; + boundary.Zbc(ib) = 0.0; + boundary.Zbs(ib) = 0.0; + boundary.Rbs(ib) = 0.0; + + nfield = length(field); + for ii=1:nfield + boundary.(field{ii})(ib) = value{ii}; + end + + bm(ib) = m; + bn(ib) = n; + + elseif strcmp(field(1:3),'Rwc') % same as above + iw = iw + 1; + [n, m] = obj.get_nm_from_field(field); + + [value, field] = obj.extract_4_values(tline, n, m, 'Rwc', 'Zws', 'Rws', 'Zwc'); + + wall.Rwc(iw) = 0.0; + wall.Zwc(iw) = 0.0; + wall.Zws(iw) = 0.0; + wall.Rws(iw) = 0.0; + + nfield = length(field); + for ii=1:nfield + wall.(field{ii})(iw) = value{ii}; + end + + wm(iw) = m; + wn(iw) = n; + + elseif strcmp(field(1:3),'Vns') || strcmp(field(1:3),'Vnc') || strcmp(field(1:3),'Bns') || strcmp(field(1:3),'Bnc')% same as above + iv = iv + 1; + [n, m] = obj.get_nm_from_field(field); + + [value, field] = obj.extract_4_values(tline, n, m, 'Vns', 'Bns', 'Vnc', 'Bnc'); + + Nfield.Vnc(iv) = 0.0; + Nfield.Bnc(iv) = 0.0; + Nfield.Vns(iv) = 0.0; + Nfield.Bns(iv) = 0.0; + + nfield = length(field); + for ii=1:nfield + Nfield.(field{ii})(iv) = value{ii}; + end + + vm(iv) = m; + vn(iv) = n; + + else % easier, just read content + content_str = extractAfter(tline,'='); + + content = char(content_str); + content = content(~isspace(content)); + if strcmp(content,'F') + content = false; + elseif strcmp(content,'T') + content = true; + else + content = str2num(char(content_str)); + end + + % Store in structure + if isempty(category) + obj.(input_category).(field) = content; + else + obj.(category).(field) = content; + end + end + end + + % get next line + tline = fgetl(fid); + end + + % Store rbc, rbs ... in structure + + boundaryfields = fieldnames(boundary); + wallfields = fieldnames(wall); + Nfieldfields = fieldnames(Nfield); + + for ii=1:4 + obj.physicslist.(boundaryfields{ii}) = boundary.(boundaryfields{ii}); + obj.physicslist.(wallfields{ii}) = wall.(wallfields{ii}); + obj.physicslist.(Nfieldfields{ii}) = Nfield.(Nfieldfields{ii}); + end + + fclose(fid); % close template file + + % Reformat the Rbc, Zbs, ... arrays + if(isfield(obj.physicslist, 'Mpol')) + Mpol = obj.physicslist.Mpol; + Ntor = obj.physicslist.Ntor; + else + Mpol = max([wm,bm,vm]); Ntor = max([wn,bn,vn]); + end + + mn = 1 + Ntor + Mpol * ( 2 * Ntor + 1 ); + + Rbc = zeros(1,mn); Rbs = zeros(1,mn); Zbc = zeros(1,mn); Zbs = zeros(1,mn); + Rwc = zeros(1,mn); Rws = zeros(1,mn); Zwc = zeros(1,mn); Zws = zeros(1,mn); + Vnc = zeros(1,mn); Vns = zeros(1,mn); Bnc = zeros(1,mn); Bns = zeros(1,mn); + im = zeros(1,mn); + in = zeros(1,mn); + + im(1:1+Ntor) = 0; + in(1:1+Ntor) = 0:Ntor; + count = Ntor+1; + for ii=1:Mpol + for jj=-Ntor:Ntor + count = count + 1; + im( count ) = ii; + in( count ) = jj; + end + end + + for imn = 1:mn + m = im(imn); + n = in(imn); + + b_ind = find(double(bm==m) .* double(bn==n)); + if( ~isempty(b_ind) ) + Rbc( imn ) = obj.physicslist.Rbc( b_ind ); + Rbs( imn ) = obj.physicslist.Rbs( b_ind ); + Zbc( imn ) = obj.physicslist.Zbc( b_ind ); + Zbs( imn ) = obj.physicslist.Zbs( b_ind ); + end + + w_ind = find(double(wm==m) .* double(wn==n)); + if( ~isempty(w_ind) ) + Rwc( imn ) = obj.physicslist.Rwc( w_ind ); + Rws( imn ) = obj.physicslist.Rws( w_ind ); + Zwc( imn ) = obj.physicslist.Zwc( w_ind ); + Zws( imn ) = obj.physicslist.Zws( w_ind ); + end + + v_ind = find(double(vm==m) .* double(vn==n)); + if( ~isempty(v_ind) ) + Vnc( imn ) = obj.physicslist.Vnc( v_ind ); + Vns( imn ) = obj.physicslist.Vns( v_ind ); + Bnc( imn ) = obj.physicslist.Bnc( v_ind ); + Bns( imn ) = obj.physicslist.Bns( v_ind ); + end + end + + obj.physicslist.im = im; + obj.physicslist.in = in; + + obj.physicslist.Rbc = Rbc; + obj.physicslist.Rbs = Rbs; + obj.physicslist.Zbc = Zbc; + obj.physicslist.Zbs = Zbs; + + obj.physicslist.Rwc = Rwc; + obj.physicslist.Rws = Rws; + obj.physicslist.Zwc = Zwc; + obj.physicslist.Zws = Zws; + + obj.physicslist.Vnc = Vnc; + obj.physicslist.Vns = Vns; + obj.physicslist.Bnc = Bnc; + obj.physicslist.Bns = Bns; + + obj = obj.update_flux_surfaces(); + + % Read initial guess + try + obj = obj.read_initial_guess( inputfile ); + catch + warning('No initial guess available') + end + + end + + + function obj = read_initial_guess(obj, init_guess_file) + % + % Read geometrical initial guess from another input / .end file + % + % INPUT + % ----- + % - init_guess_file: filename from which initial guess is read + % + % OUTPUT + % ------ + % - obj: updated version of SPEC_Namelist object + % + + fid2 = fopen(init_guess_file, 'r'); + + save_line = false; + category = ''; + + initial_guess = {}; + + while( ~feof(fid2) ) % while it is not the end of the file + + tline = fgetl(fid2); + tline = strtrim(tline); + + field = extractBefore(tline,'='); %read field + field = char(field); + field = field(~isspace(field)); %remove spaces + content_str = extractAfter(tline,'='); + content = str2num(content_str); + + % Read initial guess for coordinate axis + switch field + case 'Rac' + obj.physicslist.Rac = content; + case 'Ras' + obj.physicslist.Ras = content; + case 'Zac' + obj.physicslist.Zac = content; + case 'Zas' + obj.physicslist.Zas = content; + end + + + if( save_line ) % write line + initial_guess{end+1} = tline; + + else % otherwise look for beginning of geometrical initial guess + if( strcmp(tline, '/') ) + if( strcmp(category,'screenlist') ) + save_line = true; + end + + else + % read category + if strcmp(tline(end-3:end),'list') + category = tline(2:end); + end + + end + end + + + end % end of while + + fclose(fid2); % Close file + + % ================================== + % Now, format initial guess in arrays + % Prepare format for reading + nlines = length(initial_guess); + + % Allocate memory + im = obj.physicslist.im; in = obj.physicslist.in; + mn = length( im ); + Nvol = obj.physicslist.Nvol; + Mvol = Nvol + obj.physicslist.Lfreebound; + + Ric = zeros(mn,Mvol); Zis = zeros(mn,Mvol); + Ris = zeros(mn,Mvol); Zic = zeros(mn,Mvol); + + format = '%f%f'; + for ii=1:Nvol + format = [format, '%f%f%f%f']; + end + + + % Read + for iline=1:nlines + + % Scan line + line_data = textscan( initial_guess{iline}, format ); + + % Find corresponding index + m = line_data{1}; n = line_data{2}; + imn = obj.find_ii_given_mn(m, n); + + for ivol=1:Nvol + Ric(imn,ivol) = line_data{ivol*4-1}; + Zis(imn,ivol) = line_data{ivol*4 }; + Ris(imn,ivol) = line_data{ivol*4+1}; + Zic(imn,ivol) = line_data{ivol*4+2}; + end + end + + init.Ric = Ric; + init.Ris = Ris; + init.Zis = Zis; + init.Zic = Zic; + + obj.initial_guess = init; + + end + + + function obj = read_axis_from_focus(obj, focus_data) + + Ntor = obj.physicslist.Ntor; + + axis = focus_data.get_axis_harmonics( Ntor ); + + obj.physicslist.Rac = axis.Remn(Ntor+1:end); + obj.physicslist.Ras = axis.Romn(Ntor+1:end); + obj.physicslist.Zac = axis.Zemn(Ntor+1:end); + obj.physicslist.Zas = axis.Zomn(Ntor+1:end); + + end + + + function obj = interpolate_initial_guess( obj, interp_type, Linitialize ) + % + % INTERPOLATE_INITIAL_GUESS( INTERP_TYPE, LINITIALIZE ) + % ===================================================== + % + % Generate an initial guess by interpolation from computational boundary + % (if free-boundary and Linitialize=2) or from plasma boundary + % (if Linitialize=1). + % + % INPUTS + % ------ + % * interp_type: (1) Same interpolation as in SPEC + % (2) Same as in SPEC, but plasma boundary is considered + % as an internal plasma boundary + % * Linitialize (0) No interpolation + % (1) Inner plasma interfaces are interpolated + % (2) Inner plasma and plasma-vacuum interfaces are + % interpolated + % + % OUTPUTS + % ------- + % * obj: instance of SPEC_Namelist + % + % + + machine_precision = eps; + vsmall = 100 * machine_precision; + small = 100 * vsmall; + + Nvol = obj.physicslist.Nvol; + Mvol = Nvol + obj.physicslist.Lfreebound; + + % First find the axis + if( obj.physicslist.Igeometry==3 && (obj.physicslist.Rac(1) Mpol + continue + end + + if in(ii) > Ntor + continue + end + + arg = im(ii) * theta - in(ii) * Nfp * phi; + cosarg = cos(arg); + sinarg = sin(arg); + + R = R + Rmnc(ii) * cosarg + Rmns(ii) * sinarg; + Z = Z + Zmnc(ii) * cosarg + Zmns(ii) * sinarg; + + end + + switch newfig + case 0 + hold on; + case 1 + figure('Color', 'w', 'Position', [200 200 900 700]) + case 2 + hold off; + end + scatter(R,Z,50, 'filled') + xlabel('$R$[m]', 'Interpreter', 'latex') + ylabel('$Z$[m]', 'Interpreter', 'latex') + set(gca, 'FontSize', 18) + + end + + + function plot_initial_guess( obj, phi, Nt, newfig ) + % + % PLOT_INITIAL_GUESS( PHI, NT, ONLY_BOUNDARY, NEWFIG ) + % ==================================================== + % + % Plots spec input initial guess. + % + % INPUTS + % ------ + % * PHI: Toroidal angle + % * NT: Number of points per surface + % * NEWFIG: (0) Plots on gcf + % (1) Opens a new figure + % (2) Overplots on gcf + % + % Written by A. Baillod (2020) + % + + +% if isempty(obj.initial_guess) +% error('No initial guess. First read with read_initial_guess'); +% end + + + % Open figure + switch newfig + case 0 + hold on + case 1 + figure + hold on; + case 2 + hold off; + otherwise + error( 'Unknown value of newfig') + end + + Nvol = obj.physicslist.Nvol; + im = obj.physicslist.im; in = obj.physicslist.in; + mn = length(im); + Np = obj.physicslist.Nfp; + + % Prepare theta coordinate + theta = linspace(0,2*pi,Nt)'; + + % Map to real space + if( ~isempty(obj.initial_guess) ) + for ivol=1:Nvol + R = zeros(1,Nt); + Z = zeros(1,Nt); + + for imn=1:mn + cosarg = cos(im(imn)*theta - in(imn)*Np*phi); + sinarg = sin(im(imn)*theta - in(imn)*Np*phi); + + + R(:) = R(:) + obj.initial_guess.Ric(imn,ivol) * cosarg ... + + obj.initial_guess.Ris(imn,ivol) * sinarg; + Z(:) = Z(:) + obj.initial_guess.Zic(imn,ivol) * cosarg ... + + obj.initial_guess.Zis(imn,ivol) * sinarg; + end + + scatter(R, Z, 3, 'filled', 'MarkerFaceColor', 'b') + end + end + + % Plot plasma boundary + R = zeros(1,Nt); + Z = zeros(1,Nt); + + for imn=1:mn + cosarg = cos(im(imn)*theta - in(imn)*Np*phi); + sinarg = sin(im(imn)*theta - in(imn)*Np*phi); + + try + R(:) = R(:) + obj.physicslist.Rbc(imn) * cosarg ... + + obj.physicslist.Rbs(imn) * sinarg; + Z(:) = Z(:) + obj.physicslist.Zbc(imn) * cosarg ... + + obj.physicslist.Zbs(imn) * sinarg; + catch + disp('ouch') + end + end + + scatter(R, Z, 3, 'filled', 'MarkerFaceColor', [1 0 0]) + + + if obj.physicslist.Lfreebound + R = zeros(1,Nt); + Z = zeros(1,Nt); + + Rwc = obj.physicslist.Rwc; + Zwc = obj.physicslist.Zwc; + Rws = obj.physicslist.Rws; + Zws = obj.physicslist.Zws; + + for imn=1:mn + cosarg = cos(im(imn)*theta - in(imn)*Np*phi); + sinarg = sin(im(imn)*theta - in(imn)*Np*phi); + + R(:) = R(:) + Rwc(imn) * cosarg + Rws(imn) * sinarg; + Z(:) = Z(:) + Zwc(imn) * cosarg + Zws(imn) * sinarg; + end + + scatter(R, Z, 5, 'filled', 'MarkerFaceColor', [0 0 0]) + end + + %Plot the magnetic axis guess + Rax = 0; Zax = 0; + mn = length(obj.physicslist.Rac); + Nfp = double(obj.physicslist.Nfp); + for n=0:mn-1 + Rax = Rax + obj.physicslist.Rac(n+1) * cos(n * Nfp * phi) ... + - obj.physicslist.Ras(n+1) * sin(n * Nfp * phi); + Zax = Zax + obj.physicslist.Zac(n+1) * cos(n * Nfp * phi) ... + - obj.physicslist.Zas(n+1) * sin(n * Nfp * phi); + end + + scatter( Rax, Zax, 50, 'filled', 'MarkerFaceColor', 'g') + + + axis equal; + + end + + + function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) + + l = length(varargin); + if mod(l,2)~=0 + error('Incorrect number of input arguments') + end + + focus = false; f= NaN; + lines = NaN; + for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + switch field + case 'focus' + focus = true; + f = value; + case 'lines' + lines = value; + end + end + + + figdir = pwd; + GIFNAME = [figdir, '/', gifname ]; + + Nfp = double(obj.physicslist.Nfp); + + if focus + s = size(f.outputdata.ppr); + Nframes = s(2)-1; + else + phi_array = linspace(0, 2.0*pi/Nfp, Nframes); + end + Nt = 1024; + + % determine xlim and ylim + ind = find( double(obj.physicslist.im~=0) .* double(obj.physicslist.in~=0) ); + %xmin = obj.physicslist.Rac(1) - sum(abs(obj.physicslist.Rwc(ind))) - sum(abs(obj.physicslist.Rws(ind))); + %xmax = obj.physicslist.Rac(1) + sum(abs(obj.physicslist.Rwc(ind))) + sum(abs(obj.physicslist.Rws(ind))); + %ymin = obj.physicslist.Zac(1) - sum(abs(obj.physicslist.Zwc(ind))) - sum(abs(obj.physicslist.Zws(ind))); + %ymax = obj.physicslist.Zac(1) + sum(abs(obj.physicslist.Zwc(ind))) + sum(abs(obj.physicslist.Zws(ind))); + + %ydiff = ymax-ymin; + %xdiff = xmax-xmin; + + for iframe = 1:Nframes + + if focus + if isnan(lines) + phi = f.plot_poincare( iframe, 1 ); + else + phi = f.plot_poincare( iframe, 1, 'lines', lines ); + end + + newfig = 0; + else + newfig = 1; + phi = phi_array(iframe); + end + + plot_initial_guess( obj, phi, Nt, newfig ) + + axis equal; + + %xlim([xmin*0.9, xmax*1.1]) + %ylim([ymin*0.9, ymax*1.1]) + + drawnow; + + % Capture the plot as an image + fig = gcf; + frame = getframe(fig); + im = frame2im(frame); + [imind,cm] = rgb2ind(im,32); + + % Write to the GIF File + if iframe == 1 + imwrite(imind,cm,GIFNAME,'gif', 'Loopcount',inf); + else + imwrite(imind,cm,GIFNAME,'gif','WriteMode','append', 'DelayTime', frame_rate); + end + + close( fig); + end + + disp(' ') + disp(['Gif saved @ : ',GIFNAME]) + + end + + + % ===================================================================== + % Getters + function out = get_plasma_boundary(obj, m, n)% + % Return Rbc, Zbs, Rbs, Zbc for given m, n mode + % + % INPUT + % ----- + % - m: poloidal harmonic + % - n: toroidal harmonic + % + % OUTPUT + % ------ + % - out: structure with field out.Rbc, out.Rbs, out.Zbc, out.Zbs + % + + ii = obj.find_ii_given_mn(m, n); + + if isnan(ii) + out.Rbc = 0.0; + out.Rbs = 0.0; + out.Zbc = 0.0; + out.Zbs = 0.0; + else + out.Rbc = obj.physicslist.Rbc(ii); + out.Rbs = obj.physicslist.Rbs(ii); + out.Zbc = obj.physicslist.Zbc(ii); + out.Zbs = obj.physicslist.Zbs(ii); + end + + end + + + function out = get_wall(obj, m, n) + % + % Return Rwc, Zws, Rws, Zwc for given m, n mode + % + % INPUT + % ----- + % - m: poloidal harmonic + % - n: toroidal harmonic + % + % OUTPUT + % ------ + % - out: structure with field out.Rwc, out.Rws, out.Zwc, out.Zws + % + ii = obj.find_ii_given_mn(m, n); + + if isnan(ii) + out.Rwc = 0.0; + out.Rws = 0.0; + out.Zwc = 0.0; + out.Zws = 0.0; + else + out.Rwc = obj.physicslist.Rwc(ii); + out.Rws = obj.physicslist.Rws(ii); + out.Zwc = obj.physicslist.Zwc(ii); + out.Zws = obj.physicslist.Zws(ii); + end + end + + + function out = get_vnc_bns(obj, m, n) + % Return Vnc, Vns, Bnc, Bns for given m, n mode + % + % INPUT + % ----- + % - m: poloidal harmonic + % - n: toroidal harmonic + % + % OUTPUT + % ------ + % - out: structure with field out.Vnc, out.Vns, out.Bnc, out.Bns + % + + ii = obj.find_ii_given_mn(m, n); + + if isnan(ii) + out.Vnc = 0.0; + out.Vns = 0.0; + out.Bnc = 0.0; + out.Bns = 0.0; + else + out.Vnc = obj.physicslist.Vnc(ii); + out.Vns = obj.physicslist.Vns(ii); + out.Bnc = obj.physicslist.Bnc(ii); + out.Bns = obj.physicslist.Bns(ii); + end + end + + + function out = get_fourier_harmonics(obj, m, n, field) + + ii = obj.find_ii_given_mn( m, n); + + if( strcmp(field, 'Ric') || strcmp(field, 'Ris') || strcmp(field, 'Zic') || strcmp(field, 'Zis')) + if( isempty(obj.initial_guess) ) + error('No initial guess') + else + out = obj.initial_guess.(field)(ii); + end + else + out = obj.physicslist.(field)(ii); + end + end + + + % ===================================================================== + % Setters + function obj = set_fourier_harmonics(obj, im, in, values, field) + + mn = length(im); + mn_old = length(obj.physicslist.Rbc); + + obj.physicslist.(field) = zeros(1, mn_old); + + for ii = 1:mn + m = im(ii); n=in(ii); + imn = obj.find_ii_given_mn(m, n); + + if( isempty(imn) ) % Add mode + obj.physicslist.im(end+1) = m; + obj.physicslist.in(end+1) = n; + + obj.physicslist.Rbc(end+1) = 0.0; + obj.physicslist.Rbs(end+1) = 0.0; + obj.physicslist.Zbc(end+1) = 0.0; + obj.physicslist.Zbs(end+1) = 0.0; + + obj.physicslist.Rwc(end+1) = 0.0; + obj.physicslist.Rws(end+1) = 0.0; + obj.physicslist.Zwc(end+1) = 0.0; + obj.physicslist.Zws(end+1) = 0.0; + + obj.physicslist.Vnc(end+1) = 0.0; + obj.physicslist.Vns(end+1) = 0.0; + obj.physicslist.Bnc(end+1) = 0.0; + obj.physicslist.Bns(end+1) = 0.0; + + if( ~isempty(obj.initial_guess) ) + obj.initial_guess.Ric(end+1, :) = 0.0; + obj.initial_guess.Ris(end+1, :) = 0.0; + obj.initial_guess.Zic(end+1, :) = 0.0; + obj.initial_guess.Zis(end+1, :) = 0.0; + end + + obj.physicslist.(field)(end) = values(ii); + + else + obj.physicslist.(field)(imn) = values(ii); + + end + + obj = obj.update_flux_surfaces(); + + end + + + end + + + function obj = set_initial_guess_harmonics( obj, volume, im, in, values, field) + + mn = length(im); + mn_old = length(obj.physicslist.Rbc); + + Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; + obj.initial_guess.(field) = zeros(mn_old, Mvol); + + for ii = 1:mn + m = im(ii); n=in(ii); + imn = obj.find_ii_given_mn(m, n); + + if( isempty(imn) ) % Add mode + obj.physicslist.im(end+1) = m; + obj.physicslist.in(end+1) = n; + + obj.physicslist.Rbc(end+1) = 0.0; + obj.physicslist.Rbs(end+1) = 0.0; + obj.physicslist.Zbc(end+1) = 0.0; + obj.physicslist.Zbs(end+1) = 0.0; + + obj.physicslist.Rwc(end+1) = 0.0; + obj.physicslist.Rws(end+1) = 0.0; + obj.physicslist.Zwc(end+1) = 0.0; + obj.physicslist.Zws(end+1) = 0.0; + + obj.physicslist.Vnc(end+1) = 0.0; + obj.physicslist.Vns(end+1) = 0.0; + obj.physicslist.Bnc(end+1) = 0.0; + obj.physicslist.Bns(end+1) = 0.0; + + obj.initial_guess.Ric(end+1, :) = 0.0; + obj.initial_guess.Ris(end+1, :) = 0.0; + obj.initial_guess.Zic(end+1, :) = 0.0; + obj.initial_guess.Zis(end+1, :) = 0.0; + + obj.initial_guess.(field)(end, volume) = values(ii); + + else + obj.initial_guess.(field)(imn, volume) = values(ii); + + end + + + end + + + end + + + % ===================================================================== + % Utility + function compare_fourier_harmonics(obj, spec_nm, field) + + nm_in = length(obj.physicslist.im); + nm_ou = length(spec_nm.physicslist.im); + + nm = max([nm_in, nm_ou]); + + for ii = 1:nm + + if( nm_in>nm_ou) + m = obj.physicslist.im(ii); + n = obj.physicslist.in(ii); + else + m = spec_nm.physicslist.im(ii); + n = spec_nm.physicslist.in(ii); + end + + ind_in = obj.find_ii_given_mn( m, n); + ind_ou = spec_nm.find_ii_given_mn( m, n); + + if( isempty(ind_in) ) + if( ~isempty(ind_ou) ) + value = spec_nm.physicslist.(field)(ind_ou); + if( value ~= 0 ) + disp( [field, '(', num2str(m), ',', num2str(n) ') missmatch. Obj has value 0 while spec_nm has value ', num2str(value)]); + end + end + else + val_in = obj.physicslist.(field)(ind_in); + if( isempty(ind_ou) ) + disp( [field, '(', num2str(m), ',', num2str(n) ') missmatch. Obj has value ', num2str(val_in), ' while spec_nm has value 0']); + else + val_ou = spec_nm.physicslist.(field)(ind_ou); + + delta = abs(val_in - val_ou); + if( delta>1E-16 ) + disp( [field, '(', num2str(m), ',', num2str(n) ') missmatch. Obj has value ', num2str(val_in), ' while spec_nm has value ', num2str(val_ou)]) + end + end + end + + + + end + + + + + end + + + function obj = add_volume( obj, tflux ) + + Nvol = obj.physicslist.Nvol; + if Nvol==1 + error('Not implemented for Nvol=1') + end + + obj.physicslist.Nvol = obj.physicslist.Nvol + 1; + + % Find between which interface to put it + [tmp, ind] = min(abs(tflux - obj.physicslist.tflux)); + tmp = obj.physicslist.tflux(ind); + + if tmp-tflux>0 + ind = ind-1; + end + + disp(newline) + disp(newline) + fprintf('Adding a volume between interface %u and %u ...\n', ind, ind+1) + fprintf('======================================================\n') + + % Build new profiles + old_tflux = obj.physicslist.tflux; + obj.physicslist.tflux = [obj.physicslist.tflux(1:ind), tflux, obj.physicslist.tflux(ind+1:end)]; + + pflux = obj.physicslist.pflux; + if ind==0 + newpflux = pflux(ind+1)/2; + else + newpflux = (pflux(ind)+pflux(ind+1))/2; + end + obj.physicslist.pflux = [pflux(1:ind), newpflux, pflux(ind+1:end)]; + + Lrad = obj.physicslist.Lrad; + obj.physicslist.Lrad = [Lrad(1:ind), Lrad(ind+1), Lrad]; + + hel = obj.physicslist.helicity; + obj.physicslist.helicity = [hel(1:ind), 0, hel(ind+1:end)]; + + pressure = obj.physicslist.pressure; + if ind==0 + newpressure = pressure(ind+1)*1.3; + else + newpressure = (pressure(ind)+pressure(ind+1))/2; + end + obj.physicslist.pressure = [pressure(1:ind), newpressure, pressure(ind+1:end)]; + + adiabatic = obj.physicslist.adiabatic; + if ind==0 + newadiab = adiabatic(ind+1); + else + newadiab = (adiabatic(ind)+adiabatic(ind+1))/2; + end + obj.physicslist.adiabatic = [adiabatic(1:ind), newadiab, adiabatic(ind+1:end)]; + + mu = obj.physicslist.mu; + obj.physicslist.mu = [mu(1:ind), mu(ind+1), mu(ind+1:end)]; + + Ivolume = obj.physicslist.Ivolume; + obj.physicslist.Ivolume = [Ivolume(1:ind), Ivolume(ind+1), Ivolume(ind+1:end)]; + + Isurf = obj.physicslist.Isurf; + if ind==0 + newIsurf = Isurf(1); + else + newIsurf = Isurf(ind); + end + obj.physicslist.Isurf = [Isurf(1:ind), newIsurf, Isurf(ind+1:end)]; + + iota = obj.physicslist.iota; + if ind==0 + newiota = iota(ind+1); + else + newiota = (iota(ind)+iota(ind+1))/2; + end + obj.physicslist.iota = [iota(1:ind), newiota, iota(ind+1:end)]; + + oita = obj.physicslist.oita; + if ind==0 + newoita = oita(ind+1); + else + newoita = (oita(ind)+oita(ind+1))/2; + end + obj.physicslist.oita = [oita(1:ind), newoita, oita(ind+1:end)]; + + disp(newline) + fprintf('New profiles have been generated with averaged values. Please modify if necessary.\n') + fprintf(' tflux = %.8E \n', tflux ) + fprintf(' pflux = %.8E \n', newpflux ) + fprintf(' Lrad = %.8E \n', Lrad(ind+1) ) + fprintf(' helicity = %.8E \n', 0 ) + fprintf(' pressure = %.8E \n', newpressure ) + fprintf(' adiabatic = %.8E \n', newadiab ) + fprintf(' mu = %.8E \n', mu(ind+1) ) + fprintf(' Ivolume = %.8E \n', Ivolume(ind+1) ) + fprintf(' Isurf = %.8E \n', newIsurf ) + fprintf(' iota = %.8E \n', newiota ) + fprintf(' oita = %.8E \n', newoita ) + disp(newline) + + + % Interpolate initial guess + if( isempty(obj.initial_guess) ) + disp('No initial guess to build, returning ...') + disp(newline) + return + end + + + + % First select closest boundaries harmonics +% +% nmn = length( obj.physicslist.im ); +% Mpol = max(obj.physicslist.im); +% Ntor = max(obj.physicslist.in); +% stellsym = false; +% +% newGuess = fluxSurface( obj.physicslist.Nfp, Mpol, Ntor, stellsym ); +% +% for imn = 1:nmn +% +% m = obj.physicslist.im(imn); +% n = obj.physicslist.in(imn); +% +% x = [0, old_tflux( 1:end-1 )]; +% +% y = obj.initial_guess.Ric( imn, 1:end-1 ); +% y = [0, y]; +% if m==0 +% y(1) = obj.physicslist.Rac( n+1 ); +% end +% p = polyfit( x, y./x, 1 ); +% value = polyval( p, tflux ) * tflux; +% newGuess = newGuess.set_value( 'rmnc', value, m, n ); +% +% y = obj.initial_guess.Ris( imn, 1:end-1 ); +% y = [0, y]; +% if m==0 +% y(1) = obj.physicslist.Ras( n+1 ); +% end +% p = polyfit( x, y./x, 1 ); +% value = polyval( p, tflux ) * tflux; +% newGuess = newGuess.set_value( 'rmns', value, m, n ); +% +% y = obj.initial_guess.Zic( imn, 1:end-1 ); +% y = [0, y]; +% if m==0 +% y(1) = obj.physicslist.Zac( n+1 ); +% end +% p = polyfit( x, y./x, 1 ); +% value = polyval( p, tflux ) * tflux; +% newGuess = newGuess.set_value( 'zmnc', value, m, n ); +% +% y = obj.initial_guess.Zis( imn, 1:end-1 ); +% y = [0, y]; +% if m==0 +% y(1) = obj.physicslist.Zas( n+1 ); +% end +% p = polyfit( x, y./x, 1 ); +% value = polyval( p, tflux ) * tflux; +% newGuess = newGuess.set_value( 'zmns', value, m, n ); +% end +% +% obj.initial_guess.Ric = [obj.initial_guess.Ric(:,1:ind), newGuess.rmnc', obj.initial_guess.Ric(:,ind+1:end)]; +% obj.initial_guess.Ris = [obj.initial_guess.Ris(:,1:ind), newGuess.rmns', obj.initial_guess.Ris(:,ind+1:end)]; +% obj.initial_guess.Zic = [obj.initial_guess.Zic(:,1:ind), newGuess.zmnc', obj.initial_guess.Zic(:,ind+1:end)]; +% obj.initial_guess.Zis = [obj.initial_guess.Zis(:,1:ind), newGuess.zmns', obj.initial_guess.Zis(:,ind+1:end)]; + + + + nmn = length(obj.physicslist.im); + + if ind==0 %Then first volume, need regularisation + l = length(obj.physicslist.Rac); + if l>obj.physicslist.Ntor+1 + l = obj.physicslist.Ntor+1; + end + + Ric_low = zeros(nmn, 1); + Ric_low(1:l) = obj.physicslist.Rac(1:l); + Ris_low = zeros(nmn, 1); + Ris_low(1:l) = obj.physicslist.Ras(1:l); + Zic_low = zeros(nmn, 1); + Zic_low(1:l) = obj.physicslist.Zac(1:l); + Zis_low = zeros(nmn, 1); + Zis_low(1:l) = obj.physicslist.Zas(1:l); + + delta_tflux = obj.physicslist.tflux(ind+2); + tflux_norm = tflux / delta_tflux; + + else + delta_tflux = obj.physicslist.tflux(ind+2) - obj.physicslist.tflux(ind); + tflux_norm = (tflux - obj.physicslist.tflux(ind)) / delta_tflux; + Ric_low = obj.initial_guess.Ric(:,ind); + Ris_low = obj.initial_guess.Ris(:,ind); + Zic_low = obj.initial_guess.Zic(:,ind); + Zis_low = obj.initial_guess.Zis(:,ind); + + end + + + if ind==Nvol-1 + Ric_high = obj.physicslist.Rbc'; + Ris_high = obj.physicslist.Rbs'; + Zic_high = obj.physicslist.Zbc'; + Zis_high = obj.physicslist.Zbs'; + + else + Ric_high = obj.initial_guess.Ric(:,ind+1); + Ris_high = obj.initial_guess.Ris(:,ind+1); + Zic_high = obj.initial_guess.Zic(:,ind+1); + Zis_high = obj.initial_guess.Zis(:,ind+1); + + end + + % Now build regularisation factor + fj = zeros(nmn, 1); + + if ind==0 % first volume, need to regularize non-zero m-harmonics + + for ii=1:nmn + im = obj.physicslist.im(ii); + + if im==0 + fj(ii) = sqrt(tflux_norm); + else + fj(ii) = tflux_norm.^(im / 2.0); + end + end + + else % Not in first volume, them linear interpolation in radius + + fj = ones(nmn, 1) * sqrt(tflux_norm); + + end + + + % Interpolate + new_Ric = Ric_low + (Ric_high - Ric_low) .* tflux_norm; + new_Ris = Ris_low + (Ris_high - Ris_low) .* tflux_norm; + new_Zic = Zic_low + (Zic_high - Zic_low) .* tflux_norm; + new_Zis = Zis_low + (Zis_high - Zis_low) .* tflux_norm; + + + obj.initial_guess.Ric = [obj.initial_guess.Ric(:,1:ind), new_Ric, obj.initial_guess.Ric(:,ind+1:end)]; + obj.initial_guess.Ris = [obj.initial_guess.Ris(:,1:ind), new_Ris, obj.initial_guess.Ris(:,ind+1:end)]; + obj.initial_guess.Zic = [obj.initial_guess.Zic(:,1:ind), new_Zic, obj.initial_guess.Zic(:,ind+1:end)]; + obj.initial_guess.Zis = [obj.initial_guess.Zis(:,1:ind), new_Zis, obj.initial_guess.Zis(:,ind+1:end)]; + + + end + + + function obj = remove_volume( obj, ivol ) + + obj.physicslist.Nvol = obj.physicslist.Nvol-1; + obj.physicslist.Lrad = [obj.physicslist.Lrad(1:ivol-1), obj.physicslist.Lrad(ivol+1:end) ]; + obj.physicslist.tflux = [obj.physicslist.tflux(1:ivol-1), obj.physicslist.tflux(ivol+1:end) ]; + obj.physicslist.pflux = [obj.physicslist.pflux(1:ivol-1), obj.physicslist.pflux(ivol+1:end) ]; + obj.physicslist.helicity = [obj.physicslist.helicity(1:ivol-1), obj.physicslist.helicity(ivol+1:end) ]; + obj.physicslist.pressure = [obj.physicslist.pressure(1:ivol-1), obj.physicslist.pressure(ivol+1:end) ]; + obj.physicslist.adiabatic = [obj.physicslist.adiabatic(1:ivol-1), obj.physicslist.adiabatic(ivol+1:end)]; + obj.physicslist.mu = [obj.physicslist.mu(1:ivol-1), obj.physicslist.mu(ivol+1:end) ]; + obj.physicslist.Ivolume = [obj.physicslist.Ivolume(1:ivol-1), obj.physicslist.Ivolume(ivol+1:end) ]; + obj.physicslist.Isurf = [obj.physicslist.Isurf(1:ivol-1), obj.physicslist.Isurf(ivol+1:end) ]; + obj.physicslist.iota = [obj.physicslist.iota(1:ivol), obj.physicslist.iota(ivol+2:end) ]; + obj.physicslist.oita = [obj.physicslist.oita(1:ivol), obj.physicslist.oita(ivol+2:end) ]; + obj.diagnosticslist.nPtrj = [obj.diagnosticslist.nPtrj(1:ivol-1), obj.diagnosticslist.nPtrj(ivol+1:end)]; + + + obj.initial_guess.Ric = [obj.initial_guess.Ric(:,1:ivol-1), obj.initial_guess.Ric(:,ivol+1:end)]; + obj.initial_guess.Ris = [obj.initial_guess.Ris(:,1:ivol-1), obj.initial_guess.Ris(:,ivol+1:end)]; + obj.initial_guess.Zic = [obj.initial_guess.Zic(:,1:ivol-1), obj.initial_guess.Zic(:,ivol+1:end)]; + obj.initial_guess.Zis = [obj.initial_guess.Zis(:,1:ivol-1), obj.initial_guess.Zis(:,ivol+1:end)]; + + + end + + + + % ===================================================================== + % Write method + function write_input_file(obj, filename, varargin ) + % + % write_input_file(filename, (force) ) + % + % Write namelist in an input file. Be careful: if the file filename + % provided as input exist, it will be overwritten! + % + % INPUT + % ----- + % - filename: path where to save the input file. + % - options: structure containing optional input + % * force: set to true to force overwritting the input file + % + + % Read options + if( isempty(varargin) ) + force = false; + else + if( isfield(varargin{1}, 'force') ) + force = varargin{1}.force; + else + force = false; + end + end + + % Check if user want to erase existing file + if (exist(filename, 'file') && (~force)) + prompt = ['The file ', filename, ' already exist and will be overwritten. Continue? Y/N [Y]: ']; + c = input(prompt, 's'); + if( isempty(c) ) + c = 'Y'; + end + while ~( strcmp(c,"Y") || strcmp(c,"N") ) + c = input(['Please answer Y or N: '], 's'); + end + + if strcmp(c,'N') %exit routine + disp('ABORTED') + return; + else + disp(['Overwriting file ', filename, '.']) + end + end + + % Open file + fid = fopen(filename, 'w'); + + + special_list = {'Rbc', 'Rbs', 'Zbc', 'Zbs', 'im', 'in', ... + 'Rwc', 'Rws', 'Zwc', 'Zws', ... + 'Vnc', 'Vns', 'Bnc', 'Bns', ... + 'PlasmaBoundary', 'ComputationalBoundary'}; + for ii=1:numel(obj.lists) + list = obj.lists{ii}; + + if strcmp(list, 'physicslist') + obj.write_list(fid, list, special_list) + + % write Rbc, ... + obj.write_4_values(fid, 'Rbc', 'Zbs', 'Rbs', 'Zbc'); + obj.write_4_values(fid, 'Rwc', 'Zws', 'Rws', 'Zwc'); + obj.write_4_values(fid, 'Vnc', 'Vns', 'Bnc', 'Bns'); + + fprintf(fid, '/ \n'); + + else + obj.write_list(fid, list, special_list) + + fprintf(fid, '/ \n'); + end + + end + + + im = obj.physicslist.im; in = obj.physicslist.in; + mn = length(im); + + if( ~isempty(obj.initial_guess) ) + Ric = obj.initial_guess.Ric; + s = size(Ric); + + for ii=1:mn + fprintf(fid, ' %i %i', im(ii), in(ii)); + for jj=1:s(2) + fprintf(fid, ' %19.15E %19.15E %19.15E %19.15E', ... + obj.initial_guess.Ric(ii,jj), ... + obj.initial_guess.Zis(ii,jj), ... + obj.initial_guess.Ris(ii,jj), ... + obj.initial_guess.Zic(ii,jj)); % Print in file + end + fprintf(fid, '\n'); + end + end + + % close file + fclose(fid); + + end %of function write_input_file + + + function ii = find_ii_given_mn(obj, m, n) + + im = obj.physicslist.im; + in = obj.physicslist.in; + ii = find(double(im==m) .* double(in==n)); + end + + end % of public methods + % ---------------------------------------------------------------------- + % PRIVATE METHODS + % ====================================================================== + % + methods (Access = private) + + function obj = update_flux_surfaces( obj ) + + im = obj.physicslist.im; + in = obj.physicslist.in; + Mpol = max(im); Ntor = max(in); + + PlasmaBoundary = fluxSurface(obj.physicslist.Nfp, Mpol, Ntor, 0); + PlasmaBoundary = PlasmaBoundary.set_array('rmnc', obj.physicslist.Rbc, im, in); + PlasmaBoundary = PlasmaBoundary.set_array('rmns', obj.physicslist.Rbs, im, in); + PlasmaBoundary = PlasmaBoundary.set_array('zmnc', obj.physicslist.Zbc, im, in); + PlasmaBoundary = PlasmaBoundary.set_array('zmns', obj.physicslist.Zbs, im, in); + obj.physicslist.PlasmaBoundary = PlasmaBoundary; + + CompBoundary = fluxSurface(obj.physicslist.Nfp, Mpol, Ntor, 0); + CompBoundary = CompBoundary.set_array('rmnc', obj.physicslist.Rwc, im, in); + CompBoundary = CompBoundary.set_array('rmns', obj.physicslist.Rws, im, in); + CompBoundary = CompBoundary.set_array('zmnc', obj.physicslist.Zwc, im, in); + CompBoundary = CompBoundary.set_array('zmns', obj.physicslist.Zws, im, in); + obj.physicslist.ComputationalBoundary = CompBoundary; + end + + function [value, field] = extract_4_values(obj, tline, n, m, str1, str2, str3, str4) + % Extract rbc, rbs, zbc, zbs components from input file. Only + % used in the class constructor + work = tline; + + + % Remove (n,m) from line + p_open = find(work=='('); + p_close = find(work==')'); + + nfield = length(p_open); + if(nfield>4) + error(['Bad format on line: ', work,', need only four fields']); + end + + work = tline(1:p_open(1)-1); + for ii=2:nfield + work = [work, tline(p_close(ii-1)+1:p_open(ii)-1)]; + end + work = [work, tline(p_close(end)+1:end)]; + + + nm_str = ['(',num2str(n),',',num2str(m),')']; + work = erase(work, nm_str); + + % Remove = signs as well + work = erase(work, '='); + + % Now read line + format = ''; + for ii=1:nfield + format = [format, '%s%f64']; + end + work = textscan(work, format); + + for ii=1:nfield + field{ii} = work{2*ii-1}{1}; + value{ii} = work{2*ii}; + end + + + + + end % of function extract_4_values + + + function [n, m] = get_nm_from_field(obj, field); + % Read (n,m) from field Rbc(n,m), Rwc(n,m) or Vnc(n,m) + + s = extractBefore(field, ')'); + s = extractAfter( s, '('); + + n_str = extractBefore(s, ','); + m_str = extractAfter(s, ','); + + n = str2num(char(n_str)); + m = str2num(char(m_str)); + end + + + function write_4_values(obj, fid, field1, field2, field3, field4) + + im = obj.physicslist.im; + in = obj.physicslist.in; + + for ii=1:length(im) + m = im(ii); + n = in(ii); + + form = [' ', field1, '(%i,%i) = %19.15E ', ... + field2, '(%i,%i) = %19.15E ', ... + field3, '(%i,%i) = %19.15E ', ... + field4, '(%i,%i) = %19.15E \n']; + + + value1 = obj.physicslist.(field1)(ii); + value2 = obj.physicslist.(field2)(ii); + value3 = obj.physicslist.(field3)(ii); + value4 = obj.physicslist.(field4)(ii); + + fprintf(fid, form, n, m, value1, ... + n, m, value2, ... + n, m, value3, ... + n, m, value4 ); + end % of for loop + end % of function write_4_values + + + function write_list(obj, fid, list, special_list) + if( isempty(obj.(list)) ) + return + end + fields = fieldnames(obj.(list)); + + % Beginning of list + % End of list - add a \ + fprintf(fid, '&%s \n', list); + for ii = 1:numel(fields) + f = fields(ii); + f = f{1}; + % deal with special_list outside this method + if any(strcmp(f,special_list)) + continue; + end + + % write line + value = obj.(list).(f); + l = length(value); + + fprintf(fid, ' %s = ', f); + for jj=1:l + c = class(value(jj)); + + % Few logical test to decide the printing format + if strcmp(c,'logical') % bool + if value(jj) + fprintf(fid, 'T '); + else + fprintf(fid, 'F '); + end + else % not a bool + if floor(value(jj))==value(jj) %Integer value + fprintf(fid, '%i ',value(jj)); + else % double + fprintf(fid, '%19.15E ',value(jj)); + end + end + end + fprintf(fid,'\n'); + end % of for loop + + end % of function write_list + end % of private methods +end % of SPEC_Namelist class diff --git a/Utilities/matlabtools/compare_spec_outputs.m b/Utilities/matlabtools/compare_spec_outputs.m index d4588b30..f52cbe1e 100644 --- a/Utilities/matlabtools/compare_spec_outputs.m +++ b/Utilities/matlabtools/compare_spec_outputs.m @@ -1,11 +1,11 @@ -function [Dabs, Drel, df] = compare_spec_outputs(fname1,fname2) +function [Dabs, Drel, df] = compare_spec_outputs(data1,data2) % Compares the interface geometry of two spec outputs % Two outputs are considered "the same" if df ~ 1e-15 (or less) % % INPUT -% - fname1 : path to the hdf5 output file #1 -% - fname2 : path to the hdf5 output file #2 +% - data1: data obtained via read_spec( fname1 ) +% - data2: data obtained via read_spec( fname2 ) % % OUTPUT % - Dabs : absolute maximum distance @@ -23,13 +23,13 @@ % Rmn2 = h5read(fname2,'/Rbc'); % Zmn2 = h5read(fname2,'/Zbs'); -data = read_spec(fname1); -Rmn1 = data.output.Rbc; -Zmn1 = data.output.Zbs; +%data = read_spec(fname1); +Rmn1 = data1.output.Rbc; +Zmn1 = data1.output.Zbs; -data = read_spec(fname2); -Rmn2 = data.output.Rbc; -Zmn2 = data.output.Zbs; +%data = read_spec(fname2); +Rmn2 = data2.output.Rbc; +Zmn2 = data2.output.Zbs; maxR = max(max(abs(Rmn1-Rmn2))); diff --git a/Utilities/matlabtools/contra2cov.m b/Utilities/matlabtools/contra2cov.m index 930c7098..63bbac77 100644 --- a/Utilities/matlabtools/contra2cov.m +++ b/Utilities/matlabtools/contra2cov.m @@ -1,15 +1,17 @@ -function vcov = contra2cov(fdata, vol, vcontrav, s, theta, phi, norm) +function vcov = contra2cov(data, vol, vcontrav, s, theta, phi, norm) +% +% CONTRA2COV( DATA, VOL, VCONTRAV, S, THETA, PHI, NORM ) +% ====================================================== % % Transform a contravariant vector to a covariant one in any geometry % % INPUT % ----- -% fdata: via fdata_from_data(data) +% data: via read_spec(filename) % vol: volume +% vcontrav: structure containing contravariant components as a function of r, size = 3xlength(r) % s: radial coordinate -% vcontrav: contravariant vector as a function of r, size = 3xlength(r) -% ns: number of point in each volume for interpolation % theta: theta angle % phi: phi angle % norm: use the unitary (canonical) basis (=1) or the general @@ -20,12 +22,12 @@ % vcov: covariant vector as a function v % Read geometry -G = fdata.Igeometry; +G = data.input.physics.Igeometry; % Get R derivatives -[s, R] = get_spec_R_derivatives(fdata, vol, s, theta, phi, 'R'); -[s, Z] = get_spec_R_derivatives(fdata, vol, s, theta, phi, 'Z'); +[s, R] = get_spec_R_derivatives(data, vol, s, theta, phi, 'R'); +[s, Z] = get_spec_R_derivatives(data, vol, s, theta, phi, 'Z'); nt = length(theta); @@ -33,7 +35,7 @@ ns = length(s); % transform in covariant basis -g = get_spec_metric(fdata, vol, s, theta, phi); +g = get_spec_metric(data, vol, s, theta, phi); switch G case 1 diff --git a/Utilities/matlabtools/get_full_field.m b/Utilities/matlabtools/get_full_field.m index 693ee4e8..0fbb0138 100644 --- a/Utilities/matlabtools/get_full_field.m +++ b/Utilities/matlabtools/get_full_field.m @@ -1,5 +1,9 @@ function B = get_full_field(data, r, theta, zeta, nr) +% +% GET_FULL_FIELD( DATA, R, THETA, ZETA, NR ) +% ========================================== +% % Return SPEC magnetic field solution componants as a function of r, theta, % zeta. The coordinate r is constructed from the radial position of the % volume interface for a given pair (theta, zeta) and from the coordinate @@ -20,10 +24,10 @@ % % Written by A.Baillod(2019) + % Load data -fdata = fdata_from_data(data); -G = fdata.Igeometry; -Nvol = fdata.Nvol; +G = data.input.physics.Igeometry; +Nvol = data.output.Mvol; epsilon = 1E-16; @@ -40,6 +44,7 @@ B = zeros(3,length(r),nt,nz); for i=1:Nvol + % if first volume, don't take rmin=0 if i==1 rmin = epsilon; else @@ -54,7 +59,7 @@ r_vol = r_vol(2:end); if i==1 - if fdata.Igeometry == 1 + if G == 1 sarr = 2.0 * (r_vol - rmin) ./ (rmax - rmin) - 1; else sarr = 2.0 * ((r_vol - rmin) ./ (rmax - rmin)).^2 - 1; @@ -62,14 +67,14 @@ else sarr = 2.0 * (r_vol - rmin) ./ (rmax - rmin) - 1; end - Bcontrav = get_spec_magfield(fdata, i, sarr, theta, zeta); + Bcontrav = get_spec_magfield(data, i, sarr, theta, zeta); % Generate radial coordinate array iimax = iimax + length(r_vol); r_temp(iimin:iimax) = r_vol; % And convert it to covariant basis (normalized here) - B_cov = contra2cov(fdata, i, Bcontrav, sarr, theta, zeta, 1); + B_cov = contra2cov(data, i, Bcontrav, sarr, theta, zeta, 1); B_temp(1, iimin:iimax, :, :) = B_cov{1}; B_temp(2, iimin:iimax, :, :) = B_cov{2}; diff --git a/Utilities/matlabtools/get_spec_Bgrid.m b/Utilities/matlabtools/get_spec_Bgrid.m index f198b44d..3a23c259 100644 --- a/Utilities/matlabtools/get_spec_Bgrid.m +++ b/Utilities/matlabtools/get_spec_Bgrid.m @@ -1,26 +1,32 @@ function bdata = get_spec_Bgrid(data,nz0,lvol) +% +% GET_SPEC_BGRID( DATA, NZ0, LVOL ) +% ================================= +% % Obtains the canonical cylindrical components of B, namely (B^R, R*B^phi, B^Z), on the coordinate grid points % % INPUT -% -data : must be produced by calling read_spec_grid(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -nz0 : toroidal plane number at which B is obtained (nz0=1 at toroidal angle phi=0) % -lvol : volume number in which B is obtained % % OUTPUT +% ------ % -bdata : cell of size 5 containing the values of R, Z, B^R, R*B^phi, B^Z on the grid points % % written by J.Loizu (2018) -Lrad = data.Lrad; -Nt = data.Nt; -Nz = data.Nz; +Lrad = data.input.physics.Lrad; +Nt = data.grid.Nt; +Nz = data.grid.Nz; -Rij = data.Rij; -Zij = data.Zij; -BR = data.BR; -Bp = data.Bp; -BZ = data.BZ; +Rij = data.grid.Rij; +Zij = data.grid.Zij; +BR = data.grid.BR; +Bp = data.grid.Bp; +BZ = data.grid.BZ; iz = nz0-1; ngrid = Lrad(lvol)+1; diff --git a/Utilities/matlabtools/get_spec_R_derivatives.m b/Utilities/matlabtools/get_spec_R_derivatives.m index d0d3c2e5..24c75857 100644 --- a/Utilities/matlabtools/get_spec_R_derivatives.m +++ b/Utilities/matlabtools/get_spec_R_derivatives.m @@ -1,43 +1,47 @@ function [sarr, out] = get_spec_R_derivatives(data, vol, sarr, tarr, zarr, RorZ) + +% +% GET_SPEC_R_DERIVATIVES( DATA, VOL, SARR, TARR, ZARR, RORZ ) +% =========================================================== % % Returns the derivatives of R corresponding to SPEC coordinate % system. Stellarator symmetry assumed. % % INPUT % ----- -% data: fdata produced via fdata_from_data -% vol: Volume number -% sarr: s-coordinate array, shape (ns, 1) -% tarr: Theta angle array -% zarr: Phi angle array -% RorZ: Returns either R derivatives (='R') or Z derivatives (='Z') +% data: data produced via read_spec(filename) +% vol: Volume number +% sarr: s-coordinate array, shape (ns, 1) +% tarr: Theta angle array +% zarr: Phi angle array +% RorZ: Returns either R derivatives (='R') or Z derivatives (='Z') % % OUTPUT % ------ -% sarr: s-coordinate array -% R: 4xlength(sarr) array containing R, dR / ds, -% dR / dtheta and dR / dphi +% sarr: s-coordinate array +% R: 4xlength(sarr) array containing R, dR / ds, +% dR / dtheta and dR / dphi % % Written by A.Baillod (2019) % % Load geometry -mn = data.mn; -im = double(data.im); -in = double(data.in); -Rmn = data.Rbc(:,vol ); -Rmn_p = data.Rbc(:,vol+1); -Zmn = data.Zbs(:,vol ); -Zmn_p = data.Zbs(:,vol+1); +mn = data.output.mn; +im = double(data.output.im); +in = double(data.output.in); +Rmn = data.output.Rbc(:,vol ); +Rmn_p = data.output.Rbc(:,vol+1); +Zmn = data.output.Zbs(:,vol ); +Zmn_p = data.output.Zbs(:,vol+1); % Allocate data for R and its derivative in s, theta and phi (4), for each % and for ns points ns = length(sarr); nt = length(tarr); nz = length(zarr); -Rarr = cell(2); -Zarr = cell(2); +Rarr = cell(1,4); +Zarr = cell(1,4); for ii=1:4 Rarr{ii} = zeros(ns, nt, nz); diff --git a/Utilities/matlabtools/get_spec_area.m b/Utilities/matlabtools/get_spec_area.m index 504b7bc6..7a0e4772 100644 --- a/Utilities/matlabtools/get_spec_area.m +++ b/Utilities/matlabtools/get_spec_area.m @@ -1,21 +1,27 @@ function Avol = get_spec_area(data,lvol,ns,nt,phi0) - +% +% GET_SPEC_AREA( DATA, LVOL, NS, NT, PHI0 ) +% ========================================= +% % Calculates cross-sectional area of a given volume at fixed phi % % INPUT -% -data : must be produced by calling e.g. read_spec_grid(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume number % -ns : is the resolution in the s-coordinate (e.g. 64) % -nt : is the resolution in the theta-coordinate (e.g. 64) % -phi0 : toroidal angle defining a toroidal plane % % OUTPUT +% ------ % -Avol : area in m^2 if geometrical dimensions (R,Z) are interpreted in meters. % % Note: Stellarator symmetry is assumed % % written by J.Loizu (2018) +% smin = -0.999; %avoids singular inversion of the metric matrix diff --git a/Utilities/matlabtools/get_spec_beta.m b/Utilities/matlabtools/get_spec_beta.m index eaef0c86..255d9114 100644 --- a/Utilities/matlabtools/get_spec_beta.m +++ b/Utilities/matlabtools/get_spec_beta.m @@ -1,24 +1,30 @@ function [beta_ax, beta_av] = get_spec_beta(data, vols) - + +% +% GET_SPEC_BETA( DATA, VOLS ) +% =========================== +% % Calculates beta of the equilibrium, both the average beta=2*

/B(0)^2 % and the axis beta=2*p(0)/B(0)^2, and returns the latter % % INPUT +% ----- % -data : Produced via read_spec('filename.sp.h5'); % -vols : volumes on which beta is averaged % % OUTPUT -% -beta : value of beta on axis +% ------ +% -beta_ax : value of beta on axis +% -beta_av : value of beta on average % % written by J.Loizu (2016) % modified by J.Loizu (05.2017) % modified by A.Baillod (06.2019) % % A.Baillod: update for new hdf5 format (04.2020) +% % Read some data -gdata = gdata_from_data(data); -fdata = fdata_from_data(data); pscale = data.input.physics.pscale; press = pscale * data.input.physics.pressure; @@ -43,12 +49,11 @@ end % Compute total volume - volume = volume + get_spec_volume(gdata,volume_number,64,64,64); + volume = volume + get_spec_volume(data,volume_number,64,64,64); % And integral 2*p/B^2 - modB = get_spec_modB(fdata,volume_number,sarr,tarr,zarr); - %modB = get_spec_modB(fdata,1,-0.99,tarr,zarr); - jacobian = get_spec_jacobian(gdata, volume_number, sarr, tarr, zarr); + modB = get_spec_modB(data,volume_number,sarr,tarr,zarr); + jacobian = get_spec_jacobian(data, volume_number, sarr, tarr, zarr); arg = jacobian ./ (modB.^2); av_beta(lvol) = 2*press(volume_number)*trapz(zarr, trapz(tarr, trapz(sarr, arg, 1), 2), 3); @@ -56,17 +61,13 @@ beta_av = sum(av_beta) / volume; ind = find(vols==1); -if length(ind)==0 volume_number = vols(lvol); +if length(ind)==0 volume_number = 1; - volume = get_spec_volume(gdata,volume_number,64,64,64); - %modB = get_spec_modB(fdata,1,-0.99,tarr,zarr); - modB = get_spec_modB(fdata,volume_number,sarr,tarr,zarr); - jacobian = get_spec_jacobian(gdata, volume_number, sarr, tarr, zarr); + volume = get_spec_volume(data,volume_number,64,64,64); + modB = get_spec_modB(data,volume_number,sarr,tarr,zarr); + jacobian = get_spec_jacobian(data, volume_number, sarr, tarr, zarr); arg = jacobian ./ (modB.^2); - av_beta(lvol) = press(volume_number)*trapz(zarr, trapz(tarr, trapz(sarr, arg, 1), 2), 3) / volume; beta_ax = av_beta(1); else beta_ax = av_beta(ind); end - - diff --git a/Utilities/matlabtools/get_spec_energy_slab.m b/Utilities/matlabtools/get_spec_energy_slab.m index 4afe10b3..222efe14 100644 --- a/Utilities/matlabtools/get_spec_energy_slab.m +++ b/Utilities/matlabtools/get_spec_energy_slab.m @@ -1,23 +1,28 @@ function W = get_spec_energy_slab(data,lv,ns,nt,nz) - +% +% GET_SPEC_ENERGY_SLAB( DATA, LV, NS, NT, NZ ) +% ============================================ +% % Calculates Plasma Magnetic Energy in volume lv in slab geometry % % INPUT -% -data : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lv : volume in which to calculate the energy (total energy for lvol=0) % -ns : is the s-coordinate resolution % -nt : is the theta-coordinate resolution % -nz : is the zeta-coordinate resolution % % OUTPUT +% ------ % -W : total energy % % Note: Stellarator symmetry is assumed % % written by J.Loizu (2018) -Nvol = data.Nvol; +Nvol = data.input.physics.Nvol; W = 0; diff --git a/Utilities/matlabtools/get_spec_helicity_slab.m b/Utilities/matlabtools/get_spec_helicity_slab.m index 2593adfc..737aa935 100644 --- a/Utilities/matlabtools/get_spec_helicity_slab.m +++ b/Utilities/matlabtools/get_spec_helicity_slab.m @@ -1,16 +1,21 @@ -function H = get_spec_helicity_slab(fdata,lvol,ns,nt,nz) - +function H = get_spec_helicity_slab(data,lvol,ns,nt,nz) +% +% GET_SPEC_HELICITY_SLAB( DATA, LVOL, NS, NT, NZ ) +% ================================================ +% % Calculates Magnetic Helicity in a given volume in slab geometry % % INPUT -% -data : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume in which the helicity is evaluated % -ns : is the s-coordinate resolution % -nt : is the theta-coordinate resolution % -nz : is the zeta-coordinate resolution % % OUTPUT +% ------ % -H : Magnetic Helicity in volume lvol % % Note: Stellarator symmetry is assumed @@ -18,8 +23,8 @@ % % written by J.Loizu (2018) -Ate = fdata.Ate{lvol}; -Aze = fdata.Aze{lvol}; +Ate = data.vector_potential.Ate{lvol}; +Aze = data.vector_potential.Aze{lvol}; sarr = linspace(-1,1,ns); tarr = linspace(0,2*pi,nt); @@ -27,53 +32,49 @@ sarr = transpose(sarr); sbar = (sarr+1)/2; -Lrad = fdata.Lrad(lvol); -mn = fdata.mn; -im = double(fdata.im); -in = double(fdata.in); +Lrad = data.input.physics.Lrad(lvol); +mn = data.output.mn; +im = double(data.output.im); +in = double(data.output.in); h1 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 1 h2 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 2 h3 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 3 h4 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 4 -T = cell(Lrad+1,2); % allocate data for Chebyshev polynomials and their derivatives -fac = cell(mn,2); % allocate data for regularization factors and their derivatives - -T{1}{1} = ones(ns,1); -T{1}{2} = zeros(ns,1); - -T{2}{1} = sarr; -T{2}{2} = ones(ns,1); - % Construct Chebyshev polynomials and their derivatives -for l=3:Lrad+1 - T{l}{1} = 2*sarr.*T{l-1}{1} - T{l-2}{1}; - T{l}{2} = 2*T{l-1}{1} + 2*sarr.*T{l-1}{2} - T{l-2}{2}; -end - +T = get_spec_polynomial_basis(data, lvol, sarr); % Construct regularization factors and their derivatives -for j=1:mn - fac{j}{1} = ones(ns,1); - fac{j}{2} = zeros(ns,1); -end - +fac = get_spec_regularization_factor(data,lvol,sarr,'F'); % Construct magnetic helicity integrand +Lsingularity = false; +if (lvol==1) && (data.input.physics.Igeometry~=1) + Lsingularity = true; +end + for l=1:Lrad+1 for j=1:mn + if Lsingularity + basis = T{l}{1}(im(j)+1); + dbasis = T{l}{2}(im(j)+1); + else + basis = T{l}{1}; + dbasis = T{l}{2}; + end + for it=1:nt for iz=1:nz cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); - h1(:,it,iz) = h1(:,it,iz) + fac{j}{1}.*T{l}{1}.*Ate(l,j)*cosa; %A_t - h2(:,it,iz) = h2(:,it,iz) - (fac{j}{1}.*T{l}{2}+fac{j}{2}.*T{l}{1}).*Aze(l,j)*cosa; % -dA_z/ds - h3(:,it,iz) = h3(:,it,iz) + fac{j}{1}.*T{l}{1}.*Aze(l,j)*cosa; %A_z - h4(:,it,iz) = h4(:,it,iz) + (fac{j}{1}.*T{l}{2}+fac{j}{2}.*T{l}{1}).*Ate(l,j)*cosa; % +dA_t/ds + h1(:,it,iz) = h1(:,it,iz) + fac{j}{1}.* basis.*Ate(l,j)*cosa; %A_t + h2(:,it,iz) = h2(:,it,iz) - (fac{j}{1}.*dbasis+fac{j}{2}.* basis).*Aze(l,j)*cosa; % -dA_z/ds + h3(:,it,iz) = h3(:,it,iz) + fac{j}{1}.* basis.*Aze(l,j)*cosa; %A_z + h4(:,it,iz) = h4(:,it,iz) + (fac{j}{1}.*dbasis+fac{j}{2}.* basis).*Ate(l,j)*cosa; % +dA_t/ds end end end diff --git a/Utilities/matlabtools/get_spec_jacobian.m b/Utilities/matlabtools/get_spec_jacobian.m index 0ab9d56e..ea11664d 100644 --- a/Utilities/matlabtools/get_spec_jacobian.m +++ b/Utilities/matlabtools/get_spec_jacobian.m @@ -1,16 +1,21 @@ function jacobian = get_spec_jacobian(data,lvol,sarr,tarr,zarr) - +% +% GET_SPEC_JACOBIAN( DATA, LVOL, SARR, TARR, ZARR ) +% ================================================= +% % Calculates the coordinate Jacobian in volume number lvol % % INPUT -% -data : must be produced by calling gdata_from_data +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -jacobian : Jacobian of the coordinates with size ns*nt*nz where ns=length(sarr),nt=length(zarr),nt=length(zarr) % % Note: Stellarator symmetry is assumed @@ -20,7 +25,7 @@ [sarr, Rarr] = get_spec_R_derivatives(data, lvol, sarr, tarr, zarr, 'R'); -switch data.Igeometry +switch data.input.physics.Igeometry case 1 jacobian = Rarr{2}; case 2 diff --git a/Utilities/matlabtools/get_spec_length.m b/Utilities/matlabtools/get_spec_length.m index 751f6282..d223732b 100644 --- a/Utilities/matlabtools/get_spec_length.m +++ b/Utilities/matlabtools/get_spec_length.m @@ -1,15 +1,20 @@ function Lvol = get_spec_area(data,lvol,nt,phi0) - +% +% GET_SPEC_AREA( DATA, LVOL, NT, PHI0 ) +% ===================================== +% % Calculates length of a curve defined by a volume boundary at fixed phi % % INPUT -% -data : must be produced by calling e.g. read_spec_grid(filename) +% ----- +% -data : must be produced by calling e.g. read_spec(filename) % -lvol : volume number % -nt : is the resolution in the theta-coordinate (e.g. 64) % -phi0 : toroidal angle defining a toroidal plane % % OUTPUT +% ------ % -Lvol : length in meters if geometrical dimensions (R,Z) are interpreted in meters. % % Note: Stellarator symmetry is assumed diff --git a/Utilities/matlabtools/get_spec_magfield.m b/Utilities/matlabtools/get_spec_magfield.m index 87849cdb..91e4cce2 100644 --- a/Utilities/matlabtools/get_spec_magfield.m +++ b/Utilities/matlabtools/get_spec_magfield.m @@ -1,16 +1,21 @@ -function Bcontrav = get_spec_magfield(fdata,lvol,sarr,tarr,zarr) - +function Bcontrav = get_spec_magfield(data,lvol,sarr,tarr,zarr) +% +% GET_SPEC_MAGFIELD( DATA, LVOL, SARR, TARR, ZARR ) +% ================================================= +% % Computes contravariant components of B in volume lvol % % INPUT -% -fdata : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : is the volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -Bcontrav : cell structure with 3 arrays: B^s, B^theta, B^zeta each with size length(sarr)*length(tarr)*length(zarr) % % Note: Stellarator symmetry is only assumed in the Jacobian evaluation @@ -18,55 +23,60 @@ % written by J.Loizu (2016) -jac = get_spec_jacobian(fdata,lvol,sarr,tarr,zarr); % get jacobian of the coordinates (stell sym) +jac = get_spec_jacobian(data,lvol,sarr,tarr,zarr); % get jacobian of the coordinates (stell sym) -Ate = fdata.Ate{lvol}; -Aze = fdata.Aze{lvol}; -Ato = fdata.Ato{lvol}; -Azo = fdata.Azo{lvol}; +Ate = data.vector_potential.Ate{lvol}; +Aze = data.vector_potential.Aze{lvol}; +Ato = data.vector_potential.Ato{lvol}; +Azo = data.vector_potential.Azo{lvol}; -Lrad = fdata.Lrad(lvol); +Lrad = data.input.physics.Lrad(lvol); ns = length(sarr); nt = length(tarr); nz = length(zarr); -mn = fdata.mn; -im = double(fdata.im); -in = double(fdata.in); +mn = data.output.mn; +im = double(data.output.im); +in = double(data.output.in); Bs = zeros(ns,nt,nz); % allocate data for magnetic field along s Bt = zeros(ns,nt,nz); % allocate data for magnetic field along theta Bz = zeros(ns,nt,nz); % allocate data for magnetic field along zeta -T = cell(Lrad+1,2); % allocate data for Chebyshev polynomials and their derivatives +% Construct Chebyshev polynomials and their derivatives -T{1}{1} = ones(ns,1); -T{1}{2} = zeros(ns,1); +T = get_spec_polynomial_basis(data, lvol, sarr'); -T{2}{1} = transpose(sarr); -T{2}{2} = ones(ns,1); +% Construct regularization factors and their derivatives +%fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); +% Construct magnetic field contravariant components -% Construct Chebyshev polynomials and their derivatives -for l=3:Lrad+1 - T{l}{1} = 2*transpose(sarr).*T{l-1}{1} - T{l-2}{1}; - T{l}{2} = 2*T{l-1}{1} + 2*transpose(sarr).*T{l-1}{2} - T{l-2}{2}; +Lsingularity = false; +if (lvol==1) && (data.input.physics.Igeometry~=1) + Lsingularity = true; end -% Construct regularization factors and their derivatives -fac = get_spec_regularisation_factor(fdata, lvol, sarr, 'F'); - -% Construct magnetic field contravariant components for l=1:Lrad+1 for j=1:mn + if Lsingularity + basis = T{l}{1}(im(j)+1,:); + dbasis = T{l}{2}(im(j)+1,:); + basis = basis'; + dbasis = dbasis'; + else + basis = T{l}{1}; + dbasis = T{l}{2}; + end + for it=1:nt for iz=1:nz cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); - Bs(:,it,iz) = Bs(:,it,iz) + fac{j}{1}.*T{l}{1}.*( (im(j)*Azo(l,j) + in(j)*Ato(l,j))*cosa - (im(j)*Aze(l,j) + in(j)*Ate(l,j))*sina ); - Bt(:,it,iz) = Bt(:,it,iz) - (fac{j}{1}.*T{l}{2}+fac{j}{2}.*T{l}{1}).*( Aze(l,j)*cosa + Azo(l,j)*sina ); - Bz(:,it,iz) = Bz(:,it,iz) + (fac{j}{1}.*T{l}{2}+fac{j}{2}.*T{l}{1}).*( Ate(l,j)*cosa + Ato(l,j)*sina ); + Bs(:,it,iz) = Bs(:,it,iz) + basis .* ( (im(j)*Azo(l,j) + in(j)*Ato(l,j))*cosa - (im(j)*Aze(l,j) + in(j)*Ate(l,j))*sina ); + Bt(:,it,iz) = Bt(:,it,iz) - dbasis .* ( Aze(l,j)*cosa + Azo(l,j)*sina ); + Bz(:,it,iz) = Bz(:,it,iz) + dbasis .* ( Ate(l,j)*cosa + Ato(l,j)*sina ); end end end diff --git a/Utilities/matlabtools/get_spec_metric.m b/Utilities/matlabtools/get_spec_metric.m index cfa10af6..09022d54 100644 --- a/Utilities/matlabtools/get_spec_metric.m +++ b/Utilities/matlabtools/get_spec_metric.m @@ -1,16 +1,21 @@ function gmat = get_spec_metric(data,lvol,sarr,tarr,zarr) - +% +% GET_SPEC_METRIC( DATA, LVOL, SARR, TARR, ZARR ) +% =============================================== +% % Calculates covariant metric elements of the coordinates in volume number lvol % % INPUT -% -data : must be produced by calling e.g. read_spec_grid(filename) +% ----- +% -data : must be produced by calling e.g. read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -gmat : 3x3 matrix of metric coefficients % % Note: Stellarator symmetry is assumed @@ -31,15 +36,14 @@ end end - -% Construct regularization (for lvol=1) factors and their derivatives +% Get R and Z and their derivatives [out, Rarr] = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'R'); [out, Zarr] = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'Z'); % Construct metric elements -switch data.Igeometry +switch data.input.physics.Igeometry case 1 gmat{1}{1} = Rarr{2}.^2; gmat{2}{2} = 1 + Rarr{3}.^2; diff --git a/Utilities/matlabtools/get_spec_metric_contrav.m b/Utilities/matlabtools/get_spec_metric_contrav.m index 9c542756..8ca27c04 100644 --- a/Utilities/matlabtools/get_spec_metric_contrav.m +++ b/Utilities/matlabtools/get_spec_metric_contrav.m @@ -1,14 +1,27 @@ -function gmatcon = get_spec_metric_contrav(gdata,lvol,sarr,tarr,zarr) - +function gmatcon = get_spec_metric_contrav(data,lvol,sarr,tarr,zarr) +% GET_SPEC_METRIC_CONTRAV( DATA, LVOL, SARR, TARR, ZARR ) +% ======================================================= +% % Calculates contravariant metric elements in volume number lvol -% Note: Stellarator symmetry is assumed -% -gdata must be produced by calling e.g. read_spec_grid(filename) +% +% INPUT +% ----- +% -data must be produced by calling e.g. read_spec(filename) % -lvol volume number % -sarr is the array of values for the s-coordinate % -tarr is the array of values for the theta-coordinate % -zarr is the array of values for the zeta-coordinate -% written by J.Loizu (2017) +% +% OUTPUT +% ------ +% gmatcon{i}{j}(s,theta,zeta) +% +% Note: Stellarator symmetry is assumed +% +% written by J.Loizu (2017) + + % Auxiliary variables @@ -18,7 +31,7 @@ % First get the covariant metric matrix -gmatcov = get_spec_metric(gdata,lvol,sarr,tarr,zarr); +gmatcov = get_spec_metric(data,lvol,sarr,tarr,zarr); % Allocate space for contravariant metric matrix diff --git a/Utilities/matlabtools/get_spec_modB.m b/Utilities/matlabtools/get_spec_modB.m index bc3098a6..c773366a 100644 --- a/Utilities/matlabtools/get_spec_modB.m +++ b/Utilities/matlabtools/get_spec_modB.m @@ -1,16 +1,21 @@ -function modB = get_spec_modB(fdata,lvol,sarr,tarr,zarr) - +function modB = get_spec_modB(data,lvol,sarr,tarr,zarr) +% +% GET_SPEC_MODB( DATA, LVOL, SARR, TARR, ZARR ) +% ============================================= +% % Calculates mod(B) in volume lvol % % INPUT -% -fdata : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -modB : array of |B| with size ns*nt*nz where ns=size(sarr), nt=size(tarr), nz=size(zarr) % % Note: Stellarator symmetry is assumed @@ -26,8 +31,8 @@ % Calculate the magnetic field contravariant components -bvec = get_spec_magfield(fdata,lvol,sarr,tarr,zarr); -gmat = get_spec_metric(fdata,lvol,sarr,tarr,zarr); +bvec = get_spec_magfield(data,lvol,sarr,tarr,zarr); +gmat = get_spec_metric(data,lvol,sarr,tarr,zarr); % Calculate modB = sqrt(Bcontrav*gmat*Bcontrav) diff --git a/Utilities/matlabtools/get_spec_polflux.m b/Utilities/matlabtools/get_spec_polflux.m index efa07ad2..690051a3 100644 --- a/Utilities/matlabtools/get_spec_polflux.m +++ b/Utilities/matlabtools/get_spec_polflux.m @@ -1,17 +1,24 @@ -function psipol = get_spec_polflux(fdata,lvol,theta,start,send,ns,nz) +function psipol = get_spec_polflux(data,lvol,theta,start,send,ns,nz) +% +% GET_SPEC_POLFLUX( DATA, LVOL, THETA, START, SEND, NS, NZ ) +% ========================================================== +% % Computes total enclosed poloidal flux in the surface defined by theta % inside the volume number lvol and across the radial extension defined by start and send % % INPUT -% -fdata : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume number % -theta : poloidal angle at which the flux is calculated % -start : first point in the radial direction (e.g. start=-1) % -send : last point in the radial direction (e.g. send=+1) % -ns : radial resolution (e.g. 64) % -nz : toroidal resolution (e.g. 64) +% % OUPUT +% ----- % -psipol : total enclosed poloidal flux % % written by J.Loizu (2016) @@ -26,8 +33,8 @@ dz = zarr(2)-zarr(1); -Bcontrav = get_spec_magfield(fdata,lvol,sarr,theta,zarr); -jac = squeeze(get_spec_jacobian(fdata,lvol,sarr,theta,zarr)); +Bcontrav = get_spec_magfield(data,lvol,sarr,theta,zarr); +jac = squeeze(get_spec_jacobian(data,lvol,sarr,theta,zarr)); diff --git a/Utilities/matlabtools/get_spec_polynomial_basis.m b/Utilities/matlabtools/get_spec_polynomial_basis.m new file mode 100644 index 00000000..9137f406 --- /dev/null +++ b/Utilities/matlabtools/get_spec_polynomial_basis.m @@ -0,0 +1,119 @@ +function T = get_spec_polynomial_basis(data,lvol,sarr) + +% +% GET_SPEC_POLYNOMIAL_BASIS( DATA, LVOL, SARR ) +% ============================================= +% +% Return the Chebychev or the Zernike polynomial basis +% +% INPUT +% ----- +% data: generated via read_spec_filename +% lvol: volume number +% sarr: radial coordinate, shape (ns, 1) +% +% OUTPUT +% ------ +% T{i}{j}: Polynom of order i (j=1) and its derivative (j=2) +% +% +% Written by A. Baillod (2020) +% + +Lrad = double(data.input.physics.Lrad(lvol)); +ns = length(sarr); +Mpol = data.input.physics.Mpol; + +Lzernike = false; +if ((lvol==1) && (data.input.physics.Igeometry~=1)) + if data.version<3.0 + Lzernike = false; + else + Lzernike = true; + end +end + + +T = cell(Lrad+1,2); % allocate data for Chebyshev polynomials and their derivatives + +T{1}{1} = ones(ns,1); +T{1}{2} = zeros(ns,1); + +T{2}{1} = sarr; +T{2}{2} = ones(ns,1); + + +if( Lzernike ) % Build zernike polynomials +% Copy pasted from Frotran source, translated to Matlab language +% Tested on the 16.09.2020 (A. Baillod) against SPEC source. perfect match + zernike = zeros(Lrad+1,Mpol+1,2,length(sarr)); + rm = ones(size(sarr)); + rm1 = zeros(size(sarr)); + + sbar = (1 + sarr ) / 2.0; + ns = length(sbar); + + for m = 0:Mpol + if (Lrad >= m) + zernike(m+1,m+1,1,:) = rm; + zernike(m+1,m+1,2,:) = double(m)*rm1; + end + + if (Lrad >= m+2) + zernike(m+3,m+1,1,:) = double(m+2) *rm.*sbar.^2 - double(m+1) *rm; + zernike(m+3,m+1,2,:) = double((m+2)^2) *rm.*sbar - double((m+1)*m)*rm1; + end + + for n = m+4:2:Lrad + factor1 = double(n) / double(n^2 - m^2); + factor2 = double(4 * (n-1)); + factor3 = double((n-2+m)^2)/double(n-2) + double((n-m)^2)/double(n); + factor4 = double((n-2)^2-m^2) / double(n-2); + + zernike(n+1, m+1, 1, :) = factor1 * ((factor2*sbar.^2 - factor3) .* reshape(zernike(n-1, m+1, 1, :), [ns,1]) - factor4 * reshape(zernike(n-3, m+1, 1, :), [ns, 1])); + zernike(n+1, m+1, 2, :) = factor1 * (2.0*factor2*sbar .* reshape(zernike(n-1, m+1, 1, :), [ns,1]) + (factor2*sbar.^2 - factor3) .* reshape(zernike(n-1, m+1, 2, :), [ns,1]) - factor4 * reshape(zernike(n-3, m+1, 2, :), [ns,1])); + end + + rm1 = rm; + rm = rm .* sbar; + end + + for n = 2:2:Lrad + zernike(n+1,1,1,:) = zernike(n+1,1,1, :) - (-1)^(n/2); + end + + if (Mpol >= 1) + for n = 3:2:Lrad + zernike(n+1,2,1,:) = reshape(zernike(n+1,2,1,:), [ns,1]) - (-1)^((n-1)/2) * double((n+1)/2) * sbar; + zernike(n+1,2,2,:) = reshape(zernike(n+1,2,2,:), [ns,1]) - (-1)^((n-1)/2) * double((n+1)/2); + end + end + + for m = 0:Mpol + for n = m:2:Lrad + zernike(n+1,m+1,:,:) = zernike(n+1,m+1,:,:) / double(n+1); + end + end + + % Store in T{}{} structure + for ll = 1:Lrad+1 + T{ll}{1} = reshape(zernike(ll,:,1,:) , Mpol+1, length(sarr)); + T{ll}{2} = reshape(zernike(ll,:,2,:) / 2.0, Mpol+1, length(sarr)); + end + +else % Otherwise construct Chebychev basis + + for l=3:Lrad+1 + T{l}{1} = 2*sarr.*T{l-1}{1} - T{l-2}{1}; + T{l}{2} = 2*T{l-1}{1} + 2*sarr.*T{l-1}{2} - T{l-2}{2}; + end + + for l = 1:Lrad + T{l+1}{1} = T{l+1}{1} - (-1)^l; + end + + for l = 0:Lrad + T{l+1}{1} = T{l+1}{1} / double(l+1); % scale for better conditioning + T{l+1}{2} = T{l+1}{2} / double(l+1); % scale for better conditioning + end +end diff --git a/Utilities/matlabtools/get_spec_radius.m b/Utilities/matlabtools/get_spec_radius.m index e25e41c8..09db55be 100644 --- a/Utilities/matlabtools/get_spec_radius.m +++ b/Utilities/matlabtools/get_spec_radius.m @@ -1,4 +1,9 @@ function [r_out, z_out] = get_spec_radius(data, theta, zeta, vol) + +% +% GET_SPEC_RADIUS( DATA, THETA, ZETA, VOL ) +% ========================================= +% % Return the radial position of a KAM surface for a given theta, zeta and % Nvol % @@ -20,8 +25,8 @@ im = data.output.im; in = data.output.in; Rmn = data.output.Rbc; -Zmn = data.output.Zbs; -G = data.input.physics.Igeometry; +Zmn = data.output.Zbs; +G = data.input.physics.Igeometry; switch G @@ -48,4 +53,4 @@ z_out = z_out + Zmn(k, vol+1) * sin(double(im(k)) * theta - double(in(k)) * zeta); end -end \ No newline at end of file +end diff --git a/Utilities/matlabtools/get_spec_regularisation_factor.m b/Utilities/matlabtools/get_spec_regularisation_factor.m index ff673936..425b8c0e 100644 --- a/Utilities/matlabtools/get_spec_regularisation_factor.m +++ b/Utilities/matlabtools/get_spec_regularisation_factor.m @@ -1,11 +1,14 @@ function fac = get_spec_regularisation_factor(data, lvol, sarr, ForG) + % +% GET_SPEC_REGULARIZATION_FACTOR( DATA, LVOL, SARR, FORG ) +% ======================================================== % % Computes the regularisation factor in the correct geometry % % INPUT % ----- -% data: Produced by fdata_from_data(data); +% data: Produced by read_spec(filename); % lvol: Volume number % sarr: s-coordinate array, shape (ns, 1) % ForG: 'F' for field reg. factor, 'G' for geometry reg. factor @@ -17,17 +20,16 @@ % % Written by A.Baillod (2019) % -% sarr = transpose(sarr); -Igeometry= data.Igeometry; -mn = data.mn; -im = double(data.im); -ns = length(sarr); -fac = cell(mn,2); -sbar = (1+sarr)/2.0; -Mregular= double(data.Mregular); +Igeometry = data.input.physics.Igeometry; +mn = data.output.mn; +im = double(data.output.im); +ns = length(sarr); +fac = cell(mn,2); +sbar = (1+sarr)/2.0; +Mregular = double(data.input.numerics.Mregular); regumm = im / 2.0; @@ -36,9 +38,6 @@ regumm(ind) = Mregular / 2.0; end -halfmm = im / 2.0; - - if ForG=='G' switch Igeometry @@ -50,15 +49,14 @@ end case 2 % Cylindrical geometry - %TODO: add glab if Lextrap is not set to 1! for j=1:mn if(lvol==1) if im(j)==0 - fac{j}{1} = sqrt(sbar); - fac{j}{2} = 0.25 * fac{j}{1} ./ sbar; + fac{j}{1} = sbar; + fac{j}{2} = 0.5*ones(ns,1); else - fac{j}{1} = sbar.^halfmm(j); - fac{j}{2} = 0.5 * halfmm(j) * fac{j}{1} ./ sbar; + fac{j}{1} = sbar.^(im(j)+1); + fac{j}{2} = 0.5 * (im(j)+1) * fac{j}{1} ./ sbar; end else fac{j}{1} = sbar; @@ -71,11 +69,11 @@ for j=1:mn if lvol==1 %coordinate singularity if im(j)==0 - fac{j}{1} = sbar; - fac{j}{2} = 0.5; + fac{j}{1} = sbar.^2; + fac{j}{2} = sbar; else - fac{j}{1} = sbar.^halfmm(j); - fac{j}{2} = 0.5 * halfmm(j) * fac{j}{1} ./ sbar; + fac{j}{1} = sbar.^im(j); + fac{j}{2} = 0.5 * im(j) * fac{j}{1} ./ sbar; end else fac{j}{1} = sbar; @@ -89,49 +87,11 @@ elseif ForG=='F' - switch Igeometry - case 1 - for j=1:mn - fac{j}{1} = ones(ns,1); - fac{j}{2} = zeros(ns,1); - end - - case 2 - for j=1:mn - if lvol==1 % coordinate singularity - if im(j)==0 - fac{j}{1} = 1; - fac{j}{2} = 0; - else - fac{j}{1} = sbar.^regumm(j); - fac{j}{2} = 0.5 * regumm(j) * fac{j}{1} ./ sbar; - end - else - fac{j}{1} = 1; - fac{j}{2} = 0; - end - end - - case 3 - for j=1:mn - if lvol==1 % coordinate singularity - if im(j)==0 - fac{j}{1} = 1; - fac{j}{2} = 0; - else - fac{j}{1} = sbar.^regumm(j); - fac{j}{2} = 0.5 * regumm(j) * fac{j}{1} ./ sbar; - end - else - fac{j}{1} = 1; - fac{j}{2} = 0; - end - end - - otherwise - error('Unsupported geometry in get_spec_regularisation_factor') + for j=1:mn + fac{j}{1} = ones(ns,1); + fac{j}{2} = zeros(ns,1); end - + else error('Unsupported ForG value in get_spec_regularisation_factor.') -end \ No newline at end of file +end diff --git a/Utilities/matlabtools/get_spec_rtarr.m b/Utilities/matlabtools/get_spec_rtarr.m index d75965d4..1217a08a 100644 --- a/Utilities/matlabtools/get_spec_rtarr.m +++ b/Utilities/matlabtools/get_spec_rtarr.m @@ -1,16 +1,21 @@ function rtdata = get_spec_rtarr(data,lvol,sarr,tarr,zarr0) - +% +% GET_SPEC_RTARR( DATA, LVOL, SARR, TARR, ZARR0 ) +% =============================================== +% % Transforms (s,theta) array into (R,theta) array in volume number lvol in slab or cylindrical geometry % % INPUT -% -data : must be produced by calling e.g. read_spec_grid(filename) +% ----- +% -data : must be produced by calling e.g. read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -rtdata : array with (R,theta,dRds) data array with size 3*ns*nt where ns=length(sarr),nt=length(tarr) % % Note: Stellarator symmetry is assumed @@ -19,51 +24,25 @@ % updated by J.Loizu (2020) -Rac = data.Rbc(:,lvol); % inner volume boundary harmonics -Rbc = data.Rbc(:,lvol+1); % outer volume boundary harmonics - +Rac = data.output.Rbc(:,lvol); % inner volume boundary harmonics +Rbc = data.output.Rbc(:,lvol+1); % outer volume boundary harmonics -sarr = transpose(sarr); ns = length(sarr); nt = length(tarr); -sbar = (sarr+1)/2; -mn = data.mn; -im = double(data.im); -in = double(data.in); +mn = data.output.mn; +im = double(data.output.im); +in = double(data.output.in); Rarr = zeros(ns,nt); % allocate data for R-array Tarr = zeros(ns,nt); % allocate data for theta-array dRarr = zeros(ns,nt); % allocate data for R-array derivative (in s) -fac = cell(mn,2); % allocate data for regularization factors % Construct regularization factors -switch data.Igeometry - case 1 - for j=1:mn - fac{j}{1} = sbar; - fac{j}{2} = 0.5; - end - case 2 - for j=1:mn - if lvol==1 - if im(j)==0 - fac{j}{1} = sqrt(sbar); - fac{j}{2} = 0.25./sqrt(sbar); - else - fac{j}{1} = sbar.*(im(j) / 2); - fac{j}{2} = (im(j)/4)*sbar.^(im(j)/2-1); - end - else - fac{j}{1} = sbar; - fac{j}{2} = 0.5; - end - end -end - +fac = get_spec_regularisation_factor(data, lvol, sarr, 'G'); % Construct (R,theta) coordinates array diff --git a/Utilities/matlabtools/get_spec_rzarr.m b/Utilities/matlabtools/get_spec_rzarr.m index a10bf036..65dc9b8e 100644 --- a/Utilities/matlabtools/get_spec_rzarr.m +++ b/Utilities/matlabtools/get_spec_rzarr.m @@ -1,16 +1,21 @@ function rzdata = get_spec_rzarr(data,lvol,sarr,tarr,zarr) - +% +% GET_SPEC_RZARR( DATA, LVOL, SARR, TARR, ZARR ) +% ============================================== +% % Transforms (s,theta,zeta) array into (R,Z) array in volume number lvol % % INPUT -% -data : must be produced by calling e.g. read_spec_grid(filename) +% ----- +% -data : must be produced by calling e.g. read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -rzdata : array with (R,Z) data array with size 2*ns*nt*nz where ns=length(sarr),nt=length(zarr),nt=length(zarr) % % Note: Stellarator symmetry is assumed @@ -18,10 +23,10 @@ % written by J.Loizu (2016) -Rac = data.Rbc(:,lvol); % inner volume boundary harmonics -Zas = data.Zbs(:,lvol); -Rbc = data.Rbc(:,lvol+1); % outer volume boundary harmonics -Zbs = data.Zbs(:,lvol+1); +Rac = data.output.Rbc(:,lvol); % inner volume boundary harmonics +Zas = data.output.Zbs(:,lvol); +Rbc = data.output.Rbc(:,lvol+1); % outer volume boundary harmonics +Zbs = data.output.Zbs(:,lvol+1); sarr = transpose(sarr); ns = length(sarr); @@ -29,16 +34,13 @@ nz = length(zarr); sbar = (sarr+1)/2; -mn = data.mn; -im = double(data.im); -in = double(data.in); +mn = data.output.mn; +im = double(data.output.im); +in = double(data.output.in); Rarr = zeros(ns,nt,nz); % allocate data for R-array Zarr = zeros(ns,nt,nz); % allocate data for Z-array -fac = cell(mn,1); % allocate data for regularization factors - - % Construct REG FACTOR diff --git a/Utilities/matlabtools/get_spec_surface_current.m b/Utilities/matlabtools/get_spec_surface_current.m index 7e5e5b0e..f7ebf12e 100644 --- a/Utilities/matlabtools/get_spec_surface_current.m +++ b/Utilities/matlabtools/get_spec_surface_current.m @@ -1,5 +1,11 @@ function [tflux, IPDt] = get_spec_surface_current(data, ns, nt, zeta) +% +% GET_SPEC_SURFACE_CURRENT( DATA, NS, NT, ZETA ) +% ============================================== +% +% OUTDATED - should directly do 2*pi*[[B_\theta]] +% % Returns the sheet current flowing through each interface, normalized by % mu_0. This routine computes the actual integral of the poloidal field to % compute the current via Ampere's law. This requires to specify zeta; @@ -27,8 +33,7 @@ epsilon = 1E-5; % Data loading -fdata = fdata_from_data(data); % Read data -Nvol = fdata.Mvol; % Total number of volumes +Nvol = data.output.Mvol; % Total number of volumes sarr = linspace(-1, 1, ns); % Allocate memory @@ -46,9 +51,9 @@ sarr(1)=-1; end - temp = get_spec_magfield(fdata, ivol, sarr, theta, zeta); + temp = get_spec_magfield(data, ivol, sarr, theta, zeta); - Bcov{ivol} = contra2cov(fdata, ivol, temp, sarr, theta, zeta, 0); + Bcov{ivol} = contra2cov(data, ivol, temp, sarr, theta, zeta, 0); end for ivol=1:Nvol-1 @@ -56,6 +61,6 @@ IPDt(ivol) = trapz(theta, dBtheta); end -tflux = fdata.tflux; +tflux = data.output.tflux; end diff --git a/Utilities/matlabtools/get_spec_torcurr_kam_net.m b/Utilities/matlabtools/get_spec_torcurr_kam_net.m index fff5e9e3..36e68f7c 100644 --- a/Utilities/matlabtools/get_spec_torcurr_kam_net.m +++ b/Utilities/matlabtools/get_spec_torcurr_kam_net.m @@ -1,12 +1,18 @@ -function Itor = get_spec_torcurr_kam_net(filename,ntheta) +function Itor = get_spec_torcurr_kam_net(data, ntheta) +% +% GET_SPEC_TORCURR_KAM_NET( DATA, NTHETA ) +% ======================================== +% % Calculates the net toroidal surface-current on each interface % % INPUT -% - filename : name of hdf5 file +% ----- +% - data : obtained via read_spec(filename) % - ntheta : poloidal resolution for the loop integral % % OUTPUT +% ------ % - Itor : array of size Nvol-1 with values of net-surface-current on each interface (units are mu0*I) % % Note: Stellarator symmetry assumed in some of the routines used. @@ -14,10 +20,7 @@ % written by J.Loizu (2017) -fdata = read_spec_field(filename); -gdata = read_spec_grid(filename); - -Nvol = fdata.Nvol; +Nvol = data.input.physics.Nvol; Itor = zeros(1,Nvol-1); zarr = 0; @@ -33,8 +36,8 @@ for i=1:2 - Bcontrav = get_spec_magfield(fdata,lvol(i),sarr(i),tarr,zarr); - gmat = get_spec_metric(gdata,lvol(i),sarr(i),tarr,zarr); + Bcontrav = get_spec_magfield(data,lvol(i),sarr(i),tarr,zarr); + gmat = get_spec_metric( data,lvol(i),sarr(i),tarr,zarr); Bs = Bcontrav{1}; Bt = Bcontrav{2}; diff --git a/Utilities/matlabtools/get_spec_torflux.m b/Utilities/matlabtools/get_spec_torflux.m index a416307c..141ef64d 100644 --- a/Utilities/matlabtools/get_spec_torflux.m +++ b/Utilities/matlabtools/get_spec_torflux.m @@ -1,10 +1,15 @@ -function psitor = get_spec_torflux(fdata,lvol,zeta,start,send,ns,nt) +function psitor = get_spec_torflux(data,lvol,zeta,start,send,ns,nt) +% +% GET_SPEC_TORFLUX( DATA, LVOL, ZETA, START, SEND, NS, NT ) +% ========================================================= +% % Computes total enclosed toroidal flux in the poloidal cross-section defined by zeta, % inside the volume number lvol and across the radial extension defined by start and send % % INPUT -% -fdata : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume number % -zeta : toroidal angle at which the flux is calculated % -start : first point in the radial direction (e.g. start=-1) @@ -13,6 +18,7 @@ % -nt : poloidal resolution (e.g. 64) % % OUPUT +% ----- % -psitor : total enclosed toroidal flux % % written by J.Loizu (2016) @@ -35,8 +41,8 @@ else -Bcontrav = get_spec_magfield(fdata,lvol,sarr,tarr,zeta); -jac = get_spec_jacobian(fdata,lvol,sarr,tarr,zeta); +Bcontrav = get_spec_magfield(data,lvol,sarr,tarr,zeta); +jac = get_spec_jacobian(data,lvol,sarr,tarr,zeta); % Compute surface integral diff --git a/Utilities/matlabtools/get_spec_vecpot.m b/Utilities/matlabtools/get_spec_vecpot.m index 559a5898..f97e9405 100644 --- a/Utilities/matlabtools/get_spec_vecpot.m +++ b/Utilities/matlabtools/get_spec_vecpot.m @@ -1,27 +1,32 @@ -function Acov = get_spec_vecpot(fdata,lvol,sarr,tarr,zarr) - +function Acov = get_spec_vecpot(data,lvol,sarr,tarr,zarr) +% +% GET_SPEC_VECPOT( DATA, LVOL, SARR, TARR, ZARR ) +% =============================================== +% % Computes covariant components of A in volume lvol % % INPUT -% -fdata : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : is the volume number % -sarr : is the array of values for the s-coordinate % -tarr : is the array of values for the theta-coordinate % -zarr : is the array of values for the zeta-coordinate % % OUTPUT +% ------ % -Acov : cell structure with 2 arrays: A_theta, A_zeta each with size length(sarr)*length(tarr)*length(zarr) % % written by J.Loizu (2018) -Ate = fdata.Ate{lvol}; -Aze = fdata.Aze{lvol}; -Ato = fdata.Ato{lvol}; -Azo = fdata.Azo{lvol}; +Ate = data.vector_potential.Ate{lvol}; +Aze = data.vector_potential.Aze{lvol}; +Ato = data.vector_potential.Ato{lvol}; +Azo = data.vector_potential.Azo{lvol}; -Lrad = fdata.Lrad(lvol); +Lrad = data.input.physics.Lrad(lvol); sarr = transpose(sarr); ns = length(sarr); @@ -29,52 +34,46 @@ nz = length(zarr); sbar = (sarr+1)/2; -mn = fdata.mn; -im = double(fdata.im); -in = double(fdata.in); +mn = data.output.mn; +im = double(data.output.im); +in = double(data.output.in); At = zeros(ns,nt,nz); % allocate data for vector potential along theta Az = zeros(ns,nt,nz); % allocate data for vector potential along zeta -T = cell(Lrad+1,1); % allocate data for Chebyshev polynomials -fac = cell(mn,1); % allocate data for regularization factors - -T{1} = ones(ns,1); - -T{2} = sarr; - - % Construct Chebyshev polynomials -for l=3:Lrad+1 - T{l} = 2*sarr.*T{l-1} - T{l-2}; -end - +T = get_spec_polynomial_basis(data, lvol, sarr); % Construct regularization factors -for j=1:mn - if(lvol>1 || im(j)==0) - fac{j} = ones(ns,1); - elseif(im(j)==2) - fac{j} = sbar; - else - fac{j} = sbar.^(im(j)/2); - end -end - +fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); % Construct vector potential covariant components +Lsingularity = false; +if (lvol==1) && (data.input.physics.Igeometry~=1) + Lsingularity = true; +end + + for l=1:Lrad+1 for j=1:mn + if( Lsingularity ) + basis = T{l}{1}(im(j)+1); + dbasis = T{l}{2}(im(j)+1); + else + basis = T{l}{1}; + dbasis = T{l}{2}; + end + for it=1:nt for iz=1:nz cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); - At(:,it,iz) = At(:,it,iz) + fac{j}.*T{l}.*( Ate(l,j)*cosa + Ato(l,j)*sina ); - Az(:,it,iz) = Az(:,it,iz) + fac{j}.*T{l}.*( Aze(l,j)*cosa + Azo(l,j)*sina ); + At(:,it,iz) = At(:,it,iz) + fac{j}{1}.* basis.*( Ate(l,j)*cosa + Ato(l,j)*sina ); + Az(:,it,iz) = Az(:,it,iz) + fac{j}{1}.* basis.*( Aze(l,j)*cosa + Azo(l,j)*sina ); end end end diff --git a/Utilities/matlabtools/get_spec_volume.m b/Utilities/matlabtools/get_spec_volume.m index b2cee728..72c281da 100644 --- a/Utilities/matlabtools/get_spec_volume.m +++ b/Utilities/matlabtools/get_spec_volume.m @@ -1,16 +1,21 @@ function volume = get_spec_volume(data,lvol,ns,nt,nz) - +% +% GET_SPEC_VOLUME( DATA, LVOL, NS, NT, NZ ) +% ========================================= +% % Calculates volume of a given volume lvol % % INPUT -% -data : must be produced by calling e.g. read_spec_grid(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -lvol : volume number % -ns : is the resolution in the s-coordinate (e.g. 64) % -nt : is the resolution in the theta-coordinate (e.g. 64) % -nz : is the resolution in the zeta-coordinate (e.g. 64) % % OUTPUT +% ------ % -volume : volume in m^3 if geometrical dimensions (R,Z) are interpreted in meters. % % Note: Stellarator symmetry is assumed diff --git a/Utilities/matlabtools/get_spec_volume_current.m b/Utilities/matlabtools/get_spec_volume_current.m index 46fc21c6..136d196f 100644 --- a/Utilities/matlabtools/get_spec_volume_current.m +++ b/Utilities/matlabtools/get_spec_volume_current.m @@ -1,5 +1,9 @@ function [psi_coord, I_vol] = get_spec_volume_current(data, cumul) +% +% GET_SPEC_VOLUME_CURRENT( DATA, CUMUL ) +% ====================================== +% % Returns the toroidal current flowing in each volume, normalized by mu_0 % % INPUT @@ -16,8 +20,7 @@ % Data loading -fdata = fdata_from_data(data); % Read data -Nvol = fdata.Nvol; % Total number of volumes +Nvol = data.input.physics.Nvol; % Total number of volumes % Data processing @@ -25,10 +28,10 @@ psi_coord = zeros(1, Nvol); % Allocate memory I_vol = zeros(1, Nvol); -mu = fdata.mu; -tflux = fdata.tflux; +mu = data.output.mu; +tflux = data.output.tflux; sumI = 0; -phiedge = fdata.phiedge; +phiedge = data.input.physics.phiedge; for ivol=1:Nvol @@ -49,4 +52,4 @@ sumI = I_vol(ivol); end -end \ No newline at end of file +end diff --git a/Utilities/matlabtools/plot_spec_Bfield.m b/Utilities/matlabtools/plot_spec_Bfield.m index 2602c4d1..4d97c366 100644 --- a/Utilities/matlabtools/plot_spec_Bfield.m +++ b/Utilities/matlabtools/plot_spec_Bfield.m @@ -1,4 +1,8 @@ function plot_spec_Bfield(data, component, theta, phi, nr, newfig) + +% +% PLOT_SPEC_BFIELD( DATA, COMPONENT, THETA, PHI, NR, NEWFIG ) +% =========================================================== % % Plot SPEC magnetic field solution % @@ -26,9 +30,7 @@ function plot_spec_Bfield(data, component, theta, phi, nr, newfig) hold off; end - fdata = fdata_from_data(data); - - [r_end, z_end] = get_spec_radius(data, theta, phi, fdata.Nvol); + [r_end, z_end] = get_spec_radius(data, theta, phi, data.output.Mvol); [r_start, z_start] = get_spec_radius(data, theta, phi, 0); a = sqrt((r_end-r_start)^2 + (z_end-z_start)^2); @@ -61,4 +63,4 @@ function plot_spec_Bfield(data, component, theta, phi, nr, newfig) set(xlab,'Interpreter','latex'); set(ylab,'Interpreter','latex'); -end \ No newline at end of file +end diff --git a/Utilities/matlabtools/plot_spec_Bgrid.m b/Utilities/matlabtools/plot_spec_Bgrid.m index 7eadbcc2..4f0a5f73 100644 --- a/Utilities/matlabtools/plot_spec_Bgrid.m +++ b/Utilities/matlabtools/plot_spec_Bgrid.m @@ -1,9 +1,14 @@ function plot_spec_Bgrid(data,nz0,plotstyle,newfig) +% +% PLOT_SPEC_BGRID( DATA, NZ0, PLOTSTYLE, NEWFIG ) +% =============================================== +% % Produces plot of BR, Bphi, BZ, on the coordinate grid points % % INPUT -% -data : must be produced by calling read_spec_grid(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -nz0 : toroidal plane number at which B is obtained (nz0=1 at toroidal angle phi=0) % -plotstyle : whether pcolor ('pcolor') or scatter ('scatter') is to be used % -newfig : opens(=1) or not(=0) a new figure @@ -11,24 +16,25 @@ function plot_spec_Bgrid(data,nz0,plotstyle,newfig) % Note: The B components are the cylindrical contravariant terms, that is why Bphi is multiplied by R in order to get B \dot unitvectorphi. % % written by J.Loizu (2018) - +% +% OUTDATED - NEED DEBUG if(newfig==1) figure end -nvol = data.Mvol; +nvol = data.output.Mvol; -Lrad = data.Lrad; -Nt = data.Nt; -Nz = data.Nz; -Nfp = data.Nfp; +Lrad = data.input.physics.Lrad; +Nt = data.grid.Nt; +Nz = data.grid.Nz; +Nfp = data.input.physics.Nfp; -Rij = data.Rij; -Zij = data.Zij; -BR = data.BR; -Bp = data.Bp; -BZ = data.BZ; +Rij = data.grid.Rij; +Zij = data.grid.Zij; +BR = data.grid.BR; +Bp = data.grid.Bp; +BZ = data.grid.BZ; iz = nz0-1; phi0 = double((2*pi/Nfp)*(iz/Nt)); diff --git a/Utilities/matlabtools/plot_spec_Ivolume.m b/Utilities/matlabtools/plot_spec_Ivolume.m index cfe5013e..eb0ed0f6 100644 --- a/Utilities/matlabtools/plot_spec_Ivolume.m +++ b/Utilities/matlabtools/plot_spec_Ivolume.m @@ -1,12 +1,14 @@ function plot_spec_Ivolume(data, cumul, newfig) -% plot_spec_Ivolume(filename, newfig) +% +% PLOT_SPEC_IVOLUME( DATA, CUMUL, NEWFIG ) +% ======================================== % % Plots volume current % % INPUT % ----- -% filename: SPEC output filename (.sp.h5) +% data: Obtained via read_spec(filename) % cumul: Cumulative (=1) or not cumulative (=0) quantity % newfig : Plots on an existing figure (=0), a new one (=1) or % overwrite an existing one (=2) @@ -14,38 +16,6 @@ function plot_spec_Ivolume(data, cumul, newfig) % Written by A. Baillod (2019) % -% % Constant definition -% mu0 = 4*pi*1E-7; -% -% % Data loading -% fdata = read_spec_field(filename); % Read data -% Nvol = fdata.Nvol; % Total number of volumes -% -% % Data processing -% -% % First, get the current in each volume -% psi_coord = zeros(1, Nvol); % Allocate memory -% I_vol = zeros(1, Nvol); -% -% mu = fdata.mu; -% tflux = fdata.tflux; -% sumI = 0; -% phiedge = fdata.phiedge; -% -% for ivol=1:Nvol -% -% if ivol==1 -% I_vol(ivol) = mu(ivol) / mu0 * tflux(ivol) * phiedge; -% else -% % Add previous current volumes (sumI) since we use a cumulative -% % representation -% I_vol(ivol) = mu(ivol) / mu0 * (tflux(ivol) - tflux(ivol-1)) * phiedge + sumI; -% end -% -% psi_coord(ivol) = tflux(ivol); -% -% sumI = I_vol(ivol); -% end [psi_coord, I_vol] = get_spec_volume_current(data, cumul); @@ -65,7 +35,7 @@ function plot_spec_Ivolume(data, cumul, newfig) %plot(psi_coord, I_vol, '*', 'DisplayName', '$I^{vol}_\phi$') bar(I_vol); %leg = legend('Location','northwest'); -ylab = ylabel('$I_\mathcal{V}$[A]'); +ylab = ylabel('$\mu_0I_\mathcal{V}$[A]'); %xlab = xlabel('$\psi_t / \psi_{edge}$'); xlab = xlabel('Volume label'); set(gca, 'FontSize', 14) diff --git a/Utilities/matlabtools/plot_spec_current_profile.m b/Utilities/matlabtools/plot_spec_current_profile.m new file mode 100644 index 00000000..88ded61b --- /dev/null +++ b/Utilities/matlabtools/plot_spec_current_profile.m @@ -0,0 +1,87 @@ +function plot_spec_current_profile( data, newfig ) +% +% PLOT_SPEC_CURRENT_PROFILE( DATA, NEWFIG ) +% ========================================= +% +% Plot the total enclosed toroidal current as a function of the minor +% radius for a given SPEC equilibrium. +% +% INPUTS +% ------ +% * data: SPEC output data obtained with read_spec(filename) +% * newfig: (0) plot on current figure +% (1) open a new figure +% (2) Erase current figure and use it +% +% Written by A. Baillod (2020) +% + + + switch newfig + case 0 + hold on + case 1 + figure('Position', [200 200 900 700]) + hold on + case 2 + hold off + end + + nsucctrj = length(data.poincare.R(:,1,1)); % number of successfully followed trajectories + sval = data.transform.fiota(1:nsucctrj,1); + nvol = data.input.physics.Nvol; + mvol = data.output.Mvol; + nptrj = zeros(1,mvol); + count = 1; + + ind = find(sval==-2); %Remove wrongly written data + sval(ind) = []; + + for is=1:length(sval)-1 + if(sval(is)>0 && sval(is+1)<0) %Reached the end of a volume + if(count==1) + nptrj(count) = is; + else + nptrj(count) = is-sum(nptrj); + end + count = count+1; + end + end + nptrj(mvol) = length(sval)-sum(nptrj); + + + ns = 32; + nt = 32; + cumflux = 0; + cumcur = 0; + kstart = 1; + psitor = zeros(1,length(sval)); + + Iphi = zeros(1, length(sval) ); + mu = data.output.mu; + + for lvol=1:mvol + + for k=kstart:kstart-1+nptrj(lvol) + tflux = get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); + psitor(k) = cumflux + tflux; + + Iphi(k) = cumcur + mu(lvol) * tflux; + end + cumflux = psitor(k); + kstart = kstart+nptrj(lvol); + %cumcur = Iphi(k); + + cumcur = Iphi(k) + data.output.IPDt(lvol); % add surface current + end + + phiedge=psitor(end); + + + plot( sqrt(psitor / phiedge), Iphi, 'LineWidth', 3 ) + xlabel('$(\Psi_t / \Psi_{edge})^{1/2}$', 'Interpreter', 'latex') + ylabel('$\mu_0I_\phi$[Tm]', 'Interpreter', 'latex') + set(gca, 'FontSize', 18) + hold on; + +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_grid.m b/Utilities/matlabtools/plot_spec_grid.m index 7ccee1cb..88ecac72 100644 --- a/Utilities/matlabtools/plot_spec_grid.m +++ b/Utilities/matlabtools/plot_spec_grid.m @@ -1,15 +1,20 @@ function plot_spec_grid(data,nz0,newfig) +% +% PLOT_SPEC_GRID( DATA, NZ0, NEWFIG ) +% =================================== +% % Produces plot of coordinate surfaces % % INPUT -% -data : must be produced by calling read_spec_grid(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -nz0 : toroidal plane number at which coordinates are shown (nz0=1 at toroidal angle phi=0) % -newfig : opens(=1) or not(=0) a new figure, or overwrite selected % figure (=2) % % written by J.Loizu (2015) - +% switch newfig case 0 diff --git a/Utilities/matlabtools/plot_spec_hessian.m b/Utilities/matlabtools/plot_spec_hessian.m index d354a59a..49b58995 100644 --- a/Utilities/matlabtools/plot_spec_hessian.m +++ b/Utilities/matlabtools/plot_spec_hessian.m @@ -1,15 +1,20 @@ function plot_spec_hessian(data) - +% +% PLOT_SPEC_HESSIAN( DATA ) +% ========================= +% % Plots the hessian matrix elements +% +% INPUT +% ----- % -data : must be produced by calling read_spec_hessian(filename) -% written by J.Loizu (2017) - -H = data.Hmatrix; +% +% written by J.Loizu (2017) figure -imagesc(H) +imagesc(data) colorbar diff --git a/Utilities/matlabtools/plot_spec_iota.m b/Utilities/matlabtools/plot_spec_iota.m index 0d22dadf..4c18e418 100644 --- a/Utilities/matlabtools/plot_spec_iota.m +++ b/Utilities/matlabtools/plot_spec_iota.m @@ -1,8 +1,13 @@ function out = plot_spec_iota(data,iorq,xaxis,newfig) +% +% PLOT_SPEC_IOTA( DATA, IORQ, XAXIS, NEWFIG ) +% =========================================== +% % Produces rotational transform plot from field-line-tracing data % % INPUT +% ----- % -data : produced by calling read_spec(fname) % -iorq : plot iota('i') or safety factor ('q') % -xaxis='s' : plots s-coordinnate as the x-axis @@ -12,6 +17,7 @@ % -newfig : opens(=1) or not(=0) a new figure, or overwrites(=2) current plot % % OUTPUT +% ------ % -out : structure with arrays of iota and the chosen xaxis array % % written by J.Loizu (2015) @@ -20,48 +26,45 @@ % modified by A.Baillod (01.2019) % modified by J.Loizu (01.2020) -pdata = pdata_from_data(data); -idata = idata_from_data(data); -fdata = fdata_from_data(data); - if(newfig==1) figure hold on; elseif newfig==0 hold on; -elseif newfig==2 +elseif newfig==2 % A.Baillod (06.2019) hold off; end if(iorq=='i') -F = idata.iota(1:end); +F = data.transform.fiota(1:end,2); Flabel='\iota'; elseif(iorq=='q') -F = 1./idata.iota(1:end); +F = 1./data.transform.fiota(1:end,2); Flabel='q'; end -nsucctrj = length(pdata.R_lines(:,1,1)); % number of successfully followed trajectories +nsucctrj = length(data.poincare.R(:,1,1)); % number of successfully followed trajectories switch xaxis case 's' - plot(idata.sarr(1:nsucctrj),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) + plot(data.transform.fiota(1:nsucctrj,1),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) ylabel(Flabel) out = cell(2); - out{1} = idata.sarr; + out{1} = data.transform.fiota(:,1); out{2} = F; case 'R' - plot(transpose(pdata.R_lines(:,1,1)),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) + plot(transpose(data.poincare.R(:,1,1)),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) ylabel(Flabel) out = cell(2); - out{1} = pdata.R_lines(:,1,1); + out{1} = data.poincare.R(:,1,1); out{2} = F(1:nsucctrj); case 'f' - sval = idata.sarr(1:nsucctrj); - nvol = idata.Mvol; - nptrj = zeros(1,nvol); + sval = data.transform.fiota(1:nsucctrj,1); + nvol = data.input.physics.Nvol; + mvol = data.output.Mvol; + nptrj = zeros(1,mvol); count = 1; ind = find(sval==-2); %Remove wrongly written data @@ -79,7 +82,7 @@ count = count+1; end end - nptrj(nvol) = length(sval)-sum(nptrj); + nptrj(mvol) = length(sval)-sum(nptrj); ns = 32; nt = 32; @@ -88,14 +91,14 @@ psitor = zeros(1,length(sval)); - for lvol=1:nvol + for lvol=1:mvol if lvol==nvol % Required if last value had a -2 (often in free bound) - phiedge = cumflux + get_spec_torflux(fdata, nvol, 0, -1, 1, ns, nt); + phiedge = cumflux + get_spec_torflux(data, nvol, 0, -1, 1, ns, nt); end for k=kstart:kstart-1+nptrj(lvol) - psitor(k) = cumflux + get_spec_torflux(fdata,lvol,0,-1,sval(k),ns,nt); + psitor(k) = cumflux + get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); end cumflux = psitor(k); kstart = kstart+nptrj(lvol); @@ -110,8 +113,9 @@ out{2} = F(1:nsucctrj); case 'r' - sval = idata.sarr(1:nsucctrj); - nvol = idata.Mvol; + sval = data.transform.fiota(1:nsucctrj,1); + nvol = data.input.physics.Nvol; + mvol = data.output.Mvol; nptrj = zeros(1,nvol); count = 1; @@ -130,7 +134,7 @@ count = count+1; end end - nptrj(nvol) = length(sval)-sum(nptrj); + nptrj(mvol) = length(sval)-sum(nptrj); ns = 32; nt = 32; @@ -138,19 +142,21 @@ kstart = 1; psitor = zeros(1,length(sval)); - for lvol=1:nvol + for lvol=1:mvol if lvol==nvol % Required if last value had a -2 (often in free bound) - phiedge = cumflux + get_spec_torflux(fdata, nvol, 0, -1, 1, ns, nt); + phiedge = cumflux + get_spec_torflux(data, nvol, 0, -1, 1, ns, nt); end for k=kstart:kstart-1+nptrj(lvol) - psitor(k) = cumflux + get_spec_torflux(fdata,lvol,0,-1,sval(k),ns,nt); + psitor(k) = cumflux + get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); end cumflux = psitor(k); kstart = kstart+nptrj(lvol); end - + +% phiedge = data.input.physics.phiedge; + plot(sqrt(psitor/phiedge),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) ylabel(Flabel) xlabel('(\Psi / \Psi_{edge})^{1/2}') diff --git a/Utilities/matlabtools/plot_spec_iotakam.m b/Utilities/matlabtools/plot_spec_iotakam.m index 1a7b7e44..52b78707 100644 --- a/Utilities/matlabtools/plot_spec_iotakam.m +++ b/Utilities/matlabtools/plot_spec_iotakam.m @@ -1,9 +1,13 @@ function plot_spec_iotakam(data,iorq,xaxis,newfig) - +% +% PLOT_SPEC_IOTAKAM( DATA, IORQ, XAXIS, NEWFIG ) +% ============================================== +% % Plots rotational transform on each side of each ideal interface % % INPUT +% ----- % -data : produced by calling read_spec(fname) % -iorq : plot iota('i') or safety factor ('q') % -xaxis='R' : plots R-position of interfaces (at phi=0) as the x-axis @@ -31,10 +35,14 @@ function plot_spec_iotakam(data,iorq,xaxis,newfig) R0(l) = sum(Rmn(:,l+1)); end -if(newfig==1) -figure +switch newfig +case 0 + hold on +case 1 + figure +case 2 + hold off end -hold on if(iorq=='i') F = iota(2:end); @@ -50,16 +58,19 @@ function plot_spec_iotakam(data,iorq,xaxis,newfig) switch xaxis case 'R' plot(R0,F,'r+','MarkerSize',6,'LineWidth',2) + hold on; plot(R0,G,'m+','MarkerSize',6,'LineWidth',2) xlabel('R') ylabel(Flabel) case 'f' plot(tflux(1:end-freeb),F,'r+','MarkerSize',6,'LineWidth',2) + hold on; plot(tflux(1:end-freeb),G,'m+','MarkerSize',6,'LineWidth',2) xlabel('\Psi / \Psi_{edge}') ylabel(Flabel) case 'r' plot(sqrt(tflux(1:end-freeb)),F,'r+','MarkerSize',6,'LineWidth',2) + hold on; plot(sqrt(tflux(1:end-freeb)),G,'m+','MarkerSize',6,'LineWidth',2) xlabel('(\Psi / \Psi_{edge})^{1/2}') ylabel(Flabel) diff --git a/Utilities/matlabtools/plot_spec_jacobian.m b/Utilities/matlabtools/plot_spec_jacobian.m index 48411688..82c84fe4 100644 --- a/Utilities/matlabtools/plot_spec_jacobian.m +++ b/Utilities/matlabtools/plot_spec_jacobian.m @@ -1,9 +1,14 @@ -function plot_spec_jacobian(data,lvol,sarr,tarr,zarr,newfig) +function rzbdata = plot_spec_jacobian(data,lvol,sarr,tarr,zarr,newfig) +% +% PLOT_SPEC_JACOBIAN( DATA, LVOL, SARR, TARR, ZARR, NEWFIG ) +% ========================================================== +% % Produces plot of sqrt(g) in (R,Z,zarr) cross-section(s) % % INPUT -% -fname : data obtained via read_spec(filename) +% ----- +% -data : data obtained via read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate ('d' for default) % -tarr : is the array of values for the theta-coordinate ('d' for default) @@ -12,6 +17,7 @@ function plot_spec_jacobian(data,lvol,sarr,tarr,zarr,newfig) % (=2) % % OUTPUT +% ------ % -rzbdata : cell structure with 3 arrays: R-data, Z-data, |B|-data % % written by J.Loizu (2016) @@ -30,19 +36,13 @@ function plot_spec_jacobian(data,lvol,sarr,tarr,zarr,newfig) rzbdata = cell(3); - -% Read vector potential - -fdata = fdata_from_data(data); -gdata = gdata_from_data(data); - % Compute sqrt(g) -jac = get_spec_jacobian(gdata,lvol,sarr,tarr,zarr); +jac = get_spec_jacobian(data,lvol,sarr,tarr,zarr); % Compute function (R,Z)(s,theta,zeta) -rzdata = get_spec_rzarr(fdata,lvol,sarr,tarr,zarr); +rzdata = get_spec_rzarr(data,lvol,sarr,tarr,zarr); R = rzdata{1}; Z = rzdata{2}; @@ -61,7 +61,7 @@ function plot_spec_jacobian(data,lvol,sarr,tarr,zarr,newfig) Rtemp = R; Ztemp = Z; -switch fdata.Igeometry +switch data.input.physics.Igeometry case 1 R = tarr; Z = Rtemp; diff --git a/Utilities/matlabtools/plot_spec_kam.m b/Utilities/matlabtools/plot_spec_kam.m index cdc2e6c1..8899b0c4 100644 --- a/Utilities/matlabtools/plot_spec_kam.m +++ b/Utilities/matlabtools/plot_spec_kam.m @@ -1,10 +1,15 @@ -function plot_spec_kam(data,zetaov2pi,newfig) +function plot_spec_kam(data, nz0, newfig) +% +% PLOT_SPEC_KAM( DATA, NZ0, NEWFIG ) +% ======================================== +% % Produces a "Poincare plot" of the KAM surfaces. % % INPUT +% ----- % -data : obtained from read_spec(fname) -% -zetaov2pi : shows the toroidal plane at zeta=2*pi*(zetaov2pi) +% -nz0 : show the toroidal plane number nz0 % -newfig : opens(=1) or not(=0) a new figure, or overplots(=2) on existing figure % % written by J.Loizu (2016) @@ -12,6 +17,10 @@ function plot_spec_kam(data,zetaov2pi,newfig) % modified by A. Baillod (06.2019) % modified by J.Loizu (01.2020) +Np = double(data.input.physics.Nfp); +%Nplan = double(size(data.poincare.R,2)); % # of toroidal planes +%zetaov2pi = (nz0-1) / (Np * Nplan); +zetaov2pi = 0; Nvol = double(data.input.physics.Nvol); mn = data.output.mn; diff --git a/Utilities/matlabtools/plot_spec_modB.m b/Utilities/matlabtools/plot_spec_modB.m index 07f46fbc..4034f956 100644 --- a/Utilities/matlabtools/plot_spec_modB.m +++ b/Utilities/matlabtools/plot_spec_modB.m @@ -1,8 +1,13 @@ function rzbdata = plot_spec_modB(data,lvol,sarr,tarr,zarr,newfig) +% +% PLOT_SPEC_MODB( DATA, LVOL, SARR, TARR, ZARR, NEWFIG ) +% ====================================================== +% % Produces plot of |B| in (R,Z,zarr) cross-section(s) % % INPUT +% ----- % -data : data obtained via read_spec(filename) % -lvol : volume number % -sarr : is the array of values for the s-coordinate ('d' for default) @@ -12,6 +17,7 @@ % (=2) % % OUTPUT +% ------ % -rzbdata : cell structure with 3 arrays: R-data, Z-data, |B|-data % % written by J.Loizu (2016) @@ -31,17 +37,13 @@ rzbdata = cell(3); -% Read vector potential - -fdata = fdata_from_data(data); - % Compute |B| -modB = get_spec_modB(fdata,lvol,sarr,tarr,zarr); +modB = get_spec_modB(data,lvol,sarr,tarr,zarr); % Compute function (R,Z)(s,theta,zeta) -rzdata = get_spec_rzarr(fdata,lvol,sarr,tarr,zarr); +rzdata = get_spec_rzarr(data,lvol,sarr,tarr,zarr); R = rzdata{1}; Z = rzdata{2}; @@ -60,7 +62,7 @@ Rtemp = R; Ztemp = Z; -switch fdata.Igeometry +switch data.input.physics.Igeometry case 1 R = tarr; Z = Rtemp; diff --git a/Utilities/matlabtools/plot_spec_modB_boundary.m b/Utilities/matlabtools/plot_spec_modB_boundary.m index c17c91ce..a92feb89 100644 --- a/Utilities/matlabtools/plot_spec_modB_boundary.m +++ b/Utilities/matlabtools/plot_spec_modB_boundary.m @@ -1,10 +1,15 @@ -function plot_spec_modB_boundary(data,Nvol,nt,nz) +function plot_spec_modB_boundary(data,vol,nt,nz) +% +% PLOT_SPEC_MODB_BOUNDARY( DATA, VOL, NT, NZ ) +% ============================================ +% % Produces plot of |B| on the full boundary surface in toroidal geometry. % % INPUT +% ----- % -data : data obtained via read_spec(filename) -% -Nvol : total number of volumes +% -vol : Volume on which modB should be plotted % -nt : poloidal resolution for the plotting (e.g. nt=64) % -nz : toroidal resolution for the plotting (e.g. nz=64) % @@ -18,19 +23,20 @@ function plot_spec_modB_boundary(data,Nvol,nt,nz) zarr = linspace(0,2*pi,nz); -% Read vector potential - -fdata = fdata_from_data(data); +Mvol = data.output.Mvol; +if(vol>Mvol) + error('vol not valid') +end % Compute |B| -modB = get_spec_modB(fdata,Nvol,sarr,tarr,zarr); +modB = get_spec_modB(data,vol,sarr,tarr,zarr); % Compute function (R,Z)(s,theta,zeta) -rzdata = get_spec_rzarr(fdata,Nvol,sarr,tarr,zarr); +rzdata = get_spec_rzarr(data,vol,sarr,tarr,zarr); R = squeeze(rzdata{1}); Z = squeeze(rzdata{2}); diff --git a/Utilities/matlabtools/plot_spec_outfluxfun.m b/Utilities/matlabtools/plot_spec_outfluxfun.m index f4bed2a8..c3e28d75 100644 --- a/Utilities/matlabtools/plot_spec_outfluxfun.m +++ b/Utilities/matlabtools/plot_spec_outfluxfun.m @@ -1,10 +1,14 @@ -function plot_spec_outfluxfun(fdata,ns,nt,z0,ncont,newfig) +function plot_spec_outfluxfun(data,ns,nt,z0,ncont,newfig) - +% +% PLOT_SPEC_OUTFLUXFUN( DATA, NS, NT, Z0, NCONT, NEWFIG ) +% ======================================================= +% % Plots iso-contours of Az on a given cross-section % % INPUT -% -fdata : must be produced by calling read_spec_field(filename) +% ----- +% -data : must be produced by calling read_spec(filename) % -ns : radial resolution for construction of Az % -nt : poloidal resolution for construction of Az % -z0 : toroidal angle at which Az is evaluated @@ -17,7 +21,7 @@ function plot_spec_outfluxfun(fdata,ns,nt,z0,ncont,newfig) % written by J.Loizu (2018) -Nvol = fdata.Nvol; +Nvol = data.input.physics.Nvol; lvol = Nvol+1; @@ -25,9 +29,8 @@ function plot_spec_outfluxfun(fdata,ns,nt,z0,ncont,newfig) tarr = linspace(0,2*pi,nt); -acov = get_spec_vecpot(fdata,lvol,sarr,tarr,z0); - -rz = get_spec_rzarr(fdata,lvol,sarr,tarr,z0); +acov = get_spec_vecpot(data,lvol,sarr,tarr,z0); +rz = get_spec_rzarr( data,lvol,sarr,tarr,z0); ffun = -acov{2}; diff --git a/Utilities/matlabtools/plot_spec_poincare.m b/Utilities/matlabtools/plot_spec_poincare.m index 59136239..776da199 100644 --- a/Utilities/matlabtools/plot_spec_poincare.m +++ b/Utilities/matlabtools/plot_spec_poincare.m @@ -1,8 +1,13 @@ -function plot_spec_poincare(data,nz0,nfp,arr,newfig) +function phi = plot_spec_poincare(data,nz0,arr,newfig) +% +% PLOT_SPEC_POINCARE( DATA, NZ0, NFP, ARR, NEWFIG ) +% ================================================= +% % Produces Poincare plots of the field lines on different sections (within one field period) % % INPUT +% ----- % -data : must be produced by calling read_spec(fname) % -nz0 : shows the nz0 toroidal plane or equidistant planes (nz0=-1) % -nfp : number of field periods @@ -14,17 +19,17 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) % modified by A.Baillod (2019) % modified by J.Loizu (2020) +nfp = data.input.physics.Nfp; + try rpol = data.input.physics.rpol; % get size of slab catch rpol = 1; end -pdata = pdata_from_data(data); % construct stucture with poincare data information - -nptraj = size(pdata.R_lines,1); % # of poincare trajectories (field lines) +nptraj = size(data.poincare.R,1); % # of poincare trajectories (field lines) -nz = size(pdata.R_lines,2); % # of toroidal planes +nz = size(data.poincare.R,2); % # of toroidal planes flag2col = 'F'; % flag for ploting field lines with alternating colour ('T') or not ('F') @@ -45,17 +50,17 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) disp(' '); -rmax = max(max(max(pdata.R_lines))); -rmin = min(min(min(pdata.R_lines))); -zmax = max(max(max(pdata.Z_lines))); -zmin = min(min(min(pdata.Z_lines))); +rmax = max(max(max(data.poincare.R))); +rmin = min(min(min(data.poincare.R))); +zmax = max(max(max(data.poincare.Z))); +zmin = min(min(min(data.poincare.Z))); -switch pdata.Igeometry +switch data.input.physics.Igeometry case 1 xmin = 0; xmax = 2*pi*rpol; ymin = -0.1; - ymax = pdata.Rbc(1,end)+0.1; + ymax = data.output.Rbc(1,end)+0.1; case 2 xmin = -1.1*rmax; xmax = 1.1*rmax; @@ -72,7 +77,7 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) nth = 5096; %ploting options for the boundary bcol = 'r'; bthick = 3; -if(pdata.Lfreebound==1) +if(data.input.physics.Lfreebound==1) bcol = 'k'; bthick = 1; end @@ -108,24 +113,24 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) subplot(npl,1,k) - switch pdata.Igeometry + switch data.input.physics.Igeometry case 1 - R = squeeze(pdata.R_lines(:,j,:)); - T = rpol*mod(squeeze(pdata.th_lines(:,j,:)),2*pi); + R = squeeze(data.poincare.R(:,j,:)); + T = rpol*mod(squeeze(data.poincare.t(:,j,:)),2*pi); for i=arr %for each field line trajectory scatter(T(i,:),R(i,:),10,'.k') hold on end case 2 - R = squeeze(pdata.R_lines(:,j,:)); - T = squeeze(pdata.th_lines(:,j,:)); + R = squeeze(data.poincare.R(:,j,:)); + T = squeeze(data.poincare.t(:,j,:)); for i=arr %for each field line trajectory scatter(R(i,:).*cos(T(i,:)),R(i,:).*sin(T(i,:)),10,'.k') hold on; end case 3 - R = squeeze(pdata.R_lines(:,j,:)); - Z = squeeze(pdata.Z_lines(:,j,:)); + R = squeeze(data.poincare.R(:,j,:)); + Z = squeeze(data.poincare.Z(:,j,:)); for i=arr %for each field line trajectory scatter(R(i,:),Z(i,:),10,'.k') hold on; @@ -136,39 +141,40 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) dth = 2*pi/nth; theta = dth:dth:2*pi; - zeta = (j-1)*(2*pi/nz)/nfp; + zeta = (j-1)*(2*pi/nz)/nfp + phi = NaN; - switch pdata.Igeometry + switch data.input.physics.Igeometry case 1 Xb = rpol*theta; Yb1 = 0; Yb2 = 0; - for imn=1:pdata.mn % get and plot the boundary - alpha = double(pdata.im(imn))*theta-double(pdata.in(imn))*zeta; - Yb1 = Yb1 + pdata.Rbc(imn,1)*cos(alpha) + pdata.Rbs(imn,1)*sin(alpha); - Yb2 = Yb2 + pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha); + for imn=1:data.output.mn % get and plot the boundary + alpha = double(data.output.im(imn))*theta-double(data.output.in(imn))*zeta; + Yb1 = Yb1 + data.output.Rbc(imn,1 )*cos(alpha) + data.output.Rbs(imn,1 )*sin(alpha); + Yb2 = Yb2 + data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha); end case 2 Rb = 0; Zb = 0; - for imn=1:pdata.mn % get and plot the boundary - alpha = double(pdata.im(imn))*theta-double(pdata.in(imn))*zeta; - Rb = Rb + (pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha)).*cos(theta); - Zb = Zb + (pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha)).*sin(theta); + for imn=1:data.output.mn % get and plot the boundary + alpha = double(data.output.im(imn))*theta-double(data.output.in(imn))*zeta; + Rb = Rb + (data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha)).*cos(theta); + Zb = Zb + (data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha)).*sin(theta); end case 3 Rb = 0; Zb = 0; - for imn=1:pdata.mn % get and plot the boundary % the pdata.in values go in steps of nfp - alpha = double(pdata.im(imn))*theta-double(pdata.in(imn))*zeta; - Rb = Rb + pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha); - Zb = Zb + pdata.Zbs(imn,end)*sin(alpha) + pdata.Zbc(imn,end)*cos(alpha); + for imn=1:data.output.mn % get and plot the boundary % the data.output.in values go in steps of nfp + alpha = double(data.output.im(imn))*theta-double(data.output.in(imn))*zeta; + Rb = Rb + data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha); + Zb = Zb + data.output.Zbs(imn,end)*sin(alpha) + data.output.Zbc(imn,end)*cos(alpha); end otherwise error('Unsupported geometry') end - if pdata.Igeometry ~= 1 + if data.input.physics.Igeometry ~= 1 scatter(Rb,Zb,bthick,'*',bcol) hold on set(gca,'FontSize',12) @@ -191,24 +197,24 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) otherwise %if nz0>0 - switch pdata.Igeometry + switch data.input.physics.Igeometry case 1 - R = squeeze(pdata.R_lines(:,nz0,:)); - T = rpol*mod(squeeze(pdata.th_lines(:,nz0,:)),2*pi); + R = squeeze(data.poincare.R(:,nz0,:)); + T = rpol*mod(squeeze(data.poincare.t(:,nz0,:)),2*pi); for i=arr %for each field line trajectory scatter(T(i,:),R(i,:),10,'.k') hold on end case 2 - R = squeeze(pdata.R_lines(:,nz0,:)); - T = squeeze(pdata.th_lines(:,nz0,:)); + R = squeeze(data.poincare.R(:,nz0,:)); + T = squeeze(data.poincare.t(:,nz0,:)); for i=arr %for each field line trajectory scatter(R(i,:).*cos(T(i,:)),R(i,:).*sin(T(i,:)),10,'.k') hold on; end case 3 - R = squeeze(pdata.R_lines(:,nz0,:)); - Z = squeeze(pdata.Z_lines(:,nz0,:)); + R = squeeze(data.poincare.R(:,nz0,:)); + Z = squeeze(data.poincare.Z(:,nz0,:)); for i=arr %for each field line trajectory scatter(R(i,:),Z(i,:),10,'.k') hold on; @@ -220,40 +226,41 @@ function plot_spec_poincare(data,nz0,nfp,arr,newfig) dth = 2*pi/nth; theta = dth:dth:2*pi; - zeta = (nz0-1.0)*(2.0*pi/nz)/double(nfp); + zeta = (nz0-1.0)*(2.0*pi/nz)/double(nfp) + phi = zeta; - switch pdata.Igeometry + switch data.input.physics.Igeometry case 1 Xb = rpol*theta; Yb1 = 0; Yb2 = 0; - for imn=1:pdata.mn % get and plot the boundary - alpha = double(pdata.im(imn))*theta-double(pdata.in(imn))*zeta; - Yb1 = Yb1 + pdata.Rbc(imn,1)*cos(alpha) + pdata.Rbs(imn,1)*sin(alpha); - Yb2 = Yb2 + pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha); + for imn=1:data.output.mn % get and plot the boundary + alpha = double(data.output.im(imn))*theta-double(data.output.in(imn))*zeta; + Yb1 = Yb1 + data.output.Rbc(imn,1)*cos(alpha) + data.output.Rbs(imn,1)*sin(alpha); + Yb2 = Yb2 + data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha); end case 2 Rb = 0; Zb = 0; - for imn=1:pdata.mn % get and plot the boundary - alpha = double(pdata.im(imn))*theta-double(pdata.in(imn))*zeta; - Rb = Rb + (pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha)).*cos(theta); - Zb = Zb + (pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha)).*sin(theta); + for imn=1:data.output.mn % get and plot the boundary + alpha = double(data.output.im(imn))*theta-double(data.output.in(imn))*zeta; + Rb = Rb + (data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha)).*cos(theta); + Zb = Zb + (data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha)).*sin(theta); end case 3 Rb = 0; Zb = 0; - for imn=1:pdata.mn % get and plot the boundary % the pdata.in values go in steps of nfp - alpha = double(pdata.im(imn))*theta-double(pdata.in(imn))*zeta; - Rb = Rb + pdata.Rbc(imn,end)*cos(alpha) + pdata.Rbs(imn,end)*sin(alpha); - Zb = Zb + pdata.Zbs(imn,end)*sin(alpha) + pdata.Zbc(imn,end)*cos(alpha); + for imn=1:data.output.mn % get and plot the boundary % the data.output.in values go in steps of nfp + alpha = double(data.output.im(imn))*theta-double(data.output.in(imn))*zeta; + Rb = Rb + data.output.Rbc(imn,end)*cos(alpha) + data.output.Rbs(imn,end)*sin(alpha); + Zb = Zb + data.output.Zbs(imn,end)*sin(alpha) + data.output.Zbc(imn,end)*cos(alpha); end otherwise error('Unsupported geometry') end - if pdata.Igeometry ~= 1 + if data.input.physics.Igeometry ~= 1 scatter(Rb,Zb,bthick,'*',bcol) hold on set(gca,'FontSize',12) diff --git a/Utilities/matlabtools/plot_spec_polflux.m b/Utilities/matlabtools/plot_spec_polflux.m index 0b330017..9b4f3824 100644 --- a/Utilities/matlabtools/plot_spec_polflux.m +++ b/Utilities/matlabtools/plot_spec_polflux.m @@ -1,7 +1,7 @@ function plot_spec_polflux(data, zeta, cumulative, newfig) % % -% PLOT_SPEC_POLFLUX( FILENAME, CUMULATIVE ) +% PLOT_SPEC_POLFLUX( FILENAME, ZETA, CUMULATIVE, NEWFIG ) % ----------------------------------------- % % Plots the poloidal flux from the output file filename, in a cumulative or @@ -24,18 +24,17 @@ function plot_spec_polflux(data, zeta, cumulative, newfig) % % -fdata = fdata_from_data(data); -Nvol = fdata.Nvol; +Nvol = data.input.physics.Nvol; polflux = zeros(1,Nvol); % Start at one only if slab geometry (otherwise it is zero by definition) -if fdata.Igeometry==1 - polflux(1) = get_spec_polflux(fdata,1,zeta,-1,1,64,64); +if data.input.physics.Igeometry==1 + polflux(1) = get_spec_polflux(data,1,zeta,-1,1,64,64); end for lvol=2:Nvol - tmp = get_spec_polflux(fdata,lvol,zeta,-1,1,64,64); + tmp = get_spec_polflux(data,lvol,zeta,-1,1,64,64); if cumulative polflux(lvol) = polflux(lvol-1) + tmp; @@ -65,4 +64,4 @@ function plot_spec_polflux(data, zeta, cumulative, newfig) xticks(1:1:Nvol) grid on; -end \ No newline at end of file +end diff --git a/Utilities/matlabtools/plot_spec_pressure.m b/Utilities/matlabtools/plot_spec_pressure.m index d9eb344f..94e40b75 100644 --- a/Utilities/matlabtools/plot_spec_pressure.m +++ b/Utilities/matlabtools/plot_spec_pressure.m @@ -1,9 +1,15 @@ -function plot_spec_pressure(data, newfig) +function plot_spec_pressure(data, norm, newfig) +% +% PLOT_SPEC_PRESSURE( DATA, NEWFIG ) +% ================================== +% % Plots stepped-pressure profile versus normalized toroidal flux used in SPEC % % INPUT +% ----- % -data : data obtained from read_spec(fname) +% -norm : (0) plot p, (1) plot p / p0 % -newfig : open a new figue (=1), plots on an existing one (=0) or overwrite last plot (=2) % % written by J.Loizu (2018) @@ -11,6 +17,12 @@ function plot_spec_pressure(data, newfig) pvol = data.input.physics.pressure * data.input.physics.pscale; + +if norm + pvol = pvol / pvol(1); +end + + pmax = max(pvol); pmin = min(pvol); @@ -66,12 +78,18 @@ function plot_spec_pressure(data, newfig) plot(x,y,'b') end -ylabel('p') -xlabel('\Psi / \Psi_{edge}') +if( norm ) + ylabel('$p / p_0$', 'Interpreter', 'latex') + ylabel('$p$', 'Interpreter', 'latex') +end +xlabel('$\Psi / \Psi_{edge}$', 'Interpreter', 'latex') if (pmin~=0 || pmax~=0) ylim([0.9*pmin, 1.1*pmax]); end +set(gcf, 'Color', 'w') +set(gcf,'Position',[200 200 900 700]) +set(gca,'FontSize',18) diff --git a/Utilities/matlabtools/plot_spec_surfcurent.m b/Utilities/matlabtools/plot_spec_surfcurent.m index 0336a79b..feb04142 100644 --- a/Utilities/matlabtools/plot_spec_surfcurent.m +++ b/Utilities/matlabtools/plot_spec_surfcurent.m @@ -1,5 +1,9 @@ function plot_spec_surfcurent(data, ns, nt, zeta, newfig) - + +% +% PLOT_SPEC_SURFCURRENT( DATA, NS, NT, ZETA, NEWFIG ) +% =================================================== +% % Plot pressure-driven currents located at each volume interface % % INPUT @@ -16,7 +20,7 @@ function plot_spec_surfcurent(data, ns, nt, zeta, newfig) [tflux, IPDt] = get_spec_surface_current(data, ns, nt, zeta); -Nvol = data.input.physics.Mvol; +Nvol = data.input.physics.Nvol + data.input.physics.Lfreebound; switch newfig case 0 diff --git a/Utilities/matlabtools/plot_spec_torflux.m b/Utilities/matlabtools/plot_spec_torflux.m index 009e62c6..bf15f342 100644 --- a/Utilities/matlabtools/plot_spec_torflux.m +++ b/Utilities/matlabtools/plot_spec_torflux.m @@ -1,11 +1,11 @@ function plot_spec_torflux(data, zeta, cumulative, newfig) + % -% -% PLOT_SPEC_TORFLUX( FILENAME, CUMULATIVE ) +% PLOT_SPEC_TORFLUX( DATA, ZETA, CUMULATIVE, NEWFIG ) % ----------------------------------------- % -% Plots the toroidal flux from the output file filename, in a cumulative or -% non-cumulative way. +% Integrates the magnetic field on a constant toroidal surface, +% in a cumulative or non-cumulative way. % % INPUTS % ------ @@ -22,17 +22,13 @@ function plot_spec_torflux(data, zeta, cumulative, newfig) % % Written by A. Baillod (2019) % -% - - -fdata = fdata_from_data(data); -Nvol = fdata.Nvol; +Nvol = data.input.physics.Nvol; torflux = zeros(1,Nvol); for lvol=1:Nvol - tmp = get_spec_torflux(fdata,lvol,zeta,-1,1,64,64); + tmp = get_spec_torflux(data,lvol,zeta,-1,1,64,64); if cumulative if lvol==1 @@ -66,4 +62,4 @@ function plot_spec_torflux(data, zeta, cumulative, newfig) xticks(1:1:Nvol) grid on; -end \ No newline at end of file +end diff --git a/Utilities/matlabtools/plot_spec_wall.m b/Utilities/matlabtools/plot_spec_wall.m index f7246041..6786af3b 100644 --- a/Utilities/matlabtools/plot_spec_wall.m +++ b/Utilities/matlabtools/plot_spec_wall.m @@ -1,8 +1,13 @@ function plot_spec_wall(data,zetaov2pi,newfig) +% +% PLOT_SPEC_WALL( DATA, ZETAOV2PI, NEWFIG ) +% ========================================= +% % Produces a "Poincare plot" of the computational boundary surface in toroidal geometry. % % INPUT +% ----- % -data : obtained from read_spec(fname) % -zetaov2pi : shows the toroidal plane at zeta=2*pi*(zetaov2pi) % -newfig : opens(=1) or not(=0) a new figure diff --git a/Utilities/matlabtools/produce_spec_movie.m b/Utilities/matlabtools/produce_spec_movie.m index 85f8283b..428edfd5 100644 --- a/Utilities/matlabtools/produce_spec_movie.m +++ b/Utilities/matlabtools/produce_spec_movie.m @@ -1,6 +1,14 @@ function produce_spec_movie(inputroot,seqstart,seqstep,seqend,framerate,nfp,nz0,zetaov2pi,xrange,yrange,labtext) + +% +% PRODUCE_SPEC_MOVIE( INPUTROOT, SEQSTART, SEQSTEP, SEQEND, FRAMERATE, NFP, NZ0, ZETAOV2PI, XRANGE, YRANGE, LABTEXT ) +% =================================================================================================================== +% % Produces Poincare movie from SPEC sequence of result files (Poincare data must exist) +% +% INPUT +% ----- % -inputroot : spec input file name of the form 'somename_seq', and the '.end/.h5' files must already exist. % -seqstart : sequence number to start the movie % -seqstep : step to be taken as sequence files are read and showed @@ -12,6 +20,8 @@ function produce_spec_movie(inputroot,seqstart,seqstep,seqend,framerate,nfp,nz0, % -xrange: minimum and maximum values for xaxis, i.e. [xmin xmax] % -yrange: minimum and maximum values for yaxis, i.e. [ymin ymax] % -labtext: text label to add on each snapshot ('b' for beta, 'I' for current, 'none' for nothing) +% +% % written by J.Loizu (2017) % modified by J.Loizu (2019) @@ -37,7 +47,7 @@ function produce_spec_movie(inputroot,seqstart,seqstep,seqend,framerate,nfp,nz0, spec_hdf5 = strcat(inputroot,num2str(it),'.h5'); - pdata = read_spec_poincare(spec_hdf5); + data = read_spec(spec_hdf5); if(labtext=='b') beta = get_spec_beta(spec_hdf5); @@ -49,7 +59,7 @@ function produce_spec_movie(inputroot,seqstart,seqstep,seqend,framerate,nfp,nz0, figtext = strcat('I_{\phi} = ', num2str(abs(round((Itor/mu0)/1000))),' kA'); end - plot_spec_poincare(pdata,nz0,nfp,0,1) + plot_spec_poincare(data,nz0,nfp,0,1) plot_spec_kam(spec_hdf5,zetaov2pi,0) diff --git a/Utilities/matlabtools/read_hdf5.m b/Utilities/matlabtools/read_hdf5.m index 9adb8ab6..7390b05f 100644 --- a/Utilities/matlabtools/read_hdf5.m +++ b/Utilities/matlabtools/read_hdf5.m @@ -1,5 +1,11 @@ function data = read_hdf5(filename) +% +% OUTDATED ? +% +% READ_HDF5( FILENAME ) +% ===================== +% % The READ_HDF5 function reads an HDF5 file and returns the contents of % that file as the fields of a structure. Groups are treated as elements % of their parent structure. If the file file cannot be opened a -1 is diff --git a/Utilities/matlabtools/read_spec.m b/Utilities/matlabtools/read_spec.m index 0137e065..e155d329 100644 --- a/Utilities/matlabtools/read_spec.m +++ b/Utilities/matlabtools/read_spec.m @@ -1,11 +1,17 @@ function data = read_spec(filename) - + +% +% READ_SPEC ( FILENAME ) +% ====================== +% % Reads the HDF5 output file produced by SPEC % % INPUT +% ----- % - filename : path to the HDF5 output file (e.g. 'testcase.h5') % % OUTPUT +% ------ % - data : contains all data from the SPEC run, which can be fed into several routines for analyzing and plotting % % written by J.Schilling (2019) diff --git a/Utilities/matlabtools/read_spec_hessian.m b/Utilities/matlabtools/read_spec_hessian.m index 96179953..7a7d805b 100644 --- a/Utilities/matlabtools/read_spec_hessian.m +++ b/Utilities/matlabtools/read_spec_hessian.m @@ -1,11 +1,17 @@ function Hmatrix = read_spec_hessian(filename) +% +% READ_SPEC_HESSIAN( FILENAME ) +% ============================= +% % Reads Hessian matrix using output from SPEC % % INPUT +% ----- % - filename : path to the hdf5 output file (e.g. 'testcase.sp.h5') % % OUTPUT +% ------ % - Hmatrix : Hessian matrix, which can be fed into several routines for analyzing and ploting % % written by J.Loizu (2017) diff --git a/Utilities/matlabtools/write_spec_input_L0.m b/Utilities/matlabtools/write_spec_input_L0.m index 6f90c477..bacc7797 100644 --- a/Utilities/matlabtools/write_spec_input_L0.m +++ b/Utilities/matlabtools/write_spec_input_L0.m @@ -1,8 +1,13 @@ function write_spec_input_L0(template,inputname,Nvol,phiedge,tfl,pfl,mu,pre,lrad,nptr) +% +% WRITE_SPEC_INPUT_L0( TEMPLATE, INPUTNAME, NVOL, PHIEDGE, TFL, PFL, MU, PRE, LRAD, NPTR ) +% ======================================================================================== +% % Writes spec input file from template with constraints corresponding to Lconstraint=0 (tfl,pfl,mu) % % INPUT +% ----- % -template : template input file name with .sp format % -inputname : new input file name with .sp format % -Nvol : number of volumes diff --git a/Utilities/matlabtools/write_spec_input_L1.m b/Utilities/matlabtools/write_spec_input_L1.m index 308a7811..c4d6fa71 100644 --- a/Utilities/matlabtools/write_spec_input_L1.m +++ b/Utilities/matlabtools/write_spec_input_L1.m @@ -1,9 +1,14 @@ function write_spec_input_L1(template, inputname, Nvol, tfl, pfl, iota, oita, phit_edge, pre, mu, lrad, nptr) +% +% WRITE_SPEC_INPUT_L1( TEMPLATE, INPUTNAME, NVOL, TFL, PFL, IOTA, OITA, PHIT_EDGE, PRE, MU, LRAD, NPTR ) +% ====================================================================================================== +% % Writes spec input file from template with constraints corresponding to % Lconstraint=1 (tfl,iota,oita) % % INPUT +% ----- % -template : template input file name with .sp format % -inputname : new input file name with .sp format % -Nvol : number of volumes diff --git a/Utilities/matlabtools/write_spec_input_L3.m b/Utilities/matlabtools/write_spec_input_L3.m index 3e74a7cf..7a214914 100644 --- a/Utilities/matlabtools/write_spec_input_L3.m +++ b/Utilities/matlabtools/write_spec_input_L3.m @@ -1,10 +1,15 @@ function write_spec_input_L3(template, inputname, Nvol, Lfreebound, tfl, phit_edge, ... pflux, Ivol, Isurf, curtor, pressure, lrad, nptr, Linitialize) +% +% WRITE_SPEC_INPUT_L3( TEMPLATE, INPUTNAME, NVOL, LFREEBOUND, TFL, PHIT_EDGE, ... ) +% ================================================================================= +% % Writes spec input file from template with constraints corresponding to % Lconstraint=1 (tfl,iota,oita) % % INPUT +% ----- % -template : template input file name with .sp format % -inputname : new input file name with .sp format % -Nvol : number of volume @@ -123,4 +128,4 @@ function write_spec_input_L3(template, inputname, Nvol, Lfreebound, tfl, phit_ed end end -fclose(fid); \ No newline at end of file +fclose(fid); diff --git a/Utilities/matlabtools/write_spec_rzdata.m b/Utilities/matlabtools/write_spec_rzdata.m index dcac3659..912a4eab 100644 --- a/Utilities/matlabtools/write_spec_rzdata.m +++ b/Utilities/matlabtools/write_spec_rzdata.m @@ -1,8 +1,13 @@ function write_spec_rzdata(R,Z,outfname) +% +% WRITE_SPEC_RZDATA( R, Z, OUTFNAME ) +% =================================== +% % Writes text file with R,Z data as two columns % % INPUT +% ----- % -R,Z : data in the form of matrices (np x np) % -outfname : output file name with .txt form % diff --git a/Utilities/matlabtools/write_spec_rzgrid.m b/Utilities/matlabtools/write_spec_rzgrid.m index 39ab879d..61f9cf5f 100644 --- a/Utilities/matlabtools/write_spec_rzgrid.m +++ b/Utilities/matlabtools/write_spec_rzgrid.m @@ -1,8 +1,14 @@ -function write_spec_rzgrid(fname,nz0,lvol,outfname) +function write_spec_rzgrid(data, nz0,lvol,outfname) + +% +% WRITE_SPEC_RZGRID( DATA, NZ0, LVOL, OUTFNAME ) +% ============================================== +% % Writes text file with grid coordinate data points R,Z on a given volume, on a toroidal plane, as two columns % % INPUT +% ----- % -fname : input file name with .h5 form % -nz0 : toroidal plane number % -lvol : volume number @@ -11,13 +17,11 @@ function write_spec_rzgrid(fname,nz0,lvol,outfname) % written by J.Loizu (2018) -gdata = read_spec_grid(fname); - -Nt = gdata.Nt; -Nz = gdata.Nz; +Nt = data.grid.Nt; +Nz = data.grid.Nz; iz = nz0-1; -Rij = gdata.Rij; -Zij = gdata.Zij; +Rij = data.grid.Rij; +Zij = data.grid.Zij; Rdata = Rij(lvol,1+Nt*iz:(iz+1)*Nt,:); Zdata = Zij(lvol,1+Nt*iz:(iz+1)*Nt,:); From 98c4d74b0a058fbc23b493cb4eaa70837153cc96 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 29 Apr 2022 13:25:53 +0200 Subject: [PATCH 002/134] Update matlab tools --- Utilities/matlabtools/get_spec_Bxyz.m | 112 +++++ Utilities/matlabtools/get_spec_area.m | 5 +- Utilities/matlabtools/get_spec_fourier.m | 55 +++ Utilities/matlabtools/get_spec_fractaldim_2.m | 463 ++++++++++++++++++ Utilities/matlabtools/modify_Linitialize.m | 53 ++ .../matlabtools/plot_spec_current_profile.m | 37 +- Utilities/matlabtools/plot_spec_iota.m | 40 +- Utilities/matlabtools/plot_spec_iterations.m | 79 +++ Utilities/matlabtools/plot_spec_kam.m | 25 +- .../matlabtools/plot_spec_modB_boundary.m | 127 +++-- Utilities/matlabtools/plot_spec_poincare.m | 70 ++- Utilities/matlabtools/plot_spec_poincare_3d.m | 177 +++++++ Utilities/matlabtools/plot_spec_pressure.m | 33 +- Utilities/matlabtools/read_spec.m | 42 ++ Utilities/matlabtools/write_spec_Bxyz.m | 32 ++ 15 files changed, 1259 insertions(+), 91 deletions(-) create mode 100644 Utilities/matlabtools/get_spec_Bxyz.m create mode 100644 Utilities/matlabtools/get_spec_fourier.m create mode 100644 Utilities/matlabtools/get_spec_fractaldim_2.m create mode 100644 Utilities/matlabtools/modify_Linitialize.m create mode 100644 Utilities/matlabtools/plot_spec_iterations.m create mode 100644 Utilities/matlabtools/plot_spec_poincare_3d.m create mode 100644 Utilities/matlabtools/write_spec_Bxyz.m diff --git a/Utilities/matlabtools/get_spec_Bxyz.m b/Utilities/matlabtools/get_spec_Bxyz.m new file mode 100644 index 00000000..81071b48 --- /dev/null +++ b/Utilities/matlabtools/get_spec_Bxyz.m @@ -0,0 +1,112 @@ +function xyz = get_spec_Bxyz( data, lvol, sarr, tarr, zarr ) +% +% GET_SPEC_BXYZ( DATA, LVOL, SARR, TARR, ZARR ) +% ============================================= +% +% Write the cartesian components of the magnetic field on a +% (x,y,z) grid on the outer side of the plasma-vacuum interface +% given a SPEC equilibrium. +% +% INPUTS +% ------ +% * DATA: data read from spec output via read_spec( fname ) +% * LVOL: volume +% * SARR: Array of s-coordinate +% * TARR: Array of poloidal angles +% * ZARR: Array of toroidal angles +% +% Written by A. Baillod (2021) +% + +% Read some input from data +Mvol = data.output.Mvol; + +if( lvol<1 || lvol>Mvol ) + error('invalid volume') +end + +im = data.output.im; +in = data.output.in; + +Rbc = data.output.Rbc(:,Mvol-1); +Rbs = data.output.Rbs(:,Mvol-1); +Zbc = data.output.Zbc(:,Mvol-1); +Zbs = data.output.Zbs(:,Mvol-1); + +mn = length(Rbc); + +% Start by building the grid and compute (R,Z,phi) coords +ns = length(sarr); +sarr = reshape( sarr, 1, ns); + +nt = length(tarr); +theta = reshape( tarr, 1, nt ); + +nz = length(zarr); +phi = reshape( zarr, 1, nz ); + + +[t_grid, z_grid] = meshgrid( theta, phi ); + +[tmp, Rarr] = get_spec_R_derivatives( data, Mvol, sarr, theta, phi, 'R' ); +[tmp, Zarr] = get_spec_R_derivatives( data, Mvol, sarr, theta, phi, 'Z' ); + + +% Transform to cartesian coordinates (x,y,z) +x = zeros(ns,nt,nz); +y = zeros(ns,nt,nz); +for is = 1:ns + for it = 1:nt + Rtmp = reshape(Rarr{1}(is,it,:), 1, nz); + + x(is,it,:) = Rtmp.*cos(phi); + y(is,it,:) = Rtmp.*sin(phi); + end +end +z = Zarr{1}; +z = reshape(z, ns, nt, nz); + +% Now evaluate field on each grid point +Bcontrav = get_spec_magfield( data, Mvol, sarr, theta, phi ); + +Bx = zeros(ns,nt,nz); +By = zeros(ns,nt,nz); +Bz = zeros(ns,nt,nz); + +for is = 1:ns + for it=1:nt + Bs = reshape( Bcontrav{1}(is,it,:), 1, nz); + Bt = reshape( Bcontrav{2}(is,it,:), 1, nz); + Bphi = reshape( Bcontrav{3}(is,it,:), 1, nz); + + R = reshape( Rarr{1}(is,it,:), 1, nz ); + Rs = reshape( Rarr{2}(is,it,:), 1, nz ); + Rt = reshape( Rarr{3}(is,it,:), 1, nz ); + Rz = reshape( Rarr{4}(is,it,:), 1, nz ); + + Z = reshape( Zarr{1}(is,it,:), 1, nz ); + Zs = reshape( Zarr{2}(is,it,:), 1, nz ); + Zt = reshape( Zarr{3}(is,it,:), 1, nz ); + Zz = reshape( Zarr{4}(is,it,:), 1, nz ); + + Bx(is,it,:) = Bs.*(Rs.*cos(phi) ) ... + + Bt.*(Rt.*cos(phi) ) ... + + Bphi.*(Rz.*cos(phi) - R.*sin(phi)); + By(is,it,:) = Bs.*(Rs.*sin(phi) ) ... + + Bt.*(Rt.*sin(phi) ) ... + + Bphi.*(Rz.*sin(phi) + R.*cos(phi)); + Bz(is,it,:) = Bs.*Zs ... + + Bt.*Zt ... + + Bphi.*Zz + end + +xyz.theta = theta; +xyz.phi = phi; +xyz.x = x; +xyz.y = y; +xyz.z = z; +xyz.Bx = Bx; +xyz.By = By; +xyz.Bz = Bz; + +end diff --git a/Utilities/matlabtools/get_spec_area.m b/Utilities/matlabtools/get_spec_area.m index 7a0e4772..7481f7d0 100644 --- a/Utilities/matlabtools/get_spec_area.m +++ b/Utilities/matlabtools/get_spec_area.m @@ -1,4 +1,4 @@ -function Avol = get_spec_area(data,lvol,ns,nt,phi0) +function Avol = get_spec_area(data,lvol,smax,ns,nt,phi0) % % GET_SPEC_AREA( DATA, LVOL, NS, NT, PHI0 ) @@ -10,6 +10,7 @@ % ----- % -data : must be produced by calling read_spec(filename) % -lvol : volume number +% -smax : max s % -ns : is the resolution in the s-coordinate (e.g. 64) % -nt : is the resolution in the theta-coordinate (e.g. 64) % -phi0 : toroidal angle defining a toroidal plane @@ -25,7 +26,7 @@ smin = -0.999; %avoids singular inversion of the metric matrix -sarr = linspace(smin,1,ns); +sarr = linspace(smin,smax,ns); tarr = linspace(0,2*pi,nt); jacobian = get_spec_jacobian(data,lvol,sarr,tarr,phi0); diff --git a/Utilities/matlabtools/get_spec_fourier.m b/Utilities/matlabtools/get_spec_fourier.m new file mode 100644 index 00000000..7300d408 --- /dev/null +++ b/Utilities/matlabtools/get_spec_fourier.m @@ -0,0 +1,55 @@ +function rmn = get_spec_fourier( data, surface_index, Mpol, Ntor ) +% +% GET_SPEC_FOURIER( DATA, SURFACE_INDEX, MPOL, NTOR ) +% =================================================== +% +% Extract the fourier harmonics from a SPEC Poincaré data +% +% INPUTS +% ------ +% - DATA: obtained via read_spec() +% - SURFACE_INDEX: index of surface you want to target +% - MPOL: Poloidal resolution +% - NTOR: Toroidal resolution +% +% OUTPUT +% ------ +% - RMN: fluxSurface instance containing the fourier harmonics of the flux +% surface +% +% + + Nfp = double(data.input.physics.Nfp); + stellsym = 1; + rmn = fluxSurface( Nfp, Mpol, Ntor, stellsym ); + + + R = data.poincare.R( surface_index, :, : ); + Z = data.poincare.Z( surface_index, :, : ); + + s = size(R); + + R = reshape(R, s(2), s(3)); + Z = reshape(Z, s(2), s(3)); + + s = size(R); + nz = s(1); + + phi = (0:nz-1.0)*(2.0*pi/nz)/Nfp; + + rmn_axis = data.output.Rbc(1:data.input.physics.Ntor+1,1); + zmn_axis = data.output.Zbs(1:data.input.physics.Ntor+1,1); + + r_axis = zeros(1, nz); + z_axis = zeros(1, nz); + for n=0:double(data.input.physics.Ntor) + + r_axis = r_axis + rmn_axis(n+1) * cos(n*Nfp*phi); + z_axis = z_axis - zmn_axis(n+1) * sin(n*Nfp*phi); + + end + + + rmn = rmn.initialize_from_poincare( R, Z, phi, r_axis, z_axis ); + +end \ No newline at end of file diff --git a/Utilities/matlabtools/get_spec_fractaldim_2.m b/Utilities/matlabtools/get_spec_fractaldim_2.m new file mode 100644 index 00000000..ba09ba9c --- /dev/null +++ b/Utilities/matlabtools/get_spec_fractaldim_2.m @@ -0,0 +1,463 @@ +function [Dfrac, Lmin_polyfit, Lmax_polyfit, Lmin_num, Lmax_num] = get_spec_fractaldim_2(data, numline, mth, polyfit_degree, varargin) + + % + % GET_FRACTALDIM( N, L, CASE_TITLE, POLYFIT_DEGREE, N_PTS, PLOTFIG ) + % ================================================================== + % + % Plot the N, L parameters resulting from get_NL_boxcount and deduce the fractal dimension + % Ex : + % [D_polyfit, D_num, D_slope, Lmin_polyfit, Lmax_polyfit, Lmin_num, Lmax_num] = get_fractaldim(N_cantor, L_cantor, 1, 'Cantor', 6); + % + % INPUT + % ----- + % -data : SPEC output data, read from read_spec(filename) + % -numline : Line number + % -mth : 0: uses the mean value to get the fractal dim + % 1: evaluates numerically the curvature and + % extract the linear part + % 2: polyfits the curve and evaluate the curvature + % analytically to extract the linear part. + % -polyfit_degree : degree of the polyfit used to approximate the fractal dim + % : found out that it worked well between 4 and 6 depending on kmax (better to have 6 for large kmax and 4 otherwise) + % + % OUTPUT + % ------ + % -Dfrac : fractal dimension + % -Lmin_num : parameter defining the minimal size of the boxes used for the linear fit with numerical curvature + % -Lmax_num : parameter defining the maximal size of the boxes used for the linear fit with numerical curvature + % -Lmin_polyfit : parameter defining the minimal size of the boxes used for the linear fit using polyfit + % -Lmax_polyfit : parameter defining the maximal size of the boxes used for the linear fit using polyfit + % : recall that the size of the boxes is proportional to 2^(-k), hence kmin_edge < kmax_edge + % + + % Optional input + % --------------- + torplane = 1; + base_exponent = 2; + kmin = 2; + kmax = 8; + newfig = 0; + + % Optional outputs + % ---------------- + Lmin_num = 0; + Lmax_num = 0; + Lmin_polyfit = 0; + Lmax_polyfit = 0; + + l = length(varargin); + if mod(l,2)~=0 + error('Invalid number of input arguments') + end + + for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + switch field + case 'torplane' + torplane = value; + case 'base_exponent' + base_exponent = value; + case 'kmin' + kmin = value; + case 'kmax' + kmax = value; + case 'newfig' + newfig = value; + otherwise + warning(['Inknown input field: ', field, '. Ignored...']) + end + end + + + % Read some important input + % -------------------------- + R = data.poincare.R(numline,torplane,:); + Z = data.poincare.Z(numline,torplane,:); + + s = size( R ); + n_pts = s(3); + + % Perform box counting + % --------------------- + [N, L] = get_NL_boxcount(base_exponent, kmin, kmax, R, Z); + + + % Set up... + idx = 1:length(N); + + % slopes between each datapoints + xp = diff(-log(L)); + yp = diff(log(N)); + + if newfig + figure('Color','w') + loglog( L, N, 'o', 'MarkerFaceColor', 'b') + ylabel('Number of box with a point N') + xlabel('Box size') + + end + + switch mth + case 0 % mean slope + + % take the centered finite differences and having forward and backward + % finite diff for the last points + xp_ = (xp(1:end-1) + xp(2:end))/2; + yp_ = (yp(1:end-1) + yp(2:end))/2; + slopes = [yp(1)/xp(1), yp_./xp_, yp(end)/xp(end)]; + + % polyf_1d = polyfit(-log(L),log(N), 1); + % D_slope = polyf_1d(1); + Dfrac = mean(slopes); + + + case 1 % numerical curvature + % idea is to remove the saturation plateau + % the -1 comes from the correspondance between the curvature and the slopes + min_plateau_idx_num = min(idx(N>0.95*n_pts))-1; + + % take the centered finite differences and having forward and backward + % finite diff for the last points + xp_ = (xp(1:end-1) + xp(2:end))/2; + yp_ = (yp(1:end-1) + yp(2:end))/2; + slopes = [yp(1)/xp(1), yp_./xp_, yp(end)/xp(end)]; + + % curvature + curv_num = curvature(-log(L),log(N)); + + % threshold (kind of arbitrary for the moment) + % we take the max w.r.t. a very low curvature in the case where the + % points are already all well aligned + threshold_num = max(max(curv_num)/2, 0.2); + + % find min, max indices + % there are always at least two points in between + [idx_min_num, idx_max_num] = find_idx_min_max(curv_num, threshold_num, min_plateau_idx_num); + + % we take the best points to compute the dimension + % the +1 are due to the correspondance between the curvature and the slopes + % taking a polyfit yields a similar accuracy than the mean slope + Dfrac = mean(slopes(idx_min_num+1:idx_max_num+1)); + + % determine the corresponding Lmin_num and Lmax_num + Lmin_num = L(idx_max_num+1); + Lmax_num = L(idx_min_num+1); + + case 2 % polyfit curvature + + % 100 logarithmically spaced values exp(x) with x between [beg, end] + Lfit = exp(linspace(log(L(1)), log(L(end)), 100)); + one_over_L = 1./Lfit; + + % the -1 comes from the correspondance between the curvature and the slopes + min_plateau_idx_polyfit = uint64((min(idx(N>0.95*n_pts))-1)*100/length(N)); + + % fit the whole data + p = polyfit(-log(L),log(N), polyfit_degree); + pp = polyder(p); + ppp = polyder(pp); + + curv_polyfit = abs(polyval(ppp,log(one_over_L)))./(1+polyval(pp,log(one_over_L)).^2).^(3/2); + + % threshold (kind of arbitrary for the moment) + threshold_polyfit = max(max(curv_polyfit)/10, 0.2); + + % find all zones (min, max indices) with curvature below threshold + [idx_min_polyfit, idx_max_polyfit] = find_idx_min_max(curv_polyfit, threshold_polyfit, min_plateau_idx_polyfit); + + % determine the corresponding Lmin_polyfit and Lmax_polyfit associated + % with kmax_edge and kmin_edge respectively if idx_min_polyfit or + % idx_max_polyfit is empty, it is a consequence of a too low threshold ! + Lmin_polyfit = 1/one_over_L(idx_max_polyfit); + Lmax_polyfit = 1/one_over_L(idx_min_polyfit); + + % taking a polyfit yields a similar accuracy than the mean slope + Dfrac = mean(polyval(pp,log(one_over_L(idx_min_polyfit:idx_max_polyfit-1)))); + + if newfig + hold on; + xx = log(Lfit); + yy = polyval(p, -xx); + loglog( exp(xx), exp(yy), 'LineWidth', 2 ) + ax = gca; + yy = ax.YLim; + loglog( Lmin_polyfit*[1,1], yy, 'k--' ) + loglog( Lmax_polyfit*[1,1], yy, 'k--' ) + end + + otherwise + + error('Invalid input') + + end + + + + + + % ===================================================================== + % average over the whole data (without correction) + + +% if plotfig +% set(groot, 'defaultAxesTickLabelInterpreter','latex'); +% set(groot, 'defaultLegendInterpreter','latex'); +% set(groot, 'defaultTextInterpreter','latex'); +% set(groot, 'defaultAxesFontSize', 15); +% +% graph = figure; +% hold on; +% plot(1./L, N, '.', 'markersize', 12); +% xline(1/Lmax_polyfit, 'r'); +% xline(1/Lmin_polyfit, 'r'); +% xline(1/Lmax_num); +% xline(1/Lmin_num); +% plot(one_over_L, exp(polyval(p, log(one_over_L))), 'r'); +% xlabel('Inverse box-length $1/L$'); +% ylabel('Box-count $N$'); +% box on; +% grid on; +% set(gca,'xscale','log'); +% set(gca,'yscale','log'); +% % title(case_title, 'Interpreter', 'latex'); +% str = ['Dimension with polynomial fit : ', num2str(D_polyfit), ... +% newline, 'Dimension with numerical curvature : ', ... +% num2str(D_num), newline, ... +% 'Dimension with average slope : ', num2str(D_slope)]; +% annotation('textbox', [.36 0 .3 .3], 'String', str, ... +% 'FitBoxToText', 'on', 'LineWidth', 0.5, 'BackgroundColor', ... +% [1, 1, 1], 'Interpreter', 'latex'); +% +% graph = figure; +% hold on; +% plot(linspace(1,length(curv_polyfit)+1,length(curv_polyfit)), curv_polyfit); +% xline(idx_min_polyfit); +% xline(idx_max_polyfit); +% yline(threshold_polyfit); +% text(2.3, threshold_polyfit*1.05, 'Polynomial fit threshold', ... +% 'FontSize', 12, 'Interpreter', 'latex'); +% box on; +% grid on; +% set(gca,'xlim',[1 length(curv_polyfit)+1]); +% xlabel('Indices of the points considered'); +% ylabel(['Analytical curvature of ',newline,... +% 'polynomial fit of $N(1/L)$']); +% +% graph = figure; +% hold on; +% plot(linspace(1,length(curv_num),length(curv_num)), curv_num); +% xline(idx_min_num); +% xline(idx_max_num); +% yline(threshold_num); +% text(2.3, threshold_num*1.05, 'Numerical threshold', ... +% 'FontSize', 12, 'Interpreter', 'latex'); +% box on; +% grid on; +% set(gca,'xlim',[1 length(curv_num)]); +% xlabel('Indices of the points considered'); +% ylabel('Numerical curvature of $N(1/L)$'); +% end +end + +% ========================================================================= +% ========================================================================= +function curv = curvature(x, y) + + % + % CURV = CURVATURE( X, Y ) + % ======================== + % + % Compute the curvature of the curve defined by x,y (the starting point and the endpoints have not defined curvature here, it is not checked whether the starting point and the endpoint coincide) + % + % INPUT + % ----- + % -x,y : coordinates of the curve + % + % OUTPUT + % ------ + % -curv : curvature of the curve + % + + xp = diff(x); xpp = diff(xp); + yp = diff(y); ypp = diff(yp); + + curv = zeros(1, length(x)-2); + % take the centered finite differences + xp_ = (xp(1:end-1) + xp(2:end))/2; + yp_ = (yp(1:end-1) + yp(2:end))/2; + + curv = abs(xp_.*ypp - yp_.*xpp)./(xp_.^2 + yp_.^2).^(3/2); + + % can also be implemented such as the following (exact same formula actually) + % for i = 1:length(xp)-1 + % % twice the area of the triangle between these 3 pts + % D = norm(xp(i)*yp(i+1)-yp(i)*xp(i+1)); + % a = (x(i)-x(i+1))^2 + (y(i)-y(i+1))^2; + % b = (x(i+1)-x(i+2))^2 + (y(i+1)-y(i+2))^2; + % c = (x(i)-x(i+2))^2 + (y(i)-y(i+2))^2; + % curv(i) = 2*D/(a*b*c); + % end +end + +% ============================================== +% ============================================== +function [idx_min, idx_max] = find_idx_min_max(curv, threshold, min_plateau_idx) + + % + % FIND_IDX_MIN_MAX( CURV, threshold, min_plateau_idx ) + % ================================================= + % + % Find the zones (min and max indices) associated with the minimal curvature under the threshold (one of them is the best linear zone) + % + % INPUT + % ----- + % -curv : curvature of the curve + % -threshold : threshold for the minimal curvature + % -plateau_idx : indices of the pts near the saturation plateau at log(n_pts) + % + % OUTPUT + % ------ + % -idx_min,idx_max : min and max indices for the linear zone + % + + n_curv = length(curv); + + % find all the indices such that both neighbours are below the threshold + start_pt_2_idx_below_threshold = []; + end_pt_2_idx_below_threshold = []; + for i = 1:n_curv + % finds the pts such that \_ + if i>1 && curv(i) < threshold && curv(i-1) > threshold || i==1 && curv(1) < threshold + start_pt_2_idx_below_threshold(end+1) = i; + end + % finds the pts such that _/ + if i threshold && curv(i) < threshold || i==n_curv && curv(n_curv) < threshold + end_pt_2_idx_below_threshold(end+1) = i; + end + end + + if length(end_pt_2_idx_below_threshold) > 1 + if ~isempty(min_plateau_idx) + % remove the plateau from the possibilities + while start_pt_2_idx_below_threshold(end) >= min_plateau_idx && length(end_pt_2_idx_below_threshold) > 1 + start_pt_2_idx_below_threshold(end) = []; + end_pt_2_idx_below_threshold(end) = []; + end + end + + % find the largest zone delta L + [~, idx_largest_delta_L] = max(end_pt_2_idx_below_threshold-start_pt_2_idx_below_threshold); + % as indices of curv + idx_min = start_pt_2_idx_below_threshold(idx_largest_delta_L); + idx_max = end_pt_2_idx_below_threshold(idx_largest_delta_L); + else + % as indices of curv + idx_min = start_pt_2_idx_below_threshold; + idx_max = end_pt_2_idx_below_threshold; + end +end + +function [N, L] = get_NL_boxcount(base_exponent, kmin, kmax, x, y) + + % + % GET_NL_BOXCOUNT( BASE_EXPONENT, KMIN, KMAX, X, Y ) + % ================================================== + % + % Get the N, L parameters necessary for fractal dimension computation using box-counting + % + % INPUT + % ----- + % -base_exponent : base of the exponential factor by which the box sizes are reduced (1 < base <= 2 is good) + % -kmin : min exponent linked to the size of the boxes (integer >= 0) + % -kmax : max exponent linked to the size of the boxes + % -x,y : coordinates of the points in the set to analyse (y optional) + % + % OUTPUT + % ------ + % -N : number of box counted + % -L : size of the box counted (normalized by the max size of the boxes Lmax) + % + + switch nargin + case 4 + dim = 1; + case 5 + dim = 2; + otherwise + error('Too many or not enough input arguments. Type "help get_NL_fractaldim" for more informations') + end + + n_pts = length(x); + N = zeros(1,kmax-kmin+1); + L = zeros(1,kmax-kmin+1); + x_min = min(x); + x_max = max(x); + p = 1; + + switch dim + case 1 % fractal is represented in 1D + Lmax = x_max-x_min; + + for k = kmin:kmax + s = base_exponent^k; + L(p) = Lmax/s; + + counter = zeros(1,ceil(s)); + + for i = 1:n_pts + % x-y indices of the i-th pt + is = 1+floor((x(i)-x_min)/L(p) ); + + try + counter(1,is) = 1; + catch + error(';problem') + end + end + + N(p) = sum(counter); + % increment p (boxsize parameter) + p = p+1; + end + + case 2 % fractal is represented in 2D + y_min = min(y); + y_max = max(y); + + % At least 1 box in each coordinate - total of 100 boxes + % Better precision than if one takes : + % Lmax = max([x_max-x_min, y_max-y_min]); + % However one must be careful with the memory allocation! + Lmax_x = x_max - x_min; + Lmax_y = y_max - y_min; + Lmax = min([Lmax_x, Lmax_y]); + if abs(Lmax) < 1e-7 + % due to points being possible + Lmax = 1; + end + for k = kmin:kmax + s = base_exponent^k; + L(p) = Lmax/s; + + counter = zeros(ceil(s * Lmax_x / Lmax), ceil(s * Lmax_y / Lmax)); + + for i = 1:n_pts + % x-y indices of the i-th pt + is = 1+floor((x(i)-x_min)/L(p) ); + js = 1+floor((y(i)-y_min)/L(p) ); + + try + counter(is,js) = 1; + catch + error(';problem') + end + end + + N(p) = sum(sum(counter)); + % increment p (boxsize parameter) + p = p+1; + end + end +end diff --git a/Utilities/matlabtools/modify_Linitialize.m b/Utilities/matlabtools/modify_Linitialize.m new file mode 100644 index 00000000..b26cc0a8 --- /dev/null +++ b/Utilities/matlabtools/modify_Linitialize.m @@ -0,0 +1,53 @@ +function modify_Linitialize(filename, Linitialize) + +sref = ' Linitialize ='; +snew1 = strcat(sref,{' '}, num2str(Linitialize)); +snew = snew1{1}; + + + +%Open file +fid = fopen(filename,'rt'); + +tline = fgetl(fid); + +count = 1; +lnum = 0; + +A{1} = tline; + + +% Read template file, copy lines in A, and identify reference lines + +while ischar(tline) + if(size(tline)>=size(sref)) + if(strcmp(tline(1:length(sref)),sref)==1) + lnum = count; + end + end + tline = fgetl(fid); + count = count + 1; + A{count} = tline; +end + +fclose(fid); + + +% Modify cell A at reference lines +A{lnum} = sprintf('%s',snew); + +% Write cell A into new input file + +fid = fopen(filename, 'w'); + +for i = 1:numel(A) + if(A{i+1} == -1) + fprintf(fid,'%s', A{i}); + break + else + fprintf(fid,'%s\n', A{i}); + end +end + +fclose(fid); +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_current_profile.m b/Utilities/matlabtools/plot_spec_current_profile.m index 88ded61b..d3b6f334 100644 --- a/Utilities/matlabtools/plot_spec_current_profile.m +++ b/Utilities/matlabtools/plot_spec_current_profile.m @@ -1,4 +1,4 @@ -function plot_spec_current_profile( data, newfig ) +function plot_spec_current_profile( data, iflag, newfig, varargin ) % % PLOT_SPEC_CURRENT_PROFILE( DATA, NEWFIG ) % ========================================= @@ -9,19 +9,38 @@ function plot_spec_current_profile( data, newfig ) % INPUTS % ------ % * data: SPEC output data obtained with read_spec(filename) +% * iflag: (0) plots Ivolume +% (1) plots Isurf +% (2) plots both % * newfig: (0) plot on current figure % (1) open a new figure % (2) Erase current figure and use it % % Written by A. Baillod (2020) % + l = length(varargin); + if mod(l,2)~=0 + error('Invalid number of argument') + end + + opt.LineWidth = 2; + opt.Color = 'r'; + opt.Marker = 'none'; + opt.MarkerSize = 8; + opt.LineStyle = '-'; + for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + opt.(field) = value; + end switch newfig case 0 hold on case 1 - figure('Position', [200 200 900 700]) + figure('Position', [200 200 900 700],'Color','w') hold on case 2 hold off @@ -66,19 +85,27 @@ function plot_spec_current_profile( data, newfig ) tflux = get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); psitor(k) = cumflux + tflux; - Iphi(k) = cumcur + mu(lvol) * tflux; + if iflag==0 || iflag==2 + Iphi(k) = cumcur + mu(lvol) * tflux; + else + Iphi(k) = cumcur; + end end cumflux = psitor(k); kstart = kstart+nptrj(lvol); %cumcur = Iphi(k); - cumcur = Iphi(k) + data.output.IPDt(lvol); % add surface current + if iflag==1 || iflag==2 + cumcur = Iphi(k) + data.output.IPDt(lvol); % add surface current + else + cumcur = Iphi(k); + end end phiedge=psitor(end); - plot( sqrt(psitor / phiedge), Iphi, 'LineWidth', 3 ) + plot( sqrt(psitor / phiedge), Iphi, 'LineWidth', opt.LineWidth, 'Color', opt.Color, 'Marker', opt.Marker, 'LineStyle', opt.LineStyle ) xlabel('$(\Psi_t / \Psi_{edge})^{1/2}$', 'Interpreter', 'latex') ylabel('$\mu_0I_\phi$[Tm]', 'Interpreter', 'latex') set(gca, 'FontSize', 18) diff --git a/Utilities/matlabtools/plot_spec_iota.m b/Utilities/matlabtools/plot_spec_iota.m index 4c18e418..b9dfeb3c 100644 --- a/Utilities/matlabtools/plot_spec_iota.m +++ b/Utilities/matlabtools/plot_spec_iota.m @@ -1,4 +1,4 @@ -function out = plot_spec_iota(data,iorq,xaxis,newfig) +function out = plot_spec_iota(data,iorq,xaxis,newfig,varargin) % % PLOT_SPEC_IOTA( DATA, IORQ, XAXIS, NEWFIG ) @@ -26,8 +26,26 @@ % modified by A.Baillod (01.2019) % modified by J.Loizu (01.2020) +l = length(varargin); +if mod(l,2)~=0 + error('Invalid number of argument') +end + +opt.LineWidth = 2; +opt.Color = 'r'; +opt.Marker = '*'; +opt.MarkerSize = 8; +opt.LineStyle = 'none'; +for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + opt.(field) = value; +end + + if(newfig==1) - figure + figure('Position', [200 200 900 700], 'Color', 'w') hold on; elseif newfig==0 hold on; @@ -47,14 +65,18 @@ switch xaxis case 's' - plot(data.transform.fiota(1:nsucctrj,1),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) + plot(data.transform.fiota(1:nsucctrj,1),F(1:nsucctrj),'Marker',opt.Marker,... + 'MarkerSize',opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... + opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) ylabel(Flabel) out = cell(2); out{1} = data.transform.fiota(:,1); out{2} = F; case 'R' - plot(transpose(data.poincare.R(:,1,1)),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) + plot(transpose(data.poincare.R(:,1,1)),F(1:nsucctrj),'Marker',opt.Marker,... + 'MarkerSize',opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... + opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) ylabel(Flabel) out = cell(2); out{1} = data.poincare.R(:,1,1); @@ -104,7 +126,9 @@ kstart = kstart+nptrj(lvol); end - plot(psitor/phiedge,F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) + plot(psitor/phiedge,F(1:nsucctrj),'Marker',opt.Marker,'MarkerSize',opt.MarkerSize,... + 'LineWidth',opt.LineWidth,'MarkerEdgeColor',opt.Color,... + 'LineStyle',opt.LineStyle,'Color',opt.Color) ylabel(Flabel) xlabel('\Psi / \Psi_{edge}') @@ -157,7 +181,9 @@ % phiedge = data.input.physics.phiedge; - plot(sqrt(psitor/phiedge),F(1:nsucctrj),'*','MarkerSize',8,'LineWidth',2) + plot(sqrt(psitor/phiedge),F(1:nsucctrj),'Marker',opt.Marker,'MarkerSize',... + opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... + opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) ylabel(Flabel) xlabel('(\Psi / \Psi_{edge})^{1/2}') @@ -166,3 +192,5 @@ out{2} = F(1:nsucctrj); end + +set(gca,'FontSize',18) diff --git a/Utilities/matlabtools/plot_spec_iterations.m b/Utilities/matlabtools/plot_spec_iterations.m new file mode 100644 index 00000000..f23ef490 --- /dev/null +++ b/Utilities/matlabtools/plot_spec_iterations.m @@ -0,0 +1,79 @@ +function plot_spec_iterations( data, xl, yl ) + +figure( 'Position', [200 200 900 700], 'Color', 'w' ) +fig = gcf; +ax = gca; +ax.Position = [0.1300 0.2386 0.7750 0.6864]; + + +Nfp = double(data.input.physics.Nfp); +Niter = size(data.iterations.iRbc); +Niter = Niter(3); + +sld_phi = uicontrol(fig, 'style', 'slider', 'Position', [200 25 500 20],'units','pixel', ... + 'Value',0,'Max',2*pi / Nfp,'Min',0); +sld_it = uicontrol(fig, 'style', 'slider', 'Position', [200 63 500 20],'units','pixel', ... + 'Value',1,'Max', Niter,'Min',1, 'SliderStep', [1/(Niter-1), 1/(Niter-1)]); + +el_phi = addlistener( sld_phi, 'ContinuousValueChange', @(sld_phi, event) updatePlot(sld_phi, sld_it, data, xl, yl) ); +el_it = addlistener( sld_it , 'ContinuousValueChange', @(sld_it , event) updatePlot(sld_phi, sld_it, data, xl, yl) ); + +plot_iteration( data, 1, 0, xl, yl ) + +mytitle = sprintf('%s=%2.3f, iteration %05i', '\phi', 0, 1); +title(mytitle,'FontSize',18) + + +end + + + + +function updatePlot(sld_phi, sld_it, data, xl, yl) + + phi = sld_phi.Value; + iter = round(sld_it.Value); + + plot_iteration( data, iter, phi, xl, yl ) + + mytitle = sprintf('%s=%2.3f, iteration %05i', '\phi', phi, iter); + title(mytitle,'FontSize',18) +end + + +function plot_iteration( data, iter, phi, xl, yl ) + + Nfp = double(data.input.physics.Nfp); + input.representation = 'hudson'; + input.im = double(data.output.im); + input.in = double(data.output.in) / Nfp; + Mvol = double(data.output.Mvol); + Ntor = double(data.input.physics.Ntor); + + % Erase previous plot + hold off + + % Axis + Ra = 0; + Za = 0; + for nn=0:Ntor + Ra = Ra + data.iterations.iRbc(nn+1,1,iter) * cos( nn*Nfp*phi ); + Za = Za - data.iterations.iZbs(nn+1,1,iter) * sin( nn*Nfp*phi ); + end + + scatter( Ra, Za, 50, 'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'r' ) + + hold on + % volume boundaries + for ivol=2:Mvol+1 + input.Rmn = data.iterations.iRbc(:,ivol,iter); + input.Zmn = data.iterations.iZbs(:,ivol,iter); + + plot_boundary_2d( input, 512, phi, Nfp, 0 ) + end + + + xlim(xl) + ylim(yl) +end + diff --git a/Utilities/matlabtools/plot_spec_kam.m b/Utilities/matlabtools/plot_spec_kam.m index 8899b0c4..d9752e22 100644 --- a/Utilities/matlabtools/plot_spec_kam.m +++ b/Utilities/matlabtools/plot_spec_kam.m @@ -1,4 +1,4 @@ -function plot_spec_kam(data, nz0, newfig) +function plot_spec_kam(data, nz0, newfig, varargin) % % PLOT_SPEC_KAM( DATA, NZ0, NEWFIG ) @@ -16,11 +16,25 @@ function plot_spec_kam(data, nz0, newfig) % upgraded by J.Loizu (07.2017) % modified by A. Baillod (06.2019) % modified by J.Loizu (01.2020) +l = length(varargin); +if mod(l,2)~=0 + error('Invalid number of argument') +end + +opt.InterfaceColor = 'r'; +for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + opt.(field)=value; +end Np = double(data.input.physics.Nfp); -%Nplan = double(size(data.poincare.R,2)); % # of toroidal planes -%zetaov2pi = (nz0-1) / (Np * Nplan); -zetaov2pi = 0; +Ndiscrete = double(data.input.numerics.Ndiscrete); +Ntor = double(max(abs(data.output.in))); +Nplan = max(Ndiscrete*4*Ntor, 1) +zetaov2pi = (nz0-1) / (Nplan); +%zetaov2pi = 0; Nvol = double(data.input.physics.Nvol); mn = data.output.mn; @@ -93,8 +107,9 @@ function plot_spec_kam(data, nz0, newfig) hold off end + for i=1:size(X,1) - scatter(X(i,:),Y(i,:),3,'filled','r') + scatter(X(i,:),Y(i,:),3,'filled','MarkerFaceColor',opt.InterfaceColor,'MarkerEdgeColor',opt.InterfaceColor) hold on end diff --git a/Utilities/matlabtools/plot_spec_modB_boundary.m b/Utilities/matlabtools/plot_spec_modB_boundary.m index a92feb89..f8808df2 100644 --- a/Utilities/matlabtools/plot_spec_modB_boundary.m +++ b/Utilities/matlabtools/plot_spec_modB_boundary.m @@ -1,4 +1,4 @@ -function plot_spec_modB_boundary(data,vol,nt,nz) +function plot_spec_modB_boundary(data,interface,innout,nt,nz,dimension) % % PLOT_SPEC_MODB_BOUNDARY( DATA, VOL, NT, NZ ) @@ -9,22 +9,41 @@ function plot_spec_modB_boundary(data,vol,nt,nz) % INPUT % ----- % -data : data obtained via read_spec(filename) -% -vol : Volume on which modB should be plotted +% -interface : Volume on which modB should be plotted +% -innout: (0) - inner side of interface +% (1) - outer side of interface % -nt : poloidal resolution for the plotting (e.g. nt=64) % -nz : toroidal resolution for the plotting (e.g. nz=64) +% -dimension: (2) - plot a colorplot on a theta-phi grid +% (3) - plot a colorplot on a 3d surface % % written by J.Loizu (2016) % modified by J.Loizu (01.2017) -sarr = 1; +Mvol = data.output.Mvol; -tarr = linspace(0,2*pi,nt); +if interface<1 || interface>Mvol + error('Invalid interface') +end -zarr = linspace(0,2*pi,nz); +switch innout + case 0 + vol = interface; + sarr = 1; + case 1 + if interface==Mvol + error('Cannot plot on the outer side of last interface!') + end + vol = interface+1; + sarr = -1; + otherwise + error('Interface should be 0 or 1') +end +tarr = linspace(0,2*pi,nt); +zarr = linspace(0,2*pi,nz); -Mvol = data.output.Mvol; -if(vol>Mvol) +if(vol>Mvol || vol<1) error('vol not valid') end @@ -33,36 +52,66 @@ function plot_spec_modB_boundary(data,vol,nt,nz) modB = get_spec_modB(data,vol,sarr,tarr,zarr); - -% Compute function (R,Z)(s,theta,zeta) - -rzdata = get_spec_rzarr(data,vol,sarr,tarr,zarr); - -R = squeeze(rzdata{1}); -Z = squeeze(rzdata{2}); - - -% Construct cartesian corrdinates - -X = zeros(nt,nz); - -Y = zeros(nt,nz); - -for it=1:nt - for iz=1:nz - X(it,iz) = R(it,iz)*cos(zarr(iz)); - Y(it,iz) = R(it,iz)*sin(zarr(iz)); - end +switch dimension + case 2 + figure + + [t,z] = meshgrid(tarr, zarr); + + modB = reshape(modB, nt, nz); + + pcolor( z, t, modB' ) + shading interp + + colorbar + xlabel('$\phi$', 'Interpreter', 'latex') + ylabel('$\theta$', 'Interpreter', 'latex') + + ax = gca; + ax.YTick = [pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4]; + ax.YTickLabel = {'$\frac{\pi}{4}$','$\frac{\pi}{2}$','$\frac{3\pi}{4}$','$\pi$','$\frac{5\pi}{4}$', '$\frac{3\pi}{2}$','$\frac{7\pi}{4}$'}; + ax.XTick = [pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4]; + ax.XTickLabel = {'$\frac{\pi}{4}$','$\frac{\pi}{2}$','$\frac{3\pi}{4}$','$\pi$','$\frac{5\pi}{4}$', '$\frac{3\pi}{2}$','$\frac{7\pi}{4}$'}; + ax.TickLabelInterpreter = 'latex'; + + set(gca,'FontSize',18) + set(gcf,'Position',[200 200 900 700]) + + + case 3 + % Compute function (R,Z)(s,theta,zeta) + + rzdata = get_spec_rzarr(data,vol,sarr,tarr,zarr); + + R = squeeze(rzdata{1}); + Z = squeeze(rzdata{2}); + + + % Construct cartesian corrdinates + + X = zeros(nt,nz); + + Y = zeros(nt,nz); + + for it=1:nt + for iz=1:nz + X(it,iz) = R(it,iz)*cos(zarr(iz)); + Y(it,iz) = R(it,iz)*sin(zarr(iz)); + end + end + + + % Plot + + figure + + h=surf(X,Y,Z,squeeze(modB(1,:,:))); + + axis equal + shading interp + colorbar + title('| B |') + + otherwise + error('Invalid dimension') end - - -% Plot - -figure - -h=surf(X,Y,Z,squeeze(modB(1,:,:))); - -axis equal -shading interp -colorbar -title('| B |') diff --git a/Utilities/matlabtools/plot_spec_poincare.m b/Utilities/matlabtools/plot_spec_poincare.m index 776da199..8470c604 100644 --- a/Utilities/matlabtools/plot_spec_poincare.m +++ b/Utilities/matlabtools/plot_spec_poincare.m @@ -1,4 +1,4 @@ -function phi = plot_spec_poincare(data,nz0,arr,newfig) +function phi = plot_spec_poincare(data,nz0,arr,newfig,varargin) % % PLOT_SPEC_POINCARE( DATA, NZ0, NFP, ARR, NEWFIG ) @@ -19,6 +19,20 @@ % modified by A.Baillod (2019) % modified by J.Loizu (2020) +opt.BoundaryColor = 'r'; +opt.CBColor = 'k'; +opt.step = 1; + +ll = length(varargin); +if mod(ll,2)~=0 + error('Invalid number of arguments') +end + +for ii=1:ll/2 + opt.(varargin{2*ii-1}) = varargin{2*ii}; +end +stp = opt.step; + nfp = data.input.physics.Nfp; try @@ -50,10 +64,10 @@ disp(' '); -rmax = max(max(max(data.poincare.R))); -rmin = min(min(min(data.poincare.R))); -zmax = max(max(max(data.poincare.Z))); -zmin = min(min(min(data.poincare.Z))); +rmax = max(max(max(data.poincare.R(:,nz0,:)))); +rmin = min(min(min(data.poincare.R(:,nz0,:)))); +zmax = max(max(max(data.poincare.Z(:,nz0,:)))); +zmin = min(min(min(data.poincare.Z(:,nz0,:)))); switch data.input.physics.Igeometry case 1 @@ -67,18 +81,20 @@ ymin = -1.1*rmax; ymax = 1.1*rmax; case 3 - xmin = 0.9*rmin; - xmax = 1.1*rmax; - ymin = 1.1*zmin; - ymax = 1.1*zmax; + xmin = 0.99*rmin; + xmax = 1.01*rmax; + dz = zmax-zmin; + ymin = zmin - 0.05*dz; + ymax = zmax + 0.05*dz; end nth = 5096; %ploting options for the boundary -bcol = 'r'; +bcol = opt.BoundaryColor; bthick = 3; +lthick = 1; if(data.input.physics.Lfreebound==1) -bcol = 'k'; +bcol = opt.CBColor; bthick = 1; end @@ -94,7 +110,7 @@ case 0 hold on case 1 - figure + figure('Color','w','Position',[200 200 900 700]) hold on case 2 hold off @@ -118,21 +134,21 @@ R = squeeze(data.poincare.R(:,j,:)); T = rpol*mod(squeeze(data.poincare.t(:,j,:)),2*pi); for i=arr %for each field line trajectory - scatter(T(i,:),R(i,:),10,'.k') + scatter(T(i,:),R(i,:),lthick,'.k') hold on end case 2 R = squeeze(data.poincare.R(:,j,:)); T = squeeze(data.poincare.t(:,j,:)); for i=arr %for each field line trajectory - scatter(R(i,:).*cos(T(i,:)),R(i,:).*sin(T(i,:)),10,'.k') + scatter(R(i,:).*cos(T(i,:)),R(i,:).*sin(T(i,:)),lthick,'.k') hold on; end case 3 R = squeeze(data.poincare.R(:,j,:)); Z = squeeze(data.poincare.Z(:,j,:)); for i=arr %for each field line trajectory - scatter(R(i,:),Z(i,:),10,'.k') + scatter(R(i,:),Z(i,:),lthick,'.k') hold on; end otherwise @@ -190,8 +206,8 @@ ylabel('R','FontSize',12) end - xlim([xmin xmax]) - ylim([ymin ymax]) +% xlim([xmin xmax]) +% ylim([ymin ymax]) end @@ -199,22 +215,22 @@ switch data.input.physics.Igeometry case 1 - R = squeeze(data.poincare.R(:,nz0,:)); - T = rpol*mod(squeeze(data.poincare.t(:,nz0,:)),2*pi); + R = squeeze(data.poincare.R(:,nz0,1:stp:end)); + T = rpol*mod(squeeze(data.poincare.t(:,nz0,1:stp:end)),2*pi); for i=arr %for each field line trajectory scatter(T(i,:),R(i,:),10,'.k') hold on end case 2 - R = squeeze(data.poincare.R(:,nz0,:)); - T = squeeze(data.poincare.t(:,nz0,:)); + R = squeeze(data.poincare.R(:,nz0,1:stp:end)); + T = squeeze(data.poincare.t(:,nz0,1:stp:end)); for i=arr %for each field line trajectory scatter(R(i,:).*cos(T(i,:)),R(i,:).*sin(T(i,:)),10,'.k') hold on; end case 3 - R = squeeze(data.poincare.R(:,nz0,:)); - Z = squeeze(data.poincare.Z(:,nz0,:)); + R = squeeze(data.poincare.R(:,nz0,1:stp:end)); + Z = squeeze(data.poincare.Z(:,nz0,1:stp:end)); for i=arr %for each field line trajectory scatter(R(i,:),Z(i,:),10,'.k') hold on; @@ -261,7 +277,7 @@ end if data.input.physics.Igeometry ~= 1 - scatter(Rb,Zb,bthick,'*',bcol) + scatter(Rb,Zb,bthick,'*','MarkerFaceColor',bcol,'MarkerEdgeColor',bcol) hold on set(gca,'FontSize',12) axis equal @@ -276,8 +292,10 @@ ylabel('R','FontSize',12) end - xlim([xmin xmax]) - ylim([ymin ymax]) +% xlim([xmin xmax]) +% ylim([ymin ymax]) + + set(gca,'FontSize',18) end diff --git a/Utilities/matlabtools/plot_spec_poincare_3d.m b/Utilities/matlabtools/plot_spec_poincare_3d.m new file mode 100644 index 00000000..cda8aa93 --- /dev/null +++ b/Utilities/matlabtools/plot_spec_poincare_3d.m @@ -0,0 +1,177 @@ +function plot_spec_poincare_3d( data, varargin ) +% +% PLOT_SPEC_POINCARE_3D( DATA ) +% ----------------------------- +% +% Plot parts of the 3d stellarator geometry, the Poincare plot and traces a +% field line +% +% INPUTS +% ------ +% * data: Obtained with read_spec(filename) +% * varargin: optional inputs. Can be any pairs of +% 'nt': Number of poloidal points. Default is 64 +% 'nz': Number of toroidal points. Default is 64 +% 'phiend': Plots 3d shape from phi=0 to phiend. Default is 2pi/Nfp +% 'tstart': Start field line tracing at this value of theta. Can be +% and array. Default is 0. + + +% Load the colors and some data +col = EPFL_colors; +Nvol = double(data.input.physics.Nvol); +Nfp = double(data.input.physics.Nfp); + +% Set up options +opt.nt = 64; +opt.nz = 64; +opt.phiend = 2*pi / Nfp; +opt.tstart = 0; + +l = length(varargin); +if mod(l,2)~=0 + error('Invalid number of arguments') +end + +for ii=1:l/2 + opt.(varargin{2*ii-1}) = varargin{2*ii}; +end + +opt.tstart = reshape(opt.tstart, length(opt.tstart), 1); + +% Define coordinate arrays in real space +sarr = 1; % We plot on the outermost surface, i.e. the plasma boundary +tarr = linspace(0,2*pi ,opt.nt); +zarr = linspace(0,opt.phiend ,opt.nz); + +%modB = get_spec_modB(data,Nvol,sarr,tarr,zarr); + +rzdata = get_spec_rzarr(data,Nvol,sarr,tarr,zarr); + +R = squeeze(rzdata{1}); +Z = squeeze(rzdata{2}); + + +% Construct cartesian corrdinates + +X = zeros(opt.nt,opt.nz); +Y = zeros(opt.nt,opt.nz); + +for it=1:opt.nt + for iz=1:opt.nz + X(it,iz) = R(it,iz)*cos(zarr(iz)); + Y(it,iz) = R(it,iz)*sin(zarr(iz)); + end +end + + +% Plot + +figure('Position', [200 200 900 700], 'Color', 'w') + +s = size(X); +c = zeros(s(1), s(2), 3); +c(:,:,1) = 1; +mesh(X,Y,Z,c); +hold on + +axis equal +shading interp + +xlabel('X') +ylabel('Y') +zlabel('Z') +set(gca, 'FontSize', 18 ) + +% Add white surface on plane y=0 +M = makehgtform('xrotate',pi/2); +t = hgtransform('Matrix', M); + +pshape = polyshape(X(:,1), Z(:,1)); +plot(pshape, 'Parent', t, 'FaceColor', 'w', 'FaceAlpha', 0.9 ) + + + + +% Add Poincare plot +X = squeeze(data.poincare.R(:,1,:)); + +s = size(X); + +Y = zeros(size(X)); +Z = squeeze(data.poincare.Z(:,1,:)); +for i=1:s(1) %for each field line trajectory + scatter3(X(i,:),Y(i,:),Z(i,:),10,'.k') + hold on; +end + +% Add KAM surfaces +mn = data.output.mn; +im = data.output.im; +Rbcmn = data.output.Rbc; +Rbsmn = data.output.Rbs; +Zbcmn = data.output.Zbc; +Zbsmn = data.output.Zbs; + +nt = 1024; +tarr = linspace(0, 2*pi, nt); + +X = zeros(Nvol,nt); +Y = zeros(Nvol,nt); +for i=1:Nvol + for k=1:mn + alpha = double(im(k))*tarr; %phi = 0 + X(i,:) = X(i,:) + Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha); + Y(i,:) = Y(i,:) + Zbsmn(k,i+1)*sin(alpha) + Zbcmn(k,i+1)*cos(alpha); + end +end + +for i=1:size(X,1) + scatter3(X(i,:),zeros(nt,1),Y(i,:),3,'filled','MarkerFaceColor','r','MarkerEdgeColor','r') + hold on +end + +% Add a field line +tarr = opt.tstart; + + +if ~isempty(tarr) + phi = 0; + + nstep = 1024; + dstep = opt.phiend/1024; + + for istep=1:nstep + phi(istep+1) = phi(istep) + dstep; + + B = get_spec_magfield( data, Nvol, 1, tarr(:,istep), phi(istep) ); + + Bt = reshape(B{2}, length(B{2}), 1); + Bz = reshape(B{3}, length(B{2}), 1); + + tarr(:,istep+1) = tarr(:,istep) + Bt./Bz * dstep; + + end + + X = []; + Y = []; + Z = []; + for ii = 1:nstep + rzdata = get_spec_rzarr(data,Nvol,1,tarr(ii),phi(ii)); + + X(ii) = squeeze(rzdata{1}) * cos(phi(ii)); + Y(ii) = squeeze(rzdata{1}) * sin(phi(ii)); + Z(ii) = squeeze(rzdata{2}); + end + + scatter3( X, Y, Z, 10, 'MarkerFaceColor', col.Leman, 'MarkerEdgeColor', col.Leman) +end + + + + + + + + +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_pressure.m b/Utilities/matlabtools/plot_spec_pressure.m index 94e40b75..9a856887 100644 --- a/Utilities/matlabtools/plot_spec_pressure.m +++ b/Utilities/matlabtools/plot_spec_pressure.m @@ -1,4 +1,4 @@ -function plot_spec_pressure(data, norm, newfig) +function plot_spec_pressure(data, norm, newfig, varargin) % % PLOT_SPEC_PRESSURE( DATA, NEWFIG ) @@ -15,6 +15,21 @@ function plot_spec_pressure(data, norm, newfig) % written by J.Loizu (2018) % modified by A. Baillod (2019) +l = length(varargin); +if mod(l,2)~=0 + error('Invalid number of argument') +end + +opt.Color='b'; +opt.LineWidth=2.0; +for ii=1:l/2 + value = varargin{2*ii}; + field = varargin{2*ii-1}; + + opt.(field)=value; +end + + pvol = data.input.physics.pressure * data.input.physics.pscale; @@ -42,28 +57,30 @@ function plot_spec_pressure(data, norm, newfig) hold off end +% First volume p0(1:end) = pvol(1); tmin = 0; tmax = tfl(1); tarr = linspace(tmin,tmax,10); -plot(tarr,p0,'b') +plot(tarr,p0,'Color',opt.Color,'LineWidth',opt.LineWidth) hold on x = [tfl(1),tfl(1)]; if Nvol>1 y = [pvol(2) pvol(1)]; - plot(x,y,'b') + plot(x,y,'Color',opt.Color,'LineWidth',opt.LineWidth) end +% Next volumes for i=2:Nvol-1 p0(1:end) = pvol(i); tmin = tfl(i-1); tmax = tfl(i); tarr = linspace(tmin,tmax,10); - plot(tarr,p0,'b') + plot(tarr,p0,'Color',opt.Color,'LineWidth',opt.LineWidth) x = [tfl(i),tfl(i)]; y = [pvol(i+1) pvol(i)]; - plot(x,y,'b') + plot(x,y,'Color',opt.Color,'LineWidth',opt.LineWidth) end @@ -72,10 +89,10 @@ function plot_spec_pressure(data, norm, newfig) tmin = tfl(Nvol-1); tmax = tfl(Nvol); tarr = linspace(tmin,tmax,10); - plot(tarr,p0,'b') + plot(tarr,p0,'Color',opt.Color,'LineWidth',opt.LineWidth) x = [tfl(Nvol),tfl(Nvol)]; y = [0 pvol(Nvol)]; - plot(x,y,'b') + plot(x,y,'Color',opt.Color,'LineWidth',opt.LineWidth) end if( norm ) @@ -85,7 +102,7 @@ function plot_spec_pressure(data, norm, newfig) xlabel('$\Psi / \Psi_{edge}$', 'Interpreter', 'latex') if (pmin~=0 || pmax~=0) - ylim([0.9*pmin, 1.1*pmax]); + ylim([0, 1.1*pmax]); end set(gcf, 'Color', 'w') diff --git a/Utilities/matlabtools/read_spec.m b/Utilities/matlabtools/read_spec.m index e155d329..9c2746a1 100644 --- a/Utilities/matlabtools/read_spec.m +++ b/Utilities/matlabtools/read_spec.m @@ -150,5 +150,47 @@ data.grid.Bp = cBp; data.grid.BZ = cBZ; +% generate flux surfaces instances for boundary and initial guess +Nfp = double(data.input.physics.Nfp); +Nvol = data.input.physics.Nvol; +Mpol = data.input.physics.Mpol; +Ntor = data.input.physics.Ntor; +stellsym = data.input.physics.Istellsym; + +% Computational boundary +fsurf = fluxSurface( Nfp, Mpol, Ntor, stellsym); + +im = data.output.im; +in = data.output.in / Nfp; +fsurf = fsurf.set_array( 'rmnc', data.output.Rbc(:,end), im, in ); +fsurf = fsurf.set_array( 'zmns', data.output.Zbs(:,end), im, in ); + +if ~stellsym + fsurf = fsurf.set_array( 'rmns', data.output.Rbs(:,end), im, in ); + fsurf = fsurf.set_array( 'zmnc', data.output.Zbc(:,end), im, in ); +end + +data.output.computationalBoundary = fsurf; + +% Initial guess +data.physicslist.KAMSurfaces = cell(1,Nvol); +for ivol=1:Mvol + + fsurf = fluxSurface( Nfp, Mpol, Ntor, stellsym); + + fsurf = fsurf.set_array( 'rmnc', data.output.Rbc(:,ivol+1), im, in ); + fsurf = fsurf.set_array( 'zmns', data.output.Zbs(:,ivol+1), im, in ); + + if ~stellsym + fsurf = fsurf.set_array( 'rmns', data.output.Rbs(:,ivol+1), im, in ); + fsurf = fsurf.set_array( 'zmnc', data.output.Zbc(:,ivol+1), im, in ); + end + + data.output.KAMSurface{ivol} = fsurf; + + +end + + end diff --git a/Utilities/matlabtools/write_spec_Bxyz.m b/Utilities/matlabtools/write_spec_Bxyz.m new file mode 100644 index 00000000..cbd82530 --- /dev/null +++ b/Utilities/matlabtools/write_spec_Bxyz.m @@ -0,0 +1,32 @@ +function write_spec_Bxyz( data, filename ) + +nt = length(data.theta); +nz = length(data.phi); + +fid = fopen( filename, 'w' ); + +fprintf( fid, 'theta phi x y z Bx By Bz\n') + + +for it = 1:nt + for iz = 1:nz + + theta = data.theta(it); + phi = data.phi(iz); + x = data.x(1,it,iz); + y = data.y(1,it,iz); + z = data.z(1,it,iz); + Bx = data.Bx(1,it,iz); + By = data.By(1,it,iz); + Bz = data.Bz(1,it,iz); + + + %fprintf(fid,'%s', A{i}); + fprintf( fid, '%12.8E %12.8E %+12.8E %+12.8E %+12.8E %+12.8E %+12.8E %+12.8E\n', ... + theta, phi, x, y, z, Bx, By, Bz) + + end +end + +fclose(fid); +end From d921579664cac3d3d735cf0c6a955cbbde2360cc Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 5 May 2022 15:23:33 +0200 Subject: [PATCH 003/134] Cleaning up the matlab routines; work in progress... --- Utilities/matlabtools/compare_spec_outputs.m | 8 + Utilities/matlabtools/contra2cov.m | 103 ++++----- Utilities/matlabtools/fdata_from_data.m | 31 --- Utilities/matlabtools/gdata_from_data.m | 17 -- Utilities/matlabtools/get_full_field.m | 104 --------- Utilities/matlabtools/get_spec_Bgrid.m | 46 ---- Utilities/matlabtools/get_spec_Bxyz.m | 28 +-- .../matlabtools/get_spec_R_derivatives.m | 116 +++++----- Utilities/matlabtools/get_spec_area.m | 6 +- Utilities/matlabtools/get_spec_energy_slab.m | 75 ++++--- Utilities/matlabtools/get_spec_fourier.m | 55 ----- ...c_fractaldim_2.m => get_spec_fractaldim.m} | 150 ++++--------- .../matlabtools/get_spec_helicity_slab.m | 97 +++++---- Utilities/matlabtools/get_spec_jacobian.m | 31 +-- Utilities/matlabtools/get_spec_metric.m | 97 +++++---- .../matlabtools/get_spec_metric_contrav.m | 85 +++----- Utilities/matlabtools/get_spec_modB.m | 18 +- Utilities/matlabtools/get_spec_polflux.m | 28 ++- .../matlabtools/get_spec_polynomial_basis.m | 187 ++++++++-------- Utilities/matlabtools/get_spec_radius.m | 56 ----- .../get_spec_regularisation_factor.m | 112 +++++----- Utilities/matlabtools/get_spec_rtarr.m | 61 ------ Utilities/matlabtools/get_spec_rzarr.m | 63 ------ .../matlabtools/get_spec_surface_current.m | 66 ------ .../matlabtools/get_spec_torcurr_kam_net.m | 13 +- Utilities/matlabtools/get_spec_torflux.m | 55 +++-- Utilities/matlabtools/get_spec_vecpot.m | 26 ++- Utilities/matlabtools/get_spec_volume.m | 32 ++- .../matlabtools/get_spec_volume_current.m | 52 ++--- Utilities/matlabtools/idata_from_data.m | 20 -- Utilities/matlabtools/pdata_from_data.m | 34 --- Utilities/matlabtools/plot_spec_Bfield.m | 66 ------ Utilities/matlabtools/plot_spec_Bgrid.m | 199 ++++++++++-------- Utilities/matlabtools/plot_spec_Jvolume.m | 113 ---------- Utilities/matlabtools/plot_spec_fluxfun.m | 70 ++++++ Utilities/matlabtools/plot_spec_jacobian.m | 91 ++++---- Utilities/matlabtools/plot_spec_modB.m | 8 +- .../matlabtools/plot_spec_modB_boundary.m | 8 +- Utilities/matlabtools/plot_spec_outfluxfun.m | 41 ---- Utilities/matlabtools/plot_spec_poincare_3d.m | 20 +- Utilities/matlabtools/plot_spec_polflux.m | 3 +- .../matlabtools/plot_spec_surface_current.m | 57 +++++ Utilities/matlabtools/plot_spec_surfcurent.m | 49 ----- Utilities/matlabtools/run_spec.m | 48 +++++ 44 files changed, 1015 insertions(+), 1630 deletions(-) delete mode 100644 Utilities/matlabtools/fdata_from_data.m delete mode 100644 Utilities/matlabtools/gdata_from_data.m delete mode 100644 Utilities/matlabtools/get_full_field.m delete mode 100644 Utilities/matlabtools/get_spec_Bgrid.m delete mode 100644 Utilities/matlabtools/get_spec_fourier.m rename Utilities/matlabtools/{get_spec_fractaldim_2.m => get_spec_fractaldim.m} (70%) delete mode 100644 Utilities/matlabtools/get_spec_radius.m delete mode 100644 Utilities/matlabtools/get_spec_rtarr.m delete mode 100644 Utilities/matlabtools/get_spec_rzarr.m delete mode 100644 Utilities/matlabtools/get_spec_surface_current.m delete mode 100644 Utilities/matlabtools/idata_from_data.m delete mode 100644 Utilities/matlabtools/pdata_from_data.m delete mode 100644 Utilities/matlabtools/plot_spec_Bfield.m delete mode 100644 Utilities/matlabtools/plot_spec_Jvolume.m create mode 100644 Utilities/matlabtools/plot_spec_fluxfun.m delete mode 100644 Utilities/matlabtools/plot_spec_outfluxfun.m create mode 100644 Utilities/matlabtools/plot_spec_surface_current.m delete mode 100644 Utilities/matlabtools/plot_spec_surfcurent.m create mode 100644 Utilities/matlabtools/run_spec.m diff --git a/Utilities/matlabtools/compare_spec_outputs.m b/Utilities/matlabtools/compare_spec_outputs.m index f52cbe1e..30da8e99 100644 --- a/Utilities/matlabtools/compare_spec_outputs.m +++ b/Utilities/matlabtools/compare_spec_outputs.m @@ -1,19 +1,27 @@ function [Dabs, Drel, df] = compare_spec_outputs(data1,data2) +% +% COMPARE_SPEC_OUTPUTS( DATA1, DATA2 ) +% ==================================== +% % Compares the interface geometry of two spec outputs % Two outputs are considered "the same" if df ~ 1e-15 (or less) % % INPUT +% ----- % - data1: data obtained via read_spec( fname1 ) % - data2: data obtained via read_spec( fname2 ) % % OUTPUT +% ------ % - Dabs : absolute maximum distance % - Drel : relative maximum distance % - df : expected change in force-balance if one output is used as input for the other run % % written by J.Loizu (08.2017) % modified by J.Loizu (10.2017) +% +% TODO: UPDATE - IS THIS STILL CORRECT ? % % Rmn1 = h5read(fname1,'/Rbc'); diff --git a/Utilities/matlabtools/contra2cov.m b/Utilities/matlabtools/contra2cov.m index 63bbac77..be901b7c 100644 --- a/Utilities/matlabtools/contra2cov.m +++ b/Utilities/matlabtools/contra2cov.m @@ -20,74 +20,61 @@ % OUTPUT % ------ % vcov: covariant vector as a function v +% +% -% Read geometry -G = data.input.physics.Igeometry; - - -% Get R derivatives -[s, R] = get_spec_R_derivatives(data, vol, s, theta, phi, 'R'); -[s, Z] = get_spec_R_derivatives(data, vol, s, theta, phi, 'Z'); - - -nt = length(theta); -np = length(phi); -ns = length(s); - -% transform in covariant basis -g = get_spec_metric(data, vol, s, theta, phi); - -switch G - case 1 - norm1 = sqrt(1 + R{3}.^2 + R{4}.^2) ./ R{2}; - norm2 = ones(size(R{1})); - norm3 = ones(size(R{1})); - - case 2 - norm1 = sqrt(R{3}.^2 + R{1}.^2 + (R{1}.*R{4}).^2) ./ (R{2}.*R{1}); - norm2 = 1 ./ R{1}; - norm3 = ones(size(R{1})); - - case 3 - norm1 = sqrt((R{3}.*Z{4}).^2 + (R{4}.*Z{3}).^2 + (R{1}.*Z{3}).^2 ... - -2*R{3}.*R{4}.*Z{3}.*Z{4} + (R{1}.*R{3}).^2); - norm2 = sqrt((R{4}.*Z{2}).^2 + (R{1}.*Z{2}).^2 + (R{2}.*Z{4}).^2 + (R{1}.*R{2}).^2 ... - -2*R{2}.*R{4}.*Z{2}.*Z{4}); - norm3 = sqrt((R{2}.*Z{3}).^2 + (R{3}.*Z{2}).^2 -2*R{2}.*R{3}.*Z{2}.*Z{3}); - -end +% TODO: test - is this useful ? -% Compute covariant components -temp = cell(1,3); -vcov = cell(1,3); -for ii=1:3 - temp{ii} = zeros(ns, nt, np); - vcov{ii} = zeros(ns, nt, np); -end + % Read geometry + G = data.input.physics.Igeometry; + % Get R derivatives + R = get_spec_R_derivatives(data, vol, s, theta, phi, 'R'); + Z = get_spec_R_derivatives(data, vol, s, theta, phi, 'Z'); -for is = 1:ns - for it = 1:nt - for ip = 1:np - temp{1} = vcontrav{1}.*g{1}{1} + vcontrav{2}.*g{1}{2} + vcontrav{3}.*g{1}{3}; - temp{2} = vcontrav{1}.*g{2}{1} + vcontrav{2}.*g{2}{2} + vcontrav{3}.*g{2}{3}; - temp{3} = vcontrav{1}.*g{3}{1} + vcontrav{2}.*g{3}{2} + vcontrav{3}.*g{3}{3}; - end + % transform in covariant basis + g = get_spec_metric(data, vol, s, theta, phi); + + % Compute covariant components + vcov = cell(1,3); + + for ii=1:3 + vcov{ii} = zeros(size(vcontrav)); end -end -% Normalize to canonical basis if necessary -if norm - vcov{1} = temp{1} .* norm1; - vcov{2} = temp{2} .* norm2; - vcov{3} = temp{3} .* norm3; -else - vcov = temp; -end + vcov{1} = vcontrav{1}.*g{1,1} + vcontrav{2}.*g{1,2} + vcontrav{3}.*g{1,3}; + vcov{2} = vcontrav{1}.*g{2,1} + vcontrav{2}.*g{2,2} + vcontrav{3}.*g{2,3}; + vcov{3} = vcontrav{1}.*g{3,1} + vcontrav{2}.*g{3,2} + vcontrav{3}.*g{3,3}; + + % Normalize to canonical basis (unit vector) if necessary + if norm + + switch G + case 1 + norm1 = sqrt(1 + R{3}.^2 + R{4}.^2) ./ R{2}; + norm2 = ones(size(R{1})); + norm3 = ones(size(R{1})); + + case 2 + norm1 = sqrt(R{3}.^2 + R{1}.^2 + (R{1}.*R{4}).^2) ./ (R{2}.*R{1}); + norm2 = 1 ./ R{1}; + norm3 = ones(size(R{1})); + case 3 + norm1 = sqrt((R{3}.*Z{4}).^2 + (R{4}.*Z{3}).^2 + (R{1}.*Z{3}).^2 ... + -2*R{3}.*R{4}.*Z{3}.*Z{4} + (R{1}.*R{3}).^2); + norm2 = sqrt((R{4}.*Z{2}).^2 + (R{1}.*Z{2}).^2 + (R{2}.*Z{4}).^2 + (R{1}.*R{2}).^2 ... + -2*R{2}.*R{4}.*Z{2}.*Z{4}); + norm3 = sqrt((R{2}.*Z{3}).^2 + (R{3}.*Z{2}).^2 -2*R{2}.*R{3}.*Z{2}.*Z{3}); + end + + vcov{1} = vcov{1} .* norm1; + vcov{2} = vcov{2} .* norm2; + vcov{3} = vcov{3} .* norm3; + end end diff --git a/Utilities/matlabtools/fdata_from_data.m b/Utilities/matlabtools/fdata_from_data.m deleted file mode 100644 index 51277fd8..00000000 --- a/Utilities/matlabtools/fdata_from_data.m +++ /dev/null @@ -1,31 +0,0 @@ -function fdata = fdata_from_data(data) - -% Reads magnetic vector potential data using output from SPEC -% -% INPUT -% - data : data file obtained from read_spec(filename) -% -% OUTPUT -% - pdata : contains all the poincare data, which can be fed into several routines for analyzing and ploting -% -% written by A. Baillod (2019) - - -nvol = double(data.input.physics.Nvol); -Lfreebound = data.input.physics.Lfreebound; -Lrad = data.input.physics.Lrad; - - -fdata = data.input.physics; - -f = fieldnames(data.output); -for i = 1:length(f) -fdata.(f{i}) = data.output.(f{i}); -end - -f = fieldnames(data.vector_potential); -for i = 1:length(f) - fdata.(f{i}) = data.vector_potential.(f{i}); -end - -fdata.Mregular = data.input.numerics.Mregular; diff --git a/Utilities/matlabtools/gdata_from_data.m b/Utilities/matlabtools/gdata_from_data.m deleted file mode 100644 index 5d4ce69d..00000000 --- a/Utilities/matlabtools/gdata_from_data.m +++ /dev/null @@ -1,17 +0,0 @@ -function gdata = gdata_from_data(data) - - -gdata = data.grid; -gdata.mn = data.output.mn; -gdata.im = data.output.im; -gdata.in = data.output.in; -gdata.Rbc = data.output.Rbc; -gdata.Rbs = data.output.Rbs; -gdata.Zbc = data.output.Zbc; -gdata.Zbs = data.output.Zbs; -gdata.Igeometry = data.input.physics.Igeometry; -gdata.Mregular = data.input.numerics.Mregular; - - - -end \ No newline at end of file diff --git a/Utilities/matlabtools/get_full_field.m b/Utilities/matlabtools/get_full_field.m deleted file mode 100644 index 0fbb0138..00000000 --- a/Utilities/matlabtools/get_full_field.m +++ /dev/null @@ -1,104 +0,0 @@ -function B = get_full_field(data, r, theta, zeta, nr) - -% -% GET_FULL_FIELD( DATA, R, THETA, ZETA, NR ) -% ========================================== -% -% Return SPEC magnetic field solution componants as a function of r, theta, -% zeta. The coordinate r is constructed from the radial position of the -% volume interface for a given pair (theta, zeta) and from the coordinate -% s. -% -% INPUT -% ----- -% data: data obtained from read_spec(filename) -% r: Radial coordinate (array of doubles) -% theta: Theta coordinate (double) -% zeta: Zeta coordinate (double) -% nr: Number of points in each volume for radial interpolation -% -% OUTPUT -% ------ -% B: 3xlength(r)xlength(theta)xlength array containing the B field solution -% interpolated at r -% -% Written by A.Baillod(2019) - - -% Load data -G = data.input.physics.Igeometry; -Nvol = data.output.Mvol; - -epsilon = 1E-16; - -nt = length(theta); -nz = length(zeta); - -B_temp = zeros(3, nr*Nvol, nt, nz); % Allocate memory -r_temp = zeros(1, nr*Nvol, nt, nz); % Allocate memory - -iimin = 1; -iimax = 0; - -r0 = get_spec_radius(data, theta, zeta, 0); -B = zeros(3,length(r),nt,nz); -for i=1:Nvol - - % if first volume, don't take rmin=0 - if i==1 - rmin = epsilon; - else - [ri, zi] = get_spec_radius(data, theta, zeta, i-1); - rmin = sqrt((ri-r0)^2+zi^2); - end - - [ri, zi] = get_spec_radius(data, theta, zeta, i); - rmax = sqrt((ri-r0)^2+zi^2); - - r_vol = linspace(rmin, rmax, nr+1); % Minor radius - r_vol = r_vol(2:end); - - if i==1 - if G == 1 - sarr = 2.0 * (r_vol - rmin) ./ (rmax - rmin) - 1; - else - sarr = 2.0 * ((r_vol - rmin) ./ (rmax - rmin)).^2 - 1; - end - else - sarr = 2.0 * (r_vol - rmin) ./ (rmax - rmin) - 1; - end - Bcontrav = get_spec_magfield(data, i, sarr, theta, zeta); - - % Generate radial coordinate array - iimax = iimax + length(r_vol); - r_temp(iimin:iimax) = r_vol; - - % And convert it to covariant basis (normalized here) - B_cov = contra2cov(data, i, Bcontrav, sarr, theta, zeta, 1); - - B_temp(1, iimin:iimax, :, :) = B_cov{1}; - B_temp(2, iimin:iimax, :, :) = B_cov{2}; - B_temp(3, iimin:iimax, :, :) = B_cov{3}; - - iimin = iimin + length(r_vol); - - - for comp = 1:3 - ind = find(r<=rmax); - r_int = r(ind); - ind = find(r_int>=rmin); - r_int = r_int(ind); - - for j = 1:nt - for k = 1:nz - B(comp, ind, j, k) = interp1(r_vol, B_cov{comp}(:,j,k), r_int, 'spline'); - end - end - end -end - - - - - - diff --git a/Utilities/matlabtools/get_spec_Bgrid.m b/Utilities/matlabtools/get_spec_Bgrid.m deleted file mode 100644 index 3a23c259..00000000 --- a/Utilities/matlabtools/get_spec_Bgrid.m +++ /dev/null @@ -1,46 +0,0 @@ -function bdata = get_spec_Bgrid(data,nz0,lvol) - -% -% GET_SPEC_BGRID( DATA, NZ0, LVOL ) -% ================================= -% -% Obtains the canonical cylindrical components of B, namely (B^R, R*B^phi, B^Z), on the coordinate grid points -% -% INPUT -% ----- -% -data : must be produced by calling read_spec(filename) -% -nz0 : toroidal plane number at which B is obtained (nz0=1 at toroidal angle phi=0) -% -lvol : volume number in which B is obtained -% -% OUTPUT -% ------ -% -bdata : cell of size 5 containing the values of R, Z, B^R, R*B^phi, B^Z on the grid points -% -% written by J.Loizu (2018) - -Lrad = data.input.physics.Lrad; -Nt = data.grid.Nt; -Nz = data.grid.Nz; - -Rij = data.grid.Rij; -Zij = data.grid.Zij; -BR = data.grid.BR; -Bp = data.grid.Bp; -BZ = data.grid.BZ; - -iz = nz0-1; -ngrid = Lrad(lvol)+1; - -if(lvol==1) - nstart = 2; -else - nstart = 1; -end - -bdata{1} = squeeze(Rij(lvol,1+Nt*iz:(iz+1)*Nt,nstart:ngrid)); -bdata{2} = squeeze(Zij(lvol,1+Nt*iz:(iz+1)*Nt,nstart:ngrid)); -bdata{3} = squeeze(BR(lvol,1+Nt*iz:(iz+1)*Nt,nstart:ngrid)); -bdata{4} = squeeze(Bp(lvol,1+Nt*iz:(iz+1)*Nt,nstart:ngrid)).*bdata{1}; -bdata{5} = squeeze(BZ(lvol,1+Nt*iz:(iz+1)*Nt,nstart:ngrid)); - - diff --git a/Utilities/matlabtools/get_spec_Bxyz.m b/Utilities/matlabtools/get_spec_Bxyz.m index 81071b48..726afb79 100644 --- a/Utilities/matlabtools/get_spec_Bxyz.m +++ b/Utilities/matlabtools/get_spec_Bxyz.m @@ -18,6 +18,12 @@ % Written by A. Baillod (2021) % +% Check input +Igeometry = data.input.physics.Igeometry; +if Igeometry~=3 + error('Invalide geometry') +end + % Read some input from data Mvol = data.output.Mvol; @@ -25,17 +31,7 @@ error('invalid volume') end -im = data.output.im; -in = data.output.in; - -Rbc = data.output.Rbc(:,Mvol-1); -Rbs = data.output.Rbs(:,Mvol-1); -Zbc = data.output.Zbc(:,Mvol-1); -Zbs = data.output.Zbs(:,Mvol-1); - -mn = length(Rbc); - -% Start by building the grid and compute (R,Z,phi) coords +% Reshape input ns = length(sarr); sarr = reshape( sarr, 1, ns); @@ -45,11 +41,8 @@ nz = length(zarr); phi = reshape( zarr, 1, nz ); - -[t_grid, z_grid] = meshgrid( theta, phi ); - -[tmp, Rarr] = get_spec_R_derivatives( data, Mvol, sarr, theta, phi, 'R' ); -[tmp, Zarr] = get_spec_R_derivatives( data, Mvol, sarr, theta, phi, 'Z' ); +Rarr = get_spec_R_derivatives( data, Mvol, sarr, theta, phi, 'R' ); +Zarr = get_spec_R_derivatives( data, Mvol, sarr, theta, phi, 'Z' ); % Transform to cartesian coordinates (x,y,z) @@ -84,7 +77,6 @@ Rt = reshape( Rarr{3}(is,it,:), 1, nz ); Rz = reshape( Rarr{4}(is,it,:), 1, nz ); - Z = reshape( Zarr{1}(is,it,:), 1, nz ); Zs = reshape( Zarr{2}(is,it,:), 1, nz ); Zt = reshape( Zarr{3}(is,it,:), 1, nz ); Zz = reshape( Zarr{4}(is,it,:), 1, nz ); @@ -97,7 +89,7 @@ + Bphi.*(Rz.*sin(phi) + R.*cos(phi)); Bz(is,it,:) = Bs.*Zs ... + Bt.*Zt ... - + Bphi.*Zz + + Bphi.*Zz; end xyz.theta = theta; diff --git a/Utilities/matlabtools/get_spec_R_derivatives.m b/Utilities/matlabtools/get_spec_R_derivatives.m index 24c75857..67b51cf8 100644 --- a/Utilities/matlabtools/get_spec_R_derivatives.m +++ b/Utilities/matlabtools/get_spec_R_derivatives.m @@ -1,4 +1,4 @@ -function [sarr, out] = get_spec_R_derivatives(data, vol, sarr, tarr, zarr, RorZ) +function out = get_spec_R_derivatives(data, vol, sarr, tarr, zarr, RorZ) % % GET_SPEC_R_DERIVATIVES( DATA, VOL, SARR, TARR, ZARR, RORZ ) @@ -25,67 +25,75 @@ % Written by A.Baillod (2019) % + % Test input + Istellsym = data.input.physics.Istellsym; + if Istellsym~=1 + error('Only implemented for stellarator symmetric equilibria') + end -% Load geometry -mn = data.output.mn; -im = double(data.output.im); -in = double(data.output.in); -Rmn = data.output.Rbc(:,vol ); -Rmn_p = data.output.Rbc(:,vol+1); -Zmn = data.output.Zbs(:,vol ); -Zmn_p = data.output.Zbs(:,vol+1); - -% Allocate data for R and its derivative in s, theta and phi (4), for each -% and for ns points -ns = length(sarr); -nt = length(tarr); -nz = length(zarr); -Rarr = cell(1,4); -Zarr = cell(1,4); -for ii=1:4 - Rarr{ii} = zeros(ns, nt, nz); - Zarr{ii} = zeros(ns, nt, nz); -end + % Load geometry + mn = data.output.mn; + im = double(data.output.im); + in = double(data.output.in); + Rmn = data.output.Rbc(:,vol ); + Rmn_p = data.output.Rbc(:,vol+1); + Zmn = data.output.Zbs(:,vol ); + Zmn_p = data.output.Zbs(:,vol+1); -% Compute the regularisation factor -factor = get_spec_regularisation_factor(data, vol, sarr, 'G'); - -% And R derivatives -if RorZ=='R' - for imn=1:mn - for it=1:nt - for iz=1:nz - cosa = cos(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); - sina = sin(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); - - Rarr{1}(:,it,iz) = Rarr{1}(:,it,iz) + ( Rmn(imn) + (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{1}) * cosa; - Rarr{2}(:,it,iz) = Rarr{2}(:,it,iz) + ( (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{2}) * cosa; - Rarr{3}(:,it,iz) = Rarr{3}(:,it,iz) - ( Rmn(imn) + (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{1}) * double(im(imn)) * sina; - Rarr{4}(:,it,iz) = Rarr{4}(:,it,iz) + ( Rmn(imn) + (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{1}) * double(in(imn)) * sina; - end + % Allocate data for R and its derivative in s, theta and phi (4), for each + % and for ns points + ns = length(sarr); + nt = length(tarr); + nz = length(zarr); + Rarr = cell(1,4); + Zarr = cell(1,4); + + for ii=1:4 + Rarr{ii} = zeros(ns, nt, nz); + Zarr{ii} = zeros(ns, nt, nz); end - end - out = Rarr; - -elseif RorZ=='Z' - for imn=1:mn - for it=1:nt - for iz=1:nz - cosa = cos(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); - sina = sin(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); - Zarr{1}(:,it,iz) = Zarr{1}(:,it,iz) + ( Zmn(imn) + (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{1}) * sina; - Zarr{2}(:,it,iz) = Zarr{2}(:,it,iz) + ( (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{2}) * sina; - Zarr{3}(:,it,iz) = Zarr{3}(:,it,iz) + ( Zmn(imn) + (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{1}) * double(im(imn))* cosa; - Zarr{4}(:,it,iz) = Zarr{4}(:,it,iz) - ( Zmn(imn) + (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{1}) * double(in(imn))* cosa; + % Compute the regularisation factor + factor = get_spec_regularisation_factor(data, vol, sarr, 'G'); + + % And R derivatives + if RorZ=='R' + for imn=1:mn + for it=1:nt + for iz=1:nz + cosa = cos(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); + sina = sin(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); + + Rarr{1}(:,it,iz) = Rarr{1}(:,it,iz) + ( Rmn(imn) + (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{1}) * cosa; + Rarr{2}(:,it,iz) = Rarr{2}(:,it,iz) + ( (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{2}) * cosa; + Rarr{3}(:,it,iz) = Rarr{3}(:,it,iz) - ( Rmn(imn) + (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{1}) * double(im(imn)) * sina; + Rarr{4}(:,it,iz) = Rarr{4}(:,it,iz) + ( Rmn(imn) + (Rmn_p(imn) - Rmn(imn)) .* factor{imn}{1}) * double(in(imn)) * sina; + end + end end + out = Rarr; + + elseif RorZ=='Z' + for imn=1:mn + for it=1:nt + for iz=1:nz + cosa = cos(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); + sina = sin(double(im(imn)*tarr(it) - in(imn)*zarr(iz))); + + Zarr{1}(:,it,iz) = Zarr{1}(:,it,iz) + ( Zmn(imn) + (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{1}) * sina; + Zarr{2}(:,it,iz) = Zarr{2}(:,it,iz) + ( (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{2}) * sina; + Zarr{3}(:,it,iz) = Zarr{3}(:,it,iz) + ( Zmn(imn) + (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{1}) * double(im(imn))* cosa; + Zarr{4}(:,it,iz) = Zarr{4}(:,it,iz) - ( Zmn(imn) + (Zmn_p(imn) - Zmn(imn)) .* factor{imn}{1}) * double(in(imn))* cosa; + end + end + end + out = Zarr; + + else + error(['Not defined for RorZ=',RorZ]); end - end - out = Zarr; -else - error(['Not defined for RorZ=',RorZ]); end diff --git a/Utilities/matlabtools/get_spec_area.m b/Utilities/matlabtools/get_spec_area.m index 7481f7d0..a2389a41 100644 --- a/Utilities/matlabtools/get_spec_area.m +++ b/Utilities/matlabtools/get_spec_area.m @@ -26,14 +26,16 @@ smin = -0.999; %avoids singular inversion of the metric matrix +% Define arrays sarr = linspace(smin,smax,ns); tarr = linspace(0,2*pi,nt); +% Evaluate Jacobian and metric jacobian = get_spec_jacobian(data,lvol,sarr,tarr,phi0); gcontrav = get_spec_metric_contrav(data,lvol,sarr,tarr,phi0); - sqrtgradphi = sqrt(gcontrav{3}{3}); -Avol = sum(sum(jacobian(2:end,:).*sqrtgradphi(2:end,:)))*(2*2*pi)/(ns*nt); +% Evaluate area +Avol = trapz(tarr, trapz(sarr, jacobian.*sqrtgradphi, 1) ); end diff --git a/Utilities/matlabtools/get_spec_energy_slab.m b/Utilities/matlabtools/get_spec_energy_slab.m index 222efe14..fab2d59d 100644 --- a/Utilities/matlabtools/get_spec_energy_slab.m +++ b/Utilities/matlabtools/get_spec_energy_slab.m @@ -22,44 +22,41 @@ % % written by J.Loizu (2018) -Nvol = data.input.physics.Nvol; - -W = 0; - -sarr = linspace(-1,1,ns); -tarr = linspace(0,2*pi,nt); -zarr = linspace(0,2*pi,nz); - -if(lv==0) - - for lvol=1:Nvol - - modB = get_spec_modB(data,lvol,sarr,tarr,zarr); - - jac = get_spec_jacobian_slab(data,lvol,sarr,tarr,zarr); - - F = jac.*modB.^2; - - dW = trapz(sarr,trapz(tarr,trapz(zarr,F,3),2)); - - W = W + 0.5*dW; - - end - -else - - lvol = lv; - - modB = get_spec_modB(data,lvol,sarr,tarr,zarr); - - jac = get_spec_jacobian_slab(data,lvol,sarr,tarr,zarr); - - F = jac.*modB.^2; - - dW = trapz(sarr,trapz(tarr,trapz(zarr,F,3),2)); - - W = W + 0.5*dW; - -end + % Test input + Igeometry = data.input.physics.Igeometry; + if Igeometry~=1 + error('This routine is only for slab geometries') + end + + % Read data + Nvol = data.input.physics.Nvol; + + W = 0; + + sarr = linspace(-1,1,ns); + tarr = linspace(0,2*pi,nt); + zarr = linspace(0,2*pi,nz); + + if(lv==0) + lvol_start=1; + lvol_end =Nvol; + else + lvol_start=lv; + lvol_end =lv; + end + + + for lvol=lvol_start:lvol_end + + % Evaluate mod B and jacobian + modB = get_spec_modB(data,lvol,sarr,tarr,zarr); + jac = get_spec_jacobian(data,lvol,sarr,tarr,zarr); + + % Integrate + F = jac.*modB.^2; + + dW = trapz(sarr,trapz(tarr,trapz(zarr,F,3),2)); + W = W + 0.5*dW; + end diff --git a/Utilities/matlabtools/get_spec_fourier.m b/Utilities/matlabtools/get_spec_fourier.m deleted file mode 100644 index 7300d408..00000000 --- a/Utilities/matlabtools/get_spec_fourier.m +++ /dev/null @@ -1,55 +0,0 @@ -function rmn = get_spec_fourier( data, surface_index, Mpol, Ntor ) -% -% GET_SPEC_FOURIER( DATA, SURFACE_INDEX, MPOL, NTOR ) -% =================================================== -% -% Extract the fourier harmonics from a SPEC Poincaré data -% -% INPUTS -% ------ -% - DATA: obtained via read_spec() -% - SURFACE_INDEX: index of surface you want to target -% - MPOL: Poloidal resolution -% - NTOR: Toroidal resolution -% -% OUTPUT -% ------ -% - RMN: fluxSurface instance containing the fourier harmonics of the flux -% surface -% -% - - Nfp = double(data.input.physics.Nfp); - stellsym = 1; - rmn = fluxSurface( Nfp, Mpol, Ntor, stellsym ); - - - R = data.poincare.R( surface_index, :, : ); - Z = data.poincare.Z( surface_index, :, : ); - - s = size(R); - - R = reshape(R, s(2), s(3)); - Z = reshape(Z, s(2), s(3)); - - s = size(R); - nz = s(1); - - phi = (0:nz-1.0)*(2.0*pi/nz)/Nfp; - - rmn_axis = data.output.Rbc(1:data.input.physics.Ntor+1,1); - zmn_axis = data.output.Zbs(1:data.input.physics.Ntor+1,1); - - r_axis = zeros(1, nz); - z_axis = zeros(1, nz); - for n=0:double(data.input.physics.Ntor) - - r_axis = r_axis + rmn_axis(n+1) * cos(n*Nfp*phi); - z_axis = z_axis - zmn_axis(n+1) * sin(n*Nfp*phi); - - end - - - rmn = rmn.initialize_from_poincare( R, Z, phi, r_axis, z_axis ); - -end \ No newline at end of file diff --git a/Utilities/matlabtools/get_spec_fractaldim_2.m b/Utilities/matlabtools/get_spec_fractaldim.m similarity index 70% rename from Utilities/matlabtools/get_spec_fractaldim_2.m rename to Utilities/matlabtools/get_spec_fractaldim.m index ba09ba9c..1bb4ad48 100644 --- a/Utilities/matlabtools/get_spec_fractaldim_2.m +++ b/Utilities/matlabtools/get_spec_fractaldim.m @@ -1,34 +1,34 @@ -function [Dfrac, Lmin_polyfit, Lmax_polyfit, Lmin_num, Lmax_num] = get_spec_fractaldim_2(data, numline, mth, polyfit_degree, varargin) - - % - % GET_FRACTALDIM( N, L, CASE_TITLE, POLYFIT_DEGREE, N_PTS, PLOTFIG ) - % ================================================================== - % - % Plot the N, L parameters resulting from get_NL_boxcount and deduce the fractal dimension - % Ex : - % [D_polyfit, D_num, D_slope, Lmin_polyfit, Lmax_polyfit, Lmin_num, Lmax_num] = get_fractaldim(N_cantor, L_cantor, 1, 'Cantor', 6); - % - % INPUT - % ----- - % -data : SPEC output data, read from read_spec(filename) - % -numline : Line number - % -mth : 0: uses the mean value to get the fractal dim - % 1: evaluates numerically the curvature and - % extract the linear part - % 2: polyfits the curve and evaluate the curvature - % analytically to extract the linear part. - % -polyfit_degree : degree of the polyfit used to approximate the fractal dim - % : found out that it worked well between 4 and 6 depending on kmax (better to have 6 for large kmax and 4 otherwise) - % - % OUTPUT - % ------ - % -Dfrac : fractal dimension - % -Lmin_num : parameter defining the minimal size of the boxes used for the linear fit with numerical curvature - % -Lmax_num : parameter defining the maximal size of the boxes used for the linear fit with numerical curvature - % -Lmin_polyfit : parameter defining the minimal size of the boxes used for the linear fit using polyfit - % -Lmax_polyfit : parameter defining the maximal size of the boxes used for the linear fit using polyfit - % : recall that the size of the boxes is proportional to 2^(-k), hence kmin_edge < kmax_edge - % +function [x, y, Dfrac, N, Lmin, Lmax] = get_spec_fractaldim(data, numline, mth, polyfit_degree, varargin) + +% +% GET_FRACTALDIM( N, L, CASE_TITLE, POLYFIT_DEGREE, N_PTS, PLOTFIG ) +% ================================================================== +% +% Plot the N, L parameters resulting from get_NL_boxcount and deduce the fractal dimension +% Ex : +% [D_polyfit, D_num, D_slope, Lmin_polyfit, Lmax_polyfit, Lmin_num, Lmax_num] = get_fractaldim(N_cantor, L_cantor, 1, 'Cantor', 6); +% +% INPUT +% ----- +% -data : SPEC output data, read from read_spec(filename) +% -numline : Line number +% -mth : 0: uses the mean value to get the fractal dim +% 1: evaluates numerically the curvature and +% extract the linear part +% 2: polyfits the curve and evaluate the curvature +% analytically to extract the linear part. +% -polyfit_degree : degree of the polyfit used to approximate the fractal +% dim. Only used if mth=2 +% +% OUTPUT +% ------ +% -x : log10( Lmax/L ) +% -y : log10( N ) +% -Dfrac : fractal dimension +% -N : Number of points as function of L +% -Lmin : Maximal L taken into account for evaluation of Dfrac +% -Lmax : Minimal L taken into account for evaluation of Dfrac +% % Optional input % --------------- @@ -40,10 +40,8 @@ % Optional outputs % ---------------- - Lmin_num = 0; - Lmax_num = 0; - Lmin_polyfit = 0; - Lmax_polyfit = 0; + Lmin = 0; + Lmax = 0; l = length(varargin); if mod(l,2)~=0 @@ -83,11 +81,10 @@ % --------------------- [N, L] = get_NL_boxcount(base_exponent, kmin, kmax, R, Z); - % Set up... idx = 1:length(N); - % slopes between each datapoints + % Get slopes between each datapoints xp = diff(-log(L)); yp = diff(log(N)); @@ -108,6 +105,10 @@ yp_ = (yp(1:end-1) + yp(2:end))/2; slopes = [yp(1)/xp(1), yp_./xp_, yp(end)/xp(end)]; + % For output... + Lmax = max(L); + Lmin = min(L); + % polyf_1d = polyfit(-log(L),log(N), 1); % D_slope = polyf_1d(1); Dfrac = mean(slopes); @@ -142,8 +143,8 @@ Dfrac = mean(slopes(idx_min_num+1:idx_max_num+1)); % determine the corresponding Lmin_num and Lmax_num - Lmin_num = L(idx_max_num+1); - Lmax_num = L(idx_min_num+1); + Lmin = L(idx_max_num+1); + Lmax = L(idx_min_num+1); case 2 % polyfit curvature @@ -170,8 +171,8 @@ % determine the corresponding Lmin_polyfit and Lmax_polyfit associated % with kmax_edge and kmin_edge respectively if idx_min_polyfit or % idx_max_polyfit is empty, it is a consequence of a too low threshold ! - Lmin_polyfit = 1/one_over_L(idx_max_polyfit); - Lmax_polyfit = 1/one_over_L(idx_min_polyfit); + Lmin = 1/one_over_L(idx_max_polyfit); + Lmax = 1/one_over_L(idx_min_polyfit); % taking a polyfit yields a similar accuracy than the mean slope Dfrac = mean(polyval(pp,log(one_over_L(idx_min_polyfit:idx_max_polyfit-1)))); @@ -192,73 +193,10 @@ error('Invalid input') end - - - - - - % ===================================================================== - % average over the whole data (without correction) + x = log10(Lmax./L); + y = log10( N ); -% if plotfig -% set(groot, 'defaultAxesTickLabelInterpreter','latex'); -% set(groot, 'defaultLegendInterpreter','latex'); -% set(groot, 'defaultTextInterpreter','latex'); -% set(groot, 'defaultAxesFontSize', 15); -% -% graph = figure; -% hold on; -% plot(1./L, N, '.', 'markersize', 12); -% xline(1/Lmax_polyfit, 'r'); -% xline(1/Lmin_polyfit, 'r'); -% xline(1/Lmax_num); -% xline(1/Lmin_num); -% plot(one_over_L, exp(polyval(p, log(one_over_L))), 'r'); -% xlabel('Inverse box-length $1/L$'); -% ylabel('Box-count $N$'); -% box on; -% grid on; -% set(gca,'xscale','log'); -% set(gca,'yscale','log'); -% % title(case_title, 'Interpreter', 'latex'); -% str = ['Dimension with polynomial fit : ', num2str(D_polyfit), ... -% newline, 'Dimension with numerical curvature : ', ... -% num2str(D_num), newline, ... -% 'Dimension with average slope : ', num2str(D_slope)]; -% annotation('textbox', [.36 0 .3 .3], 'String', str, ... -% 'FitBoxToText', 'on', 'LineWidth', 0.5, 'BackgroundColor', ... -% [1, 1, 1], 'Interpreter', 'latex'); -% -% graph = figure; -% hold on; -% plot(linspace(1,length(curv_polyfit)+1,length(curv_polyfit)), curv_polyfit); -% xline(idx_min_polyfit); -% xline(idx_max_polyfit); -% yline(threshold_polyfit); -% text(2.3, threshold_polyfit*1.05, 'Polynomial fit threshold', ... -% 'FontSize', 12, 'Interpreter', 'latex'); -% box on; -% grid on; -% set(gca,'xlim',[1 length(curv_polyfit)+1]); -% xlabel('Indices of the points considered'); -% ylabel(['Analytical curvature of ',newline,... -% 'polynomial fit of $N(1/L)$']); -% -% graph = figure; -% hold on; -% plot(linspace(1,length(curv_num),length(curv_num)), curv_num); -% xline(idx_min_num); -% xline(idx_max_num); -% yline(threshold_num); -% text(2.3, threshold_num*1.05, 'Numerical threshold', ... -% 'FontSize', 12, 'Interpreter', 'latex'); -% box on; -% grid on; -% set(gca,'xlim',[1 length(curv_num)]); -% xlabel('Indices of the points considered'); -% ylabel('Numerical curvature of $N(1/L)$'); -% end end % ========================================================================= diff --git a/Utilities/matlabtools/get_spec_helicity_slab.m b/Utilities/matlabtools/get_spec_helicity_slab.m index 737aa935..2249257e 100644 --- a/Utilities/matlabtools/get_spec_helicity_slab.m +++ b/Utilities/matlabtools/get_spec_helicity_slab.m @@ -23,65 +23,70 @@ % % written by J.Loizu (2018) -Ate = data.vector_potential.Ate{lvol}; -Aze = data.vector_potential.Aze{lvol}; + % Test input + Igeometry = data.input.physics.Igeometry; + if( Igeometry~=1 ) + error('Invalid geometry. Only available for slab') + end -sarr = linspace(-1,1,ns); -tarr = linspace(0,2*pi,nt); -zarr = linspace(0,2*pi,nz); -sarr = transpose(sarr); -sbar = (sarr+1)/2; + % Read data + Ate = data.vector_potential.Ate{lvol}; + Aze = data.vector_potential.Aze{lvol}; -Lrad = data.input.physics.Lrad(lvol); -mn = data.output.mn; -im = double(data.output.im); -in = double(data.output.in); + sarr = linspace(-1,1,ns); + tarr = linspace(0,2*pi,nt); + zarr = linspace(0,2*pi,nz); + sarr = transpose(sarr); -h1 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 1 -h2 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 2 -h3 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 3 -h4 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 4 + Lrad = data.input.physics.Lrad(lvol); + mn = data.output.mn; + im = double(data.output.im); + in = double(data.output.in); -% Construct Chebyshev polynomials and their derivatives + h1 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 1 + h2 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 2 + h3 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 3 + h4 = zeros(ns,nt,nz); % allocate data for magnetic helicity integrand 4 -T = get_spec_polynomial_basis(data, lvol, sarr); + % Construct Chebyshev polynomials and their derivatives -% Construct regularization factors and their derivatives + T = get_spec_polynomial_basis(data, lvol, sarr); -fac = get_spec_regularization_factor(data,lvol,sarr,'F'); + % Construct regularization factors and their derivatives -% Construct magnetic helicity integrand + fac = get_spec_regularisation_factor(data,lvol,sarr,'F'); -Lsingularity = false; -if (lvol==1) && (data.input.physics.Igeometry~=1) - Lsingularity = true; -end + % Construct magnetic helicity integrand -for l=1:Lrad+1 - for j=1:mn - if Lsingularity - basis = T{l}{1}(im(j)+1); - dbasis = T{l}{2}(im(j)+1); - else - basis = T{l}{1}; - dbasis = T{l}{2}; + Lsingularity = false; + if (lvol==1) && (data.input.physics.Igeometry~=1) + Lsingularity = true; end - for it=1:nt - for iz=1:nz - cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); - sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); - h1(:,it,iz) = h1(:,it,iz) + fac{j}{1}.* basis.*Ate(l,j)*cosa; %A_t - h2(:,it,iz) = h2(:,it,iz) - (fac{j}{1}.*dbasis+fac{j}{2}.* basis).*Aze(l,j)*cosa; % -dA_z/ds - h3(:,it,iz) = h3(:,it,iz) + fac{j}{1}.* basis.*Aze(l,j)*cosa; %A_z - h4(:,it,iz) = h4(:,it,iz) + (fac{j}{1}.*dbasis+fac{j}{2}.* basis).*Ate(l,j)*cosa; % +dA_t/ds + for l=1:Lrad+1 + for j=1:mn + if Lsingularity + basis = T{l}{1}(im(j)+1); + dbasis = T{l}{2}(im(j)+1); + else + basis = T{l}{1}; + dbasis = T{l}{2}; + end + + for it=1:nt + for iz=1:nz + cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); + h1(:,it,iz) = h1(:,it,iz) + fac{j}{1}.* basis .*Ate(l,j)*cosa; %A_t + h2(:,it,iz) = h2(:,it,iz) - (fac{j}{1}.*dbasis+fac{j}{2}.* basis).*Aze(l,j)*cosa; % -dA_z/ds + h3(:,it,iz) = h3(:,it,iz) + fac{j}{1}.* basis .*Aze(l,j)*cosa; %A_z + h4(:,it,iz) = h4(:,it,iz) + (fac{j}{1}.*dbasis+fac{j}{2}.* basis).*Ate(l,j)*cosa; % +dA_t/ds + end + end end end - end -end - -h = h1.*h2 + h3.*h4; - -H = trapz(sarr,trapz(tarr,trapz(zarr,h,3),2)); + % Evaluate helicity + h = h1.*h2 + h3.*h4; + H = trapz(sarr,trapz(tarr,trapz(zarr,h,3),2)); +end diff --git a/Utilities/matlabtools/get_spec_jacobian.m b/Utilities/matlabtools/get_spec_jacobian.m index ea11664d..5ce74412 100644 --- a/Utilities/matlabtools/get_spec_jacobian.m +++ b/Utilities/matlabtools/get_spec_jacobian.m @@ -23,17 +23,24 @@ % written by J.Loizu (2016) % modified by A. Baillod (2019) -[sarr, Rarr] = get_spec_R_derivatives(data, lvol, sarr, tarr, zarr, 'R'); + % Check input + Istellsym = data.input.physics.Istellsym; + if Istellsym==0 + error('Non stellarator symmetric not implemented') + end -switch data.input.physics.Igeometry - case 1 - jacobian = Rarr{2}; - case 2 - jacobian = Rarr{1}.*Rarr{2}; - case 3 - [sarr, Zarr] = get_spec_R_derivatives(data, lvol, sarr, tarr, zarr, 'Z'); - jacobian = Rarr{1}.*(Rarr{3}.*Zarr{2} - Rarr{2}.*Zarr{3}); - otherwise - error('Unsupported geometry in get_spec_jacobian') -end + Rarr = get_spec_R_derivatives(data, lvol, sarr, tarr, zarr, 'R'); + switch data.input.physics.Igeometry + case 1 + jacobian = Rarr{2}; + case 2 + jacobian = Rarr{1}.*Rarr{2}; + case 3 + Zarr = get_spec_R_derivatives(data, lvol, sarr, tarr, zarr, 'Z'); + jacobian = Rarr{1}.*(Rarr{3}.*Zarr{2} - Rarr{2}.*Zarr{3}); + otherwise + error('Unsupported geometry in get_spec_jacobian') + end + +end \ No newline at end of file diff --git a/Utilities/matlabtools/get_spec_metric.m b/Utilities/matlabtools/get_spec_metric.m index 09022d54..6f5c00ab 100644 --- a/Utilities/matlabtools/get_spec_metric.m +++ b/Utilities/matlabtools/get_spec_metric.m @@ -21,57 +21,66 @@ % Note: Stellarator symmetry is assumed % % written by J.Loizu (2016) -% modified by A. Baillod (2019) +% modified by A. Baillod (2019)] -% Allocate data for the metric matrix -ns = length(sarr); -nt = length(tarr); -nz = length(zarr); + % Check input + Istellsym = data.input.physics.Istellsym; + if Istellsym==0 + error('Non stellarator symmetric not implemented') + end + + % Allocate data for the metric matrix + ns = length(sarr); + nt = length(tarr); + nz = length(zarr); -gmat = cell(3,3); + gmat = cell(3,3); -for k=1:3 - for p=1:3 - gmat{k}{p} = zeros(ns,nt,nz); - end -end - -% Get R and Z and their derivatives + for k=1:3 + for p=1:3 + gmat{k,p} = zeros(ns,nt,nz); + end + end -[out, Rarr] = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'R'); -[out, Zarr] = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'Z'); + % Get R and its derivatives + Rarr = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'R'); -% Construct metric elements + % Construct metric elements -switch data.input.physics.Igeometry - case 1 - gmat{1}{1} = Rarr{2}.^2; - gmat{2}{2} = 1 + Rarr{3}.^2; - gmat{3}{3} = 1 + Rarr{4}.^2; - gmat{1}{2} = Rarr{2}.*Rarr{3}; - gmat{1}{3} = Rarr{2}.*Rarr{4}; - gmat{2}{3} = Rarr{3}.*Rarr{4}; - case 2 - gmat{1}{1} = Rarr{2}.^2; %gss - gmat{2}{2} = Rarr{3}.^2 + Rarr{1}.^2; %gtt - gmat{3}{3} = Rarr{4}.^2 + 1; %gzz - gmat{1}{2} = Rarr{2}.*Rarr{3}; %gst - gmat{1}{3} = Rarr{2}.*Rarr{4}; %gsz - gmat{2}{3} = Rarr{3}.*Rarr{4}; %gtz - case 3 - gmat{1}{1} = Rarr{2}.^2 + Zarr{2}.^2; %gss - gmat{2}{2} = Rarr{3}.^2 + Zarr{3}.^2; %gtt - gmat{3}{3} = Rarr{1}.^2 + Rarr{4}.^2 + Zarr{4}.^2; %gzz - gmat{1}{2} = Rarr{2}.*Rarr{3} + Zarr{2}.*Zarr{3}; %gst - gmat{1}{3} = Rarr{2}.*Rarr{4} + Zarr{2}.*Zarr{4}; %gsz - gmat{2}{3} = Rarr{3}.*Rarr{4} + Zarr{3}.*Zarr{4}; %gtz - otherwise - error('Unsupported geometry in get_spec_metric.m') -end + switch data.input.physics.Igeometry + case 1 % Slab geometry + gmat{1,1} = Rarr{2}.^2; + gmat{2,2} = 1 + Rarr{3}.^2; + gmat{3,3} = 1 + Rarr{4}.^2; + gmat{1,2} = Rarr{2}.*Rarr{3}; + gmat{1,3} = Rarr{2}.*Rarr{4}; + gmat{2,3} = Rarr{3}.*Rarr{4}; + + case 2 % Cylindrical geometry + gmat{1,1} = Rarr{2}.^2; %gss + gmat{2,2} = Rarr{3}.^2 + Rarr{1}.^2; %gtt + gmat{3,3} = Rarr{4}.^2 + 1; %gzz + gmat{1,2} = Rarr{2}.*Rarr{3}; %gst + gmat{1,3} = Rarr{2}.*Rarr{4}; %gsz + gmat{2,3} = Rarr{3}.*Rarr{4}; %gtz + + case 3 %Toroidal geometry + % Get Z and its derivatives + Zarr = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'Z'); + + gmat{1,1} = Rarr{2}.^2 + Zarr{2}.^2; %gss + gmat{2,2} = Rarr{3}.^2 + Zarr{3}.^2; %gtt + gmat{3,3} = Rarr{1}.^2 + Rarr{4}.^2 + Zarr{4}.^2; %gzz + gmat{1,2} = Rarr{2}.*Rarr{3} + Zarr{2}.*Zarr{3}; %gst + gmat{1,3} = Rarr{2}.*Rarr{4} + Zarr{2}.*Zarr{4}; %gsz + gmat{2,3} = Rarr{3}.*Rarr{4} + Zarr{3}.*Zarr{4}; %gtz + otherwise + error('Unsupported geometry in get_spec_metric.m') + end -gmat{2}{1} = gmat{1}{2}; % by symmetry of g -gmat{3}{1} = gmat{1}{3}; -gmat{3}{2} = gmat{2}{3}; + gmat{2,1} = gmat{1,2}; % by symmetry of g + gmat{3,1} = gmat{1,3}; + gmat{3,2} = gmat{2,3}; end diff --git a/Utilities/matlabtools/get_spec_metric_contrav.m b/Utilities/matlabtools/get_spec_metric_contrav.m index 8ca27c04..e3589062 100644 --- a/Utilities/matlabtools/get_spec_metric_contrav.m +++ b/Utilities/matlabtools/get_spec_metric_contrav.m @@ -15,12 +15,16 @@ % % OUTPUT % ------ -% gmatcon{i}{j}(s,theta,zeta) +% gmatcon{i,j}(s,theta,zeta) % % Note: Stellarator symmetry is assumed % % written by J.Loizu (2017) +Istellsym = data.input.physics.Istellsym; +if Istellsym~=1 + error('Only valid for stellarator symmetric equilibria') +end % Auxiliary variables @@ -30,19 +34,11 @@ nz = length(zarr); % First get the covariant metric matrix - gmatcov = get_spec_metric(data,lvol,sarr,tarr,zarr); % Allocate space for contravariant metric matrix - gmatcon = cell(3,3); -for k=1:3 - for p=1:3 - gmatcon{k}{p} = zeros(ns,nt,nz); - end -end - % Initiate calculation loop (over each position on the surface) for is=1:ns @@ -53,66 +49,51 @@ % Define arrays of gcov, gcon, and rhs rhs = transpose([1 1 1 0 0 0]); - gcon = zeros(6,1); - gcov = zeros(6,1); - - gcov(1) = gmatcov{1}{1}(is,it,iz); - gcov(2) = gmatcov{2}{2}(is,it,iz); - gcov(3) = gmatcov{3}{3}(is,it,iz); - gcov(4) = gmatcov{1}{2}(is,it,iz); - gcov(5) = gmatcov{1}{3}(is,it,iz); - gcov(6) = gmatcov{2}{3}(is,it,iz); % Define transformation matrix G - G = zeros(6,6); - G(1,1) = gmatcov{1}{1}(is,it,iz); - G(2,2) = gmatcov{2}{2}(is,it,iz); - G(3,3) = gmatcov{3}{3}(is,it,iz); - G(4,4) = gmatcov{1}{1}(is,it,iz); - G(5,5) = gmatcov{1}{1}(is,it,iz); - G(6,6) = gmatcov{2}{2}(is,it,iz); + G(1,1) = gmatcov{1,1}(is,it,iz); + G(2,2) = gmatcov{2,2}(is,it,iz); + G(3,3) = gmatcov{3,3}(is,it,iz); + G(4,4) = gmatcov{1,1}(is,it,iz); + G(5,5) = gmatcov{1,1}(is,it,iz); + G(6,6) = gmatcov{2,2}(is,it,iz); - G(1,4) = gmatcov{1}{2}(is,it,iz); - G(1,5) = gmatcov{1}{3}(is,it,iz); + G(1,4) = gmatcov{1,2}(is,it,iz); + G(1,5) = gmatcov{1,3}(is,it,iz); - G(2,4) = gmatcov{1}{2}(is,it,iz); - G(2,6) = gmatcov{2}{3}(is,it,iz); + G(2,4) = gmatcov{1,2}(is,it,iz); + G(2,6) = gmatcov{2,3}(is,it,iz); - G(3,5) = gmatcov{1}{3}(is,it,iz); - G(3,6) = gmatcov{2}{3}(is,it,iz); - - G(4,2) = gmatcov{1}{2}(is,it,iz); - G(4,6) = gmatcov{1}{3}(is,it,iz); + G(3,5) = gmatcov{1,3}(is,it,iz); + G(3,6) = gmatcov{2,3}(is,it,iz); - G(5,3) = gmatcov{1}{3}(is,it,iz); - G(5,6) = gmatcov{1}{2}(is,it,iz); + G(4,2) = gmatcov{1,2}(is,it,iz); + G(4,6) = gmatcov{1,3}(is,it,iz); - G(6,3) = gmatcov{2}{3}(is,it,iz); - G(6,5) = gmatcov{1}{2}(is,it,iz); + G(5,3) = gmatcov{1,3}(is,it,iz); + G(5,6) = gmatcov{1,2}(is,it,iz); - % Invert transformation matrix - - Ginv = inv(G); + G(6,3) = gmatcov{2,3}(is,it,iz); + G(6,5) = gmatcov{1,2}(is,it,iz); % Calculate gcon elements - - gcon = Ginv*rhs; + gcon = G\rhs; % Construct contravariant metric matrix - gmatcon{1}{1}(is,it,iz) = gcon(1); %g^ss - gmatcon{2}{2}(is,it,iz) = gcon(2); %g^tt - gmatcon{3}{3}(is,it,iz) = gcon(3); %g^zz - gmatcon{1}{2}(is,it,iz) = gcon(4); %g^st - gmatcon{1}{3}(is,it,iz) = gcon(5); %g^sz - gmatcon{2}{3}(is,it,iz) = gcon(6); %g^tz + gmatcon{1,1}(is,it,iz) = gcon(1); %g^ss + gmatcon{2,2}(is,it,iz) = gcon(2); %g^tt + gmatcon{3,3}(is,it,iz) = gcon(3); %g^zz + gmatcon{1,2}(is,it,iz) = gcon(4); %g^st + gmatcon{1,3}(is,it,iz) = gcon(5); %g^sz + gmatcon{2,3}(is,it,iz) = gcon(6); %g^tz - gmatcon{2}{1}(is,it,iz) = gmatcon{1}{2}(is,it,iz); % by symmetry of g - gmatcon{3}{1}(is,it,iz) = gmatcon{1}{3}(is,it,iz); - gmatcon{3}{2}(is,it,iz) = gmatcon{2}{3}(is,it,iz); + gmatcon{2,1}(is,it,iz) = gmatcon{1,2}(is,it,iz); % by symmetry of g + gmatcon{3,1}(is,it,iz) = gmatcon{1,3}(is,it,iz); + gmatcon{3,2}(is,it,iz) = gmatcon{2,3}(is,it,iz); end end diff --git a/Utilities/matlabtools/get_spec_modB.m b/Utilities/matlabtools/get_spec_modB.m index c773366a..38525908 100644 --- a/Utilities/matlabtools/get_spec_modB.m +++ b/Utilities/matlabtools/get_spec_modB.m @@ -40,15 +40,15 @@ for is=1:ns for it=1:nt for iz=1:nz - a0 = gmat{1}{1}(is,it,iz); - b0 = gmat{1}{2}(is,it,iz); - c0 = gmat{1}{3}(is,it,iz); - d0 = gmat{2}{1}(is,it,iz); - e0 = gmat{2}{2}(is,it,iz); - f0 = gmat{2}{3}(is,it,iz); - g0 = gmat{3}{1}(is,it,iz); - h0 = gmat{3}{2}(is,it,iz); - i0 = gmat{3}{3}(is,it,iz); + a0 = gmat{1,1}(is,it,iz); + b0 = gmat{1,2}(is,it,iz); + c0 = gmat{1,3}(is,it,iz); + d0 = gmat{2,1}(is,it,iz); + e0 = gmat{2,2}(is,it,iz); + f0 = gmat{2,3}(is,it,iz); + g0 = gmat{3,1}(is,it,iz); + h0 = gmat{3,2}(is,it,iz); + i0 = gmat{3,3}(is,it,iz); bs = bvec{1}(is,it,iz); bt = bvec{2}(is,it,iz); diff --git a/Utilities/matlabtools/get_spec_polflux.m b/Utilities/matlabtools/get_spec_polflux.m index 690051a3..10686f5c 100644 --- a/Utilities/matlabtools/get_spec_polflux.m +++ b/Utilities/matlabtools/get_spec_polflux.m @@ -1,11 +1,12 @@ -function psipol = get_spec_polflux(data,lvol,theta,start,send,ns,nz) +function psipol = get_spec_polflux(data,lvol,theta,sarr,nz) % % GET_SPEC_POLFLUX( DATA, LVOL, THETA, START, SEND, NS, NZ ) % ========================================================== % % Computes total enclosed poloidal flux in the surface defined by theta -% inside the volume number lvol and across the radial extension defined by start and send +% inside the volume number lvol and across the radial extension defined by +% start and send % % INPUT % ----- @@ -22,24 +23,21 @@ % -psipol : total enclosed poloidal flux % % written by J.Loizu (2016) -% modified by A. Baillod (2019) - Added switch for geometry -sarr = linspace(start,send,ns); +% Check input +Igeometry = data.input.physics.Igeometry; +if (sarr(1)==-1) && (lvol==1) && (Igeometry~=1) + error('Singularity in first volume for s=-1. Set sarr to start from >-1') +end +% Build zeta array zarr = linspace(0,2*pi,nz); -ds = sarr(2)-sarr(1); - -dz = zarr(2)-zarr(1); - - +% Get B theta contravariant and the jacobian Bcontrav = get_spec_magfield(data,lvol,sarr,theta,zarr); +Btheta = squeeze(Bcontrav{2}); jac = squeeze(get_spec_jacobian(data,lvol,sarr,theta,zarr)); - - -Btheta = Bcontrav{2}; - + % Compute surface integral - -psipol = sum(sum( jac(2:end,:).*Btheta(2:end,:) ))*ds*dz; +psipol = trapz(zarr, trapz(sarr, jac.*Btheta, 1 ) ); diff --git a/Utilities/matlabtools/get_spec_polynomial_basis.m b/Utilities/matlabtools/get_spec_polynomial_basis.m index 9137f406..b1e38a26 100644 --- a/Utilities/matlabtools/get_spec_polynomial_basis.m +++ b/Utilities/matlabtools/get_spec_polynomial_basis.m @@ -14,106 +14,111 @@ % % OUTPUT % ------ -% T{i}{j}: Polynom of order i (j=1) and its derivative (j=2) +% T{i}{j}: Polynom of order i (j=1) +% and its derivative with respect to s (j=2) % % % Written by A. Baillod (2020) % -Lrad = double(data.input.physics.Lrad(lvol)); -ns = length(sarr); -Mpol = data.input.physics.Mpol; + % Read input data + Lrad = double(data.input.physics.Lrad(lvol)); + ns = length(sarr); + Mpol = data.input.physics.Mpol; -Lzernike = false; -if ((lvol==1) && (data.input.physics.Igeometry~=1)) - if data.version<3.0 + % Check if zernike or Chebychev polynomials are required Lzernike = false; - else - Lzernike = true; - end -end - - -T = cell(Lrad+1,2); % allocate data for Chebyshev polynomials and their derivatives - -T{1}{1} = ones(ns,1); -T{1}{2} = zeros(ns,1); - -T{2}{1} = sarr; -T{2}{2} = ones(ns,1); - - -if( Lzernike ) % Build zernike polynomials -% Copy pasted from Frotran source, translated to Matlab language -% Tested on the 16.09.2020 (A. Baillod) against SPEC source. perfect match - zernike = zeros(Lrad+1,Mpol+1,2,length(sarr)); - rm = ones(size(sarr)); - rm1 = zeros(size(sarr)); - - sbar = (1 + sarr ) / 2.0; - ns = length(sbar); - - for m = 0:Mpol - if (Lrad >= m) - zernike(m+1,m+1,1,:) = rm; - zernike(m+1,m+1,2,:) = double(m)*rm1; + if ((lvol==1) && (data.input.physics.Igeometry~=1)) + if data.version<3.0 + Lzernike = false; + else + Lzernike = true; + end end - if (Lrad >= m+2) - zernike(m+3,m+1,1,:) = double(m+2) *rm.*sbar.^2 - double(m+1) *rm; - zernike(m+3,m+1,2,:) = double((m+2)^2) *rm.*sbar - double((m+1)*m)*rm1; - end - for n = m+4:2:Lrad - factor1 = double(n) / double(n^2 - m^2); - factor2 = double(4 * (n-1)); - factor3 = double((n-2+m)^2)/double(n-2) + double((n-m)^2)/double(n); - factor4 = double((n-2)^2-m^2) / double(n-2); - - zernike(n+1, m+1, 1, :) = factor1 * ((factor2*sbar.^2 - factor3) .* reshape(zernike(n-1, m+1, 1, :), [ns,1]) - factor4 * reshape(zernike(n-3, m+1, 1, :), [ns, 1])); - zernike(n+1, m+1, 2, :) = factor1 * (2.0*factor2*sbar .* reshape(zernike(n-1, m+1, 1, :), [ns,1]) + (factor2*sbar.^2 - factor3) .* reshape(zernike(n-1, m+1, 2, :), [ns,1]) - factor4 * reshape(zernike(n-3, m+1, 2, :), [ns,1])); - end - - rm1 = rm; - rm = rm .* sbar; - end - - for n = 2:2:Lrad - zernike(n+1,1,1,:) = zernike(n+1,1,1, :) - (-1)^(n/2); - end - - if (Mpol >= 1) - for n = 3:2:Lrad - zernike(n+1,2,1,:) = reshape(zernike(n+1,2,1,:), [ns,1]) - (-1)^((n-1)/2) * double((n+1)/2) * sbar; - zernike(n+1,2,2,:) = reshape(zernike(n+1,2,2,:), [ns,1]) - (-1)^((n-1)/2) * double((n+1)/2); + % Allocate memory + T = cell(Lrad+1,2); + + T{1}{1} = ones(ns,1); + T{1}{2} = zeros(ns,1); + + T{2}{1} = sarr; + T{2}{2} = ones(ns,1); + + + if( Lzernike ) % Build zernike polynomials + % Copy pasted from Frotran source, translated to Matlab language + % Tested on the 16.09.2020 (A. Baillod) against SPEC source. perfect match + zernike = zeros(Lrad+1,Mpol+1,2,length(sarr)); + rm = ones(size(sarr)); + rm1 = zeros(size(sarr)); + + sbar = (1 + sarr ) / 2.0; + ns = length(sbar); + + for m = 0:Mpol + if (Lrad >= m) + zernike(m+1,m+1,1,:) = rm; + zernike(m+1,m+1,2,:) = double(m)*rm1; + end + + if (Lrad >= m+2) + zernike(m+3,m+1,1,:) = double(m+2) *rm.*sbar.^2 - double(m+1) *rm; + zernike(m+3,m+1,2,:) = double((m+2)^2) *rm.*sbar - double((m+1)*m)*rm1; + end + + for n = m+4:2:Lrad + factor1 = double(n) / double(n^2 - m^2); + factor2 = double(4 * (n-1)); + factor3 = double((n-2+m)^2)/double(n-2) + double((n-m)^2)/double(n); + factor4 = double((n-2)^2-m^2) / double(n-2); + + zernike(n+1, m+1, 1, :) = factor1 * ((factor2*sbar.^2 - factor3) .* reshape(zernike(n-1, m+1, 1, :), [ns,1]) - factor4 * reshape(zernike(n-3, m+1, 1, :), [ns, 1])); + zernike(n+1, m+1, 2, :) = factor1 * (2.0*factor2*sbar .* reshape(zernike(n-1, m+1, 1, :), [ns,1]) + (factor2*sbar.^2 - factor3) .* reshape(zernike(n-1, m+1, 2, :), [ns,1]) - factor4 * reshape(zernike(n-3, m+1, 2, :), [ns,1])); + end + + rm1 = rm; + rm = rm .* sbar; + end + + for n = 2:2:Lrad + zernike(n+1,1,1,:) = zernike(n+1,1,1, :) - (-1)^(n/2); + end + + if (Mpol >= 1) + for n = 3:2:Lrad + zernike(n+1,2,1,:) = reshape(zernike(n+1,2,1,:), [ns,1]) - (-1)^((n-1)/2) * double((n+1)/2) * sbar; + zernike(n+1,2,2,:) = reshape(zernike(n+1,2,2,:), [ns,1]) - (-1)^((n-1)/2) * double((n+1)/2); + end + end + + for m = 0:Mpol + for n = m:2:Lrad + zernike(n+1,m+1,:,:) = zernike(n+1,m+1,:,:) / double(n+1); + end + end + + % Store in T{}{} structure + for ll = 1:Lrad+1 + T{ll}{1} = reshape(zernike(ll,:,1,:) , Mpol+1, length(sarr)); + T{ll}{2} = reshape(zernike(ll,:,2,:) / 2.0, Mpol+1, length(sarr)); + end + + else % Otherwise construct Chebychev basis + + for l=3:Lrad+1 + T{l}{1} = 2*sarr.*T{l-1}{1} - T{l-2}{1}; + T{l}{2} = 2*T{l-1}{1} + 2*sarr.*T{l-1}{2} - T{l-2}{2}; + end + + for l = 1:Lrad + T{l+1}{1} = T{l+1}{1} - (-1)^l; + end + + for l = 0:Lrad + T{l+1}{1} = T{l+1}{1} / double(l+1); % scale for better conditioning + T{l+1}{2} = T{l+1}{2} / double(l+1); % scale for better conditioning + end end - end - - for m = 0:Mpol - for n = m:2:Lrad - zernike(n+1,m+1,:,:) = zernike(n+1,m+1,:,:) / double(n+1); - end - end - - % Store in T{}{} structure - for ll = 1:Lrad+1 - T{ll}{1} = reshape(zernike(ll,:,1,:) , Mpol+1, length(sarr)); - T{ll}{2} = reshape(zernike(ll,:,2,:) / 2.0, Mpol+1, length(sarr)); - end - -else % Otherwise construct Chebychev basis - - for l=3:Lrad+1 - T{l}{1} = 2*sarr.*T{l-1}{1} - T{l-2}{1}; - T{l}{2} = 2*T{l-1}{1} + 2*sarr.*T{l-1}{2} - T{l-2}{2}; - end - - for l = 1:Lrad - T{l+1}{1} = T{l+1}{1} - (-1)^l; - end - - for l = 0:Lrad - T{l+1}{1} = T{l+1}{1} / double(l+1); % scale for better conditioning - T{l+1}{2} = T{l+1}{2} / double(l+1); % scale for better conditioning - end end diff --git a/Utilities/matlabtools/get_spec_radius.m b/Utilities/matlabtools/get_spec_radius.m deleted file mode 100644 index 09db55be..00000000 --- a/Utilities/matlabtools/get_spec_radius.m +++ /dev/null @@ -1,56 +0,0 @@ -function [r_out, z_out] = get_spec_radius(data, theta, zeta, vol) - -% -% GET_SPEC_RADIUS( DATA, THETA, ZETA, VOL ) -% ========================================= -% -% Return the radial position of a KAM surface for a given theta, zeta and -% Nvol -% -% INPUT -% ----- -% data Obtained via read_spec(filename) -% theta: Poloidal angle -% zeta: Toroidal angle -% vol: Volume number -% -% OUPUT -% ----- -% r_out: Radial position of the KAM surface - - -% Load a bunch of stuff - -mn = data.output.mn; -im = data.output.im; -in = data.output.in; -Rmn = data.output.Rbc; -Zmn = data.output.Zbs; -G = data.input.physics.Igeometry; - - -switch G - case 1 - r_out = 0; - - for k=1:mn - r_out = r_out + Rmn(k, vol+1) * cos(double(im(k)) * theta - double(in(k)) * zeta); - end - z_out = 0; - case 2 - r_out = 0; - - for k=1:mn - r_out = r_out + Rmn(k, vol+1) * cos(double(im(k)) * theta - double(in(k)) * zeta); - end - z_out = 0; - case 3 - r_out = 0; - z_out = 0; - - for k=1:mn - r_out = r_out + Rmn(k, vol+1) * cos(double(im(k)) * theta - double(in(k)) * zeta); - z_out = z_out + Zmn(k, vol+1) * sin(double(im(k)) * theta - double(in(k)) * zeta); - end - -end diff --git a/Utilities/matlabtools/get_spec_regularisation_factor.m b/Utilities/matlabtools/get_spec_regularisation_factor.m index 425b8c0e..a06511ed 100644 --- a/Utilities/matlabtools/get_spec_regularisation_factor.m +++ b/Utilities/matlabtools/get_spec_regularisation_factor.m @@ -21,77 +21,69 @@ % Written by A.Baillod (2019) % -sarr = transpose(sarr); + sarr = transpose(sarr); -Igeometry = data.input.physics.Igeometry; -mn = data.output.mn; -im = double(data.output.im); -ns = length(sarr); -fac = cell(mn,2); -sbar = (1+sarr)/2.0; -Mregular = double(data.input.numerics.Mregular); + Igeometry = data.input.physics.Igeometry; + mn = data.output.mn; + im = double(data.output.im); + ns = length(sarr); + fac = cell(mn,2); + sbar = (1+sarr)/2.0; + if ForG=='G' + switch Igeometry + case 1 % Slab geometry -regumm = im / 2.0; -if Mregular>1 - ind = find(regumm>Mregular); - regumm(ind) = Mregular / 2.0; -end - - -if ForG=='G' - switch Igeometry - case 1 % Slab geometry - - for j=1:mn - fac{j}{1} = sbar; - fac{j}{2} = 0.5*ones(ns,1); - end + for j=1:mn + fac{j}{1} = sbar; + fac{j}{2} = 0.5*ones(ns,1); + end - case 2 % Cylindrical geometry - for j=1:mn - if(lvol==1) - if im(j)==0 - fac{j}{1} = sbar; - fac{j}{2} = 0.5*ones(ns,1); + case 2 % Cylindrical geometry + for j=1:mn + if(lvol==1) + if im(j)==0 + fac{j}{1} = sbar; + fac{j}{2} = 0.5*ones(ns,1); + else + fac{j}{1} = sbar.^(im(j)+1); + fac{j}{2} = 0.5 * (im(j)+1) * fac{j}{1} ./ sbar; + end else - fac{j}{1} = sbar.^(im(j)+1); - fac{j}{2} = 0.5 * (im(j)+1) * fac{j}{1} ./ sbar; + fac{j}{1} = sbar; + fac{j}{2} = 0.5 * ones(ns,1); end - else - fac{j}{1} = sbar; - fac{j}{2} = 0.5 * ones(ns,1); end - end - case 3 % Toroidal geometry + case 3 % Toroidal geometry - for j=1:mn - if lvol==1 %coordinate singularity - if im(j)==0 - fac{j}{1} = sbar.^2; - fac{j}{2} = sbar; + for j=1:mn + if lvol==1 %coordinate singularity + if im(j)==0 + fac{j}{1} = sbar.^2; + fac{j}{2} = sbar; + else + fac{j}{1} = sbar.^im(j); + fac{j}{2} = 0.5 * im(j) * fac{j}{1} ./ sbar; + end else - fac{j}{1} = sbar.^im(j); - fac{j}{2} = 0.5 * im(j) * fac{j}{1} ./ sbar; + fac{j}{1} = sbar; + fac{j}{2} = 0.5 * ones(ns,1); end - else - fac{j}{1} = sbar; - fac{j}{2} = 0.5 * ones(ns,1); end - end - otherwise - error('Unsupported geometry in get_spec_regularisation_factor') - end - - - -elseif ForG=='F' - for j=1:mn - fac{j}{1} = ones(ns,1); - fac{j}{2} = zeros(ns,1); + otherwise + error('Unsupported geometry in get_spec_regularisation_factor') + end + + + + elseif ForG=='F' + for j=1:mn + fac{j}{1} = ones(ns,1); + fac{j}{2} = zeros(ns,1); + end + + else + error('Unsupported ForG value in get_spec_regularisation_factor.') end - -else - error('Unsupported ForG value in get_spec_regularisation_factor.') end diff --git a/Utilities/matlabtools/get_spec_rtarr.m b/Utilities/matlabtools/get_spec_rtarr.m deleted file mode 100644 index 1217a08a..00000000 --- a/Utilities/matlabtools/get_spec_rtarr.m +++ /dev/null @@ -1,61 +0,0 @@ -function rtdata = get_spec_rtarr(data,lvol,sarr,tarr,zarr0) - -% -% GET_SPEC_RTARR( DATA, LVOL, SARR, TARR, ZARR0 ) -% =============================================== -% -% Transforms (s,theta) array into (R,theta) array in volume number lvol in slab or cylindrical geometry -% -% INPUT -% ----- -% -data : must be produced by calling e.g. read_spec(filename) -% -lvol : volume number -% -sarr : is the array of values for the s-coordinate -% -tarr : is the array of values for the theta-coordinate -% -zarr : is the array of values for the zeta-coordinate -% -% OUTPUT -% ------ -% -rtdata : array with (R,theta,dRds) data array with size 3*ns*nt where ns=length(sarr),nt=length(tarr) -% -% Note: Stellarator symmetry is assumed -% -% written by J.Loizu (2018) -% updated by J.Loizu (2020) - - -Rac = data.output.Rbc(:,lvol); % inner volume boundary harmonics -Rbc = data.output.Rbc(:,lvol+1); % outer volume boundary harmonics - -ns = length(sarr); -nt = length(tarr); - -mn = data.output.mn; -im = double(data.output.im); -in = double(data.output.in); - -Rarr = zeros(ns,nt); % allocate data for R-array -Tarr = zeros(ns,nt); % allocate data for theta-array -dRarr = zeros(ns,nt); % allocate data for R-array derivative (in s) - - - -% Construct regularization factors - -fac = get_spec_regularisation_factor(data, lvol, sarr, 'G'); - -% Construct (R,theta) coordinates array - -for j=1:mn - for it=1:nt - cosa = cos(im(j)*tarr(it)-in(j)*zarr0); - sina = sin(im(j)*tarr(it)-in(j)*zarr0); - Rarr(:,it) = Rarr(:,it) + (Rac(j) + fac{j}{1}.*(Rbc(j)-Rac(j)) )*cosa; - dRarr(:,it) = dRarr(:,it) + fac{j}{2}*(Rbc(j)-Rac(j))*cosa; - Tarr(:,it) = tarr(it); - end -end - -rtdata{1} = Rarr; -rtdata{2} = Tarr; -rtdata{3} = dRarr; diff --git a/Utilities/matlabtools/get_spec_rzarr.m b/Utilities/matlabtools/get_spec_rzarr.m deleted file mode 100644 index 65dc9b8e..00000000 --- a/Utilities/matlabtools/get_spec_rzarr.m +++ /dev/null @@ -1,63 +0,0 @@ -function rzdata = get_spec_rzarr(data,lvol,sarr,tarr,zarr) - -% -% GET_SPEC_RZARR( DATA, LVOL, SARR, TARR, ZARR ) -% ============================================== -% -% Transforms (s,theta,zeta) array into (R,Z) array in volume number lvol -% -% INPUT -% ----- -% -data : must be produced by calling e.g. read_spec(filename) -% -lvol : volume number -% -sarr : is the array of values for the s-coordinate -% -tarr : is the array of values for the theta-coordinate -% -zarr : is the array of values for the zeta-coordinate -% -% OUTPUT -% ------ -% -rzdata : array with (R,Z) data array with size 2*ns*nt*nz where ns=length(sarr),nt=length(zarr),nt=length(zarr) -% -% Note: Stellarator symmetry is assumed -% -% written by J.Loizu (2016) - - -Rac = data.output.Rbc(:,lvol); % inner volume boundary harmonics -Zas = data.output.Zbs(:,lvol); -Rbc = data.output.Rbc(:,lvol+1); % outer volume boundary harmonics -Zbs = data.output.Zbs(:,lvol+1); - -sarr = transpose(sarr); -ns = length(sarr); -nt = length(tarr); -nz = length(zarr); -sbar = (sarr+1)/2; - -mn = data.output.mn; -im = double(data.output.im); -in = double(data.output.in); - -Rarr = zeros(ns,nt,nz); % allocate data for R-array -Zarr = zeros(ns,nt,nz); % allocate data for Z-array - - -% Construct REG FACTOR - -fac = get_spec_regularisation_factor(data, lvol, sarr', 'G'); - -% Construct (R,Z) coordinates array - -for j=1:mn - for it=1:nt - for iz=1:nz - cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); - sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); - Rarr(:,it,iz) = Rarr(:,it,iz) + (Rac(j) + fac{j}{1}.*(Rbc(j)-Rac(j)) )*cosa; - Zarr(:,it,iz) = Zarr(:,it,iz) + (Zas(j) + fac{j}{1}.*(Zbs(j)-Zas(j)) )*sina; - end - end -end - -rzdata{1} = Rarr; -rzdata{2} = Zarr; diff --git a/Utilities/matlabtools/get_spec_surface_current.m b/Utilities/matlabtools/get_spec_surface_current.m deleted file mode 100644 index f7ebf12e..00000000 --- a/Utilities/matlabtools/get_spec_surface_current.m +++ /dev/null @@ -1,66 +0,0 @@ -function [tflux, IPDt] = get_spec_surface_current(data, ns, nt, zeta) - -% -% GET_SPEC_SURFACE_CURRENT( DATA, NS, NT, ZETA ) -% ============================================== -% -% OUTDATED - should directly do 2*pi*[[B_\theta]] -% -% Returns the sheet current flowing through each interface, normalized by -% mu_0. This routine computes the actual integral of the poloidal field to -% compute the current via Ampere's law. This requires to specify zeta; -% however, since the surface current is a flux function, zeta should not -% have any influence on the result. -% -% INPUT -% ----- -% data: data obtained via read_spec(filename) -% ns: Radial resolution -% nt: Poloidal resolution -% zeta: Toroidal angle - see introduction remark -% -% OUTPUT -% ------ -% tflux: The toroidal flux enclosed by each interface (1xNvol) -% IPDt: The toroidal surface current in each interface (1xNvol-1), -% normalized by mu_0 -% -% Written by A.Baillod (2019) - - -% Constant definition -mu0 = 4*pi*1E-7; -epsilon = 1E-5; - -% Data loading -Nvol = data.output.Mvol; % Total number of volumes -sarr = linspace(-1, 1, ns); - -% Allocate memory -Bcov = cell(1, Nvol); - -theta = linspace(0, 2*pi, nt); - -IPDt = zeros(1, Nvol-1); - -% Get magnetic field -for ivol=1:Nvol - if ivol==1 - sarr(1)=-1+epsilon; - else - sarr(1)=-1; - end - - temp = get_spec_magfield(data, ivol, sarr, theta, zeta); - - Bcov{ivol} = contra2cov(data, ivol, temp, sarr, theta, zeta, 0); -end - -for ivol=1:Nvol-1 - dBtheta = -Bcov{ivol}{2}(end,:,1) + Bcov{ivol+1}{2}(1,:,1); - IPDt(ivol) = trapz(theta, dBtheta); -end - -tflux = data.output.tflux; - -end diff --git a/Utilities/matlabtools/get_spec_torcurr_kam_net.m b/Utilities/matlabtools/get_spec_torcurr_kam_net.m index 36e68f7c..08303b6d 100644 --- a/Utilities/matlabtools/get_spec_torcurr_kam_net.m +++ b/Utilities/matlabtools/get_spec_torcurr_kam_net.m @@ -20,17 +20,16 @@ % written by J.Loizu (2017) -Nvol = data.input.physics.Nvol; -Itor = zeros(1,Nvol-1); +Mvol = data.output.Mvol; +Itor = zeros(1,Mvol-1); zarr = 0; tarr = linspace(0,2*pi,ntheta); -dtheta = tarr(2)-tarr(1); sarr = [1 -1]; intB = [0 0]; -for ikam=1:Nvol-1 +for ikam=1:Mvol-1 lvol = [ikam ikam+1]; @@ -43,9 +42,9 @@ Bt = Bcontrav{2}; Bz = Bcontrav{3}; - gst = gmat{1}{2}; - gtt = gmat{2}{2}; - gzt = gmat{3}{2}; + gst = gmat{1,2}; + gtt = gmat{2,2}; + gzt = gmat{3,2}; intB(i) = trapz(tarr, Bs.*gst + Bt.*gtt + Bz.*gzt); diff --git a/Utilities/matlabtools/get_spec_torflux.m b/Utilities/matlabtools/get_spec_torflux.m index 141ef64d..d90e7ebc 100644 --- a/Utilities/matlabtools/get_spec_torflux.m +++ b/Utilities/matlabtools/get_spec_torflux.m @@ -26,28 +26,55 @@ % modified by J.Loizu (06.2017) % modified by A.Baillod (06.2019) - added switch for geometry + %Check inputs + Igeometry = data.input.physics.Igeometry; + if lvol==1 && Igeometry~=1 && start==1 + error('InputError: start should be >1 in first volume') + end -sarr = linspace(start,send,ns); + Mvol = data.output.Mvol; + if lvol<1 || lvol>Mvol + error('InputError: Invalid lvol') + end -tarr = linspace(0,2*pi,nt); + if start<-1 || start>send + error('InputError: invalid start') + end -ds = sarr(2)-sarr(1); + if send1 + error('InputError: invalid send') + end -dth = tarr(2)-tarr(1); + if ns<1 + error('InputError: invalid ns') + end -if(ds==0 || dth==0) + if nt<1 + error('InputError: invalid nt') + end - psitor = 0; - -else + % Prepare coordinate arrays + sarr = linspace(start,send,ns); + tarr = linspace(0,2*pi,nt); -Bcontrav = get_spec_magfield(data,lvol,sarr,tarr,zeta); -jac = get_spec_jacobian(data,lvol,sarr,tarr,zeta); - + ds = sarr(2)-sarr(1); - % Compute surface integral + dth = tarr(2)-tarr(1); - Bzeta = Bcontrav{3}; - psitor = sum(sum( jac(2:end,:).*Bzeta(2:end,:) ))*ds*dth; + if(ds==0 || dth==0) + + psitor = 0; + + else + + Bcontrav = get_spec_magfield(data,lvol,sarr,tarr,zeta); + jac = get_spec_jacobian(data,lvol,sarr,tarr,zeta); + + + % Compute surface integral + + Bzeta = Bcontrav{3}; + psitor = trapz( sarr, trapz( tarr, jac.*Bzeta, 2 ) ); + end end diff --git a/Utilities/matlabtools/get_spec_vecpot.m b/Utilities/matlabtools/get_spec_vecpot.m index f97e9405..5faf829e 100644 --- a/Utilities/matlabtools/get_spec_vecpot.m +++ b/Utilities/matlabtools/get_spec_vecpot.m @@ -20,7 +20,27 @@ % % written by J.Loizu (2018) +% Test input +Mvol = data.output.Mvol; +if lvol<1 || lvol>Mvol + error('InputError: invalid lvol') +end + +if isempty(sarr) + error('InputError: empty sarr') +end +if isempty(tarr) + error('InputError: empty tarr') +end +if isempty(zarr) + error('InputError: empty zarr') +end +if sarr(1)<-1 || sarr(end)>1 + error('InputError: invalid sarr') +end + +% Read data Ate = data.vector_potential.Ate{lvol}; Aze = data.vector_potential.Aze{lvol}; Ato = data.vector_potential.Ato{lvol}; @@ -32,7 +52,6 @@ ns = length(sarr); nt = length(tarr); nz = length(zarr); -sbar = (sarr+1)/2; mn = data.output.mn; im = double(data.output.im); @@ -43,15 +62,12 @@ % Construct Chebyshev polynomials - T = get_spec_polynomial_basis(data, lvol, sarr); % Construct regularization factors - fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); % Construct vector potential covariant components - Lsingularity = false; if (lvol==1) && (data.input.physics.Igeometry~=1) Lsingularity = true; @@ -62,10 +78,8 @@ for j=1:mn if( Lsingularity ) basis = T{l}{1}(im(j)+1); - dbasis = T{l}{2}(im(j)+1); else basis = T{l}{1}; - dbasis = T{l}{2}; end for it=1:nt diff --git a/Utilities/matlabtools/get_spec_volume.m b/Utilities/matlabtools/get_spec_volume.m index 72c281da..0697cfb4 100644 --- a/Utilities/matlabtools/get_spec_volume.m +++ b/Utilities/matlabtools/get_spec_volume.m @@ -22,11 +22,33 @@ % % written by J.Loizu (2016) + % Test input + Mvol = data.output.Mvol; + if lvol<1 || lvol>Mvol + error('InputError: invalid lvol') + end + if ns<1 + error('Invalid ns') + end + if nt<1 + error('Invalid nt') + end + if nz<1 + error('Invalid nz') + end -sarr = linspace(-1,1,ns); -tarr = linspace(0,2*pi,nt); -zarr = linspace(0,2*pi,nz); + Igeometry=data.input.physics.Igeometry; + if lvol==1 && Igeometry~=1 + start=-0.999; + else + start=-1; + end + + sarr = linspace(start,1,ns); + tarr = linspace(0,2*pi,nt); + zarr = linspace(0,2*pi,nz); -jacobian = get_spec_jacobian(data,lvol,sarr,tarr,zarr); + jacobian = get_spec_jacobian(data,lvol,sarr,tarr,zarr); -volume = sum(sum(sum(jacobian(2:end,:,:))))*(2*2*pi*2*pi)/(ns*nt*nz); + volume = trapz(sarr, trapz(tarr, trapz(zarr, jacobian, 3), 2) ); +end diff --git a/Utilities/matlabtools/get_spec_volume_current.m b/Utilities/matlabtools/get_spec_volume_current.m index 136d196f..8c3868e9 100644 --- a/Utilities/matlabtools/get_spec_volume_current.m +++ b/Utilities/matlabtools/get_spec_volume_current.m @@ -9,47 +9,47 @@ % INPUT % ----- % data: data obtained via read_spec(filename) +% cumul: Choose if quantity is cumulative or not % % OUTPUT % ------ % psi_coord: The toroidal flux enclosed by each interface % I_vol: The toroidal volume current flowing in each volume -% (cumulative) % % Written by A.Baillod (2019) -% Data loading -Nvol = data.input.physics.Nvol; % Total number of volumes + % Data loading + Mvol = data.output.Mvol; % Total number of volumes -% Data processing + % Data processing -% First, get the current in each volume -psi_coord = zeros(1, Nvol); % Allocate memory -I_vol = zeros(1, Nvol); + % First, get the current in each volume + psi_coord = zeros(1, Mvol); % Allocate memory + I_vol = zeros(1, Mvol); -mu = data.output.mu; -tflux = data.output.tflux; -sumI = 0; -phiedge = data.input.physics.phiedge; - -for ivol=1:Nvol + mu = data.output.mu; + tflux = data.output.tflux; + sumI = 0; + phiedge = data.input.physics.phiedge; - if ivol==1 - I_vol(ivol) = mu(ivol) * tflux(ivol) * phiedge; - else - % Add previous current volumes (sumI) since we use a cumulative - % representation - if cumul - I_vol(ivol) = mu(ivol) * (tflux(ivol) - tflux(ivol-1)) * phiedge + sumI; + for ivol=1:Mvol + + if ivol==1 + I_vol(ivol) = mu(ivol) * tflux(ivol) * phiedge; else - I_vol(ivol) = mu(ivol) * (tflux(ivol) - tflux(ivol-1)) * phiedge; + % Add previous current volumes (sumI) since we use a cumulative + % representation + if cumul + I_vol(ivol) = mu(ivol) * (tflux(ivol) - tflux(ivol-1)) * phiedge + sumI; + else + I_vol(ivol) = mu(ivol) * (tflux(ivol) - tflux(ivol-1)) * phiedge; + end end + + psi_coord(ivol) = tflux(ivol); + + sumI = I_vol(ivol); end - - psi_coord(ivol) = tflux(ivol); - - sumI = I_vol(ivol); -end end diff --git a/Utilities/matlabtools/idata_from_data.m b/Utilities/matlabtools/idata_from_data.m deleted file mode 100644 index 65308cfb..00000000 --- a/Utilities/matlabtools/idata_from_data.m +++ /dev/null @@ -1,20 +0,0 @@ -function idata = idata_from_data(data) - -% Reads rotational transform data from field-line-tracing using output from SPEC -% -% INPUT -% - data : data file obtained from read_spec(filename) -% -% OUTPUT -% - pdata : contains all the transform data, which can be fed into several routines for analyzing and ploting -% -% written by A. Baillod (2019) - - -nvol = double(data.input.physics.Nvol); -Lfreebound = data.input.physics.Lfreebound; -nvol = nvol + Lfreebound; - -idata.iota = data.transform.fiota(:,2); -idata.sarr = data.transform.fiota(:,1); -idata.Mvol = nvol; diff --git a/Utilities/matlabtools/pdata_from_data.m b/Utilities/matlabtools/pdata_from_data.m deleted file mode 100644 index bbd3ab11..00000000 --- a/Utilities/matlabtools/pdata_from_data.m +++ /dev/null @@ -1,34 +0,0 @@ -function pdata = pdata_from_data(data) - -% Reads Poincare data from field-line-tracing using output from SPEC -% -% INPUT -% - data : data file obtained from read_spec(filename) -% -% OUTPUT -% - pdata : contains all the poincare data, which can be fed into several routines for analyzing and ploting -% -% written by A.Baillod (2019) - -nvol = double(data.input.physics.Nvol); -Lfreebound = data.input.physics.Lfreebound; -nvol = nvol + Lfreebound; - -pdata.R_lines = data.poincare.R; -pdata.Z_lines = data.poincare.Z; -pdata.npoinc = data.input.diagnostics.nPpts; -pdata.th_lines = data.poincare.t; -pdata.rho_lines = data.poincare.rho; -pdata.Igeometry = data.input.physics.Igeometry; -pdata.Lfreebound= data.input.physics.Lfreebound; -pdata.mn = data.output.mn; -pdata.in = data.output.in; -pdata.im = data.output.im; -pdata.Rbc = data.output.Rbc; -pdata.Rbs = data.output.Rbs; -pdata.Zbc = data.output.Zbc; -pdata.Zbs = data.output.Zbs; -pdata.Nfp = data.input.physics.Nfp; -pdata.Mvol = nvol; -pdata.Nvol = nvol - Lfreebound; - diff --git a/Utilities/matlabtools/plot_spec_Bfield.m b/Utilities/matlabtools/plot_spec_Bfield.m deleted file mode 100644 index 4d97c366..00000000 --- a/Utilities/matlabtools/plot_spec_Bfield.m +++ /dev/null @@ -1,66 +0,0 @@ -function plot_spec_Bfield(data, component, theta, phi, nr, newfig) - -% -% PLOT_SPEC_BFIELD( DATA, COMPONENT, THETA, PHI, NR, NEWFIG ) -% =========================================================== -% -% Plot SPEC magnetic field solution -% -% INPUT -% ----- -% data: data obtained from read_spec(filename) -% component: ='psi' to plot r-component, 'theta' to plot theta component -% and 'phi' to plot phi component, ='all' for all components -% theta: Angle theta at which the field is plotted -% phi: Angle phi at which the field is plotted -% nr: Number of radial points -% newfig: open (=1) a new figure or use the current figure and hold -% on (=0) or old off (=2) -% -% -% Written by A.Baillod (2019) - - switch newfig - case 0 - hold on; - case 1 - figure - hold on; - case 2 - hold off; - end - - [r_end, z_end] = get_spec_radius(data, theta, phi, data.output.Mvol); - [r_start, z_start] = get_spec_radius(data, theta, phi, 0); - a = sqrt((r_end-r_start)^2 + (z_end-z_start)^2); - - r = linspace(0, a, nr); - B = get_full_field(data, r, theta, phi, nr); - - switch component - case 'psi' - plot(r, B(1,:)) - ylab = ylabel('$B_\psi$ [T]'); - case 'theta' - plot(r, B(2,:)) - ylab = ylabel('$B_\theta$ [T]'); - case 'phi' - plot(r, B(3,:)) - ylab = ylabel('$B_\zeta$ [T]'); - case 'all' - plot(r, B(1,:)) - hold on; - plot(r, B(2,:)) - plot(r, B(3,:)) - ylab = ylabel('B [T]'); - leg = legend('$B_\psi$', '$B_\theta$','$B_\zeta$' ); - set(leg,'Interpreter','latex'); - end - - xlab = xlabel('Distance to magnetic axis [m]'); - - set(gca, 'FontSize', 14) - set(xlab,'Interpreter','latex'); - set(ylab,'Interpreter','latex'); - -end diff --git a/Utilities/matlabtools/plot_spec_Bgrid.m b/Utilities/matlabtools/plot_spec_Bgrid.m index 4f0a5f73..8fb5d437 100644 --- a/Utilities/matlabtools/plot_spec_Bgrid.m +++ b/Utilities/matlabtools/plot_spec_Bgrid.m @@ -20,108 +20,135 @@ function plot_spec_Bgrid(data,nz0,plotstyle,newfig) % OUTDATED - NEED DEBUG if(newfig==1) -figure + figure('Color','w','Position',[200 200 1500, 600]) end -nvol = data.output.Mvol; +Mvol = data.output.Mvol; Lrad = data.input.physics.Lrad; Nt = data.grid.Nt; -Nz = data.grid.Nz; Nfp = data.input.physics.Nfp; -Rij = data.grid.Rij; -Zij = data.grid.Zij; -BR = data.grid.BR; -Bp = data.grid.Bp; -BZ = data.grid.BZ; iz = nz0-1; phi0 = double((2*pi/Nfp)*(iz/Nt)); -rzdata = get_spec_rzarr(data,nvol,1,linspace(0,2*pi,32),phi0); -rmax = max(rzdata{1}); -rmin = min(rzdata{1}); -zmax = max(rzdata{2}); -zmin = min(rzdata{2}); +R = get_spec_R_derivatives(data, Mvol, 1, linspace(0,2*pi,64), phi0, 'R'); +Z = get_spec_R_derivatives(data, Mvol, 1, linspace(0,2*pi,64), phi0, 'Z'); + +rmax = max(R{1}); +rmin = min(R{1}); +zmax = max(Z{1}); +zmin = min(Z{1}); if(strcmp(plotstyle,'pcolor')==1) -for i=1:nvol - ngrid = Lrad(i)+1; - - if(i==1) - nstart = 2; - else - nstart = 1; - end - - np1 = Nt; - np2 = 1+ngrid-nstart; - - Rc = reshape(Rij(i,1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); - Zc = reshape(Zij(i,1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); - br = reshape(BR(i,1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); - bp = reshape(Bp(i,1+Nt*iz:(iz+1)*Nt,nstart:ngrid).*Rij(i,1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); - bz = reshape(BZ(i,1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); - - subplot(3,1,1) - pcolor(Rc,Zc,br) - axis equal; colorbar; hold on - xlim([0.95*rmin 1.05*rmax]) - ylim([1.05*zmin 1.05*zmax]) - title('B_R') - subplot(3,1,2) - pcolor(Rc,Zc,bp) - axis equal; colorbar; hold on - xlim([0.95*rmin 1.05*rmax]) - ylim([1.05*zmin 1.05*zmax]) - title('B_{\phi}') - subplot(3,1,3) - pcolor(Rc,Zc,bz) - axis equal; colorbar; hold on - xlim([0.95*rmin 1.05*rmax]) - ylim([1.05*zmin 1.05*zmax]) - title('B_Z') -end + for i=1:Mvol + ngrid = Lrad(i)+1; + + % Read data corresponding to correct volume + Rij = data.grid.Rij{i}; + Zij = data.grid.Zij{i}; + BR = data.grid.BR{i}; + Bp = data.grid.Bp{i}; + BZ = data.grid.BZ{i}; + + % Reshape as an array + if(i==1) + nstart = 2; + else + nstart = 1; + end + + np1 = Nt; + np2 = 1+ngrid-nstart; + + Rc = reshape(Rij(1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); + Zc = reshape(Zij(1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); + br = reshape(BR( 1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); + bp = reshape(Bp( 1+Nt*iz:(iz+1)*Nt,nstart:ngrid) ... + .*Rij(1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); + bz = reshape(BZ( 1+Nt*iz:(iz+1)*Nt,nstart:ngrid),np1,np2); + + % Double first entry to fill entire plane + Rc(end+1,:) = Rc(1,:); + Zc(end+1,:) = Zc(1,:); + br(end+1,:) = br(1,:); + bp(end+1,:) = bp(1,:); + bz(end+1,:) = bz(1,:); + + % Plots + subplot(1,3,1) + pcolor(Rc,Zc,br) + shading interp + axis equal; colorbar; hold on + xlim([0.95*rmin 1.05*rmax]) + ylim([1.05*zmin 1.05*zmax]) + title('B_R') + + subplot(1,3,2) + pcolor(Rc,Zc,bp) + shading interp + axis equal; colorbar; hold on + xlim([0.95*rmin 1.05*rmax]) + ylim([1.05*zmin 1.05*zmax]) + title('B_{\phi}') + + subplot(1,3,3) + pcolor(Rc,Zc,bz) + shading interp + axis equal; colorbar; hold on + xlim([0.95*rmin 1.05*rmax]) + ylim([1.05*zmin 1.05*zmax]) + title('B_Z') + end elseif(strcmp(plotstyle,'scatter')==1) -cthick = 12 ; - -for i=1:nvol - ngrid = Lrad(i)+1; - if(i==1) - nstart = 2; - else - nstart = 1; - end - for l=nstart:ngrid - Rc = Rij(i,1+Nt*iz:(iz+1)*Nt,l); - Zc = Zij(i,1+Nt*iz:(iz+1)*Nt,l); - colR = BR(i,1+Nt*iz:(iz+1)*Nt,l); - colp = Bp(i,1+Nt*iz:(iz+1)*Nt,l).*Rc; - colZ = BZ(i,1+Nt*iz:(iz+1)*Nt,l); - - subplot(3,1,1) - scatter(Rc,Zc,cthick,colR) - axis equal; colorbar; hold on - xlim([0.95*rmin 1.05*rmax]) - ylim([1.05*zmin 1.05*zmax]) - title('B_R') - subplot(3,1,2) - scatter(Rc,Zc,cthick,colp) - axis equal; colorbar; hold on - xlim([0.95*rmin 1.05*rmax]) - ylim([1.05*zmin 1.05*zmax]) - title('B_{\phi}') - subplot(3,1,3) - scatter(Rc,Zc,cthick,colZ) - axis equal; colorbar; hold on - xlim([0.95*rmin 1.05*rmax]) - ylim([1.05*zmin 1.05*zmax]) - title('B_Z') - end -end + cthick = 12 ; + + for i=1:Mvol + % Read data corresponding to correct volume + Rij = data.grid.Rij{i}; + Zij = data.grid.Zij{i}; + BR = data.grid.BR{i}; + Bp = data.grid.Bp{i}; + BZ = data.grid.BZ{i}; + + ngrid = Lrad(i)+1; + if(i==1) + nstart = 2; + else + nstart = 1; + end + for l=nstart:ngrid + Rc = Rij(1+Nt*iz:(iz+1)*Nt,l); + Zc = Zij(1+Nt*iz:(iz+1)*Nt,l); + colR = BR(1+Nt*iz:(iz+1)*Nt,l); + colp = Bp(1+Nt*iz:(iz+1)*Nt,l).*Rc; + colZ = BZ(1+Nt*iz:(iz+1)*Nt,l); + + subplot(1,3,1) + scatter(Rc,Zc,cthick,colR) + axis equal; colorbar; hold on + xlim([0.95*rmin 1.05*rmax]) + ylim([1.05*zmin 1.05*zmax]) + title('B_R') + + subplot(1,3,2) + scatter(Rc,Zc,cthick,colp) + axis equal; colorbar; hold on + xlim([0.95*rmin 1.05*rmax]) + ylim([1.05*zmin 1.05*zmax]) + title('B_{\phi}') + + subplot(1,3,3) + scatter(Rc,Zc,cthick,colZ) + axis equal; colorbar; hold on + xlim([0.95*rmin 1.05*rmax]) + ylim([1.05*zmin 1.05*zmax]) + title('B_Z') + end + end end diff --git a/Utilities/matlabtools/plot_spec_Jvolume.m b/Utilities/matlabtools/plot_spec_Jvolume.m deleted file mode 100644 index 3f50bfb4..00000000 --- a/Utilities/matlabtools/plot_spec_Jvolume.m +++ /dev/null @@ -1,113 +0,0 @@ -function plot_spec_Jvolume(filename, component, ns, theta, zeta, newfig) - - -% Constant definition -mu0 = 4*pi*1E-7; -epsilon = 1E-5; - -% Data loading -fdata = read_spec_field(filename); % Read data -Nvol = fdata.Nvol; % Total number of volumes -sarr = linspace(-1, 1, ns); - -% Allocate memory -Bcontrav = cell(1, Nvol); -Bcov = cell(1, Nvol); - -% Get magnetic field -for ivol=1:Nvol - if ivol==1 - sarr(1)=-1+epsilon; - else - sarr(1)=-1; - end - temp = get_spec_magfield(fdata, ivol, sarr, theta, zeta); - Bcontrav{ivol} = zeros(3, length(temp{1})); - - for ii=1:3 % transform the output of get_spec_magfield_cyl in an array - Bcontrav{ivol}(ii,:) = temp{ii}; - end - - Bcov{ivol} = contra2cov(filename, ivol, sarr, Bcontrav{ivol}, ns, ... - theta, zeta, 0); -end - -% Data processing - -% First, get the current in each volume -nr = Nvol*ns; % Number of points in r coordinate -j_parallel_contrav = zeros(3, nr); % Allocate memory -j_parallel_covar = zeros(3, nr); % Allocate memory -r = zeros(1, nr); % Allocate memory -r_kam = zeros(1, Nvol); % Allocate memory - -iimin = 1; -iimax = ns; -for ivol=1:Nvol - - % Construct radial coordinate - if ivol==1 - sarr(1)=-1+epsilon; - sbar = (sarr+1) / 2; - rmax = get_spec_radius(filename, theta, zeta, ivol); - r(iimin:iimax) = rmax .* sqrt(sbar); - else - sarr(1)=-1; - sbar = (sarr+1) / 2; - rmin = get_spec_radius(filename, theta, zeta, ivol-1); - rmax = get_spec_radius(filename, theta, zeta, ivol); - r(iimin:iimax) = rmin + (rmax-rmin) * sbar; - end - - r_kam(ivol) = rmax; - - % And compute the parallel current - j_parallel_contrav(:,iimin:iimax) = fdata.mu(ivol)/ mu0 * Bcontrav{ivol}; - j_parallel_covar(:,iimin:iimax) = contra2cov(filename, ivol, sarr,... - j_parallel_contrav(:,iimin:iimax), ns, theta, zeta, 1); - - % Change indices for next volume - iimin = iimin + ns; - iimax = iimax + ns; -end - - - - -% some plots - -switch newfig - case 0 - hold on - case 1 - figure - hold on - case 2 - hold off -end - -switch component - case 'psi' - plot(r, j_parallel_covar(1,:), 'LineWidth', 1.5, 'DisplayName', '$j_{\parallel,\psi}$') - hold on; - case 'theta' - plot(r, j_parallel_covar(2,:), 'LineWidth', 1.5, 'DisplayName', '$j_{\parallel,\theta}$') - hold on; - case 'phi' - plot(r, j_parallel_covar(3,:), 'LineWidth', 1.5, 'DisplayName', '$j_{\parallel,\phi}$') - hold on; - case 'all' - plot(r, j_parallel_covar(1,:), 'LineWidth', 1.5, 'DisplayName', '$j_{\parallel,\psi}$') - hold on; - plot(r, j_parallel_covar(2,:), 'LineWidth', 1.5, 'DisplayName', '$j_{\parallel,\theta}$') - plot(r, j_parallel_covar(3,:), 'LineWidth', 1.5, 'DisplayName', '$j_{\parallel,\phi}$') -end - -leg = legend('Location','northwest'); -ylab = ylabel('$\mathbf{J}_\mathcal{V}$'); -xlab = xlabel('r'); -set(gca, 'FontSize', 14) -set(leg,'Interpreter','latex'); -set(xlab,'Interpreter','latex'); -set(ylab,'Interpreter','latex'); -grid on; diff --git a/Utilities/matlabtools/plot_spec_fluxfun.m b/Utilities/matlabtools/plot_spec_fluxfun.m new file mode 100644 index 00000000..221588a0 --- /dev/null +++ b/Utilities/matlabtools/plot_spec_fluxfun.m @@ -0,0 +1,70 @@ +function plot_spec_fluxfun(data,lvol,ns,nt,z0,ncont,newfig) + +% +% PLOT_SPEC_OUTFLUXFUN( DATA, NS, NT, Z0, NCONT, NEWFIG ) +% ======================================================= +% +% Plots iso-contours of Az on a given cross-section +% +% INPUT +% ----- +% -data : must be produced by calling read_spec(filename) +% -lvol : volume number +% -ns : radial resolution for construction of Az +% -nt : poloidal resolution for construction of Az +% -z0 : toroidal angle at which Az is evaluated +% -ncont : number of iso-contour lines +% -newfig : flag for whether a new figure should be open (=1) or not(=0) +% +% Note: should only work for free-boundary equilibria +% Note: poloidal flux function is psi=-A_phi if A_phi is the covariant component and psi=-R*A_phi if A_phi is the canonical component +% +% written by J.Loizu (2018) + + + % Check input + if lvol>data.output.Mvol || lvol<1 + error('Invalid lvol') + end + + if ns<1 + error('Invalid ns') + end + + if nt<1 + error('Invalid nt') + end + + if ncont<1 + error('Invalid ncont') + end + + switch newfig + case 0 + hold on + case 1 + figure + hold on + case 2 + hold off + otherwise + error('Invalid newfig') + end + + % Generate coordinate arrays + sarr = linspace(-1,1,ns); + tarr = linspace(0,2*pi,nt); + + acov = get_spec_vecpot(data,lvol,sarr,tarr,z0); + R = get_spec_R_derivatives(data,lvol,sarr,tarr,z0,'R'); + Z = get_spec_R_derivatives(data,lvol,sarr,tarr,z0,'Z'); + + ffun = -acov{2}; + + if(newfig==1) + figure; hold on; + end + + contour(R{1},Z{1},ffun,ncont,'k') + +end diff --git a/Utilities/matlabtools/plot_spec_jacobian.m b/Utilities/matlabtools/plot_spec_jacobian.m index 82c84fe4..b57b100f 100644 --- a/Utilities/matlabtools/plot_spec_jacobian.m +++ b/Utilities/matlabtools/plot_spec_jacobian.m @@ -9,7 +9,7 @@ % INPUT % ----- % -data : data obtained via read_spec(filename) -% -lvol : volume number +% -lvol : volume number. Set to 0 for plotting all volumes % -sarr : is the array of values for the s-coordinate ('d' for default) % -tarr : is the array of values for the theta-coordinate ('d' for default) % -zarr : is the array of values for the zeta-coordinate ('d' for default) @@ -34,20 +34,10 @@ zarr=0; end -rzbdata = cell(3); - -% Compute sqrt(g) - -jac = get_spec_jacobian(data,lvol,sarr,tarr,zarr); - -% Compute function (R,Z)(s,theta,zeta) - -rzdata = get_spec_rzarr(data,lvol,sarr,tarr,zarr); - -R = rzdata{1}; -Z = rzdata{2}; - -% Plot +% Check input +if (length(sarr)>1) && length(tarr)>1 && length(zarr)>1 + error('This is a 2d plotting routine; one input array has to be a scalar') +end switch newfig case 0 @@ -59,34 +49,57 @@ hold off end -Rtemp = R; -Ztemp = Z; -switch data.input.physics.Igeometry - case 1 - R = tarr; - Z = Rtemp; - case 2 - for it=1:length(tarr) - R(:,it,:) = Rtemp(:,it,:) .* cos(tarr(it)); - Z(:,it,:) = Rtemp(:,it,:) .* sin(tarr(it)); - end - case 3 - R = Rtemp; - Z = Ztemp; -end - +% Allocate memory +rzbdata = cell(3); -for iz=1:length(zarr) - - pcolor(R(:,:,iz),Z(:,:,iz),jac(:,:,iz)); shading interp; colorbar - hold on +if lvol==0 + lstart=1; + lend =data.output.Mvol; +else + lstart=lvol; + lend =lvol; +end - axis equal - title('|B|'); - xlabel('R'); - ylabel('Z'); +for ivol=lstart:lend + % Compute sqrt(g) + jac = squeeze(get_spec_jacobian(data,ivol,sarr,tarr,zarr)); + + % Compute function (R,Z)(s,theta,zeta) + R = get_spec_R_derivatives(data,ivol,sarr,tarr,zarr,'R'); + Z = get_spec_R_derivatives(data,ivol,sarr,tarr,zarr,'Z'); + + R = R{1}; + Z = Z{1}; + + % Plot + Rtemp = R; + Ztemp = Z; + switch data.input.physics.Igeometry + case 1 + R = tarr; + Z = Rtemp; + case 2 + for it=1:length(tarr) + R(:,it,:) = Rtemp(:,it,:) .* cos(tarr(it)); + Z(:,it,:) = Rtemp(:,it,:) .* sin(tarr(it)); + end + case 3 + R = squeeze(Rtemp); + Z = squeeze(Ztemp); + end + + + pcolor(R,Z,jac); + shading interp; + colorbar + hold on end +axis equal +title('|B|'); +xlabel('R'); +ylabel('Z'); + % Output data rzbdata{1} = R; diff --git a/Utilities/matlabtools/plot_spec_modB.m b/Utilities/matlabtools/plot_spec_modB.m index 4034f956..e68613cf 100644 --- a/Utilities/matlabtools/plot_spec_modB.m +++ b/Utilities/matlabtools/plot_spec_modB.m @@ -42,11 +42,11 @@ modB = get_spec_modB(data,lvol,sarr,tarr,zarr); % Compute function (R,Z)(s,theta,zeta) +R = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'R'); +Z = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'Z'); -rzdata = get_spec_rzarr(data,lvol,sarr,tarr,zarr); - -R = rzdata{1}; -Z = rzdata{2}; +R = R{1}; +Z = Z{1}; % Plot diff --git a/Utilities/matlabtools/plot_spec_modB_boundary.m b/Utilities/matlabtools/plot_spec_modB_boundary.m index f8808df2..572609b9 100644 --- a/Utilities/matlabtools/plot_spec_modB_boundary.m +++ b/Utilities/matlabtools/plot_spec_modB_boundary.m @@ -80,11 +80,11 @@ function plot_spec_modB_boundary(data,interface,innout,nt,nz,dimension) case 3 % Compute function (R,Z)(s,theta,zeta) + R = get_spec_R_derivatives(data,vol,sarr,tarr,zarr,'R'); + Z = get_spec_R_derivatives(data,vol,sarr,tarr,zarr,'Z'); - rzdata = get_spec_rzarr(data,vol,sarr,tarr,zarr); - - R = squeeze(rzdata{1}); - Z = squeeze(rzdata{2}); + R = squeeze(R{1}); + Z = squeeze(Z{1}); % Construct cartesian corrdinates diff --git a/Utilities/matlabtools/plot_spec_outfluxfun.m b/Utilities/matlabtools/plot_spec_outfluxfun.m deleted file mode 100644 index c3e28d75..00000000 --- a/Utilities/matlabtools/plot_spec_outfluxfun.m +++ /dev/null @@ -1,41 +0,0 @@ -function plot_spec_outfluxfun(data,ns,nt,z0,ncont,newfig) - -% -% PLOT_SPEC_OUTFLUXFUN( DATA, NS, NT, Z0, NCONT, NEWFIG ) -% ======================================================= -% -% Plots iso-contours of Az on a given cross-section -% -% INPUT -% ----- -% -data : must be produced by calling read_spec(filename) -% -ns : radial resolution for construction of Az -% -nt : poloidal resolution for construction of Az -% -z0 : toroidal angle at which Az is evaluated -% -ncont : number of iso-contour lines -% -newfig : flag for whether a new figure should be open (=1) or not(=0) -% -% Note: should only work for free-boundary equilibria -% Note: poloidal flux function is psi=-A_phi if A_phi is the covariant component and psi=-R*A_phi if A_phi is the canonical component -% -% written by J.Loizu (2018) - - -Nvol = data.input.physics.Nvol; - -lvol = Nvol+1; - -sarr = linspace(-1,1,ns); - -tarr = linspace(0,2*pi,nt); - -acov = get_spec_vecpot(data,lvol,sarr,tarr,z0); -rz = get_spec_rzarr( data,lvol,sarr,tarr,z0); - -ffun = -acov{2}; - -if(newfig==1) - figure; hold on; -end - -contour(rz{1},rz{2},ffun,ncont,'k') diff --git a/Utilities/matlabtools/plot_spec_poincare_3d.m b/Utilities/matlabtools/plot_spec_poincare_3d.m index cda8aa93..1ce38175 100644 --- a/Utilities/matlabtools/plot_spec_poincare_3d.m +++ b/Utilities/matlabtools/plot_spec_poincare_3d.m @@ -25,7 +25,7 @@ function plot_spec_poincare_3d( data, varargin ) % Set up options opt.nt = 64; opt.nz = 64; -opt.phiend = 2*pi / Nfp; +opt.phiend = 2*pi / max(Nfp,2); opt.tstart = 0; l = length(varargin); @@ -44,12 +44,11 @@ function plot_spec_poincare_3d( data, varargin ) tarr = linspace(0,2*pi ,opt.nt); zarr = linspace(0,opt.phiend ,opt.nz); -%modB = get_spec_modB(data,Nvol,sarr,tarr,zarr); +R = get_spec_R_derivatives(data,Nvol,sarr,tarr,zarr,'R'); +Z = get_spec_R_derivatives(data,Nvol,sarr,tarr,zarr,'Z'); -rzdata = get_spec_rzarr(data,Nvol,sarr,tarr,zarr); - -R = squeeze(rzdata{1}); -Z = squeeze(rzdata{2}); +R = squeeze(R{1}); +Z = squeeze(Z{1}); % Construct cartesian corrdinates @@ -157,11 +156,12 @@ function plot_spec_poincare_3d( data, varargin ) Y = []; Z = []; for ii = 1:nstep - rzdata = get_spec_rzarr(data,Nvol,1,tarr(ii),phi(ii)); + Rd = get_spec_R_derivatives(data,Nvol,sarr,tarr(ii),phi(ii),'R'); + Zd = get_spec_R_derivatives(data,Nvol,sarr,tarr(ii),phi(ii),'Z'); - X(ii) = squeeze(rzdata{1}) * cos(phi(ii)); - Y(ii) = squeeze(rzdata{1}) * sin(phi(ii)); - Z(ii) = squeeze(rzdata{2}); + X(ii) = squeeze(Rd{1}) * cos(phi(ii)); + Y(ii) = squeeze(Rd{1}) * sin(phi(ii)); + Z(ii) = squeeze(Zd{1}); end scatter3( X, Y, Z, 10, 'MarkerFaceColor', col.Leman, 'MarkerEdgeColor', col.Leman) diff --git a/Utilities/matlabtools/plot_spec_polflux.m b/Utilities/matlabtools/plot_spec_polflux.m index 9b4f3824..7c27e984 100644 --- a/Utilities/matlabtools/plot_spec_polflux.m +++ b/Utilities/matlabtools/plot_spec_polflux.m @@ -29,8 +29,9 @@ function plot_spec_polflux(data, zeta, cumulative, newfig) polflux = zeros(1,Nvol); % Start at one only if slab geometry (otherwise it is zero by definition) +sarr = linspace(-1, 1, 64); if data.input.physics.Igeometry==1 - polflux(1) = get_spec_polflux(data,1,zeta,-1,1,64,64); + polflux(1) = get_spec_polflux(data,1,zeta,sarr,64); end for lvol=2:Nvol diff --git a/Utilities/matlabtools/plot_spec_surface_current.m b/Utilities/matlabtools/plot_spec_surface_current.m new file mode 100644 index 00000000..300f01f7 --- /dev/null +++ b/Utilities/matlabtools/plot_spec_surface_current.m @@ -0,0 +1,57 @@ +function plot_spec_surface_current(data, nt, newfig) + +% +% PLOT_SPEC_SURFACE_CURRENT( DATA, NS, NT, ZETA, NEWFIG ) +% =================================================== +% +% Plot pressure-driven currents located at each volume interface +% +% INPUT +% ----- +% -data : data obtained via read_spec(filename) +% -nt : number of poloidal interpolation points +% -zeta : toroidal angle +% -newfig : plots on an existing figure (=0), a new figure (=1) or +% overwrites last figure (=2) +% +% written by A.Baillod (2019) +% + + % Test input + if nt<1 + error('Invalid nt') + end + + + switch newfig + case 0 + hold on + case 1 + figure + hold on + case 2 + hold off + otherwise + error('Invalide newfig') + end + + % Evaluate toroidal current + Itor = get_spec_torcurr_kam_net(data, nt); + Mvol = data.output.Mvol; + + + %plot(tflux(1:end-1), IPDt, '*') + bar(Itor, 'BarWidth', 0.3); + grid on + %xl = xlabel('$\psi_t / \psi_{edge}$'); + xl = xlabel('Surface label'); + yl = ylabel('$\mu_0 I_\mathcal{S}$[A]'); + xlim([0, Mvol]) + + set(xl, 'Interpreter', 'latex'); + set(yl, 'Interpreter', 'latex'); + + set(gca, 'FontSize', 14) + + +end diff --git a/Utilities/matlabtools/plot_spec_surfcurent.m b/Utilities/matlabtools/plot_spec_surfcurent.m deleted file mode 100644 index feb04142..00000000 --- a/Utilities/matlabtools/plot_spec_surfcurent.m +++ /dev/null @@ -1,49 +0,0 @@ -function plot_spec_surfcurent(data, ns, nt, zeta, newfig) - -% -% PLOT_SPEC_SURFCURRENT( DATA, NS, NT, ZETA, NEWFIG ) -% =================================================== -% -% Plot pressure-driven currents located at each volume interface -% -% INPUT -% ----- -% -data : data obtained via read_spec(filename) -% -ns : number of radial interpolation points -% -nt : number of poloidal interpolation points -% -zeta : toroidal angle -% -newfig : plots on an existing figure (=0), a new figure (=1) or -% overwrites last figure (=2) -% -% written by A.Baillod (2019) -% - -[tflux, IPDt] = get_spec_surface_current(data, ns, nt, zeta); - -Nvol = data.input.physics.Nvol + data.input.physics.Lfreebound; - -switch newfig - case 0 - hold on - case 1 - figure - hold on - case 2 - hold off -end - -%plot(tflux(1:end-1), IPDt, '*') -bar(IPDt, 'BarWidth', 0.3); -grid on -%xl = xlabel('$\psi_t / \psi_{edge}$'); -xl = xlabel('Surface label'); -yl = ylabel('$\mu_0 I_\mathcal{S}$[A]'); -xlim([0, Nvol]) - -set(xl, 'Interpreter', 'latex'); -set(yl, 'Interpreter', 'latex'); - -set(gca, 'FontSize', 14) - - -end diff --git a/Utilities/matlabtools/run_spec.m b/Utilities/matlabtools/run_spec.m new file mode 100644 index 00000000..6667fe8d --- /dev/null +++ b/Utilities/matlabtools/run_spec.m @@ -0,0 +1,48 @@ +function run_spec(fname, comment) + +% Go in ~/specruns/ +!cd ~/specruns/ + +% Run SPEC +command = char(['./xspec ', fname]); +system(command) + +% Move everything in there +h5fname = [fname, '.sp.h5']; + +c = datetime('now'); + +matname = [fname, '.sp.mat']; + + +gdata = read_spec_grid(h5fname); +input = compose(string([ + '\n Igeometry = ', num2str(gdata.Igeometry), ... + '\n Lconstraint = ', num2str(gdata.Lconstraint), ... + '\n Lfreebound = ', num2str(gdata.Lfreebound), ... + '\n Nvol = ', num2str(gdata.Nvol), ... + '\n Mrad = ', num2str(gdata.Mrad), ... + '\n Nfp = ', num2str(gdata.Nfp), ... + '\n Ntor = ', num2str(gdata.Ntor), ... + '\n Mpol = ', num2str(gdata.Mpol), ... + '\n'])); +output = compose(string([ + '\n ForceErr = ', num2str(gdata.ForceErr), ... + '\n'])); + + +out.date = c; +out.comment = comment; +out.input = fname; +out.h5name = h5fname; +out.input = input; +out.output = output; + + +% Write mat file +save(matname, '-struct', 'out'); + + + + +end \ No newline at end of file From 084bda5bff15d3858fc8927fbf896745d7e0e428 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 6 May 2022 13:54:16 +0200 Subject: [PATCH 004/134] update matlab tools --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 384 ++++ .../SPEC_Namelist_depr.m} | 1435 ++++++++----- .../rw_namelist/rw_namelist/read_namelist.m | 340 ++++ .../rw_namelist/rw_namelist/write_namelist.m | 100 + Utilities/matlabtools/Tutorial.01.txt | 4 +- Utilities/matlabtools/Tutorial.02.txt | 2 +- Utilities/matlabtools/get_spec_polflux.m | 2 +- Utilities/matlabtools/modify_Linitialize.m | 53 - Utilities/matlabtools/plot_spec.m | 1207 ----------- Utilities/matlabtools/plot_spec_Bgrid.m | 17 +- Utilities/matlabtools/plot_spec_Ivolume.m | 43 +- .../matlabtools/plot_spec_current_profile.m | 165 +- Utilities/matlabtools/plot_spec_grid.m | 11 +- Utilities/matlabtools/plot_spec_hessian.m | 21 - Utilities/matlabtools/plot_spec_iota.m | 354 ++-- Utilities/matlabtools/plot_spec_iotakam.m | 120 +- Utilities/matlabtools/plot_spec_iterations.m | 109 +- Utilities/matlabtools/plot_spec_jacobian.m | 44 +- Utilities/matlabtools/plot_spec_kam.m | 212 +- Utilities/matlabtools/plot_spec_modB.m | 161 +- .../matlabtools/plot_spec_modB_boundary.m | 192 +- Utilities/matlabtools/plot_spec_poincare.m | 86 +- Utilities/matlabtools/plot_spec_poincare_3d.m | 227 +-- Utilities/matlabtools/plot_spec_polflux.m | 70 +- Utilities/matlabtools/plot_spec_pressure.m | 11 +- .../matlabtools/plot_spec_surface_current.m | 4 +- Utilities/matlabtools/plot_spec_torflux.m | 59 +- Utilities/matlabtools/plot_spec_wall.m | 91 +- Utilities/matlabtools/produce_spec_movie.m | 1 + Utilities/matlabtools/read_hdf5.m | 81 - Utilities/matlabtools/read_spec.m | 1 - Utilities/matlabtools/read_spec_field.m | 127 -- Utilities/matlabtools/read_spec_hessian.m | 82 - Utilities/matlabtools/read_spec_iota.m | 95 - Utilities/matlabtools/read_spec_poincare.m | 103 - Utilities/matlabtools/run_spec.m | 48 - .../matlabtools/run_spec_iter_fixtorcurr.m | 137 -- Utilities/matlabtools/specheck.m | 293 --- Utilities/matlabtools/write_spec_Bxyz.m | 32 - Utilities/matlabtools/write_spec_input_L0.m | 113 -- Utilities/matlabtools/write_spec_input_L1.m | 125 -- Utilities/matlabtools/write_spec_input_L3.m | 131 -- Utilities/matlabtools/write_spec_rzgrid.m | 3 +- out.txt | 1801 +++++++++++++++++ 44 files changed, 4628 insertions(+), 4069 deletions(-) create mode 100644 Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m rename Utilities/matlabtools/{SPEC_Namelist.m => SPEC_Namelist/SPEC_Namelist_depr.m} (56%) create mode 100755 Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/read_namelist.m create mode 100755 Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m delete mode 100644 Utilities/matlabtools/modify_Linitialize.m delete mode 100644 Utilities/matlabtools/plot_spec.m delete mode 100644 Utilities/matlabtools/plot_spec_hessian.m delete mode 100644 Utilities/matlabtools/read_hdf5.m delete mode 100644 Utilities/matlabtools/read_spec_field.m delete mode 100644 Utilities/matlabtools/read_spec_hessian.m delete mode 100644 Utilities/matlabtools/read_spec_iota.m delete mode 100644 Utilities/matlabtools/read_spec_poincare.m delete mode 100644 Utilities/matlabtools/run_spec.m delete mode 100644 Utilities/matlabtools/run_spec_iter_fixtorcurr.m delete mode 100644 Utilities/matlabtools/specheck.m delete mode 100644 Utilities/matlabtools/write_spec_Bxyz.m delete mode 100644 Utilities/matlabtools/write_spec_input_L0.m delete mode 100644 Utilities/matlabtools/write_spec_input_L1.m delete mode 100644 Utilities/matlabtools/write_spec_input_L3.m create mode 100644 out.txt diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m new file mode 100644 index 00000000..42390251 --- /dev/null +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -0,0 +1,384 @@ +classdef SPEC_Namelist + properties (Access=public) + lists + physicslist + numericlist + locallist + globallist + diagnosticslist + screenlist + initial_guess + end + + properties (Access=private) + Mpol = 0; + Ntor = 0; + array_size = [0, 0]; + Mvol = 0; + + end + + methods (Access=public) + % Class constructor + function obj = SPEC_Namelist( filename ) + + work = read_namelist( filename ); + obj.lists = fields(work); + obj.physicslist = work.physicslist; + obj.numericlist = work.numericlist; + obj.locallist = work.locallist; + obj.globallist = work.globallist; + obj.diagnosticslist = work.diagnosticslist; + obj.screenlist = work.screenlist; + obj.initial_guess = []; + + % Check that the size of arrays makes sense, fills with zeros + % otherwise + obj = obj.initialize_structure(); + + % Find the largest Fourier resolution used in the input file; + % reformat all spectral quantities to have the same resolution + obj = obj.set_fourier_resolution(); + + + + end + + end + + methods (Access=private) + + function obj = initialize_structure( obj ) + + % Fill some important inputs + if ~isfield(obj.physicslist, 'Nvol') + error('Missing Nvol') + end + if ~isfield(obj.physicslist, 'Lfreebound') + error('Missing Lfreebound') + end + + obj.Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; + + % PHYSICSLIST + % ----------- + % Lrad + if ~isfield(obj.physicslist, 'Lrad') + warning('Missing Lrad. Filling with 4...') + obj.physicslist.Lrad = ones(1,obj.Mvol) * 4; + else + % Fill potential missing elements with 4s + obj.physicslist.Lrad(end+1:obj.Mvol) = 4; + end + + % tflux + if ~isfield(obj.physicslist, 'tflux') + warning('Missing tflux. Filling equal radial distances') + obj.physicslist.tflux = (1:obj.Mvol).^2; + else + if length(obj.physicslist.tflux)~=obj.Mvol + error('Invalid number of tflux elements') + end + end + + % pflux + if ~isfield(obj.physicslist, 'pflux') + warning('Missing pflux. Filling with 0...') + obj.physicslist.pflux = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.pflux(end+1:obj.Mvol) = 0; + end + + % helicity + if ~isfield(obj.physicslist, 'helicity') + warning('Missing Lrad. Filling with 0...') + obj.physicslist.helicity = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.helicity(end+1:obj.Mvol) = 0; + end + + % pscale + if ~isfield(obj.physicslist, 'pscale') + warning('Missing pscale. Setting to zero...') + obj.physicslist.pscale = 0.0; + end + + % Ladiabatic + if ~isfield(obj.physicslist, 'Ladiabatic') + warning('Missing Ladiabatic. Setting to zero...') + obj.physicslist.Ladiabatic = 0.0; + end + + % Pressure + if ~isfield(obj.physicslist, 'pressure') + warning('Missing pressure. Filling with 0...') + obj.physicslist.pressure = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.pressure(end+1:obj.Mvol) = 0; + end + + % Adiabatic + if obj.physicslist.Ladiabatic==1 + if ~isfield(obj.physicslist, 'adiabatic') + warning('Missing adiabatic. Filling with 0...') + obj.physicslist.adiabatic = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.adiabatic(end+1:obj.Mvol) = 0; + end + end + + % mu + if ~isfield(obj.physicslist, 'mu') + warning('Missing mu. Filling with 0...') + obj.physicslist.mu = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.mu(end+1:obj.Mvol) = 0; + end + + % Lconstraint + if ~isfield(obj.physicslist, 'Lconstraint') + warning('Missing Lconstraint. Setting to 0...') + obj.physicslist.Lconstraint = 0; + end + + if ~any(obj.physicslist.Lconstraint==[0,1,2,3]) + error('Invalid Lconstraint') + end + + + % Ivolume, Isurf + if obj.physicslist.Lconstraint==3 + if ~isfield(obj.physicslist, 'Ivolume') + warning('Missing Ivolume. Filling with 0...') + obj.physicslist.Ivolume = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.Ivolume(end+1:obj.Mvol) = 0; + end + if ~isfield(obj.physicslist, 'Isurf') + warning('Missing Isurf. Filling with 0...') + obj.physicslist.Isurf = zeros(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.Isurf(end+1:obj.Mvol) = 0; + end + end + + if obj.physicslist.Lconstraint==1 + if ~isfield(obj.physicslist, 'iota') + warning('Missing iota. Filling with sqrt(2)...') + obj.physicslist.iota = sqrt(2)*ones(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.iota(end+1:obj.Mvol) = sqrt(2); + end + if ~isfield(obj.physicslist, 'oita') + warning('Missing oita. Filling with sqrt(2)...') + obj.physicslist.oita = sqrt(2)*ones(1,obj.Mvol); + else + % Fill potential missing elements with zeros + obj.physicslist.oita(end+1:obj.Mvol) = sqrt(2); + end + end + + % mupftol + if ~isfield(obj.physicslist, 'mupftol') + warning('Missing mupftol. Setting to 1E-12...') + obj.physicslist.mupftol = 1E-12; + end + + % mupfits + if ~isfield(obj.physicslist, 'mupfits') + warning('Missing mupfits. Setting to 128...') + obj.physicslist.mupfits = 128; + end + + % Check geometry + if ~isfield(obj.physicslist, 'Mpol') + error('Missing Mpol information') + end + if ~isfield(obj.physicslist, 'Ntor') + error('Missing Ntor information') + end + if ~isfield(obj.physicslist, 'Lboundary') + warning('Missing Lboundary. Setting to zero') + obj.physicslist.Lboundary = 0; + end + + Mpol_in = obj.physicslist.Mpol; + Ntor_in = obj.physicslist.Ntor; + + if obj.physicslist.Lboundary==0 + if ~isfield(obj.physicslist, 'Rbc') + obj.physicslist.Rbc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Rbs') + obj.physicslist.Rbs = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Zbc') + obj.physicslist.Zbc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Zbs') + obj.physicslist.Zbs = zeros(2*Ntor_in+1, Mpol_in); + end + + % Check that sizes are consistent with each others + if any(size(obj.physicslist.Rbc)~=size(obj.physicslist.Rbs)) + error('Size mismatch between Rbc and Rbs') + end + if any(size(obj.physicslist.Rbc)~=size(obj.physicslist.Zbc)) + error('Size mismatch between Rbc and Zbc') + end + if any(size(obj.physicslist.Rbc)~=size(obj.physicslist.Zbs)) + error('Size mismatch between Rbc and Zbs') + end + + + + if ~isfield(obj.physicslist, 'Rwc') + obj.physicslist.Rwc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Rws') + obj.physicslist.Rws = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Zwc') + obj.physicslist.Zwc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Zws') + obj.physicslist.Zws = zeros(2*Ntor_in+1, Mpol_in); + end + + % Check that sizes are consistent with each others + if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Rws)) + error('Size mismatch between Rwc and Rws') + end + if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zwc)) + error('Size mismatch between Rwc and Zwc') + end + if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zws)) + error('Size mismatch between Rwc and Zws') + end + + + + else + error('To complete') + end + + if ~isfield(obj.physicslist, 'Vnc') + obj.physicslist.Vnc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Vns') + obj.physicslist.Vns = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Bnc') + obj.physicslist.Bnc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Bns') + obj.physicslist.Bns = zeros(2*Ntor_in+1, Mpol_in); + end + + % Check that sizes are consistent with each others + if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Vns)) + error('Size mismatch between Rwc and Vns') + end + if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Bnc)) + error('Size mismatch between Rwc and Bnc') + end + if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Bns)) + error('Size mismatch between Rwc and Bns') + end + + % DIAGNOSTICSLIST + % --------------- + if ~isfield(obj.diagnosticslist, 'nPpts') + warning('Missing nPpts. Setting to zero') + obj.diagnosticslist.nPpts = 0; + end + + if ~isfield(obj.diagnosticslist, 'nPtrj') + warning('Missing nPtrj. Setting to zero') + obj.diagnosticslist.nPtrj = 0; + end + end + + + + + + function obj = set_fourier_resolution( obj ) + + % Check beforehand that the resolution of Rbc is the same as + % Rbs, Zbc and Zbs. Do something similar for Vnc, Vns, Bnc, Bns + % and Rwc, Rws, Zws, Zwc. + + % Find largest Fourier resolution in the input file + Mpol_in = obj.physicslist.Mpol; + Ntor_in = obj.physicslist.Ntor; + + s_bc = size(obj.physicslist.Rbc); + shift = obj.physicslist.shift.Rbc(1); + Mpol_bc = s_bc(2)-1 ; + Ntor_bc = max([abs(1-shift), s_bc(1)-shift]); + + s_wc = size(obj.physicslist.Rwc); + shift = obj.physicslist.shift.Rwc(1); + Mpol_wc = s_wc(2)-1 ; + Ntor_wc = max([abs(1-shift), s_wc(1)-shift]); + + s_vb = size(obj.physicslist.Vnc); + shift = obj.physicslist.shift.Vnc(1); + Mpol_vb = s_vb(2)-1 ; + Ntor_vb = max([abs(1-shift), s_vb(1)-shift]); + + obj.Mpol = max([Mpol_in, Mpol_bc, Mpol_wc, Mpol_vb]); + obj.Ntor = max([Ntor_in, Ntor_bc, Ntor_wc, Ntor_vb]); + obj.array_size = [2*obj.Ntor+1, obj.Mpol+1]; + + % Check that all arrays have the same size; otherwise, fill + % with zeros the missing elements + if any(size(obj.physicslist.Rbc)~=obj.array_size) + obj.physicslist.Rbc = obj.reshape_array( obj.physicslist.Rbc, Ntor_bc ); + obj.physicslist.Rbs = obj.reshape_array( obj.physicslist.Rbs, Ntor_bc ); + obj.physicslist.Zbc = obj.reshape_array( obj.physicslist.Zbc, Ntor_bc ); + obj.physicslist.Zbs = obj.reshape_array( obj.physicslist.Zbs, Ntor_bc ); + end + + if any(size(obj.physicslist.Rwc)~=obj.array_size) + obj.physicslist.Rwc = obj.reshape_array( obj.physicslist.Rwc, Ntor_wc ); + obj.physicslist.Rws = obj.reshape_array( obj.physicslist.Rws, Ntor_wc ); + obj.physicslist.Zwc = obj.reshape_array( obj.physicslist.Zwc, Ntor_wc ); + obj.physicslist.Zws = obj.reshape_array( obj.physicslist.Zws, Ntor_wc ); + end + + if any(size(obj.physicslist.Vnc)~=obj.array_size) + obj.physicslist.Vnc = obj.reshape_array( obj.physicslist.Vnc, Ntor_vb ); + obj.physicslist.Vns = obj.reshape_array( obj.physicslist.Vns, Ntor_vb ); + obj.physicslist.Bnc = obj.reshape_array( obj.physicslist.Bnc, Ntor_vb ); + obj.physicslist.Bns = obj.reshape_array( obj.physicslist.Bns, Ntor_vb ); + end + end + + + function new_array = reshape_array( obj, array, Ntor_array ) + + s = size(array); + + new_array = zeros(obj.array_size); + for ii=1:s(1) + for jj=1:s(2) + nn = ii-Ntor_array-1; + mm = jj-1; + + new_array(nn+obj.Ntor+1, mm+1) = array(ii, jj); + end + end + end + end + +end \ No newline at end of file diff --git a/Utilities/matlabtools/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m similarity index 56% rename from Utilities/matlabtools/SPEC_Namelist.m rename to Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m index 4f2a5021..bf887ee9 100644 --- a/Utilities/matlabtools/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m @@ -14,266 +14,196 @@ % ===================================================================== % Class constructor - function obj = SPEC_Namelist(inputfile, varargin) - - if( ~isempty(varargin) ) - input_category = varargin{1}; - end - - fid = fopen(inputfile,'r'); % open template file - tline = fgetl(fid); - - obj.lists = {'physicslist', 'numericlist', 'locallist', ... - 'globallist', 'diagnosticslist', 'screenlist'}; - - for ii=numel(obj.lists) - list = obj.lists{ii}; - obj.(list) = struct; + function obj = SPEC_Namelist(inputfile) + + % Read namelist + work = read_namelist( inputfile ); + obj.lists = fields(work); + + % Read Lboundary + if isfield(work.physicslist, 'Lboundary') + Lboundary = work.physicslist.Lboundary; + else + Lboundary = 0; % by default end - category = ''; - - boundary.Rbc = []; boundary.Rbs = []; boundary.Zbc = []; boundary.Zbs = []; ib=0; bm = []; bn = []; - wall.Rwc = []; wall.Rws = []; wall.Zwc = []; wall.Zws = []; iw=0; wm = []; wn = []; - Nfield.Vns = []; Nfield.Vnc = []; Nfield.Bnc = []; Nfield.Bns = []; iv=0; vm = []; vn = []; - - iline = 0; - while ~isempty(tline) || feof(fid) - - % Remove trailing and leading spaces - tline = strtrim(tline); - - if feof(fid) - break; - end - - iline = iline + 1 ; - % jump / lines between categories. - if strcmp(tline, '/') - if strcmp(category,'screenlist') - break; % end of file, ignore geometry initial guess - else - tline = fgetl(fid); - continue; - end - end - - % read category - if strcmp(tline(end-3:end),'list') - category = tline(2:end); - tline = fgetl(fid); - continue; - end - - - % Field - try - field = extractBefore(tline,'='); %read field - field = char(field); - field = field(~isspace(field)); %remove spaces - catch - disp(['Error in field reading at line ', num2str(iline)]) - disp(['Field is ', field]) - end - - - % Content - if length(field)<3 - - try - content_str = extractAfter(tline,'='); - content = char(content_str); - content = content(~isspace(content)); - if strcmp(content,'F') - content = false; - elseif strcmp(content,'T') - content = true; - else - content = str2num(char(content_str)); - end - - % Store in structure - obj.(category).(field) = content; - - catch - error(['Error reading line ', tline]) - + + if Lboundary==0 + % Build im, in arrays + + %If boundary not given + if ~isfield(work.physicslist, 'Rbc') + if work.physicslist.Lfreebound==1 + work.physicslist.Rbc = zeros(size(work.physicslist.Rwc)); + work.physicslist.Rbs = zeros(size(work.physicslist.Rwc)); + work.physicslist.Zbc = zeros(size(work.physicslist.Rwc)); + work.physicslist.Zbs = zeros(size(work.physicslist.Rwc)); + work.physicslist.shift.Rbc = work.physicslist.shift.Rwc; + work.physicslist.shift.Rbs = work.physicslist.shift.Rws; + work.physicslist.shift.Zbc = work.physicslist.shift.Zwc; + work.physicslist.shift.Zbs = work.physicslist.shift.Zws; + else + error('Plasma boundary is not provided') + end end - - - else - if strcmp(field(1:3),'Rbc') %need to split Rbc, Rbs, Zbc, Zbs - ib = ib + 1; - [n, m] = obj.get_nm_from_field(field); - - [value, field] = obj.extract_4_values(tline, n, m, 'Rbc', 'Zbs', 'Rbs', 'Zbc'); - - boundary.Rbc(ib) = 0.0; - boundary.Zbc(ib) = 0.0; - boundary.Zbs(ib) = 0.0; - boundary.Rbs(ib) = 0.0; - - nfield = length(field); - for ii=1:nfield - boundary.(field{ii})(ib) = value{ii}; - end - - bm(ib) = m; - bn(ib) = n; - - elseif strcmp(field(1:3),'Rwc') % same as above - iw = iw + 1; - [n, m] = obj.get_nm_from_field(field); - - [value, field] = obj.extract_4_values(tline, n, m, 'Rwc', 'Zws', 'Rws', 'Zwc'); - - wall.Rwc(iw) = 0.0; - wall.Zwc(iw) = 0.0; - wall.Zws(iw) = 0.0; - wall.Rws(iw) = 0.0; - - nfield = length(field); - for ii=1:nfield - wall.(field{ii})(iw) = value{ii}; - end - - wm(iw) = m; - wn(iw) = n; - - elseif strcmp(field(1:3),'Vns') || strcmp(field(1:3),'Vnc') || strcmp(field(1:3),'Bns') || strcmp(field(1:3),'Bnc')% same as above - iv = iv + 1; - [n, m] = obj.get_nm_from_field(field); - - [value, field] = obj.extract_4_values(tline, n, m, 'Vns', 'Bns', 'Vnc', 'Bnc'); - - Nfield.Vnc(iv) = 0.0; - Nfield.Bnc(iv) = 0.0; - Nfield.Vns(iv) = 0.0; - Nfield.Bns(iv) = 0.0; - - nfield = length(field); - for ii=1:nfield - Nfield.(field{ii})(iv) = value{ii}; - end - - vm(iv) = m; - vn(iv) = n; - - else % easier, just read content - content_str = extractAfter(tline,'='); - - content = char(content_str); - content = content(~isspace(content)); - if strcmp(content,'F') - content = false; - elseif strcmp(content,'T') - content = true; - else - content = str2num(char(content_str)); - end - - % Store in structure - if isempty(category) - obj.(input_category).(field) = content; - else - obj.(category).(field) = content; - end + + if ~isfield(work.physicslist, 'Rwc') && work.physicslist.Lfreebound==1 + error('Computational boundary is not provided') end - end - - % get next line - tline = fgetl(fid); - end - - % Store rbc, rbs ... in structure - - boundaryfields = fieldnames(boundary); - wallfields = fieldnames(wall); - Nfieldfields = fieldnames(Nfield); - - for ii=1:4 - obj.physicslist.(boundaryfields{ii}) = boundary.(boundaryfields{ii}); - obj.physicslist.(wallfields{ii}) = wall.(wallfields{ii}); - obj.physicslist.(Nfieldfields{ii}) = Nfield.(Nfieldfields{ii}); - end + + if ~isfield(work.physicslist, 'Vnc') && work.physicslist.Lfreebound==1 + work.physicslist.Vnc = zeros(size( + + s = size(work.physicslist.Rbc); + mpol = s(2) - 1; + ntor = (s(1) - 1) / 2.0; - fclose(fid); % close template file + im = 0:mpol; + in = -ntor:ntor; - % Reformat the Rbc, Zbs, ... arrays - if(isfield(obj.physicslist, 'Mpol')) - Mpol = obj.physicslist.Mpol; - Ntor = obj.physicslist.Ntor; + [work.physicslist.im, work.physicslist.in] = meshgrid(im,in); + + + % Need to build Rbc, Zbs, ... + arr_str = {'Rbc', 'Rbs', 'Zbc', 'Zbs', 'Rwc', 'Rws', 'Zwc', 'Zws', 'Vnc', 'Vns', 'Bnc', 'Bns'}; + n = length(arr_str); + ntor = zeros(1,n); + mpol = zeros(1,n); + for ii=1:n + + if ~isfield(work.physicslist, arr_str{ii}) + ntor(ii) = 0; + mpol(ii) = 0; + + continue + end + + if ~isfield(work.physicslist.shift, arr_str{ii}) + ntor(ii) = 0; + mpol(ii) = 0; + + continue + end + + s_shift = size(work.physicslist.(arr_str{ii})) - work.physicslist.shift.(arr_str{ii}); + ntor(ii) = s_shift(1); + mpol(ii) = s_shift(2); + + end + + %select poloidal and toroidal resolution for our arrays + if isfield(work.physicslist, 'Mpol') + Mpol = max(max(mpol), work.physicslist.Mpol); + Ntor = max(max(ntor), work.physicslist.Ntor); + else + Mpol = max(mpol); + Ntor = max(ntor); + end + + + bnd = struct; + for ii=1:n + fldname = arr_str{ii}; + bnd.(fldname) = zeros(Mpol+1, 2*Ntor+1); + + if ~isfield(work.physicslist, arr_str{ii}) + continue + end + + if ~isfield(work.physicslist.shift, arr_str{ii}) + continue + end + + + flds = size( work.physicslist.(fldname) ); + s = work.physicslist.shift.(fldname); + for in=1:flds(1) + + nn = in - s(1); + + for im=1:flds(2) + + mm = im - s(2); + bnd.(fldname)(mm+1,nn+Ntor+1) = work.physicslist.(fldname)(in,im); + + end + end + end + + % Finally build im, in grids + im = 0:Mpol; + in = -Ntor:Ntor; + + [in, im] = meshgrid(in, im); + + work.physicslist.im = im; + work.physicslist.in = in; + + + else - Mpol = max([wm,bm,vm]); Ntor = max([wn,bn,vn]); - end - - mn = 1 + Ntor + Mpol * ( 2 * Ntor + 1 ); - - Rbc = zeros(1,mn); Rbs = zeros(1,mn); Zbc = zeros(1,mn); Zbs = zeros(1,mn); - Rwc = zeros(1,mn); Rws = zeros(1,mn); Zwc = zeros(1,mn); Zws = zeros(1,mn); - Vnc = zeros(1,mn); Vns = zeros(1,mn); Bnc = zeros(1,mn); Bns = zeros(1,mn); - im = zeros(1,mn); - in = zeros(1,mn); - - im(1:1+Ntor) = 0; - in(1:1+Ntor) = 0:Ntor; - count = Ntor+1; - for ii=1:Mpol - for jj=-Ntor:Ntor - count = count + 1; - im( count ) = ii; - in( count ) = jj; - end + + arr_str = {'R0c', 'Z0s', 'bn','rhomn'}; + n = length(arr_str); + ntor_arr = zeros(1,n); + + for ii=1:n + if strcmp(arr_str{ii}, 'rhomn') + continue + end + + ntor_arr(ii) = length(work.physicslist.(arr_str{ii}))-1; + end + + ntor = max( [work.physicslist.Ntor, max(ntor_arr)] ); + + for ii=1:n + if strcmp(arr_str{ii}, 'rhomn') + continue + end + + bnd.(arr_str{ii}) = zeros(1, ntor); + bnd.(arr_str{ii})(1:ntor_arr(ii)+1) = work.physicslist.(arr_str{ii})(1:ntor_arr(ii)+1); + end + + % Now deal with rhomn + s = size(work.physicslist.rhomn); + ntor_rho = max( (s(1)-1)/2.0, work.physicslist.Ntor ); + mpol_rho = max( s(2)-1 , work.physicslist.Mpol ); + + bnd.rhomn = zeros( mpol_rho+1, 2*ntor_rho+1 ); + + for ii=1:s(1) + + nn = ii - work.physicslist.shift.rhomn(1); + + for jj=1:s(2) + + mm = jj - work.physicslist.shift.rhomn(2); + + bnd.rhomn( mm+1, nn+ntor_rho+1 ) = work.physicslist.rhomn( ii, jj ); + end + end + + im = 0:mpol_rho; + in = -ntor_rho:ntor_rho; + + [in, im] = meshgrid(in, im); + + work.physicslist.im = im; + work.physicslist.in = in; + end - - for imn = 1:mn - m = im(imn); - n = in(imn); - - b_ind = find(double(bm==m) .* double(bn==n)); - if( ~isempty(b_ind) ) - Rbc( imn ) = obj.physicslist.Rbc( b_ind ); - Rbs( imn ) = obj.physicslist.Rbs( b_ind ); - Zbc( imn ) = obj.physicslist.Zbc( b_ind ); - Zbs( imn ) = obj.physicslist.Zbs( b_ind ); - end - - w_ind = find(double(wm==m) .* double(wn==n)); - if( ~isempty(w_ind) ) - Rwc( imn ) = obj.physicslist.Rwc( w_ind ); - Rws( imn ) = obj.physicslist.Rws( w_ind ); - Zwc( imn ) = obj.physicslist.Zwc( w_ind ); - Zws( imn ) = obj.physicslist.Zws( w_ind ); - end - - v_ind = find(double(vm==m) .* double(vn==n)); - if( ~isempty(v_ind) ) - Vnc( imn ) = obj.physicslist.Vnc( v_ind ); - Vns( imn ) = obj.physicslist.Vns( v_ind ); - Bnc( imn ) = obj.physicslist.Bnc( v_ind ); - Bns( imn ) = obj.physicslist.Bns( v_ind ); - end + + % Store in object + for ii=1:length(obj.lists) + obj.(obj.lists{ii}) = work.(obj.lists{ii}); end - - obj.physicslist.im = im; - obj.physicslist.in = in; - - obj.physicslist.Rbc = Rbc; - obj.physicslist.Rbs = Rbs; - obj.physicslist.Zbc = Zbc; - obj.physicslist.Zbs = Zbs; - obj.physicslist.Rwc = Rwc; - obj.physicslist.Rws = Rws; - obj.physicslist.Zwc = Zwc; - obj.physicslist.Zws = Zws; - - obj.physicslist.Vnc = Vnc; - obj.physicslist.Vns = Vns; - obj.physicslist.Bnc = Bnc; - obj.physicslist.Bns = Bns; + for ii=1:n + fldname = arr_str{ii}; + obj.physicslist.(fldname) = bnd.(fldname); + end - obj = obj.update_flux_surfaces(); - % Read initial guess try obj = obj.read_initial_guess( inputfile ); @@ -283,7 +213,6 @@ end - function obj = read_initial_guess(obj, init_guess_file) % % Read geometrical initial guess from another input / .end file @@ -308,26 +237,7 @@ tline = fgetl(fid2); tline = strtrim(tline); - - field = extractBefore(tline,'='); %read field - field = char(field); - field = field(~isspace(field)); %remove spaces - content_str = extractAfter(tline,'='); - content = str2num(content_str); - - % Read initial guess for coordinate axis - switch field - case 'Rac' - obj.physicslist.Rac = content; - case 'Ras' - obj.physicslist.Ras = content; - case 'Zac' - obj.physicslist.Zac = content; - case 'Zas' - obj.physicslist.Zas = content; - end - - + if( save_line ) % write line initial_guess{end+1} = tline; @@ -345,8 +255,6 @@ end end - - end % end of while fclose(fid2); % Close file @@ -355,50 +263,198 @@ % Now, format initial guess in arrays % Prepare format for reading nlines = length(initial_guess); + + if isfield(obj.physicslist, 'Lboundary'); + Lboundary = obj.physicslist.Lboundary; + else + Lboundary = 0; % by default + end + + if nlines>0 - % Allocate memory - im = obj.physicslist.im; in = obj.physicslist.in; - mn = length( im ); - Nvol = obj.physicslist.Nvol; - Mvol = Nvol + obj.physicslist.Lfreebound; + % Allocate memory + Mpol = obj.physicslist.Mpol; + Ntor = obj.physicslist.Ntor; + Nvol = obj.physicslist.Nvol; + Mvol = Nvol + obj.physicslist.Lfreebound; + + if Lboundary==0 + Ric = zeros(Mpol+1,2*Ntor+1,Mvol); Zis = zeros(Mpol+1,2*Ntor+1,Mvol); + Ris = zeros(Mpol+1,2*Ntor+1,Mvol); Zic = zeros(Mpol+1,2*Ntor+1,Mvol); - Ric = zeros(mn,Mvol); Zis = zeros(mn,Mvol); - Ris = zeros(mn,Mvol); Zic = zeros(mn,Mvol); + % Read + for iline=1:nlines - format = '%f%f'; - for ii=1:Nvol - format = [format, '%f%f%f%f']; + % Scan line + line_data = str2num( initial_guess{iline} ); + + % Find corresponding index + m = line_data(1); n = line_data(2); + im = m+1; + in = n+Ntor+1; + + for ivol=1:Nvol + Ric(im,in,ivol) = line_data(ivol*4-1); + Zis(im,in,ivol) = line_data(ivol*4 ); + Ris(im,in,ivol) = line_data(ivol*4+1); + Zic(im,in,ivol) = line_data(ivol*4+2); + end + end + + init.Ric = Ric; + init.Ris = Ris; + init.Zis = Zis; + init.Zic = Zic; + else + + rhoi = zeros(Mpol , 2*Ntor+1, Mvol); + bin = zeros(Ntor+1, Mvol); + R0ic = zeros(Ntor+1, Mvol); + Z0is = zeros(Ntor+1, Mvol); + + for iline=1:nlines + + line_data = str2num( initial_guess{iline} ); + + m = line_data(1); + n = line_data(2); + + for ivol=1:Nvol + + if n>=0 && m==0 + bin( n+1, ivol) = line_data(ivol*4-1); + R0ic(n+1, ivol) = line_data(ivol*4 ); + Z0is(n+1, ivol) = line_data(ivol*4+1); + end + + if m>0 + rhoi( m, n+Ntor+1, ivol ) = line_data( ivol*4+2 ); + end + end + + end + + + init.rhoi = rhoi; + init.bin = bin; + init.R0ic = R0ic; + init.Z0is = Z0is; + + end + else + + if Lboundary==0 + init.Ric = []; + init.Ris = []; + init.Zic = []; + init.Zis = []; + init.im = []; + init.in = []; + init.surfaces = cell(0); + else + init.rhoi = []; + init.bin = []; + init.R0ic = []; + init.Z0is = []; + end + end + obj.initial_guess = init; + + + if nlines>0 && Lboundary==0 + obj.initial_guess.surfaces = cell(1,Nvol); + + for ii=1:Nvol - % Read - for iline=1:nlines + fsurf = fluxSurface( obj.physicslist.Nfp, obj.physicslist.Mpol, ... + obj.physicslist.Ntor, obj.physicslist.Istellsym); - % Scan line - line_data = textscan( initial_guess{iline}, format ); + work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Ric(:,:,ii)) ); + fsurf = fsurf.set_array( 'rmnc', work.mode, work.im, work.in ); - % Find corresponding index - m = line_data{1}; n = line_data{2}; - imn = obj.find_ii_given_mn(m, n); + work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Zis(:,:,ii)) ); + fsurf = fsurf.set_array( 'zmns', work.mode, work.im, work.in ); + + if ~obj.physicslist.Istellsym + work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Ris(:,:,ii)) ); + fsurf = fsurf.set_array( 'rmns', work.mode, work.im, work.in ); + + work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Zic(:,:,ii)) ); + fsurf = fsurf.set_array( 'zmnc', work.mode, work.im, work.in ); + end + + obj.initial_guess.surfaces{ii} = fsurf; - for ivol=1:Nvol - Ric(imn,ivol) = line_data{ivol*4-1}; - Zis(imn,ivol) = line_data{ivol*4 }; - Ris(imn,ivol) = line_data{ivol*4+1}; - Zic(imn,ivol) = line_data{ivol*4+2}; end - end - init.Ric = Ric; - init.Ris = Ris; - init.Zis = Zis; - init.Zic = Zic; - obj.initial_guess = init; + % Build im, in arrays + s = size(obj.initial_guess.Ric); + mpol = s(1) - 1; + ntor = (s(2) - 1) / 2.0; + im = 0:mpol; + in = -ntor:ntor; + [obj.initial_guess.in, obj.initial_guess.im] = meshgrid(in,im); end - + + end + + function out = reshape_array_1to2d( obj, arr ) + + out.Mpol = max(arr.im); + out.Ntor = max(arr.in); + out.arr = zeros(Mpol+1,2*Ntor+1); + + nmn = length(in.im); + + ii=0; + for mm=0:out.Mpol + for nn=-out.Ntor:out.Ntor + if mm==0 && nn<0 + continue + end + + ii = ii + 1; + + out.arr( mm+1, nn+out.Ntor+1 ) = arr.mode( ii ); + end + end + + + end + + function out = reshape_array_2to1d( obj, arr ) + + s = size(arr); + Mpol = s(1) - 1; + Ntor = (s(2) - 1) /2.0 ; + + nmn = Ntor + 1 + Mpol*(2*Ntor+1); + + out.mode = zeros(1,nmn); + out.im = zeros(1,nmn); + out.in = zeros(1,nmn); + + ii=0; + for mm=0:Mpol + for nn=-Ntor:Ntor + if mm==0 && nn<0 + continue + end + + ii = ii+1; + out.im(ii) = mm; + out.in(ii) = nn; + + out.mode(ii) = arr(mm+1,nn+Ntor+1); + end + end + end + function obj = read_axis_from_focus(obj, focus_data) Ntor = obj.physicslist.Ntor; @@ -412,7 +468,6 @@ end - function obj = interpolate_initial_guess( obj, interp_type, Linitialize ) % % INTERPOLATE_INITIAL_GUESS( INTERP_TYPE, LINITIALIZE ) @@ -437,6 +492,8 @@ % * obj: instance of SPEC_Namelist % % + + error('deprecated') machine_precision = eps; vsmall = 100 * machine_precision; @@ -618,6 +675,8 @@ end % of function + % ===================================================================== + % Plotters function plot_BdotN( obj, Nt, Nphi ) theta = linspace( 0, 2*pi, Nt ); @@ -647,9 +706,6 @@ function plot_BdotN( obj, Nt, Nphi ) end - - % ===================================================================== - % Plotters function plot_boundary( obj, phi, Nt, Mpol, Ntor, PorW, newfig ) % % PLOT_BOUNDARY( PHI, NT, PorW, NEWFIG ) @@ -683,42 +739,125 @@ function plot_boundary( obj, phi, Nt, Mpol, Ntor, PorW, newfig ) im = obj.physicslist.im; in = obj.physicslist.in; - switch PorW - case 'P' - Rmnc = obj.physicslist.Rbc; - Rmns = obj.physicslist.Rbs; - Zmnc = obj.physicslist.Zbc; - Zmns = obj.physicslist.Zbs; - case 'W' - Rmnc = obj.physicslist.Rwc; - Rmns = obj.physicslist.Rws; - Zmnc = obj.physicslist.Zwc; - Zmns = obj.physicslist.Zws; - otherwise - 'Invalid input' + if isfield(obj.physicslist,'Lboundary') + Lboundary = obj.physicslist.Lboundary; + else + Lboundary = 0; end + + Nfp = obj.physicslist.Nfp; theta = linspace(0, 2*pi, Nt ); R = zeros(1,Nt); Z = zeros(1,Nt); - for ii=1:length(im) - - if im(ii) > Mpol - continue + + + if Lboundary==0 + switch PorW + case 'P' + Rmnc = obj.physicslist.Rbc; + Rmns = obj.physicslist.Rbs; + Zmnc = obj.physicslist.Zbc; + Zmns = obj.physicslist.Zbs; + case 'W' + Rmnc = obj.physicslist.Rwc; + Rmns = obj.physicslist.Rws; + Zmnc = obj.physicslist.Zwc; + Zmns = obj.physicslist.Zws; + otherwise + error('Invalid input') + end + + s = size(im); + + for ii=1:s(1) + for jj=1:s(2) + + if im(ii,jj) > Mpol + continue + end + + if abs(in(ii,jj)) > Ntor + continue + end + + + arg = im(ii,jj) * theta - in(ii,jj) * Nfp * phi; + cosarg = cos(arg); + sinarg = sin(arg); + + R = R + Rmnc(ii,jj) * cosarg ; + Z = Z + Zmns(ii,jj) * sinarg; + + if ~obj.physicslist.Istellsym + R = R + Rmns(ii,jj) * sinarg ; + Z = Z + Zmnc(ii,jj) * cosarg ; + end + + end + end - if in(ii) > Ntor - continue + else + switch PorW + case 'P' + rhomn = obj.physicslist.rhomn; + bn = obj.physicslist.bn; + R0c = obj.physicslist.R0c; + Z0s = obj.physicslist.Z0s; + case 'W' + error('Not implemented yet') + otherwise + error('Invalid input') end - arg = im(ii) * theta - in(ii) * Nfp * phi; - cosarg = cos(arg); - sinarg = sin(arg); - - R = R + Rmnc(ii) * cosarg + Rmns(ii) * sinarg; - Z = Z + Zmnc(ii) * cosarg + Zmns(ii) * sinarg; - + alpha = double(obj.physicslist.twoalpha) / 2.0; + + s = size(rhomn); + Nrho = (s(2)-1)/2.0; + + rhoij = zeros(1, Nt); + R0 = 0; + Z0 = 0; + b = 0; + + lr = length(obj.physicslist.R0c); + lz = length(obj.physicslist.Z0s); + lb = length(obj.physicslist.bn); + + for nn=0:Ntor + + in = nn+1; + + if in<=lr + R0 = R0 + obj.physicslist.R0c(in) * cos(nn*Nfp*phi ); + end + if in<=lz + Z0 = Z0 + obj.physicslist.Z0s(in) * sin(nn*Nfp*phi ); + end + if in<=lb + b = b + obj.physicslist.bn(in) * cos(nn*Nfp*phi ); + end + end + + zetaij = b*sin(theta - alpha*Nfp*phi); + + for ii=1:s(1) + for jj=1:s(2) + mm = ii-1; + nn = jj-1-Nrho; + + arg = mm*theta + nn*Nfp*phi - alpha*Nfp*phi; + + rhoij = rhoij + obj.physicslist.rhomn(ii,jj)*cos(arg); + end + end + + R = R0 + rhoij * cos(alpha*Nfp*phi) - zetaij * sin(alpha*Nfp*phi); + Z = Z0 + rhoij * sin(alpha*Nfp*phi) + zetaij * cos(alpha*Nfp*phi); + + end switch newfig @@ -736,7 +875,6 @@ function plot_boundary( obj, phi, Nt, Mpol, Ntor, PorW, newfig ) end - function plot_initial_guess( obj, phi, Nt, newfig ) % % PLOT_INITIAL_GUESS( PHI, NT, ONLY_BOUNDARY, NEWFIG ) @@ -755,73 +893,57 @@ function plot_initial_guess( obj, phi, Nt, newfig ) % Written by A. Baillod (2020) % + % Open figure + switch newfig + case 0 + hold on + case 1 + figure('Position',[200 200 900 700], 'Color','w') + hold on; + case 2 + hold off; + otherwise + error( 'Unknown value of newfig') + end -% if isempty(obj.initial_guess) -% error('No initial guess. First read with read_initial_guess'); -% end - - - % Open figure - switch newfig - case 0 - hold on - case 1 - figure - hold on; - case 2 - hold off; - otherwise - error( 'Unknown value of newfig') - end - - Nvol = obj.physicslist.Nvol; - im = obj.physicslist.im; in = obj.physicslist.in; - mn = length(im); - Np = obj.physicslist.Nfp; + Nvol = obj.physicslist.Nvol; % Prepare theta coordinate theta = linspace(0,2*pi,Nt)'; - + % Map to real space if( ~isempty(obj.initial_guess) ) - for ivol=1:Nvol - R = zeros(1,Nt); - Z = zeros(1,Nt); - - for imn=1:mn - cosarg = cos(im(imn)*theta - in(imn)*Np*phi); - sinarg = sin(im(imn)*theta - in(imn)*Np*phi); - - - R(:) = R(:) + obj.initial_guess.Ric(imn,ivol) * cosarg ... - + obj.initial_guess.Ris(imn,ivol) * sinarg; - Z(:) = Z(:) + obj.initial_guess.Zic(imn,ivol) * cosarg ... - + obj.initial_guess.Zis(imn,ivol) * sinarg; - end - - scatter(R, Z, 3, 'filled', 'MarkerFaceColor', 'b') + newfig = 0; + for ivol=1:Nvol-1 + obj.initial_guess.surfaces{ivol}.plot_poloidal_section( phi, newfig ) end end % Plot plasma boundary R = zeros(1,Nt); Z = zeros(1,Nt); - - for imn=1:mn - cosarg = cos(im(imn)*theta - in(imn)*Np*phi); - sinarg = sin(im(imn)*theta - in(imn)*Np*phi); - - try - R(:) = R(:) + obj.physicslist.Rbc(imn) * cosarg ... - + obj.physicslist.Rbs(imn) * sinarg; - Z(:) = Z(:) + obj.physicslist.Zbc(imn) * cosarg ... - + obj.physicslist.Zbs(imn) * sinarg; - catch - disp('ouch') + + im = obj.physicslist.im; + in = obj.physicslist.in; + mn = size(im); + + for ii=1:mn(1) + for jj=1:mn(2) + cosarg = cos(im(ii,jj)*theta - in(ii,jj)*Np*phi); + sinarg = sin(im(ii,jj)*theta - in(ii,jj)*Np*phi); + + try + R(:) = R(:) + obj.physicslist.Rbc(ii,jj) * cosarg ... + + obj.physicslist.Rbs(ii,jj) * sinarg; + Z(:) = Z(:) + obj.physicslist.Zbc(ii,jj) * cosarg ... + + obj.physicslist.Zbs(ii,jj) * sinarg; + catch + disp('ouch') + end end end - scatter(R, Z, 3, 'filled', 'MarkerFaceColor', [1 0 0]) + scatter(R, Z, 10, 'filled', 'MarkerFaceColor', [1 0 0]) if obj.physicslist.Lfreebound @@ -833,12 +955,14 @@ function plot_initial_guess( obj, phi, Nt, newfig ) Rws = obj.physicslist.Rws; Zws = obj.physicslist.Zws; - for imn=1:mn - cosarg = cos(im(imn)*theta - in(imn)*Np*phi); - sinarg = sin(im(imn)*theta - in(imn)*Np*phi); + for ii=1:mn(1) + for jj=1:mn(2) + cosarg = cos(im(ii,jj)*theta - in(ii,jj)*Np*phi); + sinarg = sin(im(ii,jj)*theta - in(ii,jj)*Np*phi); - R(:) = R(:) + Rwc(imn) * cosarg + Rws(imn) * sinarg; - Z(:) = Z(:) + Zwc(imn) * cosarg + Zws(imn) * sinarg; + R(:) = R(:) + Rwc(ii,jj) * cosarg + Rws(ii,jj) * sinarg; + Z(:) = Z(:) + Zwc(ii,jj) * cosarg + Zws(ii,jj) * sinarg; + end end scatter(R, Z, 5, 'filled', 'MarkerFaceColor', [0 0 0]) @@ -848,7 +972,8 @@ function plot_initial_guess( obj, phi, Nt, newfig ) Rax = 0; Zax = 0; mn = length(obj.physicslist.Rac); Nfp = double(obj.physicslist.Nfp); - for n=0:mn-1 + Ntor = obj.physicslist.Ntor; + for n=0:Ntor Rax = Rax + obj.physicslist.Rac(n+1) * cos(n * Nfp * phi) ... - obj.physicslist.Ras(n+1) * sin(n * Nfp * phi); Zax = Zax + obj.physicslist.Zac(n+1) * cos(n * Nfp * phi) ... @@ -862,7 +987,6 @@ function plot_initial_guess( obj, phi, Nt, newfig ) end - function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) l = length(varargin); @@ -954,7 +1078,7 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) end - + % ===================================================================== % Getters function out = get_plasma_boundary(obj, m, n)% @@ -970,23 +1094,23 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) % - out: structure with field out.Rbc, out.Rbs, out.Zbc, out.Zbs % - ii = obj.find_ii_given_mn(m, n); - - if isnan(ii) + Mpol = max(max(obj.physicslist.im)); + Ntor = max(max(obj.physicslist.in)); + + if m>Mpol || abs(n)>Ntor out.Rbc = 0.0; out.Rbs = 0.0; out.Zbc = 0.0; out.Zbs = 0.0; else - out.Rbc = obj.physicslist.Rbc(ii); - out.Rbs = obj.physicslist.Rbs(ii); - out.Zbc = obj.physicslist.Zbc(ii); - out.Zbs = obj.physicslist.Zbs(ii); + out.Rbc = obj.physicslist.Rbc(m+1, n+Ntor+1); + out.Rbs = obj.physicslist.Rbs(m+1, n+Ntor+1); + out.Zbc = obj.physicslist.Zbc(m+1, n+Ntor+1); + out.Zbs = obj.physicslist.Zbs(m+1, n+Ntor+1); end end - function out = get_wall(obj, m, n) % % Return Rwc, Zws, Rws, Zwc for given m, n mode @@ -1000,22 +1124,22 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) % ------ % - out: structure with field out.Rwc, out.Rws, out.Zwc, out.Zws % - ii = obj.find_ii_given_mn(m, n); + Mpol = max(max(obj.physicslist.im)); + Ntor = max(max(obj.physicslist.in)); - if isnan(ii) + if m>Mpol || abs(n)>Ntor out.Rwc = 0.0; out.Rws = 0.0; out.Zwc = 0.0; out.Zws = 0.0; else - out.Rwc = obj.physicslist.Rwc(ii); - out.Rws = obj.physicslist.Rws(ii); - out.Zwc = obj.physicslist.Zwc(ii); - out.Zws = obj.physicslist.Zws(ii); + out.Rwc = obj.physicslist.Rwc(m+1, n+Ntor+1); + out.Rws = obj.physicslist.Rws(m+1, n+Ntor+1); + out.Zwc = obj.physicslist.Zwc(m+1, n+Ntor+1); + out.Zws = obj.physicslist.Zws(m+1, n+Ntor+1); end end - function out = get_vnc_bns(obj, m, n) % Return Vnc, Vns, Bnc, Bns for given m, n mode % @@ -1028,26 +1152,27 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) % ------ % - out: structure with field out.Vnc, out.Vns, out.Bnc, out.Bns % + Mpol = max(max(obj.physicslist.im)); + Ntor = max(max(obj.physicslist.in)); - ii = obj.find_ii_given_mn(m, n); - - if isnan(ii) + if m>Mpol || abs(n)>Ntor out.Vnc = 0.0; out.Vns = 0.0; out.Bnc = 0.0; out.Bns = 0.0; else - out.Vnc = obj.physicslist.Vnc(ii); - out.Vns = obj.physicslist.Vns(ii); - out.Bnc = obj.physicslist.Bnc(ii); - out.Bns = obj.physicslist.Bns(ii); + out.Vnc = obj.physicslist.Vnc(m+1, n+Ntor+1); + out.Vns = obj.physicslist.Vns(m+1, n+Ntor+1); + out.Bnc = obj.physicslist.Bnc(m+1, n+Ntor+1); + out.Bns = obj.physicslist.Bns(m+1, n+Ntor+1); end end - function out = get_fourier_harmonics(obj, m, n, field) - - ii = obj.find_ii_given_mn( m, n); + + Mpol = max(max(obj.physicslist.im)); + Ntor = max(max(obj.physicslist.in)); + if( strcmp(field, 'Ric') || strcmp(field, 'Ris') || strcmp(field, 'Zic') || strcmp(field, 'Zis')) if( isempty(obj.initial_guess) ) @@ -1056,19 +1181,104 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) out = obj.initial_guess.(field)(ii); end else - out = obj.physicslist.(field)(ii); + out = obj.physicslist.(field)(m+1, n+Ntor+1); end end % ===================================================================== % Setters - function obj = set_fourier_harmonics(obj, im, in, values, field) + function obj = truncate_fourier_series( obj, min_value ) + + nmn = length(obj.physicslist.im); + + ind = cell(1,12); + + ind{1} = find(obj.physicslist.Rbc obj.physicslist.Mpol ); + ind2 = find( abs(obj.physicslist.in) > obj.physicslist.Ntor ); + + ind = union( ind1, ind2 ); + + obj.physicslist.im(ind) = []; + obj.physicslist.in(ind) = []; + obj.physicslist.Rbc(ind) = []; + obj.physicslist.Rbs(ind) = []; + obj.physicslist.Zbc(ind) = []; + obj.physicslist.Zbs(ind) = []; + + obj.physicslist.Rwc(ind) = []; + obj.physicslist.Rws(ind) = []; + obj.physicslist.Zwc(ind) = []; + obj.physicslist.Zws(ind) = []; + + obj.physicslist.Vnc(ind) = []; + obj.physicslist.Vns(ind) = []; + obj.physicslist.Bnc(ind) = []; + obj.physicslist.Bns(ind) = []; + + if ~isempty( obj.initial_guess ) + obj.initial_guess.Ric(ind,:) = []; + obj.initial_guess.Ris(ind,:) = []; + obj.initial_guess.Zic(ind,:) = []; + obj.initial_guess.Zis(ind,:) = []; + end + end + + function obj = set_fourier_harmonics(obj, im, in, values, field, varargin) + + l = length(varargin); + if( mod(l,2)~=0 ) + error('Invalid number of argument') + end + + set_to_zero=true; + for iv=1:l/2 + fieldarg=varargin{2*iv-1}; + value=varargin{2*iv}; + switch fieldarg + case 'set_to_zero' + set_to_zero=value; + otherwise + error('Unknown input') + end + end + mn = length(im); mn_old = length(obj.physicslist.Rbc); - - obj.physicslist.(field) = zeros(1, mn_old); + + + if set_to_zero + obj.physicslist.(field) = zeros(size(obj.physicslist.Rbc)); + end for ii = 1:mn m = im(ii); n=in(ii); @@ -1107,21 +1317,104 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) end - obj = obj.update_flux_surfaces(); end + + if ~(strcmp(field, 'Vnc') || strcmp(field, 'Vns') || strcmp(field, 'Bnc') || strcmp(field, 'Bns') ) + obj = obj.update_flux_surfaces(); + end - end + function obj = convert_to_standard_representation( obj ) + + Lb = obj.physicslist.Lboundary; + if Lb==0 + error('Can only convert from Lboundary=1 to Lboundary=0') + end + + obj.physicslist.Lboundary=0; + obj.physicslist.twoalpha=0; + + % Map computational boundary + if( obj.physicslist.Lfreebound ) + error('Not implemented for freeboundary cases yet') + end + + % Map computational boundary + rhomn = obj.physicslist.rhomn; + bn = obj.physicslist.bn; + R0c = obj.physicslist.R0c; + Z0s = obj.physicslist.Z0s; + alpha = obj.physicslist.twoalpha / 2.0; + + [Rmn, Zmn, Mpol, Ntor] = map_rho_to_RZ( rhomn, bn, R0c, Z0s, alpha, 0); + + obj.physicslist.Mpol = Mpol; + obj.physicslist.Ntor = Ntor; + + obj.physicslist.Rbc = Rmn; + obj.physicslist.Zbs = Zmn; + obj.physicslist.Rbs = zeros(size(Rmn)); + obj.physicslist.Zbc = zeros(size(Zmn)); + + obj.physicslist = rmfield(obj.physicslist, 'rhomn'); + obj.physicslist = rmfield(obj.physicslist, 'bn'); + obj.physicslist = rmfield(obj.physicslist, 'R0c'); + obj.physicslist = rmfield(obj.physicslist, 'Z0s'); + + % Map initial guess + if ~isempty(obj.initial_guess ) + Nvol = obj.physicslist.Nvol; + + obj.initial_guess.Ric = zeros( Mpol+1, 2*Ntor+1, Nvol ); + obj.initial_guess.Ris = zeros( Mpol+1, 2*Ntor+1, Nvol ); + obj.initial_guess.Zic = zeros( Mpol+1, 2*Ntor+1, Nvol ); + obj.initial_guess.Zis = zeros( Mpol+1, 2*Ntor+1, Nvol ); + + % Plasma boundary + obj.initial_guess.Ric(:,:,Nvol) = Rmn; + obj.initial_guess.Zis(:,:,Nvol) = Zmn; + + % Inner interfaces + for ivol=1:Nvol-1 + [Rmn, Zmn, Mpol, Ntor] = map_rho_to_RZ( obj.initial_guess.rhoi(:,:,ivol), ... + obj.initial_guess.bin(:,ivol), ... + obj.initial_guess.R0ic(:,ivol), ... + obj.initial_guess.Z0is(:,ivol), ... + alpha, 0); + obj.initial_guess.Ric(1:Mpol+1,1:2*Ntor+1,ivol) = Rmn; + obj.initial_guess.Zis(1:Mpol+1,1:2*Ntor+1,ivol) = Zmn; + end + + obj.initial_guess = rmfield(obj.initial_guess, 'rhoi'); + obj.initial_guess = rmfield(obj.initial_guess, 'bin'); + obj.initial_guess = rmfield(obj.initial_guess, 'R0ic'); + obj.initial_guess = rmfield(obj.initial_guess, 'Z0is'); + end + + + end + + function obj = set_initial_guess_harmonics( obj, volume, im, in, values, field) + mn = length(im); mn_old = length(obj.physicslist.Rbc); - Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; - obj.initial_guess.(field) = zeros(mn_old, Mvol); + + if isempty(obj.initial_guess) + obj.initial_guess.Ric = zeros( mn_old, Mvol ); + obj.initial_guess.Ris = zeros( mn_old, Mvol ); + obj.initial_guess.Zic = zeros( mn_old, Mvol ); + obj.initial_guess.Zis = zeros( mn_old, Mvol ); + end + + %obj.initial_guess.(field) = zeros(mn_old, Mvol); + tmp = obj.initial_guess.(field); + tmp( 1:mn_old, volume ) = zeros( mn_old, 1 ); for ii = 1:mn m = im(ii); n=in(ii); @@ -1151,13 +1444,16 @@ function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) obj.initial_guess.Zic(end+1, :) = 0.0; obj.initial_guess.Zis(end+1, :) = 0.0; - obj.initial_guess.(field)(end, volume) = values(ii); + tmp( end+1, : ) = 0.0; + tmp( end , volume ) = values(ii); else - obj.initial_guess.(field)(imn, volume) = values(ii); + tmp( imn, volume ) = values(ii); end + obj.initial_guess.(field) = tmp; + end @@ -1217,7 +1513,6 @@ function compare_fourier_harmonics(obj, spec_nm, field) end - function obj = add_volume( obj, tflux ) Nvol = obj.physicslist.Nvol; @@ -1471,7 +1766,6 @@ function compare_fourier_harmonics(obj, spec_nm, field) end - function obj = remove_volume( obj, ivol ) obj.physicslist.Nvol = obj.physicslist.Nvol-1; @@ -1498,105 +1792,226 @@ function compare_fourier_harmonics(obj, spec_nm, field) end - % ===================================================================== % Write method - function write_input_file(obj, filename, varargin ) + function write_input_file(obj, filename ) % - % write_input_file(filename, (force) ) - % - % Write namelist in an input file. Be careful: if the file filename - % provided as input exist, it will be overwritten! - % - % INPUT - % ----- - % - filename: path where to save the input file. - % - options: structure containing optional input + % write_input_file(filename, (force) ) + % + % Write namelist in an input file. Be careful: if the file filename + % provided as input exist, it will be overwritten! + % + % INPUT + % ----- + % - filename: path where to save the input file. + % - options: structure containing optional input % * force: set to true to force overwritting the input file % - % Read options - if( isempty(varargin) ) - force = false; - else - if( isfield(varargin{1}, 'force') ) - force = varargin{1}.force; - else - force = false; - end - end - % Check if user want to erase existing file - if (exist(filename, 'file') && (~force)) - prompt = ['The file ', filename, ' already exist and will be overwritten. Continue? Y/N [Y]: ']; - c = input(prompt, 's'); - if( isempty(c) ) - c = 'Y'; + nlists = length(obj.lists); + S = struct; + for ii=1:nlists + S.(obj.lists{ii}) = obj.(obj.lists{ii}); end - while ~( strcmp(c,"Y") || strcmp(c,"N") ) - c = input(['Please answer Y or N: '], 's'); - end - - if strcmp(c,'N') %exit routine - disp('ABORTED') - return; + + S.physicslist = rmfield( S.physicslist, 'im' ); + S.physicslist = rmfield( S.physicslist, 'in' ); + try + S.physicslist = rmfield( S.physicslist, 'PlasmaBoundary' ); + catch + disp('No field PlasmaBoundary...') + end + + try + S.physicslist = rmfield( S.physicslist, 'ComputationalBoundary' ); + catch + disp('No field ComputationalBoundary...') + end + + if isfield(S.physicslist, 'Lboundary') + Lboundary = S.physicslist.Lboundary; else - disp(['Overwriting file ', filename, '.']) - end - end - - % Open file - fid = fopen(filename, 'w'); - - - special_list = {'Rbc', 'Rbs', 'Zbc', 'Zbs', 'im', 'in', ... - 'Rwc', 'Rws', 'Zwc', 'Zws', ... - 'Vnc', 'Vns', 'Bnc', 'Bns', ... - 'PlasmaBoundary', 'ComputationalBoundary'}; - for ii=1:numel(obj.lists) - list = obj.lists{ii}; - - if strcmp(list, 'physicslist') - obj.write_list(fid, list, special_list) + Lboundary = 0; %by default + end + + Ntor = max(max(obj.physicslist.in)); + S.shift.Rbc = [1, Ntor+1]; + S.shift.Rbs = [1, Ntor+1]; + S.shift.Zbc = [1, Ntor+1]; + S.shift.Zbs = [1, Ntor+1]; + S.shift.Rwc = [1, Ntor+1]; + S.shift.Rws = [1, Ntor+1]; + S.shift.Zws = [1, Ntor+1]; + S.shift.Zwc = [1, Ntor+1]; + S.shift.Vnc = [1, Ntor+1]; + S.shift.Vns = [1, Ntor+1]; + S.shift.Bnc = [1, Ntor+1]; + S.shift.Bns = [1, Ntor+1]; + S.shift.rhomn = [1, Ntor+1]; + + if Lboundary==0 + + initialguess = cell(1,1); + if ~isempty(obj.initial_guess) + s = size(obj.initial_guess.Ric); + initialguess = cell(1, s(1)*s(2)); + n=0; + for ii=1:s(1) + for jj=1:s(2) + n = n+1; + initialguess{n} = sprintf( '%i %i ', obj.initial_guess.im(ii,jj), obj.initial_guess.in(ii,jj) ); + for ivol=1:s(3) + initialguess{n} = sprintf( '%s %0.12E %0.12E %0.12E %0.12E', initialguess{n}, ... + obj.initial_guess.Ric(ii,jj,ivol), ... + obj.initial_guess.Zis(ii,jj,ivol), ... + obj.initial_guess.Ris(ii,jj,ivol), ... + obj.initial_guess.Zic(ii,jj,ivol) ); + end + end + end + end + + else + + nrho = max(max(obj.physicslist.in)); + S.shift.rhomn = [ 1, nrho+1 ]; + + % Now prepare initial guess... + if isfield(obj.initial_guess, 'bin') + sb = size(obj.initial_guess.bin); + srho = size(obj.initial_guess.rhoi); + ntor = (srho(2)-1)/2.0; + initialguess = cell(1, sb(1) + srho(1)*srho(2)); + + % Modes m=0, n + for ii=1:sb(1) + nn = ii-1; + initialguess{ii} = sprintf('0 %i ', nn); + for ivol=1:sb(2) + initialguess{ii} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii}, ... + obj.initial_guess.bin( ii, ivol ), ... + obj.initial_guess.R0ic(ii, ivol ), ... + obj.initial_guess.Z0is(ii, ivol ), 0.0 ); + end + end - % write Rbc, ... - obj.write_4_values(fid, 'Rbc', 'Zbs', 'Rbs', 'Zbc'); - obj.write_4_values(fid, 'Rwc', 'Zws', 'Rws', 'Zwc'); - obj.write_4_values(fid, 'Vnc', 'Vns', 'Bnc', 'Bns'); + it = sb(1); + for ii=1:srho(2) - fprintf(fid, '/ \n'); + nn = ii-ntor-1; - else - obj.write_list(fid, list, special_list) + for jj=1:srho(1) - fprintf(fid, '/ \n'); - end + it = it+1; - end + mm = jj; + initialguess{it} = sprintf('%i %i ', mm, nn); - im = obj.physicslist.im; in = obj.physicslist.in; - mn = length(im); + for ivol=1:srho(3) - if( ~isempty(obj.initial_guess) ) - Ric = obj.initial_guess.Ric; - s = size(Ric); + initialguess{it} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii},... + 0.0, 0.0, 0.0, obj.initial_guess.rhoi(ii, jj, ivol)); - for ii=1:mn - fprintf(fid, ' %i %i', im(ii), in(ii)); - for jj=1:s(2) - fprintf(fid, ' %19.15E %19.15E %19.15E %19.15E', ... - obj.initial_guess.Ric(ii,jj), ... - obj.initial_guess.Zis(ii,jj), ... - obj.initial_guess.Ris(ii,jj), ... - obj.initial_guess.Zic(ii,jj)); % Print in file - end - fprintf(fid, '\n'); - end + end + end + end + else + initialguess = cell(0); + end + + + + end + + write_namelist( S, filename, initialguess ); + - % close file - fclose(fid); +% % Read options +% if( isempty(varargin) ) +% force = false; +% else +% if( isfield(varargin{1}, 'force') ) +% force = varargin{1}.force; +% else +% force = false; +% end +% end +% +% % Check if user want to erase existing file +% if (exist(filename, 'file') && (~force)) +% prompt = ['The file ', filename, ' already exist and will be overwritten. Continue? Y/N [Y]: ']; +% c = input(prompt, 's'); +% if( isempty(c) ) +% c = 'Y'; +% end +% +% while ~( (c=='Y') || (c=='N') ) +% c = input('Please answer Y or N: ', 's'); +% end +% +% if strcmp(c,'N') %exit routine +% disp('ABORTED') +% return; +% else +% disp(['Overwriting file ', filename, '.']) +% end +% end +% +% % Open file +% fid = fopen(filename, 'w'); +% +% +% special_list = {'Rbc', 'Rbs', 'Zbc', 'Zbs', 'im', 'in', ... +% 'Rwc', 'Rws', 'Zwc', 'Zws', ... +% 'Vnc', 'Vns', 'Bnc', 'Bns', ... +% 'PlasmaBoundary', 'ComputationalBoundary'}; +% for ii=1:numel(obj.lists) +% list = obj.lists{ii}; +% +% if strcmp(list, 'physicslist') +% obj.write_list(fid, list, special_list) +% +% % write Rbc, ... +% obj.write_4_values(fid, 'Rbc', 'Zbs', 'Rbs', 'Zbc'); +% obj.write_4_values(fid, 'Rwc', 'Zws', 'Rws', 'Zwc'); +% obj.write_4_values(fid, 'Vnc', 'Vns', 'Bnc', 'Bns'); +% +% fprintf(fid, '/ \n'); +% +% else +% obj.write_list(fid, list, special_list) +% +% fprintf(fid, '/ \n'); +% end +% +% end +% +% +% im = obj.physicslist.im; in = obj.physicslist.in; +% mn = length(im); +% +% if( ~isempty(obj.initial_guess) ) +% Ric = obj.initial_guess.Ric; +% s = size(Ric); +% +% for ii=1:mn +% fprintf(fid, ' %i %i', im(ii), in(ii)); +% for jj=1:s(2) +% fprintf(fid, ' %19.15E %19.15E %19.15E %19.15E', ... +% obj.initial_guess.Ric(ii,jj), ... +% obj.initial_guess.Zis(ii,jj), ... +% obj.initial_guess.Ris(ii,jj), ... +% obj.initial_guess.Zic(ii,jj)); % Print in file +% end +% fprintf(fid, '\n'); +% end +% end +% +% % close file +% fclose(fid); end %of function write_input_file @@ -1619,7 +2034,7 @@ function write_input_file(obj, filename, varargin ) im = obj.physicslist.im; in = obj.physicslist.in; - Mpol = max(im); Ntor = max(in); + Mpol = max(max(im)); Ntor = max(max(in)); PlasmaBoundary = fluxSurface(obj.physicslist.Nfp, Mpol, Ntor, 0); PlasmaBoundary = PlasmaBoundary.set_array('rmnc', obj.physicslist.Rbc, im, in); diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/read_namelist.m b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/read_namelist.m new file mode 100755 index 00000000..46249610 --- /dev/null +++ b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/read_namelist.m @@ -0,0 +1,340 @@ +function S = read_namelist(filename) +% S = READ_NAMELIST(FILENAME) returns the struct S containg namelists and +% variables in the file FILENAME organised in hierachical way: +% +% |--VAR1 +% |--VAR2 +% |-- NMLST_A--|... +% | |--VARNa +% | +% | |--VAR1 +% |-- NMLST_B--|--VAR2 +% | |... +% S --| ... |--VARNb +% | +% | |--VAR1 +% |-- NMLST_M--|--VAR2 +% |... +% |--VARNm +% +% Note: The function can read multidimensioal variables as well. The +% function assumes that there is no more than one namelist section per +% line. At this time there is no syntax checking functionality so the +% function will crash in case of errors. +% +% Example: +% NMLST = read_namelist('OPTIONS.nam'); +% NMLST.NAM_FRAC.XUNIF_NATURE = 0.1; +% write_namelist(NMlST, 'MOD_OPTIONS.nam'); +% +% Written by: Darien Pardinas Diaz (darien.pardinas-diaz@monash.edu) +% Version: 1.0 +% Date: 16 Dec 2011 + +S = struct(); +% Open and read the text file containing the namelists +fid = fopen(filename,'r'); +c = 0; +lines = cell(1); + +% Read all the text lines in namelist file +while ~feof(fid) + line = fgetl(fid); + % Remove comments if any on the line + idx = find(line == '!'); + if ~isempty(idx), + line = line(1:idx(1)-1); + end + if ~isempty(line), + c = c + 1; + lines{c} = line; + end +end +fclose(fid); + +i = 0; +while i < c; + % Find a record + i = i + 1; + line = lines{i}; + idx = find(line == '&'); + if ~isempty(idx), % i.e. a namelist start + line = line(idx(1) + 1:end); + % find next space + idx = find(line == ' '); + if ~isempty(idx), + namelst = line(1:idx(1) - 1); + line = line(idx(1) + 1:end); + else + namelst = line; + line = []; + end + nmlst_bdy = []; + idx = strfind(line,'/'); + % Get the variable specification section + while isempty(idx) && i < c, + nmlst_bdy = [nmlst_bdy ' ' line]; + i = i + 1; + line = lines{i}; + idx = strfind(line,'/'); + end + if ~isempty(idx) && idx(1) > 1, + nmlst_bdy = [nmlst_bdy ' ' line]; + end + if nmlst_bdy==' ' + S.(namelst) = struct; + continue + end + % Parse current namelist (set of variables) + [S.(namelst), shift] = parse_namelist(nmlst_bdy); + S.(namelst).shift = shift; + end +end +function [S, shift] = parse_namelist(strng) +% Internal function to parse the body text of a namelist section. +% Limitations: the following patterns are prohibited inside the literal +% strings: '.t.' '.f.' '.true.' '.false.' '(:)' + +% Get all .true., .t. and .false., .f. to T and F +strng = regexprep(strng,'\.true\.' ,'T','ignorecase'); +strng = regexprep(strng,'\.false\.','F','ignorecase'); +strng = regexprep(strng,'\.t\.','T','ignorecase'); +strng = regexprep(strng,'\.f\.','F','ignorecase'); + +% Make evaluable the (:) expression in MATLAB if any +strng = regexprep(strng, '\(:\)', '(1,:)'); +[strng, islit] = parse_literal_strings([strng ' ']); + +% Find the position of all the '=' +eq_idx = find(strng == '='); +nvars = length(eq_idx); + +arg_start = eq_idx + 1; +arg_end = zeros(size(eq_idx)); +vars = cell(nvars,1); +S = struct; + +% Loop through every variable +for k = 1:nvars + i = eq_idx(k) - 1; + % Move to the left and discard blank spaces + while strng(i) == ' ', i = i - 1; end + % Now we are over the variable name or closing parentesis + j = i; + if strng(i) == ')' + while strng(i) ~= '(', i = i - 1; end + i = i - 1; + % Move to the left and discard any possible blank spaces + while strng(i) == ' ', i = i - 1; end + end + + % Now we are over the last character of the variable name + while strng(i) ~= ' ', i = i - 1; end + + if k > 1, arg_end(k - 1) = i; end + vars{k} = ['S.' strng(i + 1: j)]; +end + +arg_end(end) = length(strng); + + +% Find all array, shift indices +shift = struct; +k_array = zeros(1,nvars); +for k=1:nvars + v = vars{k}; + + % Check if it is an array + ind_open = find(v=='('); + if isempty(ind_open) + continue + end + + ind_close = find(v==')'); + if isempty(ind_close) + continue + end + + % Store info + k_array(k) = 1; + + % get how many dimensions + v_name = v(3:ind_open-1); + v_ind = v(ind_open+1:ind_close-1); + + indices = str2num(v_ind); + dim = length(indices); + + + % Loop on dimensions + if( isfield(shift, v_name) ) + for idim = 1:dim + ind = indices(idim); + + % Check if shift larger + new_shift = 1 - ind; + old_shift = shift.(v_name)(idim); + shift.(v_name)(idim) = max( new_shift, old_shift ); + end + else % First encounter with this variable + for idim = 1:dim + ind = indices(idim); + if ind>0 + shift.(v_name)(idim) = 0.0; + else + shift.(v_name)(idim) = 1-ind; + end + end + end + + + +end + + + +% This variables are used in the eval function to evaluate True/False, +% so don't remove it! +T = '.true.'; +F = '.false.'; +% Loop through every variable guess variable type +for k = 1:nvars + arg = strng(arg_start(k):arg_end(k)); + arglit = islit(arg_start(k):arg_end(k))'; + + % Remove commas in non literal string... + commas = ~arglit & arg == ','; + if any(commas) + arg(commas) = ' '; + end + + if any(arglit) + % We are parsing a variable that is literal string + arg = ['{' arg '};']; + elseif ~isempty(find( arg == 'T' | arg == 'F', 1)) + % We are parsing a boolean variable + arg = ['{' arg '};']; + else + % We are parsing a numerical array + arg = ['[' arg '];']; + end + + + % Eval the modified syntax in Matlab + if k_array(k)==0 + eval([vars{k} ' = ' arg]); + else % apply shift + v = vars{k}; + ind_open = find(v=='('); + ind_close = find(v==')'); + v_name = v(3:ind_open-1); + v_ind = v(ind_open+1:ind_close-1); + + tmp = find(v_ind==','); + dim = length(tmp)+1; + + + %indices = str2num(v_ind); + + newstr = ['S.', v_name, '(']; + for idim = 1:dim + if idim==1 + ind_start=1; + else + ind_start=tmp(idim-1)+1; + end + + if idim==dim + ind_end=length(v_ind); + else + ind_end=tmp(idim)-1; + end + + strdim = v_ind(ind_start:ind_end); + + indsmcl = find(strdim==':'); + + if isempty(indsmcl) + new_ind = str2num(strdim) + shift.(v_name)(idim); + new_ind = sprintf('%i', new_ind); + else + a = str2num(strdim(1:indsmcl-1)) + shift.(v_name)(idim); + b = str2num(strdim(indsmcl+1:end)) + shift.(v_name)(idim); + new_ind = sprintf('%i:%i', a, b); + end + + if idim==1 + newstr = sprintf( '%s%s', newstr, new_ind ); + else + newstr = sprintf( '%s,%s', newstr, new_ind ); + end + + end + newstr = sprintf( '%s) = %s', newstr, arg ); + + eval(newstr); + end +end +function [strng, is_lit] = parse_literal_strings(strng) +% Parse the literal declarations of strings and change to Matlab syntax + +len = length(strng); +add_squote = []; % Positions to add a scape single quote on syntax +rem_dquote = []; % Positions to remove a double quote scape on syntax +i = 1; +while i < len + if strng(i) == '''', % Opening string with single quote... + i = i + 1; + while i < len && strng(i) ~= '''' || strcmp(strng(i:i+1),'''''') , + i = i + 1; + if strcmp(strng(i-1:i),''''''), + i = i + 1; + end + end + end + if strng(i) == '"', % Opening string with double quote... + strng(i) = ''''; % Change to single quote + i = i + 1; + while strng(i) ~= '"' || strcmp(strng(i:i+1),'""') && i < len, + % Check for a possible sigle quote here + if strng(i) == '''', + add_squote = [add_squote i]; + end + i = i + 1; + if strcmp(strng(i-1:i),'""'), + rem_dquote = [rem_dquote i-1]; + i = i + 1; + end + end + strng(i) = ''''; % Change to single quote + end + i = i + 1; +end +for i = 1:length(add_squote); + strng = [strng(1:add_squote(i)) strng(add_squote(i):end)]; +end +for i = 1:length(rem_dquote); + strng = [strng(1:rem_dquote(i)-1) strng(rem_squote(i)+1:end)]; +end + +% Now everything should be in Matlab string syntax +% Classify syntax as literal or regular expression +i = 1; +len = length(strng); +is_lit = zeros(len,1); +while i < len, + if strng(i) == '''', % Opening string with single quote... + is_lit(i) = 1; + i = i + 1; + while i < len && strng(i) ~= '''' || strcmp(strng(i:i+1),''''''), + is_lit(i) = 1; + i = i + 1; + if strcmp(strng(i-1:i),''''''), + is_lit(i) = 1; + i = i + 1; + end + end + is_lit(i) = 1; + end + i = i + 1; +end \ No newline at end of file diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m new file mode 100755 index 00000000..c71b6cb4 --- /dev/null +++ b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m @@ -0,0 +1,100 @@ +function write_namelist(S, filename, endlines) +% WRITE_NAMELIST(S, FILENAME) writes a namelist data structure S to a +% file FILENAME. S should follow the following structure: +% +% |--VAR1 +% |--VAR2 +% |-- NMLST_A--|... +% | |--VARNa +% | +% | |--VAR1 +% |-- NMLST_B--|--VAR2 +% | |... +% S --| ... |--VARNb +% | +% | |--VAR1 +% |-- NMLST_M--|--VAR2 +% |... +% |--VARNm +% +% Notes: Only supports variables of type: +% Scalars, vectors and 2D numeric arrays (integers and floating points) +% Scalars and 1D boolean arrays specified as '.true.' and '.false.' strings +% Single and 1D arrays of strings +% +% Example: +% NMLST = read_namelist('OPTIONS.nam'); +% NMLST.NAM_FRAC.XUNIF_NATURE = 0.1; +% write_namelist(NMlST, 'MOD_OPTIONS.nam'); +% +% Written by: Darien Pardinas Diaz (darien.pardinas-diaz@monash.edu) +% Version: 1.0 +% Date: 16 Dec 2011 + +fid = fopen(filename, 'w'); +name_lists = fieldnames(S); +n_name_lists = length(name_lists); + +for i = 1:n_name_lists + % Write individual namelist records + if strcmp(name_lists{i}, 'shift') + continue + end + + fprintf(fid, '&%s\n', name_lists{i}); + rcrds = S.(name_lists{i}); + + + rcrds_name = fieldnames(rcrds); + n_rcrds = length(rcrds_name); + + for j = 1:n_rcrds + if strcmp(rcrds_name{j},'shift') + continue + end + + var = rcrds.(rcrds_name{j}); + % Find variable type... + if iscell(var) + fprintf(fid, ' %s =', rcrds_name{j}); + if strcmp(var{1},'.true.') || strcmp(var{1},'.false.') + for k = 1:length(var) + fprintf(fid, ' %s,', var{k}); + end + else + for k = 1:length(var) + fprintf(fid, ' %s,', ['''' var{k} '''']); + end + end + fprintf(fid, '%s\n', ''); + else + [m,n] = size(var); + if m == 1 || n == 1 + % Variable is a scalar or vector + fprintf(fid, ' %s =', rcrds_name{j}); + fprintf(fid, ' %g,', var); + fprintf(fid, '%s\n', ''); + else + % Varible is a two dimensional array + for k = 1:n + fprintf(fid, ' %s(%i,%i:%i) =', rcrds_name{j}, k-S.shift.(rcrds_name{j})(2), ... + 1-S.shift.(rcrds_name{j})(1), ... + n-S.shift.(rcrds_name{j})(1) ); + fprintf(fid, ' %g,', var(:,k)); + fprintf(fid, '%s\n', ''); + end + end + end + end + fprintf(fid, '%s\n', '/'); +end + +s = length(endlines); +for ii=1:s + + fprintf(fid, '%s\n', endlines{ii}); + +end + + + diff --git a/Utilities/matlabtools/Tutorial.01.txt b/Utilities/matlabtools/Tutorial.01.txt index 9594c413..92391167 100644 --- a/Utilities/matlabtools/Tutorial.01.txt +++ b/Utilities/matlabtools/Tutorial.01.txt @@ -22,11 +22,11 @@ 3. Call ploting routine for Poincare section: - plot_spec_poincare(data,1,5,0,1); + plot_spec_poincare(data,1,1,1); 4. Call ploting routine for ideal-interfaces on Poincare section: - plot_spec_kam(data,0,0); + plot_spec_kam(data,1,0); %%% More details %%% diff --git a/Utilities/matlabtools/Tutorial.02.txt b/Utilities/matlabtools/Tutorial.02.txt index b7420250..8aaaff1a 100644 --- a/Utilities/matlabtools/Tutorial.02.txt +++ b/Utilities/matlabtools/Tutorial.02.txt @@ -21,7 +21,7 @@ 3. Call ploting routine for |B| on the boundary surface: - plot_spec_modB_boundary(data,2,32,64); + plot_spec_modB_boundary(data, 2, 0, 64, 64, 3); 3. Call ploting routine for |B| on a cross-section for volumes lvol=2 and lvol=1: diff --git a/Utilities/matlabtools/get_spec_polflux.m b/Utilities/matlabtools/get_spec_polflux.m index 10686f5c..faee4a9a 100644 --- a/Utilities/matlabtools/get_spec_polflux.m +++ b/Utilities/matlabtools/get_spec_polflux.m @@ -1,7 +1,7 @@ function psipol = get_spec_polflux(data,lvol,theta,sarr,nz) % -% GET_SPEC_POLFLUX( DATA, LVOL, THETA, START, SEND, NS, NZ ) +% GET_SPEC_POLFLUX( DATA, LVOL, THETA, sarr, NZ ) % ========================================================== % % Computes total enclosed poloidal flux in the surface defined by theta diff --git a/Utilities/matlabtools/modify_Linitialize.m b/Utilities/matlabtools/modify_Linitialize.m deleted file mode 100644 index b26cc0a8..00000000 --- a/Utilities/matlabtools/modify_Linitialize.m +++ /dev/null @@ -1,53 +0,0 @@ -function modify_Linitialize(filename, Linitialize) - -sref = ' Linitialize ='; -snew1 = strcat(sref,{' '}, num2str(Linitialize)); -snew = snew1{1}; - - - -%Open file -fid = fopen(filename,'rt'); - -tline = fgetl(fid); - -count = 1; -lnum = 0; - -A{1} = tline; - - -% Read template file, copy lines in A, and identify reference lines - -while ischar(tline) - if(size(tline)>=size(sref)) - if(strcmp(tline(1:length(sref)),sref)==1) - lnum = count; - end - end - tline = fgetl(fid); - count = count + 1; - A{count} = tline; -end - -fclose(fid); - - -% Modify cell A at reference lines -A{lnum} = sprintf('%s',snew); - -% Write cell A into new input file - -fid = fopen(filename, 'w'); - -for i = 1:numel(A) - if(A{i+1} == -1) - fprintf(fid,'%s', A{i}); - break - else - fprintf(fid,'%s\n', A{i}); - end -end - -fclose(fid); -end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec.m b/Utilities/matlabtools/plot_spec.m deleted file mode 100644 index f5254642..00000000 --- a/Utilities/matlabtools/plot_spec.m +++ /dev/null @@ -1,1207 +0,0 @@ -function plot_spec(varargin) - -% ========================================================================= -% -% PLOT_SPEC - GUI tool to visualize SPEC output -% -% -% INPUT -% ----- -% plot_spec can be used with either 0, 1 or 2 input argument. -% -% plot_spec(): Open the GUI tool without specifying a directory or a file. -% By default, the directory is the current working directory. -% The file (and directory) can be chosen from the GUI using a -% file explorer. -% -% plot_spec(filename) : Open the GUI tool and already specify SPEC hdf5 -% output file. By default, the directory is the current -% working directory -% -% plot_spec(dir, filename) : Open the GUI tool and specify the directory -% dir and the SPEC hdf5 output file. -% -% -% EXAMPLES -% -------- -% plot_spec -% plot_spec('G2V02L1Fi.001.sp.h5') -% plot_spec('~/specruns/', 'G2V02L1Fi.001.sp.h5') -% -% -% NOTES -% ----- -% - If SPEC output file does not exist or is incomplete (no Poincare data), -% errors will occur -% - Be sure that the path to SPEC routines has been added to MATLAB. (if -% not, use "addpath ~/SPEC/Utilities/matlabtools/" -% -% -% Written by A.Baillod (2019) -% -% ========================================================================= - - -% Test if a figure is open and give a new id for the GUI -listfig = findobj('type', 'figure'); -id = num2str(length(listfig) +1); - - -% Read input variables -switch length(varargin) - case 0 - dir = pwd; - file = '-'; - case 1 - dir = pwd; - file = varargin{1}; - case 2 - dir = varargin{1}; - file = varargin{2}; - otherwise - error('Too many input arguments. Type "help plot_spec" for more informations') -end - - -% ========================================================================= -% Open Figure and setup some tabs - -set(0, 'units', 'pixels'); -monitor = get(0, 'ScreenSize'); -Mwidth = monitor(3); -Mheight = monitor(4); - -MainFig = figure('Name', 'SPEC output', 'NumberTitle', 'off', ... - 'OuterPosition', [0, 0, Mwidth, Mheight]); - -PlotPosition = [.35 .15 .6 .75]; -MainPlot = subplot('Position', PlotPosition, 'Tag', ['MainPlot_', id]); - - -% tab group - -tabgp = uitabgroup(MainFig, 'Position', [.02, .02, .2, .96]); -tab1 = uitab(tabgp, 'Title', 'SPEC run infos'); -tab2 = uitab(tabgp, 'Title', 'Plotting options'); - - - -% ========================================================================= -% FIRST TAB - -% File explorer to select input file and directory -SelectDir = uicontrol('Style', 'pushbutton', 'Parent', tab1, ... - 'String', 'Browse to select output file', 'Units', 'normalized', ... - 'Position', [.025, .94, .95, .04], 'Tag', ['SelectDirButton_', id], ... - 'Callback', {@SelectDirButtonFct, id}, ... - 'FontSize', 11); - -% Directory input field -Dir = uicontrol('Style', 'edit', 'Parent', tab1, 'Units', 'normalized', ... - 'Position', [.025 .82 .95 .04], 'FontSize', 11, ... - 'String', dir, 'Tag', ['Dir_', id], ... - 'HorizontalAlignment', 'Left', ... - 'Callback', {@reset, id}); -% And a text to describe it -DirText = uicontrol('Style', 'text', 'String', 'Directory:', 'Units', 'normalized', ... - 'Position', [.025 .87 .5 .04], 'FontSize', 11, 'Parent', tab1, ... - 'HorizontalAlignment', 'Left'); - - -% File input field -RunName = uicontrol('Style', 'edit', 'Parent', tab1, 'Units', 'normalized', ... - 'Position', [.025 .7 .95 .04], 'FontSize', 11, ... - 'String', file, 'Tag', ['RunName_', id], ... - 'Callback', {@reset, id}, ... - 'HorizontalAlignment', 'Left'); -% And a text to describe it -RunNameText = uicontrol('Style', 'text', 'String', 'Filename:', 'Units', 'normalized', ... - 'Position', [.025 .75 .5 .04], 'FontSize', 11, 'Parent', tab1, ... - 'HorizontalAlignment', 'Left'); - -% Information bubble -RunInfos = uicontrol('Style', 'text', 'Units', 'normalized', 'Parent', tab1, ... - 'Position', [.025 .2 .95 .45], ... - 'String', sprintf('\n\n\n\n %s \n\n %s ','Select a run', 'for additional informations'), ... - 'FontSize', 12, ... - 'Tag', ['RunInfos_', id], 'Max', 10, ... - 'BackgroundColor', 'w', ... - 'HorizontalAlignment', 'Left', 'UserData', struct('data', 1)); - -% Load run button -LoadButton = uicontrol('Style', 'pushbutton', 'Parent', tab1, ... - 'String', 'Load run', 'Units', 'normalized', ... - 'Position', [.025, .15, .95, .04], 'Tag', ['LoadButton_', id], ... - 'Callback', {@LoadButtonFct, id}, ... - 'FontSize', 11, 'UserData', struct('loaded', false)); - - - - - - - -% ========================================================================= -% SECOND TAB - -% Plotting choice -PlotChoice = uicontrol('Style', 'popupmenu', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.025, .825, .95, .03], 'FontSize', 11, ... - 'String', {'Poincare (default)', 'pressure', 'Toroidal flux', 'Poloidal flux', 'iota', ... - 'safety factor', 'modB', 'grid', ... - 'Surface current', 'Volume current', 'B field'}, ... - 'Callback', {@PlotChoiceFct, id}, 'Tag', ['PlotChoice_', id]); - - -% Plotting choice -PlotOption = uicontrol('Style', 'popupmenu', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.025, .725, .95, .03], 'FontSize', 11, ... - 'String', {'No options'}, ... - 'Tag', ['PlotOption_', id], ... - 'Callback', {@PlotOptionFct, id}); - -InfoButton = uicontrol('Style', 'pushbutton', 'Parent', tab2, ... - 'String', 'Informations', 'Units', 'normalized', ... - 'Position', [.025 .625 .95 .03], 'Tag', ['InfoButton_', id], ... - 'Callback', {@InfoButtonFct, id}, 'FontSize', 11); - -% Autoplot radio button -AutoPlot = uicontrol('Style', 'radiobutton', 'String', 'Enable auto plot', 'Units', 'normalized', ... - 'Position', [0.025, .9, .45, .03], 'FontSize', 12, ... - 'Tag', ['AutoPlot_', id], 'Parent', tab2); - - -% Overlay radio button -Overlay = uicontrol('Style', 'radiobutton', 'String', 'Overlay', 'Units', 'normalized', ... - 'Position', [0.525, .9, .45, .03], 'FontSize', 12, ... - 'Tag', ['Overlay_', id], 'Parent', tab2); - - -% Display toroidal plane -DispTorPlane = uicontrol('Style', 'text', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.025 .535 .95 .03], 'String', 'Toroidal plane 1/?', 'FontSize', 11, ... - 'Tag', ['DispTorPlane_', id], 'UserData', struct('TorPlane', 1)); -% And some pushbuttons to move around -PlusTorPlane = uicontrol('Style', 'pushbutton', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.475 .50 .45 .03], 'String', '+', 'Fontsize', 12, ... - 'Tag', ['PlusTorPlane_', id], 'Callback', {@PlusTorPlaneFct, id}); -MinusTorPlane = uicontrol('Style', 'pushbutton', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.025 .50 .45 .03], 'String', '-', 'Fontsize', 12, ... - 'Tag', ['MinusTorPlane_', id], 'Callback', {@MinusTorPlaneFct, id}); - - -% Display poloidal angle -DispTheta = uicontrol('Style', 'text', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.025 .435 .95 .03], 'String', 'Theta = 180', 'FontSize', 11, ... - 'Tag', ['DispTheta_', id]); -% And some pushbuttons to move around -ThetaSlider = uicontrol('Style', 'slider', 'Parent', tab2, 'Units', 'normalized', ... - 'Position', [.025 .40 .95 .03], 'Value', 180, 'Min', 0, 'Max', 360, ... - 'Tag', ['ThetaSlider_', id], 'Callback', {@ThetaSliderFct, id}); - - - -% Plot button and its explanation text -Status = uicontrol('Style', 'text', 'String', 'Ready to plot', 'Units', 'normalized', ... - 'Position', [.025 .01 .95 .15], 'FontSize', 11, 'Parent', tab2, ... - 'Tag', ['Status_', id], 'BackgroundColor', 'w'); -PlotButton = uicontrol('Style', 'pushbutton', 'Parent', tab2, ... - 'String', 'Plot Poincare', 'Units', 'normalized', ... - 'Position', [.025, .2, .95, .05], 'Tag', ['PlotButton_', id], ... - 'Callback', {@PlotButtonFct, id}, ... - 'FontSize', 11); - - - - - - - - - - - -end - - - - - -% ========================================================================= -% CALLBACK DEFINITION -% ========================================================================= - -function SelectDirButtonFct(src, event, id) -% Open file explorer to find SPEC output file and select it. Callback -% function for SelectDir button on tab 1 -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure -% - - DirButton = findobj('Tag', ['Dir_', id]); - FileButton = findobj('Tag', ['RunName_', id]); - - - if (FileButton.String==string('-')) - temp = 'output.sp.h5'; - else - temp = char(FileButton.String); - end - - [file, path] = uigetfile(temp); - - - if (all(file==0) && all(path==0)) - warning('Please select a file') - else - DirButton.String = string(path); - FileButton.String = string(file); - end - - reset(src,event,id); - -end - - -function reset(src,event,id) -% Resets options, select Poincare plot and set the flag loaded to false. -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - - PlotChoice = findobj('Tag', ['PlotChoice_', id]); - PlotChoice.Value = 1; - - PlotOption = findobj('Tag', ['PlotOption_', id]); - PlotOption.Value = 1; - PlotOption.String = 'No options'; - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - DispTorPlane.UserData.TorPlane = 1; - DispTorPlane.String = 'Toroidal plane 1/?'; - - ThetaSlider = findobj('Tag', ['ThetaSlider_', id]); - ThetaSlider.Value = 180; - - DispTheta = findobj('Tag', ['DispTheta_', id]); - DispTheta.String = 'Theta = 180'; - - PlotButton = findobj('Tag', ['PlotButton_', id]); - PlotButton.String = 'Plot Poincare'; - - LoadButton = findobj('Tag', ['LoadButton_', id]); - LoadButton.UserData.loaded = false; - - -end - -function PlotChoiceFct(src,event,id) -% Define different possible options given which plot is required by the -% user. Callback of button PlotChoice -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - PlotButton = findobj('Tag', ['PlotButton_', id]); - PlotChoice = findobj('Tag', ['PlotChoice_', id]); - - str_temp = PlotChoice.String(PlotChoice.Value); - - PlotButton.String = ['Plot ', str_temp{1}]; - - tmp = pwd; - Dir = findobj('Tag', ['Dir_', id]); - RunName = findobj('Tag', ['RunName_', id]); - cd(Dir.String); - - PlotOption = findobj('Tag', ['PlotOption_', id]); - PlotOption.Value = 1; - - ChoiceList = PlotChoice.String; - ToPlot = ChoiceList(PlotChoice.Value); - ToPlot = ToPlot{1}; - - switch ToPlot - case 'Poincare (default)' - PlotOption.String = {'No option'}; - case 'Toroidal flux' - PlotOption.String = {'Non cumulative', 'cumulative'}; - case 'Poloidal flux' - PlotOption.String = {'Non cumulative', 'cumulative'}; - case 'iota' - PlotOption.String = {'s-coordinate', 'R-coordinate', 'Toroidal flux', 'sqrt(toroidal flux)'}; - case 'safety factor' - PlotOption.String = {'s-coordinate', 'R-coordinate', 'Toroidal flux', 'sqrt(toroidal flux)'}; - case 'grid' - PlotOption.String = {'No option'}; - case 'pressure' - PlotOption.String = {'No option'}; - case 'modB' - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - return - end - Nvol = data.input.physics.Nvol + data.input.physics.Lfreebound; - NewString = {'All'}; - for ii = 1:Nvol - NewString{ii+1} = ['Volume ', num2str(ii)]; - end - PlotOption.String = NewString; - case 'Surface current' - PlotOption.String = {'No option'}; - case 'Volume current' - PlotOption.String = {'Non cumulative', 'Cumulative'}; - case 'B field' - PlotOption.String = {'All', 'radial component', 'poloidal component', 'toroidal component'}; - end - - AutoPlot = findobj('Tag', ['AutoPlot_', id]); - if AutoPlot.Value - PlotButtonFct(src,event,id) - end - - - cd(tmp); -end - -function InfoButtonFct(src,event,id) -% Define the information text given the plot the user requires. Callback of -% button InfoButton -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - tfigure = figure; - t = uicontrol('Style', 'edit', 'Units', 'normalized', 'Position', [.05 .05 .9 .9], 'min', 0, 'max', 2, 'Parent', tfigure, ... - 'FontSize', 14); - - PlotChoice = findobj('Tag', ['PlotChoice_', id]); - - ChoiceList = PlotChoice.String; - ToPlot = ChoiceList(PlotChoice.Value); - ToPlot = ToPlot{1}; - - switch ToPlot - case 'Poincare (default)' - str = {[newline, 'Poincare plot', newline, '-------------', newline, newline, ... - 'Generate a Poincare plot at a given toroidal plane. Navigate ', ... - 'between toroidal planes with the "+" and "-" buttons. Press', ... - ' on "Enable auto plot" for automatic plotting of each plane.']}; - case 'Toroidal flux' - str = {[newline, 'Toroidal flux', newline, '-------------', newline, newline, ... - 'Generate a bar plot of the toroidal flux in each volume. ', ... - 'Options are cumulative or non-cumulative. The cumulative plot will sum ', ... - 'the toroidal flux from volume 1 to i for the ith bar; non cumulative will ', ... - 'not sum toroidal flux between volumes.', newline, newline, ... - 'Please note that the flux is integrated from the vector potential solution, ', ... - 'and not read from the variable tflux. Small differences may occur due to the ',... - 'integration resolution.']}; - case 'Poloidal flux' - str = {[newline, 'Poloidal flux', newline, '-------------', newline, newline, ... - 'Generate a bar plot of the poloidal flux in each volume. ', ... - 'Options are cumulative or non-cumulative. The cumulative plot will sum ', ... - 'the poloidal flux from volume 1 to i for the ith bar; non cumulative will ', ... - 'not sum poloidal flux between volumes.', newline, newline, ... - 'Please note that the flux is integrated from the vector potential solution, ', ... - 'and not read from the variable tflux. Small differences may occur due to the ',... - 'integration resolution.']}; - case 'iota' - str = {[newline, 'Rotational transform plot', newline, '-------------------------', newline, newline, ... - 'Plots the rotational transform as a function of either the volume radial coordinate s, the major radius R,', ... - ' the toroidal flux or the square root of the toroidal flux (~minor radius). Change the x-axis with the ', ... - 'option menu.']}; - case 'safety factor' - str = {[newline, 'Safety factor plot', newline, '------------------', newline, newline, ... - 'Plots the safety factor as a function of either the volume radial coordinate s, the major radius R,', ... - ' the toroidal flux or the square root of the toroidal flux (~minor radius). Change the x-axis with the ', ... - 'option menu.']}; - - case 'grid' - str = {[newline, 'Grid plot', newline, '---------', newline, newline, ... - 'Plots the coordinate grid. Represents how the volume radial coordinate s is chosen']}; - case 'pressure' - str = {[newline, 'Pressure plot', newline, '-------------', newline, newline, ... - 'Plots the pressure steps.']}; - case 'modB' - str = {[newline, 'Modulus of magnetic field plot', newline, '----------------------------', newline, newline, ... - 'Plots a colormap of the magnetic field strength on a poloidal cut (constant toroidal angle). Change the ', ... - 'toroidal angle with the button "+" and "-".']}; - case 'Surface current' - str = {[newline, 'Surface current plot', newline, '--------------------', newline, newline, ... - 'Produce a bar plot of the toroidal current sheet in each KAM surface. Useful for comparison with', ... - 'toroidal current constraint.']}; - case 'Volume current' - str = {[newline, 'Volume current plot', newline, '-------------------', newline, newline, ... - 'Produce a bar plot of the volume current in each volume. Useful for comparison with', ... - 'toroidal current constraint.']}; - case 'B field' - str = {[newline, 'Magnetic field plot', newline, '-------------------', newline, newline, ... - 'Plots the toroidal, poloidal and radial component of the magnetic field as a function of', ... - 'the distance to the magnetic axis. The toroidal and poloidal angles can be changed with',... - 'the "+" / "-" buttons and the slider respectively.']}; - end - - set(t, 'String', str); -end - -function PlotOptionFct(src,event,id) -% Automatically plot the data if Autoplot is set. Callback of -% button PlotOption -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - AutoPlot = findobj('Tag', ['AutoPlot_', id]); - if AutoPlot.Value - PlotButtonFct(src,event,id) - end -end - -function LoadButtonFct(src,event,id) -% Load the data and set the flag loaded to true. Callback of -% button LoadButton -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - tmp = pwd; - Dir = findobj('Tag', ['Dir_', id]); - RunName = findobj('Tag', ['RunName_', id]); - - cd(Dir.String); - - RunInfos = findobj('Tag', ['RunInfos_', id]); - if exist(RunName.String, 'file') - - data = read_spec(RunName.String); - RunInfos.UserData.data = data; - - NewStr = sprintf('\n%s\n%s\n\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s', ... - 'Informations:', ... - '-----------------------', ... - sprintf('Igeometry: %i', data.input.physics.Igeometry), ... - sprintf('Istellsym: %i', data.input.physics.Istellsym), ... - sprintf('Lconstraint: %i', data.input.physics.Lconstraint), ... - sprintf('Lfreebound: %i', data.input.physics.Lfreebound), ... - sprintf('Nvol: %i', data.input.physics.Nvol), ... - sprintf('mupftol: %0.2e', data.input.physics.mupftol), ... - sprintf('ForceErr: %0.2e', data.output.ForceErr)); - else - NewStr = sprintf('\n%s\n%s\n\n%s\n', ... - 'Informations:', ... - '-----------------------', ... - 'File not found!'); - RunInfos.String = NewStr; - return - end - - - - RunInfos.String = NewStr; - - AutoPlot = findobj('Tag', ['AutoPlot_', id]); - if AutoPlot.Value - PlotButtonFct(src,event,id) - end - - LoadButton = findobj('Tag', ['LoadButton_', id]); - LoadButton.UserData.loaded = true; - - - %reset(src,event,id) - - cd(tmp); -end - -function MinusTorPlaneFct(src,event,id) -% Select previous toroidal plane. Callback of -% button MinusTorPlane -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - Status = findobj('Tag', ['Status_', id]); - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - TorPlane = DispTorPlane.UserData.TorPlane; - - tmp = pwd; - Dir = findobj('Tag', ['Dir_', id]); - RunName = findobj('Tag', ['RunName_', id]); - cd(Dir.String); - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - return - end - - % Change TorPlane - nz = size(data.poincare.R,2); % # of toroidal planes - - if TorPlane==1 - TorPlane = nz; - else - TorPlane = TorPlane - 1; - end - - DispTorPlane.UserData.TorPlane = TorPlane; - DispTorPlane.String = sprintf('Toroidal plane %i/%i', TorPlane, nz); - - AutoPlot = findobj('Tag', ['AutoPlot_', id]); - if AutoPlot.Value - PlotButtonFct(src,event,id) - end - - cd(tmp); -end - -function PlusTorPlaneFct(src,event,id) -% Select next toroidal plane. Callback of -% button PlusTorPlane -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - Status = findobj('Tag', ['Status_', id]); - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - TorPlane = DispTorPlane.UserData.TorPlane; - - tmp = pwd; - Dir = findobj('Tag', ['Dir_', id]); - RunName = findobj('Tag', ['RunName_', id]); - cd(Dir.String); - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - return - end - - % Change TorPlane - nz = size(data.poincare.R,2); % # of toroidal planes - - if TorPlane==nz - TorPlane = 1; - else - TorPlane = TorPlane + 1; - end - - DispTorPlane.UserData.TorPlane = TorPlane; - DispTorPlane.String = sprintf('Toroidal plane %i/%i', TorPlane, nz); - - AutoPlot = findobj('Tag', ['AutoPlot_', id]); - if AutoPlot.Value - PlotButtonFct(src,event,id) - end - - cd(tmp); -end - -function ThetaSliderFct(src,event,id) -% Select theta angle given the slider value. Callback of -% button ThetaSlider -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - DispTheta = findobj('Tag', ['DispTheta_', id]); - ThetaSlider = findobj('Tag', ['ThetaSlider_', id]); - - theta = ThetaSlider.Value; - DispTheta.String = sprintf('Theta = %0.1f', theta); - - AutoPlot = findobj('Tag', ['AutoPlot_', id]); - if AutoPlot.Value - PlotButtonFct(src,event,id) - end - -end - -function PlotButtonFct(src,event,id) -% Plot the data. Callback function of PlotButton -% -% INPUT -% ----- -% src: required, not used -% event: required, not used -% id: Identificator for plot_spec figure - - LoadButton = findobj('Tag', ['LoadButton_', id]); - Status = findobj('Tag', ['Status_', id]); - try - if ~LoadButton.UserData.loaded - error('ERROR: Please load data file first (Load run button)') - end - catch er - Status.String = er.message; - return - end - - Status.String = ['Processing . . .']; - - - tmp = pwd; - Dir = findobj('Tag', ['Dir_', id]); - cd(Dir.String); - - MainPlot = findobj('Tag', ['MainPlot_', id]); - %axes(MainPlot); - - RunName = findobj('Tag', ['RunName_', id]); - PlotChoice = findobj('Tag', ['PlotChoice_', id]); - - ChoiceList = PlotChoice.String; % 'Poincare (default)', 'iota', 'safety factor' - ToPlot = ChoiceList(PlotChoice.Value); - ToPlot = ToPlot{1}; - - PlotOption = findobj('Tag', ['PlotOption_', id]); - - % Plot - %axes(MainPlot); - switch ToPlot - case 'Poincare (default)' - out = plot_poincare(Status, id); - case 'Toroidal flux' - switch PlotOption.Value - case 1 - out = plot_torflux(Status, false, id); - case 2 - out = plot_torflux(Status, true, id); - end - case 'Poloidal flux' - switch PlotOption.Value - case 1 - out = plot_polflux(Status, false, id); - case 2 - out = plot_polflux(Status, true, id); - end - case 'iota' - switch PlotOption.Value - case 1 - out = plot_iota(Status, 'i', 's', id); - case 2 - out = plot_iota(Status, 'i', 'R', id); - case 3 - out = plot_iota(Status, 'i', 'f', id); - case 4 - out = plot_iota(Status, 'i', 'r', id); - end - case 'safety factor' - switch PlotOption.Value - case 1 - out = plot_iota(Status, 'q', 's', id); - case 2 - out = plot_iota(Status, 'q', 'R', id); - case 3 - out = plot_iota(Status, 'q', 'f', id); - case 4 - out = plot_iota(Status, 'q', 'r', id); - end - case 'grid' - out = plot_grid(Status, id); - case 'pressure' - out = plot_pressure(Status, id); - case 'modB' - out = plot_modB(Status, id); - case 'Surface current' - out = plot_surfI(Status, id); - case 'Volume current' - switch PlotOption.Value - case 1 - out = plot_volI(Status, id, false); - case 2 - out = plot_volI(Status, id, true); - end - case 'B field' - out = plot_field(Status, id); - end - - - cd(tmp); - - if out - Status.String = 'Done. Ready to plot'; - end -end - - -function out = plot_poincare(Status, id) -% Plot poincare data -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - if ~isfield(data, 'poincare') - Status.String = 'No poincare data available for this run'; - out = false; - return - end - - % Get zeta angle - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - Nfp = double(data.input.physics.Nfp); - nz = 4*data.input.physics.Ntor*data.input.numerics.Ndiscrete; - zeta = double((NTorPlane-1) * (2 * pi / nz)/ Nfp);%zeta = (nz0-1)*(2*pi/nz)/nfp; - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - plot_spec_poincare(data, NTorPlane, Nfp, 0, newfig); - plot_spec_kam(data, zeta / (2*pi), 0); - - out = true; -end - -function out = plot_torflux(Status, cumulative, id) -% Plot toroidal flux data. Can plot the cumulative flux (integral of B.dS -% from r=0 to r_max) or non cumulative flux (integral of B.dS -% from r_min to r_max) -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% cumulative: bool to chose if cumulative or non cumulative plot -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - Nfp = double(data.input.physics.Nfp); - nz = 4*data.input.physics.Ntor*data.input.numerics.Ndiscrete; - zeta = double((NTorPlane-1) * (2 * pi / nz)/ Nfp);%zeta = (nz0-1)*(2*pi/nz)/nfp; - - plot_spec_torflux(data, zeta, cumulative, 2); - out = true; -end - -function out = plot_polflux(Status, cumulative, id) -% Plot poloidal flux data. Can plot the cumulative flux (integral of B.dS -% from r=0 to r_max) or non cumulative flux (integral of B.dS -% from r_min to r_max) -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% cumulative: bool to chose if cumulative or non cumulative plot -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - Nfp = double(data.input.physics.Nfp); - nz = 4*data.input.physics.Ntor*data.input.numerics.Ndiscrete; - zeta = double((NTorPlane-1) * (2 * pi / nz)/ Nfp);%zeta = (nz0-1)*(2*pi/nz)/nfp; - - plot_spec_polflux(data, zeta, cumulative, 2); - out = true; -end - -function out = plot_iota(Status, iorq, xaxis, id) -% Plot iota or safety factor as a function of s, R, toroidal flux or square -% root of toroidal flux. -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% iorq: chose either the iota or safety factor profile -% xaxis: chose s, R, toroidal flux or square root of toroidal flux for x -% axis. -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - % Load poincare data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - if ~isfield(data, 'poincare') - Status.String = 'No poincare data available for this run. Try plotting iota at KAM surfaces using plot_spec_iota_kam.'; - out = false; - return - end - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - plot_spec_iota(data, iorq, xaxis, newfig); - out = true; -end - -function out = plot_grid(Status, id) -% Plot coordinate grid -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - % Load poincare data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - plot_spec_grid(data, NTorPlane, newfig); - out = true; -end - -function out = plot_pressure(Status, id) -% Plot pressure -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - plot_spec_pressure(data, newfig); - grid on; - out = true; -end - -function out = plot_modB(Status, id) -% Plot modulus of B -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - % Load data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - Nfp = double(data.input.physics.Nfp); - nz = 4*data.input.physics.Ntor*data.input.numerics.Ndiscrete; - zeta = double((NTorPlane-1) * (2 * pi / nz) * 1 / Nfp); - - Mvol = data.input.physics.Nvol + data.input.physics.Lfreebound; - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - PlotOption = findobj('Tag', ['PlotOption_', id]); - lvolstr = PlotOption.String{PlotOption.Value}; - if strcmp(lvolstr,'All') - tarr = linspace(0, 2*pi, 100); - sarr = linspace(-1+1E-2, 1, 100); - - - - plot_spec_modB(data, 1, sarr, tarr, zeta, newfig); - - sarr = linspace(-1, 1, 100); - for ii=2:Mvol - plot_spec_modB(data, ii, sarr, tarr, zeta, 0); - end - - plot_spec_kam(data, zeta / (2*pi), 0); - else - lvol = str2double(lvolstr(8:end)); - - tarr = linspace(0, 2*pi, 100); - - if lvol==1 - sarr = linspace(-1+1E-2, 1, 100); - else - sarr = linspace(-1, 1, 100); - end - - plot_spec_modB(data, lvol, sarr, tarr, zeta, newfig); - - end - out = true; -end - -function out = plot_surfI(Status, id) -% Plot surface current -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% id: Identificator for plot_spec figure -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - -%Load poincare data - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - Nfp = double(data.input.physics.Nfp); - nz = 4*data.input.physics.Ntor*data.input.numerics.Ndiscrete; - zeta = double((NTorPlane-1) * (2 * pi / nz) * 1 / Nfp); - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - plot_spec_surfcurent(data, 256, 256, zeta, newfig); - out = true; -end - -function out = plot_volI(Status, id, cumul) -% Plot volume current, either in cumulative or non cumulative format -% -% INPUT -% ----- -% Status: object containing plotting status. string is modified depending -% on status. -% id: Identificator for plot_spec figure -% cumul: Chose if the cumulative volume current or the non cumulative -% one is plotted -% -% OUTPUT -% ------ -% out: Bool set to false if failure -% - - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - plot_spec_Ivolume(data, cumul, 2); - out = true; -end - -function out = plot_field(Status, id) -%Load poincare data -disp('!!! WARNING: This plot might be wrong in slab geometry. to debug!') - try - RunInfos = findobj('Tag', ['RunInfos_', id]); - data = RunInfos.UserData.data; - catch ME - Status.String = ME.message; - out = false; - return - end - - pdata = pdata_from_data(data); - - DispTorPlane = findobj('Tag', ['DispTorPlane_', id]); - NTorPlane = DispTorPlane.UserData.TorPlane; - Nfp = double(pdata.Nfp); - nz = size(pdata.R_lines,2); % # of toroidal planes - zeta = double((NTorPlane-1) * (2 * pi / nz) * 1 / Nfp); - - ThetaSlider = findobj('Tag', ['ThetaSlider_', id]); - theta = ThetaSlider.Value; - - theta = theta * pi / 180; - - Overlay = findobj('Tag', ['Overlay_', id]); - if Overlay.Value - newfig = 0; - else - newfig = 2; - end - - PlotOption = findobj('Tag', ['PlotOption_', id]); - Pltopt = PlotOption.String{PlotOption.Value}; - - switch Pltopt - case 'All' - plot_spec_Bfield(data, 'all', theta, zeta, 500, newfig) - case 'radial component' - plot_spec_Bfield(data, 'psi', theta, zeta, 500, newfig) - case 'poloidal component' - plot_spec_Bfield(data, 'theta', theta, zeta, 500, newfig) - case 'toroidal component' - plot_spec_Bfield(data, 'phi', theta, zeta, 500, newfig) - end - - out = true; - -end - - - - - diff --git a/Utilities/matlabtools/plot_spec_Bgrid.m b/Utilities/matlabtools/plot_spec_Bgrid.m index 8fb5d437..12f8240d 100644 --- a/Utilities/matlabtools/plot_spec_Bgrid.m +++ b/Utilities/matlabtools/plot_spec_Bgrid.m @@ -19,8 +19,21 @@ function plot_spec_Bgrid(data,nz0,plotstyle,newfig) % % OUTDATED - NEED DEBUG -if(newfig==1) - figure('Color','w','Position',[200 200 1500, 600]) +% Check inputs +if ~strcmp(string(plotstyle),string('pcolor')) && ~strcmp(string(plotstyle),string('scatter')) + error('InputError: Invalid plotstyle') +end + +switch newfig + case 0 + hold on + case 1 + figure('Color','w','Position',[200 200 1500, 600]) + hold on + case 2 + hold off + otherwise + error('Invalide newfig') end Mvol = data.output.Mvol; diff --git a/Utilities/matlabtools/plot_spec_Ivolume.m b/Utilities/matlabtools/plot_spec_Ivolume.m index eb0ed0f6..e051d39b 100644 --- a/Utilities/matlabtools/plot_spec_Ivolume.m +++ b/Utilities/matlabtools/plot_spec_Ivolume.m @@ -16,30 +16,29 @@ function plot_spec_Ivolume(data, cumul, newfig) % Written by A. Baillod (2019) % + if ~any(cumul==[0,1]) + error('InputError: invalid cumul') + end -[psi_coord, I_vol] = get_spec_volume_current(data, cumul); + switch newfig + case 0 + hold on + case 1 + figure + hold on + case 2 + hold off + end -% some plots + [~, I_vol] = get_spec_volume_current(data, cumul); -switch newfig - case 0 - hold on - case 1 - figure - hold on - case 2 - hold off -end -%plot(psi_coord, I_vol, '*', 'DisplayName', '$I^{vol}_\phi$') -bar(I_vol); -%leg = legend('Location','northwest'); -ylab = ylabel('$\mu_0I_\mathcal{V}$[A]'); -%xlab = xlabel('$\psi_t / \psi_{edge}$'); -xlab = xlabel('Volume label'); -set(gca, 'FontSize', 14) -%set(leg,'Interpreter','latex'); -set(xlab,'Interpreter','latex'); -set(ylab,'Interpreter','latex'); -grid on; + bar(I_vol); + xlab = xlabel('Volume label'); + ylab = ylabel('$\mu_0I_\mathcal{V}$[A]'); + set(gca, 'FontSize', 14) + set(xlab,'Interpreter','latex'); + set(ylab,'Interpreter','latex'); + grid on; +end diff --git a/Utilities/matlabtools/plot_spec_current_profile.m b/Utilities/matlabtools/plot_spec_current_profile.m index d3b6f334..088f6478 100644 --- a/Utilities/matlabtools/plot_spec_current_profile.m +++ b/Utilities/matlabtools/plot_spec_current_profile.m @@ -15,9 +15,34 @@ function plot_spec_current_profile( data, iflag, newfig, varargin ) % * newfig: (0) plot on current figure % (1) open a new figure % (2) Erase current figure and use it +% * Optional input: any combination of +% -'LineWidth', value (default 2) +% -'Color', value (default 'r') +% -'Marker', value (default 'none') +% -'MarkerSize', value (default 8) +% -'LineStyle', value (default '-') % % Written by A. Baillod (2020) % + + % Check inputs + if ~any(iflag==[0,1,2]) + error('InputError: Invalid iflag') + end + + switch newfig + case 0 + hold on + case 1 + figure('Position', [200 200 900 700],'Color','w') + hold on + case 2 + hold off + otherwise + error('InputError: invalid newfig') + end + + l = length(varargin); if mod(l,2)~=0 error('Invalid number of argument') @@ -35,80 +60,74 @@ function plot_spec_current_profile( data, iflag, newfig, varargin ) opt.(field) = value; end - - switch newfig - case 0 - hold on - case 1 - figure('Position', [200 200 900 700],'Color','w') - hold on - case 2 - hold off - end - - nsucctrj = length(data.poincare.R(:,1,1)); % number of successfully followed trajectories - sval = data.transform.fiota(1:nsucctrj,1); - nvol = data.input.physics.Nvol; - mvol = data.output.Mvol; - nptrj = zeros(1,mvol); - count = 1; - - ind = find(sval==-2); %Remove wrongly written data - sval(ind) = []; - for is=1:length(sval)-1 - if(sval(is)>0 && sval(is+1)<0) %Reached the end of a volume - if(count==1) - nptrj(count) = is; - else - nptrj(count) = is-sum(nptrj); + nsucctrj = length(data.poincare.R(:,1,1)); % number of successfully followed trajectories + sval = data.transform.fiota(1:nsucctrj,1); + nvol = data.input.physics.Nvol; + mvol = data.output.Mvol; + nptrj = zeros(1,mvol); + count = 1; + + ind = find(sval==-2); %Remove wrongly written data + sval(ind) = []; + + for is=1:length(sval)-1 + if(sval(is)>0 && sval(is+1)<0) %Reached the end of a volume + if(count==1) + nptrj(count) = is; + else + nptrj(count) = is-sum(nptrj); + end + count = count+1; + end end - count = count+1; - end - end - nptrj(mvol) = length(sval)-sum(nptrj); - - - ns = 32; - nt = 32; - cumflux = 0; - cumcur = 0; - kstart = 1; - psitor = zeros(1,length(sval)); - - Iphi = zeros(1, length(sval) ); - mu = data.output.mu; - - for lvol=1:mvol - - for k=kstart:kstart-1+nptrj(lvol) - tflux = get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); - psitor(k) = cumflux + tflux; - - if iflag==0 || iflag==2 - Iphi(k) = cumcur + mu(lvol) * tflux; - else - Iphi(k) = cumcur; - end - end - cumflux = psitor(k); - kstart = kstart+nptrj(lvol); - %cumcur = Iphi(k); - - if iflag==1 || iflag==2 - cumcur = Iphi(k) + data.output.IPDt(lvol); % add surface current - else - cumcur = Iphi(k); - end - end - - phiedge=psitor(end); - - - plot( sqrt(psitor / phiedge), Iphi, 'LineWidth', opt.LineWidth, 'Color', opt.Color, 'Marker', opt.Marker, 'LineStyle', opt.LineStyle ) - xlabel('$(\Psi_t / \Psi_{edge})^{1/2}$', 'Interpreter', 'latex') - ylabel('$\mu_0I_\phi$[Tm]', 'Interpreter', 'latex') - set(gca, 'FontSize', 18) - hold on; + nptrj(mvol) = length(sval)-sum(nptrj); + + + ns = 32; + nt = 32; + cumflux = 0; + cumcur = 0; + kstart = 1; + psitor = zeros(1,length(sval)); + + Iphi = zeros(1, length(sval) ); + mu = data.output.mu; + + for lvol=1:mvol + start = -1; + if lvol==1 + start=-0.999; + end + + for k=kstart:kstart-1+nptrj(lvol) + tflux = get_spec_torflux(data,lvol,0,start,sval(k),ns,nt); + psitor(k) = cumflux + tflux; + + if iflag==0 || iflag==2 + Iphi(k) = cumcur + mu(lvol) * tflux; + else + Iphi(k) = cumcur; + end + end + cumflux = psitor(k); + kstart = kstart+nptrj(lvol); + %cumcur = Iphi(k); + + if iflag==1 || iflag==2 + cumcur = Iphi(k) + data.output.IPDt(lvol); % add surface current + else + cumcur = Iphi(k); + end + end + + phiedge=psitor(end); + + + plot( sqrt(psitor / phiedge), Iphi, 'LineWidth', opt.LineWidth, 'Color', opt.Color, 'Marker', opt.Marker, 'LineStyle', opt.LineStyle ) + xlabel('$(\Psi_t / \Psi_{edge})^{1/2}$', 'Interpreter', 'latex') + ylabel('$\mu_0I_\phi$[Tm]', 'Interpreter', 'latex') + set(gca, 'FontSize', 18) + hold on; end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_grid.m b/Utilities/matlabtools/plot_spec_grid.m index 88ecac72..a38611f1 100644 --- a/Utilities/matlabtools/plot_spec_grid.m +++ b/Utilities/matlabtools/plot_spec_grid.m @@ -11,7 +11,7 @@ function plot_spec_grid(data,nz0,newfig) % -data : must be produced by calling read_spec(filename) % -nz0 : toroidal plane number at which coordinates are shown (nz0=1 at toroidal angle phi=0) % -newfig : opens(=1) or not(=0) a new figure, or overwrite selected -% figure (=2) +% figure (=2) % % written by J.Loizu (2015) % @@ -24,23 +24,24 @@ function plot_spec_grid(data,nz0,newfig) hold on case 2 hold off + otherwise + error('InputError: invalid newfig') end -nvol = data.input.physics.Nvol+data.input.physics.Lfreebound; +Mvol = data.output.Mvol; Lrad = data.input.physics.Lrad; Nt = data.grid.Nt; -Nz = data.grid.Nz; Rij = data.grid.Rij; Zij = data.grid.Zij; ccol = 'm'; -cthick = 12; +cthick = 6; iz = nz0-1; -for i=1:nvol +for i=1:Mvol for l=1:Lrad(i)+1 R_tmp = Rij{i}; diff --git a/Utilities/matlabtools/plot_spec_hessian.m b/Utilities/matlabtools/plot_spec_hessian.m deleted file mode 100644 index 49b58995..00000000 --- a/Utilities/matlabtools/plot_spec_hessian.m +++ /dev/null @@ -1,21 +0,0 @@ -function plot_spec_hessian(data) - -% -% PLOT_SPEC_HESSIAN( DATA ) -% ========================= -% -% Plots the hessian matrix elements -% -% INPUT -% ----- -% -data : must be produced by calling read_spec_hessian(filename) -% -% written by J.Loizu (2017) - -figure - -imagesc(data) - -colorbar - -%set(gca, 'CLim', [-0.1 0.1]); diff --git a/Utilities/matlabtools/plot_spec_iota.m b/Utilities/matlabtools/plot_spec_iota.m index b9dfeb3c..0f72c67e 100644 --- a/Utilities/matlabtools/plot_spec_iota.m +++ b/Utilities/matlabtools/plot_spec_iota.m @@ -8,13 +8,20 @@ % % INPUT % ----- -% -data : produced by calling read_spec(fname) -% -iorq : plot iota('i') or safety factor ('q') -% -xaxis='s' : plots s-coordinnate as the x-axis -% -xaxis='R' : plots R-coordinnate as the x-axis -% -xaxis='f' : plots toroidal flux as the x-axis -% -xaxis='r' : plots sqrt(toroidal flux) as the x-axis -% -newfig : opens(=1) or not(=0) a new figure, or overwrites(=2) current plot +% -data : produced by calling read_spec(fname) +% -iorq : plot iota('i') or safety factor ('q') +% -xaxis : 's' plots s-coordinnate as the x-axis +% 'R' plots R-coordinnate as the x-axis +% 'f' plots toroidal flux as the x-axis +% 'r' plots sqrt(toroidal flux) as the x-axis +% -newfig: opens (=1) or not (=0) a new figure, or overwrites (=2) +% current plot +% -varargin: Optional arguments. Can be any of the following pairs, +% 'LineWidth', linewidth +% 'Color', color +% 'Marker', marker +% 'MarkerSize', makersize +% 'LineStyle', linestyle % % OUTPUT % ------ @@ -26,171 +33,192 @@ % modified by A.Baillod (01.2019) % modified by J.Loizu (01.2020) -l = length(varargin); -if mod(l,2)~=0 - error('Invalid number of argument') -end + % Check inputs + if ~any(iorq==['iq']) + error('InputError: invalid iorq') + end + + if ~any(xaxis==['sRfr']) + error('InputError: invalid xaxis') + end -opt.LineWidth = 2; -opt.Color = 'r'; -opt.Marker = '*'; -opt.MarkerSize = 8; -opt.LineStyle = 'none'; -for ii=1:l/2 - field = varargin{2*ii-1}; - value = varargin{2*ii }; + l = length(varargin); + if mod(l,2)~=0 + error('InputError: invalid number of argument') + end - opt.(field) = value; -end + switch newfig + case 1 + figure('Position', [200 200 900 700], 'Color', 'w') + hold on; + case 0 + hold on; + case 2 + hold off; + otherwise + error('InputError: invalid newfig') + end + % Read optional inputs + opt.LineWidth = 2; + opt.Color = 'r'; + opt.Marker = '*'; + opt.MarkerSize = 8; + opt.LineStyle = 'none'; + for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + opt.(field) = value; + end -if(newfig==1) - figure('Position', [200 200 900 700], 'Color', 'w') - hold on; -elseif newfig==0 - hold on; -elseif newfig==2 % A.Baillod (06.2019) - hold off; -end -if(iorq=='i') -F = data.transform.fiota(1:end,2); -Flabel='\iota'; -elseif(iorq=='q') -F = 1./data.transform.fiota(1:end,2); -Flabel='q'; -end -nsucctrj = length(data.poincare.R(:,1,1)); % number of successfully followed trajectories - -switch xaxis - case 's' - plot(data.transform.fiota(1:nsucctrj,1),F(1:nsucctrj),'Marker',opt.Marker,... - 'MarkerSize',opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... - opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) - ylabel(Flabel) - out = cell(2); - out{1} = data.transform.fiota(:,1); - out{2} = F; - - case 'R' - plot(transpose(data.poincare.R(:,1,1)),F(1:nsucctrj),'Marker',opt.Marker,... - 'MarkerSize',opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... - opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) - ylabel(Flabel) - out = cell(2); - out{1} = data.poincare.R(:,1,1); - out{2} = F(1:nsucctrj); - - case 'f' - sval = data.transform.fiota(1:nsucctrj,1); - nvol = data.input.physics.Nvol; - mvol = data.output.Mvol; - nptrj = zeros(1,mvol); - count = 1; - - ind = find(sval==-2); %Remove wrongly written data - sval(ind) = []; - F(ind) = []; - nsucctrj = nsucctrj - length(ind); - - for is=1:length(sval)-1 - if(sval(is)>0 && sval(is+1)<0) %Reached the end of a volume - if(count==1) - nptrj(count) = is; - else - nptrj(count) = is-sum(nptrj); + if(iorq=='i') + F = data.transform.fiota(1:end,2); + Flabel='\iota'; + elseif(iorq=='q') + F = 1./data.transform.fiota(1:end,2); + Flabel='q'; end - count = count+1; - end - end - nptrj(mvol) = length(sval)-sum(nptrj); - - ns = 32; - nt = 32; - cumflux = 0; - kstart = 1; - psitor = zeros(1,length(sval)); - - - for lvol=1:mvol - - if lvol==nvol % Required if last value had a -2 (often in free bound) - phiedge = cumflux + get_spec_torflux(data, nvol, 0, -1, 1, ns, nt); + + nsucctrj = length(data.poincare.R(:,1,1)); % number of successfully followed trajectories + + switch xaxis + case 's' + plot(data.transform.fiota(1:nsucctrj,1),F(1:nsucctrj),'Marker',opt.Marker,... + 'MarkerSize',opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... + opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) + ylabel(Flabel) + out = cell(2); + out{1} = data.transform.fiota(:,1); + out{2} = F; + + case 'R' + plot(transpose(data.poincare.R(:,1,1)),F(1:nsucctrj),'Marker',opt.Marker,... + 'MarkerSize',opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... + opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) + ylabel(Flabel) + out = cell(2); + out{1} = data.poincare.R(:,1,1); + out{2} = F(1:nsucctrj); + + case 'f' + sval = data.transform.fiota(1:nsucctrj,1); + nvol = data.input.physics.Nvol; + mvol = data.output.Mvol; + nptrj = zeros(1,mvol); + count = 1; + + ind = find(sval==-2); %Remove wrongly written data + sval(ind) = []; + F(ind) = []; + nsucctrj = nsucctrj - length(ind); + + for is=1:length(sval)-1 + if(sval(is)>0 && sval(is+1)<0) %Reached the end of a volume + if(count==1) + nptrj(count) = is; + else + nptrj(count) = is-sum(nptrj); + end + count = count+1; + end end - - for k=kstart:kstart-1+nptrj(lvol) - psitor(k) = cumflux + get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); + nptrj(mvol) = length(sval)-sum(nptrj); + + ns = 32; + nt = 32; + cumflux = 0; + kstart = 1; + psitor = zeros(1,length(sval)); + + + for lvol=1:mvol + + if lvol==nvol % Required if last value had a -2 (often in free bound) + phiedge = cumflux + get_spec_torflux(data, nvol, 0, -1, 1, ns, nt); + end + + for k=kstart:kstart-1+nptrj(lvol) + psitor(k) = cumflux + get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); + end + cumflux = psitor(k); + kstart = kstart+nptrj(lvol); end - cumflux = psitor(k); - kstart = kstart+nptrj(lvol); - end - - plot(psitor/phiedge,F(1:nsucctrj),'Marker',opt.Marker,'MarkerSize',opt.MarkerSize,... - 'LineWidth',opt.LineWidth,'MarkerEdgeColor',opt.Color,... - 'LineStyle',opt.LineStyle,'Color',opt.Color) - ylabel(Flabel) - xlabel('\Psi / \Psi_{edge}') - - out = cell(2); - out{1} = psitor/psitor(end); - out{2} = F(1:nsucctrj); - -case 'r' - sval = data.transform.fiota(1:nsucctrj,1); - nvol = data.input.physics.Nvol; - mvol = data.output.Mvol; - nptrj = zeros(1,nvol); - count = 1; - - ind = find(sval==-2); %Remove wrongly written data - sval(ind) = []; - F(ind) = []; - nsucctrj = nsucctrj - length(ind); - - for is=1:length(sval)-1 - if(sval(is)>0 && sval(is+1)<0) - if(count==1) - nptrj(count) = is; - else - nptrj(count) = is-sum(nptrj); - end - count = count+1; - end - end - nptrj(mvol) = length(sval)-sum(nptrj); - - ns = 32; - nt = 32; - cumflux = 0; - kstart = 1; - psitor = zeros(1,length(sval)); - - for lvol=1:mvol - - if lvol==nvol % Required if last value had a -2 (often in free bound) - phiedge = cumflux + get_spec_torflux(data, nvol, 0, -1, 1, ns, nt); + + plot(psitor/phiedge,F(1:nsucctrj),'Marker',opt.Marker,'MarkerSize',opt.MarkerSize,... + 'LineWidth',opt.LineWidth,'MarkerEdgeColor',opt.Color,... + 'LineStyle',opt.LineStyle,'Color',opt.Color) + ylabel(Flabel) + xlabel('\Psi / \Psi_{edge}') + + out = cell(2); + out{1} = psitor/psitor(end); + out{2} = F(1:nsucctrj); + + case 'r' + sval = data.transform.fiota(1:nsucctrj,1); + nvol = data.input.physics.Nvol; + mvol = data.output.Mvol; + nptrj = zeros(1,nvol); + count = 1; + + ind = find(sval==-2); %Remove wrongly written data + sval(ind) = []; + F(ind) = []; + nsucctrj = nsucctrj - length(ind); + + for is=1:length(sval)-1 + if(sval(is)>0 && sval(is+1)<0) + if(count==1) + nptrj(count) = is; + else + nptrj(count) = is-sum(nptrj); + end + count = count+1; + end end - - for k=kstart:kstart-1+nptrj(lvol) - psitor(k) = cumflux + get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); + nptrj(mvol) = length(sval)-sum(nptrj); + + ns = 32; + nt = 32; + cumflux = 0; + kstart = 1; + psitor = zeros(1,length(sval)); + + for lvol=1:mvol + + start = -1; + if lvol==1 + start = -0.999; + end + + if lvol==nvol % Required if last value had a -2 (often in free bound) + phiedge = cumflux + get_spec_torflux(data, nvol, 0, start, 1 , ns, nt); + end + + for k=kstart:kstart-1+nptrj(lvol) + psitor(k) = cumflux + get_spec_torflux(data,lvol,0, start, sval(k),ns,nt); + end + cumflux = psitor(k); + kstart = kstart+nptrj(lvol); end - cumflux = psitor(k); - kstart = kstart+nptrj(lvol); - end - -% phiedge = data.input.physics.phiedge; - - plot(sqrt(psitor/phiedge),F(1:nsucctrj),'Marker',opt.Marker,'MarkerSize',... - opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... - opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) - ylabel(Flabel) - xlabel('(\Psi / \Psi_{edge})^{1/2}') - - out = cell(2); - out{1} = psitor/psitor(end); - out{2} = F(1:nsucctrj); - -end -set(gca,'FontSize',18) + % phiedge = data.input.physics.phiedge; + + plot(sqrt(psitor/phiedge),F(1:nsucctrj),'Marker',opt.Marker,'MarkerSize',... + opt.MarkerSize,'LineWidth',opt.LineWidth,'MarkerEdgeColor',... + opt.Color,'LineStyle',opt.LineStyle,'Color',opt.Color) + ylabel(Flabel) + xlabel('(\Psi / \Psi_{edge})^{1/2}') + + out = cell(2); + out{1} = psitor/psitor(end); + out{2} = F(1:nsucctrj); + + end + + set(gca,'FontSize',18) + +end diff --git a/Utilities/matlabtools/plot_spec_iotakam.m b/Utilities/matlabtools/plot_spec_iotakam.m index 52b78707..ba4793d3 100644 --- a/Utilities/matlabtools/plot_spec_iotakam.m +++ b/Utilities/matlabtools/plot_spec_iotakam.m @@ -8,70 +8,80 @@ function plot_spec_iotakam(data,iorq,xaxis,newfig) % % INPUT % ----- -% -data : produced by calling read_spec(fname) -% -iorq : plot iota('i') or safety factor ('q') -% -xaxis='R' : plots R-position of interfaces (at phi=0) as the x-axis -% -xaxis='f' : plots toroidal flux as the x-axis -% -xaxis='r' : plots sqrt(toroidal flux) as the x-axis -% -newfig : opens(=1) or not(=0) a new figure +% -data : produced by calling read_spec(fname) +% -iorq : plot iota('i') or safety factor ('q') +% -xaxis : 'R' plots R-position of interfaces (at phi=0) as the x-axis +% 'f' plots toroidal flux as the x-axis +% 'r' plots sqrt(toroidal flux) as the x-axis +% -newfig: opens(=1) or not(=0) a new figure % % written by J.Loizu (2017) + % Check input + if ~any(iorq==['i','q']) + error('InputError: invalid iorq') + end + if ~any(xaxis==['R','f','r']) + error('InputError: invalid xaxis') + end -Nvol = data.input.physics.Nvol; -tflux = data.input.physics.tflux; -iota = data.input.physics.iota; -oita = data.input.physics.oita; -Rmn = data.output.Rbc; -im = data.output.im; -in = data.output.in; -mn = data.output.mn; -freeb = data.input.physics.Lfreebound; + switch newfig + case 0 + hold on + case 1 + figure('Color','w') + hold on + case 2 + hold off + otherwise + error('InputError: invalid newfig') + end -R0 = zeros(1,Nvol); + Nvol = data.input.physics.Nvol; + tflux = data.input.physics.tflux; + iota = data.input.physics.iota; + oita = data.input.physics.oita; + Rmn = data.output.Rbc; + freeb = data.input.physics.Lfreebound; -for l=1:Nvol - R0(l) = sum(Rmn(:,l+1)); -end + R0 = zeros(1,Nvol); -switch newfig -case 0 - hold on -case 1 - figure -case 2 - hold off -end + for l=1:Nvol + R0(l) = sum(Rmn(:,l+1)); + end -if(iorq=='i') -F = iota(2:end); -G = oita(2:end); -Flabel='\iota'; -elseif(iorq=='q') -F = 1./iota(2:end); -G = 1./oita(2:end); -Flabel='q'; -end + + if(iorq=='i') + F = iota(2:end); + G = oita(2:end); + Flabel='\iota'; + elseif(iorq=='q') + F = 1./iota(2:end); + G = 1./oita(2:end); + Flabel='q'; + end -switch xaxis - case 'R' - plot(R0,F,'r+','MarkerSize',6,'LineWidth',2) - hold on; - plot(R0,G,'m+','MarkerSize',6,'LineWidth',2) - xlabel('R') - ylabel(Flabel) - case 'f' - plot(tflux(1:end-freeb),F,'r+','MarkerSize',6,'LineWidth',2) - hold on; - plot(tflux(1:end-freeb),G,'m+','MarkerSize',6,'LineWidth',2) - xlabel('\Psi / \Psi_{edge}') - ylabel(Flabel) - case 'r' - plot(sqrt(tflux(1:end-freeb)),F,'r+','MarkerSize',6,'LineWidth',2) - hold on; - plot(sqrt(tflux(1:end-freeb)),G,'m+','MarkerSize',6,'LineWidth',2) - xlabel('(\Psi / \Psi_{edge})^{1/2}') - ylabel(Flabel) + switch xaxis + case 'R' + plot(R0,F,'r+','MarkerSize',6,'LineWidth',2) + hold on; + plot(R0,G,'m+','MarkerSize',6,'LineWidth',2) + xlabel('R') + ylabel(Flabel) + case 'f' + plot(tflux(1:end-freeb),F,'r+','MarkerSize',6,'LineWidth',2) + hold on; + plot(tflux(1:end-freeb),G,'m+','MarkerSize',6,'LineWidth',2) + xlabel('\Psi / \Psi_{edge}') + ylabel(Flabel) + case 'r' + plot(sqrt(tflux(1:end-freeb)),F,'r+','MarkerSize',6,'LineWidth',2) + hold on; + plot(sqrt(tflux(1:end-freeb)),G,'m+','MarkerSize',6,'LineWidth',2) + xlabel('(\Psi / \Psi_{edge})^{1/2}') + ylabel(Flabel) + end + end diff --git a/Utilities/matlabtools/plot_spec_iterations.m b/Utilities/matlabtools/plot_spec_iterations.m index f23ef490..e249c211 100644 --- a/Utilities/matlabtools/plot_spec_iterations.m +++ b/Utilities/matlabtools/plot_spec_iterations.m @@ -1,35 +1,66 @@ function plot_spec_iterations( data, xl, yl ) -figure( 'Position', [200 200 900 700], 'Color', 'w' ) -fig = gcf; -ax = gca; -ax.Position = [0.1300 0.2386 0.7750 0.6864]; - - -Nfp = double(data.input.physics.Nfp); -Niter = size(data.iterations.iRbc); -Niter = Niter(3); - -sld_phi = uicontrol(fig, 'style', 'slider', 'Position', [200 25 500 20],'units','pixel', ... - 'Value',0,'Max',2*pi / Nfp,'Min',0); -sld_it = uicontrol(fig, 'style', 'slider', 'Position', [200 63 500 20],'units','pixel', ... - 'Value',1,'Max', Niter,'Min',1, 'SliderStep', [1/(Niter-1), 1/(Niter-1)]); - -el_phi = addlistener( sld_phi, 'ContinuousValueChange', @(sld_phi, event) updatePlot(sld_phi, sld_it, data, xl, yl) ); -el_it = addlistener( sld_it , 'ContinuousValueChange', @(sld_it , event) updatePlot(sld_phi, sld_it, data, xl, yl) ); - -plot_iteration( data, 1, 0, xl, yl ) +% PLOT_SPEC_ITERATIONS( DATA, XL, YL ) +% ==================================== +% +% Plot the volumes interfaces at any iteration of SPEC. Change the +% iteration using a slider +% +% INPUT +% ----- +% -DATA: Obtained from read_spec( filename ) +% -xl : xlimit +% -yl : ylimit +% +% OUTPUT +% ------ +% A magnificient plot! +% + + % Open figure + figure( 'Position', [200 200 900 700], 'Color', 'w' ) + fig = gcf; + ax = gca; + ax.Position = [0.1300 0.2386 0.7750 0.6864]; + + % Read size + Nfp = double(data.input.physics.Nfp); + [~, ~, Niter] = size(data.iterations.iRbc); -mytitle = sprintf('%s=%2.3f, iteration %05i', '\phi', 0, 1); -title(mytitle,'FontSize',18) + % Create some sliders for controling the iteration and the toroidal + % angle + sld_phi = uicontrol(fig, 'style', 'slider', 'Position', [200 25 500 20],'units','pixel', ... + 'Value',0,'Max',2*pi / Nfp,'Min',0); + sld_it = uicontrol(fig, 'style', 'slider', 'Position', [200 63 500 20],'units','pixel', ... + 'Value',1,'Max', Niter,'Min',1, 'SliderStep', [1/(Niter-1), 1/(Niter-1)]); + addlistener( sld_phi, 'ContinuousValueChange', @(sld_phi, event) updatePlot(sld_phi, sld_it, data, xl, yl) ); + addlistener( sld_it , 'ContinuousValueChange', @(sld_it , event) updatePlot(sld_phi, sld_it, data, xl, yl) ); + % Plot + plot_iteration( data, 1, 0, xl, yl ) + mytitle = sprintf('%s=%2.3f, iteration %05i', '\phi', 0, 1); + title(mytitle,'FontSize',18) end function updatePlot(sld_phi, sld_it, data, xl, yl) +% +% UPDATEPLOT( SLD_PHI, SLD_IT, DATA, XL, YL ) +% =========================================== +% +% Update plot when a slider value has changed +% +% INPUTS +% ------ +% -sld_phi: handle to toroidal angle slider +% -sld_it : handle to iteration slider +% -data : obtained from read_spec(filename) +% -xl : xlimit +% -yl : ylimit +% phi = sld_phi.Value; iter = round(sld_it.Value); @@ -42,11 +73,24 @@ function updatePlot(sld_phi, sld_it, data, xl, yl) function plot_iteration( data, iter, phi, xl, yl ) +% +% PLOT_ITERATION( DATA, ITER, PHI, XL, YL ) +% ========================================= +% +% Generate plot from SPEC data +% +% INPUTS +% ------ +% -data: obtained from read_spec( filename ) +% -iter: iteration number +% -phi : toroidal angle +% -xl : xlimit +% -yl : ylimit +% Nfp = double(data.input.physics.Nfp); - input.representation = 'hudson'; - input.im = double(data.output.im); - input.in = double(data.output.in) / Nfp; + im = double(data.output.im); + in = double(data.output.in) / Nfp; Mvol = double(data.output.Mvol); Ntor = double(data.input.physics.Ntor); @@ -66,10 +110,21 @@ function plot_iteration( data, iter, phi, xl, yl ) hold on % volume boundaries for ivol=2:Mvol+1 - input.Rmn = data.iterations.iRbc(:,ivol,iter); - input.Zmn = data.iterations.iZbs(:,ivol,iter); + Rmn = data.iterations.iRbc(:,ivol,iter); + Zmn = data.iterations.iZbs(:,ivol,iter); + + tarr = linspace( 0, 2*pi, 1024 ); + R = zeros(1,1024); + Z = zeros(1,1024); + for ii=1:length(Rmn) + arg = im(ii) * tarr - in(ii) * Nfp * phi; + R = R + Rmn(ii) * cos( arg ); + Z = Z + Zmn(ii) * sin( arg ); + end - plot_boundary_2d( input, 512, phi, Nfp, 0 ) + scatter( R, Z ) + hold on + axis equal end diff --git a/Utilities/matlabtools/plot_spec_jacobian.m b/Utilities/matlabtools/plot_spec_jacobian.m index b57b100f..7910d29c 100644 --- a/Utilities/matlabtools/plot_spec_jacobian.m +++ b/Utilities/matlabtools/plot_spec_jacobian.m @@ -23,32 +23,60 @@ % written by J.Loizu (2016) if(sarr=='d') -sarr=linspace(-1,1,64); + sarr=linspace(-1,1,64); end if(tarr=='d') -tarr=linspace(0,2*pi,64); + tarr=linspace(0,2*pi,64); end if(zarr=='d') -zarr=0; + zarr=0; end -% Check input -if (length(sarr)>1) && length(tarr)>1 && length(zarr)>1 - error('This is a 2d plotting routine; one input array has to be a scalar') +% Check inputs +if lvol<1 || lvol>data.output.Mvol + error('InputError: invalid lvol') +end + +if isempty(sarr) + error('InputError: sarr is empty') +end +if isempty(tarr) + error('InputError: tarr is empty') +end +if isempty(zarr) + error('InputError: zarr is empty') +end + +if sarr(1)<-1 || sarr(end)>1 + error('InputError: invalid sarr') +end + +if any(diff(sarr)<0) + error('InputError: sarr is not monotonic') end switch newfig case 0 hold on case 1 - figure + figure('Color','w','Position',[200 200 900 700]) hold on case 2 hold off + otherwise + error('InputError: invalid newfig') +end + + + +% Check input +if (length(sarr)>1) && length(tarr)>1 && length(zarr)>1 + error('This is a 2d plotting routine; one input array has to be a scalar') end + % Allocate memory rzbdata = cell(3); @@ -99,6 +127,8 @@ title('|B|'); xlabel('R'); ylabel('Z'); +set(gca, 'FontSize', 18) + % Output data diff --git a/Utilities/matlabtools/plot_spec_kam.m b/Utilities/matlabtools/plot_spec_kam.m index d9752e22..2148e8dc 100644 --- a/Utilities/matlabtools/plot_spec_kam.m +++ b/Utilities/matlabtools/plot_spec_kam.m @@ -13,114 +13,110 @@ function plot_spec_kam(data, nz0, newfig, varargin) % -newfig : opens(=1) or not(=0) a new figure, or overplots(=2) on existing figure % % written by J.Loizu (2016) -% upgraded by J.Loizu (07.2017) -% modified by A. Baillod (06.2019) -% modified by J.Loizu (01.2020) -l = length(varargin); -if mod(l,2)~=0 - error('Invalid number of argument') -end - -opt.InterfaceColor = 'r'; -for ii=1:l/2 - field = varargin{2*ii-1}; - value = varargin{2*ii }; - - opt.(field)=value; -end - -Np = double(data.input.physics.Nfp); -Ndiscrete = double(data.input.numerics.Ndiscrete); -Ntor = double(max(abs(data.output.in))); -Nplan = max(Ndiscrete*4*Ntor, 1) -zetaov2pi = (nz0-1) / (Nplan); -%zetaov2pi = 0; - -Nvol = double(data.input.physics.Nvol); -mn = data.output.mn; -im = data.output.im; -in = data.output.in; -Rbcmn = data.output.Rbc; -Rbsmn = data.output.Rbs; -Zbcmn = data.output.Zbc; -Zbsmn = data.output.Zbs; -Igeometry = data.input.physics.Igeometry; -try - rpol = data.input.physics.rpol; -catch - rpol = 1; -end - -% Compute (x,y) coordinates of each KAM surface - -zeta = zetaov2pi*(2*pi); - -nth = 2048; -dth = 2*pi/nth; -theta = dth:dth:2*pi; - -X = zeros(Nvol,nth); -Y = zeros(Nvol,nth); - - -switch Igeometry - case 1 - X = zeros(Nvol+1,nth); - Y = zeros(Nvol+1,nth); - for i=1:Nvol+1 - X(i,:) = rpol*theta; - for k=1:mn - alpha = double(im(k))*theta-double(in(k))*zeta; - Y(i,:) = Y(i,:) + Rbcmn(k,i)*cos(alpha) + Rbsmn(k,i)*sin(alpha); + + % Check inputs + switch newfig + case 0 + hold on + case 1 + figure + hold on + case 2 + hold off + otherwise + error('InputError: invalid newfig') + end + + + l = length(varargin); + if mod(l,2)~=0 + error('InputError: Invalid number of argument') + end + + opt.InterfaceColor = 'r'; + for ii=1:l/2 + field = varargin{2*ii-1}; + value = varargin{2*ii }; + + opt.(field)=value; + end + + Ndiscrete = double(data.input.numerics.Ndiscrete); + Ntor = double(max(abs(data.output.in))); + Nplan = max(Ndiscrete*4*Ntor, 1); + zeta = 2*pi*(nz0-1) / (Nplan); + + Nvol = double(data.input.physics.Nvol); + mn = data.output.mn; + im = data.output.im; + in = data.output.in; + Rbcmn = data.output.Rbc; + Rbsmn = data.output.Rbs; + Zbcmn = data.output.Zbc; + Zbsmn = data.output.Zbs; + Igeometry = data.input.physics.Igeometry; + try + rpol = data.input.physics.rpol; + catch + rpol = 1; + end + + % Compute (x,y) coordinates of each KAM surface + nth = 2048; + dth = 2*pi/nth; + theta = dth:dth:2*pi; + + X = zeros(Nvol,nth); + Y = zeros(Nvol,nth); + + + switch Igeometry + case 1 + X = zeros(Nvol+1,nth); + Y = zeros(Nvol+1,nth); + for i=1:Nvol+1 + X(i,:) = rpol*theta; + for k=1:mn + alpha = double(im(k))*theta-double(in(k))*zeta; + Y(i,:) = Y(i,:) + Rbcmn(k,i)*cos(alpha) + Rbsmn(k,i)*sin(alpha); + end end - end - case 2 - for i=1:Nvol - for k=1:mn - alpha = double(im(k))*theta-double(in(k))*zeta; - X(i,:) = X(i,:) + (Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha)).*cos(theta); - Y(i,:) = Y(i,:) + (Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha)).*sin(theta); + case 2 + for i=1:Nvol + for k=1:mn + alpha = double(im(k))*theta-double(in(k))*zeta; + X(i,:) = X(i,:) + (Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha)).*cos(theta); + Y(i,:) = Y(i,:) + (Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha)).*sin(theta); + end end - end - case 3 - for i=1:Nvol - for k=1:mn - alpha = double(im(k))*theta-double(in(k))*zeta; - X(i,:) = X(i,:) + Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha); - Y(i,:) = Y(i,:) + Zbsmn(k,i+1)*sin(alpha) + Zbcmn(k,i+1)*cos(alpha); + case 3 + for i=1:Nvol + for k=1:mn + alpha = double(im(k))*theta-double(in(k))*zeta; + X(i,:) = X(i,:) + Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha); + Y(i,:) = Y(i,:) + Zbsmn(k,i+1)*sin(alpha) + Zbcmn(k,i+1)*cos(alpha); + end end - end - otherwise - error('Unsupported geometry') -end - - -% Plot Poincare section - -switch newfig - case 0 - hold on - case 1 - figure - hold on - case 2 - hold off -end - - -for i=1:size(X,1) - scatter(X(i,:),Y(i,:),3,'filled','MarkerFaceColor',opt.InterfaceColor,'MarkerEdgeColor',opt.InterfaceColor) - hold on -end - -hold on -set(gca,'FontSize',12) - -if Igeometry~=1 - axis equal - xlabel('R','FontSize',12) - ylabel('Z','FontSize',12) -else - xlabel('\theta r_{pol}','FontSize',12) - ylabel('R','FontSize',12) -end + otherwise + error('Unsupported geometry') + end + + + % Plot Poincare section + for i=1:size(X,1) + scatter(X(i,:),Y(i,:),3,'filled','MarkerFaceColor',opt.InterfaceColor,'MarkerEdgeColor',opt.InterfaceColor) + hold on + end + + hold on + set(gca,'FontSize',12) + + if Igeometry~=1 + axis equal + xlabel('R','FontSize',12) + ylabel('Z','FontSize',12) + else + xlabel('\theta r_{pol}','FontSize',12) + ylabel('R','FontSize',12) + end +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_modB.m b/Utilities/matlabtools/plot_spec_modB.m index e68613cf..4870ae35 100644 --- a/Utilities/matlabtools/plot_spec_modB.m +++ b/Utilities/matlabtools/plot_spec_modB.m @@ -4,7 +4,7 @@ % PLOT_SPEC_MODB( DATA, LVOL, SARR, TARR, ZARR, NEWFIG ) % ====================================================== % -% Produces plot of |B| in (R,Z,zarr) cross-section(s) +% Produces plot of |B| in (R,Z) cross-section(s), for any toroidal angle % % INPUT % ----- @@ -14,7 +14,7 @@ % -tarr : is the array of values for the theta-coordinate ('d' for default) % -zarr : is the array of values for the zeta-coordinate ('d' for default) % -newfig : opens(=1) or not(=0) a new figure, or overwrite existing one -% (=2) +% (=2) % % OUTPUT % ------ @@ -22,75 +22,102 @@ % % written by J.Loizu (2016) -if(sarr=='d') -sarr=linspace(-1,1,64); -end - -if(tarr=='d') -tarr=linspace(0,2*pi,64); -end - -if(zarr=='d') -zarr=0; -end - -rzbdata = cell(3); - - -% Compute |B| - -modB = get_spec_modB(data,lvol,sarr,tarr,zarr); - -% Compute function (R,Z)(s,theta,zeta) -R = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'R'); -Z = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'Z'); - -R = R{1}; -Z = Z{1}; - -% Plot + % Default inputs + if(sarr=='d') + sarr=linspace(-1,1,64); + end + + if(tarr=='d') + tarr=linspace(0,2*pi,64); + end + + if(zarr=='d') + zarr=0; + end + + % Check inputs + Mvol = data.output.Mvol; + if lvol<1 || lvol>Mvol + error('InputError: invalid lvol') + end + + if isempty(sarr) + error('InputError: sarr is empty') + end + if isempty(tarr) + error('InputError: tarr is empty') + end + if isempty(zarr) + error('InputError: zarr is empty') + end + + if sarr(1)<-1 || sarr(end)>1 + error('InputError: invalid sarr') + end + + if any(diff(sarr)<0) + error('InputError: sarr is not monotonic') + end + + + rzbdata = cell(3); + + + % Compute |B| + + modB = get_spec_modB(data,lvol,sarr,tarr,zarr); + + % Compute function (R,Z)(s,theta,zeta) + R = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'R'); + Z = get_spec_R_derivatives(data,lvol,sarr,tarr,zarr,'Z'); + + R = R{1}; + Z = Z{1}; + + % Plot + Rtemp = R; + Ztemp = Z; + switch data.input.physics.Igeometry + case 1 + R = tarr; + Z = Rtemp; + case 2 + for it=1:length(tarr) + R(:,it,:) = Rtemp(:,it,:) .* cos(tarr(it)); + Z(:,it,:) = Rtemp(:,it,:) .* sin(tarr(it)); + end + case 3 + R = Rtemp; + Z = Ztemp; + end + + + for iz=1:length(zarr) + switch newfig + case 0 + hold on + case 1 + figure + hold on + case 2 + hold off + otherwise + error('InputError: Invalid newfig') + end -switch newfig - case 0 + pcolor(R(:,:,iz),Z(:,:,iz),modB(:,:,iz)); shading interp; colorbar hold on - case 1 - figure - hold on - case 2 - hold off -end -Rtemp = R; -Ztemp = Z; -switch data.input.physics.Igeometry - case 1 - R = tarr; - Z = Rtemp; - case 2 - for it=1:length(tarr) - R(:,it,:) = Rtemp(:,it,:) .* cos(tarr(it)); - Z(:,it,:) = Rtemp(:,it,:) .* sin(tarr(it)); - end - case 3 - R = Rtemp; - Z = Ztemp; -end - + axis equal + title('|B|'); + xlabel('R'); + ylabel('Z'); + end -for iz=1:length(zarr) - - pcolor(R(:,:,iz),Z(:,:,iz),modB(:,:,iz)); shading interp; colorbar - hold on + % Output data - axis equal - title('|B|'); - xlabel('R'); - ylabel('Z'); + rzbdata{1} = R; + rzbdata{2} = Z; + rzbdata{3} = modB; end -% Output data - -rzbdata{1} = R; -rzbdata{2} = Z; -rzbdata{3} = modB; - diff --git a/Utilities/matlabtools/plot_spec_modB_boundary.m b/Utilities/matlabtools/plot_spec_modB_boundary.m index 572609b9..5a7c1543 100644 --- a/Utilities/matlabtools/plot_spec_modB_boundary.m +++ b/Utilities/matlabtools/plot_spec_modB_boundary.m @@ -1,15 +1,15 @@ function plot_spec_modB_boundary(data,interface,innout,nt,nz,dimension) % -% PLOT_SPEC_MODB_BOUNDARY( DATA, VOL, NT, NZ ) -% ============================================ +% PLOT_SPEC_MODB_BOUNDARY( DATA, INTERFACE, INNOUT, NT, NZ, DIMENSION ) +% ===================================================================== % % Produces plot of |B| on the full boundary surface in toroidal geometry. % % INPUT % ----- % -data : data obtained via read_spec(filename) -% -interface : Volume on which modB should be plotted +% -interface : Interface on which modB should be plotted % -innout: (0) - inner side of interface % (1) - outer side of interface % -nt : poloidal resolution for the plotting (e.g. nt=64) @@ -20,98 +20,108 @@ function plot_spec_modB_boundary(data,interface,innout,nt,nz,dimension) % written by J.Loizu (2016) % modified by J.Loizu (01.2017) -Mvol = data.output.Mvol; + Mvol = data.output.Mvol; + if interface<1 || interface>Mvol + error('InputError: invalid interface') + end -if interface<1 || interface>Mvol - error('Invalid interface') -end + switch innout + case 0 + vol = interface; + sarr = 1; + case 1 + if interface==Mvol + error('InputError: Cannot plot on the outer side of last interface!') + end + vol = interface+1; + sarr = -1; + otherwise + error('InputError: interface should be 0 or 1') + end -switch innout - case 0 - vol = interface; - sarr = 1; - case 1 - if interface==Mvol - error('Cannot plot on the outer side of last interface!') - end - vol = interface+1; - sarr = -1; - otherwise - error('Interface should be 0 or 1') -end + if nt<1 + error('InputError: invalid nt') + end + if nz<1 + error('InputError: invalid nz') + end + if ~any(dimension==[2,3]) + error('InputError: invalid dimension') + end -tarr = linspace(0,2*pi,nt); -zarr = linspace(0,2*pi,nz); + tarr = linspace(0,2*pi,nt); + zarr = linspace(0,2*pi,nz); -if(vol>Mvol || vol<1) - error('vol not valid') -end + if(vol>Mvol || vol<1) + error('vol not valid') + end + + + % Compute |B| + + modB = get_spec_modB(data,vol,sarr,tarr,zarr); + + switch dimension + case 2 + figure + + [t,z] = meshgrid(tarr, zarr); + + modB = reshape(modB, nt, nz); + + pcolor( z, t, modB' ) + shading interp + + colorbar + xlabel('$\phi$', 'Interpreter', 'latex') + ylabel('$\theta$', 'Interpreter', 'latex') + + ax = gca; + ax.YTick = [pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4]; + ax.YTickLabel = {'$\frac{\pi}{4}$','$\frac{\pi}{2}$','$\frac{3\pi}{4}$','$\pi$','$\frac{5\pi}{4}$', '$\frac{3\pi}{2}$','$\frac{7\pi}{4}$'}; + ax.XTick = [pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4]; + ax.XTickLabel = {'$\frac{\pi}{4}$','$\frac{\pi}{2}$','$\frac{3\pi}{4}$','$\pi$','$\frac{5\pi}{4}$', '$\frac{3\pi}{2}$','$\frac{7\pi}{4}$'}; + ax.TickLabelInterpreter = 'latex'; + + set(gca,'FontSize',18) + set(gcf,'Position',[200 200 900 700]) + + + case 3 + % Compute function (R,Z)(s,theta,zeta) + R = get_spec_R_derivatives(data,vol,sarr,tarr,zarr,'R'); + Z = get_spec_R_derivatives(data,vol,sarr,tarr,zarr,'Z'); + + R = squeeze(R{1}); + Z = squeeze(Z{1}); + + + % Construct cartesian corrdinates + + X = zeros(nt,nz); + + Y = zeros(nt,nz); + + for it=1:nt + for iz=1:nz + X(it,iz) = R(it,iz)*cos(zarr(iz)); + Y(it,iz) = R(it,iz)*sin(zarr(iz)); + end + end + + + % Plot + + figure + + h=surf(X,Y,Z,squeeze(modB(1,:,:))); + axis equal + shading interp + colorbar + title('| B |') -% Compute |B| - -modB = get_spec_modB(data,vol,sarr,tarr,zarr); - -switch dimension - case 2 - figure - - [t,z] = meshgrid(tarr, zarr); - - modB = reshape(modB, nt, nz); - - pcolor( z, t, modB' ) - shading interp - - colorbar - xlabel('$\phi$', 'Interpreter', 'latex') - ylabel('$\theta$', 'Interpreter', 'latex') - - ax = gca; - ax.YTick = [pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4]; - ax.YTickLabel = {'$\frac{\pi}{4}$','$\frac{\pi}{2}$','$\frac{3\pi}{4}$','$\pi$','$\frac{5\pi}{4}$', '$\frac{3\pi}{2}$','$\frac{7\pi}{4}$'}; - ax.XTick = [pi/4,pi/2,3*pi/4,pi,5*pi/4,3*pi/2,7*pi/4]; - ax.XTickLabel = {'$\frac{\pi}{4}$','$\frac{\pi}{2}$','$\frac{3\pi}{4}$','$\pi$','$\frac{5\pi}{4}$', '$\frac{3\pi}{2}$','$\frac{7\pi}{4}$'}; - ax.TickLabelInterpreter = 'latex'; - - set(gca,'FontSize',18) - set(gcf,'Position',[200 200 900 700]) - - - case 3 - % Compute function (R,Z)(s,theta,zeta) - R = get_spec_R_derivatives(data,vol,sarr,tarr,zarr,'R'); - Z = get_spec_R_derivatives(data,vol,sarr,tarr,zarr,'Z'); - - R = squeeze(R{1}); - Z = squeeze(Z{1}); - - - % Construct cartesian corrdinates - - X = zeros(nt,nz); - - Y = zeros(nt,nz); - - for it=1:nt - for iz=1:nz - X(it,iz) = R(it,iz)*cos(zarr(iz)); - Y(it,iz) = R(it,iz)*sin(zarr(iz)); - end - end - - - % Plot - - figure - - h=surf(X,Y,Z,squeeze(modB(1,:,:))); - - axis equal - shading interp - colorbar - title('| B |') - - otherwise - error('Invalid dimension') + otherwise + error('Invalid dimension') + end end diff --git a/Utilities/matlabtools/plot_spec_poincare.m b/Utilities/matlabtools/plot_spec_poincare.m index 8470c604..c3f8f567 100644 --- a/Utilities/matlabtools/plot_spec_poincare.m +++ b/Utilities/matlabtools/plot_spec_poincare.m @@ -19,33 +19,37 @@ % modified by A.Baillod (2019) % modified by J.Loizu (2020) -opt.BoundaryColor = 'r'; -opt.CBColor = 'k'; -opt.step = 1; - ll = length(varargin); if mod(ll,2)~=0 - error('Invalid number of arguments') + error('InputError: invalid number of optional arguments') end +opt.BoundaryColor = 'r'; +opt.CBColor = 'k'; +opt.step = 1; for ii=1:ll/2 opt.(varargin{2*ii-1}) = varargin{2*ii}; end stp = opt.step; +% Read some data... nfp = data.input.physics.Nfp; -try - rpol = data.input.physics.rpol; % get size of slab -catch - rpol = 1; +if data.input.physics.Igeometry==1 + try + rpol = data.input.physics.rpol; % get size of slab + catch + rpol = 1; + end end +% Read size nptraj = size(data.poincare.R,1); % # of poincare trajectories (field lines) - nz = size(data.poincare.R,2); % # of toroidal planes +if nz0<1 || nz0>nz + error('InputError: invalid toroidal plane. Should be 0nptraj); if ~isempty(ind) @@ -56,54 +60,14 @@ arr = 1:arr:nptraj; end - - -disp(' '); -disp('Number of toroidal planes available: (one field period)'); -nz -disp(' '); - - -rmax = max(max(max(data.poincare.R(:,nz0,:)))); -rmin = min(min(min(data.poincare.R(:,nz0,:)))); -zmax = max(max(max(data.poincare.Z(:,nz0,:)))); -zmin = min(min(min(data.poincare.Z(:,nz0,:)))); - -switch data.input.physics.Igeometry - case 1 - xmin = 0; - xmax = 2*pi*rpol; - ymin = -0.1; - ymax = data.output.Rbc(1,end)+0.1; - case 2 - xmin = -1.1*rmax; - xmax = 1.1*rmax; - ymin = -1.1*rmax; - ymax = 1.1*rmax; - case 3 - xmin = 0.99*rmin; - xmax = 1.01*rmax; - dz = zmax-zmin; - ymin = zmin - 0.05*dz; - ymax = zmax + 0.05*dz; -end - - -nth = 5096; %ploting options for the boundary +%ploting options for the boundary +nth = 5096; bcol = opt.BoundaryColor; bthick = 3; lthick = 1; if(data.input.physics.Lfreebound==1) -bcol = opt.CBColor; -bthick = 1; -end - - - -if(flag2col=='T') - pcol = ['k' 'b']; -else - pcol = ['k' 'k']; + bcol = opt.CBColor; + bthick = 1; end switch newfig @@ -114,6 +78,8 @@ hold on case 2 hold off + otherwise + error('InputError: invalid newfig') end switch nz0 @@ -157,7 +123,7 @@ dth = 2*pi/nth; theta = dth:dth:2*pi; - zeta = (j-1)*(2*pi/nz)/nfp + zeta = (j-1)*(2*pi/nz)/nfp; phi = NaN; switch data.input.physics.Igeometry @@ -206,9 +172,6 @@ ylabel('R','FontSize',12) end -% xlim([xmin xmax]) -% ylim([ymin ymax]) - end otherwise %if nz0>0 @@ -242,7 +205,7 @@ dth = 2*pi/nth; theta = dth:dth:2*pi; - zeta = (nz0-1.0)*(2.0*pi/nz)/double(nfp) + zeta = (nz0-1.0)*(2.0*pi/nz)/double(nfp); phi = zeta; @@ -292,9 +255,6 @@ ylabel('R','FontSize',12) end -% xlim([xmin xmax]) -% ylim([ymin ymax]) - set(gca,'FontSize',18) end diff --git a/Utilities/matlabtools/plot_spec_poincare_3d.m b/Utilities/matlabtools/plot_spec_poincare_3d.m index 1ce38175..90f58483 100644 --- a/Utilities/matlabtools/plot_spec_poincare_3d.m +++ b/Utilities/matlabtools/plot_spec_poincare_3d.m @@ -14,164 +14,161 @@ function plot_spec_poincare_3d( data, varargin ) % 'nz': Number of toroidal points. Default is 64 % 'phiend': Plots 3d shape from phi=0 to phiend. Default is 2pi/Nfp % 'tstart': Start field line tracing at this value of theta. Can be -% and array. Default is 0. +% an array. Default is 0. -% Load the colors and some data -col = EPFL_colors; -Nvol = double(data.input.physics.Nvol); -Nfp = double(data.input.physics.Nfp); + % Load the colors and some data + col = EPFL_colors; + Nvol = double(data.input.physics.Nvol); + Nfp = double(data.input.physics.Nfp); -% Set up options -opt.nt = 64; -opt.nz = 64; -opt.phiend = 2*pi / max(Nfp,2); -opt.tstart = 0; + % Set up options + opt.nt = 64; + opt.nz = 64; + opt.phiend = 2*pi / max(Nfp,2); + opt.tstart = 0; -l = length(varargin); -if mod(l,2)~=0 - error('Invalid number of arguments') -end - -for ii=1:l/2 - opt.(varargin{2*ii-1}) = varargin{2*ii}; -end + l = length(varargin); + if mod(l,2)~=0 + error('Invalid number of arguments') + end -opt.tstart = reshape(opt.tstart, length(opt.tstart), 1); + for ii=1:l/2 + opt.(varargin{2*ii-1}) = varargin{2*ii}; + end -% Define coordinate arrays in real space -sarr = 1; % We plot on the outermost surface, i.e. the plasma boundary -tarr = linspace(0,2*pi ,opt.nt); -zarr = linspace(0,opt.phiend ,opt.nz); + opt.tstart = reshape(opt.tstart, length(opt.tstart), 1); -R = get_spec_R_derivatives(data,Nvol,sarr,tarr,zarr,'R'); -Z = get_spec_R_derivatives(data,Nvol,sarr,tarr,zarr,'Z'); + % Define coordinate arrays in real space + sarr = 1; % We plot on the outermost surface, i.e. the plasma boundary + tarr = linspace(0,2*pi ,opt.nt); + zarr = linspace(0,opt.phiend ,opt.nz); -R = squeeze(R{1}); -Z = squeeze(Z{1}); + R = get_spec_R_derivatives(data,Nvol,sarr,tarr,zarr,'R'); + Z = get_spec_R_derivatives(data,Nvol,sarr,tarr,zarr,'Z'); + R = squeeze(R{1}); + Z = squeeze(Z{1}); -% Construct cartesian corrdinates -X = zeros(opt.nt,opt.nz); -Y = zeros(opt.nt,opt.nz); + % Construct cartesian corrdinates -for it=1:opt.nt - for iz=1:opt.nz - X(it,iz) = R(it,iz)*cos(zarr(iz)); - Y(it,iz) = R(it,iz)*sin(zarr(iz)); - end -end + X = zeros(opt.nt,opt.nz); + Y = zeros(opt.nt,opt.nz); + for it=1:opt.nt + for iz=1:opt.nz + X(it,iz) = R(it,iz)*cos(zarr(iz)); + Y(it,iz) = R(it,iz)*sin(zarr(iz)); + end + end -% Plot -figure('Position', [200 200 900 700], 'Color', 'w') + % Plot -s = size(X); -c = zeros(s(1), s(2), 3); -c(:,:,1) = 1; -mesh(X,Y,Z,c); -hold on + figure('Position', [200 200 900 700], 'Color', 'w') -axis equal -shading interp + s = size(X); + c = zeros(s(1), s(2), 3); + c(:,:,1) = 1; + mesh(X,Y,Z,c); + hold on -xlabel('X') -ylabel('Y') -zlabel('Z') -set(gca, 'FontSize', 18 ) + axis equal + shading interp -% Add white surface on plane y=0 -M = makehgtform('xrotate',pi/2); -t = hgtransform('Matrix', M); + xlabel('X') + ylabel('Y') + zlabel('Z') + set(gca, 'FontSize', 18 ) -pshape = polyshape(X(:,1), Z(:,1)); -plot(pshape, 'Parent', t, 'FaceColor', 'w', 'FaceAlpha', 0.9 ) + % Add white surface on plane y=0 + M = makehgtform('xrotate',pi/2); + t = hgtransform('Matrix', M); + pshape = polyshape(X(:,1), Z(:,1)); + plot(pshape, 'Parent', t, 'FaceColor', 'w', 'FaceAlpha', 0.9 ) -% Add Poincare plot -X = squeeze(data.poincare.R(:,1,:)); -s = size(X); + % Add Poincare plot + X = squeeze(data.poincare.R(:,1,:)); -Y = zeros(size(X)); -Z = squeeze(data.poincare.Z(:,1,:)); -for i=1:s(1) %for each field line trajectory - scatter3(X(i,:),Y(i,:),Z(i,:),10,'.k') - hold on; -end + s = size(X); -% Add KAM surfaces -mn = data.output.mn; -im = data.output.im; -Rbcmn = data.output.Rbc; -Rbsmn = data.output.Rbs; -Zbcmn = data.output.Zbc; -Zbsmn = data.output.Zbs; + Y = zeros(size(X)); + Z = squeeze(data.poincare.Z(:,1,:)); + for i=1:s(1) %for each field line trajectory + scatter3(X(i,:),Y(i,:),Z(i,:),10,'.k') + hold on; + end -nt = 1024; -tarr = linspace(0, 2*pi, nt); + % Add KAM surfaces + mn = data.output.mn; + im = data.output.im; + Rbcmn = data.output.Rbc; + Rbsmn = data.output.Rbs; + Zbcmn = data.output.Zbc; + Zbsmn = data.output.Zbs; + + nt = 1024; + tarr = linspace(0, 2*pi, nt); + + X = zeros(Nvol,nt); + Y = zeros(Nvol,nt); + for i=1:Nvol + for k=1:mn + alpha = double(im(k))*tarr; %phi = 0 + X(i,:) = X(i,:) + Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha); + Y(i,:) = Y(i,:) + Zbsmn(k,i+1)*sin(alpha) + Zbcmn(k,i+1)*cos(alpha); + end + end -X = zeros(Nvol,nt); -Y = zeros(Nvol,nt); -for i=1:Nvol - for k=1:mn - alpha = double(im(k))*tarr; %phi = 0 - X(i,:) = X(i,:) + Rbcmn(k,i+1)*cos(alpha) + Rbsmn(k,i+1)*sin(alpha); - Y(i,:) = Y(i,:) + Zbsmn(k,i+1)*sin(alpha) + Zbcmn(k,i+1)*cos(alpha); + for i=1:size(X,1) + scatter3(X(i,:),zeros(nt,1),Y(i,:),3,'filled','MarkerFaceColor','r','MarkerEdgeColor','r') + hold on end -end -for i=1:size(X,1) - scatter3(X(i,:),zeros(nt,1),Y(i,:),3,'filled','MarkerFaceColor','r','MarkerEdgeColor','r') - hold on -end + % Add a field line + tarr = opt.tstart; -% Add a field line -tarr = opt.tstart; + if ~isempty(tarr) + phi = 0; -if ~isempty(tarr) - phi = 0; + nstep = 1024; + dstep = opt.phiend/1024; - nstep = 1024; - dstep = opt.phiend/1024; + for istep=1:nstep + phi(istep+1) = phi(istep) + dstep; - for istep=1:nstep - phi(istep+1) = phi(istep) + dstep; + B = get_spec_magfield( data, Nvol, 1, tarr(:,istep), phi(istep) ); - B = get_spec_magfield( data, Nvol, 1, tarr(:,istep), phi(istep) ); + Bt = reshape(B{2}, length(B{2}), 1); + Bz = reshape(B{3}, length(B{2}), 1); - Bt = reshape(B{2}, length(B{2}), 1); - Bz = reshape(B{3}, length(B{2}), 1); + tarr(:,istep+1) = tarr(:,istep) + Bt./Bz * dstep; - tarr(:,istep+1) = tarr(:,istep) + Bt./Bz * dstep; + end - end + nline = length(opt.tstart); + for jj=1:nline + X = []; + Y = []; + Z = []; + for ii = 1:nstep + Rd = get_spec_R_derivatives(data,Nvol,sarr,tarr(jj,ii),phi(ii),'R'); + Zd = get_spec_R_derivatives(data,Nvol,sarr,tarr(jj,ii),phi(ii),'Z'); - X = []; - Y = []; - Z = []; - for ii = 1:nstep - Rd = get_spec_R_derivatives(data,Nvol,sarr,tarr(ii),phi(ii),'R'); - Zd = get_spec_R_derivatives(data,Nvol,sarr,tarr(ii),phi(ii),'Z'); + X(ii) = squeeze(Rd{1}) * cos(phi(ii)); + Y(ii) = squeeze(Rd{1}) * sin(phi(ii)); + Z(ii) = squeeze(Zd{1}); + end - X(ii) = squeeze(Rd{1}) * cos(phi(ii)); - Y(ii) = squeeze(Rd{1}) * sin(phi(ii)); - Z(ii) = squeeze(Zd{1}); + scatter3( X, Y, Z, 10, 'MarkerFaceColor', col.Leman, 'MarkerEdgeColor', col.Leman) + end end - scatter3( X, Y, Z, 10, 'MarkerFaceColor', col.Leman, 'MarkerEdgeColor', col.Leman) -end - - - - - - - end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_polflux.m b/Utilities/matlabtools/plot_spec_polflux.m index 7c27e984..26280b48 100644 --- a/Utilities/matlabtools/plot_spec_polflux.m +++ b/Utilities/matlabtools/plot_spec_polflux.m @@ -1,4 +1,4 @@ -function plot_spec_polflux(data, zeta, cumulative, newfig) +function plot_spec_polflux(data, theta, cumulative, newfig) % % % PLOT_SPEC_POLFLUX( FILENAME, ZETA, CUMULATIVE, NEWFIG ) @@ -10,7 +10,7 @@ function plot_spec_polflux(data, zeta, cumulative, newfig) % INPUTS % ------ % data: data obtained from read_spec(filename); -% zeta: Toroidal angle +% theta: Poloidal angle % cumulative: True to get cumulative plot (\psi_a = \int_0^a B_\phi dS) % or False to get a non-cumulative plot (\psi_a = % \int_{a-1}^a B_\phi dS) @@ -24,45 +24,45 @@ function plot_spec_polflux(data, zeta, cumulative, newfig) % % -Nvol = data.input.physics.Nvol; + Nvol = data.input.physics.Nvol; -polflux = zeros(1,Nvol); + polflux = zeros(1,Nvol); -% Start at one only if slab geometry (otherwise it is zero by definition) -sarr = linspace(-1, 1, 64); -if data.input.physics.Igeometry==1 - polflux(1) = get_spec_polflux(data,1,zeta,sarr,64); -end + % Start at one only if slab geometry (otherwise it is zero by definition) + sarr = linspace(-1, 1, 64); + if data.input.physics.Igeometry==1 + polflux(1) = get_spec_polflux(data,1,theta,sarr,64); + end + + for lvol=2:Nvol + tmp = get_spec_polflux(data,lvol,theta,sarr,64); + + if cumulative + polflux(lvol) = polflux(lvol-1) + tmp; + else + polflux(lvol)=tmp; + end -for lvol=2:Nvol - tmp = get_spec_polflux(data,lvol,zeta,-1,1,64,64); - - if cumulative - polflux(lvol) = polflux(lvol-1) + tmp; - else - polflux(lvol)=tmp; end - -end -switch newfig - case 0 - hold on; - case 1 - figure - hold on; - case 2 - hold off; - otherwise - error('Unsupported newfig value') -end + switch newfig + case 0 + hold on; + case 1 + figure + hold on; + case 2 + hold off; + otherwise + error('InputError: invalid newfig') + end -bar(polflux) -xlabel('Volume label') -ylabel('Poloidal flux') -set(gca, 'FontSize', 14) -xticks(1:1:Nvol) -grid on; + bar(polflux) + xlabel('Volume label') + ylabel('Poloidal flux') + set(gca, 'FontSize', 14) + xticks(1:1:Nvol) + grid on; end diff --git a/Utilities/matlabtools/plot_spec_pressure.m b/Utilities/matlabtools/plot_spec_pressure.m index 9a856887..0e3f9959 100644 --- a/Utilities/matlabtools/plot_spec_pressure.m +++ b/Utilities/matlabtools/plot_spec_pressure.m @@ -1,8 +1,8 @@ function plot_spec_pressure(data, norm, newfig, varargin) % -% PLOT_SPEC_PRESSURE( DATA, NEWFIG ) -% ================================== +% PLOT_SPEC_PRESSURE( DATA, NORM, NEWFIG, VARARGIN ) +% ================================================== % % Plots stepped-pressure profile versus normalized toroidal flux used in SPEC % @@ -15,9 +15,13 @@ function plot_spec_pressure(data, norm, newfig, varargin) % written by J.Loizu (2018) % modified by A. Baillod (2019) +if ~any(norm==[0,1]) + error('InputError: invalid norm') +end + l = length(varargin); if mod(l,2)~=0 - error('Invalid number of argument') + error('InputError: invalid number of argument') end opt.Color='b'; @@ -97,6 +101,7 @@ function plot_spec_pressure(data, norm, newfig, varargin) if( norm ) ylabel('$p / p_0$', 'Interpreter', 'latex') +else ylabel('$p$', 'Interpreter', 'latex') end xlabel('$\Psi / \Psi_{edge}$', 'Interpreter', 'latex') diff --git a/Utilities/matlabtools/plot_spec_surface_current.m b/Utilities/matlabtools/plot_spec_surface_current.m index 300f01f7..a43db383 100644 --- a/Utilities/matlabtools/plot_spec_surface_current.m +++ b/Utilities/matlabtools/plot_spec_surface_current.m @@ -19,7 +19,7 @@ function plot_spec_surface_current(data, nt, newfig) % Test input if nt<1 - error('Invalid nt') + error('InputError: Invalid nt') end @@ -32,7 +32,7 @@ function plot_spec_surface_current(data, nt, newfig) case 2 hold off otherwise - error('Invalide newfig') + error('InputError: Invalid newfig') end % Evaluate toroidal current diff --git a/Utilities/matlabtools/plot_spec_torflux.m b/Utilities/matlabtools/plot_spec_torflux.m index bf15f342..8c7eed87 100644 --- a/Utilities/matlabtools/plot_spec_torflux.m +++ b/Utilities/matlabtools/plot_spec_torflux.m @@ -23,43 +23,42 @@ function plot_spec_torflux(data, zeta, cumulative, newfig) % Written by A. Baillod (2019) % -Nvol = data.input.physics.Nvol; + Mvol = data.output.Mvol; + torflux = zeros(1,Mvol); -torflux = zeros(1,Nvol); + for lvol=1:Mvol + tmp = get_spec_torflux(data,lvol,zeta,-1,1,64,64); -for lvol=1:Nvol - tmp = get_spec_torflux(data,lvol,zeta,-1,1,64,64); - - if cumulative - if lvol==1 - torflux(lvol)=tmp; + if cumulative + if lvol==1 + torflux(lvol)=tmp; + else + torflux(lvol) = torflux(lvol-1) + tmp; + end else - torflux(lvol) = torflux(lvol-1) + tmp; + torflux(lvol)=tmp; end - else - torflux(lvol)=tmp; + end - -end -switch newfig - case 0 - hold on; - case 1 - figure - hold on; - case 2 - hold off; - otherwise - error('Unsupported newfig value') -end + switch newfig + case 0 + hold on; + case 1 + figure + hold on; + case 2 + hold off; + otherwise + error('InputError: Invalid newfig') + end -bar(torflux) -xlabel('Volume label') -ylabel('Toroidal flux') -set(gca, 'FontSize', 14) -xticks(1:1:Nvol) -grid on; + bar(torflux) + xlabel('Volume label') + ylabel('Toroidal flux') + set(gca, 'FontSize', 14) + xticks(1:1:Nvol) + grid on; end diff --git a/Utilities/matlabtools/plot_spec_wall.m b/Utilities/matlabtools/plot_spec_wall.m index 6786af3b..7660cb16 100644 --- a/Utilities/matlabtools/plot_spec_wall.m +++ b/Utilities/matlabtools/plot_spec_wall.m @@ -4,7 +4,7 @@ function plot_spec_wall(data,zetaov2pi,newfig) % PLOT_SPEC_WALL( DATA, ZETAOV2PI, NEWFIG ) % ========================================= % -% Produces a "Poincare plot" of the computational boundary surface in toroidal geometry. +% Plots the computational boundary surface in toroidal geometry. % % INPUT % ----- @@ -14,53 +14,70 @@ function plot_spec_wall(data,zetaov2pi,newfig) % % written by J.Loizu (2018) % modified by J.Loizu (2020) +% + if data.input.physics.Igeometry~=3 + error('InputError: only works in toroidal geometry') + end -mn = data.output.mn; -im = data.output.im; -in = data.output.in; -Rbcmn = data.output.Rbc; -Rbsmn = data.output.Rbs; -Zbcmn = data.output.Zbc; -Zbsmn = data.output.Zbs; + if data.input.physics.Lfreebound==0 + warning(['This will plot the plasma boundary, since no walls are' ... + 'defined in fixed-boundary equilibria']) + end -Rwcmn = Rbcmn(:,end); -Rwsmn = Rbsmn(:,end); -Zwcmn = Zbcmn(:,end); -Zwsmn = Zbsmn(:,end); -% Compute (x,y) coordinates of the boundary surface + mn = data.output.mn; + im = data.output.im; + in = data.output.in; + Rbcmn = data.output.Rbc; + Rbsmn = data.output.Rbs; + Zbcmn = data.output.Zbc; + Zbsmn = data.output.Zbs; -zeta = zetaov2pi*(2*pi); + Rwcmn = Rbcmn(:,end); + Rwsmn = Rbsmn(:,end); + Zwcmn = Zbcmn(:,end); + Zwsmn = Zbsmn(:,end); -nth = 2048; -dth = 2*pi/nth; -theta = dth:dth:2*pi; + % Compute (x,y) coordinates of the boundary surface -X = zeros(1,nth); -Y = zeros(1,nth); + zeta = zetaov2pi*(2*pi); -for k=1:mn - alpha = double(im(k))*theta-double(in(k))*zeta; - X = X + Rwcmn(k)*cos(alpha) + Rwsmn(k)*sin(alpha); - Y = Y + Zwsmn(k)*sin(alpha) + Zwcmn(k)*cos(alpha); -end + nth = 2048; + dth = 2*pi/nth; + theta = dth:dth:2*pi; + X = zeros(1,nth); + Y = zeros(1,nth); + for k=1:mn + alpha = double(im(k))*theta-double(in(k))*zeta; + X = X + Rwcmn(k)*cos(alpha) + Rwsmn(k)*sin(alpha); + Y = Y + Zwsmn(k)*sin(alpha) + Zwcmn(k)*cos(alpha); + end -% Plot Poincare section -if(newfig==1) -figure -end -hold on -scatter(X,Y,3,'filled', 'b') + % Plot Poincare section -axis equal -hold on -set(gca,'FontSize',12) -xlabel('R','FontSize',12) -ylabel('Z','FontSize',12) -%xlim([-1.1*rmax 1.1*rmax]) -%ylim([-1.1*zmax 1.1*zmax]) + switch newfig + case 0 + hold on + case 1 + figure('Color','w','Position',[200 200 900 700]) + case 2 + hold off + otherwise + error('InputError: invalid newfig') + end + + scatter(X,Y,3,'filled', 'b') + + axis equal + hold on + set(gca,'FontSize',12) + xlabel('R','FontSize',12) + ylabel('Z','FontSize',12) + %xlim([-1.1*rmax 1.1*rmax]) + %ylim([-1.1*zmax 1.1*zmax]) +end diff --git a/Utilities/matlabtools/produce_spec_movie.m b/Utilities/matlabtools/produce_spec_movie.m index 428edfd5..4433b424 100644 --- a/Utilities/matlabtools/produce_spec_movie.m +++ b/Utilities/matlabtools/produce_spec_movie.m @@ -25,6 +25,7 @@ function produce_spec_movie(inputroot,seqstart,seqstep,seqend,framerate,nfp,nz0, % written by J.Loizu (2017) % modified by J.Loizu (2019) +error('DEPRECATED: this needs to be reviewed') % writerObj = VideoWriter('spec_movie.avi'); diff --git a/Utilities/matlabtools/read_hdf5.m b/Utilities/matlabtools/read_hdf5.m deleted file mode 100644 index 7390b05f..00000000 --- a/Utilities/matlabtools/read_hdf5.m +++ /dev/null @@ -1,81 +0,0 @@ -function data = read_hdf5(filename) - -% -% OUTDATED ? -% -% READ_HDF5( FILENAME ) -% ===================== -% -% The READ_HDF5 function reads an HDF5 file and returns the contents of -% that file as the fields of a structure. Groups are treated as elements -% of their parent structure. If the file file cannot be opened a -1 is -% returned. -% -% Example -% data=read_hdf5('input.h5'); -% -% Version 1.0 -% Maintained by: Samuel Lazerson (lazerson@pppl.gov) -% Date 05/02/2012 - - -% Try to read the file first -try - data_info = h5info(filename,'/'); -catch h5info_error - data=-1; - disp(['ERROR: Opening HDF5 File: ' filename]); - disp([' -identifier: ' h5info_error.identifier]); - disp([' -message: ' h5info_error.message]); - disp(' For information type: help read_hdf5'); - return -end - -ngroups = length(data_info.Groups); -nvars = length(data_info.Datasets); -% Get root datasets -for i = 1: nvars - data.([data_info.Datasets(i).Name]) = h5read(filename,['/' data_info.Datasets(i).Name]); - natts = length(data_info.Datasets(i).Attributes); - for j=1:natts - data.([data_info.Datasets(i).Attributes(j).Name]) = data_info.Datasets(i).Attributes(j).Value{1}; - end - % Fix by Weatherby,Gerard 10/17/13 - %for j=2:natts - % data.([data_info.Datasets(i).Attributes(j).Name]) = data_info.Datasets(i).Attributes(j).Value{1}; - %end - %if natts == 1 - % data.([data_info.Datasets(i).Attributes(1).Name]) = data_info.Datasets(i).Attributes(1); - %end -end - -% Get each subgroup -if ngroups > 0 - for i = 1 : ngroups - data.([data_info.Groups(i).Name]) = getGroup(['/' data_info.Groups(i).Name]); - end -end -return -end - -function data = getGroup(root) -data_info = h5info(filename,root); -ngroups = length(data_info.Groups); -nvars = length(data_info.Datasets); -% Get root datasets -for i = 1: nvars - data.([data_info.Datasets(i).Name]) = h5read(filename,[root data_info.Datasets(i).Name]); - natts = length(data_info.Datasets(i).Attributes); - for j=1:natts - data.([data_info.Datasets(i).Attributes(j).Name]) = data_info.Datasets(i).Attributes(j).Value{1}; - end -end - -% Get each subgroup -if ngroups > 0 - for i = 1 : ngroups - data.([data_info.Groups(i).Name]) = getGroup(['/' data_info.Groups(i).Name]); - end -end -return -end diff --git a/Utilities/matlabtools/read_spec.m b/Utilities/matlabtools/read_spec.m index 9c2746a1..3bab1aaf 100644 --- a/Utilities/matlabtools/read_spec.m +++ b/Utilities/matlabtools/read_spec.m @@ -25,7 +25,6 @@ disp(['ERROR: Opening HDF5 File: ' filename]); disp([' -identifier: ' h5info_error.identifier]); disp([' -message: ' h5info_error.message]); - disp(' For information type: help read_hdf5'); return end diff --git a/Utilities/matlabtools/read_spec_field.m b/Utilities/matlabtools/read_spec_field.m deleted file mode 100644 index 4752439e..00000000 --- a/Utilities/matlabtools/read_spec_field.m +++ /dev/null @@ -1,127 +0,0 @@ -function fdata = read_spec_field(filename) - -% Reads coefficients of the vector potential using output from SPEC -% -% INPUT -% - filename : path to the hdf5 output file (e.g. 'testcase.sp.h5') -% -% OUTPUT -% - fdata : contains all the field data, which can be fed into several routines for analyzing and ploting -% -% Note: So far only works if Lrad is the same for all volumes -% -% written by J.Loizu (2017) -% modified by J.Loizu (10.2017) -% modified by J.Loizu (02.2018) - -if ~exist(filename) - ME = MException('MyComp:FileDoesNotExist', ... - 'The file %s does not exist (in this directory)', filename); - throw(ME) -end - -global machform; - -machform = 's'; - -data = read_hdf5(filename); - -nvol = data.Mvol; - -mn = data.mn; - -data.Lrad = zeros(nvol,1); % allocate data set for Lrad(1:nvol) - -data.Ate = cell(nvol,1); % create cells for each volume's field - -data.Aze = cell(nvol,1); - -data.Ato = cell(nvol,1); - -data.Azo = cell(nvol,1); - - -% Read the field files - -machine_format = machform; % needs to be 's' (intel) or 'a' (gnu); format is swapped if an error occurs -triedallform = 0; % whether all formats have been tried (1) or not (0) -success = 0; -int_format = 'int32'; -float_format = 'float64'; -spacer_format = 'int32'; - -while(success==0) -try - - if(machine_format ~= machform) - machine_format = machform; % update value - end - field_file = ['.' filename(1:length(filename)-3) '.A']; - fid = fopen(field_file,'r',machine_format); - if (fid > 0) - % Read through Mvol, Mpol, Ntor, mn, Nfp, im(1:mn), in(1:mn) - fread(fid,1,spacer_format); - fread(fid,5,int_format); % Mvol, Mpol, Ntor, mn, Nfp - fread(fid,2,spacer_format); - fread(fid,mn,int_format); % im - fread(fid,2,spacer_format); - fread(fid,mn,int_format); % in - fread(fid,1,spacer_format); - else - disp(' - File does not exist'); break; - end - - for v=1:nvol - % Get radial resolution - fread(fid,1,spacer_format); - Lrad = fread(fid,1,int_format); - fread(fid,1,spacer_format); - data.Lrad(v,1) = Lrad; - % Allocate data for the fields - data.Ate{v} = zeros(Lrad+1,mn); - data.Aze{v} = zeros(Lrad+1,mn); - data.Ato{v} = zeros(Lrad+1,mn); - data.Azo{v} = zeros(Lrad+1,mn); - for i=1:mn - fread(fid,1,spacer_format); - data.Ate{v}(:,i) = fread(fid,Lrad+1,float_format); % Ate - fread(fid,2,spacer_format); - data.Aze{v}(:,i) = fread(fid,Lrad+1,float_format); % Aze - fread(fid,2,spacer_format); - data.Ato{v}(:,i) = fread(fid,Lrad+1,float_format); % Ato - fread(fid,2,spacer_format); - data.Azo{v}(:,i) = fread(fid,Lrad+1,float_format); % Azo - fread(fid,1,spacer_format); - end - end - - success=1; - -catch - - if(triedallform==1) - disp(' - Could not read field file'); break; - end - if(machform~='s') - machform ='s'; - triedallform = 1; - else - machform ='a'; - triedallform = 1; - end - if (fid ~= -1) - fclose(fid); - fid = -1; - end -end - -end - -if (fid ~= -1) - fclose(fid); -end - - -%return output -fdata = data; - diff --git a/Utilities/matlabtools/read_spec_hessian.m b/Utilities/matlabtools/read_spec_hessian.m deleted file mode 100644 index 7a7d805b..00000000 --- a/Utilities/matlabtools/read_spec_hessian.m +++ /dev/null @@ -1,82 +0,0 @@ -function Hmatrix = read_spec_hessian(filename) - -% -% READ_SPEC_HESSIAN( FILENAME ) -% ============================= -% -% Reads Hessian matrix using output from SPEC -% -% INPUT -% ----- -% - filename : path to the hdf5 output file (e.g. 'testcase.sp.h5') -% -% OUTPUT -% ------ -% - Hmatrix : Hessian matrix, which can be fed into several routines for analyzing and ploting -% -% written by J.Loizu (2017) -% updated by J.Loizu (2020) - - -global machform; - -machform = 's'; - - -% Read the hessian file - -machine_format = machform; % needs to be 's' (intel) or 'a' (gnu); format is swapped if an error occurs -triedallform = 0; % whether all formats have been tried (1) or not (0) -success = 0; -int_format = 'int32'; -float_format = 'float64'; -spacer_format = 'int32'; - - -while(success==0) -try - - if(machine_format ~= machform) - machine_format = machform; % update value - end - hessian_file = ['.' filename(1:length(filename)-6) '.GF.ma']; - fid = fopen(hessian_file,'r',machine_format); - if (fid > 0) - % Read through NGdof - fread(fid,1,spacer_format); - ngdof = fread(fid,1,int_format); % NGdof - fread(fid,1,spacer_format); - else - disp(' - File does not exist'); break; - end - - fread(fid,1,spacer_format); - Hmatrix = fread(fid,[ngdof ngdof],float_format); - fread(fid,1,spacer_format); - - success=1; - -catch - - if(triedallform==1) - disp(' - Could not read hessian file'); break; - end - if(machform~='s') - machform ='s'; - triedallform = 1; - else - machform ='a'; - triedallform = 1; - end - if (fid ~= -1) - fclose(fid); - fid = -1; - end -end - -end - -if (fid ~= -1) - fclose(fid); -end - diff --git a/Utilities/matlabtools/read_spec_iota.m b/Utilities/matlabtools/read_spec_iota.m deleted file mode 100644 index 7f1d016c..00000000 --- a/Utilities/matlabtools/read_spec_iota.m +++ /dev/null @@ -1,95 +0,0 @@ -function idata = read_spec_iota(filename) - -% Reads rotational transform data from field-line-tracing using output from SPEC -% -% INPUT -% - filename : path to the hdf5 output file (e.g. 'testcase.sp.h5') -% -% OUTPUT -% - idata : contains all the transform data, which can be fed into several routines for analyzing and ploting -% -% written by J.Loizu (2017) -% modified by J.Loizu (02.2018) - -if ~exist(filename) - ME = MException('MyComp:FileDoesNotExist', ... - 'The file %s does not exist (in this directory)', filename); - throw(ME) -end - -global machform; - -machform = 's'; - -data = read_hdf5(filename); - -nvol = double(data.Mvol); - - -% Read the transform files - -machine_format = machform; % needs to be 's' (intel) or 'a' (gnu); format is swapped if an error occurs -triedallform = 0; % whether all formats have been tried (1) or not (0) -success = 0; -int_format = 'int32'; -float_format = 'float64'; -spacer_format = 'int32'; - -j=1; - -for i=1:nvol - success = 0; - triedallform = 0; - while(success==0) - try - if(machine_format ~= machform) - machine_format = machform; % update value - end - transform_file=['.' filename(1:length(filename)-3) '.t.' num2str(i,'%4.4i') '.dat']; - fid = fopen(transform_file,'r',machine_format); - if (fid > 0) - % Get subgrid - fread(fid,1,spacer_format); - npts=fread(fid,1,int_format); - fread(fid,1,spacer_format); - if(npts>1e4), npts=-1; end; % dirty fix to force switching of binary format - % Get Iota edges - fread(fid,1,spacer_format); - iotae=fread(fid,2,float_format); - fread(fid,1,spacer_format); - % Get Profile iota(s) - fread(fid,1,spacer_format); - out=fread(fid,[2 npts],float_format); - nptraj=size(out,2); - data.sarr(j:j+nptraj-1) = out(1,:); - data.iota(j:j+nptraj-1) = out(2,:); - j=j+nptraj; - success = 1; - fclose(fid); - fid = -1; - else - disp(' - File does not exist'); break - end - catch - if(triedallform==1) - disp(' - Could not read transform file'); break; - end - if(machform~='s') - machform ='s'; - triedallform = 1; - else - machform ='a'; - triedallform = 1; - end - if (fid ~= -1) - fclose(fid); - fid = -1; - end - end - end -end - - -%return output -idata = data; - diff --git a/Utilities/matlabtools/read_spec_poincare.m b/Utilities/matlabtools/read_spec_poincare.m deleted file mode 100644 index 53493a62..00000000 --- a/Utilities/matlabtools/read_spec_poincare.m +++ /dev/null @@ -1,103 +0,0 @@ -function pdata = read_spec_poincare(filename) - -% Reads Poincare data from field-line-tracing using output from SPEC -% -% INPUT -% - filename : path to the hdf5 output file (e.g. 'testcase.sp.h5') -% -% OUTPUT -% - pdata : contains all the poincare data, which can be fed into several routines for analyzing and ploting -% -% written by J.Loizu (2017) - - -if ~exist(filename) - ME = MException('MyComp:FileDoesNotExist', ... - 'The file %s does not exist (in this directory)', filename); - throw(ME) -end - - -global machform; - -machform = 's'; - -data = read_hdf5(filename); - -nvol = double(data.Mvol); - - -% Read the poincare files - -machine_format = machform; % needs to be 's' (intel) or 'a' (gnu); format is swapped if an error occurs -triedallform = 0; % whether all formats have been tried (1) or not (0) -success = 0; -int_format = 'int32'; -float_format = 'float64'; -spacer_format = 'int32'; - -j=1; - -for i=1:nvol - offset = real(i-1)./real(nvol); - success = 0; - triedallform = 0; - while(success==0) - try - if(machine_format ~= machform) - machine_format = machform; % update value - end - poincare_file=['.' filename(1:length(filename)-3) '.P.' num2str(i,'%4.4i') '.dat']; - fid = fopen(poincare_file,'r',machine_format); - if (fid > 0) - while ~feof(fid) - % interface labels - fread(fid,1,spacer_format); - if (feof(fid)), break; end; - temp=fread(fid,2,int_format); - fread(fid,1,spacer_format); - nzeta=temp(1); - nppts=temp(2); - data.npoinc=nppts; - % blockdata - fread(fid,1,spacer_format); - temp=fread(fid,4*nzeta*nppts,float_format); - fread(fid,1,spacer_format); - if ~isempty(temp) - temp=reshape(temp,[4 nzeta nppts]); - data.th_lines(j,1:nzeta,1:nppts)=temp(1,1:nzeta,1:nppts); - rho = 0.5*(temp(2,1:nzeta,1:nppts)+1)./real(nvol); - data.rho_lines(j,1:nzeta,1:nppts)=rho+offset; - data.R_lines(j,1:nzeta,1:nppts)=temp(3,1:nzeta,1:nppts); - data.Z_lines(j,1:nzeta,1:nppts)=temp(4,1:nzeta,1:nppts); - j=j+1; - end - end - fclose(fid); - fid = -1; - success=1; - else - disp(' - File does not exist'); break; - end - catch - if (fid ~= -1) - fclose(fid); - fid = -1; - end - if(triedallform==1) - disp(' - Could not read poincare file'); break; - end - if(machform~='s') - machform ='s'; - triedallform = 1; - else - machform ='a'; - triedallform = 1; - end - end - end -end - - -%return output -pdata = data; diff --git a/Utilities/matlabtools/run_spec.m b/Utilities/matlabtools/run_spec.m deleted file mode 100644 index 6667fe8d..00000000 --- a/Utilities/matlabtools/run_spec.m +++ /dev/null @@ -1,48 +0,0 @@ -function run_spec(fname, comment) - -% Go in ~/specruns/ -!cd ~/specruns/ - -% Run SPEC -command = char(['./xspec ', fname]); -system(command) - -% Move everything in there -h5fname = [fname, '.sp.h5']; - -c = datetime('now'); - -matname = [fname, '.sp.mat']; - - -gdata = read_spec_grid(h5fname); -input = compose(string([ - '\n Igeometry = ', num2str(gdata.Igeometry), ... - '\n Lconstraint = ', num2str(gdata.Lconstraint), ... - '\n Lfreebound = ', num2str(gdata.Lfreebound), ... - '\n Nvol = ', num2str(gdata.Nvol), ... - '\n Mrad = ', num2str(gdata.Mrad), ... - '\n Nfp = ', num2str(gdata.Nfp), ... - '\n Ntor = ', num2str(gdata.Ntor), ... - '\n Mpol = ', num2str(gdata.Mpol), ... - '\n'])); -output = compose(string([ - '\n ForceErr = ', num2str(gdata.ForceErr), ... - '\n'])); - - -out.date = c; -out.comment = comment; -out.input = fname; -out.h5name = h5fname; -out.input = input; -out.output = output; - - -% Write mat file -save(matname, '-struct', 'out'); - - - - -end \ No newline at end of file diff --git a/Utilities/matlabtools/run_spec_iter_fixtorcurr.m b/Utilities/matlabtools/run_spec_iter_fixtorcurr.m deleted file mode 100644 index 94d61684..00000000 --- a/Utilities/matlabtools/run_spec_iter_fixtorcurr.m +++ /dev/null @@ -1,137 +0,0 @@ -function currents = run_spec_iter_fixtorcurr(execom,inputroot,Nvol,Lrad,nptr,startit,nit,Iref) - - -% Runs SPEC iteratively to find nearby equilibria with mu=0 in each volume and net toroidal surface-current Iref (units mu0*I). -% Target current is achieved by iterating on the enclosed poloidal flux. -% -% INPUT -% - execom : command for the execution of SPEC executable (e.g. './xspec' or 'mpirun -n 2 ./xspec') -% - inputroot : spec input file name of the form 'somename_iter', and 'somename_iter0.sp.end/.h5' must already exist. -% - Nvol : number of volumes -% - Lrad : radial resolution in each volume (one value) -% - nptr : number of poincare trajectories traced in each volume -% - startit : starting iteration number -% - nit : number of iterations -% - Iref : targeted net-toroidal-current (array of size Nvol-1) -% -% OUTPUT -% - currents : array of net-toroidal-currents obtained on each interface at each interation step -% -% written by J.Loizu (2017) -% upgraded by J.Loizu (2018) - - -specexec = strcat(execom,{' '}); - -specexec = specexec{1}; - -currents = zeros(nit+1,Nvol-1); - -pfac = 1e-9; % factor for the amplitude of the perturbation in pflux for Jacobian evaluation (reference: 1e-6) - -ntheta = 128; % poloidal resolution for the loop integral evaluating the current - -mu = zeros(1,Nvol); % as of now zero volume-currents are imposed - - -for i=1+startit:startit+nit - - display(' '); - display(['START OF CURRENT ITERATION ' num2str(i)]); - display(' '); - - %-------- Initial input and hdf5 files -------- - - spec_input = strcat(inputroot,num2str(i-1),'.sp.end'); - spec_hdf5 = strcat(inputroot,num2str(i-1),'.sp.h5'); - - tflux = h5read(spec_hdf5,'/tflux'); - pflux = h5read(spec_hdf5,'/pflux'); - pre = h5read(spec_hdf5,'/pressure'); - IKAMtor = get_spec_torcurr_kam_net(spec_hdf5,ntheta); - - currents(i-startit,1:Nvol-1) = IKAMtor; - - %-------- Evaluation of J=dI/dX --------- - - tfl = zeros(1,Nvol); - - pfl = zeros(1,Nvol); - - dX = zeros(1,Nvol); - - dIdX = zeros(Nvol-1,Nvol-1); - - dX = pflux*pfac; - - lrad = Lrad*ones(1,Nvol); - - template = spec_input; - - - % jacobian evaluation runs - - for lvol=2:Nvol - - display(' '); - display(['JACOBIAN EVALUATION...' num2str(lvol-1)]); - display(' '); - - tfl = tflux; - - pfl = pflux; - - pfl(lvol) = pfl(lvol) + dX(lvol); - - newinput = strcat(inputroot,'jacobian',num2str(lvol),'.sp'); - - write_spec_input_L0(template,newinput,Nvol,tfl,pfl,mu,pre,lrad,nptr); - - system(strcat([specexec newinput(1:end-3)])); - - spec_hdf5 = strcat(newinput(1:end-3),'.sp.h5'); - - newIKAMtor = get_spec_torcurr_kam_net(spec_hdf5,ntheta); - - dIdX(:,lvol-1) = (newIKAMtor-IKAMtor)/dX(lvol); - - end - - - %-------- Evaluation of dX steps from Newton method --------- - - Jinv = inv(dIdX); - curr(1:Nvol-1) = IKAMtor; - zfun(1:Nvol-1) = IKAMtor-Iref; - - dX(2:Nvol) = -Jinv*transpose(zfun); - - display(' '); - display(['CALCULATED STEP: ' num2str(transpose(dX)) ]); - display(' '); - - %-------- Final run with appropriate X+dXstep --------- - - tfl = tflux; - pfl = pflux; - pfl(2:Nvol) = pfl(2:Nvol) + dX(2:Nvol); - - newinput = strcat(inputroot,num2str(i),'.sp'); - - write_spec_input_L0(template,newinput,Nvol,tfl,pfl,mu,pre,lrad,nptr); - - system(strcat([specexec newinput(1:end-3)])); - - - %-------- Update .DF file from last output -------- - - system(strcat(['cp ' '.' inputroot num2str(i) '.sp.DF' ' .sp.DF'])); - - -end - -spec_hdf5 = strcat(inputroot,num2str(startit+nit),'.sp.h5'); -IKAMtor = get_spec_torcurr_kam_net(spec_hdf5,ntheta); -currents(nit+1,1:Nvol-1) = IKAMtor; - - diff --git a/Utilities/matlabtools/specheck.m b/Utilities/matlabtools/specheck.m deleted file mode 100644 index 427005ca..00000000 --- a/Utilities/matlabtools/specheck.m +++ /dev/null @@ -1,293 +0,0 @@ -function matching = specheck(fdata, gdata, idata, pdata, data) - -% Compares the outputs of the current SPEC version and the newly-developed single HDF5 output. -% -% INPUT -% - fdata : from read_spec_field('master/testcase.sp.h5') -% - gdata : from read_spec_grid('master/testcase.sp.h5') -% - idata : from read_spec_iota('master/testcase.sp.h5') -% - pdata : from read_spec_poincare('master/testcase.sp.h5') -% - data : from read_spec('issue68/testcase.h5') -% -% OUTPUT -% - matching : 1 if the outputs are identical, 0 otherwise -% -% written by J.Schilling (2019) - -matching = 1; - -% check equivalence of fdata: from 'testcase.sp.h5' file -% quantities from old .sp.h5 file, sorted by equivalent quantity in the new output file -if isequal(fdata.forcetol , data.input.global.forcetol ) ; disp('ok: fdata.forcetol ') ; else ; disp('ERROR: fdata.forcetol '); matching=0; end - -if isequal(fdata.Igeometry , data.input.physics.Igeometry ) ; disp('ok: fdata.Igeometry ') ; else ; disp('ERROR: fdata.Igeometry '); matching=0; end -if isequal(fdata.Istellsym , data.input.physics.Istellsym ) ; disp('ok: fdata.Istellsym ') ; else ; disp('ERROR: fdata.Istellsym '); matching=0; end -if isequal(fdata.Ladiabatic , data.input.physics.Ladiabatic ) ; disp('ok: fdata.Ladiabatic ') ; else ; disp('ERROR: fdata.Ladiabatic '); matching=0; end -if isequal(fdata.Lconstraint , data.input.physics.Lconstraint ) ; disp('ok: fdata.Lconstraint') ; else ; disp('ERROR: fdata.Lconstraint'); matching=0; end -if isequal(fdata.Lfreebound , data.input.physics.Lfreebound ) ; disp('ok: fdata.Lfreebound ') ; else ; disp('ERROR: fdata.Lfreebound '); matching=0; end -if isequal(fdata.Lrad , data.input.physics.Lrad ) ; disp('ok: fdata.Lrad ') ; else ; disp('ERROR: fdata.Lrad '); matching=0; end -if isequal(fdata.Mpol , data.input.physics.Mpol ) ; disp('ok: fdata.Mpol ') ; else ; disp('ERROR: fdata.Mpol '); matching=0; end -if isequal(fdata.Nfp , data.input.physics.Nfp ) ; disp('ok: fdata.Nfp ') ; else ; disp('ERROR: fdata.Nfp '); matching=0; end -if isequal(fdata.Ntor , data.input.physics.Ntor ) ; disp('ok: fdata.Ntor ') ; else ; disp('ERROR: fdata.Ntor '); matching=0; end -if isequal(fdata.Nvol , data.input.physics.Nvol ) ; disp('ok: fdata.Nvol ') ; else ; disp('ERROR: fdata.Nvol '); matching=0; end -if isequal(fdata.curpol , data.input.physics.curpol ) ; disp('ok: fdata.curpol ') ; else ; disp('ERROR: fdata.curpol '); matching=0; end -if isequal(fdata.curtor , data.input.physics.curtor ) ; disp('ok: fdata.curtor ') ; else ; disp('ERROR: fdata.curtor '); matching=0; end -if isequal(fdata.gamma , data.input.physics.gamma ) ; disp('ok: fdata.gamma ') ; else ; disp('ERROR: fdata.gamma '); matching=0; end -if isequal(fdata.iota , data.input.physics.iota ) ; disp('ok: fdata.iota ') ; else ; disp('ERROR: fdata.iota '); matching=0; end -if isequal(fdata.lp , data.input.physics.lp ) ; disp('ok: fdata.lp ') ; else ; disp('ERROR: fdata.lp '); matching=0; end -if isequal(fdata.lq , data.input.physics.lq ) ; disp('ok: fdata.lq ') ; else ; disp('ERROR: fdata.lq '); matching=0; end -if isequal(fdata.mupfits , data.input.physics.mupfits ) ; disp('ok: fdata.mupfits ') ; else ; disp('ERROR: fdata.mupfits '); matching=0; end -if isequal(fdata.mupftol , data.input.physics.mupftol ) ; disp('ok: fdata.mupftol ') ; else ; disp('ERROR: fdata.mupftol '); matching=0; end -if isequal(fdata.oita , data.input.physics.oita ) ; disp('ok: fdata.oita ') ; else ; disp('ERROR: fdata.oita '); matching=0; end -if isequal(fdata.phiedge , data.input.physics.phiedge ) ; disp('ok: fdata.phiedge ') ; else ; disp('ERROR: fdata.phiedge '); matching=0; end -if isequal(fdata.pl , data.input.physics.pl ) ; disp('ok: fdata.pl ') ; else ; disp('ERROR: fdata.pl '); matching=0; end -if isequal(fdata.pr , data.input.physics.pr ) ; disp('ok: fdata.pr ') ; else ; disp('ERROR: fdata.pr '); matching=0; end -if isequal(fdata.pressure , data.input.physics.pressure ) ; disp('ok: fdata.pressure ') ; else ; disp('ERROR: fdata.pressure '); matching=0; end -if isequal(fdata.pscale , data.input.physics.pscale ) ; disp('ok: fdata.pscale ') ; else ; disp('ERROR: fdata.pscale '); matching=0; end -if isequal(fdata.ql , data.input.physics.ql ) ; disp('ok: fdata.ql ') ; else ; disp('ERROR: fdata.ql '); matching=0; end -if isequal(fdata.qr , data.input.physics.qr ) ; disp('ok: fdata.qr ') ; else ; disp('ERROR: fdata.qr '); matching=0; end -if isequal(fdata.rp , data.input.physics.rp ) ; disp('ok: fdata.rp ') ; else ; disp('ERROR: fdata.rp '); matching=0; end -if isequal(fdata.rq , data.input.physics.rq ) ; disp('ok: fdata.rq ') ; else ; disp('ERROR: fdata.rq '); matching=0; end - -if isequal(fdata.Lperturbed , data.input.diagnostics.Lperturbed) ; disp('ok: fdata.Lperturbed ') ; else ; disp('ERROR: fdata.Lperturbed '); matching=0; end -if isequal(fdata.dpp , data.input.diagnostics.dpp ) ; disp('ok: fdata.dpp ') ; else ; disp('ERROR: fdata.dpp '); matching=0; end -if isequal(fdata.dqq , data.input.diagnostics.dqq ) ; disp('ok: fdata.dqq ') ; else ; disp('ERROR: fdata.dqq '); matching=0; end - -if isequal(fdata.Bnc , data.output.Bnc ) ; disp('ok: fdata.Bnc ') ; else ; disp('ERROR: fdata.Bnc '); matching=0; end -if isequal(fdata.Bns , data.output.Bns ) ; disp('ok: fdata.Bns ') ; else ; disp('ERROR: fdata.Bns '); matching=0; end -if isequal(fdata.Btemn , data.output.Btemn ) ; disp('ok: fdata.Btemn ') ; else ; disp('ERROR: fdata.Btemn '); matching=0; end -if isequal(fdata.Btomn , data.output.Btomn ) ; disp('ok: fdata.Btomn ') ; else ; disp('ERROR: fdata.Btomn '); matching=0; end -if isequal(fdata.Bzemn , data.output.Bzemn ) ; disp('ok: fdata.Bzemn ') ; else ; disp('ERROR: fdata.Bzemn '); matching=0; end -if isequal(fdata.Bzomn , data.output.Bzomn ) ; disp('ok: fdata.Bzomn ') ; else ; disp('ERROR: fdata.Bzomn '); matching=0; end -if isequal(fdata.ForceErr , data.output.ForceErr ) ; disp('ok: fdata.ForceErr ') ; else ; disp('ERROR: fdata.ForceErr '); matching=0; end -if isequal(fdata.Mrad , data.output.Mrad ) ; disp('ok: fdata.Mrad ') ; else ; disp('ERROR: fdata.Mrad '); matching=0; end -if isequal(fdata.Mvol , data.output.Mvol ) ; disp('ok: fdata.Mvol ') ; else ; disp('ERROR: fdata.Mvol '); matching=0; end -if isequal(fdata.Rbc , data.output.Rbc ) ; disp('ok: fdata.Rbc ') ; else ; disp('ERROR: fdata.Rbc '); matching=0; end -if isequal(fdata.Rbs , data.output.Rbs ) ; disp('ok: fdata.Rbs ') ; else ; disp('ERROR: fdata.Rbs '); matching=0; end -if isequal(fdata.TT , data.output.TT ) ; disp('ok: fdata.TT ') ; else ; disp('ERROR: fdata.TT '); matching=0; end -if isequal(fdata.Vnc , data.output.Vnc ) ; disp('ok: fdata.Vnc ') ; else ; disp('ERROR: fdata.Vnc '); matching=0; end -if isequal(fdata.Vns , data.output.Vns ) ; disp('ok: fdata.Vns ') ; else ; disp('ERROR: fdata.Vns '); matching=0; end -if isequal(fdata.Zbc , data.output.Zbc ) ; disp('ok: fdata.Zbc ') ; else ; disp('ERROR: fdata.Zbc '); matching=0; end -if isequal(fdata.Zbs , data.output.Zbs ) ; disp('ok: fdata.Zbs ') ; else ; disp('ERROR: fdata.Zbs '); matching=0; end -if isequal(fdata.adiabatic , data.output.adiabatic ) ; disp('ok: fdata.adiabatic ') ; else ; disp('ERROR: fdata.adiabatic '); matching=0; end -if isequal(fdata.helicity , data.output.helicity ) ; disp('ok: fdata.helicity ') ; else ; disp('ERROR: fdata.helicity '); matching=0; end -if isequal(fdata.im , data.output.im ) ; disp('ok: fdata.im ') ; else ; disp('ERROR: fdata.im '); matching=0; end -if isequal(fdata.in , data.output.in ) ; disp('ok: fdata.in ') ; else ; disp('ERROR: fdata.in '); matching=0; end -if isequal(fdata.lmns , data.output.lmns ) ; disp('ok: fdata.lmns ') ; else ; disp('ERROR: fdata.lmns '); matching=0; end -if isequal(fdata.mn , data.output.mn ) ; disp('ok: fdata.mn ') ; else ; disp('ERROR: fdata.mn '); matching=0; end -if isequal(fdata.volume , data.output.volume ) ; disp('ok: fdata.volume ') ; else ; disp('ERROR: fdata.volume '); matching=0; end -if isequal(fdata.mu , data.output.mu ) ; disp('ok: fdata.mu ') ; else ; disp('ERROR: fdata.mu '); matching=0; end -if isequal(fdata.pflux , data.output.pflux ) ; disp('ok: fdata.pflux ') ; else ; disp('ERROR: fdata.pflux '); matching=0; end -if isequal(fdata.tflux , data.output.tflux ) ; disp('ok: fdata.tflux ') ; else ; disp('ERROR: fdata.tflux '); matching=0; end - -if isequal(fdata.Ate , data.vector_potential.Ate ) ; disp('ok: fdata.Ate ') ; else ; disp('ERROR: fdata.Ate '); matching=0; end -if isequal(fdata.Aze , data.vector_potential.Aze ) ; disp('ok: fdata.Aze ') ; else ; disp('ERROR: fdata.Aze '); matching=0; end -if isequal(fdata.Ato , data.vector_potential.Ato ) ; disp('ok: fdata.Ato ') ; else ; disp('ERROR: fdata.Ato '); matching=0; end -if isequal(fdata.Azo , data.vector_potential.Azo ) ; disp('ok: fdata.Azo ') ; else ; disp('ERROR: fdata.Azo '); matching=0; end - -% check equivalence of gdata: from ".testcase.sp.grid" file -if isequal(gdata.Bnc , data.output.Bnc ) ; disp('ok: gdata.Bnc ') ; else ; disp('ERROR: gdata.Bnc '); matching=0; end -if isequal(gdata.Bns , data.output.Bns ) ; disp('ok: gdata.Bns ') ; else ; disp('ERROR: gdata.Bns '); matching=0; end -if isequal(gdata.Btemn , data.output.Btemn ) ; disp('ok: gdata.Btemn ') ; else ; disp('ERROR: gdata.Btemn '); matching=0; end -if isequal(gdata.Btomn , data.output.Btomn ) ; disp('ok: gdata.Btomn ') ; else ; disp('ERROR: gdata.Btomn '); matching=0; end -if isequal(gdata.Bzemn , data.output.Bzemn ) ; disp('ok: gdata.Bzemn ') ; else ; disp('ERROR: gdata.Bzemn '); matching=0; end -if isequal(gdata.Bzomn , data.output.Bzomn ) ; disp('ok: gdata.Bzomn ') ; else ; disp('ERROR: gdata.Bzomn '); matching=0; end -if isequal(gdata.ForceErr , data.output.ForceErr ) ; disp('ok: gdata.ForceErr ') ; else ; disp('ERROR: gdata.ForceErr '); matching=0; end -if isequal(gdata.Igeometry , data.input.physics.Igeometry ) ; disp('ok: gdata.Igeometry ') ; else ; disp('ERROR: gdata.Igeometry '); matching=0; end -if isequal(gdata.Istellsym , data.input.physics.Istellsym ) ; disp('ok: gdata.Istellsym ') ; else ; disp('ERROR: gdata.Istellsym '); matching=0; end -if isequal(gdata.Ladiabatic , data.input.physics.Ladiabatic ) ; disp('ok: gdata.Ladiabatic ') ; else ; disp('ERROR: gdata.Ladiabatic '); matching=0; end -if isequal(gdata.Lconstraint , data.input.physics.Lconstraint ) ; disp('ok: gdata.Lconstraint') ; else ; disp('ERROR: gdata.Lconstraint'); matching=0; end -if isequal(gdata.Lfreebound , data.input.physics.Lfreebound ) ; disp('ok: gdata.Lfreebound ') ; else ; disp('ERROR: gdata.Lfreebound '); matching=0; end -if isequal(gdata.Lperturbed , data.input.diagnostics.Lperturbed) ; disp('ok: gdata.Lperturbed ') ; else ; disp('ERROR: gdata.Lperturbed '); matching=0; end -if isequal(gdata.Lrad , data.input.physics.Lrad ) ; disp('ok: gdata.Lrad ') ; else ; disp('ERROR: gdata.Lrad '); matching=0; end -if isequal(gdata.Mpol , data.input.physics.Mpol ) ; disp('ok: gdata.Mpol ') ; else ; disp('ERROR: gdata.Mpol '); matching=0; end -if isequal(gdata.Mrad , data.output.Mrad ) ; disp('ok: gdata.Mrad ') ; else ; disp('ERROR: gdata.Mrad '); matching=0; end -if isequal(gdata.Mvol , data.output.Mvol ) ; disp('ok: gdata.Mvol ') ; else ; disp('ERROR: gdata.Mvol '); matching=0; end -if isequal(gdata.Nfp , data.input.physics.Nfp ) ; disp('ok: gdata.Nfp ') ; else ; disp('ERROR: gdata.Nfp '); matching=0; end -if isequal(gdata.Ntor , data.input.physics.Ntor ) ; disp('ok: gdata.Ntor ') ; else ; disp('ERROR: gdata.Ntor '); matching=0; end -if isequal(gdata.Nvol , data.input.physics.Nvol ) ; disp('ok: gdata.Nvol ') ; else ; disp('ERROR: gdata.Nvol '); matching=0; end -if isequal(gdata.Rbc , data.output.Rbc ) ; disp('ok: gdata.Rbc ') ; else ; disp('ERROR: gdata.Rbc '); matching=0; end -if isequal(gdata.Rbs , data.output.Rbs ) ; disp('ok: gdata.Rbs ') ; else ; disp('ERROR: gdata.Rbs '); matching=0; end -if isequal(gdata.TT , data.output.TT ) ; disp('ok: gdata.TT ') ; else ; disp('ERROR: gdata.TT '); matching=0; end -if isequal(gdata.Vnc , data.output.Vnc ) ; disp('ok: gdata.Vnc ') ; else ; disp('ERROR: gdata.Vnc '); matching=0; end -if isequal(gdata.Vns , data.output.Vns ) ; disp('ok: gdata.Vns ') ; else ; disp('ERROR: gdata.Vns '); matching=0; end -if isequal(gdata.Zbc , data.output.Zbc ) ; disp('ok: gdata.Zbc ') ; else ; disp('ERROR: gdata.Zbc '); matching=0; end -if isequal(gdata.Zbs , data.output.Zbs ) ; disp('ok: gdata.Zbs ') ; else ; disp('ERROR: gdata.Zbs '); matching=0; end -if isequal(gdata.adiabatic , data.output.adiabatic ) ; disp('ok: gdata.adiabatic ') ; else ; disp('ERROR: gdata.adiabatic '); matching=0; end -if isequal(gdata.curpol , data.input.physics.curpol ) ; disp('ok: gdata.curpol ') ; else ; disp('ERROR: gdata.curpol '); matching=0; end -if isequal(gdata.curtor , data.input.physics.curtor ) ; disp('ok: gdata.curtor ') ; else ; disp('ERROR: gdata.curtor '); matching=0; end -if isequal(gdata.dpp , data.input.diagnostics.dpp ) ; disp('ok: gdata.dpp ') ; else ; disp('ERROR: gdata.dpp '); matching=0; end -if isequal(gdata.dqq , data.input.diagnostics.dqq ) ; disp('ok: gdata.dqq ') ; else ; disp('ERROR: gdata.dqq '); matching=0; end -if isequal(gdata.forcetol , data.input.global.forcetol ) ; disp('ok: gdata.forcetol ') ; else ; disp('ERROR: gdata.forcetol '); matching=0; end -if isequal(gdata.gamma , data.input.physics.gamma ) ; disp('ok: gdata.gamma ') ; else ; disp('ERROR: gdata.gamma '); matching=0; end -if isequal(gdata.helicity , data.output.helicity ) ; disp('ok: gdata.helicity ') ; else ; disp('ERROR: gdata.helicity '); matching=0; end -if isequal(gdata.im , data.output.im ) ; disp('ok: gdata.im ') ; else ; disp('ERROR: gdata.im '); matching=0; end -if isequal(gdata.in , data.output.in ) ; disp('ok: gdata.in ') ; else ; disp('ERROR: gdata.in '); matching=0; end -if isequal(gdata.iota , data.input.physics.iota ) ; disp('ok: gdata.iota ') ; else ; disp('ERROR: gdata.iota '); matching=0; end -if isequal(gdata.lmns , data.output.lmns ) ; disp('ok: gdata.lmns ') ; else ; disp('ERROR: gdata.lmns '); matching=0; end -if isequal(gdata.lp , data.input.physics.lp ) ; disp('ok: gdata.lp ') ; else ; disp('ERROR: gdata.lp '); matching=0; end -if isequal(gdata.lq , data.input.physics.lq ) ; disp('ok: gdata.lq ') ; else ; disp('ERROR: gdata.lq '); matching=0; end -if isequal(gdata.mn , data.output.mn ) ; disp('ok: gdata.mn ') ; else ; disp('ERROR: gdata.mn '); matching=0; end -if isequal(gdata.mu , data.output.mu ) ; disp('ok: gdata.mu ') ; else ; disp('ERROR: gdata.mu '); matching=0; end -if isequal(gdata.mupfits , data.input.physics.mupfits ) ; disp('ok: gdata.mupfits ') ; else ; disp('ERROR: gdata.mupfits '); matching=0; end -if isequal(gdata.mupftol , data.input.physics.mupftol ) ; disp('ok: gdata.mupftol ') ; else ; disp('ERROR: gdata.mupftol '); matching=0; end -if isequal(gdata.oita , data.input.physics.oita ) ; disp('ok: gdata.oita ') ; else ; disp('ERROR: gdata.oita '); matching=0; end -if isequal(gdata.pflux , data.output.pflux ) ; disp('ok: gdata.pflux ') ; else ; disp('ERROR: gdata.pflux '); matching=0; end -if isequal(gdata.phiedge , data.input.physics.phiedge ) ; disp('ok: gdata.phiedge ') ; else ; disp('ERROR: gdata.phiedge '); matching=0; end -if isequal(gdata.pl , data.input.physics.pl ) ; disp('ok: gdata.pl ') ; else ; disp('ERROR: gdata.pl '); matching=0; end -if isequal(gdata.pr , data.input.physics.pr ) ; disp('ok: gdata.pr ') ; else ; disp('ERROR: gdata.pr '); matching=0; end -if isequal(gdata.pressure , data.input.physics.pressure ) ; disp('ok: gdata.pressure ') ; else ; disp('ERROR: gdata.pressure '); matching=0; end -if isequal(gdata.pscale , data.input.physics.pscale ) ; disp('ok: gdata.pscale ') ; else ; disp('ERROR: gdata.pscale '); matching=0; end -if isequal(gdata.ql , data.input.physics.ql ) ; disp('ok: gdata.ql ') ; else ; disp('ERROR: gdata.ql '); matching=0; end -if isequal(gdata.qr , data.input.physics.qr ) ; disp('ok: gdata.qr ') ; else ; disp('ERROR: gdata.qr '); matching=0; end -if isequal(gdata.rp , data.input.physics.rp ) ; disp('ok: gdata.rp ') ; else ; disp('ERROR: gdata.rp '); matching=0; end -if isequal(gdata.rq , data.input.physics.rq ) ; disp('ok: gdata.rq ') ; else ; disp('ERROR: gdata.rq '); matching=0; end -if isequal(gdata.tflux , data.output.tflux ) ; disp('ok: gdata.tflux ') ; else ; disp('ERROR: gdata.tflux '); matching=0; end -if isequal(gdata.volume , data.output.volume ) ; disp('ok: gdata.volume ') ; else ; disp('ERROR: gdata.volume '); matching=0; end - -if isequal(gdata.Nt , data.grid.Nt ) ; disp('ok: gdata.Nt ') ; else ; disp('ERROR: gdata.Nt '); matching=0; end -if isequal(gdata.Nz , data.grid.Nz ) ; disp('ok: gdata.Nz ') ; else ; disp('ERROR: gdata.Nz '); matching=0; end -if isequal(gdata.Ntz , data.grid.Ntz ) ; disp('ok: gdata.Ntz ') ; else ; disp('ERROR: gdata.Ntz '); matching=0; end -if isequal(gdata.Rij , data.grid.Rij ) ; disp('ok: gdata.Rij ') ; else ; disp('ERROR: gdata.Rij '); matching=0; end -if isequal(gdata.Zij , data.grid.Zij ) ; disp('ok: gdata.Zij ') ; else ; disp('ERROR: gdata.Zij '); matching=0; end -if isequal(gdata.sg , data.grid.sg ) ; disp('ok: gdata.sg ') ; else ; disp('ERROR: gdata.sg '); matching=0; end -if isequal(gdata.BR , data.grid.BR ) ; disp('ok: gdata.BR ') ; else ; disp('ERROR: gdata.BR '); matching=0; end -if isequal(gdata.Bp , data.grid.Bp ) ; disp('ok: gdata.Bp ') ; else ; disp('ERROR: gdata.Bp '); matching=0; end -if isequal(gdata.BZ , data.grid.BZ ) ; disp('ok: gdata.BZ ') ; else ; disp('ERROR: gdata.BZ '); matching=0; end - -% data on rotational transform from .ext.sp.t.0001.dat and so on -if isequal(idata.Bnc , data.output.Bnc ) ; disp('ok: idata.Bnc ') ; else ; disp('ERROR: idata.Bnc '); matching=0; end -if isequal(idata.Bns , data.output.Bns ) ; disp('ok: idata.Bns ') ; else ; disp('ERROR: idata.Bns '); matching=0; end -if isequal(idata.Btemn , data.output.Btemn ) ; disp('ok: idata.Btemn ') ; else ; disp('ERROR: idata.Btemn '); matching=0; end -if isequal(idata.Btomn , data.output.Btomn ) ; disp('ok: idata.Btomn ') ; else ; disp('ERROR: idata.Btomn '); matching=0; end -if isequal(idata.Bzemn , data.output.Bzemn ) ; disp('ok: idata.Bzemn ') ; else ; disp('ERROR: idata.Bzemn '); matching=0; end -if isequal(idata.Bzomn , data.output.Bzomn ) ; disp('ok: idata.Bzomn ') ; else ; disp('ERROR: idata.Bzomn '); matching=0; end -if isequal(idata.ForceErr , data.output.ForceErr ) ; disp('ok: idata.ForceErr ') ; else ; disp('ERROR: idata.ForceErr '); matching=0; end -if isequal(idata.Igeometry , data.input.physics.Igeometry ) ; disp('ok: idata.Igeometry ') ; else ; disp('ERROR: idata.Igeometry '); matching=0; end -if isequal(idata.Istellsym , data.input.physics.Istellsym ) ; disp('ok: idata.Istellsym ') ; else ; disp('ERROR: idata.Istellsym '); matching=0; end -if isequal(idata.Ladiabatic , data.input.physics.Ladiabatic ) ; disp('ok: idata.Ladiabatic ') ; else ; disp('ERROR: idata.Ladiabatic '); matching=0; end -if isequal(idata.Lconstraint , data.input.physics.Lconstraint ) ; disp('ok: idata.Lconstraint') ; else ; disp('ERROR: idata.Lconstraint'); matching=0; end -if isequal(idata.Lfreebound , data.input.physics.Lfreebound ) ; disp('ok: idata.Lfreebound ') ; else ; disp('ERROR: idata.Lfreebound '); matching=0; end -if isequal(idata.Lperturbed , data.input.diagnostics.Lperturbed) ; disp('ok: idata.Lperturbed ') ; else ; disp('ERROR: idata.Lperturbed '); matching=0; end -if isequal(idata.Lrad , data.input.physics.Lrad ) ; disp('ok: idata.Lrad ') ; else ; disp('ERROR: idata.Lrad '); matching=0; end -if isequal(idata.Mpol , data.input.physics.Mpol ) ; disp('ok: idata.Mpol ') ; else ; disp('ERROR: idata.Mpol '); matching=0; end -if isequal(idata.Mrad , data.output.Mrad ) ; disp('ok: idata.Mrad ') ; else ; disp('ERROR: idata.Mrad '); matching=0; end -if isequal(idata.Mvol , data.output.Mvol ) ; disp('ok: idata.Mvol ') ; else ; disp('ERROR: idata.Mvol '); matching=0; end -if isequal(idata.Nfp , data.input.physics.Nfp ) ; disp('ok: idata.Nfp ') ; else ; disp('ERROR: idata.Nfp '); matching=0; end -if isequal(idata.Ntor , data.input.physics.Ntor ) ; disp('ok: idata.Ntor ') ; else ; disp('ERROR: idata.Ntor '); matching=0; end -if isequal(idata.Nvol , data.input.physics.Nvol ) ; disp('ok: idata.Nvol ') ; else ; disp('ERROR: idata.Nvol '); matching=0; end -if isequal(idata.Rbc , data.output.Rbc ) ; disp('ok: idata.Rbc ') ; else ; disp('ERROR: idata.Rbc '); matching=0; end -if isequal(idata.Rbs , data.output.Rbs ) ; disp('ok: idata.Rbs ') ; else ; disp('ERROR: idata.Rbs '); matching=0; end -if isequal(idata.TT , data.output.TT ) ; disp('ok: idata.TT ') ; else ; disp('ERROR: idata.TT '); matching=0; end -if isequal(idata.Vnc , data.output.Vnc ) ; disp('ok: idata.Vnc ') ; else ; disp('ERROR: idata.Vnc '); matching=0; end -if isequal(idata.Vns , data.output.Vns ) ; disp('ok: idata.Vns ') ; else ; disp('ERROR: idata.Vns '); matching=0; end -if isequal(idata.Zbc , data.output.Zbc ) ; disp('ok: idata.Zbc ') ; else ; disp('ERROR: idata.Zbc '); matching=0; end -if isequal(idata.Zbs , data.output.Zbs ) ; disp('ok: idata.Zbs ') ; else ; disp('ERROR: idata.Zbs '); matching=0; end -if isequal(idata.adiabatic , data.output.adiabatic ) ; disp('ok: idata.adiabatic ') ; else ; disp('ERROR: idata.adiabatic '); matching=0; end -if isequal(idata.curpol , data.input.physics.curpol ) ; disp('ok: idata.curpol ') ; else ; disp('ERROR: idata.curpol '); matching=0; end -if isequal(idata.curtor , data.input.physics.curtor ) ; disp('ok: idata.curtor ') ; else ; disp('ERROR: idata.curtor '); matching=0; end -if isequal(idata.dpp , data.input.diagnostics.dpp ) ; disp('ok: idata.dpp ') ; else ; disp('ERROR: idata.dpp '); matching=0; end -if isequal(idata.dqq , data.input.diagnostics.dqq ) ; disp('ok: idata.dqq ') ; else ; disp('ERROR: idata.dqq '); matching=0; end -if isequal(idata.forcetol , data.input.global.forcetol ) ; disp('ok: idata.forcetol ') ; else ; disp('ERROR: idata.forcetol '); matching=0; end -if isequal(idata.gamma , data.input.physics.gamma ) ; disp('ok: idata.gamma ') ; else ; disp('ERROR: idata.gamma '); matching=0; end -if isequal(idata.helicity , data.output.helicity ) ; disp('ok: idata.helicity ') ; else ; disp('ERROR: idata.helicity '); matching=0; end -if isequal(idata.im , data.output.im ) ; disp('ok: idata.im ') ; else ; disp('ERROR: idata.im '); matching=0; end -if isequal(idata.in , data.output.in ) ; disp('ok: idata.in ') ; else ; disp('ERROR: idata.in '); matching=0; end -if isequal(idata.lmns , data.output.lmns ) ; disp('ok: idata.lmns ') ; else ; disp('ERROR: idata.lmns '); matching=0; end -if isequal(idata.lp , data.input.physics.lp ) ; disp('ok: idata.lp ') ; else ; disp('ERROR: idata.lp '); matching=0; end -if isequal(idata.lq , data.input.physics.lq ) ; disp('ok: idata.lq ') ; else ; disp('ERROR: idata.lq '); matching=0; end -if isequal(idata.mn , data.output.mn ) ; disp('ok: idata.mn ') ; else ; disp('ERROR: idata.mn '); matching=0; end -if isequal(idata.mu , data.output.mu ) ; disp('ok: idata.mu ') ; else ; disp('ERROR: idata.mu '); matching=0; end -if isequal(idata.mupfits , data.input.physics.mupfits ) ; disp('ok: idata.mupfits ') ; else ; disp('ERROR: idata.mupfits '); matching=0; end -if isequal(idata.mupftol , data.input.physics.mupftol ) ; disp('ok: idata.mupftol ') ; else ; disp('ERROR: idata.mupftol '); matching=0; end -if isequal(idata.oita , data.input.physics.oita ) ; disp('ok: idata.oita ') ; else ; disp('ERROR: idata.oita '); matching=0; end -if isequal(idata.pflux , data.output.pflux ) ; disp('ok: idata.pflux ') ; else ; disp('ERROR: idata.pflux '); matching=0; end -if isequal(idata.phiedge , data.input.physics.phiedge ) ; disp('ok: idata.phiedge ') ; else ; disp('ERROR: idata.phiedge '); matching=0; end -if isequal(idata.pl , data.input.physics.pl ) ; disp('ok: idata.pl ') ; else ; disp('ERROR: idata.pl '); matching=0; end -if isequal(idata.pr , data.input.physics.pr ) ; disp('ok: idata.pr ') ; else ; disp('ERROR: idata.pr '); matching=0; end -if isequal(idata.pressure , data.input.physics.pressure ) ; disp('ok: idata.pressure ') ; else ; disp('ERROR: idata.pressure '); matching=0; end -if isequal(idata.pscale , data.input.physics.pscale ) ; disp('ok: idata.pscale ') ; else ; disp('ERROR: idata.pscale '); matching=0; end -if isequal(idata.ql , data.input.physics.ql ) ; disp('ok: idata.ql ') ; else ; disp('ERROR: idata.ql '); matching=0; end -if isequal(idata.qr , data.input.physics.qr ) ; disp('ok: idata.qr ') ; else ; disp('ERROR: idata.qr '); matching=0; end -if isequal(idata.rp , data.input.physics.rp ) ; disp('ok: idata.rp ') ; else ; disp('ERROR: idata.rp '); matching=0; end -if isequal(idata.rq , data.input.physics.rq ) ; disp('ok: idata.rq ') ; else ; disp('ERROR: idata.rq '); matching=0; end -if isequal(idata.tflux , data.output.tflux ) ; disp('ok: idata.tflux ') ; else ; disp('ERROR: idata.tflux '); matching=0; end -if isequal(idata.volume , data.output.volume ) ; disp('ok: idata.volume ') ; else ; disp('ERROR: idata.volume '); matching=0; end - -if isequal(idata.iota , data.transform.fiota(:,2) ) ; disp('ok: idata.iota ') ; else ; disp('ERROR: idata.iota '); matching=0; end -if isequal(idata.sarr , data.transform.fiota(:,1)' ) ; disp('ok: idata.sarr ') ; else ; disp('ERROR: idata.sarr '); matching=0; end - -% pdata from field line tracing; from ".ext.sp.P.xxxx.dat" files -if isequal(pdata.Bnc , data.output.Bnc ) ; disp('ok: pdata.Bnc ') ; else ; disp('ERROR: pdata.Bnc '); matching=0; end -if isequal(pdata.Bns , data.output.Bns ) ; disp('ok: pdata.Bns ') ; else ; disp('ERROR: pdata.Bns '); matching=0; end -if isequal(pdata.Btemn , data.output.Btemn ) ; disp('ok: pdata.Btemn ') ; else ; disp('ERROR: pdata.Btemn '); matching=0; end -if isequal(pdata.Btomn , data.output.Btomn ) ; disp('ok: pdata.Btomn ') ; else ; disp('ERROR: pdata.Btomn '); matching=0; end -if isequal(pdata.Bzemn , data.output.Bzemn ) ; disp('ok: pdata.Bzemn ') ; else ; disp('ERROR: pdata.Bzemn '); matching=0; end -if isequal(pdata.Bzomn , data.output.Bzomn ) ; disp('ok: pdata.Bzomn ') ; else ; disp('ERROR: pdata.Bzomn '); matching=0; end -if isequal(pdata.ForceErr , data.output.ForceErr ) ; disp('ok: pdata.ForceErr ') ; else ; disp('ERROR: pdata.ForceErr '); matching=0; end -if isequal(pdata.Igeometry , data.input.physics.Igeometry ) ; disp('ok: pdata.Igeometry ') ; else ; disp('ERROR: pdata.Igeometry '); matching=0; end -if isequal(pdata.Istellsym , data.input.physics.Istellsym ) ; disp('ok: pdata.Istellsym ') ; else ; disp('ERROR: pdata.Istellsym '); matching=0; end -if isequal(pdata.Ladiabatic , data.input.physics.Ladiabatic ) ; disp('ok: pdata.Ladiabatic ') ; else ; disp('ERROR: pdata.Ladiabatic '); matching=0; end -if isequal(pdata.Lconstraint , data.input.physics.Lconstraint ) ; disp('ok: pdata.Lconstraint') ; else ; disp('ERROR: pdata.Lconstraint'); matching=0; end -if isequal(pdata.Lfreebound , data.input.physics.Lfreebound ) ; disp('ok: pdata.Lfreebound ') ; else ; disp('ERROR: pdata.Lfreebound '); matching=0; end -if isequal(pdata.Lperturbed , data.input.diagnostics.Lperturbed) ; disp('ok: pdata.Lperturbed ') ; else ; disp('ERROR: pdata.Lperturbed '); matching=0; end -if isequal(pdata.Lrad , data.input.physics.Lrad ) ; disp('ok: pdata.Lrad ') ; else ; disp('ERROR: pdata.Lrad '); matching=0; end -if isequal(pdata.Mpol , data.input.physics.Mpol ) ; disp('ok: pdata.Mpol ') ; else ; disp('ERROR: pdata.Mpol '); matching=0; end -if isequal(pdata.Mrad , data.output.Mrad ) ; disp('ok: pdata.Mrad ') ; else ; disp('ERROR: pdata.Mrad '); matching=0; end -if isequal(pdata.Mvol , data.output.Mvol ) ; disp('ok: pdata.Mvol ') ; else ; disp('ERROR: pdata.Mvol '); matching=0; end -if isequal(pdata.Nfp , data.input.physics.Nfp ) ; disp('ok: pdata.Nfp ') ; else ; disp('ERROR: pdata.Nfp '); matching=0; end -if isequal(pdata.Ntor , data.input.physics.Ntor ) ; disp('ok: pdata.Ntor ') ; else ; disp('ERROR: pdata.Ntor '); matching=0; end -if isequal(pdata.Nvol , data.input.physics.Nvol ) ; disp('ok: pdata.Nvol ') ; else ; disp('ERROR: pdata.Nvol '); matching=0; end -if isequal(pdata.Rbc , data.output.Rbc ) ; disp('ok: pdata.Rbc ') ; else ; disp('ERROR: pdata.Rbc '); matching=0; end -if isequal(pdata.Rbs , data.output.Rbs ) ; disp('ok: pdata.Rbs ') ; else ; disp('ERROR: pdata.Rbs '); matching=0; end -if isequal(pdata.TT , data.output.TT ) ; disp('ok: pdata.TT ') ; else ; disp('ERROR: pdata.TT '); matching=0; end -if isequal(pdata.Vnc , data.output.Vnc ) ; disp('ok: pdata.Vnc ') ; else ; disp('ERROR: pdata.Vnc '); matching=0; end -if isequal(pdata.Vns , data.output.Vns ) ; disp('ok: pdata.Vns ') ; else ; disp('ERROR: pdata.Vns '); matching=0; end -if isequal(pdata.Zbc , data.output.Zbc ) ; disp('ok: pdata.Zbc ') ; else ; disp('ERROR: pdata.Zbc '); matching=0; end -if isequal(pdata.Zbs , data.output.Zbs ) ; disp('ok: pdata.Zbs ') ; else ; disp('ERROR: pdata.Zbs '); matching=0; end -if isequal(pdata.adiabatic , data.output.adiabatic ) ; disp('ok: pdata.adiabatic ') ; else ; disp('ERROR: pdata.adiabatic '); matching=0; end -if isequal(pdata.curpol , data.input.physics.curpol ) ; disp('ok: pdata.curpol ') ; else ; disp('ERROR: pdata.curpol '); matching=0; end -if isequal(pdata.curtor , data.input.physics.curtor ) ; disp('ok: pdata.curtor ') ; else ; disp('ERROR: pdata.curtor '); matching=0; end -if isequal(pdata.dpp , data.input.diagnostics.dpp ) ; disp('ok: pdata.dpp ') ; else ; disp('ERROR: pdata.dpp '); matching=0; end -if isequal(pdata.dqq , data.input.diagnostics.dqq ) ; disp('ok: pdata.dqq ') ; else ; disp('ERROR: pdata.dqq '); matching=0; end -if isequal(pdata.forcetol , data.input.global.forcetol ) ; disp('ok: pdata.forcetol ') ; else ; disp('ERROR: pdata.forcetol '); matching=0; end -if isequal(pdata.gamma , data.input.physics.gamma ) ; disp('ok: pdata.gamma ') ; else ; disp('ERROR: pdata.gamma '); matching=0; end -if isequal(pdata.helicity , data.output.helicity ) ; disp('ok: pdata.helicity ') ; else ; disp('ERROR: pdata.helicity '); matching=0; end -if isequal(pdata.im , data.output.im ) ; disp('ok: pdata.im ') ; else ; disp('ERROR: pdata.im '); matching=0; end -if isequal(pdata.in , data.output.in ) ; disp('ok: pdata.in ') ; else ; disp('ERROR: pdata.in '); matching=0; end -if isequal(pdata.iota , data.input.physics.iota ) ; disp('ok: pdata.iota ') ; else ; disp('ERROR: pdata.iota '); matching=0; end -if isequal(pdata.lmns , data.output.lmns ) ; disp('ok: pdata.lmns ') ; else ; disp('ERROR: pdata.lmns '); matching=0; end -if isequal(pdata.lp , data.input.physics.lp ) ; disp('ok: pdata.lp ') ; else ; disp('ERROR: pdata.lp '); matching=0; end -if isequal(pdata.lq , data.input.physics.lq ) ; disp('ok: pdata.lq ') ; else ; disp('ERROR: pdata.lq '); matching=0; end -if isequal(pdata.mn , data.output.mn ) ; disp('ok: pdata.mn ') ; else ; disp('ERROR: pdata.mn '); matching=0; end -if isequal(pdata.mu , data.output.mu ) ; disp('ok: pdata.mu ') ; else ; disp('ERROR: pdata.mu '); matching=0; end -if isequal(pdata.mupfits , data.input.physics.mupfits ) ; disp('ok: pdata.mupfits ') ; else ; disp('ERROR: pdata.mupfits '); matching=0; end -if isequal(pdata.mupftol , data.input.physics.mupftol ) ; disp('ok: pdata.mupftol ') ; else ; disp('ERROR: pdata.mupftol '); matching=0; end -if isequal(pdata.oita , data.input.physics.oita ) ; disp('ok: pdata.oita ') ; else ; disp('ERROR: pdata.oita '); matching=0; end -if isequal(pdata.pflux , data.output.pflux ) ; disp('ok: pdata.pflux ') ; else ; disp('ERROR: pdata.pflux '); matching=0; end -if isequal(pdata.phiedge , data.input.physics.phiedge ) ; disp('ok: pdata.phiedge ') ; else ; disp('ERROR: pdata.phiedge '); matching=0; end -if isequal(pdata.pl , data.input.physics.pl ) ; disp('ok: pdata.pl ') ; else ; disp('ERROR: pdata.pl '); matching=0; end -if isequal(pdata.pr , data.input.physics.pr ) ; disp('ok: pdata.pr ') ; else ; disp('ERROR: pdata.pr '); matching=0; end -if isequal(pdata.pressure , data.input.physics.pressure ) ; disp('ok: pdata.pressure ') ; else ; disp('ERROR: pdata.pressure '); matching=0; end -if isequal(pdata.pscale , data.input.physics.pscale ) ; disp('ok: pdata.pscale ') ; else ; disp('ERROR: pdata.pscale '); matching=0; end -if isequal(pdata.ql , data.input.physics.ql ) ; disp('ok: pdata.ql ') ; else ; disp('ERROR: pdata.ql '); matching=0; end -if isequal(pdata.qr , data.input.physics.qr ) ; disp('ok: pdata.qr ') ; else ; disp('ERROR: pdata.qr '); matching=0; end -if isequal(pdata.rp , data.input.physics.rp ) ; disp('ok: pdata.rp ') ; else ; disp('ERROR: pdata.rp '); matching=0; end -if isequal(pdata.rq , data.input.physics.rq ) ; disp('ok: pdata.rq ') ; else ; disp('ERROR: pdata.rq '); matching=0; end -if isequal(pdata.tflux , data.output.tflux ) ; disp('ok: pdata.tflux ') ; else ; disp('ERROR: pdata.tflux '); matching=0; end -if isequal(pdata.volume , data.output.volume ) ; disp('ok: pdata.volume ') ; else ; disp('ERROR: pdata.volume '); matching=0; end - -if isequal(pdata.npoinc , data.input.diagnostics.nPpts ) ; disp('ok: pdata.npoinc ') ; else ; disp('ERROR: pdata.npoinc '); matching=0; end -if isequal(pdata.th_lines , data.poincare.t ) ; disp('ok: pdata.th_lines ') ; else ; disp('ERROR: pdata.th_lines '); matching=0; end -if isequal(pdata.rho_lines , data.poincare.rho ) ; disp('ok: pdata.rho_lines ') ; else ; disp('ERROR: pdata.rho_lines '); matching=0; end -if isequal(pdata.R_lines , data.poincare.R ) ; disp('ok: pdata.R_lines ') ; else ; disp('ERROR: pdata.R_lines '); matching=0; end -if isequal(pdata.Z_lines , data.poincare.Z ) ; disp('ok: pdata.npoinc ') ; else ; disp('ERROR: pdata.Z_lines '); matching=0; end - -if (matching == 0) - disp('Not maching :(') -else - disp('Matching :)') -end - -end - diff --git a/Utilities/matlabtools/write_spec_Bxyz.m b/Utilities/matlabtools/write_spec_Bxyz.m deleted file mode 100644 index cbd82530..00000000 --- a/Utilities/matlabtools/write_spec_Bxyz.m +++ /dev/null @@ -1,32 +0,0 @@ -function write_spec_Bxyz( data, filename ) - -nt = length(data.theta); -nz = length(data.phi); - -fid = fopen( filename, 'w' ); - -fprintf( fid, 'theta phi x y z Bx By Bz\n') - - -for it = 1:nt - for iz = 1:nz - - theta = data.theta(it); - phi = data.phi(iz); - x = data.x(1,it,iz); - y = data.y(1,it,iz); - z = data.z(1,it,iz); - Bx = data.Bx(1,it,iz); - By = data.By(1,it,iz); - Bz = data.Bz(1,it,iz); - - - %fprintf(fid,'%s', A{i}); - fprintf( fid, '%12.8E %12.8E %+12.8E %+12.8E %+12.8E %+12.8E %+12.8E %+12.8E\n', ... - theta, phi, x, y, z, Bx, By, Bz) - - end -end - -fclose(fid); -end diff --git a/Utilities/matlabtools/write_spec_input_L0.m b/Utilities/matlabtools/write_spec_input_L0.m deleted file mode 100644 index bacc7797..00000000 --- a/Utilities/matlabtools/write_spec_input_L0.m +++ /dev/null @@ -1,113 +0,0 @@ -function write_spec_input_L0(template,inputname,Nvol,phiedge,tfl,pfl,mu,pre,lrad,nptr) - -% -% WRITE_SPEC_INPUT_L0( TEMPLATE, INPUTNAME, NVOL, PHIEDGE, TFL, PFL, MU, PRE, LRAD, NPTR ) -% ======================================================================================== -% -% Writes spec input file from template with constraints corresponding to Lconstraint=0 (tfl,pfl,mu) -% -% INPUT -% ----- -% -template : template input file name with .sp format -% -inputname : new input file name with .sp format -% -Nvol : number of volumes -% -tfl : toroidal flux enclosed by each interface -% -pfl : poloidal flux enclosed by each interface -% -mu : beltrami parameter in each volume -% -pre : pressure in each volume -% -lrad : radial resolution in each volume -% -nptr : number of Poincare trajectories in each volume -% -% written by J.Loizu (2016) - -nlmod = 8; - -sref{1} = ' pressure ='; -sref{2} = ' tflux ='; -sref{3} = ' pflux ='; -sref{4} = ' mu ='; -sref{5} = ' Lrad ='; -sref{6} = ' nPtrj ='; -sref{7} = ' phiedge ='; -sref{8} = ' Nvol ='; - -snew1 = sref{1}; -snew2 = sref{2}; -snew3 = sref{3}; -snew4 = sref{4}; -snew5 = sref{5}; -snew6 = sref{6}; -snew7 = strcat(sref{7},{' '}, num2str(phiedge)); -snew8 = strcat(sref{8}, {' '}, num2str(Nvol)); - -for i=1:Nvol - snew1 = strcat(snew1,{' '},num2str(pre(i),16), {' '}); - snew2 = strcat(snew2,{' '},num2str(tfl(i),16), {' '}); - snew3 = strcat(snew3,{' '},num2str(pfl(i),16), {' '}); - snew4 = strcat(snew4,{' '},num2str(mu(i),16), {' '}); - snew5 = strcat(snew5,{' '},num2str(lrad(i),16),{' '}); - snew6 = strcat(snew6,{' '},num2str(nptr(i),16),{' '}); -end - -snew{1} = snew1{1}; -snew{2} = snew2{1}; -snew{3} = snew3{1}; -snew{4} = snew4{1}; -snew{5} = snew5{1}; -snew{6} = snew6{1}; -snew{7} = snew7{1}; -snew{8} = snew8{1}; - -% Open template file for reading - -fid = fopen(template,'rt'); - -tline = fgetl(fid); - -count = 1; - -lnum = zeros(1,nlmod); - -A{1} = tline; - - -% Read template file, copy lines in A, and identify reference lines - -while ischar(tline) - for i=1:nlmod - if(size(tline)>=size(sref{i})) - if(strcmp(tline(1:length(sref{i})),sref{i})==1) - lnum(i) = count; - end - end - end - tline = fgetl(fid); - count = count + 1; - A{count} = tline; -end - -fclose(fid); - - -% Modify cell A at reference lines - -for i=1:nlmod - A{lnum(i)} = sprintf('%s',snew{i}); -end - -% Write cell A into new input file - -fid = fopen(inputname, 'w'); - -for i = 1:numel(A) - if(A{i+1} == -1) - fprintf(fid,'%s', A{i}); - break - else - fprintf(fid,'%s\n', A{i}); - end -end - -fclose(fid); - - diff --git a/Utilities/matlabtools/write_spec_input_L1.m b/Utilities/matlabtools/write_spec_input_L1.m deleted file mode 100644 index c4d6fa71..00000000 --- a/Utilities/matlabtools/write_spec_input_L1.m +++ /dev/null @@ -1,125 +0,0 @@ -function write_spec_input_L1(template, inputname, Nvol, tfl, pfl, iota, oita, phit_edge, pre, mu, lrad, nptr) - -% -% WRITE_SPEC_INPUT_L1( TEMPLATE, INPUTNAME, NVOL, TFL, PFL, IOTA, OITA, PHIT_EDGE, PRE, MU, LRAD, NPTR ) -% ====================================================================================================== -% -% Writes spec input file from template with constraints corresponding to -% Lconstraint=1 (tfl,iota,oita) -% -% INPUT -% ----- -% -template : template input file name with .sp format -% -inputname : new input file name with .sp format -% -Nvol : number of volumes -% -tfl : toroidal flux enclosed by each interface -% -pfl : poloidal flux enclosed by each interface -% -iota : rotational transform on the inner side of the interface -% -oita : rotational transform on the outer side of the interface -% -phit_edge : total toroidal flux -% -pre : pressure in each volume -% -mu : Lagrange multiplier in each volume -% -lrad : radial resolution in each volume -% -nptr : number of Poincare trajectories in each volume -% -% written by A.Baillod (2019) - -nlmod = 10; - -sref{1} = ' pressure ='; -sref{2} = ' tflux ='; -sref{3} = ' iota ='; -sref{4} = ' oita ='; -sref{5} = ' Lrad ='; -sref{6} = ' nPtrj ='; -sref{7} = ' Nvol ='; -sref{8} = ' pflux ='; -sref{9} = ' mu ='; -sref{10} = ' phiedge ='; - -snew1 = sref{1}; -snew2 = sref{2}; -snew3 = strcat(sref{3}, {' '}, num2str(iota(1), 16), {' '}); -snew4 = strcat(sref{4}, {' '}, num2str(oita(1), 16), {' '}); -snew5 = sref{5}; -snew6 = sref{6}; -snew7 = strcat(sref{7},{' '},num2str(Nvol), {' '}); -snew8 = sref{8}; -snew9 = sref{9}; -snew10 = strcat(sref{10}, {' '}, num2str(phit_edge), {' '}); - -for i=1:Nvol - snew1 = strcat(snew1, {' '},num2str(pre(i) ,16), {' '}); - snew2 = strcat(snew2, {' '},num2str(tfl(i) ,16), {' '}); - snew3 = strcat(snew3, {' '},num2str(iota(i),16), {' '}); - snew4 = strcat(snew4, {' '},num2str(oita(i),16), {' '}); - snew5 = strcat(snew5, {' '},num2str(lrad(i),16), {' '}); - snew6 = strcat(snew6, {' '},num2str(nptr(i),16), {' '}); - snew8 = strcat(snew8, {' '},num2str(pfl(i) ,16), {' '}); - snew9 = strcat(snew9, {' '},num2str(mu(i) ,16), {' '}); -end - -snew{1} = snew1{1}; -snew{2} = snew2{1}; -snew{3} = snew3{1}; -snew{4} = snew4{1}; -snew{5} = snew5{1}; -snew{6} = snew6{1}; -snew{7} = snew7{1}; -snew{8} = snew8{1}; -snew{9} = snew9{1}; -snew{10} = snew10{1}; - - - -% Open template file for reading - -fid = fopen(template,'rt'); - -tline = fgetl(fid); - -count = 1; - -lnum = zeros(1,nlmod); - -A{1} = tline; - - -% Read template file, copy lines in A, and identify reference lines - -while ischar(tline) - for i=1:nlmod - if(size(tline)>=size(sref{i})) - if(strcmp(tline(1:length(sref{i})),sref{i})==1) - lnum(i) = count; - end - end - end - tline = fgetl(fid); - count = count + 1; - A{count} = tline; -end - -fclose(fid); - - -% Modify cell A at reference lines - -for i=1:nlmod - A{lnum(i)} = sprintf('%s',snew{i}); -end - -% Write cell A into new input file - -fid = fopen(inputname, 'w'); - -for i = 1:numel(A) - if(A{i+1} == -1) - fprintf(fid,'%s', A{i}); - break - else - fprintf(fid,'%s\n', A{i}); - end -end - -fclose(fid); diff --git a/Utilities/matlabtools/write_spec_input_L3.m b/Utilities/matlabtools/write_spec_input_L3.m deleted file mode 100644 index 7a214914..00000000 --- a/Utilities/matlabtools/write_spec_input_L3.m +++ /dev/null @@ -1,131 +0,0 @@ -function write_spec_input_L3(template, inputname, Nvol, Lfreebound, tfl, phit_edge, ... - pflux, Ivol, Isurf, curtor, pressure, lrad, nptr, Linitialize) - -% -% WRITE_SPEC_INPUT_L3( TEMPLATE, INPUTNAME, NVOL, LFREEBOUND, TFL, PHIT_EDGE, ... ) -% ================================================================================= -% -% Writes spec input file from template with constraints corresponding to -% Lconstraint=1 (tfl,iota,oita) -% -% INPUT -% ----- -% -template : template input file name with .sp format -% -inputname : new input file name with .sp format -% -Nvol : number of volume -% -Lfreebound : Flag for free boundary -% -tfl : toroidal flux enclosed by each interface -% -phit_edge : total toroidal flux -% -pflux : Poloidal flux (used as guess) -% -Ivol : volume current in each volume -% -Isurf : surface current at each interface -% -curtor : Total plasma current. only relevant if Lfreebound=1 -% -pressure : pressure in each volume -% -lrad : radial resolution in each volume -% -nptr : number of Poincare trajectories in each volume -% -Linitialize: How to initialize interfaces -% -% written by A.Baillod (2019) - -Mvol = Nvol+Lfreebound; - -nlmod = 11; - -sref{1} = ' pressure ='; -sref{2} = ' tflux ='; -sref{3} = ' Lrad ='; -sref{4} = ' nPtrj ='; -sref{5} = ' Nvol ='; -sref{6} = ' phiedge ='; -sref{7} = ' Ivolume ='; -sref{8} = ' Isurf ='; -sref{9} = ' curtor ='; -sref{10} = ' pflux ='; -sref{11} = ' Linitialize ='; - -snew1 = sref{1}; -snew2 = sref{2}; -snew3 = sref{3}; -snew4 = sref{4}; -snew5 = strcat(sref{5}, {' '}, num2str(Nvol) , {' '}); -snew6 = strcat(sref{6}, {' '}, num2str(phit_edge), {' '}); -snew7 = sref{7}; -snew8 = sref{8}; -snew9 = strcat(sref{9}, {' '}, num2str(curtor), {' '}); -snew10 = sref{10}; -snew11 = strcat(sref{11}, {' '}, num2str(Linitialize), {' '}); - -for i=1:Mvol - snew1 = strcat(snew1, {' '},num2str(pressure(i) ,16), {' '}); - snew2 = strcat(snew2, {' '},num2str(tfl(i) ,16), {' '}); - snew3 = strcat(snew3, {' '},num2str(lrad(i) ,16), {' '}); - snew4 = strcat(snew4, {' '},num2str(nptr(i) ,16), {' '}); - snew7 = strcat(snew7, {' '},num2str(Ivol(i) ,16), {' '}); - snew8 = strcat(snew8, {' '},num2str(Isurf(i) ,16), {' '}); - snew10 = strcat(snew10, {' '},num2str(pflux(i) ,16), {' '}); -end - -snew{1} = snew1{1}; -snew{2} = snew2{1}; -snew{3} = snew3{1}; -snew{4} = snew4{1}; -snew{5} = snew5{1}; -snew{6} = snew6{1}; -snew{7} = snew7{1}; -snew{8} = snew8{1}; -snew{9} = snew9{1}; -snew{10} = snew10{1}; -snew{11} = snew11{1}; - - -% Open template file for reading - -fid = fopen(template,'rt'); - -tline = fgetl(fid); - -count = 1; - -lnum = zeros(1,nlmod); - -A{1} = tline; - - -% Read template file, copy lines in A, and identify reference lines - -while ischar(tline) - for i=1:nlmod - if(size(tline)>=size(sref{i})) - if(strcmp(tline(1:length(sref{i})),sref{i})==1) - lnum(i) = count; - end - end - end - tline = fgetl(fid); - count = count + 1; - A{count} = tline; -end - -fclose(fid); - - -% Modify cell A at reference lines - -for i=1:nlmod - A{lnum(i)} = sprintf('%s',snew{i}); -end - -% Write cell A into new input file - -fid = fopen(inputname, 'w'); - -for i = 1:numel(A) - if(A{i+1} == -1) - fprintf(fid,'%s', A{i}); - break - else - fprintf(fid,'%s\n', A{i}); - end -end - -fclose(fid); diff --git a/Utilities/matlabtools/write_spec_rzgrid.m b/Utilities/matlabtools/write_spec_rzgrid.m index 61f9cf5f..c4f95849 100644 --- a/Utilities/matlabtools/write_spec_rzgrid.m +++ b/Utilities/matlabtools/write_spec_rzgrid.m @@ -5,7 +5,8 @@ function write_spec_rzgrid(data, nz0,lvol,outfname) % WRITE_SPEC_RZGRID( DATA, NZ0, LVOL, OUTFNAME ) % ============================================== % -% Writes text file with grid coordinate data points R,Z on a given volume, on a toroidal plane, as two columns +% Writes text file with grid coordinate data points R,Z on a given volume, +% on a toroidal plane, as two columns % % INPUT % ----- diff --git a/out.txt b/out.txt new file mode 100644 index 00000000..42311115 --- /dev/null +++ b/out.txt @@ -0,0 +1,1801 @@ +Not searching for unused variables given on the command line. +-- The C compiler identification is GNU 9.4.0 +-- Detecting C compiler ABI info +-- Detecting C compiler ABI info - done +-- Check for working C compiler: /misc/Anaconda3/envs/spec_env/bin/mpicc - skipped +-- Detecting C compile features +-- Detecting C compile features - done +-- The CXX compiler identification is GNU 7.4.1 +-- Detecting CXX compiler ABI info +-- Detecting CXX compiler ABI info - done +-- Check for working CXX compiler: /usr/bin/c++ - skipped +-- Detecting CXX compile features +-- Detecting CXX compile features - done +-- Configuring done +-- Generating done +-- Build files have been written to: /home/abaillod/SPEC/_cmake_test_compile/build +-- The C compiler identification is GNU 9.4.0 +-- The Fortran compiler identification is GNU 9.4.0 +-- Detecting C compiler ABI info +-- Detecting C compiler ABI info - done +-- Check for working C compiler: /misc/Anaconda3/envs/spec_env/bin/mpicc - skipped +-- Detecting C compile features +-- Detecting C compile features - done +-- Detecting Fortran compiler ABI info +-- Detecting Fortran compiler ABI info - done +-- Check for working Fortran compiler: /misc/Anaconda3/envs/spec_env/bin/mpif90 - skipped +-- Found OpenMP_C: -fopenmp (found version "4.5") +-- Found OpenMP_Fortran: -fopenmp (found version "4.5") +-- Found OpenMP: TRUE (found version "4.5") +-- Looking for pthread.h +-- Looking for pthread.h - found +-- Performing Test CMAKE_HAVE_LIBC_PTHREAD +-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success +-- Found Threads: TRUE +-- Looking for pow in m +-- Looking for pow in m - found +-- compiler is mpif90 +-- Found MPI_C: /misc/Anaconda3/envs/spec_env/bin/mpicc (found version "3.1") +-- Found MPI_Fortran: /misc/Anaconda3/envs/spec_env/bin/mpif90 (found version "3.1") +-- Found MPI: TRUE (found version "3.1") +-- Looking for Fortran sgemm +-- Looking for Fortran sgemm - found +-- Found BLAS: /misc/Anaconda3/envs/spec_env/lib/libopenblas.so +-- BLAS vendor is OpenBLAS +-- Configuring done +-- Generating done +-- Build files have been written to: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/findFFTW-download +[1/9] Creating directories for 'findFFTW_download' +[2/9] Performing download step (git clone) for 'findFFTW_download' +Cloning into 'findFFTW-src'... +Already on 'master' +Your branch is up to date with 'origin/master'. +[3/9] Performing update step for 'findFFTW_download' +HEAD is now at ac78852 Merge pull request #6 from hello-adam/master +[4/9] No patch step for 'findFFTW_download' +[5/9] No configure step for 'findFFTW_download' +[6/9] No build step for 'findFFTW_download' +[7/9] No install step for 'findFFTW_download' +[8/9] No test step for 'findFFTW_download' +[9/9] Completed 'findFFTW_download' +-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") +-- Found FFTW: /misc/Anaconda3/envs/spec_env/include +-- HDF5 C compiler wrapper is unable to compile a minimal HDF5 program. +-- HDF5 Fortran compiler wrapper is unable to compile a minimal HDF5 program. +-- Found HDF5: /misc/Anaconda3/envs/spec_env/lib/libhdf5.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5_fortran.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5.so (found version "1.12.1") found components: C Fortran HL +-- HDF5 libraries found: TRUE +-- HDF5 C include directors : /misc/Anaconda3/envs/spec_env/include +-- HDF5 Fortran include directors : /misc/Anaconda3/envs/spec_env/include +-- preprocess_fortran arguments: srcs, followed by manual.f90;rzaxis.f90;packxi.f90;volume.f90;coords.f90;basefn.f90;memory.f90;metrix.f90;ma00aa.f90;matrix.f90;spsmat.f90;spsint.f90;mp00ac.f90;ma02aa.f90;packab.f90;tr00ab.f90;curent.f90;df00ab.f90;lforce.f90;intghs.f90;mtrxhs.f90;lbpol.f90;brcast.f90;dfp100.f90;dfp200.f90;dforce.f90;newton.f90;casing.f90;bnorml.f90;jo00aa.f90;pp00aa.f90;pp00ab.f90;bfield.f90;stzxyz.f90;hesian.f90;ra00aa.f90;numrec.f90;preset.f90;bndRep.f90;global.f90;inputlist.f90 +-- Got file: manual.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90 +-- Got file: rzaxis.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90 +-- Got file: packxi.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90 +-- Got file: volume.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90 +-- Got file: coords.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90 +-- Got file: basefn.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90 +-- Got file: memory.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90 +-- Got file: metrix.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90 +-- Got file: ma00aa.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90 +-- Got file: matrix.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90 +-- Got file: spsmat.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90 +-- Got file: spsint.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90 +-- Got file: mp00ac.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90 +-- Got file: ma02aa.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90 +-- Got file: packab.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90 +-- Got file: tr00ab.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90 +-- Got file: curent.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90 +-- Got file: df00ab.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90 +-- Got file: lforce.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90 +-- Got file: intghs.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90 +-- Got file: mtrxhs.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90 +-- Got file: lbpol.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90 +-- Got file: brcast.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90 +-- Got file: dfp100.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90 +-- Got file: dfp200.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90 +-- Got file: dforce.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90 +-- Got file: newton.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90 +-- Got file: casing.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90 +-- Got file: bnorml.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90 +-- Got file: jo00aa.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90 +-- Got file: pp00aa.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90 +-- Got file: pp00ab.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90 +-- Got file: bfield.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90 +-- Got file: stzxyz.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90 +-- Got file: hesian.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90 +-- Got file: ra00aa.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90 +-- Got file: numrec.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90 +-- Got file: preset.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90 +-- Got file: bndRep.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90 +-- Got file: global.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90 +-- Got file: inputlist.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90 +-- sphdf5_FILE is /home/abaillod/SPEC/src/sphdf5.f90 +-- Exit code from awk: 0 +-- preprocess_fortran arguments: sphdf5_src, followed by /home/abaillod/SPEC/src/msphdf5.f90 +-- Got file: /home/abaillod/SPEC/src/msphdf5.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 +-- sphdf5_src is /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 +-- Exit code from awk: 0 +-- preprocess_fortran arguments: XSPEC_OUT_FILE, followed by /home/abaillod/SPEC/src/mxspech.f90 +-- Got file: /home/abaillod/SPEC/src/mxspech.f90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 +-- XSPEC_OUT_FILE is /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 +-- srcs variable is /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 +-- spec linked libraries are /misc/Anaconda3/envs/spec_env/lib/libhdf5_fortran.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3f.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3l.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3_threads.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3f_threads.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3l_threads.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3_omp.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3f_omp.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3l_omp.so;/misc/Anaconda3/envs/spec_env/lib/libopenblas.so +-- spec compile options are -cpp;$<$:-ffree-line-length-none>;$<$:-fdefault-real-8>;$<$:-fbounds-check>;$<$:-fexternal-blas>;$<$:-r8> +-- spec compile definitions are SPEC_COMPILE_DEFS-NOTFOUND +-- Found PythonInterp: /misc/Anaconda3/envs/spec_env/bin/python (found version "3.10.2") +-- Found PythonLibs: /misc/Anaconda3/envs/spec_env/lib/libpython3.10.so (found version "3.10.2") +-- Found NumPy: /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include (found version "1.22.2") +-- Found F2PY: /misc/Anaconda3/envs/spec_env/bin/f2py3 (found version "1.22.2") +-- Found F90Wrap: /misc/Anaconda3/envs/spec_env/bin/f90wrap +-- Compile definitions for preprocessor are +-- preprocess_fortran arguments: fpp_files, followed by /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/manual_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/rzaxis_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packxi_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/volume_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/coords_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/basefn_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/memory_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/metrix_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma00aa_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/matrix_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsmat_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsint_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mp00ac_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma02aa_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packab_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/tr00ab_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/curent_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/df00ab_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lforce_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/intghs_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mtrxhs_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lbpol_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/brcast_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp100_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp200_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dforce_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/newton_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/casing_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bnorml_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/jo00aa_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00aa_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00ab_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bfield_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/stzxyz_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/hesian_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ra00aa_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/numrec_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/preset_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bndRep_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/global_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/inputlist_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/msphdf5_m_fpp.F90 +-- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 +-- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mxspech_m_fpp.F90 +-- Python exten suffix expansion: .cpython-310-x86_64-linux-gnu.so +-- f90_wrap_output_files: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_global_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_inputlist_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_intghs_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_msphdf5_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_newton_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_toplevel.f90 +-- f2py_module_name: _spec_f90wrapped +-- generated_module_name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/_spec_f90wrapped.cpython-310-x86_64-linux-gnu.so +-- Configuring done +-- Generating done +-- Build files have been written to: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build +[1/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/i1mach.f-pp.f +[2/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/d1mach.f-pp.f +[3/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/ilut.f-pp.f +[4/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/dcuhre.f-pp.f +[5/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/minpack.f-pp.f +[6/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/iqpack.f-pp.f +[7/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/iters.f-pp.f +[8/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/rksuite.f-pp.f +[9/200] Generating Fortran dyndep file src/CMakeFiles/spec3p.dir/Fortran.dd +[10/200] Building Fortran object src/CMakeFiles/spec3p.dir/i1mach.f.o +[11/200] Building Fortran object src/CMakeFiles/spec3p.dir/d1mach.f.o +[12/200] Building C object Utilities/python_wrapper/CMakeFiles/_f2py_runtime_library.dir/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.c.o +In file included from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1960, + from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12, + from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5, + from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.h:13, + from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.c:2: +/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] + 17 | #warning "Using deprecated NumPy API, disable it with " \ + | ^~~~~~~ +[13/200] Linking C static library build/lib/lib_f2py_runtime_library.a +[14/200] Building Fortran object src/CMakeFiles/spec3p.dir/dcuhre.f.o +/home/abaillod/SPEC/src/dcuhre.f:1633:15: + + 1633 | C "An Imbedded Family of Fully Symmetric Numerical + | 1 +Warning: missing terminating " character +/home/abaillod/SPEC/src/dcuhre.f:1634:33: + + 1634 | C Integration Rules", + | 1 +Warning: missing terminating " character +/home/abaillod/SPEC/src/dcuhre.f:1842:15: + + 1842 | C "An Imbedded Family of Fully Symmetric Numerical + | 1 +Warning: missing terminating " character +/home/abaillod/SPEC/src/dcuhre.f:1843:33: + + 1843 | C Integration Rules", + | 1 +Warning: missing terminating " character +/home/abaillod/SPEC/src/dcuhre.f:1024:72: + + 1024 | DO 190 J = 1,NDIM + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 190 at (1) +/home/abaillod/SPEC/src/dcuhre.f:1025:72: + + 1025 | DO 190 K = 1,WTLENG + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 190 at (1) +/home/abaillod/SPEC/src/dcuhre.f:1365:72: + + 1365 | DO 10 J = 1,5 + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 10 at (1) +/home/abaillod/SPEC/src/dcuhre.f:1372:72: + + 1372 | DO 20 J = 1,14 + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 20 at (1) +/home/abaillod/SPEC/src/dcuhre.f:1535:72: + + 1535 | DO 10 J = 1,5 + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 10 at (1) +/home/abaillod/SPEC/src/dcuhre.f:1542:72: + + 1542 | DO 20 J = 1,13 + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 20 at (1) +[15/200] Building Fortran object src/CMakeFiles/spec3p.dir/minpack.f.o +/home/abaillod/SPEC/src/minpack.f:208:60: + + 208 | c Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' + | 1 +Warning: missing terminating ' character +[16/200] Building Fortran object src/CMakeFiles/spec3p.dir/iqpack.f.o +/home/abaillod/SPEC/src/iqpack.f:1373:25: + + 1373 | C KAUTSKY AND ELHAY "CALCULATION OF THE WEIGHTS OF INTERPOLATORY + | 1 +Warning: missing terminating " character +/home/abaillod/SPEC/src/iqpack.f:1374:18: + + 1374 | C QUADRATURES", NUMER MATH 40 (1982) 407-422. + | 1 +Warning: missing terminating " character +/home/abaillod/SPEC/src/iqpack.f:1726:49: + + 1726 | C LO.LT.0 MEANS PRINT WEIGHTS ONLY. DON'T COMPUTE MOMENT TESTS + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iqpack.f:1875:49: + + 1875 | C LO.LT.0 MEANS PRINT WEIGHTS ONLY. DON'T COMPUTE MOMENT TESTS + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iqpack.f:746:72: + + 746 | 20 N=N+MLT(J) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 20 at (1) +/home/abaillod/SPEC/src/iqpack.f:799:72: + + 799 | 20 N=N+MLT(J) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 20 at (1) +/home/abaillod/SPEC/src/iqpack.f:1205:72: + + 1205 | DO 10 J=L,NT + | 1 +Warning: Fortran 2018 deleted feature: Shared DO termination label 10 at (1) +/home/abaillod/SPEC/src/iqpack.f:1462:72: + + 1462 | 130 D(K)=SUM + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 130 at (1) +/home/abaillod/SPEC/src/iqpack.f:1516:72: + + 1516 | 40 BJ(I)=ABI*ABI/(ABJ*ABJ-ONE) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1) +/home/abaillod/SPEC/src/iqpack.f:1521:72: + + 1521 | 60 BJ(I)=HALF + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 60 at (1) +/home/abaillod/SPEC/src/iqpack.f:1530:72: + + 1530 | 80 BJ(I)=I*(I+AB)/(FOUR*(I+ALPHA)**2-ONE) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 80 at (1) +/home/abaillod/SPEC/src/iqpack.f:1543:72: + + 1543 | 100 BJ(I)=FOUR*I*(I+ALPHA)*(I+BETA)*(I+AB)/((ABI-ONE)*ABI) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 100 at (1) +/home/abaillod/SPEC/src/iqpack.f:1548:72: + + 1548 | 120 BJ(I)=I*(I+ALPHA) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 120 at (1) +/home/abaillod/SPEC/src/iqpack.f:1553:72: + + 1553 | 140 BJ(I)=(I+ALPHA*MOD(I,2))/TWO + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1) +/home/abaillod/SPEC/src/iqpack.f:1564:72: + + 1564 | 160 AJ(I)=-AJ(I)/ABTI/(ABTI-TWO) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 160 at (1) +/home/abaillod/SPEC/src/iqpack.f:1568:72: + + 1568 | 1 (ABTI**2)*(AB+I)/(ABTI+ONE) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 165 at (1) +/home/abaillod/SPEC/src/iqpack.f:1600:72: + + 1600 | 10 W(K)=ZERO + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 10 at (1) +/home/abaillod/SPEC/src/iqpack.f:1607:72: + + 1607 | 50 W(K)=TWO/(K+ALS) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 50 at (1) +/home/abaillod/SPEC/src/iqpack.f:1611:72: + + 1611 | 70 W(K)=W(K-2)*(K-TWO)/(K-ONE) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 70 at (1) +/home/abaillod/SPEC/src/iqpack.f:1615:72: + + 1615 | 90 W(K)=W(K-2)*(K-TWO)/(TWO*ALPHA+K) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 90 at (1) +/home/abaillod/SPEC/src/iqpack.f:1626:72: + + 1626 | 110 TMPA=TMPA*(ALPHA+JA)/(ALS+JA) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 110 at (1) +/home/abaillod/SPEC/src/iqpack.f:1628:72: + + 1628 | 120 TMPA=TMPA*(BETA+JB)/(ALS+2*I+JB) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 120 at (1) +/home/abaillod/SPEC/src/iqpack.f:1637:72: + + 1637 | 140 TMPB=TMPB*(ALPHA+I)/(ALS+I) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1) +/home/abaillod/SPEC/src/iqpack.f:1639:72: + + 1639 | 150 W(K)=SUM*W(1) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1) +/home/abaillod/SPEC/src/iqpack.f:1643:72: + + 1643 | 170 W(K)=(ALPHA+K-ONE)*W(K-1) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 170 at (1) +/home/abaillod/SPEC/src/iqpack.f:1647:72: + + 1647 | 190 W(K)=W(K-2)*(ALPHA+K-TWO)/TWO + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 190 at (1) +/home/abaillod/SPEC/src/iqpack.f:1651:72: + + 1651 | 210 W(K)=-W(K-1)*(ALPHA+K-ONE)/(ALPHA+BETA+K) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 210 at (1) +/home/abaillod/SPEC/src/iqpack.f:2103:72: + + 2103 | 160 TMP=TMP*SLP + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 160 at (1) +/home/abaillod/SPEC/src/iqpack.f:2205:72: + + 2205 | 20 W(K)=ABS(T(K))**ALPHA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 20 at (1) +/home/abaillod/SPEC/src/iqpack.f:2208:72: + + 2208 | 40 W(K)=ONE + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1) +/home/abaillod/SPEC/src/iqpack.f:2211:72: + + 2211 | 60 W(K)=ONE/SQRT((ONE-T(K))*(ONE+T(K))) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 60 at (1) +/home/abaillod/SPEC/src/iqpack.f:2215:72: + + 2215 | 80 W(K)=((ONE-T(K))*(ONE+T(K)))**ALPHA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 80 at (1) +/home/abaillod/SPEC/src/iqpack.f:2218:72: + + 2218 | 100 W(K)=ONE + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 100 at (1) +/home/abaillod/SPEC/src/iqpack.f:2221:72: + + 2221 | 110 W(K)=W(K)*(ONE-T(K))**ALPHA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 110 at (1) +/home/abaillod/SPEC/src/iqpack.f:2225:72: + + 2225 | 120 W(K)=W(K)*(ONE+T(K))**BETA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 120 at (1) +/home/abaillod/SPEC/src/iqpack.f:2229:72: + + 2229 | 140 W(K)=EXP(-T(K)) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1) +/home/abaillod/SPEC/src/iqpack.f:2232:72: + + 2232 | 150 W(K)=W(K)*T(K)**ALPHA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1) +/home/abaillod/SPEC/src/iqpack.f:2236:72: + + 2236 | 170 W(K)=EXP(-T(K)**2) + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 170 at (1) +/home/abaillod/SPEC/src/iqpack.f:2239:72: + + 2239 | 180 W(K)=W(K)*ABS(T(K))**ALPHA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 180 at (1) +/home/abaillod/SPEC/src/iqpack.f:2243:72: + + 2243 | 200 W(K)=ONE + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 200 at (1) +/home/abaillod/SPEC/src/iqpack.f:2246:72: + + 2246 | 210 W(K)=W(K)*T(K)**ALPHA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 210 at (1) +/home/abaillod/SPEC/src/iqpack.f:2250:72: + + 2250 | 220 W(K)=W(K)*(ONE+T(K))**BETA + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 220 at (1) +/home/abaillod/SPEC/src/iqpack.f:2321:72: + + 2321 | 60 Z(I)=C*Z(I)-S*F + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 60 at (1) +[17/200] Building Fortran object src/CMakeFiles/spec3p.dir/rksuite.f.o +/home/abaillod/SPEC/src/rksuite.f:1777:67: + + 1777 | C REQEST(1:1) = `S' or `s'- compute approximate `S'olution + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/rksuite.f:1780:47: + + 1780 | C `D'erivative of the solution only. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/rksuite.f:1781:55: + + 1781 | C = `B' or `b'- compute `B'oth approximate solution + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/rksuite.f:3184:54: + + 3184 | C REQEST(1:1) = `S' or `s'- compute approximate `S'olution only. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/rksuite.f:3185:60: + + 3185 | C = `D' or `d'- compute approximate first `D'erivative + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/rksuite.f:3187:42: + + 3187 | C = `B' or `b'- compute `B'oth approximate solution and + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/rksuite.f:4619:39: + + 4619 | C in the left half plane -- there won't be a stability restriction + | 1 +Warning: missing terminating ' character +[18/200] Building Fortran object src/CMakeFiles/spec3p.dir/ilut.f.o +/home/abaillod/SPEC/src/ilut.f:701:17: + + 701 | c exchange w's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/ilut.f:806:11: + + 806 | c tion ILU's such MILU. These are defined through the parameter alph * + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/ilut.f:1409:17: + + 1409 | c exchange w's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/ilut.f:1846:33: + + 1846 | c initialize work vector to zero's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/ilut.f:1968:33: + + 1968 | c initialize work vector to zero's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/ilut.f:1903:72: + + 1903 | 201 iw(jlu(i)) = 0 + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 201 at (1) +/home/abaillod/SPEC/src/ilut.f:1970:72: + + 1970 | 31 iw(i) = 0 + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 31 at (1) +/home/abaillod/SPEC/src/ilut.f:2021:72: + + 2021 | 201 iw(jlu(i)) = 0 + | 1 +Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 201 at (1) +[19/200] Building Fortran object src/CMakeFiles/spec3p.dir/iters.f.o +/home/abaillod/SPEC/src/iters.f:260:19: + + 260 | c of the TFQMR's estimate is less accurate. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:322:45: + + 322 | c ipar(6) = 100 ! use at most 100 matvec's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:803:58: + + 803 | c in this routine, before successful return, the fpar's are + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:1055:58: + + 1055 | c in this routine, before successful return, the fpar's are + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:1317:27: + + 1317 | c Internally, the fpar's are used as following: + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:1607:27: + + 1607 | c the work space in `w' is used as follows: + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:1923:26: + + 1923 | c the space of the `w' is used as follows: + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:2250:26: + + 2250 | c w(iv+1:iw) -- the V's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:2251:26: + + 2251 | c w(iw+1:ic) -- the W's + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:2437:19: + + 2437 | c update the W's (the conjugate directions) -- essentially this is one + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:2530:26: + + 2530 | c the space of the `w' is used as follows: + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:3017:49: + + 3017 | c orthogonalize current v against previous v's and + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:3238:56: + + 3238 | c Given x and y, this subroutine generates a Givens' rotation c, s. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:3483:14: + + 3483 | c The ind'th vector of VEC is orthogonalized against the rest of + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/src/iters.f:3492:67: + + 3492 | c full -- .ture. if it is necessary to orthogonalize the ind'th + | 1 +Warning: missing terminating ' character +[20/200] Preprocessing /home/abaillod/SPEC/src/manual.f90 +[21/200] Preprocessing /home/abaillod/SPEC/src/packxi.f90 +[22/200] Preprocessing /home/abaillod/SPEC/src/volume.f90 +[23/200] Preprocessing /home/abaillod/SPEC/src/metrix.f90 +[24/200] Preprocessing /home/abaillod/SPEC/src/ma00aa.f90 +[25/200] Preprocessing /home/abaillod/SPEC/src/spsint.f90 +[26/200] Preprocessing /home/abaillod/SPEC/src/rzaxis.f90 +[27/200] Preprocessing /home/abaillod/SPEC/src/coords.f90 +[28/200] Preprocessing /home/abaillod/SPEC/src/basefn.f90 +[29/200] Preprocessing /home/abaillod/SPEC/src/memory.f90 +[30/200] Preprocessing /home/abaillod/SPEC/src/matrix.f90 +[31/200] Preprocessing /home/abaillod/SPEC/src/spsmat.f90 +[32/200] Preprocessing /home/abaillod/SPEC/src/mp00ac.f90 +[33/200] Preprocessing /home/abaillod/SPEC/src/ma02aa.f90 +[34/200] Preprocessing /home/abaillod/SPEC/src/df00ab.f90 +[35/200] Preprocessing /home/abaillod/SPEC/src/packab.f90 +[36/200] Preprocessing /home/abaillod/SPEC/src/curent.f90 +[37/200] Preprocessing /home/abaillod/SPEC/src/lforce.f90 +[38/200] Preprocessing /home/abaillod/SPEC/src/tr00ab.f90 +[39/200] Preprocessing /home/abaillod/SPEC/src/mtrxhs.f90 +[40/200] Preprocessing /home/abaillod/SPEC/src/lbpol.f90 +[41/200] Preprocessing /home/abaillod/SPEC/src/intghs.f90 +[42/200] Preprocessing /home/abaillod/SPEC/src/brcast.f90 +[43/200] Preprocessing /home/abaillod/SPEC/src/dfp100.f90 +[44/200] Preprocessing /home/abaillod/SPEC/src/casing.f90 +[45/200] Preprocessing /home/abaillod/SPEC/src/bnorml.f90 +[46/200] Preprocessing /home/abaillod/SPEC/src/jo00aa.f90 +[47/200] Preprocessing /home/abaillod/SPEC/src/pp00ab.f90 +[48/200] Preprocessing /home/abaillod/SPEC/src/newton.f90 +[49/200] Preprocessing /home/abaillod/SPEC/src/dforce.f90 +[50/200] Preprocessing /home/abaillod/SPEC/src/pp00aa.f90 +[51/200] Preprocessing /home/abaillod/SPEC/src/stzxyz.f90 +[52/200] Preprocessing /home/abaillod/SPEC/src/bfield.f90 +[53/200] Preprocessing /home/abaillod/SPEC/src/ra00aa.f90 +[54/200] Preprocessing /home/abaillod/SPEC/src/numrec.f90 +[55/200] Preprocessing /home/abaillod/SPEC/src/dfp200.f90 +[56/200] Preprocessing /home/abaillod/SPEC/src/hesian.f90 +[57/200] Preprocessing /home/abaillod/SPEC/src/inputlist.f90 +[58/200] Preprocessing /home/abaillod/SPEC/src/bndRep.f90 +[59/200] Preprocessing /home/abaillod/SPEC/src/global.f90 +[60/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90 +[61/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90 +[62/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90 +[63/200] Preprocessing /home/abaillod/SPEC/src/preset.f90 +[64/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90 +[65/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90 +[66/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90 +[67/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90 +[68/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90 +[69/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90 +[70/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90 +[71/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90 +[72/200] Preprocessing /home/abaillod/SPEC/src/mxspech.f90 +[73/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90 +[74/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90 +[75/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90 +[76/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90 +[77/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90 +[78/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90 +[79/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90 +[80/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90 +[81/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90 +[82/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90 +[83/200] Preprocessing /home/abaillod/SPEC/src/msphdf5.f90 +[84/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90 +[85/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90 +[86/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90 +[87/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90 +[88/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 +[89/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90 +[90/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90 +[91/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90 +[92/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90 +[93/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90 +[94/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90 +[95/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90 +[96/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90 +[97/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/packxi_m.F90-pp.f90 +[98/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/manual_m.F90-pp.f90 +[99/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/volume_m.F90-pp.f90 +[100/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/rzaxis_m.F90-pp.f90 +[101/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/coords_m.F90-pp.f90 +[102/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/basefn_m.F90-pp.f90 +[103/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/memory_m.F90-pp.f90 +[104/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/metrix_m.F90-pp.f90 +[105/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/ma02aa_m.F90-pp.f90 +[106/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/mp00ac_m.F90-pp.f90 +[107/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/spsmat_m.F90-pp.f90 +[108/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/spsint_m.F90-pp.f90 +[109/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/ma00aa_m.F90-pp.f90 +[110/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/matrix_m.F90-pp.f90 +[111/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/packab_m.F90-pp.f90 +[112/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/tr00ab_m.F90-pp.f90 +[113/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/lbpol_m.F90-pp.f90 +[114/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/curent_m.F90-pp.f90 +[115/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/df00ab_m.F90-pp.f90 +[116/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/lforce_m.F90-pp.f90 +[117/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/dfp100_m.F90-pp.f90 +[118/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/intghs_m.F90-pp.f90 +[119/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/mtrxhs_m.F90-pp.f90 +[120/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/brcast_m.F90-pp.f90 +[121/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/dfp200_m.F90-pp.f90 +[122/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/dforce_m.F90-pp.f90 +[123/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/newton_m.F90-pp.f90 +[124/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/pp00ab_m.F90-pp.f90 +[125/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/casing_m.F90-pp.f90 +[126/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/bnorml_m.F90-pp.f90 +[127/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/stzxyz_m.F90-pp.f90 +[128/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/bfield_m.F90-pp.f90 +[129/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/hesian_m.F90-pp.f90 +[130/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/jo00aa_m.F90-pp.f90 +[131/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/pp00aa_m.F90-pp.f90 +[132/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/ra00aa_m.F90-pp.f90 +[133/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/numrec_m.F90-pp.f90 +[134/200] Building Fortran preprocessed src/CMakeFiles/xspec.dir/mxspech_m.F90-pp.f90 +[135/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90 +[136/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/bndRep_m.F90-pp.f90 +[137/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/inputlist_m.F90-pp.f90 +[138/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/mxspech_m.F90-pp.f90 +[139/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90 +[140/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90 +[141/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90 +[142/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90 +[143/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90 +[144/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90 +[145/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90 +[146/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/preset_m.F90-pp.f90 +[147/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 +[148/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/msphdf5_m.F90-pp.f90 +[149/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/global_m.F90-pp.f90 +[150/200] Generating Fortran dyndep file src/CMakeFiles/spec.dir/Fortran.dd +[151/200] Building Fortran object src/CMakeFiles/spec.dir/inputlist_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90:321:89: + + 321 | !<

  • if \c iprecon = 0, the preconditioner is `N'
  • + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90:322:89: + + 322 | !<
  • if \c iprecon = 1, the preconditioner is `J'
  • + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90:323:89: + + 323 | !<
  • if \c iprecon = 2, the preconditioner is `S'
  • + | 1 +Warning: missing terminating ' character +[152/200] Building Fortran object src/CMakeFiles/spec.dir/global_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90:369:107: + + 369 | real(8), allocatable :: irhoc(:,:) !< rhomn harmonics of interface surface geometry, using Henneberg's representation + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90:370:108: + + 370 | real(8), allocatable :: ibc(:,:) !< bn harmonics of interface surface geometry, using Henneberg's representation + | 1 +Warning: missing terminating ' character +[153/200] Building Fortran object src/CMakeFiles/spec.dir/manual_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:113:26: + + 113 | !latex i.e., adjust $\mu$'s, fluxes and/or rotational transform to obtain desired current profile (without singular currents). + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:150:24: + + 150 | !latex \item The `polar' coordinate transformation, + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:222:50: + + 222 | !latex we shall introduce a `regularization' factor, $\rho^{m/2} = r^m$. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:255:22: + + 255 | !l tex The `$?$' symbol indicates that there is no boundary condition, and $\Delta\psi_{p,1}$ is the magnetic flux linking the torus: + | 1 +Warning: missing terminating ' character +[154/200] Building Fortran object src/CMakeFiles/spec.dir/packxi_m.F90.o +[155/200] Building Fortran object src/CMakeFiles/spec.dir/lbpol_m.F90.o +[156/200] Building Fortran object src/CMakeFiles/spec.dir/basefn_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:156:34: + + 156 | rm = one ! r to the power of m'th + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:157:37: + + 157 | rm1 = zero ! r to the power of m-1'th + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:220:71: + + 220 | real(8) :: rm, rm1, rm2 ! r to the power of m'th, m-1'th and m-2'th + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:224:34: + + 224 | rm = one ! r to the power of m'th + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:225:37: + + 225 | rm1 = zero ! r to the power of m-1'th + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:226:37: + + 226 | rm2 = zero ! r to the power of m-2'th + | 1 +Warning: missing terminating ' character +[157/200] Building Fortran object src/CMakeFiles/spec.dir/curent_m.F90.o +[158/200] Building Fortran object src/CMakeFiles/spec.dir/brcast_m.F90.o +[159/200] Building Fortran object src/CMakeFiles/spec.dir/df00ab_m.F90.o +[160/200] Building Fortran object src/CMakeFiles/spec.dir/dfp100_m.F90.o +[161/200] Building Fortran object src/CMakeFiles/spec.dir/bnorml_m.F90.o +[162/200] Building Fortran object src/CMakeFiles/spec.dir/metrix_m.F90.o +[163/200] Building Fortran object src/CMakeFiles/spec.dir/pp00ab_m.F90.o +[164/200] Building Fortran object src/CMakeFiles/spec.dir/volume_m.F90.o +[165/200] Building Fortran object src/CMakeFiles/spec.dir/stzxyz_m.F90.o +[166/200] Building Fortran object src/CMakeFiles/spec.dir/numrec_m.F90.o +[167/200] Building Fortran object src/CMakeFiles/spec.dir/ma02aa_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90:1392:39: + + 1392 | ; ; iflag = 1 !(we don't need derivatives) + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90:1394:39: + + 1394 | ; ; iflag = 1 !(we don't need derivatives) ; + | 1 +Warning: missing terminating ' character +[168/200] Building Fortran object src/CMakeFiles/spec.dir/packab_m.F90.o +[169/200] Building Fortran object src/CMakeFiles/spec.dir/tr00ab_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90:1055:18: + + 1055 | ! for safety, let's assume that the following NAG routines will destroy the provided matrices, so better keep a backup; 24 Apr 13; + | 1 +Warning: missing terminating ' character +[170/200] Building Fortran object src/CMakeFiles/spec.dir/lforce_m.F90.o +[171/200] Building Fortran object src/CMakeFiles/spec.dir/casing_m.F90.o +[172/200] Building Fortran object src/CMakeFiles/spec.dir/hesian_m.F90.o +[173/200] Building Fortran object src/CMakeFiles/spec.dir/mp00ac_m.F90.o +[174/200] Building Fortran object src/CMakeFiles/spec.dir/bndRep_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90:2595:78: + + 2595 | if( (jj.le.2*Ntor+1) .and. (jj.gt.0) ) then !Check that indices don't overflow in over elements + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90:2602:78: + + 2602 | if( (jj.le.2*Ntor+1) .and. (jj.gt.0) ) then !Check that indices don't overflow in over elements + | 1 +Warning: missing terminating ' character +[175/200] Building Fortran object src/CMakeFiles/spec.dir/bfield_m.F90.o +[176/200] Building Fortran object src/CMakeFiles/spec.dir/mtrxhs_m.F90.o +[177/200] Building Fortran object src/CMakeFiles/spec.dir/spsint_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90:237:40: + + 237 | if (mi .gt. 0) cycle ! we don't nee to compute more than m>0 + | 1 +Warning: missing terminating ' character +[178/200] Building Fortran object src/CMakeFiles/spec.dir/dfp200_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90:1232:84: + + 1232 | if( IsMyVolumeValue.EQ.0 ) then ! This CPU does not deal with interface's inner volume + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90:1261:88: + + 1261 | if( IsMyVolumeValue.eq.0 ) then ! This CPU does not deal with interface's outer volume either - cycle + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90:3541:34: + + 3541 | ! one step Newton's method + | 1 +Warning: missing terminating ' character +[179/200] Building Fortran object src/CMakeFiles/spec.dir/intghs_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:33:71: + + 33 | !latex \be \verb+DToocc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \cos\a_i \cos\a_j \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:34:71: + + 34 | !latex \verb+DToocs(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \cos\a_i \sin\a_j \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:35:71: + + 35 | !latex \verb+DToosc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \sin\a_i \cos\a_j \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:36:71: + + 36 | !latex \verb+DTooss(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \sin\a_i \sin\a_j + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:45:84: + + 45 | !latex \be \verb+TDstcc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \cos\a_j \; \bar g_{\s\t} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:46:84: + + 46 | !latex \verb+TDstcs(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \sin\a_j \; \bar g_{\s\t} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:47:84: + + 47 | !latex \verb+TDsTsc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \cos\a_j \; \bar g_{\s\t} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:48:84: + + 48 | !latex \verb+TDsTss(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \sin\a_j \; \bar g_{\s\t} + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:51:84: + + 51 | !latex \be \verb+TDstcc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \cos\a_j \; \bar g_{\s\z} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:52:84: + + 52 | !latex \verb+TDstcs(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \sin\a_j \; \bar g_{\s\z} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:53:84: + + 53 | !latex \verb+TDsTsc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \cos\a_j \; \bar g_{\s\z} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:54:84: + + 54 | !latex \verb+TDsTss(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \sin\a_j \; \bar g_{\s\z} + | 1 +Warning: missing terminating ' character +[180/200] Building Fortran object src/CMakeFiles/spec.dir/spsmat_m.F90.o +[181/200] Building Fortran object src/CMakeFiles/spec.dir/jo00aa_m.F90.o +[182/200] Building Fortran object src/CMakeFiles/spec.dir/ma00aa_m.F90.o +[183/200] Building Fortran object src/CMakeFiles/spec.dir/memory_m.F90.o +[184/200] Building Fortran object src/CMakeFiles/spec.dir/matrix_m.F90.o +[185/200] Building Fortran object src/CMakeFiles/spec.dir/coords_m.F90.o +[186/200] Building Fortran object src/CMakeFiles/spec.dir/msphdf5_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:14489:70: + +14489 | integer(size_t) :: offset !< Member's offset + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:19928:121: + +19928 | !latex \type{irhoc(1:mn_rho,1:Mvol)} & real & \pb{Fourier harmonics, $\rho_{m,n}$, of interfaces using Henneberg's representation} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:20007:110: + +20007 | !latex \type{ibc(0:Ntor,1:Mvol)} & real & \pb{Fourier harmonics, $b_n$, of interfaces using Henneberg's representation} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:20086:114: + +20086 | !latex \type{iR0c(0:Ntor,1:Mvol)} & real & \pb{Fourier harmonics, $R_{0n}$, of interfaces using Henneberg's representation} \\ + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:20165:114: + +20165 | !latex \type{iZ0s(0:Ntor,1:Mvol)} & real & \pb{Fourier harmonics, $Z_{0n}$, of interfaces using Henneberg's representation} \\ + | 1 +Warning: missing terminating ' character +[187/200] Building Fortran object src/CMakeFiles/spec.dir/pp00aa_m.F90.o +[188/200] Building Fortran object src/CMakeFiles/spec.dir/ra00aa_m.F90.o +[189/200] Building Fortran object src/CMakeFiles/spec.dir/newton_m.F90.o +[190/200] Building Fortran object src/CMakeFiles/spec.dir/mxspech_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90:134:75: + + 134 | !>
  • All quantities in the input file are mirrored into the output file's group \c /input .
  • + | 1 +Warning: missing terminating ' character +[191/200] Building Fortran object src/CMakeFiles/spec.dir/rzaxis_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:681:23: + + 681 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:683:23: + + 683 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:689:23: + + 689 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:691:23: + + 691 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:711:23: + + 711 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:713:23: + + 713 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:715:23: + + 715 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:717:23: + + 717 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:721:23: + + 721 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:723:23: + + 723 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:725:23: + + 725 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:727:23: + + 727 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:736:23: + + 736 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:738:23: + + 738 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:740:23: + + 740 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:742:23: + + 742 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:746:23: + + 746 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:748:23: + + 748 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:750:23: + + 750 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:752:23: + + 752 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:942:33: + + 942 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:944:33: + + 944 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:950:33: + + 950 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:952:33: + + 952 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:970:33: + + 970 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:972:33: + + 972 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:974:33: + + 974 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:976:33: + + 976 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:980:33: + + 980 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:982:33: + + 982 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:984:33: + + 984 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:986:33: + + 986 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:994:33: + + 994 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:996:33: + + 996 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:998:33: + + 998 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1000:33: + + 1000 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1004:33: + + 1004 | ! the DRcn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1006:33: + + 1006 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1008:33: + + 1008 | ! the DRsn' term + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1010:33: + + 1010 | ! the DZsn' term + | 1 +Warning: missing terminating ' character +[192/200] Building Fortran object src/CMakeFiles/spec.dir/dforce_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:502:26: + + 502 | ! one step Newton's method + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:2178:60: + + 2178 | LComputeAxis, nDcalls) + | 1 +Warning: More actual than formal arguments in procedure call at (1) +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:2757:128: + + 2757 | call dforce( NGdof_field, iposition(isymdiff,0:NGdof_field), iforce(isymdiff,0:NGdof_force), .false., LComputeAxis, nDcalls) + | 1 +Warning: More actual than formal arguments in procedure call at (1) +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:2889:128: + + 2889 | call dforce( NGdof_field, iposition(isymdiff,0:NGdof_field), iforce(isymdiff,0:NGdof_force), .false., LComputeAxis, nDcalls) + | 1 +Warning: More actual than formal arguments in procedure call at (1) +[193/200] Building Fortran object src/CMakeFiles/spec.dir/preset_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:242:21: + + 242 | ! set up Henneberg's mapping + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3489:61: + + 3489 | ! We use the basis combination for m=0 and 1. They don't have ll=0 component. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3512:66: + + 3512 | ! Lme is for B.n at the outer boundary cos component. We don't have it for m=n=0. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3533:39: + + 3533 | ! This is not true using Henneberg's representation - Fourier truncation is different. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3558:102: + + 3558 | ! We use basis recombination method to ensure the inner boundary has At=Az=0. Therefore they don't have ll=0 component. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3573:66: + + 3573 | ! Lme is for B.n at the outer boundary cos component. We don't have it for m=n=0. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:6562:44: + + 6562 | !>
  • If \c Lboundary equals 1 (Henneberg's representation), then psifactor=1. + | 1 +Warning: missing terminating ' character +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:7542:30: + + 7542 | ! Map back to Henneberg's representation + | 1 +Warning: missing terminating ' character +[194/200] Linking Fortran static library build/lib/libspec.a +[195/200] Generating Fortran dyndep file src/CMakeFiles/xspec.dir/Fortran.dd +[196/200] Building Fortran object src/CMakeFiles/xspec.dir/mxspech_m.F90.o +/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90:134:75: + + 134 | !>
  • All quantities in the input file are mirrored into the output file's group \c /input .
  • + | 1 +Warning: missing terminating ' character +[197/200] Linking Fortran executable build/bin/xspec +FAILED: build/bin/xspec +: && /misc/Anaconda3/envs/spec_env/bin/mpif90 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/misc/Anaconda3/envs/spec_env/lib -Wl,-rpath-link,/misc/Anaconda3/envs/spec_env/lib -L/misc/Anaconda3/envs/spec_env/lib -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /misc/Anaconda3/envs/spec_env/include -O3 -DNDEBUG -O3 src/CMakeFiles/xspec.dir/mxspech_m.F90.o -o build/bin/xspec build/lib/libspec.a /misc/Anaconda3/envs/spec_env/lib/libhdf5_fortran.so /misc/Anaconda3/envs/spec_env/lib/libhdf5.so /misc/Anaconda3/envs/spec_env/lib/libfftw3.so /misc/Anaconda3/envs/spec_env/lib/libfftw3f.so /misc/Anaconda3/envs/spec_env/lib/libfftw3l.so /misc/Anaconda3/envs/spec_env/lib/libfftw3_threads.so /misc/Anaconda3/envs/spec_env/lib/libfftw3f_threads.so /misc/Anaconda3/envs/spec_env/lib/libfftw3l_threads.so /misc/Anaconda3/envs/spec_env/lib/libfftw3_omp.so /misc/Anaconda3/envs/spec_env/lib/libfftw3f_omp.so /misc/Anaconda3/envs/spec_env/lib/libfftw3l_omp.so /misc/Anaconda3/envs/spec_env/lib/libopenblas.so && : +/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: src/CMakeFiles/xspec.dir/mxspech_m.F90.o: in function `spec_': +mxspech_m.F90:(.text.spec_+0x27b0): undefined reference to `wrtend_' +/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: src/CMakeFiles/xspec.dir/mxspech_m.F90.o: in function `xspech_': +mxspech_m.F90:(.text.xspech_+0x7ae): undefined reference to `wrtend_' +/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: mxspech_m.F90:(.text.xspech_+0x7bb): undefined reference to `wrtend_' +/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: build/lib/libspec.a(newton_m.F90.o): in function `fcn1_': +newton_m.F90:(.text.fcn1_+0xe9b): undefined reference to `wrtend_' +/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: build/lib/libspec.a(newton_m.F90.o): in function `fcn2_': +newton_m.F90:(.text.fcn2_+0x1189): undefined reference to `wrtend_' +collect2: error: ld returned 1 exit status +[198/200] /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mxspech_m_fpp.F90 +Kind map (also saved to .f2py_f2cmap) +{'complex': {'': 'complex_float', + '16': 'complex_long_double', + '8': 'complex_double', + 'c_double_complex': 'complex_double', + 'dp': 'complex_double'}, + 'integer': {'': 'long_long', + '4': 'int', + '8': 'long_long', + 'dp': 'long_long', + 'hid_t': 'long_long', + 'hsize_t': 'long_long', + 'size_t': 'long_long'}, + 'real': {'': 'double', + '4': 'float', + '8': 'double', + 'dp': 'double', + 'idp': 'double', + 'isp': 'float'}} + +Constructors: +('initialise_ptr', 'initialise', 'allocate') + +Destructors: +('finalise', 'deallocate') + +Short names for derived types: +{} + +String lengths: +{} + +Initialisation lines for derived types +{} + +Python module name remapping +{} +Class names remapping +{} + +Argument name map: +{} + +Size of Fortran derived type pointers is 2 bytes. + +Parsing Fortran source files ['/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/manual_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/rzaxis_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packxi_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/volume_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/coords_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/basefn_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/memory_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/metrix_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/matrix_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsmat_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsint_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mp00ac_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma02aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/tr00ab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/curent_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/df00ab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lforce_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/intghs_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mtrxhs_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lbpol_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/brcast_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp100_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp200_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dforce_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/newton_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/casing_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bnorml_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/jo00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00ab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bfield_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/stzxyz_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/hesian_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ra00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/numrec_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/preset_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bndRep_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/global_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/inputlist_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/msphdf5_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mxspech_m_fpp.F90'] ... +INFO:f90wrap.parser:parser reading type intghs_workspace +INFO:f90wrap.parser:marking module bndRep as default public +INFO:f90wrap.parser:parser reading type subgrid +INFO:f90wrap.parser:parser reading type MatrixLU +INFO:f90wrap.parser:parser reading type derivative +done parsing source. + +Derived types detected in Fortran source files: +{'class(derivative)': Type(name=derivative), + 'class(intghs_workspace)': Type(name=intghs_workspace), + 'class(matrixlu)': Type(name=matrixlu), + 'class(subgrid)': Type(name=subgrid), + 'derivative': Type(name=derivative), + 'intghs_workspace': Type(name=intghs_workspace), + 'matrixlu': Type(name=matrixlu), + 'subgrid': Type(name=subgrid), + 'type(derivative)': Type(name=derivative), + 'type(intghs_workspace)': Type(name=intghs_workspace), + 'type(matrixlu)': Type(name=matrixlu), + 'type(subgrid)': Type(name=subgrid)} + +Class name mapping: +{'class(derivative)': 'derivative', + 'class(intghs_workspace)': 'intghs_workspace', + 'class(matrixlu)': 'MatrixLU', + 'class(subgrid)': 'subgrid', + 'derivative': 'derivative', + 'intghs_workspace': 'intghs_workspace', + 'matrixlu': 'MatrixLU', + 'subgrid': 'subgrid', + 'type(derivative)': 'derivative', + 'type(intghs_workspace)': 'intghs_workspace', + 'type(matrixlu)': 'MatrixLU', + 'type(subgrid)': 'subgrid'} +Modules for each type: +{'intghs_module': 'intghs_module', 'typedefns': 'typedefns'} +WARNING:f90wrap.transform:removing intghs_module.wk as missing "target" attribute +WARNING:f90wrap.transform:removing allglobal.ate as missing "target" attribute +WARNING:f90wrap.transform:removing allglobal.aze as missing "target" attribute +WARNING:f90wrap.transform:removing allglobal.ato as missing "target" attribute +WARNING:f90wrap.transform:removing allglobal.azo as missing "target" attribute +WARNING:f90wrap.transform:removing allglobal.dbdx as missing "target" attribute +WARNING:f90wrap.transform:removing fftw_interface.planf as type(c_ptr) unsupported +WARNING:f90wrap.transform:removing fftw_interface.planb as type(c_ptr) unsupported +INFO:f90wrap.transform:adding missing constructor for intghs_workspace +INFO:f90wrap.transform:adding missing constructor for subgrid +INFO:f90wrap.transform:adding missing constructor for matrixlu +INFO:f90wrap.transform:adding missing constructor for derivative +INFO:f90wrap.transform:adding missing destructor for intghs_workspace +INFO:f90wrap.transform:adding missing destructor for subgrid +INFO:f90wrap.transform:adding missing destructor for matrixlu +INFO:f90wrap.transform:adding missing destructor for derivative +INFO:f90wrap.transform:visiting Module(name=intghs_module) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Type(name=intghs_workspace) found 1 constructors with names: ['intghs_workspace_initialise'] +INFO:f90wrap.transform:visiting Module(name=newtontime) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=bndrep) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=constants) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=numerical) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=fileunits) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=cputiming) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=typedefns) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Type(name=subgrid) found 1 constructors with names: ['subgrid_initialise'] +INFO:f90wrap.transform:visiting Type(name=matrixlu) found 1 constructors with names: ['matrixlu_initialise'] +INFO:f90wrap.transform:visiting Type(name=derivative) found 1 constructors with names: ['derivative_initialise'] +INFO:f90wrap.transform:visiting Module(name=allglobal) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=fftw_interface) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=inputlist) found 0 constructors with names: [] +INFO:f90wrap.transform:visiting Module(name=sphdf5) found 0 constructors with names: [] +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module intghs_module +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type intghs_workspace +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_initialise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_finalise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module newtontime +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module bndrep +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine initialize_mapping +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine change_mapping_angle +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine forwardmap +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine backwardmap +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine initialize_force_gradient_transformation +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pack_henneberg_to_hudson +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pack_hudson_to_henneberg +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pack_rhomn_bn +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine build_mapping_matrices +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine change_angle +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine find_index +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module constants +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module numerical +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module fileunits +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mute +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module cputiming +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module typedefns +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type subgrid +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine subgrid_initialise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine subgrid_finalise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type matrixlu +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrixlu_initialise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrixlu_finalise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type derivative +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine derivative_initialise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine derivative_finalise +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module allglobal +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine build_vector_potential +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine set_mpi_comm +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_inputlists_from_file +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine check_inputs +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine broadcast_inputs +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ismyvolume +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine whichcpuid +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module fftw_interface +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module inputlist +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine initialize_inputs +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module sphdf5 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine init_outfile +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mirror_input_to_outfile +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine init_convergence_output +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_convergence_output +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_grid +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine init_flt_output +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_poincare +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_transform +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine finalize_flt_output +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_vector_potential +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine hdfint +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine finish_outfile +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine manual +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine rzaxis +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fndiff_rzaxis +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine packxi +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine volume +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine coords +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_cheby +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_cheby_d2 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_zernike +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_zernike_d2 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_zernike_rm +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine allocate_beltrami_matrices +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine deallocate_beltrami_matrices +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine allocate_geometry_matrices +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine deallocate_geometry_matrices +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine metrix +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine compute_guvijsave +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ma00aa +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrix +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrixbg +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine spsmat +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine push_back +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine clean_queue +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine addline +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine spsint +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mp00ac +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine rungmres +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matvec +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine prec_solve +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ma02aa +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine packab +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine tr00ab +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine curent +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine df00ab +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine lforce +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_init +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_destroy +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mtrxhs +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine lbpol +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine brcast +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dfp100 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dfp200 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_lu_beltrami_matrices +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_perturbed_solution +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine evaluate_dmupfdx +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine evaluate_dbb +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dforce +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fndiff_dforce +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine newton +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine writereadgf +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fcn1 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fcn2 +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine casing +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dvcfield +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine bnorml +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine jo00aa +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pp00aa +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pp00ab +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine bfield +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine bfield_tangent +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine stzxyz +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine hesian +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ra00aa +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine gi00ab +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine getimn +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine tfft +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine invfft +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine gauleg +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine preset +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine set_global_variables +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_input_geometry +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_hudson_input_geometry +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_henneberg_input_geometry +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine interpolate_initial_guess +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine check_and_change_angle +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine xspech +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_command_args +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine spec +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine final_diagnostics +INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ending +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module intghs_module +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type intghs_workspace +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_initialise call_name intghs_workspace_initialise mod_name 'intghs_module' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_finalise call_name intghs_workspace_finalise mod_name 'intghs_module' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module newtontime +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module bndrep +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine initialize_mapping call_name initialize_mapping mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine change_mapping_angle call_name change_mapping_angle mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine forwardmap call_name forwardMap mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine backwardmap call_name backwardMap mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine initialize_force_gradient_transformation call_name initialize_force_gradient_transformation mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pack_henneberg_to_hudson call_name pack_henneberg_to_hudson mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pack_hudson_to_henneberg call_name pack_hudson_to_henneberg mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pack_rhomn_bn call_name pack_rhomn_bn mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine build_mapping_matrices call_name build_mapping_matrices mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine change_angle call_name change_angle mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine find_index call_name find_index mod_name 'bndrep' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module constants +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module numerical +/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/f90wrap/f90wrapgen.py:139: UserWarning: Source file /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/global_m_fpp.F90 contains code for more than one module! + warnings.warn('Source file %s contains code for more than one module!' % node.filename) +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module fileunits +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mute call_name mute mod_name 'fileunits' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module cputiming +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module typedefns +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type subgrid +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine subgrid_initialise call_name subgrid_initialise mod_name 'typedefns' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine subgrid_finalise call_name subgrid_finalise mod_name 'typedefns' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type matrixlu +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrixlu_initialise call_name matrixlu_initialise mod_name 'typedefns' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrixlu_finalise call_name matrixlu_finalise mod_name 'typedefns' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type derivative +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine derivative_initialise call_name derivative_initialise mod_name 'typedefns' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine derivative_finalise call_name derivative_finalise mod_name 'typedefns' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module allglobal +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine build_vector_potential call_name build_vector_potential mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine set_mpi_comm call_name set_mpi_comm mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_inputlists_from_file call_name read_inputlists_from_file mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine check_inputs call_name check_inputs mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine broadcast_inputs call_name broadcast_inputs mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ismyvolume call_name IsMyVolume mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine whichcpuid call_name WhichCpuID mod_name 'allglobal' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module fftw_interface +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module inputlist +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine initialize_inputs call_name initialize_inputs mod_name 'inputlist' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module sphdf5 +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine init_outfile call_name init_outfile mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mirror_input_to_outfile call_name mirror_input_to_outfile mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine init_convergence_output call_name init_convergence_output mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_convergence_output call_name write_convergence_output mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_grid call_name write_grid mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine init_flt_output call_name init_flt_output mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_poincare call_name write_poincare mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_transform call_name write_transform mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine finalize_flt_output call_name finalize_flt_output mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_vector_potential call_name write_vector_potential mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine hdfint call_name hdfint mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine finish_outfile call_name finish_outfile mod_name 'sphdf5' +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine manual call_name manual mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine rzaxis call_name rzaxis mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fndiff_rzaxis call_name fndiff_rzaxis mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine packxi call_name packxi mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine volume call_name volume mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine coords call_name coords mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_cheby call_name get_cheby mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_cheby_d2 call_name get_cheby_d2 mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_zernike call_name get_zernike mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_zernike_d2 call_name get_zernike_d2 mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_zernike_rm call_name get_zernike_rm mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine allocate_beltrami_matrices call_name allocate_Beltrami_matrices mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine deallocate_beltrami_matrices call_name deallocate_Beltrami_matrices mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine allocate_geometry_matrices call_name allocate_geometry_matrices mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine deallocate_geometry_matrices call_name deallocate_geometry_matrices mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine metrix call_name metrix mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine compute_guvijsave call_name compute_guvijsave mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ma00aa call_name ma00aa mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrix call_name matrix mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrixbg call_name matrixBG mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine spsmat call_name spsmat mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine push_back call_name push_back mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine clean_queue call_name clean_queue mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine addline call_name addline mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine spsint call_name spsint mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mp00ac call_name mp00ac mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine rungmres call_name rungmres mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matvec call_name matvec mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine prec_solve call_name prec_solve mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ma02aa call_name ma02aa mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine packab call_name packab mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine tr00ab call_name tr00ab mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine curent call_name curent mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine df00ab call_name df00ab mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine lforce call_name lforce mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs call_name intghs mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_init call_name intghs_workspace_init mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_destroy call_name intghs_workspace_destroy mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mtrxhs call_name mtrxhs mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine lbpol call_name lbpol mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine brcast call_name brcast mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dfp100 call_name dfp100 mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dfp200 call_name dfp200 mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_lu_beltrami_matrices call_name get_LU_beltrami_matrices mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_perturbed_solution call_name get_perturbed_solution mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine evaluate_dmupfdx call_name evaluate_dmupfdx mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine evaluate_dbb call_name evaluate_dBB mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dforce call_name dforce mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fndiff_dforce call_name fndiff_dforce mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine newton call_name newton mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine writereadgf call_name writereadgf mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fcn1 call_name fcn1 mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fcn2 call_name fcn2 mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine casing call_name casing mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dvcfield call_name dvcfield mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine bnorml call_name bnorml mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine jo00aa call_name jo00aa mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pp00aa call_name pp00aa mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pp00ab call_name pp00ab mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine bfield call_name bfield mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine bfield_tangent call_name bfield_tangent mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine stzxyz call_name stzxyz mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine hesian call_name hesian mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ra00aa call_name ra00aa mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine gi00ab call_name gi00ab mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine getimn call_name getimn mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine tfft call_name tfft mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine invfft call_name invfft mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine gauleg call_name gauleg mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine preset call_name preset mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine set_global_variables call_name set_global_variables mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_input_geometry call_name read_input_geometry mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_hudson_input_geometry call_name read_hudson_input_geometry mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_henneberg_input_geometry call_name read_henneberg_input_geometry mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine interpolate_initial_guess call_name interpolate_initial_guess mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine check_and_change_angle call_name check_and_change_angle mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine xspech call_name xspech mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_command_args call_name read_command_args mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine spec call_name spec mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine final_diagnostics call_name final_diagnostics mod_name None +INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ending call_name ending mod_name None +ninja: build stopped: subcommand failed. +system.platform is linux +CMAKE_ARGS = '-DCMAKE_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ar -DCMAKE_CXX_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_C_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ranlib -DCMAKE_CXX_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_C_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_LINKER=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ld -DCMAKE_STRIP=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-strip' + + +-------------------------------------------------------------------------------- +-- Trying "Ninja" generator +-------------------------------- +--------------------------- +---------------------- +----------------- +------------ +------- +-- +-- +------- +------------ +----------------- +---------------------- +--------------------------- +-------------------------------- +-- Trying "Ninja" generator - success +-------------------------------------------------------------------------------- + +Configuring Project + Working directory: + /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build + Command: + cmake /home/abaillod/SPEC -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-install -DPYTHON_EXECUTABLE:FILEPATH=/misc/Anaconda3/envs/spec_env/bin/python -DPYTHON_VERSION_STRING:STRING=3.10.2 -DPYTHON_INCLUDE_DIR:PATH=/misc/Anaconda3/envs/spec_env/include/python3.10 -DPYTHON_LIBRARY:FILEPATH=/misc/Anaconda3/envs/spec_env/lib/libpython3.10.so -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/skbuild/resources/cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_Fortran_COMPILER=mpif90 -DBLA_VENDOR=OpenBLAS -DCMAKE_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ar -DCMAKE_CXX_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_C_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ranlib -DCMAKE_CXX_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_C_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_LINKER=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ld -DCMAKE_STRIP=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-strip -DCMAKE_C_FLAGS=-I/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include -DCMAKE_BUILD_TYPE:STRING=Release + +Traceback (most recent call last): + From 9e6aac28f99a81db931b66f64be7995368227654 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Mon, 9 May 2022 10:19:47 +0200 Subject: [PATCH 005/134] Update SPEC_Namelist.m --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 762 +++++- .../SPEC_Namelist/SPEC_Namelist_depr.m | 2187 ----------------- 2 files changed, 729 insertions(+), 2220 deletions(-) delete mode 100644 Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m index 42390251..7c5897ff 100644 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -15,13 +15,48 @@ Ntor = 0; array_size = [0, 0]; Mvol = 0; + Nvol = 0; end methods (Access=public) % Class constructor - function obj = SPEC_Namelist( filename ) + function obj = SPEC_Namelist( filename, varargin ) + % + % SPEC_NAMELIST( FILENAME ) + % ========================= + % + % Class constructor of the class SPEC_Namelist. This class + % reads the SPEC input file, checks that the data is correctly + % formatted, allow some plottings and easy changes in the input + % file, and provides a routine to write SPEC input file. + % + % INPUTS + % ------ + % -FILENAME: SPEC input file (.sp) + % -VARARGIN: Any couple of input: + % - 'Liniguess': set to true to read initial guess, false + % to skip it. default: true + % + % + % OUTPUTS + % ------- + % -OBJ: An instance of the class SPEC_Namelist + % + % + % Read optional input + l = length(varargin); + if mod(l,2)~=0 + error('InputError: invalid number of inputs') + end + + opt.Liniguess = true; + for ii=1:l/2 + opt.(varargin{2*ii-1}) = varargin{2*ii}; + end + + % Read input file work = read_namelist( filename ); obj.lists = fields(work); obj.physicslist = work.physicslist; @@ -30,7 +65,6 @@ obj.globallist = work.globallist; obj.diagnosticslist = work.diagnosticslist; obj.screenlist = work.screenlist; - obj.initial_guess = []; % Check that the size of arrays makes sense, fills with zeros % otherwise @@ -40,15 +74,523 @@ % reformat all spectral quantities to have the same resolution obj = obj.set_fourier_resolution(); + % Read initial guess + if opt.Liniguess + obj = obj.read_initial_guess( filename ); + else + obj.initial_guess = struct([]); + end + + end + + function obj = read_initial_guess( obj, filename ) + % + % READ_INITIAL_GUESS( FILENAME ) + % ============================== + % + % Read the initial guess from the input file filename. + % + % If the Fourier resolution of the initial guess is larger than + % the Fourier resolution of the other physical qunatities, these + % are extended with zeros. + % + % If the initial guess requires less Fourier harmonics, then it + % is extended with zeros to match the Fourier resolution of the + % other physical quantities + % + % If no initial guess are provided in filename, return an empty + % structure. + + + % First, open file and read relevant portion + fid = fopen( filename, 'r' ); + save_line = false; + category = ''; + + initial_guess_str = {}; + + while( ~feof(fid) ) % while it is not the end of the file + + tline = fgetl(fid); + tline = strtrim(tline); + + if( save_line ) % write line + initial_guess_str{end+1} = tline; + + else % otherwise look for beginning of geometrical initial guess + if( strcmp(tline, '/') ) + if( strcmp(category,'screenlist') ) + save_line = true; + end + + else + % read category + if strcmp(tline(end-3:end),'list') + category = tline(2:end); + end + + end + end + end % end of while + + fclose(fid); % Close file + + % Check size + l = length(str2num( initial_guess_str{1} )); + l = l-2; % Remove m, n + if mod(l,4)~=0 + error('Invalid number of modes in initial guess') + end + + if l/4obj.Nvol + error('Too many volumes in initial guess') + end + + % Read format of initial guess + tmp = SPEC_Namelist( filename, 'Liniguess', false ); + + if tmp.physicslist.Lboundary~=obj.physicslist.Lboundary + error(['The initial guess from file %s does not use the',... + 'same boundary representation.'], filename) + end + + + % Now format initial guess in a structure + switch obj.physicslist.Lboundary + case 0 % Rmn, Zmn representation + + nlines = length(initial_guess_str); + if nlines<1 + obj.initial_guess = struct([]); % generate empty structure + return + end + + % Read Mpol, Ntor + Mpol_in = 0; Ntor_in = 0; + for iline=1:nlines + % Scan line + line_data = str2num( initial_guess_str{iline} ); + + % Find corresponding index + mm = line_data(1); nn = line_data(2); + Mpol_in = max([mm, Mpol_in]); + Ntor_in = max([abs(nn), Ntor_in]); + end + + % Check if resolution is smaller or larger than inner + % resolution. This changes obj.Mpol and obj.Ntor if + % necessary + if (Mpol_in>obj.Mpol) || (Ntor_in>obj.Ntor) + obj = obj.change_fourier_resolution( Mpol_in, Ntor_in ); + end + + + % Allocate memory + Ric = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); + Ris = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); + Zic = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); + Zis = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); + + % Fill initial guess arrays + for iline=1:nlines + + % Scan line + line_data = str2num( initial_guess_str{iline} ); + + % Find corresponding index + m = line_data(1); n = line_data(2); + im = m+1; + in = n+obj.Ntor+1; + + for ivol=1:obj.Nvol + Ric(in,im,ivol) = line_data(ivol*4-1); + Zis(in,im,ivol) = line_data(ivol*4 ); + Ris(in,im,ivol) = line_data(ivol*4+1); + Zic(in,im,ivol) = line_data(ivol*4+2); + end + end + + % Fill structure + obj.initial_guess.Ric = Ric; + obj.initial_guess.Zis = Zis; + obj.initial_guess.Ris = Ris; + obj.initial_guess.Zic = Zic; + + case 1 % Henneberg representation + error('To be implemented') + otherwise + error('Invalid Lboundary!') + end + + end + + % Getters + function out = get_fourier_harmonics( obj, field, m, n, varargin ) + % + % GET_FOURIER_HARMONICS( FIELD, M, N, (IVOL) ) + % ============================================ + % + % Returns the fourier harmonics associated to the field, + % poloidal mode number m and toroidal mode number n + % + % INPUTS + % ------ + % -field: 'Rbc', 'Zws', 'Ric', ... + % -m : Poloidal mode number + % -n : Toroidal mode number + % -(ivol): Optional argument, required for fourier harmonics + % of the initial guess + + + + if m>obj.Mpol + warning('M is larger than the Fourier resolution of the input file') + out = 0; + return + end + + if abs(n)>obj.Ntor + warning('M is larger than the Fourier resolution of the input file') + out = 0; + return + end + + if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... + || strcmp(field, 'Zic') || strcmp(field, 'Zis') + + if isempty(obj.initial_guess) + error('No initial guess available') + end + + ivol = varargin{1}; + + if ivol<1 || ivol>obj.Nvol + error('Invalid ivol') + end + + cat = 'initial_guess'; + + else + cat = 'physicslist'; + ivol = 1; + + end + + + out = obj.(cat).(field)(n+obj.Ntor+1, m+1, ivol); + + end + + % Setter + function obj = set_fourier_harmonics( obj, field, im, in, value, varargin ) + % + % SET_FOURIER_HARMONICS( FIELD, M, N, (IVOL) ) + % ============================================ + % + % Sets the fourier harmonics associated to the field, + % poloidal mode number m and toroidal mode number n + % + % INPUTS + % ------ + % -field: 'Rbc', 'Zws', 'Ric', ... + % -im : Poloidal mode number, size 1xmn + % -in : Toroidal mode number, size 1xmn + % -value: Value for the mode, size 1xmn + % -(ivol): Optional argument, required for fourier harmonics + % of the initial guess + + + mn = length(im); + if length(in)~=mn + error('The array in has not the same length as im') + end + if length(value)~=mn + error('The array value has not the same length as im') + end + + for imn=1:mn + m = im(imn); + n = in(imn); + + if m>obj.Mpol + warning('Poloidal resolution has to be increased ...') + obj = obj.change_fourier_resolution( m, obj.Ntor ); + end + + if abs(n)>obj.Ntor + warning('Toroidal resolution has to be increased ...') + obj = obj.change_fourier_resolution( obj.Mpol, abs(n) ); + end + + if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... + || strcmp(field, 'Zic') || strcmp(field, 'Zis') + + if isempty(obj.initial_guess) + warning('No initial guess available... filling with zeros') + + obj.initial_guess.Ric = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + obj.initial_guess.Ris = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + obj.initial_guess.Zic = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + obj.initial_guess.Zis = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + end + + ivol = varargin{1}; + + if ivol<1 || ivol>obj.Nvol + error('Invalid ivol') + end + + cat = 'initial_guess'; + + else + cat = 'physicslist'; + ivol = 1; + + end + + + obj.(cat).(field)(n+obj.Ntor+1, m+1, ivol) = value(imn); + end + end + + function obj = truncate_fourier_series( obj, Mpol, Ntor ) + % + % TRUNCATE_FOURIER_SERIES( MPOL, NTOR ) + % ===================================== + % + % Truncates all spectral quantities to the requested poloidal + % and toroidal resolution + % + % INPUTS + % ------ + % -Mpol: Poloidal resolution + % -Ntor: Toroidal resolution + % + % OUTPUT + % ------ + % -OBJ: Truncated instance of SPEC_Namelist + % + + obj = obj.change_fourier_resolution( Mpol, Ntor ); end + % Plotters + function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) + % + % PLOT_PLASMA_BOUNDARY + % ==================== + % + % Plot the boundary given by Rbc, Zbs, Rbs, Zbc + % + % INPUTS + % ------ + % -NEWFIG: =0: plot on gca + % =1: plot on a new figure + % =2: erase and plot on gca + % -varargin: Any input you could give to plot() + % + % + + Rbc = obj.physicslist.Rbc; + Rbs = obj.physicslist.Rbs; + Zbc = obj.physicslist.Zbc; + Zbs = obj.physicslist.Zbs; + + obj.plot_surface( Rbc, Zbs, Rbs, Zbc, nt, phi, newfig, varargin{:} ) + end + + function plot_computational_boundary( obj, nt, phi, newfig, varargin ) + % + % PLOT_PLASMA_BOUNDARY + % ==================== + % + % Plot the boundary given by Rbc, Zbs, Rbs, Zbc + % + % INPUTS + % ------ + % -NEWFIG: =0: plot on gca + % =1: plot on a new figure + % =2: erase and plot on gca + % -varargin: Any input you could give to plot() + % + % + + Rwc = obj.physicslist.Rwc; + Rws = obj.physicslist.Rws; + Zwc = obj.physicslist.Zwc; + Zws = obj.physicslist.Zws; + + obj.plot_surface( Rwc, Zws, Rws, Zwc, nt, phi, newfig, varargin{:} ) + end + + function plot_initial_guess( obj, nt, phi, newfig, varargin ) + % + % PLOT_PLASMA_BOUNDARY + % ==================== + % + % Plot the boundary given by Rbc, Zbs, Rbs, Zbc + % + % INPUTS + % ------ + % -NEWFIG: =0: plot on gca + % =1: plot on a new figure + % =2: erase and plot on gca + % -varargin: Any input you could give to plot() + % + % + + for ivol=1:obj.Nvol + Ric = obj.initial_guess.Ric(:,:,ivol); + Ris = obj.initial_guess.Ris(:,:,ivol); + Zic = obj.initial_guess.Zic(:,:,ivol); + Zis = obj.initial_guess.Zis(:,:,ivol); + + if ivol==2 + newfig=0; + end + + obj.plot_surface( Ric, Zis, Ris, Zic, nt, phi, newfig, varargin{:} ) + end + end + + % Write method + function write_input_file(obj, filename ) + % + % WRITE_INPUT_FILE( filename ) + % ============================ + % + % Write namelist in an input file. Be careful: if the file filename + % provided as input exist, it will be overwritten! + % + % INPUT + % ----- + % - filename: path where to save the input file. + % + + + nlists = length(obj.lists); + S = struct; + for ii=1:nlists + S.(obj.lists{ii}) = obj.(obj.lists{ii}); + end + + S.shift.Rbc = [obj.Ntor+1, 1]; + S.shift.Rbs = [obj.Ntor+1, 1]; + S.shift.Zbc = [obj.Ntor+1, 1]; + S.shift.Zbs = [obj.Ntor+1, 1]; + S.shift.Rwc = [obj.Ntor+1, 1]; + S.shift.Rws = [obj.Ntor+1, 1]; + S.shift.Zws = [obj.Ntor+1, 1]; + S.shift.Zwc = [obj.Ntor+1, 1]; + S.shift.Vnc = [obj.Ntor+1, 1]; + S.shift.Vns = [obj.Ntor+1, 1]; + S.shift.Bnc = [obj.Ntor+1, 1]; + S.shift.Bns = [obj.Ntor+1, 1]; + S.shift.rhomn = [obj.Ntor+1, 1]; + + if obj.physicslist.Lboundary==0 + if ~isempty(obj.initial_guess) + s = size(obj.initial_guess.Ric); + initialguess = cell(1, s(1)*s(2)); + iline=0; + for ii=1:s(1) + for jj=1:s(2) + iline = iline+1; + mm = jj-1; + nn = ii-obj.Ntor-1; + + initialguess{iline} = sprintf( '%i %i ', mm, nn ); + for ivol=1:s(3) + initialguess{iline} = sprintf( '%s %0.12E %0.12E %0.12E %0.12E', initialguess{iline}, ... + obj.initial_guess.Ric(ii,jj,ivol), ... + obj.initial_guess.Zis(ii,jj,ivol), ... + obj.initial_guess.Ris(ii,jj,ivol), ... + obj.initial_guess.Zic(ii,jj,ivol) ); + end + end + end + else + initialguess = cell(0); + end + + else + + nrho = max(max(obj.physicslist.in)); + S.shift.rhomn = [ 1, nrho+1 ]; + + % Now prepare initial guess... + if isfield(obj.initial_guess, 'bin') + sb = size(obj.initial_guess.bin); + srho = size(obj.initial_guess.rhoi); + ntor = (srho(2)-1)/2.0; + initialguess = cell(1, sb(1) + srho(1)*srho(2)); + + % Modes m=0, n + for ii=1:sb(1) + nn = ii-1; + initialguess{ii} = sprintf('0 %i ', nn); + for ivol=1:sb(2) + initialguess{ii} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii}, ... + obj.initial_guess.bin( ii, ivol ), ... + obj.initial_guess.R0ic(ii, ivol ), ... + obj.initial_guess.Z0is(ii, ivol ), 0.0 ); + end + end + + it = sb(1); + for ii=1:srho(2) + + nn = ii-ntor-1; + + for jj=1:srho(1) + + it = it+1; + + mm = jj; + + initialguess{it} = sprintf('%i %i ', mm, nn); + + for ivol=1:srho(3) + + initialguess{it} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii},... + 0.0, 0.0, 0.0, obj.initial_guess.rhoi(ii, jj, ivol)); + + end + end + end + else + initialguess = cell(0); + + end + + + + end + + write_namelist( S, filename, initialguess ); + + + end end methods (Access=private) function obj = initialize_structure( obj ) + % + % INITIALIZE_STRUCTURE( OBJ ) + % =========================== + % + % Use to check that all required inputs are correctly set; + % check that the sizes of arrays are correct. Raise errors in + % case crucial informations is missing. + % + % % Fill some important inputs if ~isfield(obj.physicslist, 'Nvol') @@ -59,6 +601,7 @@ end obj.Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; + obj.Nvol = obj.physicslist.Nvol; % PHYSICSLIST % ----------- @@ -306,17 +849,77 @@ obj.diagnosticslist.nPtrj = 0; end end - + function obj = change_fourier_resolution( obj, Mpol_new, Ntor_new ) + % + % CHANGE_FOURIER_RESOLUTION( MPOL_NEW, NTOR_NEW ) + % =============================================== + % + % Change inner Fourier resolution of an instance of + % SPEC_Namelist. + % + % INPUTS + % ------ + % -Mpol_new: New poloidal resolution + % -Ntor_new: New toroidal resolution + % + % OUTPUT + % ------ + % -obj: Updated instance of SPEC_Namelist + % + + if Mpol_new<1 + error('InputError, Mpol_new should be larger than 0') + end + if Ntor_new<0 + error('InputError, Ntor_new should be larger or equal to zero') + end + + obj.Mpol = Mpol_new; + obj.Ntor = Ntor_new; + obj.array_size = [2*obj.Ntor+1, obj.Mpol+1]; + + % Check that all arrays have the same size; otherwise, fill + % with zeros the missing elements + if any(size(obj.physicslist.Rbc)~=obj.array_size) + obj = obj.reshape_array( 'Rbc' ); + obj = obj.reshape_array( 'Rbs' ); + obj = obj.reshape_array( 'Zbc' ); + obj = obj.reshape_array( 'Zbs' ); + end + + if any(size(obj.physicslist.Rwc)~=obj.array_size) + obj = obj.reshape_array( 'Rwc' ); + obj = obj.reshape_array( 'Rws' ); + obj = obj.reshape_array( 'Zwc' ); + obj = obj.reshape_array( 'Zws' ); + end + + if any(size(obj.physicslist.Vnc)~=obj.array_size) + obj = obj.reshape_array( 'Vnc' ); + obj = obj.reshape_array( 'Vns' ); + obj = obj.reshape_array( 'Bnc' ); + obj = obj.reshape_array( 'Bns' ); + end + end function obj = set_fourier_resolution( obj ) - + % + % SET_FOURIER_RESOLUTION( OBJ ) + % ============================= + % + % Set the obj internal Fourier resolution to the maximal value + % required to store the given data; then, reshapees all arrays + % to have the size obj.array_size. + % % Check beforehand that the resolution of Rbc is the same as % Rbs, Zbc and Zbs. Do something similar for Vnc, Vns, Bnc, Bns % and Rwc, Rws, Zws, Zwc. + % + % Find largest Fourier resolution in the input file Mpol_in = obj.physicslist.Mpol; Ntor_in = obj.physicslist.Ntor; @@ -336,38 +939,34 @@ Mpol_vb = s_vb(2)-1 ; Ntor_vb = max([abs(1-shift), s_vb(1)-shift]); - obj.Mpol = max([Mpol_in, Mpol_bc, Mpol_wc, Mpol_vb]); - obj.Ntor = max([Ntor_in, Ntor_bc, Ntor_wc, Ntor_vb]); - obj.array_size = [2*obj.Ntor+1, obj.Mpol+1]; - - % Check that all arrays have the same size; otherwise, fill - % with zeros the missing elements - if any(size(obj.physicslist.Rbc)~=obj.array_size) - obj.physicslist.Rbc = obj.reshape_array( obj.physicslist.Rbc, Ntor_bc ); - obj.physicslist.Rbs = obj.reshape_array( obj.physicslist.Rbs, Ntor_bc ); - obj.physicslist.Zbc = obj.reshape_array( obj.physicslist.Zbc, Ntor_bc ); - obj.physicslist.Zbs = obj.reshape_array( obj.physicslist.Zbs, Ntor_bc ); - end - - if any(size(obj.physicslist.Rwc)~=obj.array_size) - obj.physicslist.Rwc = obj.reshape_array( obj.physicslist.Rwc, Ntor_wc ); - obj.physicslist.Rws = obj.reshape_array( obj.physicslist.Rws, Ntor_wc ); - obj.physicslist.Zwc = obj.reshape_array( obj.physicslist.Zwc, Ntor_wc ); - obj.physicslist.Zws = obj.reshape_array( obj.physicslist.Zws, Ntor_wc ); - end - - if any(size(obj.physicslist.Vnc)~=obj.array_size) - obj.physicslist.Vnc = obj.reshape_array( obj.physicslist.Vnc, Ntor_vb ); - obj.physicslist.Vns = obj.reshape_array( obj.physicslist.Vns, Ntor_vb ); - obj.physicslist.Bnc = obj.reshape_array( obj.physicslist.Bnc, Ntor_vb ); - obj.physicslist.Bns = obj.reshape_array( obj.physicslist.Bns, Ntor_vb ); - end + Mpol_new = max([Mpol_in, Mpol_bc, Mpol_wc, Mpol_vb]); + Ntor_new = max([Ntor_in, Ntor_bc, Ntor_wc, Ntor_vb]); + obj = obj.change_fourier_resolution( Mpol_new, Ntor_new ); end - function new_array = reshape_array( obj, array, Ntor_array ) - + function obj = reshape_array( obj, field ) + % + % RESHAPE_ARRAY( OBJ, FIELD ) + % ======================================= + % + % Reshape the input array in a an array of size obj.array_size + % and fills missing elements with zeros + % + % INPUTS + % ------ + % -field: Field, in obj.physicslist, to be modified + % + % OUTPUT + % ------ + % -obj: Updated instance of SPEC_Namelist + % + + array = obj.physicslist.(field); + shift = obj.physicslist.shift.(field); + s = size(array); + Ntor_array = max([abs(1-shift), s(1)-shift]); new_array = zeros(obj.array_size); for ii=1:s(1) @@ -375,10 +974,107 @@ nn = ii-Ntor_array-1; mm = jj-1; + if abs(nn)>obj.Ntor || mm>obj.Mpol + continue + end + new_array(nn+obj.Ntor+1, mm+1) = array(ii, jj); end end + + obj.physicslist.(field) = new_array; + end + + + function plot_surface( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... + newfig, varargin ) + % + % PLOT_SURFACE( RMNC, ZMNS, RMNS, ZMNC, NT, NEWFIG, VARARGIN ) + % =========================================================== + % + % Plot a surface parametrized by the standard representation + % + % INPUTS + % ------ + % -Rmnc: Even Fourier modes of R, format (2*Ntor+1, Mpol+1) + % -Zmns: Odd Fourier modes of Z, format (2*Ntor+1, Mpol+1) + % -Rmns: Odd Fourier modes of R, format (2*Ntor+1, Mpol+1) + % -Zmnc: Even Fourier modes of Z, format (2*Ntor+1, Mpol+1) + % -NT : Number of poloidal points + % -PHI : Toroidal angle + % -newfig: =0: plot on gca + % =1: plot on a new figure + % =2: erase and plot on gca + % - varargin: Any input you could give to plot() + + switch newfig + case 0 + hold on + case 1 + figure('Color','w','Position',[200 200 900 700]) + hold on + case 2 + hold off + otherwise + error('InputError: invalid newfig') + end + + s = size(Rmnc); + + if any(s~=size(Rmns)) + error('InputError: Rmnc has not the same size as Rmns') + end + if any(s~=size(Zmns)) + error('InputError: Rmnc has not the same size as Zmns') + end + if any(s~=size(Zmnc)) + error('InputError: Rmnc has not the same size as Zmnc') + end + if nt<1 + error('InputError: nt should be larger than 1') + end + + Ntor = (s(1)-1) / 2.0; + Mpol = s(2)-1; + + tarr = linspace( 0, 2*pi, nt ); + R = zeros( 1, nt ); + Z = zeros( 1, nt ); + Nfp = double(obj.physicslist.Nfp); + + + for in=1:s(1) + nn = in-1-Ntor; + for im=1:s(2) + mm = im-1; + + arg = mm*tarr - nn*Nfp*phi; + + R = R + Rmnc(in,im) * cos(arg) + Rmns(in,im) * sin(arg); + Z = Z + Zmnc(in,im) * cos(arg) + Zmns(in,im) * sin(arg); + end + end + + plot( R, Z, varargin{:} ) end end -end \ No newline at end of file +end + + + + + + + + + + + + + + + + + + diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m deleted file mode 100644 index bf887ee9..00000000 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist_depr.m +++ /dev/null @@ -1,2187 +0,0 @@ -classdef SPEC_Namelist - properties (Access=public) - lists - physicslist - numericlist - locallist - globallist - diagnosticslist - screenlist - initial_guess - end - - methods (Access=public) - - % ===================================================================== - % Class constructor - function obj = SPEC_Namelist(inputfile) - - % Read namelist - work = read_namelist( inputfile ); - obj.lists = fields(work); - - % Read Lboundary - if isfield(work.physicslist, 'Lboundary') - Lboundary = work.physicslist.Lboundary; - else - Lboundary = 0; % by default - end - - if Lboundary==0 - % Build im, in arrays - - %If boundary not given - if ~isfield(work.physicslist, 'Rbc') - if work.physicslist.Lfreebound==1 - work.physicslist.Rbc = zeros(size(work.physicslist.Rwc)); - work.physicslist.Rbs = zeros(size(work.physicslist.Rwc)); - work.physicslist.Zbc = zeros(size(work.physicslist.Rwc)); - work.physicslist.Zbs = zeros(size(work.physicslist.Rwc)); - work.physicslist.shift.Rbc = work.physicslist.shift.Rwc; - work.physicslist.shift.Rbs = work.physicslist.shift.Rws; - work.physicslist.shift.Zbc = work.physicslist.shift.Zwc; - work.physicslist.shift.Zbs = work.physicslist.shift.Zws; - else - error('Plasma boundary is not provided') - end - end - - if ~isfield(work.physicslist, 'Rwc') && work.physicslist.Lfreebound==1 - error('Computational boundary is not provided') - end - - if ~isfield(work.physicslist, 'Vnc') && work.physicslist.Lfreebound==1 - work.physicslist.Vnc = zeros(size( - - s = size(work.physicslist.Rbc); - mpol = s(2) - 1; - ntor = (s(1) - 1) / 2.0; - - im = 0:mpol; - in = -ntor:ntor; - - [work.physicslist.im, work.physicslist.in] = meshgrid(im,in); - - - % Need to build Rbc, Zbs, ... - arr_str = {'Rbc', 'Rbs', 'Zbc', 'Zbs', 'Rwc', 'Rws', 'Zwc', 'Zws', 'Vnc', 'Vns', 'Bnc', 'Bns'}; - n = length(arr_str); - ntor = zeros(1,n); - mpol = zeros(1,n); - for ii=1:n - - if ~isfield(work.physicslist, arr_str{ii}) - ntor(ii) = 0; - mpol(ii) = 0; - - continue - end - - if ~isfield(work.physicslist.shift, arr_str{ii}) - ntor(ii) = 0; - mpol(ii) = 0; - - continue - end - - s_shift = size(work.physicslist.(arr_str{ii})) - work.physicslist.shift.(arr_str{ii}); - ntor(ii) = s_shift(1); - mpol(ii) = s_shift(2); - - end - - %select poloidal and toroidal resolution for our arrays - if isfield(work.physicslist, 'Mpol') - Mpol = max(max(mpol), work.physicslist.Mpol); - Ntor = max(max(ntor), work.physicslist.Ntor); - else - Mpol = max(mpol); - Ntor = max(ntor); - end - - - bnd = struct; - for ii=1:n - fldname = arr_str{ii}; - bnd.(fldname) = zeros(Mpol+1, 2*Ntor+1); - - if ~isfield(work.physicslist, arr_str{ii}) - continue - end - - if ~isfield(work.physicslist.shift, arr_str{ii}) - continue - end - - - flds = size( work.physicslist.(fldname) ); - s = work.physicslist.shift.(fldname); - for in=1:flds(1) - - nn = in - s(1); - - for im=1:flds(2) - - mm = im - s(2); - bnd.(fldname)(mm+1,nn+Ntor+1) = work.physicslist.(fldname)(in,im); - - end - end - end - - % Finally build im, in grids - im = 0:Mpol; - in = -Ntor:Ntor; - - [in, im] = meshgrid(in, im); - - work.physicslist.im = im; - work.physicslist.in = in; - - - - else - - arr_str = {'R0c', 'Z0s', 'bn','rhomn'}; - n = length(arr_str); - ntor_arr = zeros(1,n); - - for ii=1:n - if strcmp(arr_str{ii}, 'rhomn') - continue - end - - ntor_arr(ii) = length(work.physicslist.(arr_str{ii}))-1; - end - - ntor = max( [work.physicslist.Ntor, max(ntor_arr)] ); - - for ii=1:n - if strcmp(arr_str{ii}, 'rhomn') - continue - end - - bnd.(arr_str{ii}) = zeros(1, ntor); - bnd.(arr_str{ii})(1:ntor_arr(ii)+1) = work.physicslist.(arr_str{ii})(1:ntor_arr(ii)+1); - end - - % Now deal with rhomn - s = size(work.physicslist.rhomn); - ntor_rho = max( (s(1)-1)/2.0, work.physicslist.Ntor ); - mpol_rho = max( s(2)-1 , work.physicslist.Mpol ); - - bnd.rhomn = zeros( mpol_rho+1, 2*ntor_rho+1 ); - - for ii=1:s(1) - - nn = ii - work.physicslist.shift.rhomn(1); - - for jj=1:s(2) - - mm = jj - work.physicslist.shift.rhomn(2); - - bnd.rhomn( mm+1, nn+ntor_rho+1 ) = work.physicslist.rhomn( ii, jj ); - end - end - - im = 0:mpol_rho; - in = -ntor_rho:ntor_rho; - - [in, im] = meshgrid(in, im); - - work.physicslist.im = im; - work.physicslist.in = in; - - end - - % Store in object - for ii=1:length(obj.lists) - obj.(obj.lists{ii}) = work.(obj.lists{ii}); - end - - for ii=1:n - fldname = arr_str{ii}; - obj.physicslist.(fldname) = bnd.(fldname); - end - - % Read initial guess - try - obj = obj.read_initial_guess( inputfile ); - catch - warning('No initial guess available') - end - - end - - function obj = read_initial_guess(obj, init_guess_file) - % - % Read geometrical initial guess from another input / .end file - % - % INPUT - % ----- - % - init_guess_file: filename from which initial guess is read - % - % OUTPUT - % ------ - % - obj: updated version of SPEC_Namelist object - % - - fid2 = fopen(init_guess_file, 'r'); - - save_line = false; - category = ''; - - initial_guess = {}; - - while( ~feof(fid2) ) % while it is not the end of the file - - tline = fgetl(fid2); - tline = strtrim(tline); - - if( save_line ) % write line - initial_guess{end+1} = tline; - - else % otherwise look for beginning of geometrical initial guess - if( strcmp(tline, '/') ) - if( strcmp(category,'screenlist') ) - save_line = true; - end - - else - % read category - if strcmp(tline(end-3:end),'list') - category = tline(2:end); - end - - end - end - end % end of while - - fclose(fid2); % Close file - - % ================================== - % Now, format initial guess in arrays - % Prepare format for reading - nlines = length(initial_guess); - - if isfield(obj.physicslist, 'Lboundary'); - Lboundary = obj.physicslist.Lboundary; - else - Lboundary = 0; % by default - end - - if nlines>0 - - % Allocate memory - Mpol = obj.physicslist.Mpol; - Ntor = obj.physicslist.Ntor; - Nvol = obj.physicslist.Nvol; - Mvol = Nvol + obj.physicslist.Lfreebound; - - if Lboundary==0 - Ric = zeros(Mpol+1,2*Ntor+1,Mvol); Zis = zeros(Mpol+1,2*Ntor+1,Mvol); - Ris = zeros(Mpol+1,2*Ntor+1,Mvol); Zic = zeros(Mpol+1,2*Ntor+1,Mvol); - - % Read - for iline=1:nlines - - % Scan line - line_data = str2num( initial_guess{iline} ); - - % Find corresponding index - m = line_data(1); n = line_data(2); - im = m+1; - in = n+Ntor+1; - - for ivol=1:Nvol - Ric(im,in,ivol) = line_data(ivol*4-1); - Zis(im,in,ivol) = line_data(ivol*4 ); - Ris(im,in,ivol) = line_data(ivol*4+1); - Zic(im,in,ivol) = line_data(ivol*4+2); - end - end - - init.Ric = Ric; - init.Ris = Ris; - init.Zis = Zis; - init.Zic = Zic; - else - - rhoi = zeros(Mpol , 2*Ntor+1, Mvol); - bin = zeros(Ntor+1, Mvol); - R0ic = zeros(Ntor+1, Mvol); - Z0is = zeros(Ntor+1, Mvol); - - for iline=1:nlines - - line_data = str2num( initial_guess{iline} ); - - m = line_data(1); - n = line_data(2); - - for ivol=1:Nvol - - if n>=0 && m==0 - bin( n+1, ivol) = line_data(ivol*4-1); - R0ic(n+1, ivol) = line_data(ivol*4 ); - Z0is(n+1, ivol) = line_data(ivol*4+1); - end - - if m>0 - rhoi( m, n+Ntor+1, ivol ) = line_data( ivol*4+2 ); - end - end - - end - - - init.rhoi = rhoi; - init.bin = bin; - init.R0ic = R0ic; - init.Z0is = Z0is; - - end - else - - if Lboundary==0 - init.Ric = []; - init.Ris = []; - init.Zic = []; - init.Zis = []; - init.im = []; - init.in = []; - init.surfaces = cell(0); - else - init.rhoi = []; - init.bin = []; - init.R0ic = []; - init.Z0is = []; - end - - end - - obj.initial_guess = init; - - - if nlines>0 && Lboundary==0 - obj.initial_guess.surfaces = cell(1,Nvol); - - for ii=1:Nvol - - fsurf = fluxSurface( obj.physicslist.Nfp, obj.physicslist.Mpol, ... - obj.physicslist.Ntor, obj.physicslist.Istellsym); - - work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Ric(:,:,ii)) ); - fsurf = fsurf.set_array( 'rmnc', work.mode, work.im, work.in ); - - work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Zis(:,:,ii)) ); - fsurf = fsurf.set_array( 'zmns', work.mode, work.im, work.in ); - - if ~obj.physicslist.Istellsym - work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Ris(:,:,ii)) ); - fsurf = fsurf.set_array( 'rmns', work.mode, work.im, work.in ); - - work = obj.reshape_array_2to1d( squeeze(obj.initial_guess.Zic(:,:,ii)) ); - fsurf = fsurf.set_array( 'zmnc', work.mode, work.im, work.in ); - end - - obj.initial_guess.surfaces{ii} = fsurf; - - end - - - % Build im, in arrays - s = size(obj.initial_guess.Ric); - mpol = s(1) - 1; - ntor = (s(2) - 1) / 2.0; - - im = 0:mpol; - in = -ntor:ntor; - [obj.initial_guess.in, obj.initial_guess.im] = meshgrid(in,im); - end - - - end - - function out = reshape_array_1to2d( obj, arr ) - - out.Mpol = max(arr.im); - out.Ntor = max(arr.in); - out.arr = zeros(Mpol+1,2*Ntor+1); - - nmn = length(in.im); - - ii=0; - for mm=0:out.Mpol - for nn=-out.Ntor:out.Ntor - if mm==0 && nn<0 - continue - end - - ii = ii + 1; - - out.arr( mm+1, nn+out.Ntor+1 ) = arr.mode( ii ); - end - end - - - end - - function out = reshape_array_2to1d( obj, arr ) - - s = size(arr); - Mpol = s(1) - 1; - Ntor = (s(2) - 1) /2.0 ; - - nmn = Ntor + 1 + Mpol*(2*Ntor+1); - - out.mode = zeros(1,nmn); - out.im = zeros(1,nmn); - out.in = zeros(1,nmn); - - ii=0; - for mm=0:Mpol - for nn=-Ntor:Ntor - if mm==0 && nn<0 - continue - end - - ii = ii+1; - out.im(ii) = mm; - out.in(ii) = nn; - - out.mode(ii) = arr(mm+1,nn+Ntor+1); - end - end - end - - function obj = read_axis_from_focus(obj, focus_data) - - Ntor = obj.physicslist.Ntor; - - axis = focus_data.get_axis_harmonics( Ntor ); - - obj.physicslist.Rac = axis.Remn(Ntor+1:end); - obj.physicslist.Ras = axis.Romn(Ntor+1:end); - obj.physicslist.Zac = axis.Zemn(Ntor+1:end); - obj.physicslist.Zas = axis.Zomn(Ntor+1:end); - - end - - function obj = interpolate_initial_guess( obj, interp_type, Linitialize ) - % - % INTERPOLATE_INITIAL_GUESS( INTERP_TYPE, LINITIALIZE ) - % ===================================================== - % - % Generate an initial guess by interpolation from computational boundary - % (if free-boundary and Linitialize=2) or from plasma boundary - % (if Linitialize=1). - % - % INPUTS - % ------ - % * interp_type: (1) Same interpolation as in SPEC - % (2) Same as in SPEC, but plasma boundary is considered - % as an internal plasma boundary - % * Linitialize (0) No interpolation - % (1) Inner plasma interfaces are interpolated - % (2) Inner plasma and plasma-vacuum interfaces are - % interpolated - % - % OUTPUTS - % ------- - % * obj: instance of SPEC_Namelist - % - % - - error('deprecated') - - machine_precision = eps; - vsmall = 100 * machine_precision; - small = 100 * vsmall; - - Nvol = obj.physicslist.Nvol; - Mvol = Nvol + obj.physicslist.Lfreebound; - - % First find the axis - if( obj.physicslist.Igeometry==3 && (obj.physicslist.Rac(1) Mpol - continue - end - - if abs(in(ii,jj)) > Ntor - continue - end - - - arg = im(ii,jj) * theta - in(ii,jj) * Nfp * phi; - cosarg = cos(arg); - sinarg = sin(arg); - - R = R + Rmnc(ii,jj) * cosarg ; - Z = Z + Zmns(ii,jj) * sinarg; - - if ~obj.physicslist.Istellsym - R = R + Rmns(ii,jj) * sinarg ; - Z = Z + Zmnc(ii,jj) * cosarg ; - end - - end - - end - - else - switch PorW - case 'P' - rhomn = obj.physicslist.rhomn; - bn = obj.physicslist.bn; - R0c = obj.physicslist.R0c; - Z0s = obj.physicslist.Z0s; - case 'W' - error('Not implemented yet') - otherwise - error('Invalid input') - end - - alpha = double(obj.physicslist.twoalpha) / 2.0; - - s = size(rhomn); - Nrho = (s(2)-1)/2.0; - - rhoij = zeros(1, Nt); - R0 = 0; - Z0 = 0; - b = 0; - - lr = length(obj.physicslist.R0c); - lz = length(obj.physicslist.Z0s); - lb = length(obj.physicslist.bn); - - for nn=0:Ntor - - in = nn+1; - - if in<=lr - R0 = R0 + obj.physicslist.R0c(in) * cos(nn*Nfp*phi ); - end - if in<=lz - Z0 = Z0 + obj.physicslist.Z0s(in) * sin(nn*Nfp*phi ); - end - if in<=lb - b = b + obj.physicslist.bn(in) * cos(nn*Nfp*phi ); - end - end - - zetaij = b*sin(theta - alpha*Nfp*phi); - - for ii=1:s(1) - for jj=1:s(2) - mm = ii-1; - nn = jj-1-Nrho; - - arg = mm*theta + nn*Nfp*phi - alpha*Nfp*phi; - - rhoij = rhoij + obj.physicslist.rhomn(ii,jj)*cos(arg); - end - end - - R = R0 + rhoij * cos(alpha*Nfp*phi) - zetaij * sin(alpha*Nfp*phi); - Z = Z0 + rhoij * sin(alpha*Nfp*phi) + zetaij * cos(alpha*Nfp*phi); - - - end - - switch newfig - case 0 - hold on; - case 1 - figure('Color', 'w', 'Position', [200 200 900 700]) - case 2 - hold off; - end - scatter(R,Z,50, 'filled') - xlabel('$R$[m]', 'Interpreter', 'latex') - ylabel('$Z$[m]', 'Interpreter', 'latex') - set(gca, 'FontSize', 18) - - end - - function plot_initial_guess( obj, phi, Nt, newfig ) - % - % PLOT_INITIAL_GUESS( PHI, NT, ONLY_BOUNDARY, NEWFIG ) - % ==================================================== - % - % Plots spec input initial guess. - % - % INPUTS - % ------ - % * PHI: Toroidal angle - % * NT: Number of points per surface - % * NEWFIG: (0) Plots on gcf - % (1) Opens a new figure - % (2) Overplots on gcf - % - % Written by A. Baillod (2020) - % - - % Open figure - switch newfig - case 0 - hold on - case 1 - figure('Position',[200 200 900 700], 'Color','w') - hold on; - case 2 - hold off; - otherwise - error( 'Unknown value of newfig') - end - - Nvol = obj.physicslist.Nvol; - - % Prepare theta coordinate - theta = linspace(0,2*pi,Nt)'; - - % Map to real space - if( ~isempty(obj.initial_guess) ) - newfig = 0; - for ivol=1:Nvol-1 - obj.initial_guess.surfaces{ivol}.plot_poloidal_section( phi, newfig ) - end - end - - % Plot plasma boundary - R = zeros(1,Nt); - Z = zeros(1,Nt); - - im = obj.physicslist.im; - in = obj.physicslist.in; - mn = size(im); - - for ii=1:mn(1) - for jj=1:mn(2) - cosarg = cos(im(ii,jj)*theta - in(ii,jj)*Np*phi); - sinarg = sin(im(ii,jj)*theta - in(ii,jj)*Np*phi); - - try - R(:) = R(:) + obj.physicslist.Rbc(ii,jj) * cosarg ... - + obj.physicslist.Rbs(ii,jj) * sinarg; - Z(:) = Z(:) + obj.physicslist.Zbc(ii,jj) * cosarg ... - + obj.physicslist.Zbs(ii,jj) * sinarg; - catch - disp('ouch') - end - end - end - - scatter(R, Z, 10, 'filled', 'MarkerFaceColor', [1 0 0]) - - - if obj.physicslist.Lfreebound - R = zeros(1,Nt); - Z = zeros(1,Nt); - - Rwc = obj.physicslist.Rwc; - Zwc = obj.physicslist.Zwc; - Rws = obj.physicslist.Rws; - Zws = obj.physicslist.Zws; - - for ii=1:mn(1) - for jj=1:mn(2) - cosarg = cos(im(ii,jj)*theta - in(ii,jj)*Np*phi); - sinarg = sin(im(ii,jj)*theta - in(ii,jj)*Np*phi); - - R(:) = R(:) + Rwc(ii,jj) * cosarg + Rws(ii,jj) * sinarg; - Z(:) = Z(:) + Zwc(ii,jj) * cosarg + Zws(ii,jj) * sinarg; - end - end - - scatter(R, Z, 5, 'filled', 'MarkerFaceColor', [0 0 0]) - end - - %Plot the magnetic axis guess - Rax = 0; Zax = 0; - mn = length(obj.physicslist.Rac); - Nfp = double(obj.physicslist.Nfp); - Ntor = obj.physicslist.Ntor; - for n=0:Ntor - Rax = Rax + obj.physicslist.Rac(n+1) * cos(n * Nfp * phi) ... - - obj.physicslist.Ras(n+1) * sin(n * Nfp * phi); - Zax = Zax + obj.physicslist.Zac(n+1) * cos(n * Nfp * phi) ... - - obj.physicslist.Zas(n+1) * sin(n * Nfp * phi); - end - - scatter( Rax, Zax, 50, 'filled', 'MarkerFaceColor', 'g') - - - axis equal; - - end - - function gif_initial_guess( obj, gifname, Nframes, frame_rate, varargin ) - - l = length(varargin); - if mod(l,2)~=0 - error('Incorrect number of input arguments') - end - - focus = false; f= NaN; - lines = NaN; - for ii=1:l/2 - field = varargin{2*ii-1}; - value = varargin{2*ii }; - - switch field - case 'focus' - focus = true; - f = value; - case 'lines' - lines = value; - end - end - - - figdir = pwd; - GIFNAME = [figdir, '/', gifname ]; - - Nfp = double(obj.physicslist.Nfp); - - if focus - s = size(f.outputdata.ppr); - Nframes = s(2)-1; - else - phi_array = linspace(0, 2.0*pi/Nfp, Nframes); - end - Nt = 1024; - - % determine xlim and ylim - ind = find( double(obj.physicslist.im~=0) .* double(obj.physicslist.in~=0) ); - %xmin = obj.physicslist.Rac(1) - sum(abs(obj.physicslist.Rwc(ind))) - sum(abs(obj.physicslist.Rws(ind))); - %xmax = obj.physicslist.Rac(1) + sum(abs(obj.physicslist.Rwc(ind))) + sum(abs(obj.physicslist.Rws(ind))); - %ymin = obj.physicslist.Zac(1) - sum(abs(obj.physicslist.Zwc(ind))) - sum(abs(obj.physicslist.Zws(ind))); - %ymax = obj.physicslist.Zac(1) + sum(abs(obj.physicslist.Zwc(ind))) + sum(abs(obj.physicslist.Zws(ind))); - - %ydiff = ymax-ymin; - %xdiff = xmax-xmin; - - for iframe = 1:Nframes - - if focus - if isnan(lines) - phi = f.plot_poincare( iframe, 1 ); - else - phi = f.plot_poincare( iframe, 1, 'lines', lines ); - end - - newfig = 0; - else - newfig = 1; - phi = phi_array(iframe); - end - - plot_initial_guess( obj, phi, Nt, newfig ) - - axis equal; - - %xlim([xmin*0.9, xmax*1.1]) - %ylim([ymin*0.9, ymax*1.1]) - - drawnow; - - % Capture the plot as an image - fig = gcf; - frame = getframe(fig); - im = frame2im(frame); - [imind,cm] = rgb2ind(im,32); - - % Write to the GIF File - if iframe == 1 - imwrite(imind,cm,GIFNAME,'gif', 'Loopcount',inf); - else - imwrite(imind,cm,GIFNAME,'gif','WriteMode','append', 'DelayTime', frame_rate); - end - - close( fig); - end - - disp(' ') - disp(['Gif saved @ : ',GIFNAME]) - - end - - - % ===================================================================== - % Getters - function out = get_plasma_boundary(obj, m, n)% - % Return Rbc, Zbs, Rbs, Zbc for given m, n mode - % - % INPUT - % ----- - % - m: poloidal harmonic - % - n: toroidal harmonic - % - % OUTPUT - % ------ - % - out: structure with field out.Rbc, out.Rbs, out.Zbc, out.Zbs - % - - Mpol = max(max(obj.physicslist.im)); - Ntor = max(max(obj.physicslist.in)); - - if m>Mpol || abs(n)>Ntor - out.Rbc = 0.0; - out.Rbs = 0.0; - out.Zbc = 0.0; - out.Zbs = 0.0; - else - out.Rbc = obj.physicslist.Rbc(m+1, n+Ntor+1); - out.Rbs = obj.physicslist.Rbs(m+1, n+Ntor+1); - out.Zbc = obj.physicslist.Zbc(m+1, n+Ntor+1); - out.Zbs = obj.physicslist.Zbs(m+1, n+Ntor+1); - end - - end - - function out = get_wall(obj, m, n) - % - % Return Rwc, Zws, Rws, Zwc for given m, n mode - % - % INPUT - % ----- - % - m: poloidal harmonic - % - n: toroidal harmonic - % - % OUTPUT - % ------ - % - out: structure with field out.Rwc, out.Rws, out.Zwc, out.Zws - % - Mpol = max(max(obj.physicslist.im)); - Ntor = max(max(obj.physicslist.in)); - - if m>Mpol || abs(n)>Ntor - out.Rwc = 0.0; - out.Rws = 0.0; - out.Zwc = 0.0; - out.Zws = 0.0; - else - out.Rwc = obj.physicslist.Rwc(m+1, n+Ntor+1); - out.Rws = obj.physicslist.Rws(m+1, n+Ntor+1); - out.Zwc = obj.physicslist.Zwc(m+1, n+Ntor+1); - out.Zws = obj.physicslist.Zws(m+1, n+Ntor+1); - end - end - - function out = get_vnc_bns(obj, m, n) - % Return Vnc, Vns, Bnc, Bns for given m, n mode - % - % INPUT - % ----- - % - m: poloidal harmonic - % - n: toroidal harmonic - % - % OUTPUT - % ------ - % - out: structure with field out.Vnc, out.Vns, out.Bnc, out.Bns - % - Mpol = max(max(obj.physicslist.im)); - Ntor = max(max(obj.physicslist.in)); - - if m>Mpol || abs(n)>Ntor - out.Vnc = 0.0; - out.Vns = 0.0; - out.Bnc = 0.0; - out.Bns = 0.0; - else - out.Vnc = obj.physicslist.Vnc(m+1, n+Ntor+1); - out.Vns = obj.physicslist.Vns(m+1, n+Ntor+1); - out.Bnc = obj.physicslist.Bnc(m+1, n+Ntor+1); - out.Bns = obj.physicslist.Bns(m+1, n+Ntor+1); - end - end - - function out = get_fourier_harmonics(obj, m, n, field) - - Mpol = max(max(obj.physicslist.im)); - Ntor = max(max(obj.physicslist.in)); - - - if( strcmp(field, 'Ric') || strcmp(field, 'Ris') || strcmp(field, 'Zic') || strcmp(field, 'Zis')) - if( isempty(obj.initial_guess) ) - error('No initial guess') - else - out = obj.initial_guess.(field)(ii); - end - else - out = obj.physicslist.(field)(m+1, n+Ntor+1); - end - end - - - % ===================================================================== - % Setters - function obj = truncate_fourier_series( obj, min_value ) - - nmn = length(obj.physicslist.im); - - ind = cell(1,12); - - ind{1} = find(obj.physicslist.Rbc obj.physicslist.Mpol ); - ind2 = find( abs(obj.physicslist.in) > obj.physicslist.Ntor ); - - ind = union( ind1, ind2 ); - - obj.physicslist.im(ind) = []; - obj.physicslist.in(ind) = []; - obj.physicslist.Rbc(ind) = []; - obj.physicslist.Rbs(ind) = []; - obj.physicslist.Zbc(ind) = []; - obj.physicslist.Zbs(ind) = []; - - obj.physicslist.Rwc(ind) = []; - obj.physicslist.Rws(ind) = []; - obj.physicslist.Zwc(ind) = []; - obj.physicslist.Zws(ind) = []; - - obj.physicslist.Vnc(ind) = []; - obj.physicslist.Vns(ind) = []; - obj.physicslist.Bnc(ind) = []; - obj.physicslist.Bns(ind) = []; - - if ~isempty( obj.initial_guess ) - obj.initial_guess.Ric(ind,:) = []; - obj.initial_guess.Ris(ind,:) = []; - obj.initial_guess.Zic(ind,:) = []; - obj.initial_guess.Zis(ind,:) = []; - end - end - - function obj = set_fourier_harmonics(obj, im, in, values, field, varargin) - - l = length(varargin); - if( mod(l,2)~=0 ) - error('Invalid number of argument') - end - - set_to_zero=true; - for iv=1:l/2 - fieldarg=varargin{2*iv-1}; - value=varargin{2*iv}; - switch fieldarg - case 'set_to_zero' - set_to_zero=value; - otherwise - error('Unknown input') - end - end - - - mn = length(im); - mn_old = length(obj.physicslist.Rbc); - - - if set_to_zero - obj.physicslist.(field) = zeros(size(obj.physicslist.Rbc)); - end - - for ii = 1:mn - m = im(ii); n=in(ii); - imn = obj.find_ii_given_mn(m, n); - - if( isempty(imn) ) % Add mode - obj.physicslist.im(end+1) = m; - obj.physicslist.in(end+1) = n; - - obj.physicslist.Rbc(end+1) = 0.0; - obj.physicslist.Rbs(end+1) = 0.0; - obj.physicslist.Zbc(end+1) = 0.0; - obj.physicslist.Zbs(end+1) = 0.0; - - obj.physicslist.Rwc(end+1) = 0.0; - obj.physicslist.Rws(end+1) = 0.0; - obj.physicslist.Zwc(end+1) = 0.0; - obj.physicslist.Zws(end+1) = 0.0; - - obj.physicslist.Vnc(end+1) = 0.0; - obj.physicslist.Vns(end+1) = 0.0; - obj.physicslist.Bnc(end+1) = 0.0; - obj.physicslist.Bns(end+1) = 0.0; - - if( ~isempty(obj.initial_guess) ) - obj.initial_guess.Ric(end+1, :) = 0.0; - obj.initial_guess.Ris(end+1, :) = 0.0; - obj.initial_guess.Zic(end+1, :) = 0.0; - obj.initial_guess.Zis(end+1, :) = 0.0; - end - - obj.physicslist.(field)(end) = values(ii); - - else - obj.physicslist.(field)(imn) = values(ii); - - end - - - end - - if ~(strcmp(field, 'Vnc') || strcmp(field, 'Vns') || strcmp(field, 'Bnc') || strcmp(field, 'Bns') ) - obj = obj.update_flux_surfaces(); - end - - end - - function obj = convert_to_standard_representation( obj ) - - Lb = obj.physicslist.Lboundary; - if Lb==0 - error('Can only convert from Lboundary=1 to Lboundary=0') - end - - obj.physicslist.Lboundary=0; - obj.physicslist.twoalpha=0; - - % Map computational boundary - if( obj.physicslist.Lfreebound ) - error('Not implemented for freeboundary cases yet') - end - - % Map computational boundary - rhomn = obj.physicslist.rhomn; - bn = obj.physicslist.bn; - R0c = obj.physicslist.R0c; - Z0s = obj.physicslist.Z0s; - alpha = obj.physicslist.twoalpha / 2.0; - - [Rmn, Zmn, Mpol, Ntor] = map_rho_to_RZ( rhomn, bn, R0c, Z0s, alpha, 0); - - obj.physicslist.Mpol = Mpol; - obj.physicslist.Ntor = Ntor; - - obj.physicslist.Rbc = Rmn; - obj.physicslist.Zbs = Zmn; - obj.physicslist.Rbs = zeros(size(Rmn)); - obj.physicslist.Zbc = zeros(size(Zmn)); - - obj.physicslist = rmfield(obj.physicslist, 'rhomn'); - obj.physicslist = rmfield(obj.physicslist, 'bn'); - obj.physicslist = rmfield(obj.physicslist, 'R0c'); - obj.physicslist = rmfield(obj.physicslist, 'Z0s'); - - % Map initial guess - if ~isempty(obj.initial_guess ) - Nvol = obj.physicslist.Nvol; - - obj.initial_guess.Ric = zeros( Mpol+1, 2*Ntor+1, Nvol ); - obj.initial_guess.Ris = zeros( Mpol+1, 2*Ntor+1, Nvol ); - obj.initial_guess.Zic = zeros( Mpol+1, 2*Ntor+1, Nvol ); - obj.initial_guess.Zis = zeros( Mpol+1, 2*Ntor+1, Nvol ); - - % Plasma boundary - obj.initial_guess.Ric(:,:,Nvol) = Rmn; - obj.initial_guess.Zis(:,:,Nvol) = Zmn; - - % Inner interfaces - for ivol=1:Nvol-1 - [Rmn, Zmn, Mpol, Ntor] = map_rho_to_RZ( obj.initial_guess.rhoi(:,:,ivol), ... - obj.initial_guess.bin(:,ivol), ... - obj.initial_guess.R0ic(:,ivol), ... - obj.initial_guess.Z0is(:,ivol), ... - alpha, 0); - obj.initial_guess.Ric(1:Mpol+1,1:2*Ntor+1,ivol) = Rmn; - obj.initial_guess.Zis(1:Mpol+1,1:2*Ntor+1,ivol) = Zmn; - end - - obj.initial_guess = rmfield(obj.initial_guess, 'rhoi'); - obj.initial_guess = rmfield(obj.initial_guess, 'bin'); - obj.initial_guess = rmfield(obj.initial_guess, 'R0ic'); - obj.initial_guess = rmfield(obj.initial_guess, 'Z0is'); - end - - - end - - - - function obj = set_initial_guess_harmonics( obj, volume, im, in, values, field) - - - mn = length(im); - mn_old = length(obj.physicslist.Rbc); - Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; - - if isempty(obj.initial_guess) - obj.initial_guess.Ric = zeros( mn_old, Mvol ); - obj.initial_guess.Ris = zeros( mn_old, Mvol ); - obj.initial_guess.Zic = zeros( mn_old, Mvol ); - obj.initial_guess.Zis = zeros( mn_old, Mvol ); - end - - %obj.initial_guess.(field) = zeros(mn_old, Mvol); - tmp = obj.initial_guess.(field); - tmp( 1:mn_old, volume ) = zeros( mn_old, 1 ); - - for ii = 1:mn - m = im(ii); n=in(ii); - imn = obj.find_ii_given_mn(m, n); - - if( isempty(imn) ) % Add mode - obj.physicslist.im(end+1) = m; - obj.physicslist.in(end+1) = n; - - obj.physicslist.Rbc(end+1) = 0.0; - obj.physicslist.Rbs(end+1) = 0.0; - obj.physicslist.Zbc(end+1) = 0.0; - obj.physicslist.Zbs(end+1) = 0.0; - - obj.physicslist.Rwc(end+1) = 0.0; - obj.physicslist.Rws(end+1) = 0.0; - obj.physicslist.Zwc(end+1) = 0.0; - obj.physicslist.Zws(end+1) = 0.0; - - obj.physicslist.Vnc(end+1) = 0.0; - obj.physicslist.Vns(end+1) = 0.0; - obj.physicslist.Bnc(end+1) = 0.0; - obj.physicslist.Bns(end+1) = 0.0; - - obj.initial_guess.Ric(end+1, :) = 0.0; - obj.initial_guess.Ris(end+1, :) = 0.0; - obj.initial_guess.Zic(end+1, :) = 0.0; - obj.initial_guess.Zis(end+1, :) = 0.0; - - tmp( end+1, : ) = 0.0; - tmp( end , volume ) = values(ii); - - else - tmp( imn, volume ) = values(ii); - - end - - obj.initial_guess.(field) = tmp; - - - end - - - end - - - % ===================================================================== - % Utility - function compare_fourier_harmonics(obj, spec_nm, field) - - nm_in = length(obj.physicslist.im); - nm_ou = length(spec_nm.physicslist.im); - - nm = max([nm_in, nm_ou]); - - for ii = 1:nm - - if( nm_in>nm_ou) - m = obj.physicslist.im(ii); - n = obj.physicslist.in(ii); - else - m = spec_nm.physicslist.im(ii); - n = spec_nm.physicslist.in(ii); - end - - ind_in = obj.find_ii_given_mn( m, n); - ind_ou = spec_nm.find_ii_given_mn( m, n); - - if( isempty(ind_in) ) - if( ~isempty(ind_ou) ) - value = spec_nm.physicslist.(field)(ind_ou); - if( value ~= 0 ) - disp( [field, '(', num2str(m), ',', num2str(n) ') missmatch. Obj has value 0 while spec_nm has value ', num2str(value)]); - end - end - else - val_in = obj.physicslist.(field)(ind_in); - if( isempty(ind_ou) ) - disp( [field, '(', num2str(m), ',', num2str(n) ') missmatch. Obj has value ', num2str(val_in), ' while spec_nm has value 0']); - else - val_ou = spec_nm.physicslist.(field)(ind_ou); - - delta = abs(val_in - val_ou); - if( delta>1E-16 ) - disp( [field, '(', num2str(m), ',', num2str(n) ') missmatch. Obj has value ', num2str(val_in), ' while spec_nm has value ', num2str(val_ou)]) - end - end - end - - - - end - - - - - end - - function obj = add_volume( obj, tflux ) - - Nvol = obj.physicslist.Nvol; - if Nvol==1 - error('Not implemented for Nvol=1') - end - - obj.physicslist.Nvol = obj.physicslist.Nvol + 1; - - % Find between which interface to put it - [tmp, ind] = min(abs(tflux - obj.physicslist.tflux)); - tmp = obj.physicslist.tflux(ind); - - if tmp-tflux>0 - ind = ind-1; - end - - disp(newline) - disp(newline) - fprintf('Adding a volume between interface %u and %u ...\n', ind, ind+1) - fprintf('======================================================\n') - - % Build new profiles - old_tflux = obj.physicslist.tflux; - obj.physicslist.tflux = [obj.physicslist.tflux(1:ind), tflux, obj.physicslist.tflux(ind+1:end)]; - - pflux = obj.physicslist.pflux; - if ind==0 - newpflux = pflux(ind+1)/2; - else - newpflux = (pflux(ind)+pflux(ind+1))/2; - end - obj.physicslist.pflux = [pflux(1:ind), newpflux, pflux(ind+1:end)]; - - Lrad = obj.physicslist.Lrad; - obj.physicslist.Lrad = [Lrad(1:ind), Lrad(ind+1), Lrad]; - - hel = obj.physicslist.helicity; - obj.physicslist.helicity = [hel(1:ind), 0, hel(ind+1:end)]; - - pressure = obj.physicslist.pressure; - if ind==0 - newpressure = pressure(ind+1)*1.3; - else - newpressure = (pressure(ind)+pressure(ind+1))/2; - end - obj.physicslist.pressure = [pressure(1:ind), newpressure, pressure(ind+1:end)]; - - adiabatic = obj.physicslist.adiabatic; - if ind==0 - newadiab = adiabatic(ind+1); - else - newadiab = (adiabatic(ind)+adiabatic(ind+1))/2; - end - obj.physicslist.adiabatic = [adiabatic(1:ind), newadiab, adiabatic(ind+1:end)]; - - mu = obj.physicslist.mu; - obj.physicslist.mu = [mu(1:ind), mu(ind+1), mu(ind+1:end)]; - - Ivolume = obj.physicslist.Ivolume; - obj.physicslist.Ivolume = [Ivolume(1:ind), Ivolume(ind+1), Ivolume(ind+1:end)]; - - Isurf = obj.physicslist.Isurf; - if ind==0 - newIsurf = Isurf(1); - else - newIsurf = Isurf(ind); - end - obj.physicslist.Isurf = [Isurf(1:ind), newIsurf, Isurf(ind+1:end)]; - - iota = obj.physicslist.iota; - if ind==0 - newiota = iota(ind+1); - else - newiota = (iota(ind)+iota(ind+1))/2; - end - obj.physicslist.iota = [iota(1:ind), newiota, iota(ind+1:end)]; - - oita = obj.physicslist.oita; - if ind==0 - newoita = oita(ind+1); - else - newoita = (oita(ind)+oita(ind+1))/2; - end - obj.physicslist.oita = [oita(1:ind), newoita, oita(ind+1:end)]; - - disp(newline) - fprintf('New profiles have been generated with averaged values. Please modify if necessary.\n') - fprintf(' tflux = %.8E \n', tflux ) - fprintf(' pflux = %.8E \n', newpflux ) - fprintf(' Lrad = %.8E \n', Lrad(ind+1) ) - fprintf(' helicity = %.8E \n', 0 ) - fprintf(' pressure = %.8E \n', newpressure ) - fprintf(' adiabatic = %.8E \n', newadiab ) - fprintf(' mu = %.8E \n', mu(ind+1) ) - fprintf(' Ivolume = %.8E \n', Ivolume(ind+1) ) - fprintf(' Isurf = %.8E \n', newIsurf ) - fprintf(' iota = %.8E \n', newiota ) - fprintf(' oita = %.8E \n', newoita ) - disp(newline) - - - % Interpolate initial guess - if( isempty(obj.initial_guess) ) - disp('No initial guess to build, returning ...') - disp(newline) - return - end - - - - % First select closest boundaries harmonics -% -% nmn = length( obj.physicslist.im ); -% Mpol = max(obj.physicslist.im); -% Ntor = max(obj.physicslist.in); -% stellsym = false; -% -% newGuess = fluxSurface( obj.physicslist.Nfp, Mpol, Ntor, stellsym ); -% -% for imn = 1:nmn -% -% m = obj.physicslist.im(imn); -% n = obj.physicslist.in(imn); -% -% x = [0, old_tflux( 1:end-1 )]; -% -% y = obj.initial_guess.Ric( imn, 1:end-1 ); -% y = [0, y]; -% if m==0 -% y(1) = obj.physicslist.Rac( n+1 ); -% end -% p = polyfit( x, y./x, 1 ); -% value = polyval( p, tflux ) * tflux; -% newGuess = newGuess.set_value( 'rmnc', value, m, n ); -% -% y = obj.initial_guess.Ris( imn, 1:end-1 ); -% y = [0, y]; -% if m==0 -% y(1) = obj.physicslist.Ras( n+1 ); -% end -% p = polyfit( x, y./x, 1 ); -% value = polyval( p, tflux ) * tflux; -% newGuess = newGuess.set_value( 'rmns', value, m, n ); -% -% y = obj.initial_guess.Zic( imn, 1:end-1 ); -% y = [0, y]; -% if m==0 -% y(1) = obj.physicslist.Zac( n+1 ); -% end -% p = polyfit( x, y./x, 1 ); -% value = polyval( p, tflux ) * tflux; -% newGuess = newGuess.set_value( 'zmnc', value, m, n ); -% -% y = obj.initial_guess.Zis( imn, 1:end-1 ); -% y = [0, y]; -% if m==0 -% y(1) = obj.physicslist.Zas( n+1 ); -% end -% p = polyfit( x, y./x, 1 ); -% value = polyval( p, tflux ) * tflux; -% newGuess = newGuess.set_value( 'zmns', value, m, n ); -% end -% -% obj.initial_guess.Ric = [obj.initial_guess.Ric(:,1:ind), newGuess.rmnc', obj.initial_guess.Ric(:,ind+1:end)]; -% obj.initial_guess.Ris = [obj.initial_guess.Ris(:,1:ind), newGuess.rmns', obj.initial_guess.Ris(:,ind+1:end)]; -% obj.initial_guess.Zic = [obj.initial_guess.Zic(:,1:ind), newGuess.zmnc', obj.initial_guess.Zic(:,ind+1:end)]; -% obj.initial_guess.Zis = [obj.initial_guess.Zis(:,1:ind), newGuess.zmns', obj.initial_guess.Zis(:,ind+1:end)]; - - - - nmn = length(obj.physicslist.im); - - if ind==0 %Then first volume, need regularisation - l = length(obj.physicslist.Rac); - if l>obj.physicslist.Ntor+1 - l = obj.physicslist.Ntor+1; - end - - Ric_low = zeros(nmn, 1); - Ric_low(1:l) = obj.physicslist.Rac(1:l); - Ris_low = zeros(nmn, 1); - Ris_low(1:l) = obj.physicslist.Ras(1:l); - Zic_low = zeros(nmn, 1); - Zic_low(1:l) = obj.physicslist.Zac(1:l); - Zis_low = zeros(nmn, 1); - Zis_low(1:l) = obj.physicslist.Zas(1:l); - - delta_tflux = obj.physicslist.tflux(ind+2); - tflux_norm = tflux / delta_tflux; - - else - delta_tflux = obj.physicslist.tflux(ind+2) - obj.physicslist.tflux(ind); - tflux_norm = (tflux - obj.physicslist.tflux(ind)) / delta_tflux; - Ric_low = obj.initial_guess.Ric(:,ind); - Ris_low = obj.initial_guess.Ris(:,ind); - Zic_low = obj.initial_guess.Zic(:,ind); - Zis_low = obj.initial_guess.Zis(:,ind); - - end - - - if ind==Nvol-1 - Ric_high = obj.physicslist.Rbc'; - Ris_high = obj.physicslist.Rbs'; - Zic_high = obj.physicslist.Zbc'; - Zis_high = obj.physicslist.Zbs'; - - else - Ric_high = obj.initial_guess.Ric(:,ind+1); - Ris_high = obj.initial_guess.Ris(:,ind+1); - Zic_high = obj.initial_guess.Zic(:,ind+1); - Zis_high = obj.initial_guess.Zis(:,ind+1); - - end - - % Now build regularisation factor - fj = zeros(nmn, 1); - - if ind==0 % first volume, need to regularize non-zero m-harmonics - - for ii=1:nmn - im = obj.physicslist.im(ii); - - if im==0 - fj(ii) = sqrt(tflux_norm); - else - fj(ii) = tflux_norm.^(im / 2.0); - end - end - - else % Not in first volume, them linear interpolation in radius - - fj = ones(nmn, 1) * sqrt(tflux_norm); - - end - - - % Interpolate - new_Ric = Ric_low + (Ric_high - Ric_low) .* tflux_norm; - new_Ris = Ris_low + (Ris_high - Ris_low) .* tflux_norm; - new_Zic = Zic_low + (Zic_high - Zic_low) .* tflux_norm; - new_Zis = Zis_low + (Zis_high - Zis_low) .* tflux_norm; - - - obj.initial_guess.Ric = [obj.initial_guess.Ric(:,1:ind), new_Ric, obj.initial_guess.Ric(:,ind+1:end)]; - obj.initial_guess.Ris = [obj.initial_guess.Ris(:,1:ind), new_Ris, obj.initial_guess.Ris(:,ind+1:end)]; - obj.initial_guess.Zic = [obj.initial_guess.Zic(:,1:ind), new_Zic, obj.initial_guess.Zic(:,ind+1:end)]; - obj.initial_guess.Zis = [obj.initial_guess.Zis(:,1:ind), new_Zis, obj.initial_guess.Zis(:,ind+1:end)]; - - - end - - function obj = remove_volume( obj, ivol ) - - obj.physicslist.Nvol = obj.physicslist.Nvol-1; - obj.physicslist.Lrad = [obj.physicslist.Lrad(1:ivol-1), obj.physicslist.Lrad(ivol+1:end) ]; - obj.physicslist.tflux = [obj.physicslist.tflux(1:ivol-1), obj.physicslist.tflux(ivol+1:end) ]; - obj.physicslist.pflux = [obj.physicslist.pflux(1:ivol-1), obj.physicslist.pflux(ivol+1:end) ]; - obj.physicslist.helicity = [obj.physicslist.helicity(1:ivol-1), obj.physicslist.helicity(ivol+1:end) ]; - obj.physicslist.pressure = [obj.physicslist.pressure(1:ivol-1), obj.physicslist.pressure(ivol+1:end) ]; - obj.physicslist.adiabatic = [obj.physicslist.adiabatic(1:ivol-1), obj.physicslist.adiabatic(ivol+1:end)]; - obj.physicslist.mu = [obj.physicslist.mu(1:ivol-1), obj.physicslist.mu(ivol+1:end) ]; - obj.physicslist.Ivolume = [obj.physicslist.Ivolume(1:ivol-1), obj.physicslist.Ivolume(ivol+1:end) ]; - obj.physicslist.Isurf = [obj.physicslist.Isurf(1:ivol-1), obj.physicslist.Isurf(ivol+1:end) ]; - obj.physicslist.iota = [obj.physicslist.iota(1:ivol), obj.physicslist.iota(ivol+2:end) ]; - obj.physicslist.oita = [obj.physicslist.oita(1:ivol), obj.physicslist.oita(ivol+2:end) ]; - obj.diagnosticslist.nPtrj = [obj.diagnosticslist.nPtrj(1:ivol-1), obj.diagnosticslist.nPtrj(ivol+1:end)]; - - - obj.initial_guess.Ric = [obj.initial_guess.Ric(:,1:ivol-1), obj.initial_guess.Ric(:,ivol+1:end)]; - obj.initial_guess.Ris = [obj.initial_guess.Ris(:,1:ivol-1), obj.initial_guess.Ris(:,ivol+1:end)]; - obj.initial_guess.Zic = [obj.initial_guess.Zic(:,1:ivol-1), obj.initial_guess.Zic(:,ivol+1:end)]; - obj.initial_guess.Zis = [obj.initial_guess.Zis(:,1:ivol-1), obj.initial_guess.Zis(:,ivol+1:end)]; - - - end - - - % ===================================================================== - % Write method - function write_input_file(obj, filename ) - % - % write_input_file(filename, (force) ) - % - % Write namelist in an input file. Be careful: if the file filename - % provided as input exist, it will be overwritten! - % - % INPUT - % ----- - % - filename: path where to save the input file. - % - options: structure containing optional input - % * force: set to true to force overwritting the input file - % - - - nlists = length(obj.lists); - S = struct; - for ii=1:nlists - S.(obj.lists{ii}) = obj.(obj.lists{ii}); - end - - S.physicslist = rmfield( S.physicslist, 'im' ); - S.physicslist = rmfield( S.physicslist, 'in' ); - try - S.physicslist = rmfield( S.physicslist, 'PlasmaBoundary' ); - catch - disp('No field PlasmaBoundary...') - end - - try - S.physicslist = rmfield( S.physicslist, 'ComputationalBoundary' ); - catch - disp('No field ComputationalBoundary...') - end - - if isfield(S.physicslist, 'Lboundary') - Lboundary = S.physicslist.Lboundary; - else - Lboundary = 0; %by default - end - - Ntor = max(max(obj.physicslist.in)); - S.shift.Rbc = [1, Ntor+1]; - S.shift.Rbs = [1, Ntor+1]; - S.shift.Zbc = [1, Ntor+1]; - S.shift.Zbs = [1, Ntor+1]; - S.shift.Rwc = [1, Ntor+1]; - S.shift.Rws = [1, Ntor+1]; - S.shift.Zws = [1, Ntor+1]; - S.shift.Zwc = [1, Ntor+1]; - S.shift.Vnc = [1, Ntor+1]; - S.shift.Vns = [1, Ntor+1]; - S.shift.Bnc = [1, Ntor+1]; - S.shift.Bns = [1, Ntor+1]; - S.shift.rhomn = [1, Ntor+1]; - - if Lboundary==0 - - initialguess = cell(1,1); - if ~isempty(obj.initial_guess) - s = size(obj.initial_guess.Ric); - initialguess = cell(1, s(1)*s(2)); - n=0; - for ii=1:s(1) - for jj=1:s(2) - n = n+1; - initialguess{n} = sprintf( '%i %i ', obj.initial_guess.im(ii,jj), obj.initial_guess.in(ii,jj) ); - for ivol=1:s(3) - initialguess{n} = sprintf( '%s %0.12E %0.12E %0.12E %0.12E', initialguess{n}, ... - obj.initial_guess.Ric(ii,jj,ivol), ... - obj.initial_guess.Zis(ii,jj,ivol), ... - obj.initial_guess.Ris(ii,jj,ivol), ... - obj.initial_guess.Zic(ii,jj,ivol) ); - end - end - end - end - - else - - nrho = max(max(obj.physicslist.in)); - S.shift.rhomn = [ 1, nrho+1 ]; - - % Now prepare initial guess... - if isfield(obj.initial_guess, 'bin') - sb = size(obj.initial_guess.bin); - srho = size(obj.initial_guess.rhoi); - ntor = (srho(2)-1)/2.0; - initialguess = cell(1, sb(1) + srho(1)*srho(2)); - - % Modes m=0, n - for ii=1:sb(1) - nn = ii-1; - initialguess{ii} = sprintf('0 %i ', nn); - for ivol=1:sb(2) - initialguess{ii} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii}, ... - obj.initial_guess.bin( ii, ivol ), ... - obj.initial_guess.R0ic(ii, ivol ), ... - obj.initial_guess.Z0is(ii, ivol ), 0.0 ); - end - end - - it = sb(1); - for ii=1:srho(2) - - nn = ii-ntor-1; - - for jj=1:srho(1) - - it = it+1; - - mm = jj; - - initialguess{it} = sprintf('%i %i ', mm, nn); - - for ivol=1:srho(3) - - initialguess{it} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii},... - 0.0, 0.0, 0.0, obj.initial_guess.rhoi(ii, jj, ivol)); - - end - end - end - else - initialguess = cell(0); - - end - - - - end - - write_namelist( S, filename, initialguess ); - - -% % Read options -% if( isempty(varargin) ) -% force = false; -% else -% if( isfield(varargin{1}, 'force') ) -% force = varargin{1}.force; -% else -% force = false; -% end -% end -% -% % Check if user want to erase existing file -% if (exist(filename, 'file') && (~force)) -% prompt = ['The file ', filename, ' already exist and will be overwritten. Continue? Y/N [Y]: ']; -% c = input(prompt, 's'); -% if( isempty(c) ) -% c = 'Y'; -% end -% -% while ~( (c=='Y') || (c=='N') ) -% c = input('Please answer Y or N: ', 's'); -% end -% -% if strcmp(c,'N') %exit routine -% disp('ABORTED') -% return; -% else -% disp(['Overwriting file ', filename, '.']) -% end -% end -% -% % Open file -% fid = fopen(filename, 'w'); -% -% -% special_list = {'Rbc', 'Rbs', 'Zbc', 'Zbs', 'im', 'in', ... -% 'Rwc', 'Rws', 'Zwc', 'Zws', ... -% 'Vnc', 'Vns', 'Bnc', 'Bns', ... -% 'PlasmaBoundary', 'ComputationalBoundary'}; -% for ii=1:numel(obj.lists) -% list = obj.lists{ii}; -% -% if strcmp(list, 'physicslist') -% obj.write_list(fid, list, special_list) -% -% % write Rbc, ... -% obj.write_4_values(fid, 'Rbc', 'Zbs', 'Rbs', 'Zbc'); -% obj.write_4_values(fid, 'Rwc', 'Zws', 'Rws', 'Zwc'); -% obj.write_4_values(fid, 'Vnc', 'Vns', 'Bnc', 'Bns'); -% -% fprintf(fid, '/ \n'); -% -% else -% obj.write_list(fid, list, special_list) -% -% fprintf(fid, '/ \n'); -% end -% -% end -% -% -% im = obj.physicslist.im; in = obj.physicslist.in; -% mn = length(im); -% -% if( ~isempty(obj.initial_guess) ) -% Ric = obj.initial_guess.Ric; -% s = size(Ric); -% -% for ii=1:mn -% fprintf(fid, ' %i %i', im(ii), in(ii)); -% for jj=1:s(2) -% fprintf(fid, ' %19.15E %19.15E %19.15E %19.15E', ... -% obj.initial_guess.Ric(ii,jj), ... -% obj.initial_guess.Zis(ii,jj), ... -% obj.initial_guess.Ris(ii,jj), ... -% obj.initial_guess.Zic(ii,jj)); % Print in file -% end -% fprintf(fid, '\n'); -% end -% end -% -% % close file -% fclose(fid); - - end %of function write_input_file - - - function ii = find_ii_given_mn(obj, m, n) - - im = obj.physicslist.im; - in = obj.physicslist.in; - ii = find(double(im==m) .* double(in==n)); - end - - end % of public methods - % ---------------------------------------------------------------------- - % PRIVATE METHODS - % ====================================================================== - % - methods (Access = private) - - function obj = update_flux_surfaces( obj ) - - im = obj.physicslist.im; - in = obj.physicslist.in; - Mpol = max(max(im)); Ntor = max(max(in)); - - PlasmaBoundary = fluxSurface(obj.physicslist.Nfp, Mpol, Ntor, 0); - PlasmaBoundary = PlasmaBoundary.set_array('rmnc', obj.physicslist.Rbc, im, in); - PlasmaBoundary = PlasmaBoundary.set_array('rmns', obj.physicslist.Rbs, im, in); - PlasmaBoundary = PlasmaBoundary.set_array('zmnc', obj.physicslist.Zbc, im, in); - PlasmaBoundary = PlasmaBoundary.set_array('zmns', obj.physicslist.Zbs, im, in); - obj.physicslist.PlasmaBoundary = PlasmaBoundary; - - CompBoundary = fluxSurface(obj.physicslist.Nfp, Mpol, Ntor, 0); - CompBoundary = CompBoundary.set_array('rmnc', obj.physicslist.Rwc, im, in); - CompBoundary = CompBoundary.set_array('rmns', obj.physicslist.Rws, im, in); - CompBoundary = CompBoundary.set_array('zmnc', obj.physicslist.Zwc, im, in); - CompBoundary = CompBoundary.set_array('zmns', obj.physicslist.Zws, im, in); - obj.physicslist.ComputationalBoundary = CompBoundary; - end - - function [value, field] = extract_4_values(obj, tline, n, m, str1, str2, str3, str4) - % Extract rbc, rbs, zbc, zbs components from input file. Only - % used in the class constructor - work = tline; - - - % Remove (n,m) from line - p_open = find(work=='('); - p_close = find(work==')'); - - nfield = length(p_open); - if(nfield>4) - error(['Bad format on line: ', work,', need only four fields']); - end - - work = tline(1:p_open(1)-1); - for ii=2:nfield - work = [work, tline(p_close(ii-1)+1:p_open(ii)-1)]; - end - work = [work, tline(p_close(end)+1:end)]; - - - nm_str = ['(',num2str(n),',',num2str(m),')']; - work = erase(work, nm_str); - - % Remove = signs as well - work = erase(work, '='); - - % Now read line - format = ''; - for ii=1:nfield - format = [format, '%s%f64']; - end - work = textscan(work, format); - - for ii=1:nfield - field{ii} = work{2*ii-1}{1}; - value{ii} = work{2*ii}; - end - - - - - end % of function extract_4_values - - - function [n, m] = get_nm_from_field(obj, field); - % Read (n,m) from field Rbc(n,m), Rwc(n,m) or Vnc(n,m) - - s = extractBefore(field, ')'); - s = extractAfter( s, '('); - - n_str = extractBefore(s, ','); - m_str = extractAfter(s, ','); - - n = str2num(char(n_str)); - m = str2num(char(m_str)); - end - - - function write_4_values(obj, fid, field1, field2, field3, field4) - - im = obj.physicslist.im; - in = obj.physicslist.in; - - for ii=1:length(im) - m = im(ii); - n = in(ii); - - form = [' ', field1, '(%i,%i) = %19.15E ', ... - field2, '(%i,%i) = %19.15E ', ... - field3, '(%i,%i) = %19.15E ', ... - field4, '(%i,%i) = %19.15E \n']; - - - value1 = obj.physicslist.(field1)(ii); - value2 = obj.physicslist.(field2)(ii); - value3 = obj.physicslist.(field3)(ii); - value4 = obj.physicslist.(field4)(ii); - - fprintf(fid, form, n, m, value1, ... - n, m, value2, ... - n, m, value3, ... - n, m, value4 ); - end % of for loop - end % of function write_4_values - - - function write_list(obj, fid, list, special_list) - if( isempty(obj.(list)) ) - return - end - fields = fieldnames(obj.(list)); - - % Beginning of list - % End of list - add a \ - fprintf(fid, '&%s \n', list); - for ii = 1:numel(fields) - f = fields(ii); - f = f{1}; - % deal with special_list outside this method - if any(strcmp(f,special_list)) - continue; - end - - % write line - value = obj.(list).(f); - l = length(value); - - fprintf(fid, ' %s = ', f); - for jj=1:l - c = class(value(jj)); - - % Few logical test to decide the printing format - if strcmp(c,'logical') % bool - if value(jj) - fprintf(fid, 'T '); - else - fprintf(fid, 'F '); - end - else % not a bool - if floor(value(jj))==value(jj) %Integer value - fprintf(fid, '%i ',value(jj)); - else % double - fprintf(fid, '%19.15E ',value(jj)); - end - end - end - fprintf(fid,'\n'); - end % of for loop - - end % of function write_list - end % of private methods -end % of SPEC_Namelist class From a5483eadc16502f6d866fb8fdb06d856be7d6011 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 10 May 2022 11:05:18 +0200 Subject: [PATCH 006/134] Fixed some issues in matlabtools --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 36 +++++++++++----- .../rw_namelist/rw_namelist/write_namelist.m | 10 ++--- Utilities/matlabtools/read_spec.m | 41 ------------------- 3 files changed, 31 insertions(+), 56 deletions(-) diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m index 7c5897ff..f42d6324 100644 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -16,6 +16,7 @@ array_size = [0, 0]; Mvol = 0; Nvol = 0; + verbose = true; end @@ -52,19 +53,25 @@ end opt.Liniguess = true; + opt.verbose = true; for ii=1:l/2 opt.(varargin{2*ii-1}) = varargin{2*ii}; end + obj.verbose = opt.verbose; + % Read input file +% obj.physicslist = read_namelist( filename, 'physicslist' ); +% obj.numericlist = read_namelist( filename, 'numericlist' ); +% obj.locallist = read_namelist( filename, 'locallist' ); +% obj.globallist = read_namelist( filename, 'globallist' ); +% obj.diagnosticslist = read_namelist( filename, 'diagnosticslist' ); +% obj.screenlist = read_namelist( filename, 'screenlist' ); work = read_namelist( filename ); obj.lists = fields(work); - obj.physicslist = work.physicslist; - obj.numericlist = work.numericlist; - obj.locallist = work.locallist; - obj.globallist = work.globallist; - obj.diagnosticslist = work.diagnosticslist; - obj.screenlist = work.screenlist; + for ii=1:length(obj.lists) + obj.(obj.lists{ii}) = work.(obj.lists{ii}); + end % Check that the size of arrays makes sense, fills with zeros % otherwise @@ -431,13 +438,15 @@ function plot_computational_boundary( obj, nt, phi, newfig, varargin ) function plot_initial_guess( obj, nt, phi, newfig, varargin ) % - % PLOT_PLASMA_BOUNDARY - % ==================== + % PLOT_PLASMA_BOUNDARY( NT, PHI, NEWFIG, VARARGIN ) + % ================================================= % % Plot the boundary given by Rbc, Zbs, Rbs, Zbc % % INPUTS % ------ + % -NT: Number of poloidal points + % -PHI: Toroidal angle % -NEWFIG: =0: plot on gca % =1: plot on a new figure % =2: erase and plot on gca @@ -473,6 +482,11 @@ function write_input_file(obj, filename ) % - filename: path where to save the input file. % + % Set minimal toroidal resolution to one, otherwise writting + % routine does not detect arrays. + if obj.Ntor==0 + obj = obj.change_fourier_resolution( obj.Mpol, 1 ); + end nlists = length(obj.lists); S = struct; @@ -606,7 +620,7 @@ function write_input_file(obj, filename ) % PHYSICSLIST % ----------- % Lrad - if ~isfield(obj.physicslist, 'Lrad') + if ~isfield(obj.physicslist, 'Lrad') && obj.verbose warning('Missing Lrad. Filling with 4...') obj.physicslist.Lrad = ones(1,obj.Mvol) * 4; else @@ -615,7 +629,7 @@ function write_input_file(obj, filename ) end % tflux - if ~isfield(obj.physicslist, 'tflux') + if ~isfield(obj.physicslist, 'tflux') && obj.verbose warning('Missing tflux. Filling equal radial distances') obj.physicslist.tflux = (1:obj.Mvol).^2; else @@ -1056,6 +1070,8 @@ function plot_surface( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... end plot( R, Z, varargin{:} ) + + axis equal end end diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m index c71b6cb4..9f0dedb1 100755 --- a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m @@ -68,7 +68,7 @@ function write_namelist(S, filename, endlines) end fprintf(fid, '%s\n', ''); else - [m,n] = size(var); + [n,m] = size(var); if m == 1 || n == 1 % Variable is a scalar or vector fprintf(fid, ' %s =', rcrds_name{j}); @@ -77,10 +77,10 @@ function write_namelist(S, filename, endlines) else % Varible is a two dimensional array for k = 1:n - fprintf(fid, ' %s(%i,%i:%i) =', rcrds_name{j}, k-S.shift.(rcrds_name{j})(2), ... - 1-S.shift.(rcrds_name{j})(1), ... - n-S.shift.(rcrds_name{j})(1) ); - fprintf(fid, ' %g,', var(:,k)); + fprintf(fid, ' %s(%i,%i:%i) =', rcrds_name{j}, k-S.shift.(rcrds_name{j})(1), ... + 1-S.shift.(rcrds_name{j})(2), ... + m-S.shift.(rcrds_name{j})(2) ); + fprintf(fid, ' %g,', var(k,:)); fprintf(fid, '%s\n', ''); end end diff --git a/Utilities/matlabtools/read_spec.m b/Utilities/matlabtools/read_spec.m index 3bab1aaf..84192599 100644 --- a/Utilities/matlabtools/read_spec.m +++ b/Utilities/matlabtools/read_spec.m @@ -149,47 +149,6 @@ data.grid.Bp = cBp; data.grid.BZ = cBZ; -% generate flux surfaces instances for boundary and initial guess -Nfp = double(data.input.physics.Nfp); -Nvol = data.input.physics.Nvol; -Mpol = data.input.physics.Mpol; -Ntor = data.input.physics.Ntor; -stellsym = data.input.physics.Istellsym; - -% Computational boundary -fsurf = fluxSurface( Nfp, Mpol, Ntor, stellsym); - -im = data.output.im; -in = data.output.in / Nfp; -fsurf = fsurf.set_array( 'rmnc', data.output.Rbc(:,end), im, in ); -fsurf = fsurf.set_array( 'zmns', data.output.Zbs(:,end), im, in ); - -if ~stellsym - fsurf = fsurf.set_array( 'rmns', data.output.Rbs(:,end), im, in ); - fsurf = fsurf.set_array( 'zmnc', data.output.Zbc(:,end), im, in ); -end - -data.output.computationalBoundary = fsurf; - -% Initial guess -data.physicslist.KAMSurfaces = cell(1,Nvol); -for ivol=1:Mvol - - fsurf = fluxSurface( Nfp, Mpol, Ntor, stellsym); - - fsurf = fsurf.set_array( 'rmnc', data.output.Rbc(:,ivol+1), im, in ); - fsurf = fsurf.set_array( 'zmns', data.output.Zbs(:,ivol+1), im, in ); - - if ~stellsym - fsurf = fsurf.set_array( 'rmns', data.output.Rbs(:,ivol+1), im, in ); - fsurf = fsurf.set_array( 'zmnc', data.output.Zbc(:,ivol+1), im, in ); - end - - data.output.KAMSurface{ivol} = fsurf; - - -end - end From 1e6331f0de3539ab46ad73c3e824f0a31447ce3d Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 10 May 2022 11:34:01 +0200 Subject: [PATCH 007/134] Added test in plot_spec_poincare.m to check if Poincare data is available --- Utilities/matlabtools/plot_spec_poincare.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Utilities/matlabtools/plot_spec_poincare.m b/Utilities/matlabtools/plot_spec_poincare.m index c3f8f567..7f6a49b3 100644 --- a/Utilities/matlabtools/plot_spec_poincare.m +++ b/Utilities/matlabtools/plot_spec_poincare.m @@ -32,6 +32,11 @@ end stp = opt.step; +% Check that Poincare data is available +if data.input.diagnostics.nPpts==0 || all(data.input.diagnostics.nPtrj==0) + error('No Poincare data available') +end + % Read some data... nfp = data.input.physics.Nfp; From 494107a143f8a34ff391e445c7cb8abde841e927 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 17 May 2022 09:40:28 +0200 Subject: [PATCH 008/134] Update, and clean upof SPEC_Namelist --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 497 ++++++++++++------ .../SPEC_Namelist/rw_namelist/license.txt | 24 + .../{rw_namelist => }/read_namelist.m | 0 .../{rw_namelist => }/write_namelist.m | 0 ...tor.m => get_spec_regularisation_factor.m} | 4 +- Utilities/matlabtools/get_spec_vecpot.m | 2 +- Utilities/matlabtools/plot_spec_poincare.m | 27 +- 7 files changed, 381 insertions(+), 173 deletions(-) create mode 100644 Utilities/matlabtools/SPEC_Namelist/rw_namelist/license.txt rename Utilities/matlabtools/SPEC_Namelist/rw_namelist/{rw_namelist => }/read_namelist.m (100%) rename Utilities/matlabtools/SPEC_Namelist/rw_namelist/{rw_namelist => }/write_namelist.m (100%) rename Utilities/matlabtools/{get_spec_regularization_factor.m => get_spec_regularisation_factor.m} (95%) diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m index f42d6324..3fa3e0e7 100644 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -17,6 +17,7 @@ Mvol = 0; Nvol = 0; verbose = true; + Lboundary = 0; end @@ -61,12 +62,6 @@ obj.verbose = opt.verbose; % Read input file -% obj.physicslist = read_namelist( filename, 'physicslist' ); -% obj.numericlist = read_namelist( filename, 'numericlist' ); -% obj.locallist = read_namelist( filename, 'locallist' ); -% obj.globallist = read_namelist( filename, 'globallist' ); -% obj.diagnosticslist = read_namelist( filename, 'diagnosticslist' ); -% obj.screenlist = read_namelist( filename, 'screenlist' ); work = read_namelist( filename ); obj.lists = fields(work); for ii=1:length(obj.lists) @@ -142,6 +137,13 @@ fclose(fid); % Close file + % Check if structure is empty - i.e. no initial guess is + % provided + if isempty( initial_guess_str ) + obj.initial_guess = struct([]); % generate empty structure + return + end + % Check size l = length(str2num( initial_guess_str{1} )); l = l-2; % Remove m, n @@ -166,41 +168,40 @@ end + nlines = length(initial_guess_str); + if nlines<1 + obj.initial_guess = struct([]); % generate empty structure + return + end + + % Read Mpol, Ntor + Mpol_in = 0; Ntor_in = 0; + for iline=1:nlines + % Scan line + line_data = str2num( initial_guess_str{iline} ); + + % Find corresponding index + mm = line_data(1); nn = line_data(2); + Mpol_in = max([mm, Mpol_in]); + Ntor_in = max([abs(nn), Ntor_in]); + end + + % Check if resolution is smaller or larger than inner + % resolution. This changes obj.Mpol and obj.Ntor if + % necessary + if (Mpol_in>obj.Mpol) || (Ntor_in>obj.Ntor) + obj = obj.change_fourier_resolution( Mpol_in, Ntor_in ); + end + % Now format initial guess in a structure - switch obj.physicslist.Lboundary + switch obj.Lboundary case 0 % Rmn, Zmn representation - nlines = length(initial_guess_str); - if nlines<1 - obj.initial_guess = struct([]); % generate empty structure - return - end - - % Read Mpol, Ntor - Mpol_in = 0; Ntor_in = 0; - for iline=1:nlines - % Scan line - line_data = str2num( initial_guess_str{iline} ); - - % Find corresponding index - mm = line_data(1); nn = line_data(2); - Mpol_in = max([mm, Mpol_in]); - Ntor_in = max([abs(nn), Ntor_in]); - end - - % Check if resolution is smaller or larger than inner - % resolution. This changes obj.Mpol and obj.Ntor if - % necessary - if (Mpol_in>obj.Mpol) || (Ntor_in>obj.Ntor) - obj = obj.change_fourier_resolution( Mpol_in, Ntor_in ); - end - - % Allocate memory - Ric = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); - Ris = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); - Zic = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); - Zis = zeros(2*obj.Ntor+1, obj.Mpol, obj.Mvol); + Ric = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); + Ris = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); + Zic = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); + Zis = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); % Fill initial guess arrays for iline=1:nlines @@ -228,7 +229,9 @@ obj.initial_guess.Zic = Zic; case 1 % Henneberg representation - error('To be implemented') + + error('Henneberg representation not yet implemented') + otherwise error('Invalid Lboundary!') end @@ -267,7 +270,9 @@ end if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... - || strcmp(field, 'Zic') || strcmp(field, 'Zis') + || strcmp(field, 'Zic') || strcmp(field, 'Zis') ... + || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... + || strcmp(field, 'R0ic') || strcmp(field, 'Z0is') if isempty(obj.initial_guess) error('No initial guess available') @@ -334,15 +339,21 @@ end if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... - || strcmp(field, 'Zic') || strcmp(field, 'Zis') + || strcmp(field, 'Zic') || strcmp(field, 'Zis') ... + || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... + || strcmp(field, 'R0ic') || strcmp(field, 'Z0is') if isempty(obj.initial_guess) warning('No initial guess available... filling with zeros') - obj.initial_guess.Ric = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); - obj.initial_guess.Ris = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); - obj.initial_guess.Zic = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); - obj.initial_guess.Zis = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + if obj.Lboundary == 0 + obj.initial_guess.Ric = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + obj.initial_guess.Ris = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + obj.initial_guess.Zic = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + obj.initial_guess.Zis = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + else + error('Henneberg representation not yet implemented' ) + end end ivol = varargin{1}; @@ -387,6 +398,22 @@ end + function obj = change_boundary_representation( obj, new_lboundary ) + % + % CHANGE_BOUNDARY_REPRESENTATION( NEW_LBOUNDARY ) + % =============================================== + % + % Changes from the hudson representation to the henneberg's one + % and vice versa. + % + % INPUT + % ----- + % -new_lboundary: New value for Lboundary + + error('Henneberg representation not yet implemented') + + end + % Plotters function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) % @@ -397,6 +424,8 @@ function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) % % INPUTS % ------ + % -NT: Number of poloidal points + % -PHI: Toroidal angle % -NEWFIG: =0: plot on gca % =1: plot on a new figure % =2: erase and plot on gca @@ -404,12 +433,21 @@ function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) % % - Rbc = obj.physicslist.Rbc; - Rbs = obj.physicslist.Rbs; - Zbc = obj.physicslist.Zbc; - Zbs = obj.physicslist.Zbs; - - obj.plot_surface( Rbc, Zbs, Rbs, Zbc, nt, phi, newfig, varargin{:} ) + if obj.Lboundary==0 + Rbc = obj.physicslist.Rbc; + Rbs = obj.physicslist.Rbs; + Zbc = obj.physicslist.Zbc; + Zbs = obj.physicslist.Zbs; + + obj.plot_surface_Lb0( Rbc, Zbs, Rbs, Zbc, nt, phi, newfig, varargin{:} ) + else + rhomn = obj.physicslist.rhomn; + bn = obj.physicslist.bn; + R0c = obj.physicslist.R0c; + Z0s = obj.physicslist.Z0s; + + obj.plot_surface_Lb1( rhomn, bn, R0c, Z0s, nt, phi, newfig, varargin{:} ) + end end function plot_computational_boundary( obj, nt, phi, newfig, varargin ) @@ -421,6 +459,8 @@ function plot_computational_boundary( obj, nt, phi, newfig, varargin ) % % INPUTS % ------ + % -NT: Number of poloidal points + % -PHI: Toroidal angle % -NEWFIG: =0: plot on gca % =1: plot on a new figure % =2: erase and plot on gca @@ -428,12 +468,16 @@ function plot_computational_boundary( obj, nt, phi, newfig, varargin ) % % - Rwc = obj.physicslist.Rwc; - Rws = obj.physicslist.Rws; - Zwc = obj.physicslist.Zwc; - Zws = obj.physicslist.Zws; - - obj.plot_surface( Rwc, Zws, Rws, Zwc, nt, phi, newfig, varargin{:} ) + if obj.Lboundary == 0 + Rwc = obj.physicslist.Rwc; + Rws = obj.physicslist.Rws; + Zwc = obj.physicslist.Zwc; + Zws = obj.physicslist.Zws; + + obj.plot_surface_Lb0( Rwc, Zws, Rws, Zwc, nt, phi, newfig, varargin{:} ) + else + error('Henneberg representation not yet implemented') + end end function plot_initial_guess( obj, nt, phi, newfig, varargin ) @@ -454,17 +498,26 @@ function plot_initial_guess( obj, nt, phi, newfig, varargin ) % % - for ivol=1:obj.Nvol - Ric = obj.initial_guess.Ric(:,:,ivol); - Ris = obj.initial_guess.Ris(:,:,ivol); - Zic = obj.initial_guess.Zic(:,:,ivol); - Zis = obj.initial_guess.Zis(:,:,ivol); - - if ivol==2 - newfig=0; + if isempty(obj.initial_guess) + error('No initial guess is provided') + end + + if obj.Lboundary == 0 + for ivol=1:obj.Nvol + Ric = obj.initial_guess.Ric(:,:,ivol); + Ris = obj.initial_guess.Ris(:,:,ivol); + Zic = obj.initial_guess.Zic(:,:,ivol); + Zis = obj.initial_guess.Zis(:,:,ivol); + + if ivol>=2 + newfig=0; + end + + obj.plot_surface_Lb0( Ric, Zis, Ris, Zic, nt, phi, newfig, varargin{:} ) end - - obj.plot_surface( Ric, Zis, Ris, Zic, nt, phi, newfig, varargin{:} ) + else + + error('Henneberg representation not yet implemented' ) end end @@ -508,6 +561,56 @@ function write_input_file(obj, filename ) S.shift.Bns = [obj.Ntor+1, 1]; S.shift.rhomn = [obj.Ntor+1, 1]; + % Remove unnecessary fields + if obj.Lboundary == 0 + if isfield( S.physicslist, 'rhomn' ) + S.physicslist = rmfield(S.physicslist, 'rhomn'); + end + if isfield( S.physicslist, 'bn' ) + S.physicslist = rmfield(S.physicslist, 'bn'); + end + if isfield( S.physicslist, 'R0c' ) + S.physicslist = rmfield(S.physicslist, 'R0c'); + end + if isfield( S.physicslist, 'Z0s' ) + S.physicslist = rmfield(S.physicslist, 'Z0s'); + end + + else % Lboundary==1 + error('Henneberg representation not yet implemented') + + end + + if obj.physicslist.Lfreebound==0 % Then no need to freeboundary info + if isfield( S.physicslist, 'Rwc' ) + S.physicslist = rmfield(S.physicslist, 'Rwc'); + end + if isfield( S.physicslist, 'Rws' ) + S.physicslist = rmfield(S.physicslist, 'Rws'); + end + if isfield( S.physicslist, 'Zwc' ) + S.physicslist = rmfield(S.physicslist, 'Zwc'); + end + if isfield( S.physicslist, 'Zws' ) + S.physicslist = rmfield(S.physicslist, 'Zws'); + end + if isfield( S.physicslist, 'Vnc' ) + S.physicslist = rmfield(S.physicslist, 'Vnc'); + end + if isfield( S.physicslist, 'Vns' ) + S.physicslist = rmfield(S.physicslist, 'Vns'); + end + if isfield( S.physicslist, 'Bnc' ) + S.physicslist = rmfield(S.physicslist, 'Bnc'); + end + if isfield( S.physicslist, 'Bns' ) + S.physicslist = rmfield(S.physicslist, 'Bns'); + end + + end + + + % Build initial guess strings if obj.physicslist.Lboundary==0 if ~isempty(obj.initial_guess) s = size(obj.initial_guess.Ric); @@ -535,53 +638,7 @@ function write_input_file(obj, filename ) else - nrho = max(max(obj.physicslist.in)); - S.shift.rhomn = [ 1, nrho+1 ]; - - % Now prepare initial guess... - if isfield(obj.initial_guess, 'bin') - sb = size(obj.initial_guess.bin); - srho = size(obj.initial_guess.rhoi); - ntor = (srho(2)-1)/2.0; - initialguess = cell(1, sb(1) + srho(1)*srho(2)); - - % Modes m=0, n - for ii=1:sb(1) - nn = ii-1; - initialguess{ii} = sprintf('0 %i ', nn); - for ivol=1:sb(2) - initialguess{ii} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii}, ... - obj.initial_guess.bin( ii, ivol ), ... - obj.initial_guess.R0ic(ii, ivol ), ... - obj.initial_guess.Z0is(ii, ivol ), 0.0 ); - end - end - - it = sb(1); - for ii=1:srho(2) - - nn = ii-ntor-1; - - for jj=1:srho(1) - - it = it+1; - - mm = jj; - - initialguess{it} = sprintf('%i %i ', mm, nn); - - for ivol=1:srho(3) - - initialguess{it} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii},... - 0.0, 0.0, 0.0, obj.initial_guess.rhoi(ii, jj, ivol)); - - end - end - end - else - initialguess = cell(0); - - end + error('Henneberg representation not yet implemented') @@ -617,6 +674,12 @@ function write_input_file(obj, filename ) obj.Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; obj.Nvol = obj.physicslist.Nvol; + if isfield(obj.physicslist, 'Lboundary') + obj.Lboundary = obj.physicslist.Lboundary; + else + obj.Lboundary = 0; + end + % PHYSICSLIST % ----------- % Lrad @@ -770,17 +833,21 @@ function write_input_file(obj, filename ) Mpol_in = obj.physicslist.Mpol; Ntor_in = obj.physicslist.Ntor; - if obj.physicslist.Lboundary==0 + if obj.Lboundary==0 if ~isfield(obj.physicslist, 'Rbc') + obj.physicslist.shift.Rbc = [Ntor_in+1, 1]; obj.physicslist.Rbc = zeros(2*Ntor_in+1, Mpol_in); end if ~isfield(obj.physicslist, 'Rbs') + obj.physicslist.shift.Rbs = [Ntor_in+1, 1]; obj.physicslist.Rbs = zeros(2*Ntor_in+1, Mpol_in); end if ~isfield(obj.physicslist, 'Zbc') + obj.physicslist.shift.Zbc = [Ntor_in+1, 1]; obj.physicslist.Zbc = zeros(2*Ntor_in+1, Mpol_in); end if ~isfield(obj.physicslist, 'Zbs') + obj.physicslist.shift.Zbs = [Ntor_in+1, 1]; obj.physicslist.Zbs = zeros(2*Ntor_in+1, Mpol_in); end @@ -796,47 +863,59 @@ function write_input_file(obj, filename ) end - - if ~isfield(obj.physicslist, 'Rwc') - obj.physicslist.Rwc = zeros(2*Ntor_in+1, Mpol_in); - end - if ~isfield(obj.physicslist, 'Rws') - obj.physicslist.Rws = zeros(2*Ntor_in+1, Mpol_in); - end - if ~isfield(obj.physicslist, 'Zwc') - obj.physicslist.Zwc = zeros(2*Ntor_in+1, Mpol_in); - end - if ~isfield(obj.physicslist, 'Zws') - obj.physicslist.Zws = zeros(2*Ntor_in+1, Mpol_in); - end - - % Check that sizes are consistent with each others - if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Rws)) - error('Size mismatch between Rwc and Rws') - end - if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zwc)) - error('Size mismatch between Rwc and Zwc') - end - if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zws)) - error('Size mismatch between Rwc and Zws') - end + else %Lboundary==1 + error('Henneberg representation not yet implemented') - else - error('To complete') end + + + if ~isfield(obj.physicslist, 'Rwc') + obj.physicslist.shift.Rwc = [Ntor_in+1, 1]; + obj.physicslist.Rwc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Rws') + obj.physicslist.shift.Rws = [Ntor_in+1, 1]; + obj.physicslist.Rws = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Zwc') + obj.physicslist.shift.Zwc = [Ntor_in+1, 1]; + obj.physicslist.Zwc = zeros(2*Ntor_in+1, Mpol_in); + end + if ~isfield(obj.physicslist, 'Zws') + obj.physicslist.shift.Zws = [Ntor_in+1, 1]; + obj.physicslist.Zws = zeros(2*Ntor_in+1, Mpol_in); + end + + % Check that sizes are consistent with each others + if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Rws)) + error('Size mismatch between Rwc and Rws') + end + if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zwc)) + error('Size mismatch between Rwc and Zwc') + end + if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zws)) + error('Size mismatch between Rwc and Zws') + end + + + if ~isfield(obj.physicslist, 'Vnc') + obj.physicslist.shift.Vnc = [Ntor_in+1, 1]; obj.physicslist.Vnc = zeros(2*Ntor_in+1, Mpol_in); end if ~isfield(obj.physicslist, 'Vns') + obj.physicslist.shift.Vns = [Ntor_in+1, 1]; obj.physicslist.Vns = zeros(2*Ntor_in+1, Mpol_in); end if ~isfield(obj.physicslist, 'Bnc') + obj.physicslist.shift.Bnc = [Ntor_in+1, 1]; obj.physicslist.Bnc = zeros(2*Ntor_in+1, Mpol_in); end if ~isfield(obj.physicslist, 'Bns') + obj.physicslist.shift.Bns = [Ntor_in+1, 1]; obj.physicslist.Bns = zeros(2*Ntor_in+1, Mpol_in); end @@ -896,19 +975,25 @@ function write_input_file(obj, filename ) % Check that all arrays have the same size; otherwise, fill % with zeros the missing elements - if any(size(obj.physicslist.Rbc)~=obj.array_size) - obj = obj.reshape_array( 'Rbc' ); - obj = obj.reshape_array( 'Rbs' ); - obj = obj.reshape_array( 'Zbc' ); - obj = obj.reshape_array( 'Zbs' ); - end - - if any(size(obj.physicslist.Rwc)~=obj.array_size) - obj = obj.reshape_array( 'Rwc' ); - obj = obj.reshape_array( 'Rws' ); - obj = obj.reshape_array( 'Zwc' ); - obj = obj.reshape_array( 'Zws' ); + if obj.Lboundary == 0 + if any(size(obj.physicslist.Rbc)~=obj.array_size) + obj = obj.reshape_array( 'Rbc' ); + obj = obj.reshape_array( 'Rbs' ); + obj = obj.reshape_array( 'Zbc' ); + obj = obj.reshape_array( 'Zbs' ); + end + + if any(size(obj.physicslist.Rwc)~=obj.array_size) + obj = obj.reshape_array( 'Rwc' ); + obj = obj.reshape_array( 'Rws' ); + obj = obj.reshape_array( 'Zwc' ); + obj = obj.reshape_array( 'Zws' ); + end + else + error('Henneberg representation not yet implemented') + end + if any(size(obj.physicslist.Vnc)~=obj.array_size) obj = obj.reshape_array( 'Vnc' ); @@ -938,10 +1023,14 @@ function write_input_file(obj, filename ) Mpol_in = obj.physicslist.Mpol; Ntor_in = obj.physicslist.Ntor; - s_bc = size(obj.physicslist.Rbc); - shift = obj.physicslist.shift.Rbc(1); - Mpol_bc = s_bc(2)-1 ; - Ntor_bc = max([abs(1-shift), s_bc(1)-shift]); + if obj.Lboundary == 0 + s_bc = size(obj.physicslist.Rbc); + shift = obj.physicslist.shift.Rbc(1); + Mpol_bc = s_bc(2)-1 ; + Ntor_bc = max([abs(1-shift), s_bc(1)-shift]); + else + error('Henneberg representation not yet implemented') + end s_wc = size(obj.physicslist.Rwc); shift = obj.physicslist.shift.Rwc(1); @@ -980,13 +1069,13 @@ function write_input_file(obj, filename ) shift = obj.physicslist.shift.(field); s = size(array); - Ntor_array = max([abs(1-shift), s(1)-shift]); + Ntor_array = max([abs(1-shift(1)), s(1)-shift(1)]); new_array = zeros(obj.array_size); for ii=1:s(1) for jj=1:s(2) nn = ii-Ntor_array-1; - mm = jj-1; + mm = jj-shift(2); if abs(nn)>obj.Ntor || mm>obj.Mpol continue @@ -1000,7 +1089,7 @@ function write_input_file(obj, filename ) end - function plot_surface( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... + function plot_surface_Lb0( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... newfig, varargin ) % % PLOT_SURFACE( RMNC, ZMNS, RMNS, ZMNC, NT, NEWFIG, VARARGIN ) @@ -1048,8 +1137,7 @@ function plot_surface( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... error('InputError: nt should be larger than 1') end - Ntor = (s(1)-1) / 2.0; - Mpol = s(2)-1; + N = (s(1)-1) / 2.0; tarr = linspace( 0, 2*pi, nt ); R = zeros( 1, nt ); @@ -1058,7 +1146,7 @@ function plot_surface( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... for in=1:s(1) - nn = in-1-Ntor; + nn = in-1-N; for im=1:s(2) mm = im-1; @@ -1073,6 +1161,91 @@ function plot_surface( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... axis equal end + + + function plot_surface_Lb1( obj, rhomn, bn, R0c, Z0s, nt, phi, newfig, varargin ) + % + % PLOT_SURFACE_LB1( RHOMN, BN, R0C, Z0S, NT, PHI, NEWFIG, VARARGIN ) + % ================================================================== + % + % Plots a surface using the Henneberg representation + % + % INPUTS + % ------ + % -rhomn: rho_mn harmonics, format (2*Ntor+1, Mpol+1) + % -bn: b_n harmonics, format (Ntor+1, 1) + % -R0c: R_0c harmonics, format (Ntor+1, 1) + % -Z0s: Z_0s harmonics, format (Ntor+1, 1) + % -nt: Number of poloidal points + % -phi: Toroidal angle + % -newfig: =0: plot on gca + % =1: plot on a new figure + % =2: erase and plot on gca + % -varargin: Optionnal input arguments, used as inputs to + % plot() + % + % + + + + switch newfig + case 0 + hold on + case 1 + figure('Color','w','Position',[200 200 900 700]) + hold on + case 2 + hold off + otherwise + error('InputError: invalid newfig') + end + + s = size(rhomn); + N = (s(1)-1) / 2.0; + + if any(length(bn)~=N+1) + error('InputError: bn has not the size Ntor+1') + end + if any(length(R0c)~=N+1) + error('InputError: R0c has not the size Ntor+1') + end + if any(length(Z0s)~=N+1) + error('InputError: Z0s has not the size Ntor+1') + end + if nt<1 + error('InputError: nt should be larger than 1') + end + + tarr = linspace(0, 2*pi, nt); + rho = zeros(1, nt); + alpha = obj.physicslist.twoalpha / 2.0; + Nfp = double(obj.physicslist.Nfp); + + for im=1:s(2) + mm = im-1; + for in=1:s(1) + nn = in-N-1; + rho = rho + rhomn(in,im) * cos(mm*tarr + nn*Nfp*phi - alpha*Nfp*phi); + end + end + + R0 = 0; + Z0 = 0; + b = 0; + for nn=0:N + R0 = R0 + R0c(nn+1) * cos(nn*Nfp*phi); + b = b + bn(nn+1 ) * cos(nn*Nfp*phi); + Z0 = Z0 + Z0s(nn+1) * sin(nn*Nfp*phi); + end + + zeta = b.*sin( tarr - alpha*Nfp*phi ); + + R = R0 + rho * cos(alpha*Nfp*phi) - zeta * sin(alpha*Nfp*phi); + Z = Z0 + rho * sin(alpha*Nfp*phi) + zeta * cos(alpha*Nfp*phi); + + plot(R, Z, varargin{:}) + axis equal + end end end diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/license.txt b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/license.txt new file mode 100644 index 00000000..793f7d6b --- /dev/null +++ b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/license.txt @@ -0,0 +1,24 @@ +Copyright (c) 2012, Darien Pardinas Diaz +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/read_namelist.m b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/read_namelist.m similarity index 100% rename from Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/read_namelist.m rename to Utilities/matlabtools/SPEC_Namelist/rw_namelist/read_namelist.m diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/write_namelist.m similarity index 100% rename from Utilities/matlabtools/SPEC_Namelist/rw_namelist/rw_namelist/write_namelist.m rename to Utilities/matlabtools/SPEC_Namelist/rw_namelist/write_namelist.m diff --git a/Utilities/matlabtools/get_spec_regularization_factor.m b/Utilities/matlabtools/get_spec_regularisation_factor.m similarity index 95% rename from Utilities/matlabtools/get_spec_regularization_factor.m rename to Utilities/matlabtools/get_spec_regularisation_factor.m index 92866951..8bf9a3b2 100644 --- a/Utilities/matlabtools/get_spec_regularization_factor.m +++ b/Utilities/matlabtools/get_spec_regularisation_factor.m @@ -1,7 +1,7 @@ -function fac = get_spec_regularization_factor(data, lvol, sarr, ForG) +function fac = get_spec_regularisation_factor(data, lvol, sarr, ForG) % -% GET_SPEC_REGULARIZATION_FACTOR( DATA, LVOL, SARR, FORG ) +% GET_SPEC_REGULARISATION_FACTOR( DATA, LVOL, SARR, FORG ) % ======================================================== % % Computes the regularisation factor in the correct geometry diff --git a/Utilities/matlabtools/get_spec_vecpot.m b/Utilities/matlabtools/get_spec_vecpot.m index 6ea3fe36..80e47e96 100644 --- a/Utilities/matlabtools/get_spec_vecpot.m +++ b/Utilities/matlabtools/get_spec_vecpot.m @@ -63,7 +63,7 @@ Az = zeros(ns,nt,nz); % allocate data for vector potential along zeta % Construct regularization factors -fac = get_spec_regularization_factor(data, lvol, sarr, 'F'); +fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); % Construct vector potential covariant components T = get_spec_polynomial_basis(data, lvol, sarr); diff --git a/Utilities/matlabtools/plot_spec_poincare.m b/Utilities/matlabtools/plot_spec_poincare.m index 7f6a49b3..819df3c1 100644 --- a/Utilities/matlabtools/plot_spec_poincare.m +++ b/Utilities/matlabtools/plot_spec_poincare.m @@ -1,19 +1,31 @@ function phi = plot_spec_poincare(data,nz0,arr,newfig,varargin) % -% PLOT_SPEC_POINCARE( DATA, NZ0, NFP, ARR, NEWFIG ) -% ================================================= +% PLOT_SPEC_POINCARE( DATA, NZ0, NFP, ARR, NEWFIG, VARARGIN ) +% =========================================================== % -% Produces Poincare plots of the field lines on different sections (within one field period) +% Produces Poincare plots of the field lines on different sections (within +% one field period) % % INPUT % ----- % -data : must be produced by calling read_spec(fname) % -nz0 : shows the nz0 toroidal plane or equidistant planes (nz0=-1) % -nfp : number of field periods -% -arr : step to skip field-line trajectories when ploting (arr=1 means all trajectories are ploted) -% : can be an array of which field line should be plotted, if size(arra)>1 -% -newfig : opens(=1) or not(=0) a new figure, or overwrites (=2) last plot +% -arr : step to skip field-line trajectories when ploting (arr=1 +% means all trajectories are ploted) +% : can be an array of which field line should be plotted, if +% size(arra)>1 +% -newfig : opens(=1) or not(=0) a new figure, or overwrites (=2) last +% plot +% -varargin : Optional arguments. Any of the following pairs are +% supported: +% - 'BoundaryColor', value: color of the plasma boundary or +% wall. default: red +% - 'step', n: plot one every n toroidal transit. This allows +% lighter plts when exporting to eps. By +% default, all toroidal transit are plotted +% (n=1) % % written by J.Loizu (2015) % modified by A.Baillod (2019) @@ -25,7 +37,6 @@ end opt.BoundaryColor = 'r'; -opt.CBColor = 'k'; opt.step = 1; for ii=1:ll/2 opt.(varargin{2*ii-1}) = varargin{2*ii}; @@ -71,7 +82,7 @@ bthick = 3; lthick = 1; if(data.input.physics.Lfreebound==1) - bcol = opt.CBColor; + bcol = opt.BoundaryColor; bthick = 1; end From 84ed11c9022764743890a11dc58d943cbd1b216c Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 17 May 2022 12:22:38 +0200 Subject: [PATCH 009/134] Solved reading issues with SPEC_Namelist --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m index 3fa3e0e7..f09f2109 100644 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -115,6 +115,10 @@ tline = fgetl(fid); tline = strtrim(tline); + + if isempty(tline) + continue + end if( save_line ) % write line initial_guess_str{end+1} = tline; @@ -133,6 +137,7 @@ end end + end % end of while fclose(fid); % Close file @@ -921,13 +926,10 @@ function write_input_file(obj, filename ) % Check that sizes are consistent with each others if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Vns)) - error('Size mismatch between Rwc and Vns') + error('Size mismatch between Vnc and Vns') end - if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Bnc)) - error('Size mismatch between Rwc and Bnc') - end - if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Bns)) - error('Size mismatch between Rwc and Bns') + if any(size(obj.physicslist.Bnc)~=size(obj.physicslist.Bns)) + error('Size mismatch between Bnc and Bns') end % DIAGNOSTICSLIST @@ -998,6 +1000,9 @@ function write_input_file(obj, filename ) if any(size(obj.physicslist.Vnc)~=obj.array_size) obj = obj.reshape_array( 'Vnc' ); obj = obj.reshape_array( 'Vns' ); + end + + if any(size(obj.physicslist.Bnc)~=obj.array_size) obj = obj.reshape_array( 'Bnc' ); obj = obj.reshape_array( 'Bns' ); end From 4b7aea37b6d0a2dcba01f4deaeb9f7d54acda5de Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 17 May 2022 13:56:53 +0200 Subject: [PATCH 010/134] Improved documentation of SPEC_Namelist --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 71 +++++++++++++------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m index f09f2109..c966b714 100644 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -53,12 +53,13 @@ error('InputError: invalid number of inputs') end - opt.Liniguess = true; - opt.verbose = true; + opt.Liniguess = true; % Decide whether or not we read initial guess + opt.verbose = true; % Print additional warnings for ii=1:l/2 opt.(varargin{2*ii-1}) = varargin{2*ii}; end + % Fill class arguments obj.verbose = opt.verbose; % Read input file @@ -104,10 +105,14 @@ % structure. - % First, open file and read relevant portion + % First, open file and read relevant portion. We look for the + % end of the category "screenlist" and then read each line. + % Each line is then saved as a string in a structure. fid = fopen( filename, 'r' ); - save_line = false; - category = ''; + save_line = false; % This is switched to true once + % we are at the end of the + % screelist + category = ''; % Save the name of the category initial_guess_str = {}; @@ -123,7 +128,8 @@ if( save_line ) % write line initial_guess_str{end+1} = tline; - else % otherwise look for beginning of geometrical initial guess + else % otherwise look for beginning of initial guess + % Check if beginning of new category if( strcmp(tline, '/') ) if( strcmp(category,'screenlist') ) save_line = true; @@ -149,7 +155,9 @@ return end - % Check size + % Check size. The number of elements should be 2 + 4 * Nvol. + % The first two elements are the mode numbers m and n, then we + % have Rbc, Zbs, Rbs, Zbc for each volume interface l = length(str2num( initial_guess_str{1} )); l = l-2; % Remove m, n if mod(l,4)~=0 @@ -172,7 +180,7 @@ 'same boundary representation.'], filename) end - + % Check if there is an initial guess... nlines = length(initial_guess_str); if nlines<1 obj.initial_guess = struct([]); % generate empty structure @@ -243,6 +251,7 @@ end + % ================================================================= % Getters function out = get_fourier_harmonics( obj, field, m, n, varargin ) % @@ -261,19 +270,23 @@ % of the initial guess - + % Check if poloidal mode is within the resolution if m>obj.Mpol - warning('M is larger than the Fourier resolution of the input file') + warning('M is larger than the Fourier resolution') out = 0; return end + % Check if toroidal mode is within the resolution if abs(n)>obj.Ntor - warning('M is larger than the Fourier resolution of the input file') + warning('N is larger than the Fourier resolution') out = 0; return end + % Need to make the difference between initial guess harmonics + % or harmonics from the physics list. rhoi, bin, R0ic and Z0is + % are related to the Henneberg representation if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... || strcmp(field, 'Zic') || strcmp(field, 'Zis') ... || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... @@ -297,11 +310,12 @@ end - + % Read relevant harmonic. out = obj.(cat).(field)(n+obj.Ntor+1, m+1, ivol); end + % ================================================================= % Setter function obj = set_fourier_harmonics( obj, field, im, in, value, varargin ) % @@ -320,7 +334,7 @@ % -(ivol): Optional argument, required for fourier harmonics % of the initial guess - + % First check the input size mn = length(im); if length(in)~=mn error('The array in has not the same length as im') @@ -329,10 +343,13 @@ error('The array value has not the same length as im') end + % Loop over the input harmonics for imn=1:mn m = im(imn); n = in(imn); + % If some modes are greater than the actual resolution, + % increase the resolution accordingly if m>obj.Mpol warning('Poloidal resolution has to be increased ...') obj = obj.change_fourier_resolution( m, obj.Ntor ); @@ -343,11 +360,15 @@ obj = obj.change_fourier_resolution( obj.Mpol, abs(n) ); end + % Check if the quantity is located in the initial guess + % structure or in the physicslist structure. if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... || strcmp(field, 'Zic') || strcmp(field, 'Zis') ... || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... || strcmp(field, 'R0ic') || strcmp(field, 'Z0is') + % If the initial guess is empty (i.e. no initial guess + % are available), then we create one filled with zeros if isempty(obj.initial_guess) warning('No initial guess available... filling with zeros') @@ -375,7 +396,7 @@ end - + % Set the relevant harmonics obj.(cat).(field)(n+obj.Ntor+1, m+1, ivol) = value(imn); end @@ -387,7 +408,8 @@ % ===================================== % % Truncates all spectral quantities to the requested poloidal - % and toroidal resolution + % and toroidal resolution. This can also be used to increase + % the Fourier resolution. % % INPUTS % ------ @@ -419,6 +441,7 @@ end + % ================================================================= % Plotters function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) % @@ -446,12 +469,8 @@ function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) obj.plot_surface_Lb0( Rbc, Zbs, Rbs, Zbc, nt, phi, newfig, varargin{:} ) else - rhomn = obj.physicslist.rhomn; - bn = obj.physicslist.bn; - R0c = obj.physicslist.R0c; - Z0s = obj.physicslist.Z0s; - obj.plot_surface_Lb1( rhomn, bn, R0c, Z0s, nt, phi, newfig, varargin{:} ) + error('Henneberg representation is not implemented') end end @@ -526,6 +545,7 @@ function plot_initial_guess( obj, nt, phi, newfig, varargin ) end end + % ================================================================= % Write method function write_input_file(obj, filename ) % @@ -541,17 +561,23 @@ function write_input_file(obj, filename ) % % Set minimal toroidal resolution to one, otherwise writting - % routine does not detect arrays. + % routine does not detect arrays. This is not ideal and should + % be fixed if obj.Ntor==0 obj = obj.change_fourier_resolution( obj.Mpol, 1 ); end + % Create a structure with the different lists nlists = length(obj.lists); S = struct; for ii=1:nlists S.(obj.lists{ii}) = obj.(obj.lists{ii}); end + % Create a shift quantity - this tells the writing routine how + % much each index has to be shifted. In MATLAB, indices start + % at 1, while in the FORTRAN Namelist, we want to write + % elements with negative indices. S.shift.Rbc = [obj.Ntor+1, 1]; S.shift.Rbs = [obj.Ntor+1, 1]; S.shift.Zbc = [obj.Ntor+1, 1]; @@ -566,7 +592,7 @@ function write_input_file(obj, filename ) S.shift.Bns = [obj.Ntor+1, 1]; S.shift.rhomn = [obj.Ntor+1, 1]; - % Remove unnecessary fields + % Remove unnecessary fields. if obj.Lboundary == 0 if isfield( S.physicslist, 'rhomn' ) S.physicslist = rmfield(S.physicslist, 'rhomn'); @@ -649,6 +675,7 @@ function write_input_file(obj, filename ) end + % Call namelist writer write_namelist( S, filename, initialguess ); From 5cb0175d1a815d8ab656d68b93207bdf7a01f0a9 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 17 May 2022 14:24:38 +0200 Subject: [PATCH 011/134] Solved bug with get_spec_R_derivatives.m --- .../matlabtools/get_spec_R_derivatives.m | 10 +- Utilities/matlabtools/get_spec_magfield.m | 4 - .../get_spec_regularisation_factor.m | 7 +- Utilities/matlabtools/get_spec_vecpot.m | 120 +++++++++--------- 4 files changed, 68 insertions(+), 73 deletions(-) diff --git a/Utilities/matlabtools/get_spec_R_derivatives.m b/Utilities/matlabtools/get_spec_R_derivatives.m index 8729551d..089279c1 100644 --- a/Utilities/matlabtools/get_spec_R_derivatives.m +++ b/Utilities/matlabtools/get_spec_R_derivatives.m @@ -43,12 +43,14 @@ % Allocate data for R and its derivative in s, theta and phi (4), for each % and for ns points -if(size(sarr,1)==1) -sarr = transpose(sarr); -end ns = length(sarr); nt = length(tarr); nz = length(zarr); + + sarr = reshape(sarr, ns, 1); + tarr = reshape(tarr, nt, 1); + zarr = reshape(zarr, nz, 1); + Rarr = cell(1,4); Zarr = cell(1,4); @@ -60,6 +62,8 @@ % Compute the regularisation factor factor = get_spec_regularisation_factor(data, vol, sarr, 'G'); + + % And R derivatives if RorZ=='R' for imn=1:mn diff --git a/Utilities/matlabtools/get_spec_magfield.m b/Utilities/matlabtools/get_spec_magfield.m index 91e4cce2..ef7f6e59 100644 --- a/Utilities/matlabtools/get_spec_magfield.m +++ b/Utilities/matlabtools/get_spec_magfield.m @@ -48,11 +48,7 @@ T = get_spec_polynomial_basis(data, lvol, sarr'); -% Construct regularization factors and their derivatives -%fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); - % Construct magnetic field contravariant components - Lsingularity = false; if (lvol==1) && (data.input.physics.Igeometry~=1) Lsingularity = true; diff --git a/Utilities/matlabtools/get_spec_regularisation_factor.m b/Utilities/matlabtools/get_spec_regularisation_factor.m index 8bf9a3b2..57516880 100644 --- a/Utilities/matlabtools/get_spec_regularisation_factor.m +++ b/Utilities/matlabtools/get_spec_regularisation_factor.m @@ -21,7 +21,8 @@ % Written by A.Baillod (2019) % - sarr = transpose(sarr); + ns = length( sarr ); + sarr = reshape( sarr, ns, 1 ); Igeometry = data.input.physics.Igeometry; mn = data.output.mn; @@ -47,7 +48,7 @@ fac{j}{2} = 0.5*ones(ns,1); else fac{j}{1} = sbar.^(im(j)+1); - fac{j}{2} = 0.5 * (im(j)+1) * fac{j}{1} ./ sbar; + fac{j}{2} = reshape(0.5 * (im(j)+1) * fac{j}{1} ./ sbar, ns, 1); end else fac{j}{1} = sbar; @@ -64,7 +65,7 @@ fac{j}{2} = sbar; else fac{j}{1} = sbar.^im(j); - fac{j}{2} = 0.5 * im(j) * fac{j}{1} ./ sbar; + fac{j}{2} = reshape(0.5 * im(j) * fac{j}{1} ./ sbar, ns, 1); end else fac{j}{1} = sbar; diff --git a/Utilities/matlabtools/get_spec_vecpot.m b/Utilities/matlabtools/get_spec_vecpot.m index 80e47e96..66ef9035 100644 --- a/Utilities/matlabtools/get_spec_vecpot.m +++ b/Utilities/matlabtools/get_spec_vecpot.m @@ -20,80 +20,74 @@ % % written by J.Loizu (2018) -% Test input -Mvol = data.output.Mvol; -if lvol<1 || lvol>Mvol - error('InputError: invalid lvol') -end + % Test input + Mvol = data.output.Mvol; + if lvol<1 || lvol>Mvol + error('InputError: invalid lvol') + end -if isempty(sarr) - error('InputError: empty sarr') -end -if isempty(tarr) - error('InputError: empty tarr') -end -if isempty(zarr) - error('InputError: empty zarr') -end + if isempty(sarr) + error('InputError: empty sarr') + end + if isempty(tarr) + error('InputError: empty tarr') + end + if isempty(zarr) + error('InputError: empty zarr') + end -if sarr(1)<-1 || sarr(end)>1 - error('InputError: invalid sarr') -end + if sarr(1)<-1 || sarr(end)>1 + error('InputError: invalid sarr') + end -% Read data -Ate = data.vector_potential.Ate{lvol}; -Aze = data.vector_potential.Aze{lvol}; -Ato = data.vector_potential.Ato{lvol}; -Azo = data.vector_potential.Azo{lvol}; + % Read data + Ate = data.vector_potential.Ate{lvol}; + Aze = data.vector_potential.Aze{lvol}; + Ato = data.vector_potential.Ato{lvol}; + Azo = data.vector_potential.Azo{lvol}; -Lrad = data.input.physics.Lrad(lvol); + Lrad = data.input.physics.Lrad(lvol); -if(size(sarr,1)==1) -sarr = transpose(sarr); -end -ns = length(sarr); -nt = length(tarr); -nz = length(zarr); + if(size(sarr,1)==1) + sarr = transpose(sarr); + end + ns = length(sarr); + nt = length(tarr); + nz = length(zarr); -mn = data.output.mn; -im = double(data.output.im); -in = double(data.output.in); + mn = data.output.mn; + im = double(data.output.im); + in = double(data.output.in); -At = zeros(ns,nt,nz); % allocate data for vector potential along theta -Az = zeros(ns,nt,nz); % allocate data for vector potential along zeta + At = zeros(ns,nt,nz); % allocate data for vector potential along theta + Az = zeros(ns,nt,nz); % allocate data for vector potential along zeta -% Construct regularization factors -fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); + % Construct vector potential covariant components + T = get_spec_polynomial_basis(data, lvol, sarr); + + % Construct vector potential covariant components + Lsingularity = (lvol==1) && (data.input.physics.Igeometry~=1); -% Construct vector potential covariant components -T = get_spec_polynomial_basis(data, lvol, sarr); - Lsingularity = true; + for l=1:Lrad+1 + for j=1:length(im) + if( Lsingularity ) + basis = T{l}{1}(im(j)+1); + else + basis = T{l}{1}; + end -for l=1:Lrad+1 -fac = get_spec_regularisation_factor(data, lvol, sarr, 'F'); -% Construct vector potential covariant components -Lsingularity = false; -if (lvol==1) && (data.input.physics.Igeometry~=1) - Lsingularity = true; + for it=1:nt + for iz=1:nz + cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); + sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); + At(:,it,iz) = At(:,it,iz) + basis.*( Ate(l,j)*cosa + Ato(l,j)*sina ); + Az(:,it,iz) = Az(:,it,iz) + basis.*( Aze(l,j)*cosa + Azo(l,j)*sina ); + end + end + end end - if( Lsingularity ) - basis = T{l}{1}(im(j)+1); - else - basis = T{l}{1}; - end - for it=1:nt - for iz=1:nz - cosa = cos(im(j)*tarr(it)-in(j)*zarr(iz)); - sina = sin(im(j)*tarr(it)-in(j)*zarr(iz)); - At(:,it,iz) = At(:,it,iz) + fac{j}{1}.* basis.*( Ate(l,j)*cosa + Ato(l,j)*sina ); - Az(:,it,iz) = Az(:,it,iz) + fac{j}{1}.* basis.*( Aze(l,j)*cosa + Azo(l,j)*sina ); - end - end - end + Acov{1} = At; + Acov{2} = Az; end - - -Acov{1} = At; -Acov{2} = Az; From 56a69dfe1c88fdaf119351f714565e301409209b Mon Sep 17 00:00:00 2001 From: Joaquim Loizu Date: Wed, 18 May 2022 11:25:59 +0200 Subject: [PATCH 012/134] Fixed bug for plotting iota versus flux --- Utilities/matlabtools/plot_spec_iota.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Utilities/matlabtools/plot_spec_iota.m b/Utilities/matlabtools/plot_spec_iota.m index 0f72c67e..b8db004e 100644 --- a/Utilities/matlabtools/plot_spec_iota.m +++ b/Utilities/matlabtools/plot_spec_iota.m @@ -133,15 +133,19 @@ kstart = 1; psitor = zeros(1,length(sval)); - for lvol=1:mvol + start = -1; + if lvol==1 + start = -0.999; + end + if lvol==nvol % Required if last value had a -2 (often in free bound) - phiedge = cumflux + get_spec_torflux(data, nvol, 0, -1, 1, ns, nt); + phiedge = cumflux + get_spec_torflux(data, nvol, 0, start, 1 , ns, nt); end for k=kstart:kstart-1+nptrj(lvol) - psitor(k) = cumflux + get_spec_torflux(data,lvol,0,-1,sval(k),ns,nt); + psitor(k) = cumflux + get_spec_torflux(data,lvol,0, start, sval(k),ns,nt); end cumflux = psitor(k); kstart = kstart+nptrj(lvol); @@ -214,7 +218,7 @@ xlabel('(\Psi / \Psi_{edge})^{1/2}') out = cell(2); - out{1} = psitor/psitor(end); + out{1} = sqrt(psitor/psitor(end)); out{2} = F(1:nsucctrj); end From e78becd4ccb8584e36bd78cd1d232ded04de8152 Mon Sep 17 00:00:00 2001 From: Joaquim Loizu Date: Wed, 18 May 2022 11:30:53 +0200 Subject: [PATCH 013/134] Fixed bug (number of inputs was wrong) --- Utilities/matlabtools/plot_spec_surface_current.m | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Utilities/matlabtools/plot_spec_surface_current.m b/Utilities/matlabtools/plot_spec_surface_current.m index a43db383..f364eb68 100644 --- a/Utilities/matlabtools/plot_spec_surface_current.m +++ b/Utilities/matlabtools/plot_spec_surface_current.m @@ -1,7 +1,7 @@ function plot_spec_surface_current(data, nt, newfig) % -% PLOT_SPEC_SURFACE_CURRENT( DATA, NS, NT, ZETA, NEWFIG ) +% PLOT_SPEC_SURFACE_CURRENT( DATA, NS, NT, NEWFIG ) % =================================================== % % Plot pressure-driven currents located at each volume interface @@ -10,7 +10,6 @@ function plot_spec_surface_current(data, nt, newfig) % ----- % -data : data obtained via read_spec(filename) % -nt : number of poloidal interpolation points -% -zeta : toroidal angle % -newfig : plots on an existing figure (=0), a new figure (=1) or % overwrites last figure (=2) % From 17dc196410cdf41e3cfd51e1590d684b8b6beb86 Mon Sep 17 00:00:00 2001 From: Joaquim Loizu Date: Wed, 18 May 2022 11:36:32 +0200 Subject: [PATCH 014/134] Fixed bug (some lines had to be deleted) --- Utilities/matlabtools/plot_spec_iotakam.m | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Utilities/matlabtools/plot_spec_iotakam.m b/Utilities/matlabtools/plot_spec_iotakam.m index dadac157..f4f7d168 100644 --- a/Utilities/matlabtools/plot_spec_iotakam.m +++ b/Utilities/matlabtools/plot_spec_iotakam.m @@ -51,12 +51,6 @@ function plot_spec_iotakam(data,iorq,xaxis,newfig) R0(l) = sum(Rmn(:,l+1)); end -case 0 - hold on -case 1 -case 2 - hold off - if(iorq=='i') F = iota(2:end); G = oita(2:end); From 10e9b9c5266b5c5de328ff796fd0d34f9ec20bc3 Mon Sep 17 00:00:00 2001 From: Joaquim Loizu Date: Wed, 18 May 2022 11:45:42 +0200 Subject: [PATCH 015/134] Fixed bug (start=-1 gives problem for lvol=1) --- Utilities/matlabtools/plot_spec_torflux.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Utilities/matlabtools/plot_spec_torflux.m b/Utilities/matlabtools/plot_spec_torflux.m index e0332ac5..c757f2a3 100644 --- a/Utilities/matlabtools/plot_spec_torflux.m +++ b/Utilities/matlabtools/plot_spec_torflux.m @@ -11,8 +11,8 @@ function plot_spec_torflux(data, zeta, cumulative, newfig) % ------ % data: data obtained from read_spec(filename) % zeta: Toroidal angle -% cumulative: True to get cumulative plot (\psi_a = \int_0^a B_\phi dS) -% or False to get a non-cumulative plot (\psi_a = +% cumulative: true to get cumulative plot (\psi_a = \int_0^a B_\phi dS) +% or false to get a non-cumulative plot (\psi_a = % \int_{a-1}^a B_\phi dS) % newfig: 0: plots on an existing figure without erasing previous % plot @@ -25,7 +25,11 @@ function plot_spec_torflux(data, zeta, cumulative, newfig) Mvol = data.output.Mvol; torflux = zeros(1,Mvol); for lvol=1:Mvol - tmp = get_spec_torflux(data,lvol,zeta,-1,1,64,64); + start=-1; + if(lvol==1) + start=-0.999; + end + tmp = get_spec_torflux(data,lvol,zeta,start,1,64,64); Nvol = data.input.physics.Nvol; if cumulative From 6c9bb752d64967aeb5c5d5a04caae5f81cc2e352 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 19 May 2022 17:32:33 +0200 Subject: [PATCH 016/134] Update SPEC_Namelist; added a tutorial --- .../matlabtools/SPEC_Namelist/SPEC_Namelist.m | 1239 +++++++++++------ .../SPEC_Namelist/nm_tutorial_001.md | 146 ++ .../SPEC_Namelist/rw_namelist/read_namelist.m | 18 +- 3 files changed, 1004 insertions(+), 399 deletions(-) create mode 100644 Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md diff --git a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m index c966b714..49c1609f 100644 --- a/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/SPEC_Namelist.m @@ -11,13 +11,13 @@ end properties (Access=private) - Mpol = 0; - Ntor = 0; + mpol = 0; + ntor = 0; array_size = [0, 0]; Mvol = 0; - Nvol = 0; + nvol = 0; verbose = true; - Lboundary = 0; + lboundary = 0; end @@ -36,7 +36,7 @@ % INPUTS % ------ % -FILENAME: SPEC input file (.sp) - % -VARARGIN: Any couple of input: + % -VArArGIN: Any couple of input: % - 'Liniguess': set to true to read initial guess, false % to skip it. default: true % @@ -47,7 +47,7 @@ % % - % Read optional input + % read optional input l = length(varargin); if mod(l,2)~=0 error('InputError: invalid number of inputs') @@ -59,10 +59,9 @@ opt.(varargin{2*ii-1}) = varargin{2*ii}; end - % Fill class arguments obj.verbose = opt.verbose; - % Read input file + % read input file work = read_namelist( filename ); obj.lists = fields(work); for ii=1:length(obj.lists) @@ -77,7 +76,7 @@ % reformat all spectral quantities to have the same resolution obj = obj.set_fourier_resolution(); - % Read initial guess + % read initial guess if opt.Liniguess obj = obj.read_initial_guess( filename ); else @@ -91,7 +90,7 @@ % READ_INITIAL_GUESS( FILENAME ) % ============================== % - % Read the initial guess from the input file filename. + % read the initial guess from the input file filename. % % If the Fourier resolution of the initial guess is larger than % the Fourier resolution of the other physical qunatities, these @@ -109,10 +108,9 @@ % end of the category "screenlist" and then read each line. % Each line is then saved as a string in a structure. fid = fopen( filename, 'r' ); - save_line = false; % This is switched to true once - % we are at the end of the - % screelist - category = ''; % Save the name of the category + save_line = false; % This is switched to true once + % we are at the end of the screelist + category = ''; % Save the name of the category initial_guess_str = {}; @@ -121,7 +119,7 @@ tline = fgetl(fid); tline = strtrim(tline); - if isempty(tline) + if isempty( tline ) continue end @@ -129,7 +127,6 @@ initial_guess_str{end+1} = tline; else % otherwise look for beginning of initial guess - % Check if beginning of new category if( strcmp(tline, '/') ) if( strcmp(category,'screenlist') ) save_line = true; @@ -143,7 +140,6 @@ end end - end % end of while fclose(fid); % Close file @@ -159,62 +155,62 @@ % The first two elements are the mode numbers m and n, then we % have Rbc, Zbs, Rbs, Zbc for each volume interface l = length(str2num( initial_guess_str{1} )); - l = l-2; % Remove m, n + l = l-2; % remove m, n if mod(l,4)~=0 error('Invalid number of modes in initial guess') end - if l/4obj.Nvol + if l/4>obj.nvol error('Too many volumes in initial guess') end - % Read format of initial guess + % read format of initial guess tmp = SPEC_Namelist( filename, 'Liniguess', false ); - if tmp.physicslist.Lboundary~=obj.physicslist.Lboundary + if tmp.physicslist.lboundary~=obj.physicslist.lboundary error(['The initial guess from file %s does not use the',... 'same boundary representation.'], filename) end - % Check if there is an initial guess... + % Check if there is an initial guess nlines = length(initial_guess_str); if nlines<1 obj.initial_guess = struct([]); % generate empty structure return end - % Read Mpol, Ntor - Mpol_in = 0; Ntor_in = 0; + % read mpol, ntor + mpol_in = 0; ntor_in = 0; for iline=1:nlines % Scan line line_data = str2num( initial_guess_str{iline} ); % Find corresponding index mm = line_data(1); nn = line_data(2); - Mpol_in = max([mm, Mpol_in]); - Ntor_in = max([abs(nn), Ntor_in]); + mpol_in = max([mm, mpol_in]); + ntor_in = max([abs(nn), ntor_in]); end % Check if resolution is smaller or larger than inner - % resolution. This changes obj.Mpol and obj.Ntor if + % resolution. This changes obj.mpol and obj.ntor if % necessary - if (Mpol_in>obj.Mpol) || (Ntor_in>obj.Ntor) - obj = obj.change_fourier_resolution( Mpol_in, Ntor_in ); + if (mpol_in>obj.mpol) || (ntor_in>obj.ntor) + obj = obj.change_fourier_resolution( mpol_in, ntor_in ); end % Now format initial guess in a structure - switch obj.Lboundary - case 0 % Rmn, Zmn representation + switch obj.physicslist.lboundary + case 0 % rmn, zmn representation % Allocate memory - Ric = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); - Ris = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); - Zic = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); - Zis = zeros(2*obj.Ntor+1, obj.Mpol+1, obj.Mvol); + ric = zeros(2*obj.ntor+1, obj.mpol+1, obj.Mvol); + ris = zeros(2*obj.ntor+1, obj.mpol+1, obj.Mvol); + zic = zeros(2*obj.ntor+1, obj.mpol+1, obj.Mvol); + zis = zeros(2*obj.ntor+1, obj.mpol+1, obj.Mvol); % Fill initial guess arrays for iline=1:nlines @@ -225,72 +221,195 @@ % Find corresponding index m = line_data(1); n = line_data(2); im = m+1; - in = n+obj.Ntor+1; + in = n+obj.ntor+1; - for ivol=1:obj.Nvol - Ric(in,im,ivol) = line_data(ivol*4-1); - Zis(in,im,ivol) = line_data(ivol*4 ); - Ris(in,im,ivol) = line_data(ivol*4+1); - Zic(in,im,ivol) = line_data(ivol*4+2); + for ivol=1:obj.nvol + ric(in,im,ivol) = line_data(ivol*4-1); + zis(in,im,ivol) = line_data(ivol*4 ); + ris(in,im,ivol) = line_data(ivol*4+1); + zic(in,im,ivol) = line_data(ivol*4+2); end end % Fill structure - obj.initial_guess.Ric = Ric; - obj.initial_guess.Zis = Zis; - obj.initial_guess.Ris = Ris; - obj.initial_guess.Zic = Zic; + obj.initial_guess.ric = ric; + obj.initial_guess.zis = zis; + obj.initial_guess.ris = ris; + obj.initial_guess.zic = zic; case 1 % Henneberg representation - error('Henneberg representation not yet implemented') + rhoi = zeros(2*obj.ntor+1, obj.mpol+1, obj.nvol); + bin = zeros(obj.ntor+1, obj.nvol); + r0ic = zeros(obj.ntor+1, obj.nvol); + z0is = zeros(obj.ntor+1, obj.nvol); + + for iline=1:nlines + + line_data = str2num( initial_guess_str{iline} ); + + m = line_data(1); n = line_data(2); + im = m+1; + in = n+obj.ntor+1; + + for ivol=1:obj.nvol + + if n>=0 && m==0 + bin( n+1, ivol) = line_data(ivol*4-1); + r0ic(n+1, ivol) = line_data(ivol*4 ); + z0is(n+1, ivol) = line_data(ivol*4+1); + end + + if m>0 + rhoi(in, im, ivol ) = line_data( ivol*4+2 ); + end + end + + end + + + obj.initial_guess.rhoi = rhoi; + obj.initial_guess.bin = bin; + obj.initial_guess.r0ic = r0ic; + obj.initial_guess.z0is = z0is; otherwise - error('Invalid Lboundary!') + error('Invalid lboundary!') end end + + function obj = set_boundary_from_namelist( obj, filename, boundary ) + % + % SET_BOUNDARY_FROM_NAMELIST( FILENAME ) + % ====================================== + % + % Read the plasma or computational boundary from another SPEC + % namelist and use it for the current instance + % + % INPUT + % ----- + % -filename: Filename of the other SPEC input namelist + % -boundary: PB for Plasma Boundary or CB for computational + % boundary + % + % OUTPUT + % ------ + % -obj: Updated output of SPEC Namelist + + + % Read input SPEC Namelist + nm = SPEC_Namelist( filename ); + + % Get relevant boundary + switch boundary + case 'PB' + Remn = nm.physicslist.rbc; + Romn = nm.physicslist.rbs; + Zemn = nm.physicslist.zbc; + Zomn = nm.physicslist.zbs; + case 'CB' + Remn = nm.physicslist.rwc; + Romn = nm.physicslist.rws; + Zemn = nm.physicslist.zwc; + Zomn = nm.physicslist.zws; + otherwise + error('InputError: Invalid boundary') + end + + % Check size + if any(size(Remn)~=size(Romn)) + error('Size mismatch') + end + if any(size(Remn)~=size(Zemn)) + error('Size mismatch') + end + if any(size(Remn)~=size(Zomn)) + error('Size mismatch') + end + + % Get Fourier resolution + s = size(Remn); + ntor_in = (s(1)-1) / 2.0; + mpol_in = s(2)-1; + + % Change FOurier resolution to the largest one between obj and + % nm + if mpol_in>obj.mpol + obj = obj.change_fourier_resolution( mpol_in, obj.ntor ); + elseif mpol_inobj.ntor + obj = obj.change_fourier_resolution( obj.mpol, ntor_in ); + elseif ntor_inobj.Mpol + + if m>obj.mpol warning('M is larger than the Fourier resolution') out = 0; return end - % Check if toroidal mode is within the resolution - if abs(n)>obj.Ntor - warning('N is larger than the Fourier resolution') + if abs(n)>obj.ntor + warning('M is larger than the Fourier resolution') out = 0; return end - + % Need to make the difference between initial guess harmonics % or harmonics from the physics list. rhoi, bin, R0ic and Z0is % are related to the Henneberg representation - if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... - || strcmp(field, 'Zic') || strcmp(field, 'Zis') ... + if strcmp(field, 'ric') || strcmp(field, 'ris') ... + || strcmp(field, 'zic') || strcmp(field, 'zis') ... || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... - || strcmp(field, 'R0ic') || strcmp(field, 'Z0is') + || strcmp(field, 'r0ic') || strcmp(field, 'z0is') if isempty(obj.initial_guess) error('No initial guess available') @@ -298,7 +417,7 @@ ivol = varargin{1}; - if ivol<1 || ivol>obj.Nvol + if ivol<1 || ivol>obj.nvol error('Invalid ivol') end @@ -310,16 +429,49 @@ end - % Read relevant harmonic. - out = obj.(cat).(field)(n+obj.Ntor+1, m+1, ivol); + % Read relevant harmonic + out = obj.(cat).(field)(n+obj.ntor+1, m+1, ivol); end % ================================================================= % Setter + function obj = set_harmonics_to_zero( obj, field ) + % + % SET_HARMONICS_TO_ZERO( FIELD ) + % ============================== + % + % Set all Fourier harmonics of the field to zero + % + % INPUT + % ----- + % -FIELD: Field to set harmonics to zero + % + % OUTPUT + % ------ + % -OBJ: Updated instance of SPEC_Namelist\ + % + + + if strcmp(field, 'ric') || strcmp(field, 'ris') ... + || strcmp(field, 'zic') || strcmp(field, 'zis') ... + || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... + || strcmp(field, 'r0ic') || strcmp(field, 'z0is') + + cat = 'initial_guess'; + else + cat = 'physicslist'; + end + + obj.(cat).(field) = zeros( obj.array_size ); + + end + + + function obj = set_fourier_harmonics( obj, field, im, in, value, varargin ) % - % SET_FOURIER_HARMONICS( FIELD, M, N, (IVOL) ) + % SET_FOURiER_HARMONICS( FIELD, M, N, (IVOL) ) % ============================================ % % Sets the fourier harmonics associated to the field, @@ -327,13 +479,14 @@ % % INPUTS % ------ - % -field: 'Rbc', 'Zws', 'Ric', ... + % -field: 'rbc', 'zws', 'ric', ... % -im : Poloidal mode number, size 1xmn % -in : Toroidal mode number, size 1xmn % -value: Value for the mode, size 1xmn % -(ivol): Optional argument, required for fourier harmonics % of the initial guess + % First check the input size mn = length(im); if length(in)~=mn @@ -343,91 +496,95 @@ error('The array value has not the same length as im') end + % If some modes are greater than the actual resolution, + % increase the resolution accordingly + mpol_in = max(im); + if mpol_in>obj.mpol + warning('Poloidal resolution has to be increased ...') + obj = obj.change_fourier_resolution( mpol_in, obj.ntor ); + end + + ntor_in = max(abs(in)); + if ntor_in>obj.ntor + warning('Toroidal resolution has to be increased ...') + obj = obj.change_fourier_resolution( obj.mpol, ntor_in ); + end + % Loop over the input harmonics for imn=1:mn m = im(imn); n = in(imn); - - % If some modes are greater than the actual resolution, - % increase the resolution accordingly - if m>obj.Mpol - warning('Poloidal resolution has to be increased ...') - obj = obj.change_fourier_resolution( m, obj.Ntor ); - end - - if abs(n)>obj.Ntor - warning('Toroidal resolution has to be increased ...') - obj = obj.change_fourier_resolution( obj.Mpol, abs(n) ); - end + % Check if the quantity is located in the initial guess % structure or in the physicslist structure. - if strcmp(field, 'Ric') || strcmp(field, 'Ris') ... - || strcmp(field, 'Zic') || strcmp(field, 'Zis') ... + if strcmp(field, 'ric') || strcmp(field, 'ris') ... + || strcmp(field, 'zic') || strcmp(field, 'zis') ... || strcmp(field, 'rhoi') || strcmp(field, 'bin') ... - || strcmp(field, 'R0ic') || strcmp(field, 'Z0is') + || strcmp(field, 'r0ic') || strcmp(field, 'z0is') - % If the initial guess is empty (i.e. no initial guess - % are available), then we create one filled with zeros if isempty(obj.initial_guess) warning('No initial guess available... filling with zeros') - - if obj.Lboundary == 0 - obj.initial_guess.Ric = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); - obj.initial_guess.Ris = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); - obj.initial_guess.Zic = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); - obj.initial_guess.Zis = zeros( obj.array_size(1), obj.array_size(2), obj.Nvol ); + + % If the initial guess is empty (i.e. no initial guess + % are available), then we create one filled with zeros + if obj.lboundary == 0 + obj.initial_guess.ric = zeros( obj.array_size(1), obj.array_size(2), obj.nvol ); + obj.initial_guess.ris = zeros( obj.array_size(1), obj.array_size(2), obj.nvol ); + obj.initial_guess.zic = zeros( obj.array_size(1), obj.array_size(2), obj.nvol ); + obj.initial_guess.zis = zeros( obj.array_size(1), obj.array_size(2), obj.nvol ); else - error('Henneberg representation not yet implemented' ) + obj.initial_guess.rhoi = zeros( obj.array_size(1), obj.array_size(2), obj.nvol ); + obj.initial_guess.bin = zeros( obj.ntor+1, obj.nvol ); + obj.initial_guess.r0ic = zeros( obj.ntor+1, obj.nvol ); + obj.initial_guess.z0is = zeros( obj.ntor+1, obj.nvol ); end end ivol = varargin{1}; - if ivol<1 || ivol>obj.Nvol + if ivol<1 || ivol>obj.nvol error('Invalid ivol') end - cat = 'initial_guess'; + obj.initial_guess.(field)(n+obj.ntor+1, m+1, ivol) = value(imn); else - cat = 'physicslist'; - ivol = 1; + + obj.physicslist.(field)(n+obj.ntor+1, m+1) = value(imn); + end - - % Set the relevant harmonics - obj.(cat).(field)(n+obj.Ntor+1, m+1, ivol) = value(imn); end end - function obj = truncate_fourier_series( obj, Mpol, Ntor ) + function obj = truncate_fourier_series( obj, mpol, ntor ) % - % TRUNCATE_FOURIER_SERIES( MPOL, NTOR ) + % TRUNCATE_FOURiER_SERiES( mpol, ntor ) % ===================================== % % Truncates all spectral quantities to the requested poloidal - % and toroidal resolution. This can also be used to increase + % and toroidal resolution This can also be used to increase % the Fourier resolution. % % INPUTS % ------ - % -Mpol: Poloidal resolution - % -Ntor: Toroidal resolution + % -mpol: Poloidal resolution + % -ntor: Toroidal resolution % % OUTPUT % ------ % -OBJ: Truncated instance of SPEC_Namelist % - obj = obj.change_fourier_resolution( Mpol, Ntor ); + obj = obj.change_fourier_resolution( mpol, ntor ); end function obj = change_boundary_representation( obj, new_lboundary ) % - % CHANGE_BOUNDARY_REPRESENTATION( NEW_LBOUNDARY ) + % CHANGE_BOUNDArY_rEPrESENTATION( NEW_lbOUNDArY ) % =============================================== % % Changes from the hudson representation to the henneberg's one @@ -435,9 +592,45 @@ % % INPUT % ----- - % -new_lboundary: New value for Lboundary + % -new_lboundary: New value for lboundary - error('Henneberg representation not yet implemented') + + if obj.lboundary==0 && new_lboundary==1 + + obj.physicslist.rhomn = zeros(2*obj.ntor+1, obj.mpol); + obj.physicslist.shift.rhomn = [obj.ntor+1, 1]; + obj.physicslist.bn = zeros(obj.ntor+1, 1); + obj.physicslist.r0c = zeros(obj.ntor+1, 1); + obj.physicslist.z0s = zeros(obj.ntor+1, 1); + + obj.physicslist = rmfield( obj.physicslist, 'rbc' ); + obj.physicslist = rmfield( obj.physicslist, 'rbs' ); + obj.physicslist = rmfield( obj.physicslist, 'zbc' ); + obj.physicslist = rmfield( obj.physicslist, 'zbs' ); + + elseif obj.lboundary==1 && new_lboundary==0 + obj.physicslist.rbc = zeros(2*obj.ntor+1, obj.mpol); + obj.physicslist.rbs = zeros(2*obj.ntor+1, obj.mpol); + obj.physicslist.zbc = zeros(2*obj.ntor+1, obj.mpol); + obj.physicslist.zbs = zeros(2*obj.ntor+1, obj.mpol); + + obj.physicslist = rmfield( obj.physicslist, 'rhomn' ); + obj.physicslist = rmfield( obj.physicslist, 'bn' ); + obj.physicslist = rmfield( obj.physicslist, 'r0c' ); + obj.physicslist = rmfield( obj.physicslist, 'z0s' ); + + obj.physicslist.shift.rbc = [obj.ntor+1, 1]; + obj.physicslist.shift.rbs = [obj.ntor+1, 1]; + obj.physicslist.shift.zbc = [obj.ntor+1, 1]; + obj.physicslist.shift.zbs = [obj.ntor+1, 1]; + + end + + obj.physicslist.lboundary = new_lboundary; + obj.lboundary = new_lboundary; + + + end @@ -445,10 +638,10 @@ % Plotters function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) % - % PLOT_PLASMA_BOUNDARY + % PLOT_PLASMA_BOUNDArY % ==================== % - % Plot the boundary given by Rbc, Zbs, Rbs, Zbc + % Plot the boundary given by rbc, zbs, rbs, zbc % % INPUTS % ------ @@ -461,30 +654,38 @@ function plot_plasma_boundary( obj, nt, phi, newfig, varargin ) % % - if obj.Lboundary==0 - Rbc = obj.physicslist.Rbc; - Rbs = obj.physicslist.Rbs; - Zbc = obj.physicslist.Zbc; - Zbs = obj.physicslist.Zbs; + if obj.lboundary==0 + rbc = obj.physicslist.rbc; + rbs = obj.physicslist.rbs; + zbc = obj.physicslist.zbc; + zbs = obj.physicslist.zbs; - obj.plot_surface_Lb0( Rbc, Zbs, Rbs, Zbc, nt, phi, newfig, varargin{:} ) + obj.plot_surface_lb0( rbc, zbs, rbs, zbc, nt, phi, newfig, varargin{:} ) else + rhomn = obj.physicslist.rhomn; + bn = obj.physicslist.bn; + r0c = obj.physicslist.r0c; + z0s = obj.physicslist.z0s; - error('Henneberg representation is not implemented') + obj.plot_surface_lb1( rhomn, bn, r0c, z0s, nt, phi, newfig, varargin{:} ) end end - function plot_computational_boundary( obj, nt, phi, newfig, varargin ) + function plot_computational_boundary( obj, nt, phi, VorB, newfig, varargin ) % - % PLOT_PLASMA_BOUNDARY + % PLOT_PLASMA_BOUNDArY % ==================== % - % Plot the boundary given by Rbc, Zbs, Rbs, Zbc + % Plot the boundary given by rbc, zbs, rbs, zbc % % INPUTS % ------ % -NT: Number of poloidal points % -PHI: Toroidal angle + % -VorB: ='V' + % ='B' + % ='F' + % ='N' % -NEWFIG: =0: plot on gca % =1: plot on a new figure % =2: erase and plot on gca @@ -492,24 +693,29 @@ function plot_computational_boundary( obj, nt, phi, newfig, varargin ) % % - if obj.Lboundary == 0 - Rwc = obj.physicslist.Rwc; - Rws = obj.physicslist.Rws; - Zwc = obj.physicslist.Zwc; - Zws = obj.physicslist.Zws; + if obj.lboundary == 0 + rwc = obj.physicslist.rwc; + rws = obj.physicslist.rws; + zwc = obj.physicslist.zwc; + zws = obj.physicslist.zws; - obj.plot_surface_Lb0( Rwc, Zws, Rws, Zwc, nt, phi, newfig, varargin{:} ) + obj.plot_surface_lb0( rwc, zws, rws, zwc, nt, phi, newfig, varargin{:} ) else - error('Henneberg representation not yet implemented') + error('Not implemented') + end + + if VorB~='N' + newfig = 0; + obj.plot_normal_field( floor(nt/10), phi, VorB, newfig ) end end function plot_initial_guess( obj, nt, phi, newfig, varargin ) % - % PLOT_PLASMA_BOUNDARY( NT, PHI, NEWFIG, VARARGIN ) + % PLOT_PLASMA_BOUNDArY( NT, PHI, NEWFIG, VArArGIN ) % ================================================= % - % Plot the boundary given by Rbc, Zbs, Rbs, Zbc + % Plot the boundary given by rbc, zbs, rbs, zbc % % INPUTS % ------ @@ -526,22 +732,32 @@ function plot_initial_guess( obj, nt, phi, newfig, varargin ) error('No initial guess is provided') end - if obj.Lboundary == 0 - for ivol=1:obj.Nvol - Ric = obj.initial_guess.Ric(:,:,ivol); - Ris = obj.initial_guess.Ris(:,:,ivol); - Zic = obj.initial_guess.Zic(:,:,ivol); - Zis = obj.initial_guess.Zis(:,:,ivol); + if obj.lboundary == 0 + for ivol=1:obj.nvol + ric = obj.initial_guess.ric(:,:,ivol); + ris = obj.initial_guess.ris(:,:,ivol); + zic = obj.initial_guess.zic(:,:,ivol); + zis = obj.initial_guess.zis(:,:,ivol); if ivol>=2 newfig=0; end - obj.plot_surface_Lb0( Ric, Zis, Ris, Zic, nt, phi, newfig, varargin{:} ) + obj.plot_surface_lb0( ric, zis, ris, zic, nt, phi, newfig, varargin{:} ) end else - - error('Henneberg representation not yet implemented' ) + for ivol=1:obj.nvol + rhoi = obj.initial_guess.rhoi(:,:,ivol); + bin = obj.initial_guess.bin(:, ivol); + r0ic = obj.initial_guess.r0ic(:, ivol); + z0is = obj.initial_guess.z0is(:, ivol); + + if ivol>=2 + newfig=0; + end + + obj.plot_surface_lb1( rhoi, bin, r0ic, z0is, nt, phi, newfig, varargin{:} ) + end end end @@ -549,7 +765,7 @@ function plot_initial_guess( obj, nt, phi, newfig, varargin ) % Write method function write_input_file(obj, filename ) % - % WRITE_INPUT_FILE( filename ) + % WriTE_INPUT_FILE( filename ) % ============================ % % Write namelist in an input file. Be careful: if the file filename @@ -563,103 +779,113 @@ function write_input_file(obj, filename ) % Set minimal toroidal resolution to one, otherwise writting % routine does not detect arrays. This is not ideal and should % be fixed - if obj.Ntor==0 - obj = obj.change_fourier_resolution( obj.Mpol, 1 ); + if obj.ntor==0 + obj = obj.change_fourier_resolution( obj.mpol, 1 ); end - + % Create a structure with the different lists nlists = length(obj.lists); S = struct; for ii=1:nlists S.(obj.lists{ii}) = obj.(obj.lists{ii}); end - + % Create a shift quantity - this tells the writing routine how % much each index has to be shifted. In MATLAB, indices start % at 1, while in the FORTRAN Namelist, we want to write - % elements with negative indices. - S.shift.Rbc = [obj.Ntor+1, 1]; - S.shift.Rbs = [obj.Ntor+1, 1]; - S.shift.Zbc = [obj.Ntor+1, 1]; - S.shift.Zbs = [obj.Ntor+1, 1]; - S.shift.Rwc = [obj.Ntor+1, 1]; - S.shift.Rws = [obj.Ntor+1, 1]; - S.shift.Zws = [obj.Ntor+1, 1]; - S.shift.Zwc = [obj.Ntor+1, 1]; - S.shift.Vnc = [obj.Ntor+1, 1]; - S.shift.Vns = [obj.Ntor+1, 1]; - S.shift.Bnc = [obj.Ntor+1, 1]; - S.shift.Bns = [obj.Ntor+1, 1]; - S.shift.rhomn = [obj.Ntor+1, 1]; - - % Remove unnecessary fields. - if obj.Lboundary == 0 + S.shift.rbc = [obj.ntor+1, 1]; + S.shift.rbs = [obj.ntor+1, 1]; + S.shift.zbc = [obj.ntor+1, 1]; + S.shift.zbs = [obj.ntor+1, 1]; + S.shift.rwc = [obj.ntor+1, 1]; + S.shift.rws = [obj.ntor+1, 1]; + S.shift.zws = [obj.ntor+1, 1]; + S.shift.zwc = [obj.ntor+1, 1]; + S.shift.vnc = [obj.ntor+1, 1]; + S.shift.vns = [obj.ntor+1, 1]; + S.shift.bnc = [obj.ntor+1, 1]; + S.shift.bns = [obj.ntor+1, 1]; + S.shift.rhomn = [obj.ntor+1, 1]; + + % remove unnecessary fields + if obj.lboundary == 0 if isfield( S.physicslist, 'rhomn' ) S.physicslist = rmfield(S.physicslist, 'rhomn'); end if isfield( S.physicslist, 'bn' ) S.physicslist = rmfield(S.physicslist, 'bn'); end - if isfield( S.physicslist, 'R0c' ) - S.physicslist = rmfield(S.physicslist, 'R0c'); + if isfield( S.physicslist, 'r0c' ) + S.physicslist = rmfield(S.physicslist, 'r0c'); end - if isfield( S.physicslist, 'Z0s' ) - S.physicslist = rmfield(S.physicslist, 'Z0s'); + if isfield( S.physicslist, 'z0s' ) + S.physicslist = rmfield(S.physicslist, 'z0s'); end - else % Lboundary==1 - error('Henneberg representation not yet implemented') + else % lboundary==1 + if isfield( S.physicslist, 'rbc' ) + S.physicslist = rmfield(S.physicslist, 'rbc'); + end + if isfield( S.physicslist, 'rbs' ) + S.physicslist = rmfield(S.physicslist, 'rbs'); + end + if isfield( S.physicslist, 'zbc' ) + S.physicslist = rmfield(S.physicslist, 'zbc'); + end + if isfield( S.physicslist, 'zbs' ) + S.physicslist = rmfield(S.physicslist, 'zbs'); + end end - if obj.physicslist.Lfreebound==0 % Then no need to freeboundary info - if isfield( S.physicslist, 'Rwc' ) - S.physicslist = rmfield(S.physicslist, 'Rwc'); + if obj.physicslist.lfreebound==0 % Then no need to freeboundary info + if isfield( S.physicslist, 'rwc' ) + S.physicslist = rmfield(S.physicslist, 'rwc'); end - if isfield( S.physicslist, 'Rws' ) - S.physicslist = rmfield(S.physicslist, 'Rws'); + if isfield( S.physicslist, 'rws' ) + S.physicslist = rmfield(S.physicslist, 'rws'); end - if isfield( S.physicslist, 'Zwc' ) - S.physicslist = rmfield(S.physicslist, 'Zwc'); + if isfield( S.physicslist, 'zwc' ) + S.physicslist = rmfield(S.physicslist, 'zwc'); end - if isfield( S.physicslist, 'Zws' ) - S.physicslist = rmfield(S.physicslist, 'Zws'); + if isfield( S.physicslist, 'zws' ) + S.physicslist = rmfield(S.physicslist, 'zws'); end - if isfield( S.physicslist, 'Vnc' ) - S.physicslist = rmfield(S.physicslist, 'Vnc'); + if isfield( S.physicslist, 'vnc' ) + S.physicslist = rmfield(S.physicslist, 'vnc'); end - if isfield( S.physicslist, 'Vns' ) - S.physicslist = rmfield(S.physicslist, 'Vns'); + if isfield( S.physicslist, 'vns' ) + S.physicslist = rmfield(S.physicslist, 'vns'); end - if isfield( S.physicslist, 'Bnc' ) - S.physicslist = rmfield(S.physicslist, 'Bnc'); + if isfield( S.physicslist, 'bnc' ) + S.physicslist = rmfield(S.physicslist, 'bnc'); end - if isfield( S.physicslist, 'Bns' ) - S.physicslist = rmfield(S.physicslist, 'Bns'); + if isfield( S.physicslist, 'bns' ) + S.physicslist = rmfield(S.physicslist, 'bns'); end end % Build initial guess strings - if obj.physicslist.Lboundary==0 + if obj.physicslist.lboundary==0 if ~isempty(obj.initial_guess) - s = size(obj.initial_guess.Ric); + s = size(obj.initial_guess.ric); initialguess = cell(1, s(1)*s(2)); iline=0; for ii=1:s(1) for jj=1:s(2) iline = iline+1; mm = jj-1; - nn = ii-obj.Ntor-1; + nn = ii-obj.ntor-1; initialguess{iline} = sprintf( '%i %i ', mm, nn ); for ivol=1:s(3) initialguess{iline} = sprintf( '%s %0.12E %0.12E %0.12E %0.12E', initialguess{iline}, ... - obj.initial_guess.Ric(ii,jj,ivol), ... - obj.initial_guess.Zis(ii,jj,ivol), ... - obj.initial_guess.Ris(ii,jj,ivol), ... - obj.initial_guess.Zic(ii,jj,ivol) ); + obj.initial_guess.ric(ii,jj,ivol), ... + obj.initial_guess.zis(ii,jj,ivol), ... + obj.initial_guess.ris(ii,jj,ivol), ... + obj.initial_guess.zic(ii,jj,ivol) ); end end end @@ -669,7 +895,50 @@ function write_input_file(obj, filename ) else - error('Henneberg representation not yet implemented') + % Now prepare initial guess... + if isfield(obj.initial_guess, 'bin') + sb = size(obj.initial_guess.bin); + srho = size(obj.initial_guess.rhoi); + ntor = (srho(2)-1)/2.0; + initialguess = cell(1, sb(1) + srho(1)*srho(2)); + + % Modes m=0, n + for ii=1:sb(1) + nn = ii-1; + initialguess{ii} = sprintf('0 %i ', nn); + for ivol=1:sb(2) + initialguess{ii} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii}, ... + obj.initial_guess.bin( ii, ivol ), ... + obj.initial_guess.r0ic(ii, ivol ), ... + obj.initial_guess.z0is(ii, ivol ), 0.0 ); + end + end + + it = sb(1); + for ii=1:srho(2) + + nn = ii-ntor-1; + + for jj=1:srho(1) + + it = it+1; + + mm = jj; + + initialguess{it} = sprintf('%i %i ', mm, nn); + + for ivol=1:srho(3) + + initialguess{it} = sprintf('%s %0.12E %0.12E %0.12E %0.12E', initialguess{ii},... + 0.0, 0.0, 0.0, obj.initial_guess.rhoi(ii, jj, ivol)); + + end + end + end + else + initialguess = cell(0); + + end @@ -686,41 +955,42 @@ function write_input_file(obj, filename ) function obj = initialize_structure( obj ) % - % INITIALIZE_STRUCTURE( OBJ ) + % INITIALIzE_STrUCTUrE( OBJ ) % =========================== % % Use to check that all required inputs are correctly set; - % check that the sizes of arrays are correct. Raise errors in + % check that the sizes of arrays are correct. raise errors in % case crucial informations is missing. % % % Fill some important inputs - if ~isfield(obj.physicslist, 'Nvol') - error('Missing Nvol') + if ~isfield(obj.physicslist, 'nvol') + error('Missing nvol') end - if ~isfield(obj.physicslist, 'Lfreebound') - error('Missing Lfreebound') + if ~isfield(obj.physicslist, 'lfreebound') + error('Missing lfreebound') end - obj.Mvol = obj.physicslist.Nvol + obj.physicslist.Lfreebound; - obj.Nvol = obj.physicslist.Nvol; + obj.Mvol = obj.physicslist.nvol + obj.physicslist.lfreebound; + obj.nvol = obj.physicslist.nvol; - if isfield(obj.physicslist, 'Lboundary') - obj.Lboundary = obj.physicslist.Lboundary; + if isfield(obj.physicslist, 'lboundary') + obj.lboundary = obj.physicslist.lboundary; else - obj.Lboundary = 0; + warning('lboundary not provided. Setting with 0...') + obj.lboundary = 0; end % PHYSICSLIST % ----------- - % Lrad - if ~isfield(obj.physicslist, 'Lrad') && obj.verbose - warning('Missing Lrad. Filling with 4...') - obj.physicslist.Lrad = ones(1,obj.Mvol) * 4; + % lrad + if ~isfield(obj.physicslist, 'lrad') && obj.verbose + warning('Missing lrad. Filling with 4...') + obj.physicslist.lrad = ones(1,obj.Mvol) * 4; else % Fill potential missing elements with 4s - obj.physicslist.Lrad(end+1:obj.Mvol) = 4; + obj.physicslist.lrad(end+1:obj.Mvol) = 4; end % tflux @@ -744,7 +1014,7 @@ function write_input_file(obj, filename ) % helicity if ~isfield(obj.physicslist, 'helicity') - warning('Missing Lrad. Filling with 0...') + warning('Missing lrad. Filling with 0...') obj.physicslist.helicity = zeros(1,obj.Mvol); else % Fill potential missing elements with zeros @@ -757,10 +1027,10 @@ function write_input_file(obj, filename ) obj.physicslist.pscale = 0.0; end - % Ladiabatic - if ~isfield(obj.physicslist, 'Ladiabatic') - warning('Missing Ladiabatic. Setting to zero...') - obj.physicslist.Ladiabatic = 0.0; + % ladiabatic + if ~isfield(obj.physicslist, 'ladiabatic') + warning('Missing ladiabatic. Setting to zero...') + obj.physicslist.ladiabatic = 0.0; end % Pressure @@ -773,7 +1043,7 @@ function write_input_file(obj, filename ) end % Adiabatic - if obj.physicslist.Ladiabatic==1 + if obj.physicslist.ladiabatic==1 if ~isfield(obj.physicslist, 'adiabatic') warning('Missing adiabatic. Filling with 0...') obj.physicslist.adiabatic = zeros(1,obj.Mvol); @@ -792,19 +1062,19 @@ function write_input_file(obj, filename ) obj.physicslist.mu(end+1:obj.Mvol) = 0; end - % Lconstraint - if ~isfield(obj.physicslist, 'Lconstraint') - warning('Missing Lconstraint. Setting to 0...') - obj.physicslist.Lconstraint = 0; + % lconstraint + if ~isfield(obj.physicslist, 'lconstraint') + warning('Missing lconstraint. Setting to 0...') + obj.physicslist.lconstraint = 0; end - if ~any(obj.physicslist.Lconstraint==[0,1,2,3]) - error('Invalid Lconstraint') + if ~any(obj.physicslist.lconstraint==[0,1,2,3]) + error('Invalid lconstraint') end % Ivolume, Isurf - if obj.physicslist.Lconstraint==3 + if obj.physicslist.lconstraint==3 if ~isfield(obj.physicslist, 'Ivolume') warning('Missing Ivolume. Filling with 0...') obj.physicslist.Ivolume = zeros(1,obj.Mvol); @@ -821,7 +1091,7 @@ function write_input_file(obj, filename ) end end - if obj.physicslist.Lconstraint==1 + if obj.physicslist.lconstraint==1 if ~isfield(obj.physicslist, 'iota') warning('Missing iota. Filling with sqrt(2)...') obj.physicslist.iota = sqrt(2)*ones(1,obj.Mvol); @@ -851,131 +1121,168 @@ function write_input_file(obj, filename ) end % Check geometry - if ~isfield(obj.physicslist, 'Mpol') - error('Missing Mpol information') + if ~isfield(obj.physicslist, 'mpol') + error('Missing mpol information') end - if ~isfield(obj.physicslist, 'Ntor') - error('Missing Ntor information') + if ~isfield(obj.physicslist, 'ntor') + error('Missing ntor information') end - if ~isfield(obj.physicslist, 'Lboundary') - warning('Missing Lboundary. Setting to zero') - obj.physicslist.Lboundary = 0; + if ~isfield(obj.physicslist, 'lboundary') + warning('Missing lboundary. Setting to zero') + obj.physicslist.lboundary = 0; end - Mpol_in = obj.physicslist.Mpol; - Ntor_in = obj.physicslist.Ntor; + mpol_in = obj.physicslist.mpol; + ntor_in = obj.physicslist.ntor; - if obj.Lboundary==0 - if ~isfield(obj.physicslist, 'Rbc') - obj.physicslist.shift.Rbc = [Ntor_in+1, 1]; - obj.physicslist.Rbc = zeros(2*Ntor_in+1, Mpol_in); + if obj.lboundary==0 + if ~isfield(obj.physicslist, 'rbc') + obj.physicslist.shift.rbc = [ntor_in+1, 1]; + obj.physicslist.rbc = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Rbs') - obj.physicslist.shift.Rbs = [Ntor_in+1, 1]; - obj.physicslist.Rbs = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'rbs') + obj.physicslist.shift.rbs = [ntor_in+1, 1]; + obj.physicslist.rbs = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Zbc') - obj.physicslist.shift.Zbc = [Ntor_in+1, 1]; - obj.physicslist.Zbc = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'zbc') + obj.physicslist.shift.zbc = [ntor_in+1, 1]; + obj.physicslist.zbc = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Zbs') - obj.physicslist.shift.Zbs = [Ntor_in+1, 1]; - obj.physicslist.Zbs = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'zbs') + obj.physicslist.shift.zbs = [ntor_in+1, 1]; + obj.physicslist.zbs = zeros(2*ntor_in+1, mpol_in); end % Check that sizes are consistent with each others - if any(size(obj.physicslist.Rbc)~=size(obj.physicslist.Rbs)) - error('Size mismatch between Rbc and Rbs') + if any(size(obj.physicslist.rbc)~=size(obj.physicslist.rbs)) + error('Size mismatch between rbc and rbs') + end + if any(size(obj.physicslist.rbc)~=size(obj.physicslist.zbc)) + error('Size mismatch between rbc and zbc') end - if any(size(obj.physicslist.Rbc)~=size(obj.physicslist.Zbc)) - error('Size mismatch between Rbc and Zbc') + if any(size(obj.physicslist.rbc)~=size(obj.physicslist.zbs)) + error('Size mismatch between rbc and zbs') end - if any(size(obj.physicslist.Rbc)~=size(obj.physicslist.Zbs)) - error('Size mismatch between Rbc and Zbs') + + + else %lboundary==1 + if ~isfield( obj.physicslist, 'bn' ) + obj.physicslist.bn = zeros( ntor_in+1, 1 ); end + % Now fill missing elements with zeros + obj.physicslist.bn(end+1:ntor_in+1) = 0.0; - else %Lboundary==1 + if ~isfield( obj.physicslist, 'r0c' ) + obj.physicslist.r0c = zeros( ntor_in+1, 1 ); + end - error('Henneberg representation not yet implemented') + % Now fill missing elements with zeros + obj.physicslist.r0c(end+1:ntor_in+1) = 0.0; + + if ~isfield( obj.physicslist, 'z0s' ) + obj.physicslist.z0s = zeros( ntor_in+1, 1 ); + end + + % Now fill missing elements with zeros + obj.physicslist.z0s(end+1:ntor_in+1) = 0.0; + + if ~isfield( obj.physicslist, 'rhomn' ) + obj.physicslist.shift.rhomn = [ntor_in+1, 1]; + obj.physicslist.rhomn = zeros( 2*ntor_in+1, mpol_in+1 ); + end + + % Check sizes + if any(length(obj.physicslist.bn)~=ntor_in+1) + obj.physicslist.bn(end+1:ntor_in+1) = 0; + obj.physicslist.bn = obj.physicslist.bn(ntor_in+1); + end + if any(length(obj.physicslist.r0c)~=ntor_in+1) + obj.physicslist.r0c(end+1:ntor_in+1) = 0; + obj.physicslist.r0c = obj.physicslist.r0c(ntor_in+1); + end + if any(length(obj.physicslist.z0s)~=ntor_in+1) + obj.physicslist.z0s(end+1:ntor_in+1) = 0; + obj.physicslist.z0s = obj.physicslist.z0s(ntor_in+1); + end end - if ~isfield(obj.physicslist, 'Rwc') - obj.physicslist.shift.Rwc = [Ntor_in+1, 1]; - obj.physicslist.Rwc = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'rwc') + obj.physicslist.shift.rwc = [ntor_in+1, 1]; + obj.physicslist.rwc = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Rws') - obj.physicslist.shift.Rws = [Ntor_in+1, 1]; - obj.physicslist.Rws = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'rws') + obj.physicslist.shift.rws = [ntor_in+1, 1]; + obj.physicslist.rws = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Zwc') - obj.physicslist.shift.Zwc = [Ntor_in+1, 1]; - obj.physicslist.Zwc = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'zwc') + obj.physicslist.shift.zwc = [ntor_in+1, 1]; + obj.physicslist.zwc = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Zws') - obj.physicslist.shift.Zws = [Ntor_in+1, 1]; - obj.physicslist.Zws = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'zws') + obj.physicslist.shift.zws = [ntor_in+1, 1]; + obj.physicslist.zws = zeros(2*ntor_in+1, mpol_in); end % Check that sizes are consistent with each others - if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Rws)) - error('Size mismatch between Rwc and Rws') + if any(size(obj.physicslist.rwc)~=size(obj.physicslist.rws)) + error('Size mismatch between rwc and rws') end - if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zwc)) - error('Size mismatch between Rwc and Zwc') + if any(size(obj.physicslist.rwc)~=size(obj.physicslist.zwc)) + error('Size mismatch between rwc and zwc') end - if any(size(obj.physicslist.Rwc)~=size(obj.physicslist.Zws)) - error('Size mismatch between Rwc and Zws') + if any(size(obj.physicslist.rwc)~=size(obj.physicslist.zws)) + error('Size mismatch between rwc and zws') end - if ~isfield(obj.physicslist, 'Vnc') - obj.physicslist.shift.Vnc = [Ntor_in+1, 1]; - obj.physicslist.Vnc = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'vnc') + obj.physicslist.shift.vnc = [ntor_in+1, 1]; + obj.physicslist.vnc = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Vns') - obj.physicslist.shift.Vns = [Ntor_in+1, 1]; - obj.physicslist.Vns = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'vns') + obj.physicslist.shift.vns = [ntor_in+1, 1]; + obj.physicslist.vns = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Bnc') - obj.physicslist.shift.Bnc = [Ntor_in+1, 1]; - obj.physicslist.Bnc = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'bnc') + obj.physicslist.shift.bnc = [ntor_in+1, 1]; + obj.physicslist.bnc = zeros(2*ntor_in+1, mpol_in); end - if ~isfield(obj.physicslist, 'Bns') - obj.physicslist.shift.Bns = [Ntor_in+1, 1]; - obj.physicslist.Bns = zeros(2*Ntor_in+1, Mpol_in); + if ~isfield(obj.physicslist, 'bns') + obj.physicslist.shift.bns = [ntor_in+1, 1]; + obj.physicslist.bns = zeros(2*ntor_in+1, mpol_in); end % Check that sizes are consistent with each others - if any(size(obj.physicslist.Vnc)~=size(obj.physicslist.Vns)) - error('Size mismatch between Vnc and Vns') + if any(size(obj.physicslist.vnc)~=size(obj.physicslist.vns)) + error('Size mismatch between vnc and vns') end - if any(size(obj.physicslist.Bnc)~=size(obj.physicslist.Bns)) - error('Size mismatch between Bnc and Bns') + if any(size(obj.physicslist.bnc)~=size(obj.physicslist.bnc)) + error('Size mismatch between bnc and bns') end % DIAGNOSTICSLIST % --------------- - if ~isfield(obj.diagnosticslist, 'nPpts') - warning('Missing nPpts. Setting to zero') - obj.diagnosticslist.nPpts = 0; + if ~isfield(obj.diagnosticslist, 'nppts') + warning('Missing nppts. Setting to zero') + obj.diagnosticslist.nppts = 0; end - if ~isfield(obj.diagnosticslist, 'nPtrj') - warning('Missing nPtrj. Setting to zero') - obj.diagnosticslist.nPtrj = 0; + if ~isfield(obj.diagnosticslist, 'nptrj') + warning('Missing nptrj. Setting to zero') + obj.diagnosticslist.nptrj = 0; end end - function obj = change_fourier_resolution( obj, Mpol_new, Ntor_new ) + function obj = change_fourier_resolution( obj, mpol_new, ntor_new ) % - % CHANGE_FOURIER_RESOLUTION( MPOL_NEW, NTOR_NEW ) + % CHANGE_FOUriEr_rESOLUTION( mpol_NEW, ntor_NEW ) % =============================================== % % Change inner Fourier resolution of an instance of @@ -983,109 +1290,131 @@ function write_input_file(obj, filename ) % % INPUTS % ------ - % -Mpol_new: New poloidal resolution - % -Ntor_new: New toroidal resolution + % -mpol_new: New poloidal resolution + % -ntor_new: New toroidal resolution % % OUTPUT % ------ % -obj: Updated instance of SPEC_Namelist % - if Mpol_new<1 - error('InputError, Mpol_new should be larger than 0') + if mpol_new<1 + error('InputError, mpol_new should be larger than 0') end - if Ntor_new<0 - error('InputError, Ntor_new should be larger or equal to zero') + if ntor_new<0 + error('InputError, ntor_new should be larger or equal to zero') end - obj.Mpol = Mpol_new; - obj.Ntor = Ntor_new; - obj.array_size = [2*obj.Ntor+1, obj.Mpol+1]; + obj.mpol = mpol_new; + obj.ntor = ntor_new; + obj.array_size = [2*obj.ntor+1, obj.mpol+1]; % Check that all arrays have the same size; otherwise, fill % with zeros the missing elements - if obj.Lboundary == 0 - if any(size(obj.physicslist.Rbc)~=obj.array_size) - obj = obj.reshape_array( 'Rbc' ); - obj = obj.reshape_array( 'Rbs' ); - obj = obj.reshape_array( 'Zbc' ); - obj = obj.reshape_array( 'Zbs' ); + if obj.lboundary == 0 + if any(size(obj.physicslist.rbc)~=obj.array_size) + obj = obj.reshape_array( 'rbc' ); + obj = obj.reshape_array( 'rbs' ); + obj = obj.reshape_array( 'zbc' ); + obj = obj.reshape_array( 'zbs' ); end - if any(size(obj.physicslist.Rwc)~=obj.array_size) - obj = obj.reshape_array( 'Rwc' ); - obj = obj.reshape_array( 'Rws' ); - obj = obj.reshape_array( 'Zwc' ); - obj = obj.reshape_array( 'Zws' ); + if any(size(obj.physicslist.rwc)~=obj.array_size) + obj = obj.reshape_array( 'rwc' ); + obj = obj.reshape_array( 'rws' ); + obj = obj.reshape_array( 'zwc' ); + obj = obj.reshape_array( 'zws' ); end else - error('Henneberg representation not yet implemented') + if any(size(obj.physicslist.rhomn)~=obj.array_size) + obj = obj.reshape_array( 'rhomn' ); + end + + if any(size(obj.physicslist.bn)~=[obj.ntor+1, 1]) + obj.physicslist.bn(end+1:obj.ntor+1) = 0; + obj.physicslist.bn = obj.physicslist.bn(1:obj.ntor+1); + end + if any(size(obj.physicslist.r0c)~=[obj.ntor+1, 1]) + obj.physicslist.r0c(end+1:obj.ntor+1) = 0; + obj.physicslist.r0c = obj.physicslist.r0c(1:obj.ntor+1); + end + if any(size(obj.physicslist.z0s)~=[obj.ntor+1, 1]) + obj.physicslist.z0s(end+1:obj.ntor+1) = 0; + obj.physicslist.z0s = obj.physicslist.z0s(1:obj.ntor+1); + end end - if any(size(obj.physicslist.Vnc)~=obj.array_size) - obj = obj.reshape_array( 'Vnc' ); - obj = obj.reshape_array( 'Vns' ); + if any(size(obj.physicslist.vnc)~=obj.array_size) + obj = obj.reshape_array( 'vnc' ); + obj = obj.reshape_array( 'vns' ); end - if any(size(obj.physicslist.Bnc)~=obj.array_size) - obj = obj.reshape_array( 'Bnc' ); - obj = obj.reshape_array( 'Bns' ); + if any(size(obj.physicslist.bnc)~=obj.array_size) + obj = obj.reshape_array( 'bnc' ); + obj = obj.reshape_array( 'bns' ); end end function obj = set_fourier_resolution( obj ) % - % SET_FOURIER_RESOLUTION( OBJ ) + % SET_FOUriEr_rESOLUTION( OBJ ) % ============================= % % Set the obj internal Fourier resolution to the maximal value % required to store the given data; then, reshapees all arrays % to have the size obj.array_size. % - % Check beforehand that the resolution of Rbc is the same as - % Rbs, Zbc and Zbs. Do something similar for Vnc, Vns, Bnc, Bns - % and Rwc, Rws, Zws, Zwc. + % Check beforehand that the resolution of rbc is the same as + % rbs, zbc and zbs. Do something similar for vnc, vns, bnc, bns + % and rwc, rws, zws, zwc. % % Find largest Fourier resolution in the input file - Mpol_in = obj.physicslist.Mpol; - Ntor_in = obj.physicslist.Ntor; - - if obj.Lboundary == 0 - s_bc = size(obj.physicslist.Rbc); - shift = obj.physicslist.shift.Rbc(1); - Mpol_bc = s_bc(2)-1 ; - Ntor_bc = max([abs(1-shift), s_bc(1)-shift]); + mpol_in = obj.physicslist.mpol; + ntor_in = obj.physicslist.ntor; + + if obj.lboundary == 0 + s_bc = size(obj.physicslist.rbc); + shift = obj.physicslist.shift.rbc(1); + mpol_bc = s_bc(2)-1 ; + ntor_bc = max([abs(1-shift), s_bc(1)-shift]); else - error('Henneberg representation not yet implemented') + s_bc = size(obj.physicslist.rhomn); + shift = obj.physicslist.shift.rhomn(1); + mpol_bc = s_bc(2)-1; + + lbn = length( obj.physicslist.bn ); + lrc = length( obj.physicslist.r0c ); + lzs = length( obj.physicslist.z0s ); + ntor_bc = max([abs(1-shift), s_bc(1)-shift, lbn, lrc, lzs]); end - s_wc = size(obj.physicslist.Rwc); - shift = obj.physicslist.shift.Rwc(1); - Mpol_wc = s_wc(2)-1 ; - Ntor_wc = max([abs(1-shift), s_wc(1)-shift]); + s_wc = size(obj.physicslist.rwc); + shift = obj.physicslist.shift.rwc(1); + mpol_wc = s_wc(2)-1 ; + ntor_wc = max([abs(1-shift), s_wc(1)-shift]); - s_vb = size(obj.physicslist.Vnc); - shift = obj.physicslist.shift.Vnc(1); - Mpol_vb = s_vb(2)-1 ; - Ntor_vb = max([abs(1-shift), s_vb(1)-shift]); + s_vb = size(obj.physicslist.vnc); + shift = obj.physicslist.shift.vnc(1); + mpol_vb = s_vb(2)-1 ; + ntor_vb = max([abs(1-shift), s_vb(1)-shift]); - Mpol_new = max([Mpol_in, Mpol_bc, Mpol_wc, Mpol_vb]); - Ntor_new = max([Ntor_in, Ntor_bc, Ntor_wc, Ntor_vb]); - obj = obj.change_fourier_resolution( Mpol_new, Ntor_new ); + mpol_new = max([mpol_in, mpol_bc, mpol_wc, mpol_vb]); + ntor_new = max([ntor_in, ntor_bc, ntor_wc, ntor_vb]); + obj = obj.change_fourier_resolution( mpol_new, ntor_new ); end function obj = reshape_array( obj, field ) % - % RESHAPE_ARRAY( OBJ, FIELD ) + % rESHAPE_ArrAY( OBJ, FIELD ) % ======================================= % - % Reshape the input array in a an array of size obj.array_size + % reshape the input array in a an array of size obj.array_size % and fills missing elements with zeros % % INPUTS @@ -1100,20 +1429,19 @@ function write_input_file(obj, filename ) array = obj.physicslist.(field); shift = obj.physicslist.shift.(field); - s = size(array); - Ntor_array = max([abs(1-shift(1)), s(1)-shift(1)]); + s = size(array); new_array = zeros(obj.array_size); for ii=1:s(1) for jj=1:s(2) - nn = ii-Ntor_array-1; + nn = ii-shift(1); mm = jj-shift(2); - if abs(nn)>obj.Ntor || mm>obj.Mpol + if abs(nn)>obj.ntor || mm>obj.mpol continue end - new_array(nn+obj.Ntor+1, mm+1) = array(ii, jj); + new_array(nn+obj.ntor+1, mm+1) = array(ii, jj); end end @@ -1121,20 +1449,20 @@ function write_input_file(obj, filename ) end - function plot_surface_Lb0( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... + function plot_surface_lb0( obj, rmnc, zmns, rmns, zmnc, nt, phi, ... newfig, varargin ) % - % PLOT_SURFACE( RMNC, ZMNS, RMNS, ZMNC, NT, NEWFIG, VARARGIN ) + % PLOT_SUrFACE( rMNC, zMNS, rMNS, zMNC, NT, NEWFIG, VArArGIN ) % =========================================================== % % Plot a surface parametrized by the standard representation % % INPUTS % ------ - % -Rmnc: Even Fourier modes of R, format (2*Ntor+1, Mpol+1) - % -Zmns: Odd Fourier modes of Z, format (2*Ntor+1, Mpol+1) - % -Rmns: Odd Fourier modes of R, format (2*Ntor+1, Mpol+1) - % -Zmnc: Even Fourier modes of Z, format (2*Ntor+1, Mpol+1) + % -rmnc: Even Fourier modes of r, format (2*ntor+1, mpol+1) + % -zmns: Odd Fourier modes of z, format (2*ntor+1, mpol+1) + % -rmns: Odd Fourier modes of r, format (2*ntor+1, mpol+1) + % -zmnc: Even Fourier modes of z, format (2*ntor+1, mpol+1) % -NT : Number of poloidal points % -PHI : Toroidal angle % -newfig: =0: plot on gca @@ -1154,16 +1482,16 @@ function plot_surface_Lb0( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... error('InputError: invalid newfig') end - s = size(Rmnc); + s = size(rmnc); - if any(s~=size(Rmns)) - error('InputError: Rmnc has not the same size as Rmns') + if any(s~=size(rmns)) + error('InputError: rmnc has not the same size as rmns') end - if any(s~=size(Zmns)) - error('InputError: Rmnc has not the same size as Zmns') + if any(s~=size(zmns)) + error('InputError: rmnc has not the same size as zmns') end - if any(s~=size(Zmnc)) - error('InputError: Rmnc has not the same size as Zmnc') + if any(s~=size(zmnc)) + error('InputError: rmnc has not the same size as zmnc') end if nt<1 error('InputError: nt should be larger than 1') @@ -1172,9 +1500,9 @@ function plot_surface_Lb0( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... N = (s(1)-1) / 2.0; tarr = linspace( 0, 2*pi, nt ); - R = zeros( 1, nt ); - Z = zeros( 1, nt ); - Nfp = double(obj.physicslist.Nfp); + r = zeros( 1, nt ); + z = zeros( 1, nt ); + nfp = double(obj.physicslist.nfp); for in=1:s(1) @@ -1182,32 +1510,32 @@ function plot_surface_Lb0( obj, Rmnc, Zmns, Rmns, Zmnc, nt, phi, ... for im=1:s(2) mm = im-1; - arg = mm*tarr - nn*Nfp*phi; + arg = mm*tarr - nn*nfp*phi; - R = R + Rmnc(in,im) * cos(arg) + Rmns(in,im) * sin(arg); - Z = Z + Zmnc(in,im) * cos(arg) + Zmns(in,im) * sin(arg); + r = r + rmnc(in,im) * cos(arg) + rmns(in,im) * sin(arg); + z = z + zmnc(in,im) * cos(arg) + zmns(in,im) * sin(arg); end end - plot( R, Z, varargin{:} ) + plot( r, z, varargin{:} ) axis equal end - function plot_surface_Lb1( obj, rhomn, bn, R0c, Z0s, nt, phi, newfig, varargin ) + function plot_surface_lb1( obj, rhomn, bn, r0c, z0s, nt, phi, newfig, varargin ) % - % PLOT_SURFACE_LB1( RHOMN, BN, R0C, Z0S, NT, PHI, NEWFIG, VARARGIN ) + % PLOT_SUrFACE_lb1( rHOMN, bn, r0C, z0S, NT, PHI, NEWFIG, VArArGIN ) % ================================================================== % % Plots a surface using the Henneberg representation % % INPUTS % ------ - % -rhomn: rho_mn harmonics, format (2*Ntor+1, Mpol+1) - % -bn: b_n harmonics, format (Ntor+1, 1) - % -R0c: R_0c harmonics, format (Ntor+1, 1) - % -Z0s: Z_0s harmonics, format (Ntor+1, 1) + % -rhomn: rho_mn harmonics, format (2*ntor+1, mpol+1) + % -bn: b_n harmonics, format (ntor+1, 1) + % -r0c: r_0c harmonics, format (ntor+1, 1) + % -z0s: z_0s harmonics, format (ntor+1, 1) % -nt: Number of poloidal points % -phi: Toroidal angle % -newfig: =0: plot on gca @@ -1236,13 +1564,13 @@ function plot_surface_Lb1( obj, rhomn, bn, R0c, Z0s, nt, phi, newfig, varargin ) N = (s(1)-1) / 2.0; if any(length(bn)~=N+1) - error('InputError: bn has not the size Ntor+1') + error('InputError: bn has not the size ntor+1') end - if any(length(R0c)~=N+1) - error('InputError: R0c has not the size Ntor+1') + if any(length(r0c)~=N+1) + error('InputError: r0c has not the size ntor+1') end - if any(length(Z0s)~=N+1) - error('InputError: Z0s has not the size Ntor+1') + if any(length(z0s)~=N+1) + error('InputError: z0s has not the size ntor+1') end if nt<1 error('InputError: nt should be larger than 1') @@ -1251,33 +1579,164 @@ function plot_surface_Lb1( obj, rhomn, bn, R0c, Z0s, nt, phi, newfig, varargin ) tarr = linspace(0, 2*pi, nt); rho = zeros(1, nt); alpha = obj.physicslist.twoalpha / 2.0; - Nfp = double(obj.physicslist.Nfp); + nfp = double(obj.physicslist.nfp); for im=1:s(2) mm = im-1; for in=1:s(1) nn = in-N-1; - rho = rho + rhomn(in,im) * cos(mm*tarr + nn*Nfp*phi - alpha*Nfp*phi); + rho = rho + rhomn(in,im) * cos(mm*tarr + nn*nfp*phi - alpha*nfp*phi); end end - R0 = 0; - Z0 = 0; + r0 = 0; + z0 = 0; b = 0; for nn=0:N - R0 = R0 + R0c(nn+1) * cos(nn*Nfp*phi); - b = b + bn(nn+1 ) * cos(nn*Nfp*phi); - Z0 = Z0 + Z0s(nn+1) * sin(nn*Nfp*phi); + r0 = r0 + r0c(nn+1) * cos(nn*nfp*phi); + b = b + bn(nn+1 ) * cos(nn*nfp*phi); + z0 = z0 + z0s(nn+1) * sin(nn*nfp*phi); end - zeta = b.*sin( tarr - alpha*Nfp*phi ); + zeta = b.*sin( tarr - alpha*nfp*phi ); - R = R0 + rho * cos(alpha*Nfp*phi) - zeta * sin(alpha*Nfp*phi); - Z = Z0 + rho * sin(alpha*Nfp*phi) + zeta * cos(alpha*Nfp*phi); + r = r0 + rho * cos(alpha*nfp*phi) - zeta * sin(alpha*nfp*phi); + z = z0 + rho * sin(alpha*nfp*phi) + zeta * cos(alpha*nfp*phi); - plot(R, Z, varargin{:}) + plot(r, z, varargin{:}) axis equal end + + function plot_normal_field( obj, nt, phi, VorB, newfig ) + % + % PLOT_NORMAL_FIELD( NT, PHI, VORB, NEWFIG ) + % ==================================== + % + % Plots the normal field on the computational boundary as a + % vector field + % + % INPUTS + % ------ + % -NT: Number of poloidal points + % -PHI: Toroidal angle + % -VORB: ='V': Only vacuum field + % ='B': Only plasma field + % ='F': Add vacuum to plasma field + % -NEWFIG: =0: plot on gca + % =1: plot on a new figure + % =2: erase and plot on gca + + % First, build coordinate + tarr = linspace( 0, 2*pi, nt ); + r = zeros( 1, nt ); + z = zeros( 1, nt ); + + rmnc = obj.physicslist.rwc; + rmns = obj.physicslist.rws; + zmnc = obj.physicslist.zwc; + zmns = obj.physicslist.zws; + + Nfp = double(obj.physicslist.nfp); + + s = size(rmnc); + + if any(s~=size(rmns)) + error('InputError: rmnc has not the same size as rmns') + end + if any(s~=size(zmns)) + error('InputError: rmnc has not the same size as zmns') + end + if any(s~=size(zmnc)) + error('InputError: rmnc has not the same size as zmnc') + end + if nt<1 + error('InputError: nt should be larger than 1') + end + + N = (s(1)-1) / 2.0; + nfp = double(obj.physicslist.nfp); + + + for in=1:s(1) + nn = in-1-N; + for im=1:s(2) + mm = im-1; + + arg = mm*tarr - nn*nfp*phi; + + r = r + rmnc(in,im) * cos(arg) + rmns(in,im) * sin(arg); + z = z + zmnc(in,im) * cos(arg) + zmns(in,im) * sin(arg); + end + end + + % Then evaluate norm of normal field + switch VorB + case 'V' + fmnc = obj.physicslist.vnc; + fmns = obj.physicslist.vns; + case 'B' + fmnc = obj.physicslist.bnc; + fmns = obj.physicslist.bns; + case 'F' + fmnc = obj.physicslist.bnc + obj.physicslist.vnc; + fmns = obj.physicslist.bns + obj.physicslist.vns; + otherwise + error('InputError: Invalid VorB') + end + + bnorm = zeros(1, nt); + for mm=0:obj.mpol + for nn=-obj.ntor:obj.ntor + if mm==0 && nn<0 + continue + end + im = mm+1; + in = nn+obj.ntor+1; + arg = mm*tarr - nn*Nfp*phi; + + bnorm = bnorm + fmnc(in,im) * cos( arg ) ... + + fmns(in,im) * sin( arg ); + end + end + + bnorm = bnorm / max(bnorm); + + % Evaluate normal direction + bnormal = zeros(2, nt); + dt = 1e-5; + for it = 1:nt + + rj = 0; zj = 0; tj = tarr(it)-dt; + rk = 0; zk = 0; tk = tarr(it)+dt; + for in=1:s(1) + nn = in-1-N; + for im=1:s(2) + mm = im-1; + + argj = mm*tj - nn*nfp*phi; + rj = rj + rmnc(in,im) * cos(argj) + rmns(in,im) * sin(argj); + zj = zj + zmnc(in,im) * cos(argj) + zmns(in,im) * sin(argj); + + argk = mm*tk - nn*nfp*phi; + rk = rk + rmnc(in,im) * cos(argk) + rmns(in,im) * sin(argk); + zk = zk + zmnc(in,im) * cos(argk) + zmns(in,im) * sin(argk); + end + end + + bnormal(1,it) = zk-zj ; + bnormal(2,it) = -(rk-rj); + + bnormal(:,it) = bnorm(it) * bnormal(:,it) / sqrt(bnormal(1,it)^2+bnormal(2,it)^2); + end + + + + % Plot + quiver( r, z, bnormal(1,:), bnormal(2,:) ) + + + + end end end diff --git a/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md b/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md new file mode 100644 index 00000000..7edc2bb0 --- /dev/null +++ b/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md @@ -0,0 +1,146 @@ +# Introduction + +The class SPEC\_Namelist is a matlab tool to read, edit and write SPEC input files. Be careful though, always double check what kind of input file you generate - some errors are spotted by some tests in SPEC\_Namelist, but not everything is covered! + +In this tutorial, we will show how to read a namelist, edit its Fourier resolution and change some specific Fourier harmonics, plot the initial guess and finally write the namelist. + +# Reading a Namelist + +## Adding SPEC\_Namelist path to MATLAB +First of all, make sure that the path to SPEC\_Namelist is provided to MATLAB. To do so, you can write +```Matlab +addpath(genpath('my/path/to/SPEC/Utilities/matlabtools')) +``` + +to check that MATLAB is using the right SPEC\_Namelist class, you can check which file it is using with the command +```Matlab +which SPEC_Namelist +``` + +## Read a SPEC input file +To create a SPEC\_Namelist instance from a SPEC input file, you need to give its absolute or relative path to the constructor of the class. For example, try +```Matlab +nm = SPEC_Namelist('path/to/SPEC/InputFiles/TestCases/G3V08L3Fr.001.sp') +``` + +This will read the SPEC\_Namelist, create a MATLAB structure with all the input in a specific format, and check that some crucial inputs are provided. In case of missing inputs, it will print a few warnings: + +```Matlab +nm = SPEC_Namelist('~/SPEC/InputFiles/TestCases/G3V08L3Fr.001.sp') +Warning: lboundary not provided. Setting with 0... +> In SPEC_Namelist/initialize_structure (line 972) + In SPEC_Namelist (line 73) +Warning: Missing Ivolume. Filling with 0... +> In SPEC_Namelist/initialize_structure (line 1070) + In SPEC_Namelist (line 73) +Warning: Missing Isurf. Filling with 0... +> In SPEC_Namelist/initialize_structure (line 1077) + In SPEC_Namelist (line 73) +Warning: Missing lboundary. Setting to zero +> In SPEC_Namelist/initialize_structure (line 1122) + In SPEC_Namelist (line 73) +Warning: lboundary not provided. Setting with 0... +> In SPEC_Namelist/initialize_structure (line 972) + In SPEC_Namelist (line 73) + In SPEC_Namelist/read_initial_guess (line 172) + In SPEC_Namelist (line 81) +Warning: Missing Ivolume. Filling with 0... +> In SPEC_Namelist/initialize_structure (line 1070) + In SPEC_Namelist (line 73) + In SPEC_Namelist/read_initial_guess (line 172) + In SPEC_Namelist (line 81) +Warning: Missing Isurf. Filling with 0... +> In SPEC_Namelist/initialize_structure (line 1077) + In SPEC_Namelist (line 73) + In SPEC_Namelist/read_initial_guess (line 172) + In SPEC_Namelist (line 81) +Warning: Missing lboundary. Setting to zero +> In SPEC_Namelist/initialize_structure (line 1122) + In SPEC_Namelist (line 73) + In SPEC_Namelist/read_initial_guess (line 172) + In SPEC_Namelist (line 81) + +nm = + + SPEC_Namelist with properties: + + lists: {6x1 cell} + physicslist: [1x1 struct] + numericlist: [1x1 struct] + locallist: [1x1 struct] + globallist: [1x1 struct] + diagnosticslist: [1x1 struct] + screenlist: [1x1 struct] + initial_guess: [1x1 struct] +``` + +## Data structure format +SPEC\_Namelist stores SPEC input data in nested structures. All structure and data names uses lower case - be careful whenever you access the data! + +In addition, the class has an internal Fourier resolution, which is set by default to the largest poloidal and toroidal mode number in the input file. This resolution is a private attribute of the class and is not accessible to the user; to change it and increase or truncate all physical quantities in Fourier space to the resolution `mpol`, `ntor`, you can use + +```Matlab +nm = nm.truncate_fourier_series( mpol, ntor ) +``` + +All Fourier modes are stored in matrices of size `2*ntor+1 x mpol+1`. To get a specific mode, for example `Rbc(n,m)`, use +```Matlab +nm.get_fourier_harmonics( 'rbc', m, n ) +``` + +# Modifying a SPEC\_Namelist +To modify any input, you can simply access it as you would with any MATLAB structure. For example, to change the toroidal flux in the third volume to one, write +```Matlab +nm.physicslist.tflux(3) = 1; +``` + +For the Fourier modes, setters routines are provided. For example, to change the mode Rbc(n,m) to a value `value`, write +```Matlab +nm = nm.set_fourier_harmonics( 'rbc', 1, 0, value ); +``` + +If you want to set multiple modes, you can set them by providing arrays of values for `m`, `n` and `value`. Finally, if you want to use a computational boundary, a plasma boundary or the initial guess for the internal interfaces geometry from another SPEC input, you can use respectively `nm.set_boundary_from_namelist( filename, 'CB' )`, `nm.set_boundary_from_namelist( filename, 'PB' )` or `nm.read_initial_guess(filename)`. More information can be obtained by reading the documentation. + +**DO NOT CHANGE HARMONICS WITHOUT THESE ROUTINES!** This might break the class and some of your input will be ignored. + +# Visualizing the geometry of an input +Sometimes, SPEC crashes and it is difficult to know why. Some information can be obtained by plotting the geometry of computational boundary, the plasma boundary and the initial guess from the input file. + +## Plotting the plasma boundary +To plot the plasma boundary, write +```Matlab +nt = 1024; %Number of poloidal points +phi = 0; %Toroidal angle +nm.plot_plasma_boundary( nt, phi, 1 ); +``` + +The initial guess, if any, can be plotted with +```Matlab +nm.plot_initial_guess( nt, phi, 0 ); +``` + +## Plotting the computational boundary +Similarly, the computational boundary can be plotted with +```Matlab +nm.plot_computational_boundary( nt, phi, 'N', 1 ); +``` + +If you want to see the normal field on the computational boundary, switch `N` to (i) `V` to see the coils contribution, (ii) `B` to see the initial guess for the plasma contribution and (iii) `F` for the sum of both. + + +# Writing the namelist into a file +To write the Namelist, use the built in subroutine `write_input_file(filename)`. For example, do +```Matlab +nm.write_input_file( 'test.sp' ) +``` + +will write an input file called test.sp with all the relevant quantities. Some input won\'t be written if not required - for example, if `nm.physicslist.Lfreebound` is set to zero, the fields `rwc`, `rws`, `zwc` and `zws` will not be written. + + + + + + + + + diff --git a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/read_namelist.m b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/read_namelist.m index 46249610..7bce09c3 100755 --- a/Utilities/matlabtools/SPEC_Namelist/rw_namelist/read_namelist.m +++ b/Utilities/matlabtools/SPEC_Namelist/rw_namelist/read_namelist.m @@ -56,17 +56,17 @@ while i < c; % Find a record i = i + 1; - line = lines{i}; + line = lower(lines{i}); idx = find(line == '&'); if ~isempty(idx), % i.e. a namelist start line = line(idx(1) + 1:end); % find next space idx = find(line == ' '); if ~isempty(idx), - namelst = line(1:idx(1) - 1); + namelst = lower(line(1:idx(1) - 1)); line = line(idx(1) + 1:end); else - namelst = line; + namelst = lower(line); line = []; end nmlst_bdy = []; @@ -132,7 +132,7 @@ while strng(i) ~= ' ', i = i - 1; end if k > 1, arg_end(k - 1) = i; end - vars{k} = ['S.' strng(i + 1: j)]; + vars{k} = ['S.' lower(strng(i + 1: j))]; end arg_end(end) = length(strng); @@ -142,7 +142,7 @@ shift = struct; k_array = zeros(1,nvars); for k=1:nvars - v = vars{k}; + v = lower(vars{k}); % Check if it is an array ind_open = find(v=='('); @@ -159,7 +159,7 @@ k_array(k) = 1; % get how many dimensions - v_name = v(3:ind_open-1); + v_name = lower(v(3:ind_open-1)); v_ind = v(ind_open+1:ind_close-1); indices = str2num(v_ind); @@ -224,10 +224,10 @@ if k_array(k)==0 eval([vars{k} ' = ' arg]); else % apply shift - v = vars{k}; + v = lower(vars{k}); ind_open = find(v=='('); ind_close = find(v==')'); - v_name = v(3:ind_open-1); + v_name = lower(v(3:ind_open-1)); v_ind = v(ind_open+1:ind_close-1); tmp = find(v_ind==','); @@ -236,7 +236,7 @@ %indices = str2num(v_ind); - newstr = ['S.', v_name, '(']; + newstr = ['S.', lower(v_name), '(']; for idim = 1:dim if idim==1 ind_start=1; From 1ec26d3ca8dbbc4aa61287dc06025bbc47bf54be Mon Sep 17 00:00:00 2001 From: abaillod <45510759+abaillod@users.noreply.github.com> Date: Thu, 19 May 2022 17:34:35 +0200 Subject: [PATCH 017/134] Update nm_tutorial_001.md --- Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md b/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md index 7edc2bb0..9bd20c13 100644 --- a/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md +++ b/Utilities/matlabtools/SPEC_Namelist/nm_tutorial_001.md @@ -125,7 +125,7 @@ Similarly, the computational boundary can be plotted with nm.plot_computational_boundary( nt, phi, 'N', 1 ); ``` -If you want to see the normal field on the computational boundary, switch `N` to (i) `V` to see the coils contribution, (ii) `B` to see the initial guess for the plasma contribution and (iii) `F` for the sum of both. +If you want to see the normal field on the computational boundary, switch `'N'` to (i) `'V'` to see the coils contribution, (ii) `'B'` to see the initial guess for the plasma contribution and (iii) `'F'` for the sum of both. # Writing the namelist into a file From 19916dddadff7552c53ad11acb20226d2d7cfd4e Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 19 May 2022 17:42:04 +0200 Subject: [PATCH 018/134] plot_spec_kam now takes an angle as input --- Utilities/matlabtools/plot_spec_kam.m | 5 ++--- Utilities/matlabtools/plot_spec_poincare.m | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Utilities/matlabtools/plot_spec_kam.m b/Utilities/matlabtools/plot_spec_kam.m index a7dbe2e4..d5d3f4bb 100644 --- a/Utilities/matlabtools/plot_spec_kam.m +++ b/Utilities/matlabtools/plot_spec_kam.m @@ -1,4 +1,4 @@ -function plot_spec_kam(data, nz0, newfig, varargin) +function plot_spec_kam(data, zeta, newfig, varargin) % % PLOT_SPEC_KAM( DATA, NZ0, NEWFIG ) @@ -9,7 +9,7 @@ function plot_spec_kam(data, nz0, newfig, varargin) % INPUT % ----- % -data : obtained from read_spec(fname) -% -nz0 : show the toroidal plane number nz0 +% -zeta : toroidal angle % -newfig : opens(=1) or not(=0) a new figure, or overplots(=2) on existing figure % % written by J.Loizu (2016) @@ -44,7 +44,6 @@ function plot_spec_kam(data, nz0, newfig, varargin) Ndiscrete = double(data.input.numerics.Ndiscrete); Ntor = double(max(abs(data.output.in))); Nplan = max(Ndiscrete*4*Ntor, 1); - zeta = 2*pi*(nz0-1) / (Nplan); Nvol = double(data.input.physics.Nvol); mn = data.output.mn; diff --git a/Utilities/matlabtools/plot_spec_poincare.m b/Utilities/matlabtools/plot_spec_poincare.m index 819df3c1..7cb9842c 100644 --- a/Utilities/matlabtools/plot_spec_poincare.m +++ b/Utilities/matlabtools/plot_spec_poincare.m @@ -1,4 +1,4 @@ -function phi = plot_spec_poincare(data,nz0,arr,newfig,varargin) +function phi = plot_spec_poincare(data,nz0,arr,kam,newfig,varargin) % % PLOT_SPEC_POINCARE( DATA, NZ0, NFP, ARR, NEWFIG, VARARGIN ) @@ -16,6 +16,7 @@ % means all trajectories are ploted) % : can be an array of which field line should be plotted, if % size(arra)>1 +% -kam : Plots (=1) or not (=0) the KAM surfaces. % -newfig : opens(=1) or not(=0) a new figure, or overwrites (=2) last % plot % -varargin : Optional arguments. Any of the following pairs are @@ -275,6 +276,10 @@ end +if kam + phi = 2*pi*(nz0-1) / (double(nfp)*nz); + plot_spec_kam(data, phi, 0 ) +end disp(' '); disp('--- end of program ---'); From 9fa6ef162afc43213aa2aeeaddbedd348955dd03 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 12 Aug 2022 09:10:50 +0200 Subject: [PATCH 019/134] initial commit --- .../py_spec/input/spec_namelist.py | 86 +++++++++++++++++-- .../pythontools/py_spec/output/_processing.py | 81 +++++++++++++++++ Utilities/pythontools/py_spec/output/spec.py | 9 +- 3 files changed, 167 insertions(+), 9 deletions(-) diff --git a/Utilities/pythontools/py_spec/input/spec_namelist.py b/Utilities/pythontools/py_spec/input/spec_namelist.py index 9b843796..20f514d5 100644 --- a/Utilities/pythontools/py_spec/input/spec_namelist.py +++ b/Utilities/pythontools/py_spec/input/spec_namelist.py @@ -10,7 +10,7 @@ from f90nml import Namelist import numpy as np - +import matplotlib.pyplot as plt class SPECNamelist(Namelist): """The SPEC namelist class @@ -428,14 +428,14 @@ def get_interface_guess(self, m, n, ivol, key="Rbc"): return self.interface_guess[(m, n)][key][ivol] - def set_interface_guess(self, value, m, n, ivol, key="Rbc"): + def set_interface_guess(self, value, m, n, ivol, mykey="Rbc"): """Set the guess of the interface Fourier harmonic parameters: value -- the value that one wants to set m,n -- the m and n number of the guess, must be within the allowed Mpol and Ntor range the n number is the one without multiplying by Nfp ivol -- which volume, Python convention, starting from 0 - key -- which guess, can be 'Rbc', 'Zbs', 'Rbs', 'Zbc' + mykey -- which guess, can be 'Rbc', 'Zbs', 'Rbs', 'Zbc' """ if ivol >= self._Nvol or ivol < 0: raise ValueError("ivol must be between 0 and Nvol-1") @@ -443,8 +443,8 @@ def set_interface_guess(self, value, m, n, ivol, key="Rbc"): raise ValueError("0 <= m <= Mpol") if n > self._Ntor or n < -self._Ntor: raise ValueError("-Ntor <= n <= Ntor") - if key not in ["Rbc", "Rbs", "Zbc", "Zbs"]: - raise ValueError("key must be in ['Rbc', 'Rbs', 'Zbc', 'Zbs']") + if mykey not in ["Rbc", "Rbs", "Zbc", "Zbs"]: + raise ValueError("mykey must be in ['Rbc', 'Rbs', 'Zbc', 'Zbs']") if (m, n) not in self.interface_guess.keys(): # add a new item @@ -452,7 +452,30 @@ def set_interface_guess(self, value, m, n, ivol, key="Rbc"): for key in ["Rbc", "Rbs", "Zbc", "Zbs"]: self.interface_guess[(m, n)][key] = np.zeros([self._Nvol]) - self.interface_guess[(m, n)][key][ivol] = value + self.interface_guess[(m, n)][mykey][ivol] = value + + def set_plasma_boundary(self, value, m, n, key='Rbc'): + """Set the value of the plasma boundary + + parameters: + value -- the new value + m,n -- poloidal and toroidal mode number. Has to be within the allowed Mpol and Ntor Fourier resolution + n is has to be a multiple of Nfp + key -- any of 'Rbc', 'Rbs', 'Zbc', 'Zbs'. + """ + + if m > self._Mpol or m < 0: + raise ValueError("0 <= m <= Mpol") + if n > self._Ntor or n < -self._Ntor: + raise ValueError("-Ntor <= n <= Ntor") + if key not in ["Rbc", "Rbs", "Zbc", "Zbs"]: + raise ValueError("key must be in ['Rbc', 'Rbs', 'Zbc', 'Zbs']") + + if type(m)!=int: m=int(m) + if type(n)!=int: n=int(n) + if type(value)!=float: value = float(value) + + self['physicslist'][key][m][n+self._Ntor] = value def remove_interface_guess(self, m, n): """Remove the guess of the interface Fourier harmonic with some m,n @@ -465,6 +488,57 @@ def remove_interface_guess(self, m, n): raise ValueError("unknown m or n") else: del self.interface_guess[(m, n)] + def plot_initial_guess(self, phi=0, nt=1024, **kwargs): + """ + Plot the guess for the inner interfaces on a toroidal plane + + parameters: + phi -- toroidal angle + nt -- number of points per interface, 1024 by default + """ + + fig, ax = plt.subplots() + + tarr = np.linspace(0, 2*np.pi, nt) + nvol = self['physicslist']['Nvol'] + nfp = self['physicslist']['Nfp'] + + nmodes = len(self.interface_guess) + for ivol in range(0,nvol-1): + r = np.zeros(nt) + z = np.zeros(nt) + + for key in self.interface_guess.keys(): + mm = key[0] + nn = key[1] * nfp + + if mm>self['physicslist']['Mpol'] or abs(nn)>self['physicslist']['Ntor']: continue + + cosa = np.cos(mm*tarr - nn*phi) + sina = np.sin(mm*tarr - nn*phi) + r += self.interface_guess[key]['Rbc'][ivol] * cosa + \ + self.interface_guess[key]['Rbs'][ivol] * sina + z += self.interface_guess[key]['Zbc'][ivol] * cosa + \ + self.interface_guess[key]['Zbs'][ivol] * sina + + ax.scatter( r, z, **kwargs ) + + # Plot plasma boundary + r = np.zeros(nt) + z = np.zeros(nt) + for mm in range(0, self._Mpol+1): + for nn in range(-self._Ntor, self._Ntor+1): + cosa = np.cos(mm*tarr - nn*phi) + sina = np.sin(mm*tarr - nn*phi) + r += self['physicslist']['Rbc'][mm][nn+self._Ntor] * cosa \ + +self['physicslist']['Rbs'][mm][nn+self._Ntor] * sina + z += self['physicslist']['Zbc'][mm][nn+self._Ntor] * cosa \ + +self['physicslist']['Zbs'][mm][nn+self._Ntor] * sina + + ax.scatter( r, z, **kwargs ) + + plt.draw() + def _rectify_namelist(self): """correct the size/type of the namelist objects and so on""" diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 6479a6fe..f92936b4 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -359,6 +359,87 @@ def get_B_covariant(self, Bcontrav, g, derivative=False): Bco = np.einsum("...i,...ji->...j", Bcontrav, g) return Bco +def get_volume(self, ivol, ns=64, nt=64, nz=64): + """Returns volume occupied by volume ivol""" + + # Create coordinate grid + nfp = self.input.physics.Nfp + tarr = np.linspace(0, 2*np.pi, nt, endpoint=True) + zarr = np.linspace(0, 2*np.pi / nfp, nz, endpoint=True) + + if ivol==0: sarr=np.linspace(-0.999,1,ns) + else: sarr=np.linspace(-1, 1, ns) + + # Get jacobian + j = self.jacobian(lvol=ivol, sarr=sarr, tarr=tarr, zarr=zarr) + + # Integrate + dt = tarr[1]-tarr[0] + dz = zarr[1]-zarr[0] + ds = sarr[1]-sarr[0] + return nfp * integrate.simpson( y=integrate.simpson( y=integrate.simpson( y=j, x=zarr ), x=tarr ), x=sarr ) + +def get_average_beta(self, ns=64, nt=64, nz=64): + """Get beta averaged in plasma volume""" + + # Read pressure + press = self.input.physics.pressure * self.input.physics.pscale + + # Create coordinate grid + nfp = self.input.physics.Nfp + tarr = np.linspace(0, 2*np.pi, nt) + zarr = np.linspace(0, 2*np.pi / nfp, nz) + + # Get beta in each volume + nvol = self.input.physics.Nvol + + vols = np.zeros((nvol,)) + betavol = np.zeros((nvol,)) + for ivol in range(0,nvol-1): + if ivol==0: sarr=np.linspace(-0.999,1, ns) + if ivol!=0: sarr=np.linspace(-1, 1, ns) + + vols[ivol] = self.get_volume( ivol ) + + _, _, sg, g = self.get_grid_and_jacobian_and_metric( + lvol=ivol, sarr=sarr, tarr=tarr, zarr=zarr + ) + Bcontrav = self.get_B( + lvol=ivol, jacobian=sg, sarr=sarr, tarr=tarr, zarr=zarr + ) + modB = self.get_modB( Bcontrav, g ) + + betavol[ivol] = 2 * nfp * press[ivol] * integrate.simpson( + y=integrate.simpson( + y=integrate.simpson( + y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) + + return betavol.sum() / vols.sum() + + +def get_peak_beta(self, ns=64, nt=64, nz=64): + press = self.input.physics.pressure[0] * self.input.physics.pscale + + nfp = self.input.physics.Nfp + tarr = np.linspace(0, 2*np.pi, nt) + zarr = np.linspace(0, 2*np.pi / nfp, nz) + sarr=np.linspace(-0.999,1, ns) + + vol = self.get_volume( 0 ) + _, _, sg, g = self.get_grid_and_jacobian_and_metric( + lvol=0, sarr=sarr, tarr=tarr, zarr=zarr + ) + Bcontrav = self.get_B( + lvol=0, jacobian=sg, sarr=sarr, tarr=tarr, zarr=zarr + ) + modB = self.get_modB( Bcontrav, g ) + + return 2 * nfp * press * integrate.simpson( + y=integrate.simpson( + y=integrate.simpson( + y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) + + def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): ds = delta R, Z, j, g = self.get_grid_and_jacobian_and_metric(lvol, np.array([s-ds, s+ds]), np.array([t-ds, t+ds]), np.array([z-ds, z+ds])) diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index 733c48e0..28879471 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -37,6 +37,9 @@ class SPECout: get_B, get_modB, get_B_covariant, + get_volume, + get_average_beta, + get_peak_beta, test_derivatives ) from ._plot_modB import plot_modB @@ -100,9 +103,9 @@ def __init__(self, *args, **kwargs): # these define the target dimensions in the radial direction Nvol = self.input.physics.Nvol + Mvol = Nvol if self.input.physics.Lfreebound: - Nvol += 1 - self.input.physics.Nvol += 1 + Mvol += 1 Lrad = self.input.physics.Lrad @@ -122,7 +125,7 @@ def __init__(self, *args, **kwargs): # split up radial matrix dimension into list of matrices for each of the nested volumes start = 0 - for i in range(Nvol): + for i in range(Mvol): # vector potential cAte.append( np.atleast_2d(self.vector_potential.Ate)[ From 86510b7dc7c7a42d5790083f82f6cdfd5a7c9b61 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 12 Aug 2022 09:20:14 +0200 Subject: [PATCH 020/134] typos --- Utilities/pythontools/py_spec/output/_processing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index f92936b4..2e91ea79 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -1,5 +1,5 @@ import numpy as np - +from scipy import integrate def get_grid_and_jacobian_and_metric( self, @@ -395,6 +395,9 @@ def get_average_beta(self, ns=64, nt=64, nz=64): vols = np.zeros((nvol,)) betavol = np.zeros((nvol,)) + + if (press==0).all(): return 0 + for ivol in range(0,nvol-1): if ivol==0: sarr=np.linspace(-0.999,1, ns) if ivol!=0: sarr=np.linspace(-1, 1, ns) From 1b333c71a9461193810ff6e9b3a6a0d4adea19ed Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 12 Aug 2022 09:20:45 +0200 Subject: [PATCH 021/134] increased version before PR --- src/global.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global.f90 b/src/global.f90 index e61be2a7..b6d52173 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -66,7 +66,7 @@ module constants REAL, parameter :: mu0 = 2.0E-07 * pi2 !< \f$4\pi\cdot10^{-7}\f$ REAL, parameter :: goldenmean = 1.618033988749895 !< golden mean = \f$( 1 + \sqrt 5 ) / 2\f$ ; - REAL, parameter :: version = 3.20 !< version of SPEC + REAL, parameter :: version = 3.21 !< version of SPEC end module constants From eab612ad73c8d6dcb36bfb7884727fa73aab46bb Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Mon, 15 Aug 2022 10:10:59 +0200 Subject: [PATCH 022/134] Implemented SPEC_Namelist.set_vacuum_field --- .../pythontools/py_spec/input/spec_namelist.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Utilities/pythontools/py_spec/input/spec_namelist.py b/Utilities/pythontools/py_spec/input/spec_namelist.py index 20f514d5..4c629e12 100644 --- a/Utilities/pythontools/py_spec/input/spec_namelist.py +++ b/Utilities/pythontools/py_spec/input/spec_namelist.py @@ -428,6 +428,24 @@ def get_interface_guess(self, m, n, ivol, key="Rbc"): return self.interface_guess[(m, n)][key][ivol] + def set_vacuum_field( self, value, m, n, mykey='Bns'): + """Set the guess of the coils field harmonics + parameters: + value -- the value that one wants to set + m,n -- the m and n number of the guess, must be within the allowed Mpol and Ntor range + the n number is the one without multiplying by Nfp + mykey -- which guess, can be 'Bnc' or 'Bns' + """ + if m > self._Mpol or m < 0: + raise ValueError("0 <= m <= Mpol") + if n > self._Ntor or n < -self._Ntor: + raise ValueError("-Ntor <= n <= Ntor") + if mykey not in ['Bns', 'Bnc']: + raise ValueError("mykey must be in ['Bns', 'Bnc']") + + self['physicslist'][mykey][m][n+self._Ntor] = value + + def set_interface_guess(self, value, m, n, ivol, mykey="Rbc"): """Set the guess of the interface Fourier harmonic parameters: From 8d357ab4e947d45af4b31d4800718ac27b269bf9 Mon Sep 17 00:00:00 2001 From: salomon73 Date: Mon, 10 Oct 2022 20:27:46 +0200 Subject: [PATCH 023/134] Addition of first four matlab routines --- Utilities/matlabtools/extract_shear.m | 39 +++ .../get_spec_straight_fieldlines.m | 37 +++ Utilities/matlabtools/plot_spec_fieldlines.m | 86 ++++++ Utilities/matlabtools/scan_shear_auto_optim.m | 253 ++++++++++++++++++ 4 files changed, 415 insertions(+) create mode 100644 Utilities/matlabtools/extract_shear.m create mode 100644 Utilities/matlabtools/get_spec_straight_fieldlines.m create mode 100644 Utilities/matlabtools/plot_spec_fieldlines.m create mode 100644 Utilities/matlabtools/scan_shear_auto_optim.m diff --git a/Utilities/matlabtools/extract_shear.m b/Utilities/matlabtools/extract_shear.m new file mode 100644 index 00000000..8632529f --- /dev/null +++ b/Utilities/matlabtools/extract_shear.m @@ -0,0 +1,39 @@ +%% extract_shear(DATA, n, shift, n_surf) +% ======================================= +% +% Compute the shear (from iota) out of +% a SPEC out data +% +% INPUT +% ----- +% -data : must be produced using read_spec +% -n : length(iota) - (n_surf+shift-1); +% -shift : shift of the indices we take into account when computing +% shear (1st indices might not be relevant (too close to axis)) +% -n_surf : index of the first surface that encircles the magnetic axis +% +% ------------------------------------% +% Written by S.Guinchard (05/12/22) % +% ------------------------------------% +function out = extract_shear(d, n, shift, n_surf) + + id = n_surf+shift; + radial_coord = (d.transform.fiota(:,1)); % extract radial coordinate + out.mat_iota = d.transform.fiota(id:end,2); % extract iota + out.mat_r_coord = radial_coord(id:end); % truncates the radial coordinates (remove 5 first terms) + out.mat_s_coord = ((out.mat_r_coord + 1)./2); % change of variable r <--> s + out.scan_11 = d.output.Rbc(11,2); % Value of R11 + out.scan_10 = d.output.Rbc(2,2); % Value of R10 + + % CENTERED FINITE DIFFERENCES + out.derivatives(1) = (out.mat_iota(2) - out.mat_iota(1)) / (out.mat_s_coord(2) - out.mat_s_coord(1)); + out.derivatives(n) = (out.mat_iota(n) - out.mat_iota(n-1)) / (out.mat_s_coord(n) - out.mat_s_coord(n-1)); + + for j=2:n-1 + out.derivatives(j) = (out.mat_iota(j+1) - out.mat_iota(j-1)) / (out.mat_s_coord(j+1) - out.mat_s_coord(j-1)); + end + + out.coeff = out.mat_s_coord ./ (out.mat_iota) ; + out.shear = (out.coeff)' .* out.derivatives; + out.avg_shear = mean(out.shear); % Avg shear +end \ No newline at end of file diff --git a/Utilities/matlabtools/get_spec_straight_fieldlines.m b/Utilities/matlabtools/get_spec_straight_fieldlines.m new file mode 100644 index 00000000..3f396096 --- /dev/null +++ b/Utilities/matlabtools/get_spec_straight_fieldlines.m @@ -0,0 +1,37 @@ +%% GET_SPEC_STRAIGHT_FIELDLINES( d, NPOINTS, Nperiods ) +% ======================================================= +% +% Gives as output the straightfieldlines coordinates from SPEC out file +% +% INPUT +% ----- +% -data : must be produced by calling read_boozer(filename, root) +% -Npoints : number of points for toroidal resolution +% -Nperiods : number of toroidal periods +% +% ------------------------------------% +% Written by S.Guinchard (05/17/22) % +% ------------------------------------% +function SFL_coord = get_spec_straight_fieldlines(d,Npoints,Nperiods) + + m = double(d.output.ims); + n = double(d.output.ins); + lambda_mn = d.output.lambdamn(1:end,1,2); + + coord = plot_spec_fieldlines(d,Npoints,Nperiods,0); + theta = coord.theta; + phi = coord.phi; + + theta_sfl = theta; + + for i = 1:length(phi) + for j = 1:length(lambda_mn) + + theta_sfl(i) = theta_sfl(i) + lambda_mn(j,1,1)*sin(m(j)*theta(i) - n(j)*phi(i)); + + end + end + + SFL_coord.theta_sfl = wrapTo2Pi(theta_sfl); + SFL_coord.phi = wrapTo2Pi(phi); +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_spec_fieldlines.m b/Utilities/matlabtools/plot_spec_fieldlines.m new file mode 100644 index 00000000..3816d1c9 --- /dev/null +++ b/Utilities/matlabtools/plot_spec_fieldlines.m @@ -0,0 +1,86 @@ +%% plot_spec_fieldlines( DATA, NPOINTS, NPERIODS, NEWFIG ) +% ======================================================= +% +% Traces magnetic field lines in the (phi, theta) plane +% and gives an output containing the coordinates +% (used e.g with the code get_spec_straightfieldlines) +% +% INPUT +% ----- +% -data : must be produced by calling read_spec(filename) +% -Npoints : number of points along the field line +% -Nperiods : number of toroidal periods over which the field line is +% traced +% -Newfig : opens (=1) or not (=0) a new figure, or overwrites (=2) +% last plot +% +% ------------------------------------% +% Written by S.Guinchard (03/01/22) % +% Last modified (05/15/22) % +% ------------------------------------% + +function coord = plot_spec_fieldlines(d,Npoints,Nperiods,newfig) + + phi = linspace(0,2*Nperiods*pi,Npoints); + dphi = phi(2)-phi(1); + s = 1; + Fs = 18; + theta_temp(1) = 0; + + for i = 1:length(phi)-1 + Bfield_temp = get_spec_magfield(d,1,s,theta_temp(i),phi(i)); + theta_temp(i+1) = theta_temp(i)+dphi*(cell2mat(Bfield_temp(2))/cell2mat(Bfield_temp(3))); + end + + coord.theta = wrapTo2Pi(theta_temp); + coord.phi = wrapTo2Pi(phi); + switch newfig + + case 0 + hold on + scatter(coord.phi, coord.theta, 'b.') + ax = gca; + ax.TickLabelInterpreter = 'latex'; + xticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + xticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + yticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + yticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + xlim([0 2*pi]) + ylim([0 2*pi]) + set (gca, 'fontsize', Fs) + xlabel('$\phi$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + ylabel('$\theta$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + + case 1 + figure + scatter(coord.phi, coord.theta, 'b.') + ax = gca; + ax.TickLabelInterpreter = 'latex'; + xticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + xticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + yticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + yticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + xlim([0 2*pi]) + ylim([0 2*pi]) + set (gca, 'fontsize', Fs) + xlabel('$\phi$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + ylabel('$\theta$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + + case 2 + hold off + scatter(coord.phi, coord.theta, 'b.') + ax = gca; + ax.TickLabelInterpreter = 'latex'; + xticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + xticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + yticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + yticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + xlim([0 2*pi]) + ylim([0 2*pi]) + set (gca, 'fontsize', Fs) + xlabel('$\phi$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + ylabel('$\theta$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + + end + +end \ No newline at end of file diff --git a/Utilities/matlabtools/scan_shear_auto_optim.m b/Utilities/matlabtools/scan_shear_auto_optim.m new file mode 100644 index 00000000..65e03d9b --- /dev/null +++ b/Utilities/matlabtools/scan_shear_auto_optim.m @@ -0,0 +1,253 @@ +%% SCRIPT SCANNING R10 and R11 FROM SPEC AND EXTRACTING MAGNETIC SHEAR %% +%-----------------------------------------% +% Created by Salomon Guinchard (04/26/22) % +% Last modified (10/10/22) % +%-----------------------------------------% + +%% Paths to get_spec_mat_iota_torsion and other SPEC analysis routines (change path according to output folder) +addpath(genpath('/path_to_OutputSPEC')) +addpath(genpath('/path_to_/OutputBOZ')) +fs=18; lw=1.5; % Fontsize, linewidth + + +%% PARAMETERS %% +nscan = 20; +f = strings(nscan,nscan); +nn = length(f(:,1)); +parfor i=1:nn + for j=1:nn + f(i,j) = ['File', num2str(i), '_', num2str(j) '.sp.h5']; + end +end +filenames = reshape(f,1,nn^2); +ll = length(filenames); +d0 = read_spec(char(filenames(1))); + +l = d0.transform.fiota(:,2); +avg_shear = zeros(1,ll) ; +shift = 5; + +disp 'Done initialising...' +%% DISCRETISATION OF SPACE %% +scan__11 = linspace(-0.7,0.7,nscan); % values between which the mode 11 will be scanned +scan__10 = linspace(-3,3,nscan); % same for 10 mode (01 - see SPEC input format) + +%% RUN %% +tic % set timer on +parfor ii=1:ll + try + d = read_spec(char(filenames(ii))); + phi = 0; + + Nfp = double(d.input.physics.Nfp); % Number of field periods + Ntor = double(d.input.physics.Ntor); % Number of toroidal planes + Nppts = d.input.diagnostics.nPpts; % # points Poincare plots + + R0n = double(d.output.Rbc(1:Ntor+1,1)); + Z0n = double(d.output.Zbs(1:Ntor+1,1)); + + % Define coordinate axis position + Raxis = double(0); + Zaxis = double(0); + for i=0:Ntor + Raxis = Raxis + R0n(i+1) * cos(i * phi); + Zaxis = Zaxis + Z0n(i+1) * sin(i * phi); + end + + Pos_Axis = [Raxis Zaxis]; + + tt = length(d.poincare.R(:,1,1)); + jj=1; + X = reshape(d.poincare.R(jj,1,:),[1 ,Nppts]); + Y = reshape(d.poincare.Z(jj,1,:),[1 ,Nppts]); + Xbar = mean(X); + Ybar = mean(Y); + theta = atan2(Y-Ybar , X-Xbar); + theta = mod(theta, 2*pi); + + [theta, ind] = sort(theta); + + X = X(ind); + Y = Y(ind); + p = polyshape(X,Y); + %clc + is = isinterior(p,Pos_Axis); + + while is == 0 + jj = jj+1; + + X = reshape(d.poincare.R(jj,1,:),[1 ,Nppts]); + Y = reshape(d.poincare.Z(jj,1,:),[1 ,Nppts]); + + Xbar = mean(X); + Ybar = mean(Y); + theta = atan2(Y-Ybar , X-Xbar); + theta = mod(theta, 2*pi); + + [theta, ind] = sort(theta); + + X = X(ind); + Y = Y(ind); + p = polyshape(X,Y); + %clc + is = isinterior(p,Pos_Axis); + + end + n_surf = jj; + n = length(l) - (n_surf+shift-1); + + mat_iota = zeros(1,n); + mat_r_coord = zeros(1,n); + mat_s_coord = zeros(1,n); + derivatives = zeros(1,n); + shear = zeros(1,n); + coeff = zeros(1,n); + + out = extract_shear(d,n,shift, n_surf); + mat_iota = out.mat_iota; + mat_r_coord = out.mat_r_coord; + mat_s_coord = out.mat_s_coord; + scan_11(ii) = out.scan_11; + scan_10(ii) = out.scan_10; + derivatives = out.derivatives; + avg_shear(ii) = out.avg_shear; + catch + warning('Problem extracting shear. Assigning a value of -1 to d and all parameters to NaN'); + d = -1; + n = 1; + mat_iota = NaN(1,n); + mat_r_coord = NaN(1,n); + mat_s_coord = NaN(1,n); + scan_11(ii) = NaN; + scan_10(ii) = NaN; + derivatives = NaN(1,n); + avg_shear(ii) = NaN; + end + +end + +disp 'Done running...' +toc % set timer off +%% Plot last polyshape and coordinate axis %% + figure('color','w') + pg=plot(p); + pg.FaceColor = ([1 1 1]); + pg.EdgeColor = ([1 0 0]); + pg.LineWidth = 3; + hold on + plot(Pos_Axis(1), Pos_Axis(2), 'k+', 'linewidth' , 3, 'MarkerSize',8) + set (gca, 'fontsize', 16) + xlabel('R', 'interpreter', 'latex', 'FontSize', 24) + ylabel('Z', 'interpreter', 'latex','FontSize', 24) + +%% Shear %% + +shear_mat = reshape(avg_shear,[nn,nn])'; +r10_tilde = reshape(scan_10, [nn,nn]); +r11_tilde = reshape(scan_11, [nn,nn]); +parfor i=1:nn + r11(i) = r11_tilde(1,i); + r10(i) = r10_tilde(i,1); + + for j=1:nn + S(i,j) = shear_mat(i,j); + end +end +[R10,R11] = meshgrid(r10,r11); + + +%% PCOLOR SHEAR %% +figure +pcolor(R11,R10,S) +shading interp +hold on +contour(R11,R10,S,[0,0], 'r', 'LineWidth', 3) +set (gca, 'fontsize', fs) +colorbar +xlabel('$R_{11}$', 'interpreter', 'latex') +ylabel('$R_{10}$', 'interpreter', 'latex') + + +%% PLOT PROFIL IOTA ACROSS ZERO SHEAR LEVEL CURVE %% + +filename_1 = ['File1', num2str(index_R10_1), '_' num2str(index_R11) '.sp.h5']; +filename_2 = ['File2', num2str(index_R10_2), '_' num2str(index_R11) '.sp.h5']; + +shift = 8; % shift in extract shear function. Has to be determined from iota profile + +d_bel = read_spec(filename_1); +d_abov = read_spec(filename_2); + +coord_1 = d_bel.transform.fiota(shift:end,1); +coord_2 = d_abov.transform.fiota(shift:end,1); + +iota_1 = d_bel.transform.fiota(shift:end,2); +iota_2 = d_abov.transform.fiota(shift:end,2); + +figure +plot(coord_1,iota_1,'b+', 'linewidth', 2, 'MarkerSize', 7) +grid on +hold on +plot(coord_2,iota_2,'r+', 'linewidth', 2, 'MarkerSize', 7) +set(gca, 'fontsize', 17) +xlabel('$r$', 'Interpreter','latex', 'FontSize',30) +ylabel('$\iota$', 'Interpreter','latex', 'FontSize',30) +legend('$\iota_{a}$', '$\iota_{b}$', 'Interpreter', 'latex', 'FontSize', 27) + + +%% PCOLOR & SURF MULTIPLOT %% + +figure +subplot(1,2,1) +%---------------------------------------------------------- +pcolor(R11,R10, S) +title('Shear($R_{11},R_{10}$)', 'interpreter', 'latex') +shading interp +hold on +contour(R11,R10,S,[0,0], 'r', 'LineWidth', 3) +hold on +plot(scan11_trunc, scan10_trunc, 'w--', 'linewidth', 1); +hold on +plot(scan11_trunc2, scan10_trunc2, 'w--', 'linewidth', 1); +set (gca, 'fontsize', fs) +colorbar +xlabel('$R_{11}$', 'interpreter', 'latex') +ylabel('$R_{10}$', 'interpreter', 'latex') + +subplot(1,2,2) +%--------------------------------------------------------- +surf(R11,R10,S) +shading interp +hold on +contour(R11,R10,S,[0,0], 'r', 'LineWidth', 3) +set (gca, 'fontsize', fs) +colorbar +xlabel('$R_{11}$', 'interpreter', 'latex') +ylabel('$R_{10}$', 'interpreter', 'latex') + +clc + + +%% Extract %% +function out = extract_shear(d, n, shift, n_surf) % can be found in extract_shear.m file too + + id = n_surf+shift; + radial_coord = (d.transform.fiota(:,1)); % extract radial coordinate + out.mat_iota = d.transform.fiota(id:end,2); % extract iota + out.mat_r_coord = radial_coord(id:end); % truncates the radial coordinates (remove 5 first terms) + out.mat_s_coord = ((out.mat_r_coord + 1)./2); % change of variable r <--> s + out.scan_11 = d.output.Rbc(11,2); % Value of R11 + out.scan_10 = d.output.Rbc(2,2); % Value of R10 + + % CENTERED FINITE DIFFERENCES + out.derivatives(1) = (out.mat_iota(2) - out.mat_iota(1)) / (out.mat_s_coord(2) - out.mat_s_coord(1)); + out.derivatives(n) = (out.mat_iota(n) - out.mat_iota(n-1)) / (out.mat_s_coord(n) - out.mat_s_coord(n-1)); + + for j=2:n-1 + out.derivatives(j) = (out.mat_iota(j+1) - out.mat_iota(j-1)) / (out.mat_s_coord(j+1) - out.mat_s_coord(j-1)); + end + + out.coeff = out.mat_s_coord ./ (out.mat_iota) ; + out.shear = (out.coeff)' .* out.derivatives; + out.avg_shear = mean(out.shear); % Avg shear +end \ No newline at end of file From b20bfd0deacfcd15e4d0b27c159b00c4731348fa Mon Sep 17 00:00:00 2001 From: salomon73 Date: Mon, 10 Oct 2022 23:07:55 +0200 Subject: [PATCH 024/134] Addition of other routines after last check --- Utilities/matlabtools/get_SFL_fourier_modB.m | 82 ++++++++++++ .../matlabtools/get_boozer_coordinates.m | 43 ++++++ Utilities/matlabtools/get_boozer_modB.m | 45 +++++++ Utilities/matlabtools/get_metric_QA.m | 27 ++++ Utilities/matlabtools/get_metric_QH.m | 36 +++++ Utilities/matlabtools/plot_SFL_modB.m | 53 ++++++++ .../matlabtools/plot_SFL_modB_boundary.m | 104 +++++++++++++++ .../matlabtools/plot_boozer_fieldlines.m | 72 ++++++++++ Utilities/matlabtools/plot_boozer_modB.m | 53 ++++++++ .../matlabtools/plot_boozer_modB_boundary.m | 123 ++++++++++++++++++ Utilities/matlabtools/plot_spec_boundary.m | 97 ++++++++++++++ 11 files changed, 735 insertions(+) create mode 100644 Utilities/matlabtools/get_SFL_fourier_modB.m create mode 100644 Utilities/matlabtools/get_boozer_coordinates.m create mode 100644 Utilities/matlabtools/get_boozer_modB.m create mode 100644 Utilities/matlabtools/get_metric_QA.m create mode 100644 Utilities/matlabtools/get_metric_QH.m create mode 100644 Utilities/matlabtools/plot_SFL_modB.m create mode 100644 Utilities/matlabtools/plot_SFL_modB_boundary.m create mode 100644 Utilities/matlabtools/plot_boozer_fieldlines.m create mode 100644 Utilities/matlabtools/plot_boozer_modB.m create mode 100644 Utilities/matlabtools/plot_boozer_modB_boundary.m create mode 100644 Utilities/matlabtools/plot_spec_boundary.m diff --git a/Utilities/matlabtools/get_SFL_fourier_modB.m b/Utilities/matlabtools/get_SFL_fourier_modB.m new file mode 100644 index 00000000..462dd245 --- /dev/null +++ b/Utilities/matlabtools/get_SFL_fourier_modB.m @@ -0,0 +1,82 @@ +%% get_SFL_fourier_modB( DATA, NTHETA, NPHI, ) +% ============================================= +% +% Generates an output data struct for the fourier +% coefficients Bmn of mod(B)in SFL coordinates +% +% INPUT +% ----- +% -data : must be produced by calling read_spec(filename) +% -Ntheta : number of meshpoints for theta array +% -Nphi : number of meshpoints for phi array +% +% ------------------------------------% +% Written by S.Guinchard (05/23/22) % +% ------------------------------------% +function data_Bmn = get_SFL_fourier_modB(d, Ntheta, Nphi) + + + Nfp = d.input.physics.Nfp; + Ntor = d.input.physics.Ntor; + Mpol = d.input.physics.Mpol; + K = 2*pi^2/double(Nfp); + + lambdamn = squeeze(d.output.lambdamn); + lambdamn = lambdamn(1:end,2); + mprime = d.output.ims; + nprime = d.output.ins/double(Nfp); + + data_Bmn.Theta = linspace(0, 2*pi, Ntheta); + %data_Bmn.Phi = linspace(0, 2*pi/double(Nfp), Nphi); %change accordingly + data_Bmn.Phi = linspace(0, 2*pi, Nphi); + + + data_Bmn.modB = zeros(Ntheta, Nphi); + modB_SPEC = squeeze(get_spec_modB(d,1,1,data_Bmn.Theta,data_Bmn.Phi)); + + sumlmn = 0.0; + + for ind =2:length(lambdamn) + for line = 1:Ntheta + for column = 1:Nphi + sumlmn = sumlmn + mprime(ind)*lambdamn(ind)*cos(double(mprime(ind))*data_Bmn.Theta(line)-double(nprime(ind))*data_Bmn.Phi(column)); + end + end + end + + data_Bmn.jacobian = abs(double(1+sumlmn)); + + for m=0:Mpol + for n=-Ntor:Ntor + if m == 0 && n<0 + continue + end + for line = 1:Ntheta + for column = 1:Nphi + % evaluate modB_SPEC*cos(m theta - n phi) on the grid (theta, phi) + data_Bmn.modBcos(line,column) = modB_SPEC(line,column)* data_Bmn.jacobian ... + * cos(double(m)*data_Bmn.Theta(line) - double(Nfp)*double(n)*data_Bmn.Phi(column)); + end + end + + data_Bmn.Bmn(m+1,n+Ntor+1) = 1/K*trapz(data_Bmn.Phi,trapz(data_Bmn.Theta,data_Bmn.modBcos,1)); + end + end +% introduce missing 1/2 coefficient for mode (0,0) + data_Bmn.Bmn(1,Ntor+1) = 1/2*data_Bmn.Bmn(1,Ntor+1); + + for i=1:Ntheta + for m=0:Mpol + for n=-Ntor:Ntor + if m == 0 && n<0 + continue + end + data_Bmn.modB(i,:) = data_Bmn.modB(i,:) + data_Bmn.Bmn(m+1,n+Ntor+1)* ... + cos(double(m)*data_Bmn.Theta(i) - double(Nfp)*double(n)*data_Bmn.Phi); + end + end + end + data_Bmn.modB = data_Bmn.modB/2; + +%end of function +end \ No newline at end of file diff --git a/Utilities/matlabtools/get_boozer_coordinates.m b/Utilities/matlabtools/get_boozer_coordinates.m new file mode 100644 index 00000000..7ae57333 --- /dev/null +++ b/Utilities/matlabtools/get_boozer_coordinates.m @@ -0,0 +1,43 @@ +%% get_boozer_coordinates( BDATA, DATA, NPOINTS, NPERIODS ) +% ============================================= +% +% Computes the Boozer coordinates from a .boz.h5 file +% .boz.h5 file must be generated using run_boz.py (see corresponding repo) +% +% INPUT +% ----- +% -bdata : must be produced by calling read_boozer(filename, root) +% -data : must be produced using read_spec(filename) +% -Npoints : number of points to be used for the grid +% -Nperiods : Number of toroidal periods +% +% OUTPUT +% ------ +% -coordb : matlab struct with 2 fields - phi_boz, theta_boz +% ------------------------------------% +% Written by S.Guinchard (03/29/22) % +% ------------------------------------% + +function coordb = get_boozer_coordinates(b,d, Npoints, Nperiods) + +m = b.Booz_xForms.Outputs.xm_b; +n = b.Booz_xForms.Outputs.xn_b; + +coord = get_spec_straight_fieldlines(d,Npoints,Nperiods); +iota = b.Booz_xForms.Inputs.iota; +phi = coord.phi; +theta = coord.theta_sfl; +numns = b.Booz_xForms.Outputs.numns_b; +theta_b = theta; + +for i = 1:Npoints + for j =1:length(n) + phi(i) = phi(i) + numns(j) * sin(double(m(j))*theta(i) - double(n(j))*phi(i)); + theta_b(i) = theta_b(i) + iota * numns(j) * sin(double(m(j))*theta(i) - double(n(j))*phi(i)); + end +end + +coordb.phib = wrapTo2Pi(phi); +coordb.thetab = wrapTo2Pi(theta_b); + +end \ No newline at end of file diff --git a/Utilities/matlabtools/get_boozer_modB.m b/Utilities/matlabtools/get_boozer_modB.m new file mode 100644 index 00000000..2622e76e --- /dev/null +++ b/Utilities/matlabtools/get_boozer_modB.m @@ -0,0 +1,45 @@ +%% get_boozer_modB( BDATA, NTHETA, NPHI ) +% ============================================= +% +% Generates an output data struct for the fourier +% coefficients Bmn of mod(B) in Boozer coordinates +% +% INPUT +% ----- +% -bdata : must be produced by calling read_boozer(filename,root) +% -Ntheta : number of meshpoints for theta array +% -Nphi : number of meshpoints for phi array +% +% ------------------------------------% +% Written by S.Guinchard (05/18/22) % +% ------------------------------------% + +function modB = get_boozer_modB(b, Ntheta, Nphi) + + xm = double(b.Booz_xForms.Outputs.xm_b); + xn = double(b.Booz_xForms.Outputs.xn_b); + BmnB = b.Booz_xForms.Outputs.bmnc_b; + Nfp = double(b.Booz_xForms.Inputs.nfp); + + theta = linspace(0, 2*pi, Ntheta); + %phi = linspace(0, 2*pi/double(Nfp), Nphi); % (for 2D plot of modB boozer) + phi = linspace(0, 2*pi, Nphi); % (for 3D plot of modB boozer) + + [modB.Phi, modB.Theta] = meshgrid(phi, theta); + + + modB.modB = zeros(size(modB.Theta)); + for i =1:length(xm) + m = xm(i); + n = xn(i); + angle = (m* modB.Theta - n*modB.Phi); + modB.modB = modB.modB + BmnB(i)*cos(angle); + % case of stellarator symmetry (see init.from.spec.py) + if b.Booz_xForms.Inputs.asym == 1.0 + modB.modB = modB.modB + BmnB(i)*sin(angle); + end + end + + +end + \ No newline at end of file diff --git a/Utilities/matlabtools/get_metric_QA.m b/Utilities/matlabtools/get_metric_QA.m new file mode 100644 index 00000000..7997b880 --- /dev/null +++ b/Utilities/matlabtools/get_metric_QA.m @@ -0,0 +1,27 @@ +%% get_metric_QA(BDATA) +% ====================== +% +% Extract the QA metric from a Booz_xForms output +% +% INPUT +% ----- +% -bdata: must be produced calling read_boozer +% +% OUTPUT +% ------ +% -metric: the value of the QA_metric +% computed summing all bmnc_b^2 modes +% s.t n=!0 and normalising by mn_b*bmnc_b(0)^2 +% +% ------------------------------------% +% Written by S.Guinchard (05/12/22) % +% ------------------------------------% +function metric = get_metric_QA(b) + + bmnc_b = b.Booz_xForms.Outputs.bmnc_b; + xn_b = b.Booz_xForms.Outputs.xn_b; + ind = find(xn_b ~= 0); + metric = sum(bmnc_b(ind).^2)/(bmnc_b(1)^2); % Not divide enables convergence of metric w.r.t mpol + %metric = sum(bmnc_b(ind).^2)/(length(ind)*bmnc_b(1)^2); + +end \ No newline at end of file diff --git a/Utilities/matlabtools/get_metric_QH.m b/Utilities/matlabtools/get_metric_QH.m new file mode 100644 index 00000000..1349b5fc --- /dev/null +++ b/Utilities/matlabtools/get_metric_QH.m @@ -0,0 +1,36 @@ +%% get_metric_QH(BDATA, C) +% ====================== +% +% Extract the QH metric from a Booz_xForms output +% +% INPUT +% ----- +% -bdata: must be produced calling read_boozer +% -c : constant s.t c*m = n (Fourier modes) +% +% OUTPUT +% ------ +% -metric: the value of the QH_metric +% +% ------------------------------------% +% Written by S.Guinchard (05/12/22) % +% ------------------------------------% +function metric = get_metric_QH(b, c) + +bmnc_b = b.Booz_xForms.Outputs.bmnc_b; +xn_b = b.Booz_xForms.Outputs.xn_b; +xm_b = b.Booz_xForms.Outputs.xm_b; +nfp = double(b.Booz_xForms.Inputs.nfp); + +Mpol = b.Booz_xForms.Inputs.mpol; +Ntor = b.Booz_xForms.Inputs.ntor; +eq = find(xn_b ~= c*xm_b); % indices s.t c*m ~= n +m = find(abs(xm_b) <= Mpol ); % indices s.t abs(m) < Mpol +n = find(abs(xn_b) <= Ntor*nfp); % indices s.t abs(n) < Ntor +[val, indm, indn] = intersect(m,n); % val = indices s.t abs(m) < Mpol & abs(n) < Ntor +ind_to_sum = intersect(val,eq); % ind_to_sum = indices s.t c*m=!n and previous conditions + +metric = sum(bmnc_b(ind_to_sum).^2)/bmnc_b(1)^2; + + +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_SFL_modB.m b/Utilities/matlabtools/plot_SFL_modB.m new file mode 100644 index 00000000..207414d5 --- /dev/null +++ b/Utilities/matlabtools/plot_SFL_modB.m @@ -0,0 +1,53 @@ +%% plot_SFL_modB( DATA, NTHETA, NPHI, FILLED, NEWFIG ) +% ============================================= +% +% Plot of modB in SFL coordinates +% +% INPUT +% ----- +% -data : must be produced by calling read_spec(filename) +% -Ntheta : number of meshpoints for theta array +% -Nphi : number of meshpoints for phi array +% -filled : (=1) pcolor, (=2) contourplot +% -newfig : opens (=1) or not (=0) a newfig or overwrites (=2) +% previous figure +% +% ------------------------------------% +% Written by S.Guinchard (05/23/22) % +% ------------------------------------% +function plot_SFL_modB(b, Ntheta, Nphi, filled, Newfig) + + modB = get_SFL_fourier_modB(b,Ntheta,Nphi); + Theta = modB.Theta; + Phi = modB.Phi; + modB = modB.modB; + + switch Newfig + + case 0 + hold on + + case 1 + figure + + case 2 + hold off + + end + + switch filled + + case 1 + pcolor(Phi, Theta, modB); + shading interp + colorbar + hold on + contour(Phi, Theta, modB, 6, 'k', 'linewidth', 1) + + case 2 + %contourf(Theta, Phi, modB,linspace(min(min(modB)), max(max(modB)),20)); + contour(Phi, Theta, modB,linspace(min(min(modB)), max(max(modB)),20), 'linewidth', 1.5) + colorbar + colormap(jet) + end +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_SFL_modB_boundary.m b/Utilities/matlabtools/plot_SFL_modB_boundary.m new file mode 100644 index 00000000..b6b812b6 --- /dev/null +++ b/Utilities/matlabtools/plot_SFL_modB_boundary.m @@ -0,0 +1,104 @@ +function plot_SFL_modB_boundary(data,interface,innout,nt,nz,dimension) + +% +% PLOT_SPEC_MODB_BOUNDARY( BDATA, DATA, VOL, NT, NZ ) +% ============================================ +% +% Produces plot of |B|_b on the full boundary surface in toroidal geometry. +% +% INPUT +% ----- +% -bdata : data obtained via read_boozer(filename, root) +% -data : data obtained via read_spec(filename) +% -interface : Volume on which modB should be plotted +% -innout: (0) - inner side of interface +% (1) - outer side of interface +% -nt : poloidal resolution for the plotting (e.g. nt=64) +% -nz : toroidal resolution for the plotting (e.g. nz=64) +% -dimension: (2) - plot a colorplot on a theta-phi grid +% (3) - plot a colorplot on a 3d surface +% +% ------------------------------------% +% Written by S.Guinchard (05/30/22) % +% ------------------------------------% +% +% TODO: adapt for more than 1 volume +% when booz_xform has been adapted +innout =0; +interface = 1; +Mvol = data.output.Mvol; + +if interface<1 || interface>Mvol + error('Invalid interface') +end + +switch innout + case 0 + vol = interface; + sarr = 1; + case 1 + if interface==Mvol + error('Cannot plot on the outer side of last interface!') + end + vol = interface+1; + sarr = -1; + otherwise + error('Interface should be 0 or 1') +end + +tarr = linspace(0,2*pi,nt); +zarr = linspace(0,2*pi,nz); + +if(vol>Mvol || vol<1) + error('vol not valid') +end + + +switch dimension + case 2 + + plot_SFL_modB(data,nt,nz,1,1) + xlabel('$\phi_b$', 'Interpreter', 'latex') + ylabel('$\theta_b$', 'Interpreter', 'latex') + set(gca,'FontSize',20) + set(gcf,'Position',[200 200 900 700]) + + + case 3 + + % Compute |B| + modB = get_SFL_fourier_modB(data,nt,nz); + + % Compute function (R,Z)(s,theta,zeta) + sarr = 1; + rzdata = get_spec_rzarr(data,vol,sarr,tarr,zarr); + + R = squeeze(rzdata{1}); + Z = squeeze(rzdata{2}); + + + % Construct cartesian corrdinates + + X = zeros(nt,nz); + Y = zeros(nt,nz); + + for it=1:nt + for iz=1:nz + X(it,iz) = R(it,iz)*cos(zarr(iz)); + Y(it,iz) = R(it,iz)*sin(zarr(iz)); + end + end + + + % Plot + + figure + h=surf(X,Y,Z,squeeze(modB.modB)); + axis equal + shading interp + colorbar + title('$| B_b |$', 'interpreter', 'latex') + + otherwise + error('Invalid dimension') +end diff --git a/Utilities/matlabtools/plot_boozer_fieldlines.m b/Utilities/matlabtools/plot_boozer_fieldlines.m new file mode 100644 index 00000000..53a89108 --- /dev/null +++ b/Utilities/matlabtools/plot_boozer_fieldlines.m @@ -0,0 +1,72 @@ +%% plot_boozer_fieldlines( COORDB, NEWFIG ) +% ============================================= +% +% Plots a magnetic fieldline in Boozer coordinates +% starting from the point (thetab, phib) = (0,0) +% +% INPUT +% ----- +% +% -coordb : must be produced using get_boozer_coordinates +% -Newfig : opens (=1) or not (=0) a new figure, or overwrites (=2) +% last plot +% +% ------------------------------------% +% Written by S.Guinchard (05/15/22) % +% ------------------------------------% + +function plot_boozer_fieldlines(coordb, Newfig) + + phiB = coordb.phib; + thetaB = coordb.thetab; + Fs = 18; + switch Newfig + + case 0 + hold on + scatter(phiB, thetaB, 'k.') + ax = gca; + ax.TickLabelInterpreter = 'latex'; + xticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + xticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + yticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + yticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + xlim([0 2*pi]) + ylim([0 2*pi]) + set (gca, 'fontsize', Fs) + xlabel('$\phi_B$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + ylabel('$\theta_B$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + + case 1 + figure + scatter(phiB, thetaB, 'k.') + ax = gca; + ax.TickLabelInterpreter = 'latex'; + xticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + xticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + yticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + yticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + xlim([0 2*pi]) + ylim([0 2*pi]) + set (gca, 'fontsize', Fs) + xlabel('$\phi_B$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + ylabel('$\theta_B$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + + case 2 + hold off + scatter(phiB, thetaB, 'k.') + ax = gca; + ax.TickLabelInterpreter = 'latex'; + xticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + xticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + yticks([0 pi/3 2*pi/3 pi 4*pi/3 5*pi/3 2*pi]) + yticklabels({'$0$','$\frac{\pi}{3}$','$\frac{2\pi}{3}$','$\pi$', '$\frac{4\pi}{3}$','$\frac{5\pi}{3}$','$2\pi$'}); + xlim([0 2*pi]) + ylim([0 2*pi]) + set (gca, 'fontsize', Fs) + xlabel('$\phi_B$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + ylabel('$\theta_B$', 'FontSize', Fs+10 , 'Interpreter', 'latex') + + end + +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_boozer_modB.m b/Utilities/matlabtools/plot_boozer_modB.m new file mode 100644 index 00000000..6ffeb0cc --- /dev/null +++ b/Utilities/matlabtools/plot_boozer_modB.m @@ -0,0 +1,53 @@ +%% plot_boozer_modB( BDATA, NTHETA, NPHI, FILLED, NEWFIG ) +% ============================================= +% +% Plot of modB in Boozer coordinates +% +% INPUT +% ----- +% -bdata : must be produced by calling read_boozer(filename,root) +% -Ntheta : number of meshpoints for theta array +% -Nphi : number of meshpoints for phi array +% -filled : (=1) pcolor, (=2) contourplot +% -newfig : opens (=1) or not (=0) a newfig or overwrites (=2) +% previous figure +% +% ------------------------------------% +% Written by S.Guinchard (05/18/22) % +% ------------------------------------% +function plot_boozer_modB(b, Ntheta, Nphi, filled, Newfig) + + modB = get_boozer_modB(b,Ntheta,Nphi); + Theta = modB.Theta; + Phi = modB.Phi; + modB = modB.modB; + + switch Newfig + + case 0 + hold on + + case 1 + figure + + case 2 + hold off + + end + + switch filled + + case 1 + pcolor(Phi, Theta, modB); + shading interp + colorbar + hold on + contour(Phi, Theta, modB, 6, 'k', 'linewidth', 1) + + case 2 + + contour(Phi, Theta, modB,linspace(min(min(modB)), max(max(modB)),20), 'linewidth', 1.5) + colorbar + colormap(jet) + end +end \ No newline at end of file diff --git a/Utilities/matlabtools/plot_boozer_modB_boundary.m b/Utilities/matlabtools/plot_boozer_modB_boundary.m new file mode 100644 index 00000000..8701c155 --- /dev/null +++ b/Utilities/matlabtools/plot_boozer_modB_boundary.m @@ -0,0 +1,123 @@ +function plot_boozer_modB_boundary(b,data,interface,innout,nt,nz,dimension, newfig) + +% PLOT_BOOZER_MODB_BOUNDARY( BDATA, DATA, INTERFACE, INNOUT, NT, NZ, DIM, NEWFIG ) +% ============================================ +% +% Produces plot of |B|_b on the full boundary surface in toroidal geometry. +% +% INPUT +% ----- +% -bdata : data obtained via read_boozer(filename, root) +% -data : data obtained via read_spec(filename) +% -interface : Volume on which modB should be plotted +% -innout: (0) - inner side of interface +% (1) - outer side of interface +% -nt : poloidal resolution for the plotting (e.g. nt=64) +% -nz : toroidal resolution for the plotting (e.g. nz=64) +% -dimension: (2) - plot a colorplot on a theta-phi grid +% (3) - plot a colorplot on a 3d surface +% -newfig: opens (=1) or not (=0) a new figure or ovewrites (=2) previous +% plot +% +% ------------------------------------% +% Written by S.Guinchard (05/30/22) % +% ------------------------------------% +% +% TODO: adapt for more than 1 volume +% when booz_xform has been adapted + +innout = 0; % will be changed when adapted +interface = 1; +Mvol = (b.Booz_xForms.Inputs.ns_in+1)/2; + +if interface<1 || interface>Mvol + error('Invalid interface') +end + +switch innout + case 0 + vol = interface; + sarr = 1; + case 1 + if interface==Mvol + error('Cannot plot on the outer side of last interface!') + end + vol = interface+1; + sarr = -1; + otherwise + error('Interface should be 0 or 1') +end + +tarr = linspace(0,2*pi,nt); +zarr = linspace(0,2*pi,nz); + +if(vol>Mvol || vol<1) + error('vol not valid') +end + + +switch dimension + case 2 + + switch newfig + case 0 + hold on + case 1 + figure + case 2 + hold off + end + plot_boozer_modB(b,nt,nz,1,0) + xlabel('$\phi_b$', 'Interpreter', 'latex') + ylabel('$\theta_b$', 'Interpreter', 'latex') + set(gca,'FontSize',20) + set(gcf,'Position',[200 200 900 700]) + + + case 3 + + switch newfig + case 0 + hold on + case 1 + figure + case 2 + hold off + end + % Compute |B| + + modB = get_boozer_modB(b,nt,nz); + % Compute function (R,Z)(s,theta,zeta) + sarr = 1; + rzdata = get_spec_rzarr(data,vol,sarr,tarr,zarr); + + R = squeeze(rzdata{1}); + Z = squeeze(rzdata{2}); + + + % Construct cartesian coordinates + + X = zeros(nt,nz); + + Y = zeros(nt,nz); + + for it=1:nt + for iz=1:nz + X(it,iz) = R(it,iz)*cos(zarr(iz)); + Y(it,iz) = R(it,iz)*sin(zarr(iz)); + end + end + + + % Plot + + h=surf(X,Y,Z,squeeze(modB.modB)); + + axis equal + shading interp + colorbar + title('$| B_b |$', 'interpreter', 'latex') + + otherwise + error('Invalid dimension') +end diff --git a/Utilities/matlabtools/plot_spec_boundary.m b/Utilities/matlabtools/plot_spec_boundary.m new file mode 100644 index 00000000..b3cd6937 --- /dev/null +++ b/Utilities/matlabtools/plot_spec_boundary.m @@ -0,0 +1,97 @@ +%% plot_spec_boundary( DATA, NPOINTS, NEWFIG ) +% ======================================================= +% +% Traces the plasma boundary in the (R,Z) plane +% with the specified number of points +% +% INPUT +% ----- +% -data : must be produced by calling read_spec(filename) +% -Npoints : number of points for theta +% -phi0 : toroidal angle at which the boundary is plotted +% -Newfig : opens (=1) or not (=0) a new figure, or overwrites (=2) +% last plot +% +% ------------------------------------% +% Written by S.Guinchard (05/17/22) % +% ------------------------------------% + +function plot_spec_boundary(d, Npoints, phi0, Newfig) + + Rbc = d.output.Rbc(:,2); + Zbs = d.output.Zbs(:,2); + + N = 10000; + theta = linspace(0,2*pi, N); + phi = linspace(0,2*pi, N); + + m = double(d.output.im); + n = double(d.output.in/d.input.physics.Nfp); + R = zeros(size(theta)); + Z = zeros(size(phi)); + + R_ = zeros(1,Npoints); + Z_ = R_; + + for i=1:length(m) + for j =1:length(theta) + R(j) = R(j) + Rbc(i)*cos(m(i)*theta(j) - n(i)*phi0); + Z(j) = Z(j) + Zbs(i)*sin(m(i)*theta(j) - n(i)*phi0); + end + end + + + for ii = 1:Npoints + R_(ii) = R((ii-1)*floor(N/Npoints)+1); + Z_(ii) = Z((ii-1)*floor(N/Npoints)+1); + end + + p = polyshape(R,Z); + + switch Newfig + case 0 + hold on + pg=plot(p); + pg.FaceColor = ([1 1 1]); + pg.EdgeColor = ([1 0 0]); + pg.LineWidth = 3; + hold on + scatter(R_,Z_, 'filled', 'ko') + xlabel('R') + ylabel('Z') + legend(strcat('$\phi_0$ = ', num2str(phi0)), 'Location','best','Interpreter','latex'); + set(legend,'FontSize',18); + set (gca, 'fontsize', 20) + + case 1 + figure + pg=plot(p); + pg.FaceColor = ([1 1 1]); + pg.EdgeColor = ([1 0 0]); + pg.LineWidth = 3; + hold on + scatter(R_,Z_, 'filled', 'ko') + xlabel('R', 'Interpreter', 'Latex') + ylabel('Z', 'Interpreter', 'Latex') + legend(strcat('$\phi_0$ = ', num2str(phi0)), 'Location','best','Interpreter','latex'); + set(legend,'FontSize',18); + set (gca, 'fontsize', 20) + + case 2 + hold off + pg=plot(p); + pg.FaceColor = ([1 1 1]); + pg.EdgeColor = ([1 0 0]); + pg.LineWidth = 3; + hold on + scatter(R_,Z_, 'filled', 'ko') + xlabel('R') + ylabel('Z') + legend(strcat('$\phi_0$ = ', num2str(phi0)), 'Location','best','Interpreter','latex'); + set(legend,'FontSize',18); + set (gca, 'fontsize', 20) + + end + + +end From f9550eefbc6e1ecccc7d96c61aee4ffc08c32ac7 Mon Sep 17 00:00:00 2001 From: salomon73 Date: Mon, 10 Oct 2022 23:13:30 +0200 Subject: [PATCH 025/134] gitignore add .DS_Store --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index c0c569eb..564e14d3 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,7 @@ _skbuild/ # Temp fortran files src/mxspech.f90 src/msphdf5.f90 + +# Apple Mac related +.DS_Store + From ccb2db82ebf25c1752ab2932065afe67cb833c35 Mon Sep 17 00:00:00 2001 From: salomon73 Date: Tue, 11 Oct 2022 11:32:44 +0200 Subject: [PATCH 026/134] Booz-xForm routines --- Utilities/BoozerXForms/README.md | 3 + Utilities/BoozerXForms/Tutorial1.txt | 30 +++ Utilities/BoozerXForms/init_from_spec.py | 269 +++++++++++++++++++++++ Utilities/BoozerXForms/run_boz.py | 121 ++++++++++ Utilities/BoozerXForms/testBmn.py | 100 +++++++++ 5 files changed, 523 insertions(+) create mode 100644 Utilities/BoozerXForms/README.md create mode 100644 Utilities/BoozerXForms/Tutorial1.txt create mode 100644 Utilities/BoozerXForms/init_from_spec.py create mode 100644 Utilities/BoozerXForms/run_boz.py create mode 100644 Utilities/BoozerXForms/testBmn.py diff --git a/Utilities/BoozerXForms/README.md b/Utilities/BoozerXForms/README.md new file mode 100644 index 00000000..8198cb7d --- /dev/null +++ b/Utilities/BoozerXForms/README.md @@ -0,0 +1,3 @@ +# BoozerXForms +Python routines to achieve Boozer coordinates transformation from SPEC output +Useful e.g to plot modB diff --git a/Utilities/BoozerXForms/Tutorial1.txt b/Utilities/BoozerXForms/Tutorial1.txt new file mode 100644 index 00000000..b3b54a26 --- /dev/null +++ b/Utilities/BoozerXForms/Tutorial1.txt @@ -0,0 +1,30 @@ +This is a basic tutorial on how to use the Booz-xform package (M.Landreman) from SPECout file, using routines init_from_spec.py and run_boz.py + +0. Make sure you have the booz-xforms package installed. If not, can be installed with + $ pip install booz-xform (or see doc at https://hiddensymmetries.github.io/booz_xform/) + +0b. Requires additional packages: py_spec, numpy and h5py + +1. Load function to initialise a booz-xforms instance out of a SPEC output (.h5) with + > from init_from_spec import init_from_spec + +2. Call init_from_spec function with test file QA_002.sp.h5 + > b = init_from_spec('QA_002.sp.h5') + +3. Call internal run method as follows + > b.run() + +4. The output data sets can be written in .h5 file running all the commands from run_boz.py + > f = h5.File('./OutputBOZ/'+ bozout, 'w') + > print(f.filename) + > grp = f.create_group('Booz_xForms') + > ... + > ... + > outputs.create_dataset('boozer_i_all', data = b.Boozer_I_all) + > f.close() + +5. Plot the magnetic field intensity in Boozer coordinates + > plt.figure + > bx.surfplot(b, js=0, fill=False, cmap=plt.cm.jet, ntheta=50, nphi=90, ncontours=25) + > plt.savefig('QA002.eps') + > plt.show() diff --git a/Utilities/BoozerXForms/init_from_spec.py b/Utilities/BoozerXForms/init_from_spec.py new file mode 100644 index 00000000..7d356572 --- /dev/null +++ b/Utilities/BoozerXForms/init_from_spec.py @@ -0,0 +1,269 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Mon May 9 17:51:56 2022 +This file initialises a booz x form instance +without changing the SPEC output file +@authors: A.Baillod, S.Guinchard +""" + +import py_spec as sp +import booz_xform as bx +import numpy as np + +###################################################### +############### EXTRACT ALL SPECOUT DATA ############# +###################################################### + + +def init_from_spec( filename ): + d = sp.SPECout( filename ) + + compute_surfs = np.array([0]) + verbose = 1 + asym = False #False if stellarator symmetric + nfp = d.input.physics.Nfp + mpol = d.input.physics.Mpol+1 + ntor = d.input.physics.Ntor + nvol = d.input.physics.Nvol + mpol_nyq = mpol + ntor_nyq = ntor + mnmax = ntor +1 + (mpol-1) *(2*ntor +1) + mnmax_nyq = ntor_nyq+1 + (mpol_nyq-1)*(2*ntor_nyq+1) + xm = d.output.im + xn = d.output.in_ + xm_nyq = xm + xn_nyq = xn + ns_in = int(2*nvol-1) + s_in = np.ndarray(ns_in, dtype = np.float64) + s_in[0] = d.output.tflux; + iota = np.array([d.output.lambdamn[1][0][0]]) + rmnc = np.array([list(d.output.Rbc[1,:])]).transpose() + rmns = np.array([]) + zmnc = np.array([]) + zmns = np.array([list(d.output.Zbs[1,:])]).transpose() + + # build lmns + lambdamn = d.output.lambdamn[1][:].transpose() + xms = d.output.ims + xns = d.output.ins + mns = d.output.mns + lmns = np.zeros([mnmax,ns_in]) + lmnc = np.array([]) + + for ii in range (0,mns): + mm = xms[ii] + nn = xns[ii] + + if mm==0 and nn==0: #mode (0,0) is zero + continue + if mm>mpol-1 or mm<0: + continue + if nn<-ntor*nfp or nn>ntor*nfp: + continue + + for jj in range(0,mnmax): + if mm==xm[jj] and nn==xn[jj]: + lmns[jj] = lambdamn[ii] + continue + + + bsubumnc = np.array([list(d.output.Btemn[1,:])]).transpose() + bsubvmnc = np.array([list(d.output.Bzemn[1,:])]).transpose() + bsubumns = np.array([]) + bsubvmns = np.array([]) + mboz = np.max(xm) + nboz = int(1/nfp * np.max(xn)) + aspect = np.nan + toroidal_flux = d.input.physics.phiedge + + # modB computation + Nt = d.grid.Nt + Nz = d.grid.Nz + sarr = np.linspace(0,1,2) + tarr = np.linspace(0,2*np.pi,Nt) + zarr = np.linspace(0,2*np.pi/nfp,Nz) + + Bcontrav = d.get_B(lvol = 0, sarr = sarr, tarr = tarr, zarr = zarr) + [R, Z, jac, g] = d.get_grid_and_jacobian_and_metric(lvol = 0, sarr = sarr, tarr= tarr, zarr = zarr) + + modB = d.get_modB(Bcontrav, g) + modBsurf = modB[1][:][:] + modBcos = np.zeros(np.shape(modBsurf)) + K = 2*np.pi**2/nfp + Bmn_ = np.zeros((mpol,2*ntor+1)) + + for m in range (0,mpol): + for n in range (-ntor,ntor+1): + if m == 0 and n<0: + continue + for line in range (0,Nt): + for column in range (0,Nz): + modBcos[line,column] = modBsurf[line][column]* np.cos(np.double(m)*tarr[line] - np.double(n)*np.double(nfp)*zarr[column]) + + tmp = np.trapz(modBcos, x = tarr, axis = 0) + Bmn_[m,n+ntor] = 1/K*np.trapz(tmp, x=zarr) + + + Bmn_[0,ntor] = 1/2*Bmn_[0,ntor] + + + Bmnc = np.zeros((mnmax,ns_in)) + jj = 0 #index of surface + for ii in range(0,mnmax): + m = xm[ii] + n = int(xn[ii] / nfp) + Bmnc[ii,jj] = Bmn_[m,n+ntor] + + Bmns = np.array([]) + + + ########################################################## + # initialisation de l'instance b de la classe booz_xform # + ########################################################## + + b = bx.Booz_xform() + + if ns_in<1: + raise ValueError('ns has to be larger than zero') + + if nfp<1: + raise ValueError('Nfp has to be larger than zero') + + if iota.size!=ns_in: + raise ValueError('Iota has not the size ns_in') + + if xm.size!=mnmax: + raise ValueError('xm has not the size mnmax') + if xn.size!=mnmax: + raise ValueError('xn has not the size mnmax') + if xm_nyq.size!=mnmax_nyq: + raise ValueError('xm_nyq has not the size mnmax') + if xn_nyq.size!=mnmax_nyq: + raise ValueError('xn_nyq has not the size mnmax') + + if xm[0]!=0: + raise ValueError('xm first element is not right') + if xn[0]!=0: + raise ValueError('xn first element is not right') + if xm_nyq[0]!=0: + raise ValueError('xm_nyq first element is not right') + if xn_nyq[0]!=0: + raise ValueError('xn_nyq first element is not right') + + if xm[-1]!=mpol-1: + raise ValueError('xm last element is not right') + if xn[-1]!=nfp*ntor: + raise ValueError('xn last element is not right') + if xm_nyq[-1]!=mpol_nyq-1: + raise ValueError('xm_nyq last element is not right') + if xn_nyq[-1]!=nfp*ntor_nyq: + raise ValueError('xn_nyq last element is not right') + + if rmnc.shape[0]!=mnmax: + raise ValueError('Rmnc should have mnmax rows') + if zmns.shape[0]!=mnmax: + raise ValueError('Zmns should have mnmax rows') + if asym: + if rmns.shape[0]!=mnmax: + raise ValueError('Rmns should have mnmax rows') + if zmnc.shape[0]!=mnmax: + raise ValueError('Zmnc should have mnmax rows') + + if rmnc.shape[1]!=ns_in: + raise ValueError('Rmnc should have ns_in columns') + if zmns.shape[1]!=ns_in: + raise ValueError('Zmns should have ns_in columns') + if asym: + if rmns.shape[1]!=ns_in: + raise ValueError('Rmns should have ns_in columns') + if zmnc.shape[1]!=ns_in: + raise ValueError('Zmnc should have ns_in columns') + + if bsubumnc.shape[0]!=mnmax: + raise ValueError('Rmnc should have mnmax rows') + if bsubvmnc.shape[0]!=mnmax: + raise ValueError('Rmns should have mnmax rows') + if asym: + if bsubumns.shape[0]!=mnmax: + raise ValueError('Zmnc should have mnmax rows') + if bsubvmns.shape[0]!=mnmax: + raise ValueError('Zmns should have mnmax rows') + + if bsubumnc.shape[1]!=ns_in: + raise ValueError('Rmnc should have ns_in columns') + if bsubvmnc.shape[1]!=ns_in: + raise ValueError('Rmns should have ns_in columns') + if asym: + if bsubumns.shape[1]!=ns_in: + raise ValueError('Zmnc should have ns_in columns') + if bsubvmns.shape[1]!=ns_in: + raise ValueError('Zmns should have ns_in columns') + + if Bmnc.shape[0]!=mnmax: + raise ValueError('Invalid number of modes for Bmnc') + if Bmnc.shape[1]!=ns_in: + raise ValueError('Invalid number of surfaces for Bmnc') + if asym: + if Bmns.shape[0]!=mnmax: + raise ValueError('Invalid number of modes for Bmns') + if Bmns.shape[1]!=ns_in: + raise ValueError('Invalid number of surfaces for Bmns') + + if lmns.shape[0]!=mnmax: + raise ValueError('Invalid number of modes for lmns') + if lmns.shape[1]!=ns_in: + raise ValueError('Invalid number of surfaces for lmns') + if asym: + if lmnc.shape[0]!=mnmax: + raise ValueError('Invalid number of modes for lmnc') + if lmnc.shape[1]!=ns_in: + raise ValueError('Invalid number of surfaces for lmnc') + + if any(compute_surfs<0): + raise ValueError('Compute_surfs should be zero or positive') + if any(compute_surfs>=ns_in): + raise ValueError('Compute_surfs should be smaller than ns_in') + + + + + + + b.verbose = verbose + b.asym = 0.0; + b.nfp = nfp + b.mpol = mpol + b.ntor = ntor + b.mnmax = mnmax + b.mpol_nyq = mpol_nyq + b.ntor_nyq = ntor_nyq + b.mnmax_nyq = mnmax_nyq + b.xn = xn + b.xm=xm + b.xm_nyq = xm_nyq + b.xn_nyq = xn_nyq + b.ns_in = ns_in + b.s_in = s_in + b.iota = iota + b.rmnc = rmnc + b.rmns = rmns + b.zmnc = zmnc + b.zmns = zmns + b.lmns = lmns + b.lmnc = lmnc + b.bmnc = Bmnc + b.bmns = Bmns + b.bsubumnc = bsubumnc + b.bsubvmnc = bsubvmnc + b.bsubumns = bsubumns + b.bsubvmns = bsubvmns + b.mboz = mboz + b.nboz = nboz + b.compute_surfs = compute_surfs + b.aspect = aspect + b.toroidal_flux = toroidal_flux + + + + return b diff --git a/Utilities/BoozerXForms/run_boz.py b/Utilities/BoozerXForms/run_boz.py new file mode 100644 index 00000000..20671fcc --- /dev/null +++ b/Utilities/BoozerXForms/run_boz.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Mon May 9 17:50:56 2022 + +This file initialises a booz_xForms instance +and runs it before writing all outputs to +an hdf5 file. + +@author: S.Guinchard +""" + +############ +# PACKAGES # +############ + +from init_from_spec import init_from_spec +import matplotlib.pyplot as plt +import booz_xform as bx +import numpy as np +import h5py as h5 + +############## +# INIT + RUN # +############## + +file = 'Name' +filename = file + '.sp.h5' +bozout = file +'.boz.h5' +b = init_from_spec('path_to_file'+filename) +b.verbose = 2 +print("Selected surfaces:", b.compute_surfs) +b.run() + +########################## +# CREATE OUTPUT DATASETS # +########################## + +f = h5.File('path_to_Boozer_out_file'+ bozout, 'w') +print(f.filename) +grp = f.create_group('Booz_xForms') +grp.create_group('Inputs') +inputs = grp['Inputs'] +inputs['verbose'] = b.verbose +inputs['asym'] = b.asym +inputs['nfp'] = b.nfp +inputs['ntor'] = b.ntor +inputs['mpol'] = b.mpol +inputs['mnmax'] = b.mnmax +inputs['mnmax_nyq'] = b.mnmax_nyq +inputs['mpol_nyq'] = b.mpol_nyq +inputs['ntor_nyq'] = b.ntor_nyq +inputs['xn'] = b.xn +inputs['xm'] = b.xm +inputs['xn_nyq'] = b.xn_nyq +inputs['xm_nyq'] = b.xm_nyq +inputs['ns_in'] = b.ns_in +inputs['iota'] = b.iota +inputs['rmnc'] = b.rmnc +inputs['rmns'] = b.rmns +inputs['zmnc'] = b.zmnc +inputs['zmns'] = b.zmns +inputs['bmn'] = b.bmnc +inputs['bsubumnc'] = b.bsubumnc +inputs['bsubvmnc'] = b.bsubvmnc +inputs['compute_surfs'] = b.compute_surfs +inputs['aspect'] = b.aspect +inputs['toroidal_flux'] = b.toroidal_flux +inputs['mboz'] = b.mboz +inputs['nboz'] = b.nboz +inputs['lmns'] = b.lmns +inputs['lmnc'] = b.lmnc + +grp.create_group('Outputs') +outputs = grp['Outputs'] +outputs.create_dataset('ns_b', data = b.ns_b) +outputs.create_dataset('s_b', data = b.s_b) +outputs.create_dataset('mnboz', data = b.mnboz) +outputs.create_dataset('xm_b', data = b.xm_b) +outputs.create_dataset('xn_b', data = b.xn_b) +outputs.create_dataset('bmnc_b', data = b.bmnc_b) +outputs.create_dataset('bmns_b', data = b.bmns_b) +outputs.create_dataset('gmnc_b', data = b.gmnc_b) +outputs.create_dataset('gmns_b', data = b.gmns_b) +outputs.create_dataset('rmnc_b', data = b.rmnc_b) +outputs.create_dataset('zmnc_b', data = b.zmnc_b) +outputs.create_dataset('rmns_b', data = b.rmns_b) +outputs.create_dataset('zmns_b', data = b.zmns_b) +outputs.create_dataset('numnc_b', data = b.numnc_b) +outputs.create_dataset('numns_b', data = b.numns_b) +outputs.create_dataset('boozer_g', data = b.Boozer_G) +outputs.create_dataset('boozer_g_all', data = b.Boozer_G_all) +outputs.create_dataset('boozer_i', data = b.Boozer_I) +outputs.create_dataset('boozer_i_all', data = b.Boozer_I_all) + + +f.close() + + + +########### +# FIGURES # +########### + +plt.figure +bx.surfplot(b, js=0, fill=False, cmap=plt.cm.jet, ntheta=50, nphi=90, ncontours=25) +plt.savefig('Contour.eps') +plt.show() + + +plt.figure +bx.surfplot(b, js=0, cmap=plt.cm.jet, shading = 'gouraud') +plt.savefig('Filled.eps') +plt.show() + +# ANOTHER EXAMPLE +# plt.figure +# bx.surfplot(b, js=0, fill=False, cmap=plt.cm.jet, levels=np.arange(0.8, 1.3, 0.05)) +# plt.show() + + diff --git a/Utilities/BoozerXForms/testBmn.py b/Utilities/BoozerXForms/testBmn.py new file mode 100644 index 00000000..9272ce94 --- /dev/null +++ b/Utilities/BoozerXForms/testBmn.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Mon May 9 13:32:45 2022 + +This file enables to test if the modB +Fourier modes were correctly implemented +in Python, in order to pass them as a +Booz_X_Form input + +@author: S.Guinchard +""" +import py_spec as sp +import booz_xform as bx +import numpy as np +import matplotlib.pyplot as plt +import h5py as h5 + + +d = sp.SPECout('Filename.sp.h5') + +verbose = 1 +asym = False +nfp = d.input.physics.Nfp +mpol = d.input.physics.Mpol +ntor = d.input.physics.Ntor +nvol = d.input.physics.Nvol +mnmax = d.output.mn +mpol_nyq = mpol +ntor_nyq = ntor +mnmax_nyq = mnmax +xm = d.output.im +xn = d.output.in_ +xm_nyq = xm +xn_nyq = xn +ns_in = int(2*nvol-1) +s_in = np.ndarray(ns_in, dtype = np.float64) +s_in[0] = d.output.tflux; +iota = d.transform.fiota[1][:] +rmnc = d.output.Rbc +rmns = d.output.Rbs +zmnc = d.output.Zbc +zmns = d.output.Zbs +lmns = d.output.lambdamn[1][:] + +bsubumnc = d.output.Btemn +bsubvmnc = d.output.Bzemn +mboz = np.max(xm) +nboz = int(1/nfp * np.max(xn)) +aspect = np.nan +toroidal_flux = d.input.physics.phiedge + +######## MOD B ######## + +Nt = d.grid.Nt +Nz = d.grid.Nz +sarr = np.linspace(0,1,2) +tarr = np.linspace(0,2*np.pi,Nt) +zarr = np.linspace(0,2*np.pi/nfp,Nz) + +Bcontrav = d.get_B(lvol = 0, sarr = sarr, tarr = tarr, zarr = zarr) +[R, Z, jac, g] = d.get_grid_and_jacobian_and_metric(lvol = 0, sarr = sarr, tarr= tarr, zarr = zarr) +modB = d.get_modB(Bcontrav, g) +modBsurf = modB[1][:][:] +modBcos = np.zeros(np.shape(modBsurf)) +K = 2*np.pi**2/nfp +Bmn_ = np.zeros((mpol+1,2*ntor+1)) +X,Y = np.meshgrid(tarr, zarr) + + + +for m in range (0,mpol): + for n in range (-ntor,ntor): + if m == 0 and n<0: + continue + + modBcos = modBsurf * np.cos(np.double(m)*X - np.double(n)*np.double(nfp)*Y) + tmp = np.trapz(modBcos, x=tarr, axis = 0) + Bmn_[m,n+ntor] = 1/K*np.trapz(tmp, x=zarr) + +Bmn_[0,ntor] = 1/2*Bmn_[0,ntor] + + +Bmn = np.zeros((mnmax_nyq,)) +Bmn_trunc = np.zeros((mpol,2*ntor+1)) + +for jj in range(0,mpol): + Bmn_trunc[jj][:] = Bmn_[jj+1][:] +Bmn_trunc = np.reshape(Bmn_trunc, np.size(Bmn_trunc)) + +for ii in range(-ntor,0): + Bmn[ii+ntor] = Bmn_[0][ii+2*ntor] + + +for ll in range(0,np.size(Bmn_trunc)): + Bmn[ll+ntor+1] = Bmn_trunc[ll] + + +print('Bmn_ = ', Bmn_) + From 073d6cdf1e4e4387a3f54c2ae7b82b1b2cc4baa3 Mon Sep 17 00:00:00 2001 From: salomon73 Date: Tue, 11 Oct 2022 11:36:25 +0200 Subject: [PATCH 027/134] Update readme and tutorial --- Utilities/BoozerXForms/README.md | 3 +++ Utilities/BoozerXForms/Tutorial1.txt | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Utilities/BoozerXForms/README.md b/Utilities/BoozerXForms/README.md index 8198cb7d..234c0592 100644 --- a/Utilities/BoozerXForms/README.md +++ b/Utilities/BoozerXForms/README.md @@ -1,3 +1,6 @@ # BoozerXForms Python routines to achieve Boozer coordinates transformation from SPEC output Useful e.g to plot modB + +For any questions or mistake spotted, contact me at +salomon.guinchard@epfl.ch diff --git a/Utilities/BoozerXForms/Tutorial1.txt b/Utilities/BoozerXForms/Tutorial1.txt index b3b54a26..926325cc 100644 --- a/Utilities/BoozerXForms/Tutorial1.txt +++ b/Utilities/BoozerXForms/Tutorial1.txt @@ -27,4 +27,7 @@ This is a basic tutorial on how to use the Booz-xform package (M.Landreman) from > plt.figure > bx.surfplot(b, js=0, fill=False, cmap=plt.cm.jet, ntheta=50, nphi=90, ncontours=25) > plt.savefig('QA002.eps') - > plt.show() + > plt.show() + +6. If major issue can't be solved / code mistake + contact: S.Guinchard - salomon.guinchard@epfl.ch From a592e428ad55c0707fd71d22def2cd86ddbe3b07 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 8 Nov 2022 09:39:02 +0100 Subject: [PATCH 028/134] fix diagnostic logic; new features in py_spec --- .../py_spec/input/spec_namelist.py | 58 +++++ .../pythontools/py_spec/output/_processing.py | 223 ++++++++++++++++++ Utilities/pythontools/py_spec/output/spec.py | 11 +- src/xspech.f90 | 2 +- 4 files changed, 289 insertions(+), 5 deletions(-) diff --git a/Utilities/pythontools/py_spec/input/spec_namelist.py b/Utilities/pythontools/py_spec/input/spec_namelist.py index 9b843796..ec995aab 100644 --- a/Utilities/pythontools/py_spec/input/spec_namelist.py +++ b/Utilities/pythontools/py_spec/input/spec_namelist.py @@ -454,6 +454,64 @@ def set_interface_guess(self, value, m, n, ivol, key="Rbc"): self.interface_guess[(m, n)][key][ivol] = value + + def get_plasma_boundary(self, m, n, key="Rbc"): + """Get the guess of the interface Fourier harmonic + parameters: + m,n -- the m and n number of the guess, must be within the allowed Mpol and Ntor range + the n number is the one without multiplying by Nfp + ivol -- which volume, Python convention, starting from 0 + key -- which item, can be 'Rbc', 'Zbs', 'Rbs', 'Zbc' + Returns: + guess -- the initial guess of the interface harmonic used in SPEC + """ + if key not in ["Rbc", "Rbs", "Zbc", "Zbs"]: + raise ValueError("key must be in ['Rbc', 'Rbs', 'Zbc', 'Zbs']") + + ll = self['physicslist'][key] + + if m>=len(ll): + return 0 + else: + nl = len(ll[m]) + ntor = int((nl-1)/2) + if abs(n)>ntor: + return 0 + else: + return ll[m][n+ntor] + + def set_plasma_boundary(self, value, m, n, key="Rbc"): + """Set the guess of the interface Fourier harmonic + parameters: + value -- the value that one wants to set + m,n -- the m and n number of the guess, must be within the allowed Mpol and Ntor range + the n number is the one without multiplying by Nfp + ivol -- which volume, Python convention, starting from 0 + key -- which guess, can be 'Rbc', 'Zbs', 'Rbs', 'Zbc' + """ + if key not in ["Rbc", "Rbs", "Zbc", "Zbs"]: + raise ValueError("key must be in ['Rbc', 'Rbs', 'Zbc', 'Zbs']") + + ll = self['physicslist'][key] + + if m>=len(ll): + for m in range(len(ll), m+1): + self['physicslist'][key].append([0]*(2*self._Ntor+1)) + else: + nl = len(ll[m]) + ntor = int((nl-1)/2) + if abs(n)>ntor: + for n in range(ntor+1, abs(n)+1): + self['physicslist'][key][m].append(0) + self['physicslist'][key][m].insert(0, 0) + + # Change indexing + self['physicslist'].start_index[key][0] = -abs(n) + + nl = len(self['physicslist'][key][m]) + ntor = int((nl-1)/2) + self['physicslist'][key][m][n+ntor] = value + def remove_interface_guess(self, m, n): """Remove the guess of the interface Fourier harmonic with some m,n parameters: diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 6479a6fe..7874c965 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -1,6 +1,133 @@ import numpy as np +def get_RZ_derivatives( + self, + lvol=0, + sarr=np.linspace(1, 1, 1), + tarr=np.linspace(0, 0, 1), + zarr=np.linspace(0, 0, 1), + input1D=False +): + sym = self.input.physics.Istellsym == 1 + + Rac, Rbc = self.output.Rbc[lvol : lvol + 2] + Ras, Rbs = self.output.Rbs[lvol : lvol + 2] + Zas, Zbs = self.output.Zbs[lvol : lvol + 2] + Zac, Zbc = self.output.Zbc[lvol : lvol + 2] + + mn = Rac.size # s.output.mn + im = self.output.im + in_ = self.output.in_ + + #sbar = (sarr + 1) / 2 + sbar = np.divide(np.add(sarr, 1.0), 2.0) + fac = [] + + Igeometry = self.input.physics.Igeometry + rpol = self.input.physics.rpol + rtor = self.input.physics.rtor + + if Igeometry == 1: + for j in range(mn): + fac.append([sbar, 0.5 * np.ones(sarr.size), np.zeros(sarr.size)]) + elif Igeometry == 2: + for j in range(mn): + if lvol > 0 or im[j] == 0: + fac.append([sbar, 0.5 * np.ones(sarr.size), np.zeros(sarr.size)]) + else: + fac.append( + [ + sbar ** (im[j] + 1.0), + (im[j] + 1.0) / 2.0 * sbar ** (im[j]), + (im[j] + 1.0) * (im[j]) / 4.0 * sbar ** (im[j] - 1), + ] + ) + elif Igeometry == 3: + for j in range(mn): + if lvol == 0 and im[j] == 0: + fac.append([sbar ** 2, sbar, 0.5 * np.ones(sarr.size)]) + elif lvol == 0 and im[j] > 0: + fac.append( + [ + sbar ** im[j], + (im[j] / 2.0) * sbar ** (im[j] - 1.0), + (im[j] * (im[j] - 1) / 4.0) * sbar ** (im[j] - 2.0), + ] + ) + else: + fac.append([sbar, 0.5 * np.ones(sarr.size), np.zeros(sarr.size)]) + + # now fac has the dimension (number of modes, number of derivatives, number of s points) + fac = np.array(fac) + # transpose to (number of derivatives, number of modes, number of s points) + fac = np.moveaxis(fac, 0, 1) + + nax = np.newaxis + if not input1D: + im = im[:, nax, nax, nax] + in_ = in_[:, nax, nax, nax] + ang_arg = +im * tarr[nax, nax, :, nax] - in_ * zarr[nax, nax, nax, :] + else: + im = im[:, nax] + in_ = in_[:, nax] + ang_arg = im * tarr[nax, :] - in_ * zarr[nax, :] + + cos = np.cos(ang_arg) + sin = np.sin(ang_arg) + + if not input1D: + fac = fac[:, :, :, nax, nax] + Rac = Rac[:, nax, nax, nax] + Rbc = Rbc[:, nax, nax, nax] + Zas = Zas[:, nax, nax, nax] + Zbs = Zbs[:, nax, nax, nax] + if not sym: + Ras = Ras[:, nax, nax, nax] + Rbs = Rbs[:, nax, nax, nax] + Zac = Zac[:, nax, nax, nax] + Zbc = Zbc[:, nax, nax, nax] + else: + Rac = Rac[:, nax] + Rbc = Rbc[:, nax] + Zas = Zas[:, nax] + Zbs = Zbs[:, nax] + if not sym: + Ras = Ras[:, nax] + Rbs = Rbs[:, nax] + Zac = Zac[:, nax] + Zbc = Zbc[:, nax] + + dR1 = Rac + fac[0] * (Rbc - Rac) + Rarr0 = np.sum(dR1 * cos, axis=0) + + Rarr1 = np.sum(fac[1] * (Rbc - Rac) * cos, axis=0) + Rarr2 = np.sum(-im * dR1 * sin, axis=0) + Rarr3 = np.sum(in_ * dR1 * sin, axis=0) + + Rarr = np.array([Rarr1, Rarr2, Rarr3]) + + # We only need Z for Igeometry=3 + if Igeometry == 3: + dZ1 = Zas + fac[0] * (Zbs - Zas) + Zarr0 = np.sum(dZ1 * sin, axis=0) + + Zarr1 = np.sum(fac[1] * (Zbs - Zas) * sin, axis=0) + Zarr2 = np.sum(im * dZ1 * cos, axis=0) + Zarr3 = np.sum(-in_ * dZ1 * cos, axis=0) + + Zarr = np.array([Zarr1, Zarr2, Zarr3]) + else: + Zarr0 = None + + print('hello') + return Rarr0, Rarr1, Rarr2, Rarr3, Zarr0, Zarr1, Zarr2, Zarr3 + + + + + + def get_grid_and_jacobian_and_metric( self, lvol=0, @@ -381,3 +508,99 @@ def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): print((g[1,0,0,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,0,:,:]) print((g[0,1,0,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,1,:,:]) print((g[0,0,1,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,2,:,:]) + + +def get_surface_current_density(self, lvol:int=None, nt:int=64, nz:int=64): + """Compute j_surf.B on each side of the provided interfaces + + Args: + - lvol: Interface number, between 0 and Mvol-2. + - nt: Number of poloidal points + - nz: Number of toroidal points + + Returns: + - j_dot_B: j_surf.B evaluated on the grid. Shape (nsurf, nt, nz), + with nsurf the size of lvol + - tarr: theta array, size (nt,) + - zarr: zeta array, size (nz,) + + Raises: + - ValueError: if input is wrong (invalid lvol, nt<=0, nz<=0) + """ + + mvol = self.output.Mvol + nfp = self.input.physics.Nfp + + if mvol==1: raise ValueError('Mvol=1; no interface current!') + if not isinstance(lvol, np.ndarray): raise ValueError('lvol should be a np.ndarray') + if lvol is None: raise ValueError('Need to provide lvol') + if (lvol<0).any() or (lvol>mvol-1).any(): raise ValueError('lvol should be in [1,mvol-1]') + if nt<1: raise ValueError('nt should greater than zero') + if nz<1: raise ValueError('nz should greater than zero') + + # Construct grid + tarr = np.linspace(0, 2*np.pi, nt, endpoint=True) + zarr = np.linspace(0, 2*np.pi/nfp, nz, endpoint=True) + + # Evaluate geometry elements + nsurf = lvol.size*2 + j_dot_B = np.zeros((mvol-1, 2, nt, nz)) + for vvol in lvol: + # Construct geometry elements - these are independent of the + # interface side + print(0) + R0, R1, R2, R3, Z0, Z1, Z2, Z3 = self.get_RZ_derivatives( + lvol=int(vvol), + sarr=np.asarray([1]), + tarr=tarr, + zarr=zarr + ) + print(1) + et_x_ez = (R2*Z3)**2 + (R3*Z2)**2 + (R0*Z2)**2 + (R0*R2)**2 - 2*R2*R3*Z2*Z3 + + + print(2) + gtt = R2**2+Z2**2 + gzz = R0**2 + R3**2 + Z3**2 + gtz = R2*R3 + Z2*Z3 + g = gtt*gzz - gtz**2 + + # project on each side of interface + Bcontrav = np.zeros((2,nt,nz,3)) + for innout in [0,1]: + # if innout=0, inner side of interface, thus vvol=vvol and sarr=1 + # if innout=1, outer side of interface, thus vvol=vvol+1 and sarr=-1 + sarr = np.asarray([-innout*2+1]) + + # Get magnetic field + Bcontrav[innout,:,:,:] = self.get_B( + lvol=vvol, + sarr=sarr, + tarr=tarr, + zarr=zarr + ).squeeze() + + Bcontrav_jump = Bcontrav[1]-Bcontrav[0] + + for innout in [0,1]: + j_dot_B[vvol, innout] = g / et_x_ez * ( + Bcontrav[innout, :, :, 1]*Bcontrav_jump[:, :, 2] + - Bcontrav[innout, :, :, 2]*Bcontrav_jump[:, :, 1] + ) + + print(j_dot_B.shape) + print(tarr.shape) + print(zarr.shape) + return j_dot_B, tarr, zarr + + + + + + + + + + + + diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index 733c48e0..5d8d355b 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -37,7 +37,9 @@ class SPECout: get_B, get_modB, get_B_covariant, - test_derivatives + test_derivatives, + get_surface_current_density, + get_RZ_derivatives ) from ._plot_modB import plot_modB from ._plot_iota import plot_iota @@ -101,8 +103,9 @@ def __init__(self, *args, **kwargs): # these define the target dimensions in the radial direction Nvol = self.input.physics.Nvol if self.input.physics.Lfreebound: - Nvol += 1 - self.input.physics.Nvol += 1 + Mvol=Nvol+1 + else: + Mvol=Nvol Lrad = self.input.physics.Lrad @@ -122,7 +125,7 @@ def __init__(self, *args, **kwargs): # split up radial matrix dimension into list of matrices for each of the nested volumes start = 0 - for i in range(Nvol): + for i in range(Mvol): # vector potential cAte.append( np.atleast_2d(self.vector_potential.Ate)[ diff --git a/src/xspech.f90 b/src/xspech.f90 index 05fbcc0a..1e641b25 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -876,7 +876,7 @@ subroutine final_diagnostics LREGION(vvol) do iocons = 0, 1 - if( ( Lcoordinatesingularity .and. iocons.eq.0 ) .or. ( Lvacuumregion .and. iocons.eq.1 ) ) cycle + if( Lcoordinatesingularity .and. iocons.eq.0 ) cycle ! Compute covariant magnetic field at interface call lbpol(vvol, Bt00(1:Mvol, 0:1, -1:2), 0, iocons) From 5d1a814822b758dedaf7268a2367c7196d022f9c Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 8 Nov 2022 09:42:27 +0100 Subject: [PATCH 029/134] typo --- Utilities/pythontools/py_spec/output/spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index e9d40169..fb46d6a3 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -39,7 +39,7 @@ class SPECout: get_B_covariant, test_derivatives, get_surface_current_density, - get_RZ_derivatives + get_RZ_derivatives, get_volume, get_average_beta, get_peak_beta From a1ecefa30ce77311f0e25afb170ad870959c08b8 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 8 Nov 2022 09:43:24 +0100 Subject: [PATCH 030/134] forgot to resolve a conflict --- Utilities/pythontools/py_spec/output/spec.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index fb46d6a3..bd049f5f 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -107,13 +107,7 @@ def __init__(self, *args, **kwargs): Nvol = self.input.physics.Nvol Mvol = Nvol if self.input.physics.Lfreebound: -<<<<<<< HEAD - Mvol=Nvol+1 - else: - Mvol=Nvol -======= Mvol += 1 ->>>>>>> pythontools Lrad = self.input.physics.Lrad From 90041055b6eebb1d454c0e94c0c7928ddb2034bd Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Mon, 21 Nov 2022 17:43:57 +0100 Subject: [PATCH 031/134] update --- .../pythontools/py_spec/output/_processing.py | 50 +++++++++---------- .../py_spec/output/test_processing.py | 8 +++ 2 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 Utilities/pythontools/py_spec/output/test_processing.py diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 46525eb8..8ff0a1ca 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -9,6 +9,12 @@ def get_RZ_derivatives( zarr=np.linspace(0, 0, 1), input1D=False ): + + Igeometry = self.input.physics.Igeometry + + if lvol==0 and (sarr==-1).any() and Igeometry!=0: + raise ValueError('Cannot evaluate coordinate derivative on magnetic axis !') + sym = self.input.physics.Istellsym == 1 Rac, Rbc = self.output.Rbc[lvol : lvol + 2] @@ -24,7 +30,6 @@ def get_RZ_derivatives( sbar = np.divide(np.add(sarr, 1.0), 2.0) fac = [] - Igeometry = self.input.physics.Igeometry rpol = self.input.physics.rpol rtor = self.input.physics.rtor @@ -120,7 +125,6 @@ def get_RZ_derivatives( else: Zarr0 = None - print('hello') return Rarr0, Rarr1, Rarr2, Rarr3, Zarr0, Zarr1, Zarr2, Zarr3 @@ -594,31 +598,31 @@ def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): print((g[0,0,1,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,2,:,:]) -def get_surface_current_density(self, lvol:int=None, nt:int=64, nz:int=64): +def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): """Compute j_surf.B on each side of the provided interfaces Args: - - lvol: Interface number, between 0 and Mvol-2. + - lsurf: Interface number, between 1 and Mvol-1. - nt: Number of poloidal points - nz: Number of toroidal points Returns: - - j_dot_B: j_surf.B evaluated on the grid. Shape (nsurf, nt, nz), - with nsurf the size of lvol + - j_dot_B: mu0*j_surf.B evaluated on the grid. Shape (nsurf, nt, nz), + with nsurf the size of lsurf - tarr: theta array, size (nt,) - zarr: zeta array, size (nz,) Raises: - - ValueError: if input is wrong (invalid lvol, nt<=0, nz<=0) + - ValueError: if input is wrong (invalid lsurf, nt<=0, nz<=0) """ mvol = self.output.Mvol nfp = self.input.physics.Nfp if mvol==1: raise ValueError('Mvol=1; no interface current!') - if not isinstance(lvol, np.ndarray): raise ValueError('lvol should be a np.ndarray') - if lvol is None: raise ValueError('Need to provide lvol') - if (lvol<0).any() or (lvol>mvol-1).any(): raise ValueError('lvol should be in [1,mvol-1]') + if not isinstance(lsurf, np.ndarray): raise ValueError('lsurf should be a np.ndarray') + if lsurf is None: raise ValueError('Need to provide lsurf') + if (lsurf<1).any() or (lsurf>mvol-1).any(): raise ValueError('lsurf should be in [1,mvol-1]') if nt<1: raise ValueError('nt should greater than zero') if nz<1: raise ValueError('nz should greater than zero') @@ -627,23 +631,19 @@ def get_surface_current_density(self, lvol:int=None, nt:int=64, nz:int=64): zarr = np.linspace(0, 2*np.pi/nfp, nz, endpoint=True) # Evaluate geometry elements - nsurf = lvol.size*2 + nsurf = lsurf.size*2 j_dot_B = np.zeros((mvol-1, 2, nt, nz)) - for vvol in lvol: + for s in lsurf: # Construct geometry elements - these are independent of the # interface side - print(0) R0, R1, R2, R3, Z0, Z1, Z2, Z3 = self.get_RZ_derivatives( - lvol=int(vvol), + lvol=int(s-1), sarr=np.asarray([1]), tarr=tarr, zarr=zarr ) - print(1) et_x_ez = (R2*Z3)**2 + (R3*Z2)**2 + (R0*Z2)**2 + (R0*R2)**2 - 2*R2*R3*Z2*Z3 - - print(2) gtt = R2**2+Z2**2 gzz = R0**2 + R3**2 + Z3**2 gtz = R2*R3 + Z2*Z3 @@ -652,29 +652,27 @@ def get_surface_current_density(self, lvol:int=None, nt:int=64, nz:int=64): # project on each side of interface Bcontrav = np.zeros((2,nt,nz,3)) for innout in [0,1]: - # if innout=0, inner side of interface, thus vvol=vvol and sarr=1 - # if innout=1, outer side of interface, thus vvol=vvol+1 and sarr=-1 + # if innout=0, inner side of interface, thus vvol=s-1 and sarr=1 + # if innout=1, outer side of interface, thus vvol=s and sarr=-1 + lvol = s - np.mod(innout+1,2) sarr = np.asarray([-innout*2+1]) # Get magnetic field Bcontrav[innout,:,:,:] = self.get_B( - lvol=vvol, + lvol=lvol, sarr=sarr, tarr=tarr, zarr=zarr - ).squeeze() - + )[0] + Bcontrav_jump = Bcontrav[1]-Bcontrav[0] for innout in [0,1]: - j_dot_B[vvol, innout] = g / et_x_ez * ( + j_dot_B[s-1, innout] = g / et_x_ez * ( Bcontrav[innout, :, :, 1]*Bcontrav_jump[:, :, 2] - Bcontrav[innout, :, :, 2]*Bcontrav_jump[:, :, 1] ) - print(j_dot_B.shape) - print(tarr.shape) - print(zarr.shape) return j_dot_B, tarr, zarr diff --git a/Utilities/pythontools/py_spec/output/test_processing.py b/Utilities/pythontools/py_spec/output/test_processing.py new file mode 100644 index 00000000..ff88cb49 --- /dev/null +++ b/Utilities/pythontools/py_spec/output/test_processing.py @@ -0,0 +1,8 @@ +from py_spec import SPECout +import numpy as np + +d = SPECout('/BIG_14TB/BetaScan/RotatingEllipse/Nfp5/BSmodel1_Pmodel1_Bz002/BetaScan_30/BetaScan_Bz002_run_5.sp.h5') + +j_dot_B = d.get_surface_current_density(lvol=np.arange(0,7), nt=32, nz=16) + +print(j_dot_B) \ No newline at end of file From babfb6043f2e297ff550a11680338527bb8a17f6 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 24 Nov 2022 10:21:13 +0100 Subject: [PATCH 032/134] removed useless test --- Utilities/pythontools/py_spec/output/test_processing.py | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 Utilities/pythontools/py_spec/output/test_processing.py diff --git a/Utilities/pythontools/py_spec/output/test_processing.py b/Utilities/pythontools/py_spec/output/test_processing.py deleted file mode 100644 index ff88cb49..00000000 --- a/Utilities/pythontools/py_spec/output/test_processing.py +++ /dev/null @@ -1,8 +0,0 @@ -from py_spec import SPECout -import numpy as np - -d = SPECout('/BIG_14TB/BetaScan/RotatingEllipse/Nfp5/BSmodel1_Pmodel1_Bz002/BetaScan_30/BetaScan_Bz002_run_5.sp.h5') - -j_dot_B = d.get_surface_current_density(lvol=np.arange(0,7), nt=32, nz=16) - -print(j_dot_B) \ No newline at end of file From a455797a73120ca4017cd941017a7e56159a3c95 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 24 Nov 2022 10:56:12 +0100 Subject: [PATCH 033/134] update, added a few tests --- Utilities/matlabtools/plot_spec_Bgrid.m | 3 + Utilities/matlabtools/plot_spec_iterations.m | 4 + out.txt | 1801 ------------------ 3 files changed, 7 insertions(+), 1801 deletions(-) delete mode 100644 out.txt diff --git a/Utilities/matlabtools/plot_spec_Bgrid.m b/Utilities/matlabtools/plot_spec_Bgrid.m index 159b2289..c8cd178c 100644 --- a/Utilities/matlabtools/plot_spec_Bgrid.m +++ b/Utilities/matlabtools/plot_spec_Bgrid.m @@ -23,6 +23,9 @@ function plot_spec_Bgrid(data,nz0,plotstyle,newfig) if ~strcmp(string(plotstyle),string('pcolor')) && ~strcmp(string(plotstyle),string('scatter')) error('InputError: Invalid plotstyle') end +if nz0<1 + error('nzo should be greater than zero') +end switch newfig case 0 hold on diff --git a/Utilities/matlabtools/plot_spec_iterations.m b/Utilities/matlabtools/plot_spec_iterations.m index e249c211..01cf2a12 100644 --- a/Utilities/matlabtools/plot_spec_iterations.m +++ b/Utilities/matlabtools/plot_spec_iterations.m @@ -26,6 +26,10 @@ function plot_spec_iterations( data, xl, yl ) % Read size Nfp = double(data.input.physics.Nfp); [~, ~, Niter] = size(data.iterations.iRbc); + + if Niter==0 + error('No iterations available') + end % Create some sliders for controling the iteration and the toroidal % angle diff --git a/out.txt b/out.txt deleted file mode 100644 index 42311115..00000000 --- a/out.txt +++ /dev/null @@ -1,1801 +0,0 @@ -Not searching for unused variables given on the command line. --- The C compiler identification is GNU 9.4.0 --- Detecting C compiler ABI info --- Detecting C compiler ABI info - done --- Check for working C compiler: /misc/Anaconda3/envs/spec_env/bin/mpicc - skipped --- Detecting C compile features --- Detecting C compile features - done --- The CXX compiler identification is GNU 7.4.1 --- Detecting CXX compiler ABI info --- Detecting CXX compiler ABI info - done --- Check for working CXX compiler: /usr/bin/c++ - skipped --- Detecting CXX compile features --- Detecting CXX compile features - done --- Configuring done --- Generating done --- Build files have been written to: /home/abaillod/SPEC/_cmake_test_compile/build --- The C compiler identification is GNU 9.4.0 --- The Fortran compiler identification is GNU 9.4.0 --- Detecting C compiler ABI info --- Detecting C compiler ABI info - done --- Check for working C compiler: /misc/Anaconda3/envs/spec_env/bin/mpicc - skipped --- Detecting C compile features --- Detecting C compile features - done --- Detecting Fortran compiler ABI info --- Detecting Fortran compiler ABI info - done --- Check for working Fortran compiler: /misc/Anaconda3/envs/spec_env/bin/mpif90 - skipped --- Found OpenMP_C: -fopenmp (found version "4.5") --- Found OpenMP_Fortran: -fopenmp (found version "4.5") --- Found OpenMP: TRUE (found version "4.5") --- Looking for pthread.h --- Looking for pthread.h - found --- Performing Test CMAKE_HAVE_LIBC_PTHREAD --- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success --- Found Threads: TRUE --- Looking for pow in m --- Looking for pow in m - found --- compiler is mpif90 --- Found MPI_C: /misc/Anaconda3/envs/spec_env/bin/mpicc (found version "3.1") --- Found MPI_Fortran: /misc/Anaconda3/envs/spec_env/bin/mpif90 (found version "3.1") --- Found MPI: TRUE (found version "3.1") --- Looking for Fortran sgemm --- Looking for Fortran sgemm - found --- Found BLAS: /misc/Anaconda3/envs/spec_env/lib/libopenblas.so --- BLAS vendor is OpenBLAS --- Configuring done --- Generating done --- Build files have been written to: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/findFFTW-download -[1/9] Creating directories for 'findFFTW_download' -[2/9] Performing download step (git clone) for 'findFFTW_download' -Cloning into 'findFFTW-src'... -Already on 'master' -Your branch is up to date with 'origin/master'. -[3/9] Performing update step for 'findFFTW_download' -HEAD is now at ac78852 Merge pull request #6 from hello-adam/master -[4/9] No patch step for 'findFFTW_download' -[5/9] No configure step for 'findFFTW_download' -[6/9] No build step for 'findFFTW_download' -[7/9] No install step for 'findFFTW_download' -[8/9] No test step for 'findFFTW_download' -[9/9] Completed 'findFFTW_download' --- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") --- Found FFTW: /misc/Anaconda3/envs/spec_env/include --- HDF5 C compiler wrapper is unable to compile a minimal HDF5 program. --- HDF5 Fortran compiler wrapper is unable to compile a minimal HDF5 program. --- Found HDF5: /misc/Anaconda3/envs/spec_env/lib/libhdf5.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5_fortran.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5.so (found version "1.12.1") found components: C Fortran HL --- HDF5 libraries found: TRUE --- HDF5 C include directors : /misc/Anaconda3/envs/spec_env/include --- HDF5 Fortran include directors : /misc/Anaconda3/envs/spec_env/include --- preprocess_fortran arguments: srcs, followed by manual.f90;rzaxis.f90;packxi.f90;volume.f90;coords.f90;basefn.f90;memory.f90;metrix.f90;ma00aa.f90;matrix.f90;spsmat.f90;spsint.f90;mp00ac.f90;ma02aa.f90;packab.f90;tr00ab.f90;curent.f90;df00ab.f90;lforce.f90;intghs.f90;mtrxhs.f90;lbpol.f90;brcast.f90;dfp100.f90;dfp200.f90;dforce.f90;newton.f90;casing.f90;bnorml.f90;jo00aa.f90;pp00aa.f90;pp00ab.f90;bfield.f90;stzxyz.f90;hesian.f90;ra00aa.f90;numrec.f90;preset.f90;bndRep.f90;global.f90;inputlist.f90 --- Got file: manual.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90 --- Got file: rzaxis.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90 --- Got file: packxi.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90 --- Got file: volume.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90 --- Got file: coords.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90 --- Got file: basefn.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90 --- Got file: memory.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90 --- Got file: metrix.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90 --- Got file: ma00aa.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90 --- Got file: matrix.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90 --- Got file: spsmat.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90 --- Got file: spsint.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90 --- Got file: mp00ac.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90 --- Got file: ma02aa.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90 --- Got file: packab.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90 --- Got file: tr00ab.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90 --- Got file: curent.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90 --- Got file: df00ab.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90 --- Got file: lforce.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90 --- Got file: intghs.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90 --- Got file: mtrxhs.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90 --- Got file: lbpol.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90 --- Got file: brcast.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90 --- Got file: dfp100.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90 --- Got file: dfp200.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90 --- Got file: dforce.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90 --- Got file: newton.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90 --- Got file: casing.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90 --- Got file: bnorml.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90 --- Got file: jo00aa.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90 --- Got file: pp00aa.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90 --- Got file: pp00ab.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90 --- Got file: bfield.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90 --- Got file: stzxyz.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90 --- Got file: hesian.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90 --- Got file: ra00aa.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90 --- Got file: numrec.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90 --- Got file: preset.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90 --- Got file: bndRep.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90 --- Got file: global.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90 --- Got file: inputlist.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90 --- sphdf5_FILE is /home/abaillod/SPEC/src/sphdf5.f90 --- Exit code from awk: 0 --- preprocess_fortran arguments: sphdf5_src, followed by /home/abaillod/SPEC/src/msphdf5.f90 --- Got file: /home/abaillod/SPEC/src/msphdf5.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 --- sphdf5_src is /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 --- Exit code from awk: 0 --- preprocess_fortran arguments: XSPEC_OUT_FILE, followed by /home/abaillod/SPEC/src/mxspech.f90 --- Got file: /home/abaillod/SPEC/src/mxspech.f90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 --- XSPEC_OUT_FILE is /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 --- srcs variable is /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 --- spec linked libraries are /misc/Anaconda3/envs/spec_env/lib/libhdf5_fortran.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5.so;/misc/Anaconda3/envs/spec_env/lib/libhdf5.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3f.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3l.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3_threads.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3f_threads.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3l_threads.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3_omp.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3f_omp.so;/misc/Anaconda3/envs/spec_env/lib/libfftw3l_omp.so;/misc/Anaconda3/envs/spec_env/lib/libopenblas.so --- spec compile options are -cpp;$<$:-ffree-line-length-none>;$<$:-fdefault-real-8>;$<$:-fbounds-check>;$<$:-fexternal-blas>;$<$:-r8> --- spec compile definitions are SPEC_COMPILE_DEFS-NOTFOUND --- Found PythonInterp: /misc/Anaconda3/envs/spec_env/bin/python (found version "3.10.2") --- Found PythonLibs: /misc/Anaconda3/envs/spec_env/lib/libpython3.10.so (found version "3.10.2") --- Found NumPy: /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include (found version "1.22.2") --- Found F2PY: /misc/Anaconda3/envs/spec_env/bin/f2py3 (found version "1.22.2") --- Found F90Wrap: /misc/Anaconda3/envs/spec_env/bin/f90wrap --- Compile definitions for preprocessor are --- preprocess_fortran arguments: fpp_files, followed by /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90;/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/manual_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/rzaxis_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packxi_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/volume_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/coords_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/basefn_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/memory_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/metrix_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma00aa_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/matrix_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsmat_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsint_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mp00ac_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma02aa_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packab_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/tr00ab_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/curent_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/df00ab_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lforce_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/intghs_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mtrxhs_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lbpol_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/brcast_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp100_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp200_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dforce_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/newton_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/casing_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bnorml_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/jo00aa_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00aa_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00ab_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bfield_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/stzxyz_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/hesian_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ra00aa_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/numrec_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/preset_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bndRep_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/global_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/inputlist_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/msphdf5_m_fpp.F90 --- Got fortran file: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 --- Output name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mxspech_m_fpp.F90 --- Python exten suffix expansion: .cpython-310-x86_64-linux-gnu.so --- f90_wrap_output_files: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_global_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_inputlist_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_intghs_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_msphdf5_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_newton_m_fpp.f90/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/f90wrap_toplevel.f90 --- f2py_module_name: _spec_f90wrapped --- generated_module_name: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/_spec_f90wrapped.cpython-310-x86_64-linux-gnu.so --- Configuring done --- Generating done --- Build files have been written to: /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build -[1/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/i1mach.f-pp.f -[2/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/d1mach.f-pp.f -[3/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/ilut.f-pp.f -[4/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/dcuhre.f-pp.f -[5/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/minpack.f-pp.f -[6/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/iqpack.f-pp.f -[7/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/iters.f-pp.f -[8/200] Building Fortran preprocessed src/CMakeFiles/spec3p.dir/rksuite.f-pp.f -[9/200] Generating Fortran dyndep file src/CMakeFiles/spec3p.dir/Fortran.dd -[10/200] Building Fortran object src/CMakeFiles/spec3p.dir/i1mach.f.o -[11/200] Building Fortran object src/CMakeFiles/spec3p.dir/d1mach.f.o -[12/200] Building C object Utilities/python_wrapper/CMakeFiles/_f2py_runtime_library.dir/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.c.o -In file included from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1960, - from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12, - from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5, - from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.h:13, - from /misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/f2py/src/fortranobject.c:2: -/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp] - 17 | #warning "Using deprecated NumPy API, disable it with " \ - | ^~~~~~~ -[13/200] Linking C static library build/lib/lib_f2py_runtime_library.a -[14/200] Building Fortran object src/CMakeFiles/spec3p.dir/dcuhre.f.o -/home/abaillod/SPEC/src/dcuhre.f:1633:15: - - 1633 | C "An Imbedded Family of Fully Symmetric Numerical - | 1 -Warning: missing terminating " character -/home/abaillod/SPEC/src/dcuhre.f:1634:33: - - 1634 | C Integration Rules", - | 1 -Warning: missing terminating " character -/home/abaillod/SPEC/src/dcuhre.f:1842:15: - - 1842 | C "An Imbedded Family of Fully Symmetric Numerical - | 1 -Warning: missing terminating " character -/home/abaillod/SPEC/src/dcuhre.f:1843:33: - - 1843 | C Integration Rules", - | 1 -Warning: missing terminating " character -/home/abaillod/SPEC/src/dcuhre.f:1024:72: - - 1024 | DO 190 J = 1,NDIM - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 190 at (1) -/home/abaillod/SPEC/src/dcuhre.f:1025:72: - - 1025 | DO 190 K = 1,WTLENG - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 190 at (1) -/home/abaillod/SPEC/src/dcuhre.f:1365:72: - - 1365 | DO 10 J = 1,5 - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 10 at (1) -/home/abaillod/SPEC/src/dcuhre.f:1372:72: - - 1372 | DO 20 J = 1,14 - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 20 at (1) -/home/abaillod/SPEC/src/dcuhre.f:1535:72: - - 1535 | DO 10 J = 1,5 - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 10 at (1) -/home/abaillod/SPEC/src/dcuhre.f:1542:72: - - 1542 | DO 20 J = 1,13 - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 20 at (1) -[15/200] Building Fortran object src/CMakeFiles/spec3p.dir/minpack.f.o -/home/abaillod/SPEC/src/minpack.f:208:60: - - 208 | c Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More' - | 1 -Warning: missing terminating ' character -[16/200] Building Fortran object src/CMakeFiles/spec3p.dir/iqpack.f.o -/home/abaillod/SPEC/src/iqpack.f:1373:25: - - 1373 | C KAUTSKY AND ELHAY "CALCULATION OF THE WEIGHTS OF INTERPOLATORY - | 1 -Warning: missing terminating " character -/home/abaillod/SPEC/src/iqpack.f:1374:18: - - 1374 | C QUADRATURES", NUMER MATH 40 (1982) 407-422. - | 1 -Warning: missing terminating " character -/home/abaillod/SPEC/src/iqpack.f:1726:49: - - 1726 | C LO.LT.0 MEANS PRINT WEIGHTS ONLY. DON'T COMPUTE MOMENT TESTS - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iqpack.f:1875:49: - - 1875 | C LO.LT.0 MEANS PRINT WEIGHTS ONLY. DON'T COMPUTE MOMENT TESTS - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iqpack.f:746:72: - - 746 | 20 N=N+MLT(J) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 20 at (1) -/home/abaillod/SPEC/src/iqpack.f:799:72: - - 799 | 20 N=N+MLT(J) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 20 at (1) -/home/abaillod/SPEC/src/iqpack.f:1205:72: - - 1205 | DO 10 J=L,NT - | 1 -Warning: Fortran 2018 deleted feature: Shared DO termination label 10 at (1) -/home/abaillod/SPEC/src/iqpack.f:1462:72: - - 1462 | 130 D(K)=SUM - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 130 at (1) -/home/abaillod/SPEC/src/iqpack.f:1516:72: - - 1516 | 40 BJ(I)=ABI*ABI/(ABJ*ABJ-ONE) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1) -/home/abaillod/SPEC/src/iqpack.f:1521:72: - - 1521 | 60 BJ(I)=HALF - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 60 at (1) -/home/abaillod/SPEC/src/iqpack.f:1530:72: - - 1530 | 80 BJ(I)=I*(I+AB)/(FOUR*(I+ALPHA)**2-ONE) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 80 at (1) -/home/abaillod/SPEC/src/iqpack.f:1543:72: - - 1543 | 100 BJ(I)=FOUR*I*(I+ALPHA)*(I+BETA)*(I+AB)/((ABI-ONE)*ABI) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 100 at (1) -/home/abaillod/SPEC/src/iqpack.f:1548:72: - - 1548 | 120 BJ(I)=I*(I+ALPHA) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 120 at (1) -/home/abaillod/SPEC/src/iqpack.f:1553:72: - - 1553 | 140 BJ(I)=(I+ALPHA*MOD(I,2))/TWO - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1) -/home/abaillod/SPEC/src/iqpack.f:1564:72: - - 1564 | 160 AJ(I)=-AJ(I)/ABTI/(ABTI-TWO) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 160 at (1) -/home/abaillod/SPEC/src/iqpack.f:1568:72: - - 1568 | 1 (ABTI**2)*(AB+I)/(ABTI+ONE) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 165 at (1) -/home/abaillod/SPEC/src/iqpack.f:1600:72: - - 1600 | 10 W(K)=ZERO - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 10 at (1) -/home/abaillod/SPEC/src/iqpack.f:1607:72: - - 1607 | 50 W(K)=TWO/(K+ALS) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 50 at (1) -/home/abaillod/SPEC/src/iqpack.f:1611:72: - - 1611 | 70 W(K)=W(K-2)*(K-TWO)/(K-ONE) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 70 at (1) -/home/abaillod/SPEC/src/iqpack.f:1615:72: - - 1615 | 90 W(K)=W(K-2)*(K-TWO)/(TWO*ALPHA+K) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 90 at (1) -/home/abaillod/SPEC/src/iqpack.f:1626:72: - - 1626 | 110 TMPA=TMPA*(ALPHA+JA)/(ALS+JA) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 110 at (1) -/home/abaillod/SPEC/src/iqpack.f:1628:72: - - 1628 | 120 TMPA=TMPA*(BETA+JB)/(ALS+2*I+JB) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 120 at (1) -/home/abaillod/SPEC/src/iqpack.f:1637:72: - - 1637 | 140 TMPB=TMPB*(ALPHA+I)/(ALS+I) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1) -/home/abaillod/SPEC/src/iqpack.f:1639:72: - - 1639 | 150 W(K)=SUM*W(1) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1) -/home/abaillod/SPEC/src/iqpack.f:1643:72: - - 1643 | 170 W(K)=(ALPHA+K-ONE)*W(K-1) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 170 at (1) -/home/abaillod/SPEC/src/iqpack.f:1647:72: - - 1647 | 190 W(K)=W(K-2)*(ALPHA+K-TWO)/TWO - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 190 at (1) -/home/abaillod/SPEC/src/iqpack.f:1651:72: - - 1651 | 210 W(K)=-W(K-1)*(ALPHA+K-ONE)/(ALPHA+BETA+K) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 210 at (1) -/home/abaillod/SPEC/src/iqpack.f:2103:72: - - 2103 | 160 TMP=TMP*SLP - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 160 at (1) -/home/abaillod/SPEC/src/iqpack.f:2205:72: - - 2205 | 20 W(K)=ABS(T(K))**ALPHA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 20 at (1) -/home/abaillod/SPEC/src/iqpack.f:2208:72: - - 2208 | 40 W(K)=ONE - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 40 at (1) -/home/abaillod/SPEC/src/iqpack.f:2211:72: - - 2211 | 60 W(K)=ONE/SQRT((ONE-T(K))*(ONE+T(K))) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 60 at (1) -/home/abaillod/SPEC/src/iqpack.f:2215:72: - - 2215 | 80 W(K)=((ONE-T(K))*(ONE+T(K)))**ALPHA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 80 at (1) -/home/abaillod/SPEC/src/iqpack.f:2218:72: - - 2218 | 100 W(K)=ONE - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 100 at (1) -/home/abaillod/SPEC/src/iqpack.f:2221:72: - - 2221 | 110 W(K)=W(K)*(ONE-T(K))**ALPHA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 110 at (1) -/home/abaillod/SPEC/src/iqpack.f:2225:72: - - 2225 | 120 W(K)=W(K)*(ONE+T(K))**BETA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 120 at (1) -/home/abaillod/SPEC/src/iqpack.f:2229:72: - - 2229 | 140 W(K)=EXP(-T(K)) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 140 at (1) -/home/abaillod/SPEC/src/iqpack.f:2232:72: - - 2232 | 150 W(K)=W(K)*T(K)**ALPHA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 150 at (1) -/home/abaillod/SPEC/src/iqpack.f:2236:72: - - 2236 | 170 W(K)=EXP(-T(K)**2) - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 170 at (1) -/home/abaillod/SPEC/src/iqpack.f:2239:72: - - 2239 | 180 W(K)=W(K)*ABS(T(K))**ALPHA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 180 at (1) -/home/abaillod/SPEC/src/iqpack.f:2243:72: - - 2243 | 200 W(K)=ONE - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 200 at (1) -/home/abaillod/SPEC/src/iqpack.f:2246:72: - - 2246 | 210 W(K)=W(K)*T(K)**ALPHA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 210 at (1) -/home/abaillod/SPEC/src/iqpack.f:2250:72: - - 2250 | 220 W(K)=W(K)*(ONE+T(K))**BETA - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 220 at (1) -/home/abaillod/SPEC/src/iqpack.f:2321:72: - - 2321 | 60 Z(I)=C*Z(I)-S*F - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 60 at (1) -[17/200] Building Fortran object src/CMakeFiles/spec3p.dir/rksuite.f.o -/home/abaillod/SPEC/src/rksuite.f:1777:67: - - 1777 | C REQEST(1:1) = `S' or `s'- compute approximate `S'olution - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/rksuite.f:1780:47: - - 1780 | C `D'erivative of the solution only. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/rksuite.f:1781:55: - - 1781 | C = `B' or `b'- compute `B'oth approximate solution - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/rksuite.f:3184:54: - - 3184 | C REQEST(1:1) = `S' or `s'- compute approximate `S'olution only. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/rksuite.f:3185:60: - - 3185 | C = `D' or `d'- compute approximate first `D'erivative - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/rksuite.f:3187:42: - - 3187 | C = `B' or `b'- compute `B'oth approximate solution and - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/rksuite.f:4619:39: - - 4619 | C in the left half plane -- there won't be a stability restriction - | 1 -Warning: missing terminating ' character -[18/200] Building Fortran object src/CMakeFiles/spec3p.dir/ilut.f.o -/home/abaillod/SPEC/src/ilut.f:701:17: - - 701 | c exchange w's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/ilut.f:806:11: - - 806 | c tion ILU's such MILU. These are defined through the parameter alph * - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/ilut.f:1409:17: - - 1409 | c exchange w's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/ilut.f:1846:33: - - 1846 | c initialize work vector to zero's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/ilut.f:1968:33: - - 1968 | c initialize work vector to zero's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/ilut.f:1903:72: - - 1903 | 201 iw(jlu(i)) = 0 - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 201 at (1) -/home/abaillod/SPEC/src/ilut.f:1970:72: - - 1970 | 31 iw(i) = 0 - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 31 at (1) -/home/abaillod/SPEC/src/ilut.f:2021:72: - - 2021 | 201 iw(jlu(i)) = 0 - | 1 -Warning: Fortran 2018 deleted feature: DO termination statement which is not END DO or CONTINUE with label 201 at (1) -[19/200] Building Fortran object src/CMakeFiles/spec3p.dir/iters.f.o -/home/abaillod/SPEC/src/iters.f:260:19: - - 260 | c of the TFQMR's estimate is less accurate. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:322:45: - - 322 | c ipar(6) = 100 ! use at most 100 matvec's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:803:58: - - 803 | c in this routine, before successful return, the fpar's are - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:1055:58: - - 1055 | c in this routine, before successful return, the fpar's are - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:1317:27: - - 1317 | c Internally, the fpar's are used as following: - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:1607:27: - - 1607 | c the work space in `w' is used as follows: - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:1923:26: - - 1923 | c the space of the `w' is used as follows: - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:2250:26: - - 2250 | c w(iv+1:iw) -- the V's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:2251:26: - - 2251 | c w(iw+1:ic) -- the W's - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:2437:19: - - 2437 | c update the W's (the conjugate directions) -- essentially this is one - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:2530:26: - - 2530 | c the space of the `w' is used as follows: - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:3017:49: - - 3017 | c orthogonalize current v against previous v's and - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:3238:56: - - 3238 | c Given x and y, this subroutine generates a Givens' rotation c, s. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:3483:14: - - 3483 | c The ind'th vector of VEC is orthogonalized against the rest of - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/src/iters.f:3492:67: - - 3492 | c full -- .ture. if it is necessary to orthogonalize the ind'th - | 1 -Warning: missing terminating ' character -[20/200] Preprocessing /home/abaillod/SPEC/src/manual.f90 -[21/200] Preprocessing /home/abaillod/SPEC/src/packxi.f90 -[22/200] Preprocessing /home/abaillod/SPEC/src/volume.f90 -[23/200] Preprocessing /home/abaillod/SPEC/src/metrix.f90 -[24/200] Preprocessing /home/abaillod/SPEC/src/ma00aa.f90 -[25/200] Preprocessing /home/abaillod/SPEC/src/spsint.f90 -[26/200] Preprocessing /home/abaillod/SPEC/src/rzaxis.f90 -[27/200] Preprocessing /home/abaillod/SPEC/src/coords.f90 -[28/200] Preprocessing /home/abaillod/SPEC/src/basefn.f90 -[29/200] Preprocessing /home/abaillod/SPEC/src/memory.f90 -[30/200] Preprocessing /home/abaillod/SPEC/src/matrix.f90 -[31/200] Preprocessing /home/abaillod/SPEC/src/spsmat.f90 -[32/200] Preprocessing /home/abaillod/SPEC/src/mp00ac.f90 -[33/200] Preprocessing /home/abaillod/SPEC/src/ma02aa.f90 -[34/200] Preprocessing /home/abaillod/SPEC/src/df00ab.f90 -[35/200] Preprocessing /home/abaillod/SPEC/src/packab.f90 -[36/200] Preprocessing /home/abaillod/SPEC/src/curent.f90 -[37/200] Preprocessing /home/abaillod/SPEC/src/lforce.f90 -[38/200] Preprocessing /home/abaillod/SPEC/src/tr00ab.f90 -[39/200] Preprocessing /home/abaillod/SPEC/src/mtrxhs.f90 -[40/200] Preprocessing /home/abaillod/SPEC/src/lbpol.f90 -[41/200] Preprocessing /home/abaillod/SPEC/src/intghs.f90 -[42/200] Preprocessing /home/abaillod/SPEC/src/brcast.f90 -[43/200] Preprocessing /home/abaillod/SPEC/src/dfp100.f90 -[44/200] Preprocessing /home/abaillod/SPEC/src/casing.f90 -[45/200] Preprocessing /home/abaillod/SPEC/src/bnorml.f90 -[46/200] Preprocessing /home/abaillod/SPEC/src/jo00aa.f90 -[47/200] Preprocessing /home/abaillod/SPEC/src/pp00ab.f90 -[48/200] Preprocessing /home/abaillod/SPEC/src/newton.f90 -[49/200] Preprocessing /home/abaillod/SPEC/src/dforce.f90 -[50/200] Preprocessing /home/abaillod/SPEC/src/pp00aa.f90 -[51/200] Preprocessing /home/abaillod/SPEC/src/stzxyz.f90 -[52/200] Preprocessing /home/abaillod/SPEC/src/bfield.f90 -[53/200] Preprocessing /home/abaillod/SPEC/src/ra00aa.f90 -[54/200] Preprocessing /home/abaillod/SPEC/src/numrec.f90 -[55/200] Preprocessing /home/abaillod/SPEC/src/dfp200.f90 -[56/200] Preprocessing /home/abaillod/SPEC/src/hesian.f90 -[57/200] Preprocessing /home/abaillod/SPEC/src/inputlist.f90 -[58/200] Preprocessing /home/abaillod/SPEC/src/bndRep.f90 -[59/200] Preprocessing /home/abaillod/SPEC/src/global.f90 -[60/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90 -[61/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/brcast_m.F90 -[62/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bnorml_m.F90 -[63/200] Preprocessing /home/abaillod/SPEC/src/preset.f90 -[64/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bfield_m.F90 -[65/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/curent_m.F90 -[66/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/df00ab_m.F90 -[67/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/casing_m.F90 -[68/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/coords_m.F90 -[69/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90 -[70/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90 -[71/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp100_m.F90 -[72/200] Preprocessing /home/abaillod/SPEC/src/mxspech.f90 -[73/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90 -[74/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/hesian_m.F90 -[75/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90 -[76/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90 -[77/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90 -[78/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lbpol_m.F90 -[79/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/jo00aa_m.F90 -[80/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/lforce_m.F90 -[81/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma00aa_m.F90 -[82/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90 -[83/200] Preprocessing /home/abaillod/SPEC/src/msphdf5.f90 -[84/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90 -[85/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/matrix_m.F90 -[86/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mtrxhs_m.F90 -[87/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/metrix_m.F90 -[88/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90 -[89/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/memory_m.F90 -[90/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mp00ac_m.F90 -[91/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packab_m.F90 -[92/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/newton_m.F90 -[93/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/packxi_m.F90 -[94/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/numrec_m.F90 -[95/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00aa_m.F90 -[96/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/pp00ab_m.F90 -[97/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/packxi_m.F90-pp.f90 -[98/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/manual_m.F90-pp.f90 -[99/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/volume_m.F90-pp.f90 -[100/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/rzaxis_m.F90-pp.f90 -[101/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/coords_m.F90-pp.f90 -[102/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/basefn_m.F90-pp.f90 -[103/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/memory_m.F90-pp.f90 -[104/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/metrix_m.F90-pp.f90 -[105/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/ma02aa_m.F90-pp.f90 -[106/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/mp00ac_m.F90-pp.f90 -[107/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/spsmat_m.F90-pp.f90 -[108/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/spsint_m.F90-pp.f90 -[109/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/ma00aa_m.F90-pp.f90 -[110/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/matrix_m.F90-pp.f90 -[111/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/packab_m.F90-pp.f90 -[112/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/tr00ab_m.F90-pp.f90 -[113/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/lbpol_m.F90-pp.f90 -[114/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/curent_m.F90-pp.f90 -[115/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/df00ab_m.F90-pp.f90 -[116/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/lforce_m.F90-pp.f90 -[117/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/dfp100_m.F90-pp.f90 -[118/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/intghs_m.F90-pp.f90 -[119/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/mtrxhs_m.F90-pp.f90 -[120/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/brcast_m.F90-pp.f90 -[121/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/dfp200_m.F90-pp.f90 -[122/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/dforce_m.F90-pp.f90 -[123/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/newton_m.F90-pp.f90 -[124/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/pp00ab_m.F90-pp.f90 -[125/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/casing_m.F90-pp.f90 -[126/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/bnorml_m.F90-pp.f90 -[127/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/stzxyz_m.F90-pp.f90 -[128/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/bfield_m.F90-pp.f90 -[129/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/hesian_m.F90-pp.f90 -[130/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/jo00aa_m.F90-pp.f90 -[131/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/pp00aa_m.F90-pp.f90 -[132/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/ra00aa_m.F90-pp.f90 -[133/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/numrec_m.F90-pp.f90 -[134/200] Building Fortran preprocessed src/CMakeFiles/xspec.dir/mxspech_m.F90-pp.f90 -[135/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ra00aa_m.F90 -[136/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/bndRep_m.F90-pp.f90 -[137/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/inputlist_m.F90-pp.f90 -[138/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/mxspech_m.F90-pp.f90 -[139/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90 -[140/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90 -[141/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsmat_m.F90 -[142/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90 -[143/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/volume_m.F90 -[144/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/stzxyz_m.F90 -[145/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90 -[146/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/preset_m.F90-pp.f90 -[147/200] Preprocessing /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90 -[148/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/msphdf5_m.F90-pp.f90 -[149/200] Building Fortran preprocessed src/CMakeFiles/spec.dir/global_m.F90-pp.f90 -[150/200] Generating Fortran dyndep file src/CMakeFiles/spec.dir/Fortran.dd -[151/200] Building Fortran object src/CMakeFiles/spec.dir/inputlist_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90:321:89: - - 321 | !<
  • if \c iprecon = 0, the preconditioner is `N'
  • - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90:322:89: - - 322 | !<
  • if \c iprecon = 1, the preconditioner is `J'
  • - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/inputlist_m.F90:323:89: - - 323 | !<
  • if \c iprecon = 2, the preconditioner is `S'
  • - | 1 -Warning: missing terminating ' character -[152/200] Building Fortran object src/CMakeFiles/spec.dir/global_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90:369:107: - - 369 | real(8), allocatable :: irhoc(:,:) !< rhomn harmonics of interface surface geometry, using Henneberg's representation - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/global_m.F90:370:108: - - 370 | real(8), allocatable :: ibc(:,:) !< bn harmonics of interface surface geometry, using Henneberg's representation - | 1 -Warning: missing terminating ' character -[153/200] Building Fortran object src/CMakeFiles/spec.dir/manual_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:113:26: - - 113 | !latex i.e., adjust $\mu$'s, fluxes and/or rotational transform to obtain desired current profile (without singular currents). - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:150:24: - - 150 | !latex \item The `polar' coordinate transformation, - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:222:50: - - 222 | !latex we shall introduce a `regularization' factor, $\rho^{m/2} = r^m$. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/manual_m.F90:255:22: - - 255 | !l tex The `$?$' symbol indicates that there is no boundary condition, and $\Delta\psi_{p,1}$ is the magnetic flux linking the torus: - | 1 -Warning: missing terminating ' character -[154/200] Building Fortran object src/CMakeFiles/spec.dir/packxi_m.F90.o -[155/200] Building Fortran object src/CMakeFiles/spec.dir/lbpol_m.F90.o -[156/200] Building Fortran object src/CMakeFiles/spec.dir/basefn_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:156:34: - - 156 | rm = one ! r to the power of m'th - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:157:37: - - 157 | rm1 = zero ! r to the power of m-1'th - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:220:71: - - 220 | real(8) :: rm, rm1, rm2 ! r to the power of m'th, m-1'th and m-2'th - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:224:34: - - 224 | rm = one ! r to the power of m'th - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:225:37: - - 225 | rm1 = zero ! r to the power of m-1'th - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/basefn_m.F90:226:37: - - 226 | rm2 = zero ! r to the power of m-2'th - | 1 -Warning: missing terminating ' character -[157/200] Building Fortran object src/CMakeFiles/spec.dir/curent_m.F90.o -[158/200] Building Fortran object src/CMakeFiles/spec.dir/brcast_m.F90.o -[159/200] Building Fortran object src/CMakeFiles/spec.dir/df00ab_m.F90.o -[160/200] Building Fortran object src/CMakeFiles/spec.dir/dfp100_m.F90.o -[161/200] Building Fortran object src/CMakeFiles/spec.dir/bnorml_m.F90.o -[162/200] Building Fortran object src/CMakeFiles/spec.dir/metrix_m.F90.o -[163/200] Building Fortran object src/CMakeFiles/spec.dir/pp00ab_m.F90.o -[164/200] Building Fortran object src/CMakeFiles/spec.dir/volume_m.F90.o -[165/200] Building Fortran object src/CMakeFiles/spec.dir/stzxyz_m.F90.o -[166/200] Building Fortran object src/CMakeFiles/spec.dir/numrec_m.F90.o -[167/200] Building Fortran object src/CMakeFiles/spec.dir/ma02aa_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90:1392:39: - - 1392 | ; ; iflag = 1 !(we don't need derivatives) - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/ma02aa_m.F90:1394:39: - - 1394 | ; ; iflag = 1 !(we don't need derivatives) ; - | 1 -Warning: missing terminating ' character -[168/200] Building Fortran object src/CMakeFiles/spec.dir/packab_m.F90.o -[169/200] Building Fortran object src/CMakeFiles/spec.dir/tr00ab_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/tr00ab_m.F90:1055:18: - - 1055 | ! for safety, let's assume that the following NAG routines will destroy the provided matrices, so better keep a backup; 24 Apr 13; - | 1 -Warning: missing terminating ' character -[170/200] Building Fortran object src/CMakeFiles/spec.dir/lforce_m.F90.o -[171/200] Building Fortran object src/CMakeFiles/spec.dir/casing_m.F90.o -[172/200] Building Fortran object src/CMakeFiles/spec.dir/hesian_m.F90.o -[173/200] Building Fortran object src/CMakeFiles/spec.dir/mp00ac_m.F90.o -[174/200] Building Fortran object src/CMakeFiles/spec.dir/bndRep_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90:2595:78: - - 2595 | if( (jj.le.2*Ntor+1) .and. (jj.gt.0) ) then !Check that indices don't overflow in over elements - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/bndRep_m.F90:2602:78: - - 2602 | if( (jj.le.2*Ntor+1) .and. (jj.gt.0) ) then !Check that indices don't overflow in over elements - | 1 -Warning: missing terminating ' character -[175/200] Building Fortran object src/CMakeFiles/spec.dir/bfield_m.F90.o -[176/200] Building Fortran object src/CMakeFiles/spec.dir/mtrxhs_m.F90.o -[177/200] Building Fortran object src/CMakeFiles/spec.dir/spsint_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/spsint_m.F90:237:40: - - 237 | if (mi .gt. 0) cycle ! we don't nee to compute more than m>0 - | 1 -Warning: missing terminating ' character -[178/200] Building Fortran object src/CMakeFiles/spec.dir/dfp200_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90:1232:84: - - 1232 | if( IsMyVolumeValue.EQ.0 ) then ! This CPU does not deal with interface's inner volume - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90:1261:88: - - 1261 | if( IsMyVolumeValue.eq.0 ) then ! This CPU does not deal with interface's outer volume either - cycle - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dfp200_m.F90:3541:34: - - 3541 | ! one step Newton's method - | 1 -Warning: missing terminating ' character -[179/200] Building Fortran object src/CMakeFiles/spec.dir/intghs_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:33:71: - - 33 | !latex \be \verb+DToocc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \cos\a_i \cos\a_j \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:34:71: - - 34 | !latex \verb+DToocs(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \cos\a_i \sin\a_j \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:35:71: - - 35 | !latex \verb+DToosc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \sin\a_i \cos\a_j \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:36:71: - - 36 | !latex \verb+DTooss(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i}' \; \bT{p,j} \; \ooint \sin\a_i \sin\a_j - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:45:84: - - 45 | !latex \be \verb+TDstcc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \cos\a_j \; \bar g_{\s\t} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:46:84: - - 46 | !latex \verb+TDstcs(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \sin\a_j \; \bar g_{\s\t} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:47:84: - - 47 | !latex \verb+TDsTsc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \cos\a_j \; \bar g_{\s\t} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:48:84: - - 48 | !latex \verb+TDsTss(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \sin\a_j \; \bar g_{\s\t} - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:51:84: - - 51 | !latex \be \verb+TDstcc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \cos\a_j \; \bar g_{\s\z} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:52:84: - - 52 | !latex \verb+TDstcs(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \cos\a_i \sin\a_j \; \bar g_{\s\z} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:53:84: - - 53 | !latex \verb+TDsTsc(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \cos\a_j \; \bar g_{\s\z} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/intghs_m.F90:54:84: - - 54 | !latex \verb+TDsTss(l,p,i,j)+ & \equiv & \int ds \; \bT{l,i} \; \bT{p,j}' \; \ooint \sin\a_i \sin\a_j \; \bar g_{\s\z} - | 1 -Warning: missing terminating ' character -[180/200] Building Fortran object src/CMakeFiles/spec.dir/spsmat_m.F90.o -[181/200] Building Fortran object src/CMakeFiles/spec.dir/jo00aa_m.F90.o -[182/200] Building Fortran object src/CMakeFiles/spec.dir/ma00aa_m.F90.o -[183/200] Building Fortran object src/CMakeFiles/spec.dir/memory_m.F90.o -[184/200] Building Fortran object src/CMakeFiles/spec.dir/matrix_m.F90.o -[185/200] Building Fortran object src/CMakeFiles/spec.dir/coords_m.F90.o -[186/200] Building Fortran object src/CMakeFiles/spec.dir/msphdf5_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:14489:70: - -14489 | integer(size_t) :: offset !< Member's offset - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:19928:121: - -19928 | !latex \type{irhoc(1:mn_rho,1:Mvol)} & real & \pb{Fourier harmonics, $\rho_{m,n}$, of interfaces using Henneberg's representation} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:20007:110: - -20007 | !latex \type{ibc(0:Ntor,1:Mvol)} & real & \pb{Fourier harmonics, $b_n$, of interfaces using Henneberg's representation} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:20086:114: - -20086 | !latex \type{iR0c(0:Ntor,1:Mvol)} & real & \pb{Fourier harmonics, $R_{0n}$, of interfaces using Henneberg's representation} \\ - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/msphdf5_m.F90:20165:114: - -20165 | !latex \type{iZ0s(0:Ntor,1:Mvol)} & real & \pb{Fourier harmonics, $Z_{0n}$, of interfaces using Henneberg's representation} \\ - | 1 -Warning: missing terminating ' character -[187/200] Building Fortran object src/CMakeFiles/spec.dir/pp00aa_m.F90.o -[188/200] Building Fortran object src/CMakeFiles/spec.dir/ra00aa_m.F90.o -[189/200] Building Fortran object src/CMakeFiles/spec.dir/newton_m.F90.o -[190/200] Building Fortran object src/CMakeFiles/spec.dir/mxspech_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90:134:75: - - 134 | !>
  • All quantities in the input file are mirrored into the output file's group \c /input .
  • - | 1 -Warning: missing terminating ' character -[191/200] Building Fortran object src/CMakeFiles/spec.dir/rzaxis_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:681:23: - - 681 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:683:23: - - 683 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:689:23: - - 689 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:691:23: - - 691 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:711:23: - - 711 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:713:23: - - 713 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:715:23: - - 715 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:717:23: - - 717 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:721:23: - - 721 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:723:23: - - 723 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:725:23: - - 725 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:727:23: - - 727 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:736:23: - - 736 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:738:23: - - 738 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:740:23: - - 740 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:742:23: - - 742 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:746:23: - - 746 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:748:23: - - 748 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:750:23: - - 750 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:752:23: - - 752 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:942:33: - - 942 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:944:33: - - 944 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:950:33: - - 950 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:952:33: - - 952 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:970:33: - - 970 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:972:33: - - 972 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:974:33: - - 974 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:976:33: - - 976 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:980:33: - - 980 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:982:33: - - 982 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:984:33: - - 984 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:986:33: - - 986 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:994:33: - - 994 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:996:33: - - 996 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:998:33: - - 998 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1000:33: - - 1000 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1004:33: - - 1004 | ! the DRcn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1006:33: - - 1006 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1008:33: - - 1008 | ! the DRsn' term - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/rzaxis_m.F90:1010:33: - - 1010 | ! the DZsn' term - | 1 -Warning: missing terminating ' character -[192/200] Building Fortran object src/CMakeFiles/spec.dir/dforce_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:502:26: - - 502 | ! one step Newton's method - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:2178:60: - - 2178 | LComputeAxis, nDcalls) - | 1 -Warning: More actual than formal arguments in procedure call at (1) -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:2757:128: - - 2757 | call dforce( NGdof_field, iposition(isymdiff,0:NGdof_field), iforce(isymdiff,0:NGdof_force), .false., LComputeAxis, nDcalls) - | 1 -Warning: More actual than formal arguments in procedure call at (1) -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/dforce_m.F90:2889:128: - - 2889 | call dforce( NGdof_field, iposition(isymdiff,0:NGdof_field), iforce(isymdiff,0:NGdof_force), .false., LComputeAxis, nDcalls) - | 1 -Warning: More actual than formal arguments in procedure call at (1) -[193/200] Building Fortran object src/CMakeFiles/spec.dir/preset_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:242:21: - - 242 | ! set up Henneberg's mapping - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3489:61: - - 3489 | ! We use the basis combination for m=0 and 1. They don't have ll=0 component. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3512:66: - - 3512 | ! Lme is for B.n at the outer boundary cos component. We don't have it for m=n=0. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3533:39: - - 3533 | ! This is not true using Henneberg's representation - Fourier truncation is different. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3558:102: - - 3558 | ! We use basis recombination method to ensure the inner boundary has At=Az=0. Therefore they don't have ll=0 component. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:3573:66: - - 3573 | ! Lme is for B.n at the outer boundary cos component. We don't have it for m=n=0. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:6562:44: - - 6562 | !>
  • If \c Lboundary equals 1 (Henneberg's representation), then psifactor=1. - | 1 -Warning: missing terminating ' character -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/preset_m.F90:7542:30: - - 7542 | ! Map back to Henneberg's representation - | 1 -Warning: missing terminating ' character -[194/200] Linking Fortran static library build/lib/libspec.a -[195/200] Generating Fortran dyndep file src/CMakeFiles/xspec.dir/Fortran.dd -[196/200] Building Fortran object src/CMakeFiles/xspec.dir/mxspech_m.F90.o -/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/src/mxspech_m.F90:134:75: - - 134 | !>
  • All quantities in the input file are mirrored into the output file's group \c /input .
  • - | 1 -Warning: missing terminating ' character -[197/200] Linking Fortran executable build/bin/xspec -FAILED: build/bin/xspec -: && /misc/Anaconda3/envs/spec_env/bin/mpif90 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/misc/Anaconda3/envs/spec_env/lib -Wl,-rpath-link,/misc/Anaconda3/envs/spec_env/lib -L/misc/Anaconda3/envs/spec_env/lib -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /misc/Anaconda3/envs/spec_env/include -O3 -DNDEBUG -O3 src/CMakeFiles/xspec.dir/mxspech_m.F90.o -o build/bin/xspec build/lib/libspec.a /misc/Anaconda3/envs/spec_env/lib/libhdf5_fortran.so /misc/Anaconda3/envs/spec_env/lib/libhdf5.so /misc/Anaconda3/envs/spec_env/lib/libfftw3.so /misc/Anaconda3/envs/spec_env/lib/libfftw3f.so /misc/Anaconda3/envs/spec_env/lib/libfftw3l.so /misc/Anaconda3/envs/spec_env/lib/libfftw3_threads.so /misc/Anaconda3/envs/spec_env/lib/libfftw3f_threads.so /misc/Anaconda3/envs/spec_env/lib/libfftw3l_threads.so /misc/Anaconda3/envs/spec_env/lib/libfftw3_omp.so /misc/Anaconda3/envs/spec_env/lib/libfftw3f_omp.so /misc/Anaconda3/envs/spec_env/lib/libfftw3l_omp.so /misc/Anaconda3/envs/spec_env/lib/libopenblas.so && : -/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: src/CMakeFiles/xspec.dir/mxspech_m.F90.o: in function `spec_': -mxspech_m.F90:(.text.spec_+0x27b0): undefined reference to `wrtend_' -/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: src/CMakeFiles/xspec.dir/mxspech_m.F90.o: in function `xspech_': -mxspech_m.F90:(.text.xspech_+0x7ae): undefined reference to `wrtend_' -/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: mxspech_m.F90:(.text.xspech_+0x7bb): undefined reference to `wrtend_' -/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: build/lib/libspec.a(newton_m.F90.o): in function `fcn1_': -newton_m.F90:(.text.fcn1_+0xe9b): undefined reference to `wrtend_' -/misc/Anaconda3/envs/spec_env/bin/../lib/gcc/x86_64-conda-linux-gnu/9.4.0/../../../../x86_64-conda-linux-gnu/bin/ld: build/lib/libspec.a(newton_m.F90.o): in function `fcn2_': -newton_m.F90:(.text.fcn2_+0x1189): undefined reference to `wrtend_' -collect2: error: ld returned 1 exit status -[198/200] /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mxspech_m_fpp.F90 -Kind map (also saved to .f2py_f2cmap) -{'complex': {'': 'complex_float', - '16': 'complex_long_double', - '8': 'complex_double', - 'c_double_complex': 'complex_double', - 'dp': 'complex_double'}, - 'integer': {'': 'long_long', - '4': 'int', - '8': 'long_long', - 'dp': 'long_long', - 'hid_t': 'long_long', - 'hsize_t': 'long_long', - 'size_t': 'long_long'}, - 'real': {'': 'double', - '4': 'float', - '8': 'double', - 'dp': 'double', - 'idp': 'double', - 'isp': 'float'}} - -Constructors: -('initialise_ptr', 'initialise', 'allocate') - -Destructors: -('finalise', 'deallocate') - -Short names for derived types: -{} - -String lengths: -{} - -Initialisation lines for derived types -{} - -Python module name remapping -{} -Class names remapping -{} - -Argument name map: -{} - -Size of Fortran derived type pointers is 2 bytes. - -Parsing Fortran source files ['/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/manual_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/rzaxis_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packxi_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/volume_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/coords_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/basefn_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/memory_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/metrix_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/matrix_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsmat_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/spsint_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mp00ac_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ma02aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/packab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/tr00ab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/curent_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/df00ab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lforce_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/intghs_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mtrxhs_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/lbpol_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/brcast_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp100_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dfp200_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/dforce_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/newton_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/casing_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bnorml_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/jo00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/pp00ab_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bfield_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/stzxyz_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/hesian_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/ra00aa_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/numrec_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/preset_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/bndRep_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/global_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/inputlist_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/msphdf5_m_fpp.F90', '/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/mxspech_m_fpp.F90'] ... -INFO:f90wrap.parser:parser reading type intghs_workspace -INFO:f90wrap.parser:marking module bndRep as default public -INFO:f90wrap.parser:parser reading type subgrid -INFO:f90wrap.parser:parser reading type MatrixLU -INFO:f90wrap.parser:parser reading type derivative -done parsing source. - -Derived types detected in Fortran source files: -{'class(derivative)': Type(name=derivative), - 'class(intghs_workspace)': Type(name=intghs_workspace), - 'class(matrixlu)': Type(name=matrixlu), - 'class(subgrid)': Type(name=subgrid), - 'derivative': Type(name=derivative), - 'intghs_workspace': Type(name=intghs_workspace), - 'matrixlu': Type(name=matrixlu), - 'subgrid': Type(name=subgrid), - 'type(derivative)': Type(name=derivative), - 'type(intghs_workspace)': Type(name=intghs_workspace), - 'type(matrixlu)': Type(name=matrixlu), - 'type(subgrid)': Type(name=subgrid)} - -Class name mapping: -{'class(derivative)': 'derivative', - 'class(intghs_workspace)': 'intghs_workspace', - 'class(matrixlu)': 'MatrixLU', - 'class(subgrid)': 'subgrid', - 'derivative': 'derivative', - 'intghs_workspace': 'intghs_workspace', - 'matrixlu': 'MatrixLU', - 'subgrid': 'subgrid', - 'type(derivative)': 'derivative', - 'type(intghs_workspace)': 'intghs_workspace', - 'type(matrixlu)': 'MatrixLU', - 'type(subgrid)': 'subgrid'} -Modules for each type: -{'intghs_module': 'intghs_module', 'typedefns': 'typedefns'} -WARNING:f90wrap.transform:removing intghs_module.wk as missing "target" attribute -WARNING:f90wrap.transform:removing allglobal.ate as missing "target" attribute -WARNING:f90wrap.transform:removing allglobal.aze as missing "target" attribute -WARNING:f90wrap.transform:removing allglobal.ato as missing "target" attribute -WARNING:f90wrap.transform:removing allglobal.azo as missing "target" attribute -WARNING:f90wrap.transform:removing allglobal.dbdx as missing "target" attribute -WARNING:f90wrap.transform:removing fftw_interface.planf as type(c_ptr) unsupported -WARNING:f90wrap.transform:removing fftw_interface.planb as type(c_ptr) unsupported -INFO:f90wrap.transform:adding missing constructor for intghs_workspace -INFO:f90wrap.transform:adding missing constructor for subgrid -INFO:f90wrap.transform:adding missing constructor for matrixlu -INFO:f90wrap.transform:adding missing constructor for derivative -INFO:f90wrap.transform:adding missing destructor for intghs_workspace -INFO:f90wrap.transform:adding missing destructor for subgrid -INFO:f90wrap.transform:adding missing destructor for matrixlu -INFO:f90wrap.transform:adding missing destructor for derivative -INFO:f90wrap.transform:visiting Module(name=intghs_module) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Type(name=intghs_workspace) found 1 constructors with names: ['intghs_workspace_initialise'] -INFO:f90wrap.transform:visiting Module(name=newtontime) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=bndrep) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=constants) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=numerical) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=fileunits) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=cputiming) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=typedefns) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Type(name=subgrid) found 1 constructors with names: ['subgrid_initialise'] -INFO:f90wrap.transform:visiting Type(name=matrixlu) found 1 constructors with names: ['matrixlu_initialise'] -INFO:f90wrap.transform:visiting Type(name=derivative) found 1 constructors with names: ['derivative_initialise'] -INFO:f90wrap.transform:visiting Module(name=allglobal) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=fftw_interface) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=inputlist) found 0 constructors with names: [] -INFO:f90wrap.transform:visiting Module(name=sphdf5) found 0 constructors with names: [] -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module intghs_module -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type intghs_workspace -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_initialise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_finalise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module newtontime -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module bndrep -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine initialize_mapping -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine change_mapping_angle -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine forwardmap -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine backwardmap -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine initialize_force_gradient_transformation -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pack_henneberg_to_hudson -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pack_hudson_to_henneberg -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pack_rhomn_bn -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine build_mapping_matrices -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine change_angle -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine find_index -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module constants -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module numerical -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module fileunits -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mute -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module cputiming -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module typedefns -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type subgrid -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine subgrid_initialise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine subgrid_finalise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type matrixlu -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrixlu_initialise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrixlu_finalise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting type derivative -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine derivative_initialise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine derivative_finalise -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module allglobal -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine build_vector_potential -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine set_mpi_comm -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_inputlists_from_file -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine check_inputs -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine broadcast_inputs -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ismyvolume -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine whichcpuid -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module fftw_interface -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module inputlist -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine initialize_inputs -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting module sphdf5 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine init_outfile -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mirror_input_to_outfile -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine init_convergence_output -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_convergence_output -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_grid -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine init_flt_output -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_poincare -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_transform -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine finalize_flt_output -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine write_vector_potential -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine hdfint -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine finish_outfile -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine manual -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine rzaxis -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fndiff_rzaxis -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine packxi -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine volume -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine coords -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_cheby -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_cheby_d2 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_zernike -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_zernike_d2 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_zernike_rm -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine allocate_beltrami_matrices -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine deallocate_beltrami_matrices -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine allocate_geometry_matrices -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine deallocate_geometry_matrices -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine metrix -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine compute_guvijsave -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ma00aa -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrix -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matrixbg -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine spsmat -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine push_back -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine clean_queue -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine addline -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine spsint -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mp00ac -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine rungmres -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine matvec -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine prec_solve -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ma02aa -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine packab -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine tr00ab -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine curent -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine df00ab -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine lforce -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_init -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine intghs_workspace_destroy -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine mtrxhs -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine lbpol -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine brcast -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dfp100 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dfp200 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_lu_beltrami_matrices -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine get_perturbed_solution -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine evaluate_dmupfdx -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine evaluate_dbb -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dforce -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fndiff_dforce -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine newton -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine writereadgf -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fcn1 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine fcn2 -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine casing -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine dvcfield -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine bnorml -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine jo00aa -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pp00aa -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine pp00ab -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine bfield -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine bfield_tangent -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine stzxyz -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine hesian -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ra00aa -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine gi00ab -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine getimn -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine tfft -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine invfft -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine gauleg -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine preset -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine set_global_variables -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_input_geometry -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_hudson_input_geometry -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_henneberg_input_geometry -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine interpolate_initial_guess -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine check_and_change_angle -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine xspech -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine read_command_args -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine spec -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine final_diagnostics -INFO:f90wrap.pywrapgen:PythonWrapperGenerator visiting routine ending -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module intghs_module -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type intghs_workspace -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_initialise call_name intghs_workspace_initialise mod_name 'intghs_module' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_finalise call_name intghs_workspace_finalise mod_name 'intghs_module' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module newtontime -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module bndrep -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine initialize_mapping call_name initialize_mapping mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine change_mapping_angle call_name change_mapping_angle mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine forwardmap call_name forwardMap mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine backwardmap call_name backwardMap mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine initialize_force_gradient_transformation call_name initialize_force_gradient_transformation mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pack_henneberg_to_hudson call_name pack_henneberg_to_hudson mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pack_hudson_to_henneberg call_name pack_hudson_to_henneberg mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pack_rhomn_bn call_name pack_rhomn_bn mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine build_mapping_matrices call_name build_mapping_matrices mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine change_angle call_name change_angle mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine find_index call_name find_index mod_name 'bndrep' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module constants -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module numerical -/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/f90wrap/f90wrapgen.py:139: UserWarning: Source file /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build/Utilities/python_wrapper/global_m_fpp.F90 contains code for more than one module! - warnings.warn('Source file %s contains code for more than one module!' % node.filename) -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module fileunits -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mute call_name mute mod_name 'fileunits' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module cputiming -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module typedefns -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type subgrid -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine subgrid_initialise call_name subgrid_initialise mod_name 'typedefns' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine subgrid_finalise call_name subgrid_finalise mod_name 'typedefns' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type matrixlu -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrixlu_initialise call_name matrixlu_initialise mod_name 'typedefns' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrixlu_finalise call_name matrixlu_finalise mod_name 'typedefns' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting type derivative -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine derivative_initialise call_name derivative_initialise mod_name 'typedefns' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine derivative_finalise call_name derivative_finalise mod_name 'typedefns' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module allglobal -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine build_vector_potential call_name build_vector_potential mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine set_mpi_comm call_name set_mpi_comm mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_inputlists_from_file call_name read_inputlists_from_file mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine check_inputs call_name check_inputs mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine broadcast_inputs call_name broadcast_inputs mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ismyvolume call_name IsMyVolume mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine whichcpuid call_name WhichCpuID mod_name 'allglobal' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module fftw_interface -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module inputlist -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine initialize_inputs call_name initialize_inputs mod_name 'inputlist' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting module sphdf5 -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine init_outfile call_name init_outfile mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mirror_input_to_outfile call_name mirror_input_to_outfile mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine init_convergence_output call_name init_convergence_output mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_convergence_output call_name write_convergence_output mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_grid call_name write_grid mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine init_flt_output call_name init_flt_output mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_poincare call_name write_poincare mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_transform call_name write_transform mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine finalize_flt_output call_name finalize_flt_output mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine write_vector_potential call_name write_vector_potential mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine hdfint call_name hdfint mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine finish_outfile call_name finish_outfile mod_name 'sphdf5' -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine manual call_name manual mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine rzaxis call_name rzaxis mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fndiff_rzaxis call_name fndiff_rzaxis mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine packxi call_name packxi mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine volume call_name volume mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine coords call_name coords mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_cheby call_name get_cheby mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_cheby_d2 call_name get_cheby_d2 mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_zernike call_name get_zernike mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_zernike_d2 call_name get_zernike_d2 mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_zernike_rm call_name get_zernike_rm mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine allocate_beltrami_matrices call_name allocate_Beltrami_matrices mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine deallocate_beltrami_matrices call_name deallocate_Beltrami_matrices mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine allocate_geometry_matrices call_name allocate_geometry_matrices mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine deallocate_geometry_matrices call_name deallocate_geometry_matrices mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine metrix call_name metrix mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine compute_guvijsave call_name compute_guvijsave mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ma00aa call_name ma00aa mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrix call_name matrix mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matrixbg call_name matrixBG mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine spsmat call_name spsmat mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine push_back call_name push_back mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine clean_queue call_name clean_queue mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine addline call_name addline mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine spsint call_name spsint mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mp00ac call_name mp00ac mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine rungmres call_name rungmres mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine matvec call_name matvec mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine prec_solve call_name prec_solve mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ma02aa call_name ma02aa mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine packab call_name packab mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine tr00ab call_name tr00ab mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine curent call_name curent mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine df00ab call_name df00ab mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine lforce call_name lforce mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs call_name intghs mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_init call_name intghs_workspace_init mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine intghs_workspace_destroy call_name intghs_workspace_destroy mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine mtrxhs call_name mtrxhs mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine lbpol call_name lbpol mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine brcast call_name brcast mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dfp100 call_name dfp100 mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dfp200 call_name dfp200 mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_lu_beltrami_matrices call_name get_LU_beltrami_matrices mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine get_perturbed_solution call_name get_perturbed_solution mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine evaluate_dmupfdx call_name evaluate_dmupfdx mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine evaluate_dbb call_name evaluate_dBB mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dforce call_name dforce mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fndiff_dforce call_name fndiff_dforce mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine newton call_name newton mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine writereadgf call_name writereadgf mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fcn1 call_name fcn1 mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine fcn2 call_name fcn2 mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine casing call_name casing mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine dvcfield call_name dvcfield mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine bnorml call_name bnorml mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine jo00aa call_name jo00aa mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pp00aa call_name pp00aa mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine pp00ab call_name pp00ab mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine bfield call_name bfield mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine bfield_tangent call_name bfield_tangent mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine stzxyz call_name stzxyz mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine hesian call_name hesian mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ra00aa call_name ra00aa mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine gi00ab call_name gi00ab mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine getimn call_name getimn mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine tfft call_name tfft mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine invfft call_name invfft mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine gauleg call_name gauleg mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine preset call_name preset mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine set_global_variables call_name set_global_variables mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_input_geometry call_name read_input_geometry mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_hudson_input_geometry call_name read_hudson_input_geometry mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_henneberg_input_geometry call_name read_henneberg_input_geometry mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine interpolate_initial_guess call_name interpolate_initial_guess mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine check_and_change_angle call_name check_and_change_angle mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine xspech call_name xspech mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine read_command_args call_name read_command_args mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine spec call_name spec mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine final_diagnostics call_name final_diagnostics mod_name None -INFO:f90wrap.f90wrapgen:F90WrapperGenerator visiting routine ending call_name ending mod_name None -ninja: build stopped: subcommand failed. -system.platform is linux -CMAKE_ARGS = '-DCMAKE_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ar -DCMAKE_CXX_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_C_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ranlib -DCMAKE_CXX_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_C_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_LINKER=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ld -DCMAKE_STRIP=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-strip' - - --------------------------------------------------------------------------------- --- Trying "Ninja" generator --------------------------------- ---------------------------- ----------------------- ------------------ ------------- -------- --- --- -------- ------------- ------------------ ----------------------- ---------------------------- --------------------------------- --- Trying "Ninja" generator - success --------------------------------------------------------------------------------- - -Configuring Project - Working directory: - /home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-build - Command: - cmake /home/abaillod/SPEC -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/home/abaillod/SPEC/_skbuild/linux-x86_64-3.10/cmake-install -DPYTHON_EXECUTABLE:FILEPATH=/misc/Anaconda3/envs/spec_env/bin/python -DPYTHON_VERSION_STRING:STRING=3.10.2 -DPYTHON_INCLUDE_DIR:PATH=/misc/Anaconda3/envs/spec_env/include/python3.10 -DPYTHON_LIBRARY:FILEPATH=/misc/Anaconda3/envs/spec_env/lib/libpython3.10.so -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/skbuild/resources/cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_Fortran_COMPILER=mpif90 -DBLA_VENDOR=OpenBLAS -DCMAKE_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ar -DCMAKE_CXX_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_C_COMPILER_AR=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ar -DCMAKE_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ranlib -DCMAKE_CXX_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_C_COMPILER_RANLIB=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-gcc-ranlib -DCMAKE_LINKER=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-ld -DCMAKE_STRIP=/misc/Anaconda3/envs/spec_env/bin/x86_64-conda-linux-gnu-strip -DCMAKE_C_FLAGS=-I/misc/Anaconda3/envs/spec_env/lib/python3.10/site-packages/numpy/core/include -DCMAKE_BUILD_TYPE:STRING=Release - -Traceback (most recent call last): - From 7633176c45574e624bc610fa68cb89ca042af634 Mon Sep 17 00:00:00 2001 From: Jonathan Schilling Date: Fri, 25 Nov 2022 12:43:11 +0100 Subject: [PATCH 034/134] try to fix cmake compile error --- .github/workflows/build_cmake.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 138c42ca..7f02be10 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -16,6 +16,7 @@ jobs: uses: actions/checkout@master - name: Install prereqs run: | + pip3 install skbuild # prereq for ninja (it seems) pip3 install ninja cmake yum install -y hdf5-static - name: Build & Test From 6a1384a5aded8d4ae8e573eb7edb79bb9f72ce9e Mon Sep 17 00:00:00 2001 From: Jonathan Schilling Date: Fri, 25 Nov 2022 12:46:55 +0100 Subject: [PATCH 035/134] skbuild is called scikit-build on pip --- .github/workflows/build_cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 7f02be10..76d86a5b 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@master - name: Install prereqs run: | - pip3 install skbuild # prereq for ninja (it seems) + pip3 install scikit-build # prereq for cmake (it seems) pip3 install ninja cmake yum install -y hdf5-static - name: Build & Test From 3a23ae65bf9c6b829101be10e5dceee06fb1256e Mon Sep 17 00:00:00 2001 From: Jonathan Schilling Date: Fri, 25 Nov 2022 12:50:20 +0100 Subject: [PATCH 036/134] pip upgrade needed to get build deps? --- .github/workflows/build_cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 76d86a5b..1888627d 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -16,7 +16,7 @@ jobs: uses: actions/checkout@master - name: Install prereqs run: | - pip3 install scikit-build # prereq for cmake (it seems) + pip3 install --upgrade pip pip3 install ninja cmake yum install -y hdf5-static - name: Build & Test From dbe882deb2e16270a74ed5c5de56b37125a7b163 Mon Sep 17 00:00:00 2001 From: Salomon Guinchard <48314085+salomon73@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:44:39 +0100 Subject: [PATCH 037/134] Change comments language --- Utilities/BoozerXForms/init_from_spec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/BoozerXForms/init_from_spec.py b/Utilities/BoozerXForms/init_from_spec.py index 7d356572..3a4ef542 100644 --- a/Utilities/BoozerXForms/init_from_spec.py +++ b/Utilities/BoozerXForms/init_from_spec.py @@ -119,7 +119,7 @@ def init_from_spec( filename ): ########################################################## - # initialisation de l'instance b de la classe booz_xform # + # Initialisation of a Booz_xform instance b # ########################################################## b = bx.Booz_xform() From 96766168a4d36a4dc47538f4889a635989428371 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 30 Dec 2022 08:37:43 +0100 Subject: [PATCH 038/134] Some additional python routines --- .../pythontools/py_spec/output/_processing.py | 94 ++++++++++++++++++- Utilities/pythontools/py_spec/output/spec.py | 4 +- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 8ff0a1ca..15ca689f 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -642,7 +642,7 @@ def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): tarr=tarr, zarr=zarr ) - et_x_ez = (R2*Z3)**2 + (R3*Z2)**2 + (R0*Z2)**2 + (R0*R2)**2 - 2*R2*R3*Z2*Z3 + et_x_ez = np.sqrt((R2*Z3)**2 + (R3*Z2)**2 + (R0*Z2)**2 + (R0*R2)**2 - 2*R2*R3*Z2*Z3) gtt = R2**2+Z2**2 gzz = R0**2 + R3**2 + Z3**2 @@ -676,7 +676,99 @@ def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): return j_dot_B, tarr, zarr +def get_surface(self, lsurf:int=None, nt:int=64, nz:int=64): + """Compute the surface area of a volume interface + + Args: + - lsurf: Interface number, between 1 and Mvol-1. + - nt: Number of poloidal points for integration, default is 64 + - nz: Number of toroidal points for integration, default is 64 + + Returns: + - S: the surface area + + Raises: + - ValueError: if input is wrong (invalid lsurf, nt<=0, nz<=0) + """ + + mvol = self.output.Mvol + nfp = self.input.physics.Nfp + if lsurf is None: + lsurf = np.arange(1,mvol) + + if mvol==1: + raise ValueError('Mvol=1; no interface current!') + if not isinstance(lsurf, np.ndarray): + raise ValueError('lsurf should be a np.ndarray') + if (lsurf<1).any() or (lsurf>mvol-1).any(): + raise ValueError('lsurf should be in [1,mvol-1]') + if nt<1: + raise ValueError('nt should greater than zero') + if nz<1: + raise ValueError('nz should greater than zero') + + # Construct grid + tarr = np.linspace(0, 2*np.pi, nt, endpoint=True) + zarr = np.linspace(0, 2*np.pi/nfp, nz, endpoint=True) + + # Create variable for storing the surface area + S = np.zeros((mvol-1,)) + + # Loop on interfaces + for s in lsurf: + # Construct geometry elements + R0, R1, R2, R3, Z0, Z1, Z2, Z3 = self.get_RZ_derivatives( + lvol=int(s-1), + sarr=np.asarray([1]), + tarr=tarr, + zarr=zarr + ) + #e theta x e phi + et_x_ez = np.sqrt((R2*Z3)**2 + (R3*Z2)**2 + (R0*Z2)**2 + (R0*R2)**2 - 2*R2*R3*Z2*Z3) + + S = nfp*integrate.simps(integrate.simps(et_x_ez,zarr,axis=2),tarr,axis=1) + + return S + +def get_flux_surface_average( self, lsurf, f, tarr, zarr ): + """Returns the flux surface average of a function f. + + For each surface lsurf, the average is made by computing the jacobian on the + inner side of the interface (i.e. lvol=lsurf-1, sarr=1) + + Args: + - lsurf (1D numpy array): Interface number, between 1 and Mvol-1 + - f (2D numpy array): function evaluated on a grid + - tgrid (2D numpy array): theta grid + - zgrid (2D numpy array): phi grid + + Returns> + - fsavg (1D numpy array): The flux surface average of f on each surface + given in lsurf + """ + + # Get jacobian + output = np.zeros(lsurf.shape) + for ii, ll in enumerate(lsurf): + sqrtg = self.jacobian( + lvol=ll-1, + sarr=np.array([1]), + tarr=tarr, + zarr=zarr + ) + + qrtg = np.squeeze(sqrtg) + + numerator = integrate.simps( + integrate.simps(np.multiply(f, qrtg), tarr, axis=0), zarr + ) + denumerator = integrate.simps( + integrate.simps(qrtg, tarr, axis=0), zarr + ) + + output[ii] = numerator / denumerator + return output diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index bd049f5f..99d06ca3 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -39,10 +39,12 @@ class SPECout: get_B_covariant, test_derivatives, get_surface_current_density, + get_surface, get_RZ_derivatives, get_volume, get_average_beta, - get_peak_beta + get_peak_beta, + get_flux_surface_average ) from ._plot_modB import plot_modB from ._plot_iota import plot_iota From 3b4c82e58f7e1d0d235e61eff6166072c87d560f Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 13 Jan 2023 10:39:17 +0100 Subject: [PATCH 039/134] update --- Utilities/pythontools/py_spec/output/_processing.py | 5 ++++- src/bfield.f90 | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 15ca689f..fd683ddf 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -552,7 +552,10 @@ def get_average_beta(self, ns=64, nt=64, nz=64): def get_peak_beta(self, ns=64, nt=64, nz=64): - press = self.input.physics.pressure[0] * self.input.physics.pscale + if self.input.physics.pressure.size>1: + press = self.input.physics.pressure[0] * self.input.physics.pscale + else: + press = self.input.physics.pressure * self.input.physics.pscale nfp = self.input.physics.Nfp tarr = np.linspace(0, 2*np.pi, nt) diff --git a/src/bfield.f90 b/src/bfield.f90 index f0d000a5..e9d0ea0e 100644 --- a/src/bfield.f90 +++ b/src/bfield.f90 @@ -166,7 +166,7 @@ subroutine bfield( zeta, st, Bst ) write(ounit,'("bfield : ",f10.2," : lvol=",i3," ; zeta="es23.15" ; (s,t)=("es23.15" ,"es23.15" ) ; B^z="es23.15" ;")') & cput-cpus, lvol, zeta, st(1:2), dBu(3) - FATAL( bfield, abs(dBu(3)).lt.vsmall, field is not toroidal ) + !FATAL( bfield, abs(dBu(3)).lt.vsmall, field is not toroidal ) endif From 4eaba4689a81160dc3a3ca52315ec6d730054d91 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 26 Jan 2023 18:37:35 +0100 Subject: [PATCH 040/134] small changes --- src/sphdf5.f90 | 1 + src/xspech.f90 | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sphdf5.f90 b/src/sphdf5.f90 index 43aca629..5f4d144f 100644 --- a/src/sphdf5.f90 +++ b/src/sphdf5.f90 @@ -365,6 +365,7 @@ subroutine mirror_input_to_outfile HWRITELV( grpInputDiagnostics, 1, LHevalues , (/ LHevalues /)) HWRITELV( grpInputDiagnostics, 1, LHevectors , (/ LHevectors /)) HWRITELV( grpInputDiagnostics, 1, LHmatrix , (/ LHmatrix /)) + HWRITELV( grpInputDiagnostics, 1, Ltransform , (/ Ltransform /)) HWRITEIV( grpInputDiagnostics, 1, Lperturbed , (/ Lperturbed /)) HWRITEIV( grpInputDiagnostics, 1, dpp , (/ dpp /)) HWRITEIV( grpInputDiagnostics, 1, dqq , (/ dqq /)) diff --git a/src/xspech.f90 b/src/xspech.f90 index 1e641b25..2d198525 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -770,7 +770,7 @@ end subroutine spec subroutine final_diagnostics use inputlist, only: nPtrj, nPpts, Igeometry, Lcheck, Nvol, odetol, & - Isurf, Ivolume, mu, Wmacros, Ltransform + Isurf, Ivolume, mu, Wmacros, Ltransform, Lsvdiota use fileunits, only: ounit use constants, only: zero use allglobal, only: pi2, myid, ncpu, MPI_COMM_SPEC, cpus, Mvol, Ntz, mn, & @@ -838,6 +838,8 @@ subroutine final_diagnostics ! Evaluate rotational transform and straight field line coordinate transformation if( Ltransform ) then + FATAL(xspech, Lsvdiota.ne.1, Lsvdiota needs to be one for s.f.l transformation) + do vvol=1,Mvol call brcast(vvol) enddo From 737204b16626f2b20d6a63b47bb0f65e440f3a0d Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 3 Feb 2023 12:05:02 +0100 Subject: [PATCH 041/134] solved bug in pyspec --- Utilities/pythontools/py_spec/output/_processing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index fd683ddf..5ad85a7d 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -574,7 +574,7 @@ def get_peak_beta(self, ns=64, nt=64, nz=64): return 2 * nfp * press * integrate.simpson( y=integrate.simpson( y=integrate.simpson( - y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) + y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) / vol def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): From f13eda43864ea30ba23f680927ba0657ba6c654f Mon Sep 17 00:00:00 2001 From: Caoxiang Zhu Date: Wed, 8 Feb 2023 19:17:11 +0800 Subject: [PATCH 042/134] try to fix scipy error --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6e47299..80321c26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,9 @@ jobs: steps: - name: checkout sources uses: actions/checkout@master + - name: install scipy + run: | + pip3 install scipy - name: compile_xspec run: | cd ${SPEC_PATH} From de4039593cc67808cdffbd6662d3c2d05013423f Mon Sep 17 00:00:00 2001 From: Ke Liu Date: Thu, 9 Feb 2023 02:17:24 +0000 Subject: [PATCH 043/134] Update spec_namelist.py When reading interface guess, `continue` should be used instead of `break` if the empty lines should be ignored. --- Utilities/pythontools/py_spec/input/spec_namelist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/input/spec_namelist.py b/Utilities/pythontools/py_spec/input/spec_namelist.py index 9b843796..7187b465 100644 --- a/Utilities/pythontools/py_spec/input/spec_namelist.py +++ b/Utilities/pythontools/py_spec/input/spec_namelist.py @@ -596,7 +596,7 @@ def _read_interface_guess(self, file_object): # ignore empty lines if len(line_split) == 0: - break + continue # check if this line meet our expectation valid_line = True From 8f82edb93b72b484b50722554258ecc2503246fe Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 9 Feb 2023 17:20:55 +0100 Subject: [PATCH 044/134] fix Btemn output issue --- src/xspech.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xspech.f90 b/src/xspech.f90 index 2d198525..6c03fe18 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -879,6 +879,7 @@ subroutine final_diagnostics do iocons = 0, 1 if( Lcoordinatesingularity .and. iocons.eq.0 ) cycle + if( vvol.eq.Mvol .and. iocons.eq.1 ) cycle ! Compute covariant magnetic field at interface call lbpol(vvol, Bt00(1:Mvol, 0:1, -1:2), 0, iocons) From d3a815223716a5446b96b6c9a985a933fab4c324 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 14 Feb 2023 15:11:40 +0100 Subject: [PATCH 045/134] added scipy --- .github/workflows/build_cmake.yml | 2 +- .github/workflows/py_spec.yml | 2 +- .github/workflows/python_wrapper.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 1888627d..6f9a6d48 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -17,7 +17,7 @@ jobs: - name: Install prereqs run: | pip3 install --upgrade pip - pip3 install ninja cmake + pip3 install ninja cmake scipy yum install -y hdf5-static - name: Build & Test uses: ashutoshvarma/action-cmake-build@master diff --git a/.github/workflows/py_spec.yml b/.github/workflows/py_spec.yml index 495d1880..13735085 100644 --- a/.github/workflows/py_spec.yml +++ b/.github/workflows/py_spec.yml @@ -19,7 +19,7 @@ jobs: working-directory: ${{ env.PY_SPEC_DIR }} run: | pip3 install -r requirements.txt - pip3 install setuptools wheel twine + pip3 install setuptools wheel twine scipy - name: Build py_spec working-directory: ${{ env.PY_SPEC_DIR }} diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 158451d5..55952dfe 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -18,7 +18,7 @@ jobs: run: | sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev cmake ninja-build - pip3 install --user numpy f90nml scikit-build + pip3 install --user numpy f90nml scikit-build scipy pip3 install --user git+https://github.com/zhucaoxiang/f90wrap - name: Build python_wrapper From 32ecebbda2a76b60b139572478c5bf848674a9e6 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 14 Feb 2023 15:58:29 +0100 Subject: [PATCH 046/134] solve Btemn bug --- src/xspech.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xspech.f90 b/src/xspech.f90 index 6c03fe18..1bb7b694 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -879,7 +879,7 @@ subroutine final_diagnostics do iocons = 0, 1 if( Lcoordinatesingularity .and. iocons.eq.0 ) cycle - if( vvol.eq.Mvol .and. iocons.eq.1 ) cycle + if( vvol.eq.Nvol+1 .and. iocons.eq.1 ) cycle ! Compute covariant magnetic field at interface call lbpol(vvol, Bt00(1:Mvol, 0:1, -1:2), 0, iocons) From 4345ad0a99bda4ba7817ca9f650a75023fad2257 Mon Sep 17 00:00:00 2001 From: abaillod <45510759+abaillod@users.noreply.github.com> Date: Fri, 24 Feb 2023 13:52:52 +0100 Subject: [PATCH 047/134] Update bfield.f90 When field is not toroidal, bfield now prints a warning instead of raising an error. --- src/bfield.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bfield.f90 b/src/bfield.f90 index e9d0ea0e..299e9a81 100644 --- a/src/bfield.f90 +++ b/src/bfield.f90 @@ -167,7 +167,7 @@ subroutine bfield( zeta, st, Bst ) cput-cpus, lvol, zeta, st(1:2), dBu(3) !FATAL( bfield, abs(dBu(3)).lt.vsmall, field is not toroidal ) - + write(ounit,'("WARNING: bfield: field is not toroidal")') endif !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! From 3784f00db1904bdaa76fe55466ab6cc27b644641 Mon Sep 17 00:00:00 2001 From: abaillod <45510759+abaillod@users.noreply.github.com> Date: Fri, 24 Feb 2023 13:58:15 +0100 Subject: [PATCH 048/134] Update bfield.f90 Added if statement --- src/bfield.f90 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bfield.f90 b/src/bfield.f90 index 299e9a81..bf78b84c 100644 --- a/src/bfield.f90 +++ b/src/bfield.f90 @@ -167,7 +167,9 @@ subroutine bfield( zeta, st, Bst ) cput-cpus, lvol, zeta, st(1:2), dBu(3) !FATAL( bfield, abs(dBu(3)).lt.vsmall, field is not toroidal ) - write(ounit,'("WARNING: bfield: field is not toroidal")') + if( abs( dBu(3)).lt.vsmall ) then + write(ounit,'("WARNING: bfield: field is not toroidal")') + endif endif !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! From 73ecad0fc02393a35d9e2a5c17bad82db8ea82e3 Mon Sep 17 00:00:00 2001 From: abaillod <45510759+abaillod@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:30:44 +0100 Subject: [PATCH 049/134] Update __init__.py Changed version number --- Utilities/pythontools/py_spec/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 260f4170..a96f7302 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,5 +1,5 @@ # import of all SPEC-related python scripts. -__version__ = "3.1.0" +__version__ = "3.2.0" from .ci import test from .input.spec_namelist import SPECNamelist From d9ba9a0ddcba2d7e3123f59f2f8e33db3224e471 Mon Sep 17 00:00:00 2001 From: abaillod <45510759+abaillod@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:35:31 +0100 Subject: [PATCH 050/134] Update bfield.f90 Revert to raising an error when field is not toroidal. --- src/bfield.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bfield.f90 b/src/bfield.f90 index bf78b84c..5c2daa8c 100644 --- a/src/bfield.f90 +++ b/src/bfield.f90 @@ -166,10 +166,10 @@ subroutine bfield( zeta, st, Bst ) write(ounit,'("bfield : ",f10.2," : lvol=",i3," ; zeta="es23.15" ; (s,t)=("es23.15" ,"es23.15" ) ; B^z="es23.15" ;")') & cput-cpus, lvol, zeta, st(1:2), dBu(3) - !FATAL( bfield, abs(dBu(3)).lt.vsmall, field is not toroidal ) - if( abs( dBu(3)).lt.vsmall ) then - write(ounit,'("WARNING: bfield: field is not toroidal")') - endif + FATAL( bfield, abs(dBu(3)).lt.vsmall, field is not toroidal ) + !if( abs( dBu(3)).lt.vsmall ) then + ! write(ounit,'("WARNING: bfield: field is not toroidal")') + !endif endif !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! From 69468937b26fbaf56b18cc9a3fa2bdf72a50fe6b Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Sat, 25 Feb 2023 16:29:43 -0500 Subject: [PATCH 051/134] Added scipy to requirements --- Utilities/pythontools/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Utilities/pythontools/requirements.txt b/Utilities/pythontools/requirements.txt index 932ff2c4..be8bb1d3 100644 --- a/Utilities/pythontools/requirements.txt +++ b/Utilities/pythontools/requirements.txt @@ -2,4 +2,5 @@ h5py matplotlib f90nml numpy -coilpy \ No newline at end of file +scipy +coilpy From 2f89921bb0b6c4148a5acf7975cc63d18e82e496 Mon Sep 17 00:00:00 2001 From: Matt Landreman Date: Sat, 25 Feb 2023 16:39:09 -0500 Subject: [PATCH 052/134] remove scipy install from py_spec ci --- .github/workflows/py_spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/py_spec.yml b/.github/workflows/py_spec.yml index 13735085..a4c86983 100644 --- a/.github/workflows/py_spec.yml +++ b/.github/workflows/py_spec.yml @@ -19,7 +19,7 @@ jobs: working-directory: ${{ env.PY_SPEC_DIR }} run: | pip3 install -r requirements.txt - pip3 install setuptools wheel twine scipy + pip3 install setuptools wheel twine - name: Build py_spec working-directory: ${{ env.PY_SPEC_DIR }} From 5c74bb16f7e9e11743d25fb41c134cf815b1d085 Mon Sep 17 00:00:00 2001 From: liuk2020 Date: Sun, 5 Mar 2023 15:27:49 +0800 Subject: [PATCH 053/134] fix plot_iota --- Utilities/pythontools/py_spec/output/_plot_iota.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_plot_iota.py b/Utilities/pythontools/py_spec/output/_plot_iota.py index 8de0c2e3..362075e5 100644 --- a/Utilities/pythontools/py_spec/output/_plot_iota.py +++ b/Utilities/pythontools/py_spec/output/_plot_iota.py @@ -29,7 +29,7 @@ def plot_iota(self, xaxis="R", yaxis="i", ax=None, **kwargs): xlabel = r"s" elif xaxis == "R": xdata = self.poincare.R[:, 0, 0] - ydata = self.transform.fiota[1, :] + ydata = self.transform.fiota[1, self.poincare.success == 1] xlabel = r"R" else: raise ValueError("xaxis should be one of ['R', 's'].") From c29933a0f0bde7a27914f017a4d96bf72f1cc875 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 11 Apr 2023 14:45:28 +0200 Subject: [PATCH 054/134] fix bug in py_spec.SPECout.get_average_beta for equilibria with a single volume --- .../pythontools/py_spec/output/_processing.py | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 5ad85a7d..3edcc581 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -529,26 +529,44 @@ def get_average_beta(self, ns=64, nt=64, nz=64): if (press==0).all(): return 0 - for ivol in range(0,nvol-1): - if ivol==0: sarr=np.linspace(-0.999,1, ns) - if ivol!=0: sarr=np.linspace(-1, 1, ns) - - vols[ivol] = self.get_volume( ivol ) - + if nvol==1: + sarr=np.linspace(-0.999,1, ns) + vols = self.get_volume( 0 ) _, _, sg, g = self.get_grid_and_jacobian_and_metric( - lvol=ivol, sarr=sarr, tarr=tarr, zarr=zarr - ) + lvol=0, sarr=sarr, tarr=tarr, zarr=zarr + ) Bcontrav = self.get_B( - lvol=ivol, jacobian=sg, sarr=sarr, tarr=tarr, zarr=zarr + lvol=0, jacobian=sg, sarr=sarr, tarr=tarr, zarr=zarr ) modB = self.get_modB( Bcontrav, g ) - betavol[ivol] = 2 * nfp * press[ivol] * integrate.simpson( + betavol = 2 * nfp * press * integrate.simpson( y=integrate.simpson( y=integrate.simpson( y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) + + return betavol / vols + else: + for ivol in range(0,nvol-1): + if ivol==0: sarr=np.linspace(-0.999,1, ns) + if ivol!=0: sarr=np.linspace(-1, 1, ns) + + vols[ivol] = self.get_volume( ivol ) + + _, _, sg, g = self.get_grid_and_jacobian_and_metric( + lvol=ivol, sarr=sarr, tarr=tarr, zarr=zarr + ) + Bcontrav = self.get_B( + lvol=ivol, jacobian=sg, sarr=sarr, tarr=tarr, zarr=zarr + ) + modB = self.get_modB( Bcontrav, g ) + + betavol[ivol] = 2 * nfp * press[ivol] * integrate.simpson( + y=integrate.simpson( + y=integrate.simpson( + y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) - return betavol.sum() / vols.sum() + return betavol.sum() / vols.sum() def get_peak_beta(self, ns=64, nt=64, nz=64): From 8215902d9c93a77f26699101fc596e252b64fb5c Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 11 Apr 2023 14:51:39 +0200 Subject: [PATCH 055/134] increased version number --- Utilities/pythontools/py_spec/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index a96f7302..4db731a3 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,5 +1,5 @@ # import of all SPEC-related python scripts. -__version__ = "3.2.0" +__version__ = "3.3.0" from .ci import test from .input.spec_namelist import SPECNamelist From df9f3644982ef3bf4ede6f8829dd277455bcfe0d Mon Sep 17 00:00:00 2001 From: Caoxiang Zhu Date: Wed, 12 Apr 2023 21:44:25 +0800 Subject: [PATCH 056/134] try to resolve pip error --- .github/workflows/py_spec.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/py_spec.yml b/.github/workflows/py_spec.yml index a4c86983..7dd00935 100644 --- a/.github/workflows/py_spec.yml +++ b/.github/workflows/py_spec.yml @@ -14,6 +14,7 @@ jobs: run: | python3 --version pip3 --version + pip3 install --upgrade pip3 - name: Install dependencies working-directory: ${{ env.PY_SPEC_DIR }} From 69b4f0bc8970ac6146b59fbfb9176fa1e82d4179 Mon Sep 17 00:00:00 2001 From: Caoxiang Zhu Date: Wed, 12 Apr 2023 21:46:43 +0800 Subject: [PATCH 057/134] try this one --- .github/workflows/py_spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/py_spec.yml b/.github/workflows/py_spec.yml index 7dd00935..f621c376 100644 --- a/.github/workflows/py_spec.yml +++ b/.github/workflows/py_spec.yml @@ -14,11 +14,11 @@ jobs: run: | python3 --version pip3 --version - pip3 install --upgrade pip3 - name: Install dependencies working-directory: ${{ env.PY_SPEC_DIR }} run: | + pip install --upgrade pip pip3 install -r requirements.txt pip3 install setuptools wheel twine From 43e303619a981a41f462ecef0567651d88c4e94c Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Tue, 18 Apr 2023 18:00:20 +0200 Subject: [PATCH 058/134] solved bug in get_average_beta --- Utilities/pythontools/py_spec/__init__.py | 2 +- Utilities/pythontools/py_spec/output/_processing.py | 2 +- Utilities/pythontools/requirements.txt | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 4db731a3..2439c277 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,5 +1,5 @@ # import of all SPEC-related python scripts. -__version__ = "3.3.0" +__version__ = "3.3.2" from .ci import test from .input.spec_namelist import SPECNamelist diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 3edcc581..ae9d44ef 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -547,7 +547,7 @@ def get_average_beta(self, ns=64, nt=64, nz=64): return betavol / vols else: - for ivol in range(0,nvol-1): + for ivol in range(0,nvol): if ivol==0: sarr=np.linspace(-0.999,1, ns) if ivol!=0: sarr=np.linspace(-1, 1, ns) diff --git a/Utilities/pythontools/requirements.txt b/Utilities/pythontools/requirements.txt index be8bb1d3..79349753 100644 --- a/Utilities/pythontools/requirements.txt +++ b/Utilities/pythontools/requirements.txt @@ -2,5 +2,8 @@ h5py matplotlib f90nml numpy -scipy + +# Version 1.7.0 or higher is required - otherwise scipy.integrate.simpson does not exist +scipy>=1.7.0 + coilpy From 0b782342174ab8831b11c86ca7bc15c6b9ed6e2f Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 25 May 2023 09:39:09 +0200 Subject: [PATCH 059/134] new python routine --- .../pythontools/py_spec/math/spec_fft.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Utilities/pythontools/py_spec/math/spec_fft.py diff --git a/Utilities/pythontools/py_spec/math/spec_fft.py b/Utilities/pythontools/py_spec/math/spec_fft.py new file mode 100644 index 00000000..ca2caa57 --- /dev/null +++ b/Utilities/pythontools/py_spec/math/spec_fft.py @@ -0,0 +1,28 @@ +import numpy as np + +def spec_fft(tarr: np.array, + zarr: np.array, + freal: np.array, + Mpol: int=None, + Ntor: int=None, + output: str='1D'): + """ + Fourier transform as in SPEC fortran source + + Args: + - tarr: 1D numpy array of size nt. Poloidal angle coordinate, each point + should be equidistant + - zarr: 1D numpy array of size nz. Toroidal angle coordinate, each point + should be equidistant + - freal: 2D numpy array of size (nz,nt). Function, in real space, for which + Fourier harmonics should be evaluated + - Mpol: integer. Poloidal resolution. Default is nt/2. + - Ntor: integer. Toroidal resolution. Default is nz/2. + - output: either '1D' or '2D'. Determine the form of the output. + + Output: + If output=='1D', the output is a 1D numpy array, with modes organized + as in SPEC (first increasing n, then increasing m). + If output=='2D', the output is a 2D numpy array, with modes (m,n) + in element (Ntor+n,m) + """ \ No newline at end of file From acd21f3fc79133d401a9b83cbb71d6f27e808081 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 25 May 2023 12:05:09 +0200 Subject: [PATCH 060/134] Implemented spec_fft in py_spec --- .../pythontools/py_spec/math/spec_fft.py | 164 +++++++++++++++++- 1 file changed, 159 insertions(+), 5 deletions(-) diff --git a/Utilities/pythontools/py_spec/math/spec_fft.py b/Utilities/pythontools/py_spec/math/spec_fft.py index ca2caa57..acc04761 100644 --- a/Utilities/pythontools/py_spec/math/spec_fft.py +++ b/Utilities/pythontools/py_spec/math/spec_fft.py @@ -1,4 +1,6 @@ import numpy as np +import copy +import warnings def spec_fft(tarr: np.array, zarr: np.array, @@ -21,8 +23,160 @@ def spec_fft(tarr: np.array, - output: either '1D' or '2D'. Determine the form of the output. Output: - If output=='1D', the output is a 1D numpy array, with modes organized - as in SPEC (first increasing n, then increasing m). - If output=='2D', the output is a 2D numpy array, with modes (m,n) - in element (Ntor+n,m) - """ \ No newline at end of file + If output=='1D', the output is a tuple 1D numpy array, with modes + organized as in SPEC (first increasing n, then increasing m). First + tuple element are the even modes, second are the odd modes + If output=='2D', the output is tuple of 2D numpy array, with modes (m,n) + in element (Ntor+n,m). First tuple elements are the even modes, + seconds are the odd modes + """ + + # Check input + # ----------- + # tarr + if not isinstance(tarr, np.ndarray): + raise ValueError('tarr should be a numpy array') + if tarr.ndim>1: + raise ValueError('tarr should be one-dimensional') + + nt = tarr.size + if nt<3: + raise ValueError('Not enough points in tarr') + + # zarr + if not isinstance(zarr, np.ndarray): + raise ValueError('zarr should be a numpy array') + if zarr.ndim>1: + raise ValueError('zarr should be one-dimensional') + + nz = zarr.size + if nz<3: + raise ValueError('Not enough points in zarr') + + # freal + if not isinstance(freal, np.ndarray): + raise ValueError('freal should be a numpy array') + if freal.ndim!=2: + raise ValueError('freal should be two-dimensional') + if freal.shape!=(nz,nt): + raise ValueError('freal should be of size (nz,nt)') + + if tarr[0]+2*np.pi==tarr[-1]: + warnings.warn('tarr[-1] should not be equal to tarr[0]. Removing last element...') + tarr = tarr[:-1] + nt -= 1 + freal = freal[:,:-1] + + if tarr[0]+2*np.pi==tarr[-1]: + warnings.warn('zarr[-1] should not be equal to zarr[0]. Removing last element...') + zarr = zarr[:-1] + nz -= 1 + freal = freal[:-1,:] + + if not np.all(np.abs(np.diff(np.diff(tarr)))<1e-14): + raise ValueError('Points should be equidistant in tarr') + if not np.all(np.abs(np.diff(np.diff(zarr)))<1e-14): + raise ValueError('Points should be equidistant in zarr') + + # Mpol + M = int(np.floor(nt/2)) + if Mpol is None: + Mpol = M + if not isinstance(Mpol, int): + raise ValueError('Mpol should be an integer') + if Mpol<1 or Mpol>nt/2: + raise ValueError('Mpol should be at least 1 and smaller than nt/2') + + # Ntor + N = int(np.floor(nz/2)) + if Ntor is None: + Ntor = N + if not isinstance(Ntor, int): + raise ValueError('Ntor should be an integer') + if Ntor<1 or Ntor>nz/2: + raise ValueError('Ntor should be at least 1 and smaller than nt=z/2') + + # output + if not isinstance(output, str): + raise ValueError('output should be a string') + if not (output=='1D' or output=='2D'): + raise ValueError('output should be 1D or 2D') + + # Do the fft + # ---------- + # Actual fft + fmn = np.fft.fft2( freal ) / (nt*nz) + + # Now construct 2D array. Negative m-modes have to be added to positive + # m-modes, i.e. (m,n)+(-m,-n) for even modes, and (m,n)-(-m,-n) for odd + # modes. + # Difference if the number of elements (either nt or nz) is odd - this is + # due to the internal implementation of numpy.fft.fft. + efmn = copy.deepcopy(fmn) + efmn[1:,1:] = fmn[1:,1:] + np.flip(fmn[1:,1:]) + + ofmn = copy.deepcopy(fmn) + ofmn[1:,1:] = fmn[1:,1:] - np.flip(fmn[1:,1:]) + if np.mod(nt,2)==0: + efmn[0,1:M+1] += np.flip(fmn[0,M:]) #n=0 + ofmn[0,1:M+1] -= np.flip(fmn[0,M:]) + else: + efmn[0,1:M+1] += np.flip(fmn[0,M+1:]) #n=0 + ofmn[0,1:M+1] -= np.flip(fmn[0,M+1:]) + + if np.mod(nz,2)==0: + efmn[1:N+1,0] += np.flip(fmn[N:,0]) # m=0 + ofmn[1:N+1,0] -= np.flip(fmn[N:,0]) + else: + efmn[1:N+1,0] += np.flip(fmn[N+1:,0]) # m=0 + ofmn[1:N+1,0] -= np.flip(fmn[N+1:,0]) + + efmn = (np.absolute(efmn) * np.cos(np.angle(efmn)))[:,0:M+1] + ofmn = (np.absolute(ofmn) * np.sin(np.angle(ofmn)))[:,0:M+1] + + # Change sign of m>0 odd modes + ofmn[:,1:] = -ofmn[:,1:] + + # Shift result to be centered around n=0 mode + efmn = np.fft.fftshift(efmn, axes=0) + ofmn = np.fft.fftshift(ofmn, axes=0) + + # Invert n -> -n + efmn[:,1:] = np.flip(efmn[:,1:],axis=0) + ofmn[:,1:] = np.flip(ofmn[:,1:],axis=0) + + # Prepare output + # -------------- + if output=='2D': + # 2D - truncate efmn, ofmn to the required resolution + even_out = efmn[N-Ntor:N+Ntor+1,0:Mpol+1] + odd_out = ofmn[N-Ntor:N+Ntor+1,0:Mpol+1] + return (even_out, odd_out) + + elif output=='1D': + # 1D - construct array mode by mode + nmn = Ntor+1 + Mpol*(2*Ntor+1) + even_out = np.zeros((nmn,)) + odd_out = np.zeros((nmn,)) + + ind = -1 + for mm in range(0,Mpol+1): + for nn in range(-Ntor,Ntor+1): + if mm==0 and nn<0: + continue + + ind += 1 + + even_out[ind] = efmn[N+nn,mm] + odd_out[ind] = ofmn[N+nn,mm] + + return (even_out, odd_out) + + else: + raise ValueError('Invalid output') + + + + + + From 6edadbcf1a3ab6975e5df8f419ab79fc2a981bd0 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 25 May 2023 12:05:42 +0200 Subject: [PATCH 061/134] updated version number --- Utilities/pythontools/py_spec/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 2439c277..c495e0ee 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,6 +1,7 @@ # import of all SPEC-related python scripts. -__version__ = "3.3.2" +__version__ = "3.3.3" from .ci import test from .input.spec_namelist import SPECNamelist from .output.spec import SPECout +from .math.spec_fft import spec_fft From 5caa26efec2120f158b85a64c0d5d6040609c8a1 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Thu, 25 May 2023 15:31:42 +0200 Subject: [PATCH 062/134] added tests, fixed bugs in spec_fft --- Utilities/pythontools/py_spec/__init__.py | 1 + .../pythontools/py_spec/math/spec_fft.py | 22 +++-- .../pythontools/py_spec/math/spec_invfft.py | 89 +++++++++++++++++ .../pythontools/py_spec/output/_processing.py | 14 --- Utilities/pythontools/py_spec/tests/README.md | 4 + .../py_spec/tests/test_math/test_spec_fft.py | 99 +++++++++++++++++++ 6 files changed, 209 insertions(+), 20 deletions(-) create mode 100644 Utilities/pythontools/py_spec/math/spec_invfft.py create mode 100644 Utilities/pythontools/py_spec/tests/README.md create mode 100644 Utilities/pythontools/py_spec/tests/test_math/test_spec_fft.py diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index c495e0ee..5203a4a5 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -5,3 +5,4 @@ from .input.spec_namelist import SPECNamelist from .output.spec import SPECout from .math.spec_fft import spec_fft +from .math.spec_invfft import spec_invfft diff --git a/Utilities/pythontools/py_spec/math/spec_fft.py b/Utilities/pythontools/py_spec/math/spec_fft.py index acc04761..a1c0c187 100644 --- a/Utilities/pythontools/py_spec/math/spec_fft.py +++ b/Utilities/pythontools/py_spec/math/spec_fft.py @@ -23,9 +23,10 @@ def spec_fft(tarr: np.array, - output: either '1D' or '2D'. Determine the form of the output. Output: - If output=='1D', the output is a tuple 1D numpy array, with modes + If output=='1D', the output is a 4-tuple 1D numpy array, with modes organized as in SPEC (first increasing n, then increasing m). First - tuple element are the even modes, second are the odd modes + tuple element are the even modes, second are the odd modes, third + are the poloidal mode number, and fourth the toroidal mode number. If output=='2D', the output is tuple of 2D numpy array, with modes (m,n) in element (Ntor+n,m). First tuple elements are the even modes, seconds are the odd modes @@ -67,7 +68,7 @@ def spec_fft(tarr: np.array, nt -= 1 freal = freal[:,:-1] - if tarr[0]+2*np.pi==tarr[-1]: + if zarr[0]+2*np.pi==zarr[-1]: warnings.warn('zarr[-1] should not be equal to zarr[0]. Removing last element...') zarr = zarr[:-1] nz -= 1 @@ -142,8 +143,13 @@ def spec_fft(tarr: np.array, ofmn = np.fft.fftshift(ofmn, axes=0) # Invert n -> -n - efmn[:,1:] = np.flip(efmn[:,1:],axis=0) - ofmn[:,1:] = np.flip(ofmn[:,1:],axis=0) + if np.mod(nz,2)==0: + efmn[1:,1:] = np.flip(efmn[1:,1:],axis=0) + ofmn[1:,1:] = np.flip(ofmn[1:,1:],axis=0) + else: + efmn[:,1:] = np.flip(efmn[:,1:],axis=0) + ofmn[:,1:] = np.flip(ofmn[:,1:],axis=0) + # Prepare output # -------------- @@ -158,6 +164,8 @@ def spec_fft(tarr: np.array, nmn = Ntor+1 + Mpol*(2*Ntor+1) even_out = np.zeros((nmn,)) odd_out = np.zeros((nmn,)) + _im = np.zeros((nmn,), dtype=int) + _in = np.zeros((nmn,), dtype=int) ind = -1 for mm in range(0,Mpol+1): @@ -167,10 +175,12 @@ def spec_fft(tarr: np.array, ind += 1 + _im[ind]=mm + _in[ind]=nn even_out[ind] = efmn[N+nn,mm] odd_out[ind] = ofmn[N+nn,mm] - return (even_out, odd_out) + return (even_out, odd_out, _im, _in) else: raise ValueError('Invalid output') diff --git a/Utilities/pythontools/py_spec/math/spec_invfft.py b/Utilities/pythontools/py_spec/math/spec_invfft.py new file mode 100644 index 00000000..14022777 --- /dev/null +++ b/Utilities/pythontools/py_spec/math/spec_invfft.py @@ -0,0 +1,89 @@ +import numpy as np + +def spec_invfft(tarr:np.ndarray, zarr:np.ndarray, + efmn:np.ndarray, ofmn:np.ndarray, + _im:np.ndarray, _in:np.ndarray): + """ + Inverse Fourier transform as in SPEC Fortran source. + + Args: + - tarr: 1D numpy array of size nt. Poloidal angle coordinate. + - zarr: 1D numpy array of size nz. Toroidal angle coordinate. + - efmn: 1D numpy array of size nmn. Even mode numbers. + - ofmn: 1D numpy array of size nmn. Odd mode numbers. + - _im: 1D numpy array of size nmn. Poloidal mode numbers + - _in: 1D numpy array of size nmn. Toroidal mode numbers (multiples of Nfp) + + Output: + - freal: 2D numpy array of size nz x nt. Function evaluation in real space. + """ + + # Check input + # ----------- + # tarr + if not isinstance(tarr, np.ndarray): + raise ValueError('tarr should be a numpy array') + if tarr.ndim>1: + raise ValueError('tarr should be one-dimensional') + + nt = tarr.size + + # zarr + if not isinstance(zarr, np.ndarray): + raise ValueError('zarr should be a numpy array') + if zarr.ndim>1: + raise ValueError('zarr should be one-dimensional') + + nz = zarr.size + + # efmn + if not isinstance(efmn, np.ndarray): + raise ValueError('efmn should be a numpy array') + if efmn.ndim>1: + raise ValueError('efmn should be one-dimensional') + + nmn = efmn.size + + # ofmn + if not isinstance(ofmn, np.ndarray): + raise ValueError('ofmn should be a numpy array') + if ofmn.ndim>1: + raise ValueError('ofmn should be one-dimensional') + if ofmn.size!=nmn: + raise ValueError('ofmn should have the same size as efmn') + + # _im + if not isinstance(_im, np.ndarray): + raise ValueError('_im should be a numpy array') + if _im.ndim>1: + raise ValueError('_im should be one-dimensional') + if _im.size!=nmn: + raise ValueError('_im should have the same size as efmn') + if not np.all(_im>=0): + raise ValueError('_im should not have any negative values') + + # _in + if not isinstance(_in, np.ndarray): + raise ValueError('_in should be a numpy array') + if _in.ndim>1: + raise ValueError('_in should be one-dimensional') + if _in.size!=nmn: + raise ValueError('_in should have the same size as efmn') + + # Inverse Fourier transform + # ------------------------- + + # Generate grid: + tgrid, zgrid = np.meshgrid(tarr, zarr) + + # Evaluate function: + freal = np.zeros((nz,nt)) + for mm, nn, emode, omode in zip(_im, _in, efmn, ofmn): + freal += emode * np.cos(mm*tgrid - nn*zgrid) \ + + omode * np.sin(mm*tgrid - nn*zgrid) + + # Output + return freal + + + diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index ae9d44ef..a5f6c2d6 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -127,11 +127,6 @@ def get_RZ_derivatives( return Rarr0, Rarr1, Rarr2, Rarr3, Zarr0, Zarr1, Zarr2, Zarr3 - - - - - def get_grid_and_jacobian_and_metric( self, lvol=0, @@ -362,7 +357,6 @@ def get_grid_and_jacobian_and_metric( else: return Rarr0, Zarr0, jacobian, g - def grid( self, lvol=0, @@ -377,7 +371,6 @@ def grid( ) return Rarr0, Zarr0 - def jacobian( self, lvol=0, @@ -392,7 +385,6 @@ def jacobian( ) return jacobian - def metric( self, lvol=0, @@ -407,7 +399,6 @@ def metric( ) return g - def get_B( self, lvol=0, @@ -484,7 +475,6 @@ def get_modB(self, Bcontrav, g, derivative=False, dBcontrav=None, dg=None): ) + np.einsum("...i,...kji,...j->...k", Bcontrav, dg, Bcontrav) return modB, dmodB2 - def get_B_covariant(self, Bcontrav, g, derivative=False): """Get covariant component of B""" Bco = np.einsum("...i,...ji->...j", Bcontrav, g) @@ -568,7 +558,6 @@ def get_average_beta(self, ns=64, nt=64, nz=64): return betavol.sum() / vols.sum() - def get_peak_beta(self, ns=64, nt=64, nz=64): if self.input.physics.pressure.size>1: press = self.input.physics.pressure[0] * self.input.physics.pscale @@ -594,7 +583,6 @@ def get_peak_beta(self, ns=64, nt=64, nz=64): y=integrate.simpson( y=sg / modB**2, x=zarr ), x=tarr ), x=sarr ) / vol - def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): ds = delta R, Z, j, g = self.get_grid_and_jacobian_and_metric(lvol, np.array([s-ds, s+ds]), np.array([t-ds, t+ds]), np.array([z-ds, z+ds])) @@ -618,7 +606,6 @@ def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): print((g[0,1,0,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,1,:,:]) print((g[0,0,1,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,2,:,:]) - def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): """Compute j_surf.B on each side of the provided interfaces @@ -696,7 +683,6 @@ def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): return j_dot_B, tarr, zarr - def get_surface(self, lsurf:int=None, nt:int=64, nz:int=64): """Compute the surface area of a volume interface diff --git a/Utilities/pythontools/py_spec/tests/README.md b/Utilities/pythontools/py_spec/tests/README.md new file mode 100644 index 00000000..2211cf31 --- /dev/null +++ b/Utilities/pythontools/py_spec/tests/README.md @@ -0,0 +1,4 @@ +To run tests, do +``` +python -m unittest -v test_math.test_spec_fft +``` diff --git a/Utilities/pythontools/py_spec/tests/test_math/test_spec_fft.py b/Utilities/pythontools/py_spec/tests/test_math/test_spec_fft.py new file mode 100644 index 00000000..03cc77c6 --- /dev/null +++ b/Utilities/pythontools/py_spec/tests/test_math/test_spec_fft.py @@ -0,0 +1,99 @@ +import unittest +import numpy as np +from py_spec.math.spec_fft import spec_fft as fft +from py_spec.math.spec_invfft import spec_invfft as invfft + + +class fftTests(unittest.TestCase): + def test_fft_1d(self): + """ + Test spec_fft on an analytical function, 1D output + """ + + nt = 33 # Number of theta points + nz = 17 # Number of zeta points + tarr = np.linspace(0, 2*np.pi, nt, endpoint=False) + zarr = np.linspace(0, 2*np.pi, nz, endpoint=False) + + tgrid, zgrid = np.meshgrid( tarr, zarr ) # grid + + f = 0.3 \ + + 2*np.cos(tgrid) \ + - 3*np.cos(2*tgrid-zgrid) \ + + 1*np.cos(2*tgrid+zgrid) \ + - 3.8*np.sin(tgrid+2*zgrid) \ + - 2.4*np.sin(3*zgrid) + + efmn, ofmn, _, _ = fft( tarr, zarr, f, Mpol=2, Ntor=3 ) + + places=8 + self.assertAlmostEqual(efmn[ 0], 0.3, places=places) + self.assertAlmostEqual(efmn[ 7], 2, places=places) + self.assertAlmostEqual(efmn[13], 1, places=places) + self.assertAlmostEqual(efmn[15], -3, places=places) + self.assertAlmostEqual(ofmn[ 3], 2.4, places=places) + self.assertAlmostEqual(ofmn[ 5],-3.8, places=places) + + + def test_fft_2d(self): + """ + Test spec_fft on an analytical function, 2D output + """ + + nt = 32 # Number of theta points + nz = 21 # Number of zeta points + tarr = np.linspace(0, 2*np.pi, nt, endpoint=False) + zarr = np.linspace(0, 2*np.pi, nz, endpoint=True) + + tgrid, zgrid = np.meshgrid( tarr, zarr ) # grid + + f = 0.3 \ + + 2*np.cos(tgrid) \ + - 3*np.cos(2*tgrid-zgrid) \ + + 1*np.cos(2*tgrid+zgrid) \ + - 3.8*np.sin(tgrid+2*zgrid) \ + - 2.4*np.sin(3*zgrid) + + Mpol=4 + Ntor=8 + efmn, ofmn = fft( tarr, zarr, f, Mpol=Mpol, Ntor=Ntor, output='2D' ) + + places=8 + self.assertAlmostEqual(efmn[Ntor,0], 0.3, places=places) + self.assertAlmostEqual(efmn[Ntor,1], 2, places=places) + self.assertAlmostEqual(efmn[Ntor-1,2], 1, places=places) + self.assertAlmostEqual(efmn[Ntor+1,2], -3, places=places) + self.assertAlmostEqual(ofmn[Ntor-2,1],-3.8, places=places) + self.assertAlmostEqual(ofmn[Ntor+3,0], 2.4, places=places) + + + def test_invfft(self): + """ + Test spec_invfft using analytical function. + """ + + nt = 64 # Number of theta points + nz = 48 # Number of zeta points + tarr = np.linspace(0, 2*np.pi, nt, endpoint=False) + zarr = np.linspace(0, 2*np.pi, nz, endpoint=True) + + tgrid, zgrid = np.meshgrid( tarr, zarr ) # grid + + f = 0.3 \ + + 2*np.cos(tgrid) \ + - 3*np.cos(2*tgrid-zgrid) \ + + 1*np.cos(2*tgrid+zgrid) \ + - 3.8*np.sin(tgrid+2*zgrid) \ + - 2.4*np.sin(3*zgrid) + + Mpol=8 + Ntor=8 + efmn, ofmn, _im, _in = fft( tarr, zarr, f, Mpol=Mpol, Ntor=Ntor, output='1D' ) + + freal = invfft(tarr, zarr, efmn, ofmn, _im, _in) + + self.assertTrue( np.max(np.max(np.abs((freal-f)/f)))<1e-8 ) + + + + \ No newline at end of file From 699085ff50d1bef10aeb616b5a2044ad85ff6804 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Fri, 26 May 2023 14:03:42 +0200 Subject: [PATCH 063/134] quick fix to final s.f.l angle diagnostic --- src/tr00ab.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tr00ab.f90 b/src/tr00ab.f90 index 8a6b973b..260f19ce 100644 --- a/src/tr00ab.f90 +++ b/src/tr00ab.f90 @@ -767,6 +767,7 @@ subroutine tr00ab( lvol, mn, NN, Nt, Nz, iflag, ldiota ) ! construct straight-fi work(1:Lwork), Lwork, iwork(1:Liwork), idgelsd ) ldiota(innout,0) = dlambda(1,0) + dlambdaout(1:NN, lvol, innout) = dlambda(1:NN,0) case( 1 ) ! Lsvdiota = 1; jderiv = 1; 02 Sep 14; From 71408b20f9cb2525ebb6d919cc098c6b0cfe54ee Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Sun, 28 May 2023 02:30:37 -0400 Subject: [PATCH 064/134] Mimic scalapack in finding BLAS and LAPACK libraries --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef806494..0ed325bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,11 +60,11 @@ find_program(AWK awk mawk gawk) # If Intel MKL is not desired, change BLA_VENDOR variabale during configuration #set(BLA_VENDOR Intel10_64lp CACHE STRING # "Define BLAS vendor. Some of the popular options are Intel10_64lp OpenBLAS Apple Generic") -find_package (BLAS REQUIRED) -message(STATUS "BLAS vendor is ${BLA_VENDOR}") -if (NOT ${BLA_VENDOR} MATCHES "^Intel" AND NOT ${BLA_VENDOR} MATCHES "^OpenBLAS") - find_package (LAPACK REQUIRED) -endif() +# find_package (BLAS REQUIRED) +# message(STATUS "BLAS vendor is ${BLA_VENDOR}") +# if (NOT ${BLA_VENDOR} MATCHES "^Intel" AND NOT ${BLA_VENDOR} MATCHES "^OpenBLAS") +find_package (LAPACK REQUIRED) +#endif() # Find FFTW3. # Intel oneAPI has FFT3 available as part of MKL. Just linking against MKL gives FFTW functionality. From 3ba7b618e1745c47a8c7947656ea3559428c8d38 Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Thu, 1 Jun 2023 07:38:28 -0400 Subject: [PATCH 065/134] Fix for GNU 10.1 or higher --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ed325bf..c40ff723 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,11 @@ else () endif () endif () +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER "10.0") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch") + endif() + find_program(AWK awk mawk gawk) # Find LAPACK From 538610344629b34730c2f2003d8b25124e679c9d Mon Sep 17 00:00:00 2001 From: Bharat Medasani Date: Thu, 1 Jun 2023 07:42:05 -0400 Subject: [PATCH 066/134] Bug fix in CMakeLists.txt --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c40ff723..117131f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER "10.0") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch") endif() +endif() find_program(AWK awk mawk gawk) From 25b3a456628cd1ec2e50100ce8bfce704fe5323f Mon Sep 17 00:00:00 2001 From: salomon73 Date: Mon, 26 Jun 2023 13:52:48 -0400 Subject: [PATCH 067/134] read_boozer routine added --- Utilities/matlabtools/read_boozer.m | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Utilities/matlabtools/read_boozer.m diff --git a/Utilities/matlabtools/read_boozer.m b/Utilities/matlabtools/read_boozer.m new file mode 100644 index 00000000..7432cff3 --- /dev/null +++ b/Utilities/matlabtools/read_boozer.m @@ -0,0 +1,36 @@ +%% read_boozer( FILENAME, ROOT) +% ============================= +% +% Reads hdf5 output from Boozer_xForms +% and produces data struct +% +% INPUT +% ----- +% -filename : name of Boz output +% -root : root directory +% +% ------------------------------------% +% Written by S.Guinchard (05/22) % +% from read_spec routine % +% ------------------------------------% + +function g_data = read_boozer(filename, root ) + g_data_info = h5info(filename, root); + ngroups = length(g_data_info.Groups); + nvars = length(g_data_info.Datasets); + % Get datasets in root node + for i = 1: nvars + g_data.([g_data_info.Datasets(i).Name]) = h5read(filename,[root '/' g_data_info.Datasets(i).Name]); + natts = length(g_data_info.Datasets(i).Attributes); + for j=1:natts + g_data.([g_data_info.Datasets(i).Attributes(j).Name]) = g_data_info.Datasets(i).Attributes(j).Value{1}; + end + end + % get groups in root node + if ngroups > 0 + for i = 1 : ngroups + g_path = strsplit(g_data_info.Groups(i).Name, '/'); + g_data.([g_path{end}]) = read_boozer(filename, g_data_info.Groups(i).Name); + end + end +end From 714c20f0d1c9eb6b7c2b6f7f6634161d27767591 Mon Sep 17 00:00:00 2001 From: Zhisong Qu Date: Tue, 27 Jun 2023 14:59:52 +0200 Subject: [PATCH 068/134] Create LICENSE --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 73459e1da37ed1105c3822c368eae5e90c1cb19c Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 24 Jul 2023 15:26:02 +0200 Subject: [PATCH 069/134] added IFORT compiler flag for CMAKE compilation --- CMakeLists.txt | 5 +++++ cmake_machines/intel_SUSE.json | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 cmake_machines/intel_SUSE.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 117131f7..98dc87d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,11 @@ else () endif () endif () + +if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DIFORT") +endif() + if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER "10.0") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch") diff --git a/cmake_machines/intel_SUSE.json b/cmake_machines/intel_SUSE.json new file mode 100644 index 00000000..398c9534 --- /dev/null +++ b/cmake_machines/intel_SUSE.json @@ -0,0 +1,8 @@ +{ + "cmake_args": [ + "-DCMAKE_C_COMPILER=mpicc", + "-DCMAKE_CXX_COMPILER=mpicc", + "-DCMAKE_Fortran_COMPILER=mpif90", + "-DBLA_VENDOR=Intel10_64lp" + ] +} From 9aaae1282a64859be9d434988019219c9b8f31c3 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Wed, 11 Oct 2023 16:35:07 -0400 Subject: [PATCH 070/134] removed .ci from py_spec.__init__ --- Utilities/pythontools/py_spec/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 2439c277..8e6495ba 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,6 +1,6 @@ # import of all SPEC-related python scripts. __version__ = "3.3.2" -from .ci import test +#from .ci import test from .input.spec_namelist import SPECNamelist from .output.spec import SPECout From 44268961bfb14bfabc70e37ef67c05157400b7e6 Mon Sep 17 00:00:00 2001 From: Antoine Baillod Date: Wed, 11 Oct 2023 16:43:34 -0400 Subject: [PATCH 071/134] changed version number --- Utilities/pythontools/py_spec/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 8e6495ba..bbfd4491 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,5 +1,5 @@ # import of all SPEC-related python scripts. -__version__ = "3.3.2" +__version__ = "3.3.3" #from .ci import test from .input.spec_namelist import SPECNamelist From 3f075e07e6f096b330eed0ab38042ea36d9b4b12 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 12:17:15 +0200 Subject: [PATCH 072/134] fix return in _plot_poincare.py --- Utilities/pythontools/py_spec/output/_plot_poincare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_plot_poincare.py b/Utilities/pythontools/py_spec/output/_plot_poincare.py index d1002931..6de93211 100644 --- a/Utilities/pythontools/py_spec/output/_plot_poincare.py +++ b/Utilities/pythontools/py_spec/output/_plot_poincare.py @@ -73,4 +73,4 @@ def plot_poincare(self, toroidalIdx=0, prange="full", ax=None, **kwargs): plt.xticks(fontsize=16) plt.yticks(fontsize=16) - return \ No newline at end of file + return ax From 87510579c9c28461283154dac37a6d4db53e65b9 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 12:37:08 +0200 Subject: [PATCH 073/134] forced installation of ci in package --- Utilities/pythontools/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 8ffdf9b1..67d45afd 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -19,5 +19,5 @@ url="https://princetonuniversity.github.io/SPEC/", author="SPEC developers", license="GNU 3.0", - packages=setuptools.find_packages(), + packages=['py_spec', 'py_spec.input', 'py_spec.output', 'py_spec.ci'] ) From a255a66280d5ccd9874e0115f8c49ae34e27ff64 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 12:47:04 +0200 Subject: [PATCH 074/134] removed csmiet/testspec container; straight in ubuntu --- .github/workflows/build.yml | 101 +++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80321c26..7e87ebca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,61 +4,64 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - container: csmiet/testspec env: - MACHINE: docker SPEC_PATH: ${{ github.workspace }} PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: - - name: checkout sources - uses: actions/checkout@master - - name: install scipy - run: | - pip3 install scipy - - name: compile_xspec - run: | - cd ${SPEC_PATH} - make -j BUILD_ENV=gfortran xspec - - name: compile_dspec - run: | - cd ${SPEC_PATH} - make BUILD_ENV=gfortran dspec - - name: run_fast_cartesian - run: | - cd ${SPEC_PATH}/ci/G1V03L2Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G1V03L2Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - - name: run_fast_cylinder - run: | - cd ${SPEC_PATH}/ci/G2V32L1Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G2V32L1Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 - - name: toroidal_freeboundary_vacuum - run: | - cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr_LU.sp - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr.sp - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - - name: current_constraint_fixed_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fi - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - - name: current_constraint_free_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fr - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fr.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 + - uses: actions/checkout@v3 + - name: Python version info + run: | + python3 --version + pip3 --version + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + pip3 install --user numpy f90nml scikit-build scipy h5py + - name: compile_xspec + run: | + cd ${SPEC_PATH} + make -j BUILD_ENV=gfortran_ubuntu xspec + - name: compile_dspec + run: | + cd ${SPEC_PATH} + make BUILD_ENV=gfortran_ubuntu dspec + - name: run_fast_cartesian + run: | + cd ${SPEC_PATH}/ci/G1V03L2Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G1V03L2Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 + - name: run_fast_cylinder + run: | + cd ${SPEC_PATH}/ci/G2V32L1Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G2V32L1Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 + - name: toroidal_freeboundary_vacuum + run: | + cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr_LU.sp + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr.sp + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 + - name: current_constraint_fixed_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fi + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 + - name: current_constraint_free_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fr + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fr.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 From e6912c9070da5a2143d4469f67c2a700abf5e7a6 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 12:52:37 +0200 Subject: [PATCH 075/134] do import ci now that it is included in setup.py --- Utilities/pythontools/py_spec/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index bbfd4491..faa44d26 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,6 +1,6 @@ # import of all SPEC-related python scripts. __version__ = "3.3.3" -#from .ci import test +from .ci import test from .input.spec_namelist import SPECNamelist from .output.spec import SPECout From 6fc90a8c46380c691959c1b13e7d06fb7c275bad Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 13:02:45 +0200 Subject: [PATCH 076/134] changed cmake-build to ubuntu container as well --- .github/workflows/build.yml | 2 +- .github/workflows/build_cmake.yml | 117 +++++++++++++++--------------- 2 files changed, 59 insertions(+), 60 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e87ebca..aabb9598 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: run: | sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev - pip3 install --user numpy f90nml scikit-build scipy h5py + pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib - name: compile_xspec run: | cd ${SPEC_PATH} diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 6f9a6d48..a377ac1a 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -4,69 +4,68 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - container: csmiet/testspec env: - MACHINE: docker SPEC_PATH: ${{ github.workspace }} PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: - - name: checkout sources - uses: actions/checkout@master - - name: Install prereqs - run: | - pip3 install --upgrade pip - pip3 install ninja cmake scipy - yum install -y hdf5-static - - name: Build & Test - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{ runner.workspace }}/build - build-type: Release - # Extra options pass to cmake while configuring project - configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install - # install the build using cmake --install - install-build: true - #- name: compile_xspec - # run: | - # pip3 install ninja cmake - # cd ${SPEC_PATH}/build - # cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE .. -GNinja -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install - # cmake --build . - # cmake --install . - - name: run_fast_cartesian - run: | - cd ${SPEC_PATH}/ci/G1V03L2Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G1V03L2Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - - name: run_fast_cylinder - run: | - cd ${SPEC_PATH}/ci/G2V32L1Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G2V32L1Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 - - name: toroidal_freeboundary_vacuum - run: | - cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr_LU.sp - mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr.sp - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - - name: current_constraint_fixed_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fi - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - - name: current_constraint_free_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fr - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fr.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 + - uses: actions/checkout@v3 + - name: Install prereqs + run: | + sudo apt-get update + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + pip3 install --upgrade pip + pip3 install --user ninja cmake scipy + pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib + - name: Build & Test + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{ runner.workspace }}/build + build-type: Release + # Extra options pass to cmake while configuring project + configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install + # install the build using cmake --install + install-build: true + #- name: compile_xspec + # run: | + # pip3 install ninja cmake + # cd ${SPEC_PATH}/build + # cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE .. -GNinja -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install + # cmake --build . + # cmake --install . + - name: run_fast_cartesian + run: | + cd ${SPEC_PATH}/ci/G1V03L2Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 3 --allow-run-as-root xspec G1V03L2Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 + - name: run_fast_cylinder + run: | + cd ${SPEC_PATH}/ci/G2V32L1Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root xspec G2V32L1Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 + - name: toroidal_freeboundary_vacuum + run: | + cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum + export OMP_NUM_THREADS=1 + mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr_LU.sp + mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr.sp + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 + - name: current_constraint_fixed_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fi + export OMP_NUM_THREADS=1 + mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 + - name: current_constraint_free_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fr + export OMP_NUM_THREADS=1 + mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fr.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 From f7c0fe85869c494edf21b472fa98b2fa3ff83846 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 13:35:57 +0200 Subject: [PATCH 077/134] turn off fail_fast and cmake install locally --- .github/workflows/build.yml | 2 ++ .github/workflows/build_cmake.yml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index aabb9598..25cb635a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,8 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false env: SPEC_PATH: ${{ github.workspace }} PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index a377ac1a..30561c21 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -4,6 +4,8 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest + strategy: + fail-fast: false env: SPEC_PATH: ${{ github.workspace }} PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools @@ -24,7 +26,7 @@ jobs: build-dir: ${{ runner.workspace }}/build build-type: Release # Extra options pass to cmake while configuring project - configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install + configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install # install the build using cmake --install install-build: true #- name: compile_xspec From 508ed4908541ea2855dcce65f1e1fc207cdd7e80 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 14:07:12 +0200 Subject: [PATCH 078/134] try different prefix path for cmake build --- .github/workflows/build_cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 30561c21..890408ca 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -26,7 +26,7 @@ jobs: build-dir: ${{ runner.workspace }}/build build-type: Release # Extra options pass to cmake while configuring project - configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install + configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install # install the build using cmake --install install-build: true #- name: compile_xspec From 43c6e1cc4f476654df17a56d42dcc9ee74b7baea Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 14:14:13 +0200 Subject: [PATCH 079/134] reduce mpiexex to two cores as github action machines only have two now --- .github/workflows/build_cmake.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 890408ca..ee7b151a 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -41,7 +41,7 @@ jobs: cd ${SPEC_PATH}/ci/G1V03L2Fi echo ${PYTHONPATH} export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G1V03L2Fi.001.sp + mpiexec -n 2 --allow-run-as-root xspec G1V03L2Fi.001.sp python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - name: run_fast_cylinder run: | @@ -54,20 +54,20 @@ jobs: run: | cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr_LU.sp - mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr.sp + mpiexec -n 2 --allow-run-as-root xspec G3V02L0Fr_LU.sp + mpiexec -n 2 --allow-run-as-root xspec G3V02L0Fr.sp python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - name: current_constraint_fixed_boundary run: | cd ${SPEC_PATH}/ci/G3V08L3Fi export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fi.001.sp + mpiexec -n 2 --allow-run-as-root xspec G3V08L3Fi.001.sp python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - name: current_constraint_free_boundary run: | cd ${SPEC_PATH}/ci/G3V08L3Fr export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fr.001.sp + mpiexec -n 2 --allow-run-as-root xspec G3V08L3Fr.001.sp python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 From 0d92568faa6f12013c94e59542388bf8557ae852 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 14:29:42 +0200 Subject: [PATCH 080/134] run executable from install path as action-cmake-build does not have permission in ubuntu-latest container --- .github/workflows/build_cmake.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index ee7b151a..81feb19d 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -41,33 +41,33 @@ jobs: cd ${SPEC_PATH}/ci/G1V03L2Fi echo ${PYTHONPATH} export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G1V03L2Fi.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G1V03L2Fi.001.sp python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - name: run_fast_cylinder run: | cd ${SPEC_PATH}/ci/G2V32L1Fi echo ${PYTHONPATH} export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G2V32L1Fi.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G2V32L1Fi.001.sp python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 - name: toroidal_freeboundary_vacuum run: | cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G3V02L0Fr_LU.sp - mpiexec -n 2 --allow-run-as-root xspec G3V02L0Fr.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V02L0Fr_LU.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V02L0Fr.sp python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - name: current_constraint_fixed_boundary run: | cd ${SPEC_PATH}/ci/G3V08L3Fi export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G3V08L3Fi.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V08L3Fi.001.sp python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - name: current_constraint_free_boundary run: | cd ${SPEC_PATH}/ci/G3V08L3Fr export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G3V08L3Fr.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V08L3Fr.001.sp python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 From c4e1ad57b171a06123706cbf38de262ea590627a Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 14:50:58 +0200 Subject: [PATCH 081/134] fix executable path --- .github/workflows/build_cmake.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 81feb19d..866a50a9 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -41,33 +41,33 @@ jobs: cd ${SPEC_PATH}/ci/G1V03L2Fi echo ${PYTHONPATH} export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G1V03L2Fi.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G1V03L2Fi.001.sp python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - name: run_fast_cylinder run: | cd ${SPEC_PATH}/ci/G2V32L1Fi echo ${PYTHONPATH} export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G2V32L1Fi.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G2V32L1Fi.001.sp python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 - name: toroidal_freeboundary_vacuum run: | cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V02L0Fr_LU.sp - mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V02L0Fr.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V02L0Fr_LU.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V02L0Fr.sp python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - name: current_constraint_fixed_boundary run: | cd ${SPEC_PATH}/ci/G3V08L3Fi export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V08L3Fi.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V08L3Fi.001.sp python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - name: current_constraint_free_boundary run: | cd ${SPEC_PATH}/ci/G3V08L3Fr export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/xspec G3V08L3Fr.001.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V08L3Fr.001.sp python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 From 083ed69623e525d0a4c7c5f666871b4820335791 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 15:11:47 +0200 Subject: [PATCH 082/134] retrigger checks From 95ea0bc7255b8b31c45d19e49f92f9f66ef59982 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 15:31:11 +0200 Subject: [PATCH 083/134] retrigger checks From a98246df6f3a4a5b484c13a8d3620189434a66cc Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 16:12:23 +0200 Subject: [PATCH 084/134] trigger checks with updated workflows --- .github/workflows/build.yml | 3 +++ .github/workflows/build_cmake.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6e47299..80321c26 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,6 +14,9 @@ jobs: steps: - name: checkout sources uses: actions/checkout@master + - name: install scipy + run: | + pip3 install scipy - name: compile_xspec run: | cd ${SPEC_PATH} diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 1888627d..6f9a6d48 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -17,7 +17,7 @@ jobs: - name: Install prereqs run: | pip3 install --upgrade pip - pip3 install ninja cmake + pip3 install ninja cmake scipy yum install -y hdf5-static - name: Build & Test uses: ashutoshvarma/action-cmake-build@master From 261d2518c118ffeb2ceba07a489d3047fb8fce96 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 16 Oct 2023 16:15:50 +0200 Subject: [PATCH 085/134] now with correct updated workflows --- .github/workflows/build.yml | 103 ++++++++++++++------------ .github/workflows/build_cmake.yml | 119 +++++++++++++++--------------- 2 files changed, 114 insertions(+), 108 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 80321c26..25cb635a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,61 +4,66 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - container: csmiet/testspec + strategy: + fail-fast: false env: - MACHINE: docker SPEC_PATH: ${{ github.workspace }} PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: - - name: checkout sources - uses: actions/checkout@master - - name: install scipy - run: | - pip3 install scipy - - name: compile_xspec - run: | - cd ${SPEC_PATH} - make -j BUILD_ENV=gfortran xspec - - name: compile_dspec - run: | - cd ${SPEC_PATH} - make BUILD_ENV=gfortran dspec - - name: run_fast_cartesian - run: | - cd ${SPEC_PATH}/ci/G1V03L2Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G1V03L2Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - - name: run_fast_cylinder - run: | - cd ${SPEC_PATH}/ci/G2V32L1Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G2V32L1Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 - - name: toroidal_freeboundary_vacuum - run: | - cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr_LU.sp - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr.sp - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - - name: current_constraint_fixed_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fi - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - - name: current_constraint_free_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fr - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fr.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 + - uses: actions/checkout@v3 + - name: Python version info + run: | + python3 --version + pip3 --version + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib + - name: compile_xspec + run: | + cd ${SPEC_PATH} + make -j BUILD_ENV=gfortran_ubuntu xspec + - name: compile_dspec + run: | + cd ${SPEC_PATH} + make BUILD_ENV=gfortran_ubuntu dspec + - name: run_fast_cartesian + run: | + cd ${SPEC_PATH}/ci/G1V03L2Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G1V03L2Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 + - name: run_fast_cylinder + run: | + cd ${SPEC_PATH}/ci/G2V32L1Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G2V32L1Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 + - name: toroidal_freeboundary_vacuum + run: | + cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr_LU.sp + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V02L0Fr.sp + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 + - name: current_constraint_fixed_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fi + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 + - name: current_constraint_free_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fr + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G3V08L3Fr.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 6f9a6d48..866a50a9 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -4,69 +4,70 @@ on: [push, pull_request] jobs: build: runs-on: ubuntu-latest - container: csmiet/testspec + strategy: + fail-fast: false env: - MACHINE: docker SPEC_PATH: ${{ github.workspace }} PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: - - name: checkout sources - uses: actions/checkout@master - - name: Install prereqs - run: | - pip3 install --upgrade pip - pip3 install ninja cmake scipy - yum install -y hdf5-static - - name: Build & Test - uses: ashutoshvarma/action-cmake-build@master - with: - build-dir: ${{ runner.workspace }}/build - build-type: Release - # Extra options pass to cmake while configuring project - configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install - # install the build using cmake --install - install-build: true - #- name: compile_xspec - # run: | - # pip3 install ninja cmake - # cd ${SPEC_PATH}/build - # cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE .. -GNinja -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install - # cmake --build . - # cmake --install . - - name: run_fast_cartesian - run: | - cd ${SPEC_PATH}/ci/G1V03L2Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G1V03L2Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - - name: run_fast_cylinder - run: | - cd ${SPEC_PATH}/ci/G2V32L1Fi - echo ${PYTHONPATH} - export OMP_NUM_THREADS=1 - mpiexec -n 2 --allow-run-as-root xspec G2V32L1Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 - - name: toroidal_freeboundary_vacuum - run: | - cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr_LU.sp - mpiexec -n 3 --allow-run-as-root xspec G3V02L0Fr.sp - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 - python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 - - name: current_constraint_fixed_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fi - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fi.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 - - name: current_constraint_free_boundary - run: | - cd ${SPEC_PATH}/ci/G3V08L3Fr - export OMP_NUM_THREADS=1 - mpiexec -n 3 --allow-run-as-root xspec G3V08L3Fr.001.sp - python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 + - uses: actions/checkout@v3 + - name: Install prereqs + run: | + sudo apt-get update + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + pip3 install --upgrade pip + pip3 install --user ninja cmake scipy + pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib + - name: Build & Test + uses: ashutoshvarma/action-cmake-build@master + with: + build-dir: ${{ runner.workspace }}/build + build-type: Release + # Extra options pass to cmake while configuring project + configure-options: -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install -GNinja # -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install + # install the build using cmake --install + install-build: true + #- name: compile_xspec + # run: | + # pip3 install ninja cmake + # cd ${SPEC_PATH}/build + # cmake -DCMAKE_C_COMPILER=mpicc -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_Fortran_COMPILER=mpifort -DBLA_VENDOR=OpenBLAS -DHDF5_NO_FIND_PACKAGE_CONFIG_FILE=TRUE -DHDF5_PREFER_PARALLEL=TRUE .. -GNinja -DCMAKE_INSTALL_PREFIX=${SPEC_PATH}/install + # cmake --build . + # cmake --install . + - name: run_fast_cartesian + run: | + cd ${SPEC_PATH}/ci/G1V03L2Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G1V03L2Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 + - name: run_fast_cylinder + run: | + cd ${SPEC_PATH}/ci/G2V32L1Fi + echo ${PYTHONPATH} + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G2V32L1Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 + - name: toroidal_freeboundary_vacuum + run: | + cd ${SPEC_PATH}/ci/toroidal_freeboundary_vacuum + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V02L0Fr_LU.sp + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V02L0Fr.sp + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr_LU.sp.h5 --tol 1e-11 + python3 -m py_spec.ci.test compare.h5 G3V02L0Fr.sp.h5 --tol 1e-11 + - name: current_constraint_fixed_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fi + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V08L3Fi.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fi.001.sp.h5 --tol 1e-10 + - name: current_constraint_free_boundary + run: | + cd ${SPEC_PATH}/ci/G3V08L3Fr + export OMP_NUM_THREADS=1 + mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G3V08L3Fr.001.sp + python3 -m py_spec.ci.test compare.h5 G3V08L3Fr.001.sp.h5 --tol 1e-10 From 373436216042b7775fc0cc6965eb987e0b242f94 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 31 Oct 2023 17:01:13 +0100 Subject: [PATCH 086/134] replace deprecated np.fload with np.float64 https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations --- Utilities/pythontools/py_spec/input/spec_namelist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/pythontools/py_spec/input/spec_namelist.py b/Utilities/pythontools/py_spec/input/spec_namelist.py index 2e8a59b1..d40605e0 100644 --- a/Utilities/pythontools/py_spec/input/spec_namelist.py +++ b/Utilities/pythontools/py_spec/input/spec_namelist.py @@ -637,7 +637,7 @@ def _rectify_namelist(self): for key in self.boundary_keys: if key.lower() not in self["physicslist"].keys(): self["physicslist"][key] = np.zeros( - [self._Mpol, self._Ntor * 2 + 1], dtype=np.float + [self._Mpol, self._Ntor * 2 + 1], dtype=np.float64 ).tolist() self["physicslist"].start_index[key.lower()] = [-self._Ntor, 0] else: @@ -651,7 +651,7 @@ def _rectify_namelist(self): for key in self.axis_keys: if key.lower() not in self["physicslist"].keys(): self["physicslist"][key] = np.zeros( - [self._Ntor + 1], dtype=np.float + [self._Ntor + 1], dtype=np.float64 ).tolist() self["physicslist"].start_index[key.lower()] = [0] else: From dfeb64775b2de4b5ca371f4e77613cdfcdd26794 Mon Sep 17 00:00:00 2001 From: Joaquim Loizu Date: Thu, 30 Nov 2023 17:48:30 +0100 Subject: [PATCH 087/134] fix bug in writing .sp.end, when Lconstraint.\neq.3 and Nvol=1 Isurf was printing nothing and could not restart run --- src/global.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/global.f90 b/src/global.f90 index ef5056fe..c8529c78 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -1654,7 +1654,7 @@ subroutine wrtend write(iunit,'(" adiabatic = ",257es23.15)') adiabatic(1:Mvol) write(iunit,'(" mu = ",257es23.15)') mu(1:Mvol) write(iunit,'(" Ivolume = ",257es23.15)') Ivolume(1:Mvol) - write(iunit,'(" Isurf = ",257es23.15)') Isurf(1:Mvol-1) + write(iunit,'(" Isurf = ",257es23.15)') Isurf(1:Mvol-1), 0.0 write(iunit,'(" Lconstraint = ",i9 )') Lconstraint write(iunit,'(" pl = ",257i23 )') pl(0:Mvol) write(iunit,'(" ql = ",257i23 )') ql(0:Mvol) From ec476ed2f38ab7ec20ab478ffb5fb954677f3263 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 1 Feb 2024 11:30:05 +0100 Subject: [PATCH 088/134] put bnserr into allglobal and write it to hdf5/output --- src/global.f90 | 1 + src/sphdf5.f90 | 6 +++--- src/xspech.f90 | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/global.f90 b/src/global.f90 index c8529c78..2f4be107 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -250,6 +250,7 @@ module allglobal REAL :: ForceErr !< total force-imbalance REAL :: Energy !< MHD energy + REAL :: BnsErr !< (in freeboundary) error in self-consistency of field on plasma boundary (Picard iteration) REAL , allocatable :: IPDt(:), IPDtDpf(:,:) !< Toroidal pressure-driven current diff --git a/src/sphdf5.f90 b/src/sphdf5.f90 index 5f4d144f..756414c9 100644 --- a/src/sphdf5.f90 +++ b/src/sphdf5.f90 @@ -982,7 +982,7 @@ subroutine hdfint use fileunits, only : ounit use inputlist use allglobal, only : ncpu, cpus, & - Mvol, ForceErr, & + Mvol, ForceErr, BnsErr,& mn, im, in, iRbc, iZbs, iRbs, iZbc, & mns, ims, ins, & dRbc, dZbs, dRbs, dZbc, & @@ -1042,8 +1042,8 @@ subroutine hdfint HWRITERA( grpOutput, mn, (Mvol+1), Rbs, iRbs(1:mn,0:Mvol) ) !latex \type{iZbc(1:mn,0:Mvol)} & real & \pb{Fourier harmonics, $Z_{m,n}$, of interfaces} \\ HWRITERA( grpOutput, mn, (Mvol+1), Zbc, iZbc(1:mn,0:Mvol) ) -!l tex \type{forcetol} & real & \pb{force-balance error across interfaces} \\ -! HWRITERV( grpOutput, 1, forcetol, (/ forcetol /)) ! already in /input/global +!latex \type{BnsErr} & real & \pb{error in self-consistency of field on plasma boundary (in freeboundary)} \\ + HWRITERV( grpOutput, 1, BnsErr, (/ BnsErr /)) ! already in /input/global !latex \type{ForceErr} & real & \pb{force-balance error across interfaces} \\ HWRITERV( grpOutput, 1, ForceErr, (/ ForceErr /)) !latex \type{Ivolume} & real & \pb{Volume current at output (parallel, externally induced)} diff --git a/src/xspech.f90 b/src/xspech.f90 index 1bb7b694..0ceb417c 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -308,7 +308,7 @@ subroutine spec Lcoordinatesingularity, Lplasmaregion, Lvacuumregion, & dtflux, dpflux, & ImagneticOK, & - ForceErr, & + ForceErr, BnsErr,& efmn, ofmn, cfmn, sfmn, & iBns, iBnc, iVns, iVnc, & Ate, Aze, Ato, Azo, & ! only required for debugging; 09 Mar 17; @@ -326,7 +326,7 @@ subroutine spec LOGICAL :: LComputeDerivatives, LContinueFreeboundaryIterations, exist, LupdateBn, LComputeAxis INTEGER :: imn, lmn, lNfp, lim, lin, ii, ideriv, stat INTEGER :: vvol, ifail, wflag, iflag, vflag - REAL :: rflag, lastcpu, bnserr, lRwc, lRws, lZwc, lZws, lItor, lGpol, lgBc, lgBs + REAL :: rflag, lastcpu, lRwc, lRws, lZwc, lZws, lItor, lGpol, lgBc, lgBs REAL, allocatable :: position(:), gradient(:) CHARACTER :: pack INTEGER :: Lfindzero_old, mfreeits_old From 7b4e9019835fe60af57278570ae7c6b86e062de7 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 1 Feb 2024 11:40:14 +0100 Subject: [PATCH 089/134] update spec and pythonwrapped spec version numbers --- setup.py | 2 +- src/global.f90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8af1e4f2..b42480ee 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ setup( name="spec", - version="0.0.1", + version="0.0.2", #license="MIT", packages=['spec'], package_dir={'': 'Utilities/python_wrapper'}, diff --git a/src/global.f90 b/src/global.f90 index 2f4be107..b5084e07 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -66,7 +66,7 @@ module constants REAL, parameter :: mu0 = 2.0E-07 * pi2 !< \f$4\pi\cdot10^{-7}\f$ REAL, parameter :: goldenmean = 1.618033988749895 !< golden mean = \f$( 1 + \sqrt 5 ) / 2\f$ ; - REAL, parameter :: version = 3.21 !< version of SPEC + REAL, parameter :: version = 3.22 !< version of SPEC end module constants From e5ea4e3a9bf4cb0c0ebd63e33b73a9a24eb7142e Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 24 Jun 2024 17:03:52 +0200 Subject: [PATCH 090/134] update py_spec to python2.0 --- Utilities/pythontools/requirements.txt | 2 +- Utilities/pythontools/setup.py | 2 ++ src/hesian.f90 | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Utilities/pythontools/requirements.txt b/Utilities/pythontools/requirements.txt index 79349753..4891555d 100644 --- a/Utilities/pythontools/requirements.txt +++ b/Utilities/pythontools/requirements.txt @@ -1,7 +1,7 @@ h5py matplotlib f90nml -numpy +numpy>2.0 # Version 1.7.0 or higher is required - otherwise scipy.integrate.simpson does not exist scipy>=1.7.0 diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 67d45afd..a1ef5439 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -7,6 +7,8 @@ setuptools.setup( name="py_spec", version=__version__, + setup_requires=["numpy>=2.0"], + install_requires=["numpy>=1.23.5"], description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", long_description=long_description, long_description_content_type="text/markdown", diff --git a/src/hesian.f90 b/src/hesian.f90 index d4fb9e33..2ea18d90 100644 --- a/src/hesian.f90 +++ b/src/hesian.f90 @@ -1,7 +1,7 @@ !> \file -!> \brief Computes eigenvalues and eigenvectors of derivative matrix, \f$\nabla_{\bf \xi}{\bf F}\f$. +!> \brief Computes eigenvalues and eigenvectors of derivative matrix, \f$\nabla_{\bf xi}{\bf F}\f$. -!> \brief Computes eigenvalues and eigenvectors of derivative matrix, \f$\nabla_{\bf \xi}{\bf F}\f$. +!> \brief Computes eigenvalues and eigenvectors of derivative matrix, \f$\nabla_{\bf xi}{\bf F}\f$. !> \ingroup grp_diagnostics !> !> @param[in] NGdof number of global degrees of freedom From 2dcbec12963aed1b03dc2515227b2dc499bbcf96 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 11:54:25 +0200 Subject: [PATCH 091/134] require numpy2 for compilation, not install --- Utilities/pythontools/requirements.txt | 1 - Utilities/pythontools/setup.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Utilities/pythontools/requirements.txt b/Utilities/pythontools/requirements.txt index 4891555d..987fc86c 100644 --- a/Utilities/pythontools/requirements.txt +++ b/Utilities/pythontools/requirements.txt @@ -1,7 +1,6 @@ h5py matplotlib f90nml -numpy>2.0 # Version 1.7.0 or higher is required - otherwise scipy.integrate.simpson does not exist scipy>=1.7.0 diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index a1ef5439..31fac2bf 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -8,7 +8,7 @@ name="py_spec", version=__version__, setup_requires=["numpy>=2.0"], - install_requires=["numpy>=1.23.5"], + install_requires=["numpy>=1.21.1"], description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", long_description=long_description, long_description_content_type="text/markdown", From 9a8da7e544e7eded9d21a883f99ce1318bc7ce2a Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 14:39:12 +0200 Subject: [PATCH 092/134] install f90wrap branch that supports numpy 2.0 --- .github/workflows/python_wrapper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 55952dfe..a5f73e26 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -19,7 +19,7 @@ jobs: sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev cmake ninja-build pip3 install --user numpy f90nml scikit-build scipy - pip3 install --user git+https://github.com/zhucaoxiang/f90wrap + pip3 install --user git+https://github.com/zhucaoxiang/f90wrap@main_off - name: Build python_wrapper run: | From 46e1dfdd69bc4a94424ceeb4e551b6a63f0876f6 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 14:49:05 +0200 Subject: [PATCH 093/134] update python wrapper build --- .github/workflows/python_wrapper.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index a5f73e26..11d23371 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -6,26 +6,25 @@ jobs: name: python_wrapper build steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # Python3 should be pre-installed on 'ubuntu-latest' - name: Python version info run: | - python3 --version - pip3 --version + python --version + pip --version - name: Install dependencies run: | sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev cmake ninja-build - pip3 install --user numpy f90nml scikit-build scipy - pip3 install --user git+https://github.com/zhucaoxiang/f90wrap@main_off + pip install numpy f90nml scikit-build scipy + pip install git+https://github.com/zhucaoxiang/f90wrap@main_off - name: Build python_wrapper run: | - python3 setup.py bdist_wheel - pip3 install --user dist/*.whl + pip install . - name: Test if installation is ok run: | - python3 -c "import spec; print('success')" + python -c "import spec; print('success')" From 3197eea1f620bb78a516636d5d47d3b9a6ecbf16 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 15:03:50 +0200 Subject: [PATCH 094/134] install meson for f90wrap build --- .github/workflows/python_wrapper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 11d23371..564dafa3 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev cmake ninja-build + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev cmake ninja-build meson pip install numpy f90nml scikit-build scipy pip install git+https://github.com/zhucaoxiang/f90wrap@main_off From b2fa8bbde4a4d831691d770dc13d3a4427afbc75 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 15:07:04 +0200 Subject: [PATCH 095/134] test if generic hdf5 version gets newer meson --- .github/workflows/python_wrapper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 564dafa3..b94680b1 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev cmake ninja-build meson + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas-dev cmake ninja-build meson pip install numpy f90nml scikit-build scipy pip install git+https://github.com/zhucaoxiang/f90wrap@main_off From b16904d1106c29c3872ca0ac29b38bdf55ebf076 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 15:12:54 +0200 Subject: [PATCH 096/134] install meson and python-meson --- .github/workflows/python_wrapper.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index b94680b1..1778abb6 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -17,8 +17,8 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas-dev cmake ninja-build meson - pip install numpy f90nml scikit-build scipy + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas-dev cmake ninja-build + pip install numpy f90nml scikit-build scipy meson python-meson pip install git+https://github.com/zhucaoxiang/f90wrap@main_off - name: Build python_wrapper From 8725b4685dee5f656f5e4a762a5e05375af5ce41 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 25 Jun 2024 15:14:11 +0200 Subject: [PATCH 097/134] fix typo pip install meson-python --- .github/workflows/python_wrapper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 1778abb6..4c0e672d 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -18,7 +18,7 @@ jobs: run: | sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas-dev cmake ninja-build - pip install numpy f90nml scikit-build scipy meson python-meson + pip install numpy f90nml scikit-build scipy meson meson-python pip install git+https://github.com/zhucaoxiang/f90wrap@main_off - name: Build python_wrapper From c7a7c39a001caae447ef87fe44b3434a364fa468 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 26 Jun 2024 09:25:43 +0200 Subject: [PATCH 098/134] update version of wrapper; all 3 minor changes --- Utilities/pythontools/py_spec/__init__.py | 2 +- setup.py | 2 +- src/global.f90 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 5203a4a5..2add5e0e 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,5 +1,5 @@ # import of all SPEC-related python scripts. -__version__ = "3.3.3" +__version__ = "3.3.4" from .ci import test from .input.spec_namelist import SPECNamelist diff --git a/setup.py b/setup.py index b42480ee..e0ac7fad 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ setup( name="spec", - version="0.0.2", + version="0.0.3", #license="MIT", packages=['spec'], package_dir={'': 'Utilities/python_wrapper'}, diff --git a/src/global.f90 b/src/global.f90 index b5084e07..1429473f 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -66,7 +66,7 @@ module constants REAL, parameter :: mu0 = 2.0E-07 * pi2 !< \f$4\pi\cdot10^{-7}\f$ REAL, parameter :: goldenmean = 1.618033988749895 !< golden mean = \f$( 1 + \sqrt 5 ) / 2\f$ ; - REAL, parameter :: version = 3.22 !< version of SPEC + REAL, parameter :: version = 3.23 !< version of SPEC end module constants From aac5eb8a836c9a4bf7e0c67c06e4b4ebb307878a Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 27 Jun 2024 14:11:42 +0200 Subject: [PATCH 099/134] specify oldest numpy for python 3.8 --- Utilities/pythontools/setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 31fac2bf..13c3cc63 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -7,7 +7,8 @@ setuptools.setup( name="py_spec", version=__version__, - setup_requires=["numpy>=2.0"], + setup_requires=["numpy>=2.0.0; python_version > '3.8'", + "oldest-supported-numpy; python_version <= '3.8'"], install_requires=["numpy>=1.21.1"], description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", long_description=long_description, From bc927edd15b54192916d4247b19b378998208f29 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 10:43:31 +0200 Subject: [PATCH 100/134] add dependencies to setup.py, remove numpy2.0 install dep --- Utilities/pythontools/setup.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 13c3cc63..8939555a 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -7,9 +7,13 @@ setuptools.setup( name="py_spec", version=__version__, - setup_requires=["numpy>=2.0.0; python_version > '3.8'", - "oldest-supported-numpy; python_version <= '3.8'"], - install_requires=["numpy>=1.21.1"], + setup_requires=["numpy"] + install_requires=["numpy>=1.21.1", + "coilpy", + "f90nml", + "h5py", + "matplotlib" + "scipy>=1.7.0"], description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", long_description=long_description, long_description_content_type="text/markdown", From 91d4eb04817f61b09cd967970e922d65fb06f963 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 11:00:18 +0200 Subject: [PATCH 101/134] setup reqs not needed, same as install --- Utilities/pythontools/setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 8939555a..c956a4db 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -7,7 +7,6 @@ setuptools.setup( name="py_spec", version=__version__, - setup_requires=["numpy"] install_requires=["numpy>=1.21.1", "coilpy", "f90nml", From 5cec0da5410682996a40918306c62c9b1850af04 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 11:03:08 +0200 Subject: [PATCH 102/134] fix typo --- Utilities/pythontools/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index c956a4db..9cd98ced 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -11,7 +11,7 @@ "coilpy", "f90nml", "h5py", - "matplotlib" + "matplotlib", "scipy>=1.7.0"], description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", long_description=long_description, From 9f960450806336ab2755424ddcd43fcf82f1f25a Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 11:09:36 +0200 Subject: [PATCH 103/134] see if install without requirements.txt --- .github/workflows/py_spec.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/py_spec.yml b/.github/workflows/py_spec.yml index f621c376..66ce4093 100644 --- a/.github/workflows/py_spec.yml +++ b/.github/workflows/py_spec.yml @@ -19,7 +19,6 @@ jobs: working-directory: ${{ env.PY_SPEC_DIR }} run: | pip install --upgrade pip - pip3 install -r requirements.txt pip3 install setuptools wheel twine - name: Build py_spec From 29bf378760511fc4ceaba3966f9cc97513d26e50 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 12:13:23 +0200 Subject: [PATCH 104/134] move versioning to setup.py to remove install-time cirular, all deps as install_deps. remove coilpy as a dep since distutils is deprecated. --- Utilities/pythontools/py_spec/__init__.py | 9 +++++++-- Utilities/pythontools/setup.py | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 2add5e0e..96905436 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -1,5 +1,10 @@ -# import of all SPEC-related python scripts. -__version__ = "3.3.4" +try: + from importlib import metadata +except ImportError: + # Running on pre-3.8 Python; use importlib-metadata package + import importlib_metadata as metadata + +__version__ = metadata.version('py_spec') from .ci import test from .input.spec_namelist import SPECNamelist diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 9cd98ced..6f590d6c 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -1,14 +1,12 @@ import setuptools -from py_spec import __version__ with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="py_spec", - version=__version__, + version="3.3.5", install_requires=["numpy>=1.21.1", - "coilpy", "f90nml", "h5py", "matplotlib", From f876601015e45b492611d1fbced3247e8b618c79 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 12:39:27 +0200 Subject: [PATCH 105/134] only install coilpy if python below 3.12 --- Utilities/pythontools/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 6f590d6c..52842ec3 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -10,6 +10,7 @@ "f90nml", "h5py", "matplotlib", + "coilpy; python_version<'3.12'", "scipy>=1.7.0"], description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", long_description=long_description, From dadf217ba7f49ebe83c7e9d1daab9faf3e3af772 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 13:07:25 +0200 Subject: [PATCH 106/134] switch to installed ci instead of path-dependent --- .github/workflows/build.yml | 5 ++--- .github/workflows/build_cmake.yml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25cb635a..d6b8fb7a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ jobs: fail-fast: false env: SPEC_PATH: ${{ github.workspace }} - PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: @@ -22,6 +21,8 @@ jobs: sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib + cd ${{ github.workspace }}/Utilities/pythontools + pip3 install -v . - name: compile_xspec run: | cd ${SPEC_PATH} @@ -33,14 +34,12 @@ jobs: - name: run_fast_cartesian run: | cd ${SPEC_PATH}/ci/G1V03L2Fi - echo ${PYTHONPATH} export OMP_NUM_THREADS=1 mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G1V03L2Fi.001.sp python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - name: run_fast_cylinder run: | cd ${SPEC_PATH}/ci/G2V32L1Fi - echo ${PYTHONPATH} export OMP_NUM_THREADS=1 mpiexec -n 2 --allow-run-as-root ${SPEC_PATH}/xspec G2V32L1Fi.001.sp python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 866a50a9..3ea86651 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -8,7 +8,6 @@ jobs: fail-fast: false env: SPEC_PATH: ${{ github.workspace }} - PYTHONPATH: ${{ github.workspace }}/Utilities/pythontools OMPI_ALLOW_RUN_AS_ROOT: 1 OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 steps: @@ -20,6 +19,8 @@ jobs: pip3 install --upgrade pip pip3 install --user ninja cmake scipy pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib + cd ${{ github.workspace }}/Utilities/pythontools + pip3 install -v . - name: Build & Test uses: ashutoshvarma/action-cmake-build@master with: @@ -39,14 +40,12 @@ jobs: - name: run_fast_cartesian run: | cd ${SPEC_PATH}/ci/G1V03L2Fi - echo ${PYTHONPATH} export OMP_NUM_THREADS=1 mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G1V03L2Fi.001.sp python3 -m py_spec.ci.test compare.h5 G1V03L2Fi.001.sp.h5 - name: run_fast_cylinder run: | cd ${SPEC_PATH}/ci/G2V32L1Fi - echo ${PYTHONPATH} export OMP_NUM_THREADS=1 mpiexec -n 2 --allow-run-as-root $SPEC_PATH/install/bin/xspec G2V32L1Fi.001.sp python3 -m py_spec.ci.test compare.h5 G2V32L1Fi.001.sp.h5 From b67940c0e55198cd712787b17cd98595ed496f1c Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 28 Jun 2024 13:17:24 +0200 Subject: [PATCH 107/134] add py_spec.math --- Utilities/pythontools/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 52842ec3..5fca95cf 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -24,5 +24,5 @@ url="https://princetonuniversity.github.io/SPEC/", author="SPEC developers", license="GNU 3.0", - packages=['py_spec', 'py_spec.input', 'py_spec.output', 'py_spec.ci'] + packages=['py_spec', 'py_spec.input', 'py_spec.output', 'py_spec.ci', 'py_spec.math'] ) From 63923fec6ff7a46bcdd101bbf47ff1c2cf083dbf Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 4 Jul 2024 09:43:32 +0200 Subject: [PATCH 108/134] moved to pyproject.toml and included py_spec.math --- Utilities/pythontools/pyproject.toml | 31 ++++++++++++++++++++++++++++ Utilities/pythontools/setup.py | 23 --------------------- 2 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 Utilities/pythontools/pyproject.toml diff --git a/Utilities/pythontools/pyproject.toml b/Utilities/pythontools/pyproject.toml new file mode 100644 index 00000000..60e6e551 --- /dev/null +++ b/Utilities/pythontools/pyproject.toml @@ -0,0 +1,31 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + + +[project] +name="py_spec" +version="3.3.5" +dependencies = ["numpy>=1.21.1", + "f90nml", + "h5py", + "matplotlib", + "coilpy; python_version<'3.12'", + "scipy>=1.7.0"] +description="SPEC(Stepped-Pressure Equilibrium Code) python utilities" +readme="README.md" +authors = [ + { name = "Christopher Berg Smiet", email = "christopher.smiet@epfl.ch" }, + { name = "Caoxiang Zhu", email = "caoxiangzhu@gmail.com" }, + { name = "SPEC developers"} +] +maintainers = [ + { name = "Christopher Berg Smiet", email = "christopher.smiet@epfl.ch" }, +] +classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering", +] +license = {text = "GNU 3.0"} diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 5fca95cf..b1d37c93 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -1,28 +1,5 @@ import setuptools -with open("README.md", "r") as fh: - long_description = fh.read() - setuptools.setup( - name="py_spec", - version="3.3.5", - install_requires=["numpy>=1.21.1", - "f90nml", - "h5py", - "matplotlib", - "coilpy; python_version<'3.12'", - "scipy>=1.7.0"], - description="SPEC(Stepped-Pressure Equilibrium Code) python utilities", - long_description=long_description, - long_description_content_type="text/markdown", - classifiers=[ - "Development Status :: 3 - Alpha", - "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", - "Programming Language :: Python :: 3", - "Topic :: Scientific/Engineering", - ], - url="https://princetonuniversity.github.io/SPEC/", - author="SPEC developers", - license="GNU 3.0", packages=['py_spec', 'py_spec.input', 'py_spec.output', 'py_spec.ci', 'py_spec.math'] ) From 628b282f6f0d7ed465537cde984dcb52620cc1e7 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 4 Jul 2024 13:31:45 +0200 Subject: [PATCH 109/134] update versioning resolution --- Utilities/pythontools/py_spec/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/__init__.py b/Utilities/pythontools/py_spec/__init__.py index 96905436..412e22fa 100644 --- a/Utilities/pythontools/py_spec/__init__.py +++ b/Utilities/pythontools/py_spec/__init__.py @@ -4,7 +4,7 @@ # Running on pre-3.8 Python; use importlib-metadata package import importlib_metadata as metadata -__version__ = metadata.version('py_spec') +__version__ = metadata.version(__package__ or __name__) from .ci import test from .input.spec_namelist import SPECNamelist From de57e4fd8cdd03eaff4363f74db9e48b8c1cbdaa Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 4 Jul 2024 13:42:14 +0200 Subject: [PATCH 110/134] update to use upstream f90wrap --- .github/workflows/python_wrapper.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 4c0e672d..8977807c 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -19,7 +19,7 @@ jobs: sudo apt-get update sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas-dev cmake ninja-build pip install numpy f90nml scikit-build scipy meson meson-python - pip install git+https://github.com/zhucaoxiang/f90wrap@main_off + pip install f90wrap - name: Build python_wrapper run: | From 85cf14ab2abd2759301747b406c281f61322dfc6 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 4 Jul 2024 13:42:36 +0200 Subject: [PATCH 111/134] specify name in setup() --- Utilities/pythontools/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index b1d37c93..40736833 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -1,5 +1,6 @@ import setuptools setuptools.setup( + name="py_spec" packages=['py_spec', 'py_spec.input', 'py_spec.output', 'py_spec.ci', 'py_spec.math'] ) From c4683bad29d067c9dab3c0467d7d8bfd141e5a81 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 4 Jul 2024 14:31:08 +0200 Subject: [PATCH 112/134] typo in setup.py --- Utilities/pythontools/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/setup.py b/Utilities/pythontools/setup.py index 40736833..7aa39660 100644 --- a/Utilities/pythontools/setup.py +++ b/Utilities/pythontools/setup.py @@ -1,6 +1,6 @@ import setuptools setuptools.setup( - name="py_spec" + name="py_spec", packages=['py_spec', 'py_spec.input', 'py_spec.output', 'py_spec.ci', 'py_spec.math'] ) From dace2f1899428fbfad08e5b27d7f4fb7ea420354 Mon Sep 17 00:00:00 2001 From: ErolBa Date: Mon, 15 Jul 2024 17:21:26 +0200 Subject: [PATCH 113/134] Updated the instructions for compilation using cmake --- compilation_instructions.md | 113 ++++++++++++++++++ ...md => outdated_compilation_instructions.md | 0 setup_conda.sh | 26 ---- spec_conda_env.yml | 19 --- 4 files changed, 113 insertions(+), 45 deletions(-) create mode 100644 compilation_instructions.md rename Compile.md => outdated_compilation_instructions.md (100%) delete mode 100755 setup_conda.sh delete mode 100644 spec_conda_env.yml diff --git a/compilation_instructions.md b/compilation_instructions.md new file mode 100644 index 00000000..d1aa56e2 --- /dev/null +++ b/compilation_instructions.md @@ -0,0 +1,113 @@ +## SPEC complition instructions + +Guide for installing SPEC including the python wrappers, relies on usign cmake + +### Compilation + +Get the repository and install the necessary compilers and libraries +``` +git clone git@github.com:PrincetonUniversity/SPEC.git +conda create -n "spec_wrapper" python=3.11 +conda activate spec_wrapper +conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64 +conda install hdf5 openblas libopenblas fftw scalapack openmpi cmake ninja +conda install h5py matplotlib f90nml scipy scikit-build mpi4py ipython +pip install f90wrap +``` + +Link to the correct `f2py` +``` +ln -s ~/anaconda3/envs/spec_wrapper/bin/f2py ~/anaconda3/envs/spec_wrapper/bin/f2py3 +``` + +If necessary, unset HDF5 and FFTW environmental variables +``` +unset HDF5, HDF5_ROOT, HDF5_HOME, FFTW, FFTW_DIR +``` + +Finally, install SPEC and the wrapper (logs will be in `compile.log`) +``` +pip install -v . 2>&1 | tee compile.log +``` + +Install the `py_spec` python library +``` +cd Utilities/pythontools/ +pip install -e . +``` + + +### Testing your SPEC installation + +First, verify that the stand-alone executable is usable. +A few test cases are provided in `InputFiles/TestCases`. + +Create a new directory for SPEC runs and change into it + +```bash +mkdir ~/SPEC_runs +cd ~/SPEC_runs +``` + +Copy a demo input file into the current working directory: + +```bash +cp ~/SPEC/InputFiles/TestCases/G3V01L0Fi.001.sp . +``` + +Call SPEC with an input file (`*.sp`) as argument on the command line: + +```bash +xspec G3V01L0Fi.001.sp +``` + +You should see the screen output of the SPEC run. +Among the last lines should be something similar to this: + +``` +ending : 0.88 : myid= 0 ; completion ; time= 0.88s = 0.01m = 0.00h = 0.00d ; date= 2022/02/17 ; time= 17:35:33 ; ext = G1V02L0Fi.001 +ending : : +xspech : : +xspech : 0.88 : myid= 0 : time= 0.01m = 0.00h = 0.00d ; +``` + +This indicates that the stand-alone executable is usable. + +Next, the python wrapper is tested. + +1. Check that the SPEC version can be found: + + ```bash + python -c "from spec import spec_f90wrapped as spec; print('SPEC version: {:}'.format(spec.constants.version))" + ``` + + This should print a message like "SPEC version: 3.1" on the screen. + +2. Check that the Python wrapper can be used as a stand-alone code: + + ```bash + OMP_NUM_THREADS=1 python ~/SPEC/Utilities/python_wrapper/spec/core.py G3V01L0Fi.001.sp + ``` + + This should conclude with the message `SPEC called from python finished!`. + +3. Run the optimization example code: + + ```bash + OMP_NUM_THREADS=1 python ~/SPEC/Utilities/python_wrapper/examples/example.py + ``` + + This should run a basic optimization problem, + where the SPEC inputs are controlled via `scipy.optimize`. + +4. Run the interactive re-convergence example code: + + ```bash + OMP_NUM_THREADS=1 python ~/SPEC/Utilities/python_wrapper/examples/example_2.py + ``` + + This should compute a SPEC equilibrium, then change the central pressure, + re-converge SPEC, etc. for a set of five values of the central pressure + in a two-volume classical Stellarator case. + After the pressure scan with re-convergence, + a plot of the MHD energy vs. the central pressure is shown. \ No newline at end of file diff --git a/Compile.md b/outdated_compilation_instructions.md similarity index 100% rename from Compile.md rename to outdated_compilation_instructions.md diff --git a/setup_conda.sh b/setup_conda.sh deleted file mode 100755 index 12d93104..00000000 --- a/setup_conda.sh +++ /dev/null @@ -1,26 +0,0 @@ - - -# create conda environment for SPEC -conda env create -f spec_conda_env.yml - -# make sure environment variables get managed correctly -pushd ~/anaconda3/envs/spec_env -mkdir -p ./etc/conda/activate.d -mkdir -p ./etc/conda/deactivate.d - -echo " -export OLD_LD_LIBRARY_PATH=\${LD_LIBRARY_PATH} -export LD_LIBRARY_PATH=\${HOME}/anaconda3/envs/spec_env/lib:\${LD_LIBRARY_PATH} - -export FFTW_ROOT=\${HOME}/anaconda3/envs/spec_env -" > ./etc/conda/activate.d/env_vars.sh - -echo " -export LD_LIBRARY_PATH=\${OLD_LD_LIBRARY_PATH} -unset OLD_LD_LIBRARY_PATH - -unset FFTW_ROOT -" > ./etc/conda/deactivate.d/env_vars.sh - -popd - diff --git a/spec_conda_env.yml b/spec_conda_env.yml deleted file mode 100644 index a34a03dd..00000000 --- a/spec_conda_env.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: spec_env -channels: - - conda-forge - - defaults -dependencies: - - c-compiler - - fortran-compiler - - mpi4py - - ninja - - cmake - - scikit-build - - fftw - - hdf5 - - numpy - - openmp - - openblas - - matplotlib - - scipy - From 540ceedbe585e5f07cd4c159862796bf71c267d2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Aug 2024 12:57:16 +0200 Subject: [PATCH 114/134] expanded instructions to cover legacy build methods --- compilation_instructions.md | 94 +++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 15 deletions(-) diff --git a/compilation_instructions.md b/compilation_instructions.md index d1aa56e2..145a21a8 100644 --- a/compilation_instructions.md +++ b/compilation_instructions.md @@ -1,29 +1,35 @@ ## SPEC complition instructions -Guide for installing SPEC including the python wrappers, relies on usign cmake +The default installation for SPEC method for SPEC uses cmake and installs +the python wrappers and an xspec executable. -### Compilation +### Installation using Anaconda + +We recommend you use Anaconda to create a coherent build environment and prevent +dependency conflicts. + +Control over the installation can be had by editing `cmake_config.json`, to guide +CMAKE to the right compilers and BLAS vendor. +Configurations for different machines are stored in ${SPEC_ROOT}/cmake_machines, +to use these, link them to cmake_config.json: `ln -s cmake_config cmake_machines/` + +[!TIP] +install as much as possible in your environment using the `conda` command, +only use 'pip' at the very end for the last packages not in conda. +if you have not added the `conda-forge` channel do so by +`conda config --add channels conda-forge` Get the repository and install the necessary compilers and libraries -``` +```bash git clone git@github.com:PrincetonUniversity/SPEC.git -conda create -n "spec_wrapper" python=3.11 +conda create -n "spec_wrapper" python=3.11 # create your environment for SPEC conda activate spec_wrapper -conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64 +conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64 # conda install hdf5 openblas libopenblas fftw scalapack openmpi cmake ninja conda install h5py matplotlib f90nml scipy scikit-build mpi4py ipython pip install f90wrap ``` -Link to the correct `f2py` -``` -ln -s ~/anaconda3/envs/spec_wrapper/bin/f2py ~/anaconda3/envs/spec_wrapper/bin/f2py3 -``` - -If necessary, unset HDF5 and FFTW environmental variables -``` -unset HDF5, HDF5_ROOT, HDF5_HOME, FFTW, FFTW_DIR -``` Finally, install SPEC and the wrapper (logs will be in `compile.log`) ``` @@ -36,6 +42,20 @@ cd Utilities/pythontools/ pip install -e . ``` +## Troubleshooting Anaconda install +If using a newer version of python, `f2py3` is no longer shipped. If your system contains an old python install (for example from your OS), Cmake can find its `f2py3` and give try to use it to compile the wrappers instead of your environments `f2py`. +Test this by looking if you have an `f2py3` in your path: `$which f2py3`. +The easiest workaround is to soft-link f2py3 to f2py so it is found first. +``` +ln -s ~/anaconda3/envs/spec_wrapper/bin/f2py ~/anaconda3/envs/spec_wrapper/bin/f2py3 +``` + +You might have HDF5 or FFTW environment variables set (for example for a VMEC install). This can throw off cmake, which we want to use only anaconda. +``` +unset HDF5, HDF5_ROOT, HDF5_HOME, FFTW, FFTW_DIR +``` + + ### Testing your SPEC installation @@ -110,4 +130,48 @@ Next, the python wrapper is tested. re-converge SPEC, etc. for a set of five values of the central pressure in a two-volume classical Stellarator case. After the pressure scan with re-convergence, - a plot of the MHD energy vs. the central pressure is shown. \ No newline at end of file + a plot of the MHD energy vs. the central pressure is shown. + + +### Other legacy installations +It is still possible to compile SPEC using `make` or `cmake` directly, and bypass the wrapper installation. + +## Cmake installation +Spec can be installed using CMake to find the relevant libraries to link against. +You can control +in the root directory of SPEC do the following: +```bash +mkdir build +cd build +cmake .. +make +``` +This will compile SPEC (not the wrappers). The `xspec` executable is found in ${SPEC_ROOT}/build/build/bin/xspec + +## Make installation +SPEC can also be installed using the `make` command in the root directory. + +The `make` install is controlled by the `BUILD_ENV` environment variable. +Available options are found in the SPECfile +where different link and compile flags for many machines are found. + +If you cannot find your machine in the list, copy a similar machine and adapt as needed. +then compile by running the command + +```bash +BUILD_ENV= make +``` + +the `make` process creates files in the SPEC_ROOT directory, and creates the `xspec` executable there. + + +### Build process +the source files are found in the ${SPEC_ROOT}/src/ directory. +The `.f90` files contain macros that are expanded during the make process using the `m4` command. + +Depending on the build type, the macro-expanded code is either found in `build/src/`, in the root directory, or in the `_skbuild` folder. + +[!TIP] +The line numbers in error messages correspond to the macro-expanded code + +the macros are defined in src/macros From 2feefff8c292365f7dc187ab849807a42e088a3d Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Aug 2024 12:59:54 +0200 Subject: [PATCH 115/134] big headers better headers --- compilation_instructions.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compilation_instructions.md b/compilation_instructions.md index 145a21a8..49f8e388 100644 --- a/compilation_instructions.md +++ b/compilation_instructions.md @@ -1,9 +1,9 @@ -## SPEC complition instructions +# SPEC complition instructions The default installation for SPEC method for SPEC uses cmake and installs the python wrappers and an xspec executable. -### Installation using Anaconda +## Installation using Anaconda We recommend you use Anaconda to create a coherent build environment and prevent dependency conflicts. @@ -42,7 +42,7 @@ cd Utilities/pythontools/ pip install -e . ``` -## Troubleshooting Anaconda install +### Troubleshooting Anaconda install If using a newer version of python, `f2py3` is no longer shipped. If your system contains an old python install (for example from your OS), Cmake can find its `f2py3` and give try to use it to compile the wrappers instead of your environments `f2py`. Test this by looking if you have an `f2py3` in your path: `$which f2py3`. The easiest workaround is to soft-link f2py3 to f2py so it is found first. @@ -133,10 +133,10 @@ Next, the python wrapper is tested. a plot of the MHD energy vs. the central pressure is shown. -### Other legacy installations +## Other legacy installations It is still possible to compile SPEC using `make` or `cmake` directly, and bypass the wrapper installation. -## Cmake installation +### Cmake installation Spec can be installed using CMake to find the relevant libraries to link against. You can control in the root directory of SPEC do the following: @@ -148,7 +148,7 @@ make ``` This will compile SPEC (not the wrappers). The `xspec` executable is found in ${SPEC_ROOT}/build/build/bin/xspec -## Make installation +### Make installation SPEC can also be installed using the `make` command in the root directory. The `make` install is controlled by the `BUILD_ENV` environment variable. @@ -165,7 +165,7 @@ BUILD_ENV= make the `make` process creates files in the SPEC_ROOT directory, and creates the `xspec` executable there. -### Build process +## Build process the source files are found in the ${SPEC_ROOT}/src/ directory. The `.f90` files contain macros that are expanded during the make process using the `m4` command. From 09c5058d87539793cffb1744fe6d25b75ac16187 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Aug 2024 13:02:24 +0200 Subject: [PATCH 116/134] tip-top-tips --- compilation_instructions.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/compilation_instructions.md b/compilation_instructions.md index 49f8e388..72932fa0 100644 --- a/compilation_instructions.md +++ b/compilation_instructions.md @@ -13,11 +13,11 @@ CMAKE to the right compilers and BLAS vendor. Configurations for different machines are stored in ${SPEC_ROOT}/cmake_machines, to use these, link them to cmake_config.json: `ln -s cmake_config cmake_machines/` -[!TIP] -install as much as possible in your environment using the `conda` command, -only use 'pip' at the very end for the last packages not in conda. -if you have not added the `conda-forge` channel do so by -`conda config --add channels conda-forge` +>[!TIP] +>install as much as possible in your environment using the `conda` command, +>only use 'pip' at the very end for the last packages not in conda. +>if you have not added the `conda-forge` channel do so by +>`conda config --add channels conda-forge` Get the repository and install the necessary compilers and libraries ```bash @@ -171,7 +171,7 @@ The `.f90` files contain macros that are expanded during the make process using Depending on the build type, the macro-expanded code is either found in `build/src/`, in the root directory, or in the `_skbuild` folder. -[!TIP] -The line numbers in error messages correspond to the macro-expanded code +>[!TIP] +>The line numbers in error messages correspond to the macro-expanded code the macros are defined in src/macros From 52b05dfc364060a1d931dfbed31a90817025e55e Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Aug 2024 13:52:43 +0200 Subject: [PATCH 117/134] include macOS conda compiler install instructions --- compilation_instructions.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compilation_instructions.md b/compilation_instructions.md index 72932fa0..e6399363 100644 --- a/compilation_instructions.md +++ b/compilation_instructions.md @@ -24,12 +24,16 @@ Get the repository and install the necessary compilers and libraries git clone git@github.com:PrincetonUniversity/SPEC.git conda create -n "spec_wrapper" python=3.11 # create your environment for SPEC conda activate spec_wrapper -conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64 # +conda install gcc_linux-64 gxx_linux-64 gfortran_linux-64 # or macOS versions, see note below conda install hdf5 openblas libopenblas fftw scalapack openmpi cmake ninja conda install h5py matplotlib f90nml scipy scikit-build mpi4py ipython pip install f90wrap ``` +>[!NOTE] +> for macOS users use the respective compiler packages; +> `conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64' + Finally, install SPEC and the wrapper (logs will be in `compile.log`) ``` From 21cc20852c1eecac2d4d5d1f75b39ec918d6c3c2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Aug 2024 14:07:49 +0200 Subject: [PATCH 118/134] fix spelling --- compilation_instructions.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/compilation_instructions.md b/compilation_instructions.md index e6399363..fdbb086c 100644 --- a/compilation_instructions.md +++ b/compilation_instructions.md @@ -1,6 +1,6 @@ -# SPEC complition instructions +# SPEC compilation instructions -The default installation for SPEC method for SPEC uses cmake and installs +The default installation for SPEC method for SPEC uses CMake and installs the python wrappers and an xspec executable. ## Installation using Anaconda @@ -9,13 +9,13 @@ We recommend you use Anaconda to create a coherent build environment and prevent dependency conflicts. Control over the installation can be had by editing `cmake_config.json`, to guide -CMAKE to the right compilers and BLAS vendor. -Configurations for different machines are stored in ${SPEC_ROOT}/cmake_machines, +CMake to the right compilers etc. +Configurations for different machines are stored in `${SPEC_ROOT}/cmake_machines`, to use these, link them to cmake_config.json: `ln -s cmake_config cmake_machines/` >[!TIP] >install as much as possible in your environment using the `conda` command, ->only use 'pip' at the very end for the last packages not in conda. +>only use 'pip' at the very end for the last packages. >if you have not added the `conda-forge` channel do so by >`conda config --add channels conda-forge` @@ -32,7 +32,7 @@ pip install f90wrap >[!NOTE] > for macOS users use the respective compiler packages; -> `conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64' +> `conda install clang_osx-64 clangxx_osx-64 gfortran_osx-64` Finally, install SPEC and the wrapper (logs will be in `compile.log`) @@ -47,14 +47,14 @@ pip install -e . ``` ### Troubleshooting Anaconda install -If using a newer version of python, `f2py3` is no longer shipped. If your system contains an old python install (for example from your OS), Cmake can find its `f2py3` and give try to use it to compile the wrappers instead of your environments `f2py`. +If using a newer version of python, `f2py3` is no longer shipped. If your system contains an old python install (for example from your OS), CMake can find its `f2py3` and give try to use it to compile the wrappers instead of your environments `f2py`. Test this by looking if you have an `f2py3` in your path: `$which f2py3`. -The easiest workaround is to soft-link f2py3 to f2py so it is found first. +The easiest workaround is to create a link called f2py3 that links to f2py so it is found first. ``` ln -s ~/anaconda3/envs/spec_wrapper/bin/f2py ~/anaconda3/envs/spec_wrapper/bin/f2py3 ``` -You might have HDF5 or FFTW environment variables set (for example for a VMEC install). This can throw off cmake, which we want to use only anaconda. +You might have HDF5 or FFTW environment variables set (for example for a VMEC install). This can throw off CMake, which we want to use only anaconda. ``` unset HDF5, HDF5_ROOT, HDF5_HOME, FFTW, FFTW_DIR ``` @@ -140,7 +140,7 @@ Next, the python wrapper is tested. ## Other legacy installations It is still possible to compile SPEC using `make` or `cmake` directly, and bypass the wrapper installation. -### Cmake installation +### CMake installation Spec can be installed using CMake to find the relevant libraries to link against. You can control in the root directory of SPEC do the following: @@ -156,21 +156,21 @@ This will compile SPEC (not the wrappers). The `xspec` executable is found in ${ SPEC can also be installed using the `make` command in the root directory. The `make` install is controlled by the `BUILD_ENV` environment variable. -Available options are found in the SPECfile +Available options are found in the `SPECfile` where different link and compile flags for many machines are found. If you cannot find your machine in the list, copy a similar machine and adapt as needed. -then compile by running the command +Then compile by running the command ```bash BUILD_ENV= make ``` -the `make` process creates files in the SPEC_ROOT directory, and creates the `xspec` executable there. +The `make` process creates files in the SPEC_ROOT directory, and creates the `xspec` executable there. ## Build process -the source files are found in the ${SPEC_ROOT}/src/ directory. +the source files are found in the `${SPEC_ROOT}/src/ directory`. The `.f90` files contain macros that are expanded during the make process using the `m4` command. Depending on the build type, the macro-expanded code is either found in `build/src/`, in the root directory, or in the `_skbuild` folder. @@ -178,4 +178,4 @@ Depending on the build type, the macro-expanded code is either found in `build/s >[!TIP] >The line numbers in error messages correspond to the macro-expanded code -the macros are defined in src/macros +The macros are defined in `src/macros` From 42b829dd6d308f3be4571626bd1253c0eee24cb2 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 6 Aug 2024 14:08:59 +0200 Subject: [PATCH 119/134] more typo --- compilation_instructions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compilation_instructions.md b/compilation_instructions.md index fdbb086c..181af979 100644 --- a/compilation_instructions.md +++ b/compilation_instructions.md @@ -1,6 +1,6 @@ # SPEC compilation instructions -The default installation for SPEC method for SPEC uses CMake and installs +The default installation method for SPEC uses CMake and installs the python wrappers and an xspec executable. ## Installation using Anaconda From 9b0c3a14144542bf8fa613e7ce278b08b564f7a4 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Tue, 12 Nov 2024 16:16:24 +0100 Subject: [PATCH 120/134] Fix: all py_spec functions accept scalars and validate lsurf, improve type hints --- .../pythontools/py_spec/output/_processing.py | 48 +++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index a5f6c2d6..59fc6134 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -1,5 +1,6 @@ import numpy as np from scipy import integrate +import typing def get_RZ_derivatives( self, @@ -606,11 +607,33 @@ def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): print((g[0,1,0,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,1,:,:]) print((g[0,0,1,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,2,:,:]) -def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): +def _validate_lsurf(self, lsurf:int|np.ndarray|None = None)->np.ndarray: + """Check + + Args: + - lsurf: Interface number(s), between 1 and Mvol-1. default is np.arange(1, mvol) + + Returns: + - lsurf: 1d array of interface numbers + + Raises: + - ValueError: if input is outside of range or wrong type (lsurf) + """ + mvol = self.output.Mvol + + if lsurf is None: + lsurf = np.arange(1,mvol) + else: + np.atleast_1d(lsurf) + if (lsurf<1).any() or (lsurf>mvol-1).any(): raise ValueError('lsurf should be in [1,mvol-1]') + + return lsurf + +def get_surface_current_density(self, lsurf:np.ndarray|int, nt:int=64, nz:int=64)->typing.Tuple[np.ndarray, np.ndarray, np.ndarray]: """Compute j_surf.B on each side of the provided interfaces Args: - - lsurf: Interface number, between 1 and Mvol-1. + - lsurf: Interface number(s), between 1 and Mvol-1. default is np.arange(1, mvol) - nt: Number of poloidal points - nz: Number of toroidal points @@ -628,9 +651,7 @@ def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): nfp = self.input.physics.Nfp if mvol==1: raise ValueError('Mvol=1; no interface current!') - if not isinstance(lsurf, np.ndarray): raise ValueError('lsurf should be a np.ndarray') - if lsurf is None: raise ValueError('Need to provide lsurf') - if (lsurf<1).any() or (lsurf>mvol-1).any(): raise ValueError('lsurf should be in [1,mvol-1]') + lsurf = _validate_lsurf(lsurf) if nt<1: raise ValueError('nt should greater than zero') if nz<1: raise ValueError('nz should greater than zero') @@ -683,11 +704,11 @@ def get_surface_current_density(self, lsurf:int=None, nt:int=64, nz:int=64): return j_dot_B, tarr, zarr -def get_surface(self, lsurf:int=None, nt:int=64, nz:int=64): +def get_surface(self, lsurf:np.ndarray|int|None=None, nt:int=64, nz:int=64): """Compute the surface area of a volume interface Args: - - lsurf: Interface number, between 1 and Mvol-1. + - lsurf: Interface number(s), between 1 and Mvol-1. default is np.arange(1, mvol) - nt: Number of poloidal points for integration, default is 64 - nz: Number of toroidal points for integration, default is 64 @@ -700,15 +721,10 @@ def get_surface(self, lsurf:int=None, nt:int=64, nz:int=64): mvol = self.output.Mvol nfp = self.input.physics.Nfp - if lsurf is None: - lsurf = np.arange(1,mvol) if mvol==1: raise ValueError('Mvol=1; no interface current!') - if not isinstance(lsurf, np.ndarray): - raise ValueError('lsurf should be a np.ndarray') - if (lsurf<1).any() or (lsurf>mvol-1).any(): - raise ValueError('lsurf should be in [1,mvol-1]') + lsurf = _validate_lsurf(lsurf) if nt<1: raise ValueError('nt should greater than zero') if nz<1: @@ -744,7 +760,7 @@ def get_flux_surface_average( self, lsurf, f, tarr, zarr ): inner side of the interface (i.e. lvol=lsurf-1, sarr=1) Args: - - lsurf (1D numpy array): Interface number, between 1 and Mvol-1 + - lsurf: Interface number(s), between 1 and Mvol-1. default is np.arange(1, mvol) - f (2D numpy array): function evaluated on a grid - tgrid (2D numpy array): theta grid - zgrid (2D numpy array): phi grid @@ -752,7 +768,11 @@ def get_flux_surface_average( self, lsurf, f, tarr, zarr ): Returns> - fsavg (1D numpy array): The flux surface average of f on each surface given in lsurf + Raises: + - ValueError: if input is wrong (invalid lsurf) """ + + lsurf = _validate_lsurf(lsurf) # Get jacobian output = np.zeros(lsurf.shape) From 912c46745eb5c6a350214462a3b2eee42f8c262c Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Tue, 12 Nov 2024 16:21:43 +0100 Subject: [PATCH 121/134] Make new type hints python <3.10 compatible --- Utilities/pythontools/py_spec/output/_processing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 59fc6134..02d78a99 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -607,7 +607,7 @@ def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): print((g[0,1,0,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,1,:,:]) print((g[0,0,1,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,2,:,:]) -def _validate_lsurf(self, lsurf:int|np.ndarray|None = None)->np.ndarray: +def _validate_lsurf(self, lsurf:np.ndarray = None)->np.ndarray: """Check Args: @@ -629,7 +629,7 @@ def _validate_lsurf(self, lsurf:int|np.ndarray|None = None)->np.ndarray: return lsurf -def get_surface_current_density(self, lsurf:np.ndarray|int, nt:int=64, nz:int=64)->typing.Tuple[np.ndarray, np.ndarray, np.ndarray]: +def get_surface_current_density(self, lsurf:np.ndarray, nt:int=64, nz:int=64)->typing.Tuple[np.ndarray, np.ndarray, np.ndarray]: """Compute j_surf.B on each side of the provided interfaces Args: @@ -704,7 +704,7 @@ def get_surface_current_density(self, lsurf:np.ndarray|int, nt:int=64, nz:int=64 return j_dot_B, tarr, zarr -def get_surface(self, lsurf:np.ndarray|int|None=None, nt:int=64, nz:int=64): +def get_surface(self, lsurf:np.ndarray=None, nt:int=64, nz:int=64): """Compute the surface area of a volume interface Args: From 55e58c8860e1019f53997526e6422c56eeb6991a Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Tue, 12 Nov 2024 16:21:54 +0100 Subject: [PATCH 122/134] Fix: handle py_spec pressure() edge case for nvol=1 --- Utilities/pythontools/py_spec/output/_processing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 02d78a99..8ddb2336 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -505,7 +505,7 @@ def get_average_beta(self, ns=64, nt=64, nz=64): """Get beta averaged in plasma volume""" # Read pressure - press = self.input.physics.pressure * self.input.physics.pscale + press = np.atleast_1d(self.input.physics.pressure) * self.input.physics.pscale # Create coordinate grid nfp = self.input.physics.Nfp From 84056ff5fc5b2a67adc1ff1f027d4a634891a951 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Tue, 12 Nov 2024 16:26:04 +0100 Subject: [PATCH 123/134] Refactor: _validate_lsurf doesn't have to be a member function --- Utilities/pythontools/py_spec/output/_processing.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/_processing.py b/Utilities/pythontools/py_spec/output/_processing.py index 8ddb2336..3e481f78 100644 --- a/Utilities/pythontools/py_spec/output/_processing.py +++ b/Utilities/pythontools/py_spec/output/_processing.py @@ -607,24 +607,23 @@ def test_derivatives(self, lvol=0, s=0.3, t=0.4, z=0.5, delta=1e-6, tol=1e-6): print((g[0,1,0,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,1,:,:]) print((g[0,0,1,:,:] - g[0,0,0,:,:])/ds/2-dg[0,0,0,2,:,:]) -def _validate_lsurf(self, lsurf:np.ndarray = None)->np.ndarray: +def _validate_lsurf(lsurf:np.ndarray, mvol:int)->np.ndarray: """Check Args: - lsurf: Interface number(s), between 1 and Mvol-1. default is np.arange(1, mvol) - + - mvol: Number of volumes Returns: - lsurf: 1d array of interface numbers Raises: - ValueError: if input is outside of range or wrong type (lsurf) """ - mvol = self.output.Mvol if lsurf is None: lsurf = np.arange(1,mvol) else: - np.atleast_1d(lsurf) + lsurf = np.atleast_1d(lsurf) if (lsurf<1).any() or (lsurf>mvol-1).any(): raise ValueError('lsurf should be in [1,mvol-1]') return lsurf @@ -651,7 +650,7 @@ def get_surface_current_density(self, lsurf:np.ndarray, nt:int=64, nz:int=64)->t nfp = self.input.physics.Nfp if mvol==1: raise ValueError('Mvol=1; no interface current!') - lsurf = _validate_lsurf(lsurf) + lsurf = _validate_lsurf(lsurf, mvol) if nt<1: raise ValueError('nt should greater than zero') if nz<1: raise ValueError('nz should greater than zero') @@ -724,7 +723,7 @@ def get_surface(self, lsurf:np.ndarray=None, nt:int=64, nz:int=64): if mvol==1: raise ValueError('Mvol=1; no interface current!') - lsurf = _validate_lsurf(lsurf) + lsurf = _validate_lsurf(lsurf, mvol) if nt<1: raise ValueError('nt should greater than zero') if nz<1: @@ -772,7 +771,7 @@ def get_flux_surface_average( self, lsurf, f, tarr, zarr ): - ValueError: if input is wrong (invalid lsurf) """ - lsurf = _validate_lsurf(lsurf) + lsurf = _validate_lsurf(lsurf, self.output.Mvol) # Get jacobian output = np.zeros(lsurf.shape) From 76b5a36907cb5e70dd108250a60de7c765ff61f7 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Tue, 12 Nov 2024 16:40:14 +0100 Subject: [PATCH 124/134] Fix: handle py_spec plot_pressure edge case for nvol=1 --- Utilities/pythontools/py_spec/output/_plot_pressure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_plot_pressure.py b/Utilities/pythontools/py_spec/output/_plot_pressure.py index cb459a05..6110699c 100644 --- a/Utilities/pythontools/py_spec/output/_plot_pressure.py +++ b/Utilities/pythontools/py_spec/output/_plot_pressure.py @@ -9,7 +9,7 @@ def plot_pressure(self, normalize=True, ax=None, **kwargs): import numpy as np import matplotlib.pyplot as plt - pressure = self.input.physics.pressure * self.input.physics.pscale + pressure = np.atleast_1d(self.input.physics.pressure) * self.input.physics.pscale tflux = self.output.tflux[: len(pressure)] if not normalize: # remove mu_0 From 34aa10fbaabe0a79d6175887d19de331841a82fb Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Wed, 13 Nov 2024 22:16:01 +0100 Subject: [PATCH 125/134] simplify scalar handling in SPECout --- Utilities/pythontools/py_spec/output/spec.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Utilities/pythontools/py_spec/output/spec.py b/Utilities/pythontools/py_spec/output/spec.py index 99d06ca3..428b59a3 100644 --- a/Utilities/pythontools/py_spec/output/spec.py +++ b/Utilities/pythontools/py_spec/output/spec.py @@ -95,15 +95,9 @@ def __init__(self, *args, **kwargs): if isinstance(_content, h5py.File): _content.close() - # make sure that Lrad is always an array - if np.isscalar(self.input.physics.Lrad): - self.input.physics.Lrad = np.array([self.input.physics.Lrad]) - # make sure that im always an array - if np.isscalar(self.output.im): - self.output.im = np.array([self.output.im]) - # make sure that in_ is always an array - if np.isscalar(self.output.in_): - self.output.in_ = np.array([self.output.in_]) + self.input.physics.Lrad = np.atleast_1d(self.input.physics.Lrad) + self.output.im = np.atleast_1d(self.output.im) + self.output.in_ = np.atleast_1d(self.output.in_) # these define the target dimensions in the radial direction Nvol = self.input.physics.Nvol From fdc832f0d83ad87dcd40fb0d24d1801365b918de Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 14:52:04 +0100 Subject: [PATCH 126/134] pp00aa use dynamic OpenMP scheduling due to load imbalance --- src/pp00aa.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pp00aa.f90 b/src/pp00aa.f90 index dc91ff31..0de63577 100644 --- a/src/pp00aa.f90 +++ b/src/pp00aa.f90 @@ -145,7 +145,7 @@ subroutine pp00aa SALLOCATE( utflag, (ioff:lnPtrj ), 0 ) ! error flag that indicates if fieldlines successfully followed; 22 Apr 13; SALLOCATE( fiota, (ioff:lnPtrj, 1:2 ), zero ) ! will always need fiota(0,1:2); -!$OMP PARALLEL DO SHARED(lnPtrj,ioff,Wpp00aa,Nz,data,fiota,utflag,iota,oita,myid,vvol,cpus,Lconstraint,nPpts,ppts) PRIVATE(itrj,sti) +!$OMP PARALLEL DO SHARED(lnPtrj,ioff,Wpp00aa,Nz,data,fiota,utflag,iota,oita,myid,vvol,cpus,Lconstraint,nPpts,ppts) PRIVATE(itrj,sti) SCHEDULE(dynamic) do itrj = ioff, lnPtrj ! initialize Poincare plot with trajectories regularly spaced between interfaces along \t=0; ; sti(1:2) = (/ - one + itrj * two / lnPtrj , Ppts*pi /) From e8e2578186267f5d5db3be2254e706020dcf24fc Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 20:47:41 +0100 Subject: [PATCH 127/134] Store the filepath for hidden files in hiddenext --- src/global.f90 | 3 ++- src/xspech.f90 | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/global.f90 b/src/global.f90 index 1429473f..5ca4667a 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -246,7 +246,8 @@ module allglobal !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! - CHARACTER(LEN=1000) :: ext ! extension of input filename, i.e., "G3V01L1Fi.001" for an input file G3V01L1Fi.001.sp + CHARACTER(LEN=1000) :: ext ! extension of input filename, i.e., "path/G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp + CHARACTER(LEN=1000) :: hiddenext ! ext with a "." prefix added to the basename "path/.G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp REAL :: ForceErr !< total force-imbalance REAL :: Energy !< MHD energy diff --git a/src/xspech.f90 b/src/xspech.f90 index 0ceb417c..b1ea98dc 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -204,12 +204,12 @@ subroutine read_command_args use fileunits, only: ounit use inputlist, only: Wreadin - use allglobal, only: cpus, myid, ext, MPI_COMM_SPEC, write_spec_namelist + use allglobal, only: cpus, myid, ext, hiddenext, MPI_COMM_SPEC, write_spec_namelist LOCALS LOGICAL :: Lspexist - INTEGER :: iargc, iarg, numargs, extlen, sppos + INTEGER :: iargc, iarg, numargs, extlen, sppos, basenamestart CHARACTER(len=100) :: arg @@ -243,6 +243,11 @@ subroutine read_command_args endif ext = trim(arg) + ! Prepare the "hidden" ext filepath that has a "." prefix. + ! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween + basenamestart = INDEX(ext, '/', .TRUE.) + hiddenext = trim(ext(1:basenamestart))//"."//trim(ext(basenamestart+1:)) + write(ounit,'("rdcmdl : ", 10x ," : ")') write(ounit,'("rdcmdl : ",f10.2," : ext = ",a100)') cput-cpus, ext end select From 9a24970511871d01a75758e7ce2d8cb2d9189055 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 20:48:20 +0100 Subject: [PATCH 128/134] Refactor all routines using hidden files --- src/dfp200.f90 | 4 ++-- src/hesian.f90 | 10 +++++----- src/newton.f90 | 14 ++++++++------ src/pp00aa.f90 | 4 ++-- src/ra00aa.f90 | 8 ++++---- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/dfp200.f90 b/src/dfp200.f90 index 2015b3b6..bdebe88a 100644 --- a/src/dfp200.f90 +++ b/src/dfp200.f90 @@ -2110,12 +2110,12 @@ subroutine hessian3D_dFFdRZ(lvol, idof, innout, issym, irz, ii, dBB, XX, YY, len !write(ounit,1000) 'values are:' Mvol, efcol1mn(1:mn) !write(90,1000) efcol1mn(1:mn) !1000 format(" "10x" "es23.15" ") - !open(nm1unit, file="."//trim(ext)//".GF.hcol1", status="unknown", form="unformatted") + !open(nm1unit, file=hiddenext//".GF.hcol1", status="unknown", form="unformatted") !write(nm1unit) NGdof, Mvol !write(nm1unit) efcol1mn(1:Ntz) !close(nm1unit) - !open(nm2unit, file="."//trim(ext)//".GF.hcol2", status="unknown", form="unformatted") + !open(nm2unit, file=hiddenext//".GF.hcol2", status="unknown", form="unformatted") !!write(nm2unit) NGdof, Mvol !write(nm2unit) efcol2mn(1:Ntz) !close(nm2unit) diff --git a/src/hesian.f90 b/src/hesian.f90 index 2ea18d90..265619e6 100644 --- a/src/hesian.f90 +++ b/src/hesian.f90 @@ -26,7 +26,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) use cputiming, only : Thesian - use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, & + use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, hiddenext, & im, in, & iRbc, iZbs, iRbs, iZbc, & dRbc, dZbs, dRbs, dZbc, & @@ -260,7 +260,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) xx(0,-2:2)= zero ; dRZ = 1.0E-04 write(svol,'(i3.3)')myid -! open(lunit+myid,file="."//trim(ext)//".hessian."//svol,status="unknown") +! open(lunit+myid,file=hiddenext//".hessian."//svol,status="unknown") ! lmu(1:Nvol) = mu(1:Nvol) ; lpflux(1:Nvol) = pflux(1:Nvol) ; lhelicity(1:Nvol) = helicity(1:Nvol) ! save original profile information; 20 Jun 14; @@ -402,7 +402,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) !>
  • The eigenvalues and eigenvectors (if required) are written to the file \c .ext.GF.ev as follows: !> !> ``` -!> open(hunit,file="."//trim(ext)//".GF.ev",status="unknown",form="unformatted") +!> open(hunit,file=hiddenext//".GF.ev",status="unknown",form="unformatted") !> write(hunit)NGdof,Ldvr,Ldvi ! integers; if only the eigenvalues were computed then Ldvr=Ldvi=1; !> write(hunit)evalr(1:NGdof) ! reals ; real part of eigenvalues; !> write(hunit)evali(1:NGdof) ! reals ; imaginary part of eigenvalues; @@ -419,7 +419,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) if( LHmatrix ) then if( myid.eq.0 ) then ; cput = GETTIME ; write(ounit,'("hesian : ",f10.2," : LHmatrix="L2" ;")')cput-cpus, LHmatrix ; - open(munit, file="."//trim(ext)//".GF.ma", status="unknown", form="unformatted") + open(munit, file=hiddenext//".GF.ma", status="unknown", form="unformatted") write(munit) NGdof write(munit) ohessian(1:NGdof,1:NGdof) close(munit) @@ -574,7 +574,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) if( myid.eq.0 ) then ! write to file; 04 Dec 14; - open(hunit, file="."//trim(ext)//".GF.ev", status="unknown", form="unformatted") + open(hunit, file=hiddenext//".GF.ev", status="unknown", form="unformatted") write(hunit) NGdof, Ldvr, Ldvi write(hunit) evalr write(hunit) evali diff --git a/src/newton.f90 b/src/newton.f90 index 7bd26216..dfb2d3bf 100644 --- a/src/newton.f90 +++ b/src/newton.f90 @@ -64,7 +64,7 @@ subroutine newton( NGdof, position, ihybrd ) use cputiming, only : Tnewton - use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, & + use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hiddenext, & NOTstellsym, & ForceErr, Energy, & mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, & @@ -313,7 +313,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) use cputiming, only : Tnewton - use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, & + use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, hiddenext, & mn, im, in, hessian, Lhessianallocated LOCALS @@ -329,6 +329,8 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) ireadhessian = 0 ! set default intent out; + print *, "hiddenext = ", hiddenext + select case( readorwrite ) case( 'W' ) ! will write derivative matrix to file; @@ -336,7 +338,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) ! reset I/O state ios = 0 - open( dunit, file="."//trim(ext)//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file; + open( dunit, file=hiddenext//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file; FATAL( newton, ios.ne.0, error opening derivative matrix file ) write( dunit, iostat=ios ) Igeometry, Istellsym, Lfreebound, Nvol, Mpol, Ntor, NGdof ! enable resolution consistency check; @@ -352,11 +354,11 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) cput = GETTIME - inquire( file="."//trim(ext)//".sp.DF", exist=exist ) ! the derivative matrix; + inquire( file=hiddenext//".sp.DF", exist=exist ) ! the derivative matrix; if( exist ) then ! 01234567890123456789012345678901 write(ounit,2000) cput-cpus, myid, "reading .ext.sp.DF ; " - open( dunit, file="."//trim(ext)//".sp.DF", status="old", form="unformatted", iostat=ios ) + open( dunit, file=hiddenext//".sp.DF", status="old", form="unformatted", iostat=ios ) else ! 01234567890123456789012345678901 write(ounit,2000) cput-cpus, myid, ".ext.sp.DF does not exist ; " inquire( file=".sp.DF", exist=exist ) ! the derivative matrix; @@ -442,7 +444,7 @@ subroutine fcn1( NGdof, xx, fvec, irevcm ) use cputiming, only : Tnewton - use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, & + use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, hiddenext, & NOTstellsym, & ForceErr, Energy, & mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, & diff --git a/src/pp00aa.f90 b/src/pp00aa.f90 index dc91ff31..8df977ee 100644 --- a/src/pp00aa.f90 +++ b/src/pp00aa.f90 @@ -25,7 +25,7 @@ !> !>~~~~~~~~~~~~ !> write(svol,'(i4.4)')lvol ! lvol labels volume; -!> open(lunit+myid,file="."//trim(ext)//".poincare."//svol,status="unknown",form="unformatted") +!> open(lunit+myid,file=hiddenext//".poincare."//svol,status="unknown",form="unformatted") !> do until end of file !> write(lunit+myid) Nz, nPpts ! integers !> write(lunit+myid) data(1:4,0:Nz-1,1:nPpts) ! doubles @@ -55,7 +55,7 @@ !>
  • The rotational-transform data is written to \c .ext.transform:xxxx , where \c xxxx is an integer indicating the volume. !> The format of this file is as follows: !> ``` -!> open(lunit+myid,file="."//trim(ext)//".sp.t."//svol,status="unknown",form="unformatted") +!> open(lunit+myid,file=hiddenext//".sp.t."//svol,status="unknown",form="unformatted") !> write(lunit+myid) lnPtrj-ioff+1 ! integer !> write(lunit+myid) diotadxup(0:1,0,lvol) ! doubles !> write(lunit+myid) ( fiota(itrj,1:2), itrj = ioff, lnPtrj ) ! doubles diff --git a/src/ra00aa.f90 b/src/ra00aa.f90 index 81553e76..92cb6395 100644 --- a/src/ra00aa.f90 +++ b/src/ra00aa.f90 @@ -24,7 +24,7 @@ !>
      !>
    • The format of the files containing the vector potential is as follows: !> ``` -!> open(aunit, file="."//trim(ext)//".sp.A", status="replace", form="unformatted" ) +!> open(aunit, file=hiddenext//".sp.A", status="replace", form="unformatted" ) !> write(aunit) Mvol, Mpol, Ntor, mn, Nfp ! integers; !> write(aunit) im(1:mn) ! integers; poloidal modes; !> write(aunit) in(1:mn) ! integers; toroidal modes; @@ -57,7 +57,7 @@ subroutine ra00aa( writeorread ) use cputiming, only : Tra00aa - use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, Mvol, mn, im, in, Ate, Aze, Ato, Azo + use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hiddenext, Mvol, mn, im, in, Ate, Aze, Ato, Azo use sphdf5, only : write_vector_potential @@ -148,12 +148,12 @@ subroutine ra00aa( writeorread ) if( myid.eq.0 ) then - inquire(file="."//trim(ext)//".sp.A",exist=exist) + inquire(file=hiddenext//".sp.A",exist=exist) if( .not.exist ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; .ext.sp.A does not exist ;")') cput-cpus, myid ; goto 9998 endif - open(aunit,file="."//trim(ext)//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential; + open(aunit,file=hiddenext//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential; if( ios.ne.0 ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; opening .ext.sp.A ;")') cput-cpus, myid ; goto 9997 endif From b617a0cc62c05724cbf8b733da1f958cad449bbf Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 20:49:41 +0100 Subject: [PATCH 129/134] Cross platform path handling --- src/xspech.f90 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/xspech.f90 b/src/xspech.f90 index b1ea98dc..1708b894 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -245,7 +245,12 @@ subroutine read_command_args ! Prepare the "hidden" ext filepath that has a "." prefix. ! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween - basenamestart = INDEX(ext, '/', .TRUE.) + #ifdef _WIN32 + basenamestart = INDEX(ext, '\', .TRUE.) + #else + basenamestart = INDEX(ext, '/', .TRUE.) + #endif + ! folder + . + filename hiddenext = trim(ext(1:basenamestart))//"."//trim(ext(basenamestart+1:)) write(ounit,'("rdcmdl : ", 10x ," : ")') From 9650e023bae446442f5626db2be61581bae56bea Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 20:59:52 +0100 Subject: [PATCH 130/134] removed debugging print statement --- src/newton.f90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/newton.f90 b/src/newton.f90 index dfb2d3bf..d2e9ecab 100644 --- a/src/newton.f90 +++ b/src/newton.f90 @@ -329,8 +329,6 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) ireadhessian = 0 ! set default intent out; - print *, "hiddenext = ", hiddenext - select case( readorwrite ) case( 'W' ) ! will write derivative matrix to file; From 4b615bc7851ff92721f0f076c5182ce8bcb23b54 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 21:00:12 +0100 Subject: [PATCH 131/134] Fixed preprocessor indent --- src/xspech.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/xspech.f90 b/src/xspech.f90 index 1708b894..316e9eb9 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -245,11 +245,11 @@ subroutine read_command_args ! Prepare the "hidden" ext filepath that has a "." prefix. ! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween - #ifdef _WIN32 +#ifdef _WIN32 basenamestart = INDEX(ext, '\', .TRUE.) - #else +#else basenamestart = INDEX(ext, '/', .TRUE.) - #endif +#endif ! folder + . + filename hiddenext = trim(ext(1:basenamestart))//"."//trim(ext(basenamestart+1:)) From 92d03e46ca5c6823146c6e34a172107403de4da4 Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Thu, 14 Nov 2024 21:16:54 +0100 Subject: [PATCH 132/134] trimming and variable renaming --- src/dfp200.f90 | 4 ++-- src/global.f90 | 2 +- src/hesian.f90 | 10 +++++----- src/newton.f90 | 12 ++++++------ src/pp00aa.f90 | 4 ++-- src/ra00aa.f90 | 8 ++++---- src/xspech.f90 | 10 +++++----- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/dfp200.f90 b/src/dfp200.f90 index bdebe88a..7c73253c 100644 --- a/src/dfp200.f90 +++ b/src/dfp200.f90 @@ -2110,12 +2110,12 @@ subroutine hessian3D_dFFdRZ(lvol, idof, innout, issym, irz, ii, dBB, XX, YY, len !write(ounit,1000) 'values are:' Mvol, efcol1mn(1:mn) !write(90,1000) efcol1mn(1:mn) !1000 format(" "10x" "es23.15" ") - !open(nm1unit, file=hiddenext//".GF.hcol1", status="unknown", form="unformatted") + !open(nm1unit, file=trim(hidden_ext)//".GF.hcol1", status="unknown", form="unformatted") !write(nm1unit) NGdof, Mvol !write(nm1unit) efcol1mn(1:Ntz) !close(nm1unit) - !open(nm2unit, file=hiddenext//".GF.hcol2", status="unknown", form="unformatted") + !open(nm2unit, file=trim(hidden_ext)//".GF.hcol2", status="unknown", form="unformatted") !!write(nm2unit) NGdof, Mvol !write(nm2unit) efcol2mn(1:Ntz) !close(nm2unit) diff --git a/src/global.f90 b/src/global.f90 index 5ca4667a..503963c8 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -247,7 +247,7 @@ module allglobal !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! CHARACTER(LEN=1000) :: ext ! extension of input filename, i.e., "path/G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp - CHARACTER(LEN=1000) :: hiddenext ! ext with a "." prefix added to the basename "path/.G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp + CHARACTER(LEN=1000) :: hidden_ext ! ext with a "." prefix added to the basename "path/.G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp REAL :: ForceErr !< total force-imbalance REAL :: Energy !< MHD energy diff --git a/src/hesian.f90 b/src/hesian.f90 index 265619e6..dd49506f 100644 --- a/src/hesian.f90 +++ b/src/hesian.f90 @@ -26,7 +26,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) use cputiming, only : Thesian - use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, hiddenext, & + use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, hidden_ext, & im, in, & iRbc, iZbs, iRbs, iZbc, & dRbc, dZbs, dRbs, dZbc, & @@ -260,7 +260,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) xx(0,-2:2)= zero ; dRZ = 1.0E-04 write(svol,'(i3.3)')myid -! open(lunit+myid,file=hiddenext//".hessian."//svol,status="unknown") +! open(lunit+myid,file=trim(hidden_ext)//".hessian."//svol,status="unknown") ! lmu(1:Nvol) = mu(1:Nvol) ; lpflux(1:Nvol) = pflux(1:Nvol) ; lhelicity(1:Nvol) = helicity(1:Nvol) ! save original profile information; 20 Jun 14; @@ -402,7 +402,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) !>
    • The eigenvalues and eigenvectors (if required) are written to the file \c .ext.GF.ev as follows: !> !> ``` -!> open(hunit,file=hiddenext//".GF.ev",status="unknown",form="unformatted") +!> open(hunit,file=trim(hidden_ext)//".GF.ev",status="unknown",form="unformatted") !> write(hunit)NGdof,Ldvr,Ldvi ! integers; if only the eigenvalues were computed then Ldvr=Ldvi=1; !> write(hunit)evalr(1:NGdof) ! reals ; real part of eigenvalues; !> write(hunit)evali(1:NGdof) ! reals ; imaginary part of eigenvalues; @@ -419,7 +419,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) if( LHmatrix ) then if( myid.eq.0 ) then ; cput = GETTIME ; write(ounit,'("hesian : ",f10.2," : LHmatrix="L2" ;")')cput-cpus, LHmatrix ; - open(munit, file=hiddenext//".GF.ma", status="unknown", form="unformatted") + open(munit, file=trim(hidden_ext)//".GF.ma", status="unknown", form="unformatted") write(munit) NGdof write(munit) ohessian(1:NGdof,1:NGdof) close(munit) @@ -574,7 +574,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) if( myid.eq.0 ) then ! write to file; 04 Dec 14; - open(hunit, file=hiddenext//".GF.ev", status="unknown", form="unformatted") + open(hunit, file=trim(hidden_ext)//".GF.ev", status="unknown", form="unformatted") write(hunit) NGdof, Ldvr, Ldvi write(hunit) evalr write(hunit) evali diff --git a/src/newton.f90 b/src/newton.f90 index d2e9ecab..77573670 100644 --- a/src/newton.f90 +++ b/src/newton.f90 @@ -64,7 +64,7 @@ subroutine newton( NGdof, position, ihybrd ) use cputiming, only : Tnewton - use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hiddenext, & + use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, & NOTstellsym, & ForceErr, Energy, & mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, & @@ -313,7 +313,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) use cputiming, only : Tnewton - use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, hiddenext, & + use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, hidden_ext, & mn, im, in, hessian, Lhessianallocated LOCALS @@ -336,7 +336,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) ! reset I/O state ios = 0 - open( dunit, file=hiddenext//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file; + open( dunit, file=trim(hidden_ext)//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file; FATAL( newton, ios.ne.0, error opening derivative matrix file ) write( dunit, iostat=ios ) Igeometry, Istellsym, Lfreebound, Nvol, Mpol, Ntor, NGdof ! enable resolution consistency check; @@ -352,11 +352,11 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) cput = GETTIME - inquire( file=hiddenext//".sp.DF", exist=exist ) ! the derivative matrix; + inquire( file=trim(hidden_ext)//".sp.DF", exist=exist ) ! the derivative matrix; if( exist ) then ! 01234567890123456789012345678901 write(ounit,2000) cput-cpus, myid, "reading .ext.sp.DF ; " - open( dunit, file=hiddenext//".sp.DF", status="old", form="unformatted", iostat=ios ) + open( dunit, file=trim(hidden_ext)//".sp.DF", status="old", form="unformatted", iostat=ios ) else ! 01234567890123456789012345678901 write(ounit,2000) cput-cpus, myid, ".ext.sp.DF does not exist ; " inquire( file=".sp.DF", exist=exist ) ! the derivative matrix; @@ -442,7 +442,7 @@ subroutine fcn1( NGdof, xx, fvec, irevcm ) use cputiming, only : Tnewton - use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, hiddenext, & + use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, & NOTstellsym, & ForceErr, Energy, & mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, & diff --git a/src/pp00aa.f90 b/src/pp00aa.f90 index 8df977ee..6c0fb2f2 100644 --- a/src/pp00aa.f90 +++ b/src/pp00aa.f90 @@ -25,7 +25,7 @@ !> !>~~~~~~~~~~~~ !> write(svol,'(i4.4)')lvol ! lvol labels volume; -!> open(lunit+myid,file=hiddenext//".poincare."//svol,status="unknown",form="unformatted") +!> open(lunit+myid,file=trim(hidden_ext)//".poincare."//svol,status="unknown",form="unformatted") !> do until end of file !> write(lunit+myid) Nz, nPpts ! integers !> write(lunit+myid) data(1:4,0:Nz-1,1:nPpts) ! doubles @@ -55,7 +55,7 @@ !>
    • The rotational-transform data is written to \c .ext.transform:xxxx , where \c xxxx is an integer indicating the volume. !> The format of this file is as follows: !> ``` -!> open(lunit+myid,file=hiddenext//".sp.t."//svol,status="unknown",form="unformatted") +!> open(lunit+myid,file=trim(hidden_ext)//".sp.t."//svol,status="unknown",form="unformatted") !> write(lunit+myid) lnPtrj-ioff+1 ! integer !> write(lunit+myid) diotadxup(0:1,0,lvol) ! doubles !> write(lunit+myid) ( fiota(itrj,1:2), itrj = ioff, lnPtrj ) ! doubles diff --git a/src/ra00aa.f90 b/src/ra00aa.f90 index 92cb6395..15ccaf82 100644 --- a/src/ra00aa.f90 +++ b/src/ra00aa.f90 @@ -24,7 +24,7 @@ !>
        !>
      • The format of the files containing the vector potential is as follows: !> ``` -!> open(aunit, file=hiddenext//".sp.A", status="replace", form="unformatted" ) +!> open(aunit, file=trim(hidden_ext)//".sp.A", status="replace", form="unformatted" ) !> write(aunit) Mvol, Mpol, Ntor, mn, Nfp ! integers; !> write(aunit) im(1:mn) ! integers; poloidal modes; !> write(aunit) in(1:mn) ! integers; toroidal modes; @@ -57,7 +57,7 @@ subroutine ra00aa( writeorread ) use cputiming, only : Tra00aa - use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hiddenext, Mvol, mn, im, in, Ate, Aze, Ato, Azo + use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, Mvol, mn, im, in, Ate, Aze, Ato, Azo use sphdf5, only : write_vector_potential @@ -148,12 +148,12 @@ subroutine ra00aa( writeorread ) if( myid.eq.0 ) then - inquire(file=hiddenext//".sp.A",exist=exist) + inquire(file=trim(hidden_ext)//".sp.A",exist=exist) if( .not.exist ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; .ext.sp.A does not exist ;")') cput-cpus, myid ; goto 9998 endif - open(aunit,file=hiddenext//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential; + open(aunit,file=trim(hidden_ext)//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential; if( ios.ne.0 ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; opening .ext.sp.A ;")') cput-cpus, myid ; goto 9997 endif diff --git a/src/xspech.f90 b/src/xspech.f90 index 316e9eb9..26f0e1ee 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -204,12 +204,12 @@ subroutine read_command_args use fileunits, only: ounit use inputlist, only: Wreadin - use allglobal, only: cpus, myid, ext, hiddenext, MPI_COMM_SPEC, write_spec_namelist + use allglobal, only: cpus, myid, ext, hidden_ext, MPI_COMM_SPEC, write_spec_namelist LOCALS LOGICAL :: Lspexist - INTEGER :: iargc, iarg, numargs, extlen, sppos, basenamestart + INTEGER :: iargc, iarg, numargs, extlen, sppos, basename_start_index CHARACTER(len=100) :: arg @@ -246,12 +246,12 @@ subroutine read_command_args ! Prepare the "hidden" ext filepath that has a "." prefix. ! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween #ifdef _WIN32 - basenamestart = INDEX(ext, '\', .TRUE.) + basename_start_index = INDEX(ext, '\', .TRUE.) #else - basenamestart = INDEX(ext, '/', .TRUE.) + basename_start_index = INDEX(ext, '/', .TRUE.) #endif ! folder + . + filename - hiddenext = trim(ext(1:basenamestart))//"."//trim(ext(basenamestart+1:)) + hidden_ext = trim(ext(1:basename_start_index))//"."//trim(ext(basename_start_index+1:)) write(ounit,'("rdcmdl : ", 10x ," : ")') write(ounit,'("rdcmdl : ",f10.2," : ext = ",a100)') cput-cpus, ext From 5f31e3eef390db7700a674d8fdf33d6f40baf7da Mon Sep 17 00:00:00 2001 From: Philipp Jurasic Date: Mon, 18 Nov 2024 10:28:59 +0100 Subject: [PATCH 133/134] hidden_ext accessor function instead of property --- src/dfp200.f90 | 4 ++-- src/global.f90 | 21 ++++++++++++++++++++- src/hesian.f90 | 10 +++++----- src/newton.f90 | 12 ++++++------ src/pp00aa.f90 | 4 ++-- src/ra00aa.f90 | 8 ++++---- src/xspech.f90 | 14 ++------------ 7 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/dfp200.f90 b/src/dfp200.f90 index 7c73253c..311a7dfa 100644 --- a/src/dfp200.f90 +++ b/src/dfp200.f90 @@ -2110,12 +2110,12 @@ subroutine hessian3D_dFFdRZ(lvol, idof, innout, issym, irz, ii, dBB, XX, YY, len !write(ounit,1000) 'values are:' Mvol, efcol1mn(1:mn) !write(90,1000) efcol1mn(1:mn) !1000 format(" "10x" "es23.15" ") - !open(nm1unit, file=trim(hidden_ext)//".GF.hcol1", status="unknown", form="unformatted") + !open(nm1unit, file=trim(get_hidden(ext))//".GF.hcol1", status="unknown", form="unformatted") !write(nm1unit) NGdof, Mvol !write(nm1unit) efcol1mn(1:Ntz) !close(nm1unit) - !open(nm2unit, file=trim(hidden_ext)//".GF.hcol2", status="unknown", form="unformatted") + !open(nm2unit, file=trim(get_hidden(ext))//".GF.hcol2", status="unknown", form="unformatted") !!write(nm2unit) NGdof, Mvol !write(nm2unit) efcol2mn(1:Ntz) !close(nm2unit) diff --git a/src/global.f90 b/src/global.f90 index 503963c8..b02862b1 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -247,7 +247,6 @@ module allglobal !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! CHARACTER(LEN=1000) :: ext ! extension of input filename, i.e., "path/G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp - CHARACTER(LEN=1000) :: hidden_ext ! ext with a "." prefix added to the basename "path/.G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp REAL :: ForceErr !< total force-imbalance REAL :: Energy !< MHD energy @@ -950,6 +949,26 @@ subroutine set_mpi_comm(comm) !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! +pure function get_hidden(ext) result(hidden_ext) + implicit none + CHARACTER(len=1000), intent(in) :: ext + ! ext with a "." prefix added to the basename "path/.G3V01L1Fi.001" for an input file path/G3V01L1Fi.001.sp + CHARACTER(LEN=1000) :: hidden_ext + INTEGER :: basename_start_index + + ! Prepare the "hidden" ext filepath that has a "." prefix. + ! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween +#ifdef _WIN32 + basename_start_index = INDEX(ext, '\', .TRUE.) +#else + basename_start_index = INDEX(ext, '/', .TRUE.) +#endif + ! folder + . + filename + hidden_ext = trim(ext(1:basename_start_index))//"."//trim(ext(basename_start_index+1:)) +end function get_hidden + +!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! + subroutine read_inputlists_from_file() use constants diff --git a/src/hesian.f90 b/src/hesian.f90 index dd49506f..a9a15b81 100644 --- a/src/hesian.f90 +++ b/src/hesian.f90 @@ -26,7 +26,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) use cputiming, only : Thesian - use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, hidden_ext, & + use allglobal, only : ncpu, myid, cpus, MPI_COMM_SPEC, ext, get_hidden, & im, in, & iRbc, iZbs, iRbs, iZbc, & dRbc, dZbs, dRbs, dZbc, & @@ -260,7 +260,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) xx(0,-2:2)= zero ; dRZ = 1.0E-04 write(svol,'(i3.3)')myid -! open(lunit+myid,file=trim(hidden_ext)//".hessian."//svol,status="unknown") +! open(lunit+myid,file=trim(get_hidden(ext))//".hessian."//svol,status="unknown") ! lmu(1:Nvol) = mu(1:Nvol) ; lpflux(1:Nvol) = pflux(1:Nvol) ; lhelicity(1:Nvol) = helicity(1:Nvol) ! save original profile information; 20 Jun 14; @@ -402,7 +402,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) !>
      • The eigenvalues and eigenvectors (if required) are written to the file \c .ext.GF.ev as follows: !> !> ``` -!> open(hunit,file=trim(hidden_ext)//".GF.ev",status="unknown",form="unformatted") +!> open(hunit,file=trim(get_hidden(ext))//".GF.ev",status="unknown",form="unformatted") !> write(hunit)NGdof,Ldvr,Ldvi ! integers; if only the eigenvalues were computed then Ldvr=Ldvi=1; !> write(hunit)evalr(1:NGdof) ! reals ; real part of eigenvalues; !> write(hunit)evali(1:NGdof) ! reals ; imaginary part of eigenvalues; @@ -419,7 +419,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) if( LHmatrix ) then if( myid.eq.0 ) then ; cput = GETTIME ; write(ounit,'("hesian : ",f10.2," : LHmatrix="L2" ;")')cput-cpus, LHmatrix ; - open(munit, file=trim(hidden_ext)//".GF.ma", status="unknown", form="unformatted") + open(munit, file=trim(get_hidden(ext))//".GF.ma", status="unknown", form="unformatted") write(munit) NGdof write(munit) ohessian(1:NGdof,1:NGdof) close(munit) @@ -574,7 +574,7 @@ subroutine hesian( NGdof, position, Mvol, mn, LGdof ) if( myid.eq.0 ) then ! write to file; 04 Dec 14; - open(hunit, file=trim(hidden_ext)//".GF.ev", status="unknown", form="unformatted") + open(hunit, file=trim(get_hidden(ext))//".GF.ev", status="unknown", form="unformatted") write(hunit) NGdof, Ldvr, Ldvi write(hunit) evalr write(hunit) evali diff --git a/src/newton.f90 b/src/newton.f90 index 77573670..ee2fadde 100644 --- a/src/newton.f90 +++ b/src/newton.f90 @@ -64,7 +64,7 @@ subroutine newton( NGdof, position, ihybrd ) use cputiming, only : Tnewton - use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, & + use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, get_hidden, & NOTstellsym, & ForceErr, Energy, & mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, & @@ -313,7 +313,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) use cputiming, only : Tnewton - use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, hidden_ext, & + use allglobal, only : myid, cpus, MPI_COMM_SPEC, ext, get_hidden, & mn, im, in, hessian, Lhessianallocated LOCALS @@ -336,7 +336,7 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) ! reset I/O state ios = 0 - open( dunit, file=trim(hidden_ext)//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file; + open( dunit, file=trim(get_hidden(ext))//".sp.DF", status="replace", form="unformatted", iostat=ios ) ! save derivative matrix to file; FATAL( newton, ios.ne.0, error opening derivative matrix file ) write( dunit, iostat=ios ) Igeometry, Istellsym, Lfreebound, Nvol, Mpol, Ntor, NGdof ! enable resolution consistency check; @@ -352,11 +352,11 @@ subroutine writereadgf( readorwrite, NGdof , ireadhessian ) cput = GETTIME - inquire( file=trim(hidden_ext)//".sp.DF", exist=exist ) ! the derivative matrix; + inquire( file=trim(get_hidden(ext))//".sp.DF", exist=exist ) ! the derivative matrix; if( exist ) then ! 01234567890123456789012345678901 write(ounit,2000) cput-cpus, myid, "reading .ext.sp.DF ; " - open( dunit, file=trim(hidden_ext)//".sp.DF", status="old", form="unformatted", iostat=ios ) + open( dunit, file=trim(get_hidden(ext))//".sp.DF", status="old", form="unformatted", iostat=ios ) else ! 01234567890123456789012345678901 write(ounit,2000) cput-cpus, myid, ".ext.sp.DF does not exist ; " inquire( file=".sp.DF", exist=exist ) ! the derivative matrix; @@ -442,7 +442,7 @@ subroutine fcn1( NGdof, xx, fvec, irevcm ) use cputiming, only : Tnewton - use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, & + use allglobal, only : wrtend, myid, ncpu, cpus, MPI_COMM_SPEC, ext, get_hidden, & NOTstellsym, & ForceErr, Energy, & mn, im, in, iRbc, iZbs, iRbs, iZbc, Mvol, & diff --git a/src/pp00aa.f90 b/src/pp00aa.f90 index 6c0fb2f2..cf2a94dc 100644 --- a/src/pp00aa.f90 +++ b/src/pp00aa.f90 @@ -25,7 +25,7 @@ !> !>~~~~~~~~~~~~ !> write(svol,'(i4.4)')lvol ! lvol labels volume; -!> open(lunit+myid,file=trim(hidden_ext)//".poincare."//svol,status="unknown",form="unformatted") +!> open(lunit+myid,file=trim(get_hidden(ext))//".poincare."//svol,status="unknown",form="unformatted") !> do until end of file !> write(lunit+myid) Nz, nPpts ! integers !> write(lunit+myid) data(1:4,0:Nz-1,1:nPpts) ! doubles @@ -55,7 +55,7 @@ !>
      • The rotational-transform data is written to \c .ext.transform:xxxx , where \c xxxx is an integer indicating the volume. !> The format of this file is as follows: !> ``` -!> open(lunit+myid,file=trim(hidden_ext)//".sp.t."//svol,status="unknown",form="unformatted") +!> open(lunit+myid,file=trim(get_hidden(ext))//".sp.t."//svol,status="unknown",form="unformatted") !> write(lunit+myid) lnPtrj-ioff+1 ! integer !> write(lunit+myid) diotadxup(0:1,0,lvol) ! doubles !> write(lunit+myid) ( fiota(itrj,1:2), itrj = ioff, lnPtrj ) ! doubles diff --git a/src/ra00aa.f90 b/src/ra00aa.f90 index 15ccaf82..0cc88505 100644 --- a/src/ra00aa.f90 +++ b/src/ra00aa.f90 @@ -24,7 +24,7 @@ !>
          !>
        • The format of the files containing the vector potential is as follows: !> ``` -!> open(aunit, file=trim(hidden_ext)//".sp.A", status="replace", form="unformatted" ) +!> open(aunit, file=trim(get_hidden(ext))//".sp.A", status="replace", form="unformatted" ) !> write(aunit) Mvol, Mpol, Ntor, mn, Nfp ! integers; !> write(aunit) im(1:mn) ! integers; poloidal modes; !> write(aunit) in(1:mn) ! integers; toroidal modes; @@ -57,7 +57,7 @@ subroutine ra00aa( writeorread ) use cputiming, only : Tra00aa - use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, hidden_ext, Mvol, mn, im, in, Ate, Aze, Ato, Azo + use allglobal, only : myid, ncpu, cpus, MPI_COMM_SPEC, ext, get_hidden, Mvol, mn, im, in, Ate, Aze, Ato, Azo use sphdf5, only : write_vector_potential @@ -148,12 +148,12 @@ subroutine ra00aa( writeorread ) if( myid.eq.0 ) then - inquire(file=trim(hidden_ext)//".sp.A",exist=exist) + inquire(file=trim(get_hidden(ext))//".sp.A",exist=exist) if( .not.exist ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; .ext.sp.A does not exist ;")') cput-cpus, myid ; goto 9998 endif - open(aunit,file=trim(hidden_ext)//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential; + open(aunit,file=trim(get_hidden(ext))//".sp.A",status="old",form="unformatted",iostat=ios) ! this will contain initial guess for vector potential; if( ios.ne.0 ) then ; write(ounit,'("ra00aa : ",f10.2," : myid=",i3," ; error ; opening .ext.sp.A ;")') cput-cpus, myid ; goto 9997 endif diff --git a/src/xspech.f90 b/src/xspech.f90 index 26f0e1ee..1389b232 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -204,12 +204,12 @@ subroutine read_command_args use fileunits, only: ounit use inputlist, only: Wreadin - use allglobal, only: cpus, myid, ext, hidden_ext, MPI_COMM_SPEC, write_spec_namelist + use allglobal, only: cpus, myid, ext, get_hidden, MPI_COMM_SPEC, write_spec_namelist LOCALS LOGICAL :: Lspexist - INTEGER :: iargc, iarg, numargs, extlen, sppos, basename_start_index + INTEGER :: iargc, iarg, numargs, extlen, sppos CHARACTER(len=100) :: arg @@ -243,16 +243,6 @@ subroutine read_command_args endif ext = trim(arg) - ! Prepare the "hidden" ext filepath that has a "." prefix. - ! Split ext into directory path and basename using INDEX function, then concatenate them again with a "." inbetween -#ifdef _WIN32 - basename_start_index = INDEX(ext, '\', .TRUE.) -#else - basename_start_index = INDEX(ext, '/', .TRUE.) -#endif - ! folder + . + filename - hidden_ext = trim(ext(1:basename_start_index))//"."//trim(ext(basename_start_index+1:)) - write(ounit,'("rdcmdl : ", 10x ," : ")') write(ounit,'("rdcmdl : ",f10.2," : ext = ",a100)') cput-cpus, ext end select From e406819335b6b5527452d4e9c19e001b479cd4bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Jura=C5=A1i=C4=87?= <58512364+missing-user@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:50:38 +0100 Subject: [PATCH 134/134] Update _plot_pressure.py --- Utilities/pythontools/py_spec/output/_plot_pressure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/pythontools/py_spec/output/_plot_pressure.py b/Utilities/pythontools/py_spec/output/_plot_pressure.py index 6110699c..97d51d0b 100644 --- a/Utilities/pythontools/py_spec/output/_plot_pressure.py +++ b/Utilities/pythontools/py_spec/output/_plot_pressure.py @@ -10,7 +10,7 @@ def plot_pressure(self, normalize=True, ax=None, **kwargs): import matplotlib.pyplot as plt pressure = np.atleast_1d(self.input.physics.pressure) * self.input.physics.pscale - tflux = self.output.tflux[: len(pressure)] + tflux = np.atleast_1d(self.output.tflux)[: len(pressure)] if not normalize: # remove mu_0 pressure /= 4 * np.pi * 1.0e-7