From 5caf879b882ac86b156963f026e04200b3040fab Mon Sep 17 00:00:00 2001
From: Antoine Cyril David Hoffmann <ahoffman@spcpc606.epfl.ch>
Date: Wed, 3 Mar 2021 11:24:38 +0100
Subject: [PATCH] update scripts

---
 wk/analysis_2D.m | 81 +++++++++++++++++-------------------------------
 wk/daint_run.m   | 24 +++++++-------
 wk/local_run.m   | 43 +++++++++++++------------
 wk/marconi_run.m | 15 +++++----
 wk/untitled.m    | 32 +++++++++++++++++++
 5 files changed, 102 insertions(+), 93 deletions(-)
 create mode 100644 wk/untitled.m

diff --git a/wk/analysis_2D.m b/wk/analysis_2D.m
index 8a1cb01e..00306a61 100644
--- a/wk/analysis_2D.m
+++ b/wk/analysis_2D.m
@@ -1,12 +1,20 @@
 %% Load results
+outfile ='';
 if 0
-    %%
+    %% Load from Marconi
     outfile ='';
     outfile ='';
-    outfile ='/marconi_scratch/userexternal/ahoffman/HeLaZ/results/Marconi_DGGK_eta_0.6_nu_1e+00/150x75_L_70_P_10_J_5_eta_0.6_nu_1e+00_DGGK_CLOS_0_mu_8e-04/out.txt';
-
+    outfile ='/marconi_scratch/userexternal/ahoffman/HeLaZ/results/Marconi_DGGK_eta_0.6_nu_1e+00/300x150_L_70_P_10_J_5_eta_0.6_nu_1e+00_DGGK_CLOS_0_mu_1e-04/out.txt';
     BASIC.RESDIR = load_marconi(outfile);
 end
+if 0
+    %% Load from Daint
+    outfile ='';
+    outfile ='';
+    outfile ='/scratch/snx3000/ahoffman/HeLaZ/results/Daint_eta_0.6_nu_1e-01/200x100_L_70_P_12_J_6_eta_0.6_nu_1e-01_DGGK_CLOS_0_mu_1e-03/out.txt';
+%     outfile ='/scratch/snx3000/ahoffman/HeLaZ/results/Daint_eta_0.6_nu_1e-01/150x75_L_70_P_12_J_6_eta_0.6_nu_1e-01_DGGK_CLOS_0_mu_2e-03/out.txt';
+    BASIC.RESDIR = load_daint(outfile);
+end
 %%
 % JOBNUM = 0; load_results;
 % JOBNUM = 1; load_results;
@@ -143,7 +151,6 @@ disp('- growth rate')
 [~,itmax] = max(GFlux_ri);
 tstart = 0.1 * Ts2D(itmax); tend = 0.9 * Ts2D(itmax);
 g_          = zeros(Nkr,Nkz);
-[~,ikr0KH] = min(abs(kr-KR0KH));
 for ikr = 1:Nkr
     for ikz = 1:Nkz
         g_(ikr,ikz) = LinearFit_s(Ts2D,squeeze(abs(Ni00(ikr,ikz,:))),tstart,tend);
@@ -206,22 +213,17 @@ end
 
 if 1
 %% Particle fluxes
+SCALING = Nkr*dkr * Nkz*dkz;
 fig = figure; FIGNAME = ['gamma',sprintf('_%.2d',JOBNUM)];
-set(gcf, 'Position',  [100, 100, 1200, 400])
-    subplot(211)
-        plot(Ts2D,GFlux_ri); hold on
-        plot(Ts5D,PFlux_ri,'--'); hold on
-        ylabel('$\Gamma_r$'); grid on
+set(gcf, 'Position',  [100, 100, 800, 300])
+        plot(Ts2D,GFLUX_RI, 'color', line_colors(2,:)); hold on
+        plot(Ts5D,PFLUX_RI,'.', 'color', line_colors(2,:)); hold on
+        plot(Ts2D,SCALING*GFlux_ri, 'color', line_colors(1,:)); hold on
+        plot(Ts5D,SCALING*PFlux_ri,'.', 'color', line_colors(1,:)); hold on
+        xlabel('$tc_{s0}/\rho_s$'); ylabel('$\Gamma_r$'); grid on
         title(['$\eta=',num2str(ETAB),'\quad',...
-            '\nu_{',CONAME,'}=',num2str(NU),'$'])
-        legend(['$P=',num2str(PMAXI),'$, $J=',num2str(JMAXI),'$'],'Particle flux')%'$\eta\gamma_{max}/k_{max}^2$')
-    subplot(212)
-        plot(Ts2D,GFLUX_RI); hold on
-        plot(Ts5D,PFLUX_RI,'--'); hold on
-        ylabel('$\Gamma_r$'); grid on
-        title(['$\eta=',num2str(ETAB),'\quad',...
-            '\nu_{',CONAME,'}=',num2str(NU),'$'])
-        legend(['$P=',num2str(PMAXI),'$, $J=',num2str(JMAXI),'$'],'Particle flux')%'$\eta\gamma_{max}/k_{max}^2$')
+            '\nu_{',CONAME,'}=',num2str(NU),'$', ' $P=',num2str(PMAXI),'$, $J=',num2str(JMAXI),'$'])
+        legend('Gyro Flux','Particle flux', 'iFFT GFlux', 'iFFT PFlux')%'$\eta\gamma_{max}/k_{max}^2$')
 save_figure
 end
 
@@ -229,9 +231,8 @@ if 1
 %% Space time diagramm (fig 11 Ivanov 2020)
 fig = figure; FIGNAME = 'space_time_drphi';set(gcf, 'Position',  [100, 100, 1200, 600])
     subplot(311)
-        plot(Ts2D,GFlux_ri); hold on
-        plot(Ts5D,PFlux_ri,'.'); hold on
-        plot(Ts2D,GFLUX_RI,'--'); hold on
+        plot(Ts2D,GFLUX_RI,'-'); hold on
+        plot(Ts5D,PFLUX_RI,'.'); hold on
 %         plot(Ts2D,Bohm_transport*ones(size(Ts2D)),'--'); hold on
         ylabel('$\Gamma_r$'); grid on
         title(['$\eta=',num2str(ETAB),'\quad',...
@@ -354,13 +355,6 @@ FIELD = real(ni00); X = RR; Y = ZZ; T = Ts2D; FRAMES = FRAMES_2D;
 FIELDNAME = '$n_i$'; XNAME = '$r/\rho_s$'; YNAME = '$z/\rho_s$';
 create_gif
 end
-if 0
-%% Density electron
-GIFNAME = ['ne',sprintf('_%.2d',JOBNUM)]; INTERP = 1;
-FIELD = real(ne00); X = RR; Y = ZZ; T = Ts2D; FRAMES = FRAMES_2D;
-FIELDNAME = '$n_e$'; XNAME = '$r/\rho_s$'; YNAME = '$z/\rho_s$';
-create_gif
-end
 if 1
 %% Phi real space
 GIFNAME = ['phi',sprintf('_%.2d',JOBNUM)];INTERP = 1;
@@ -368,6 +362,13 @@ FIELD = real(phi); X = RR; Y = ZZ; T = Ts2D; FRAMES = FRAMES_2D;
 FIELDNAME = '$\phi$'; XNAME = '$r/\rho_s$'; YNAME = '$z/\rho_s$';
 create_gif
 end
+if 0
+%% radial particle transport
+GIFNAME = ['gamma_r',sprintf('_%.2d',JOBNUM)]; INTERP = 1;
+FIELD = real(ni00.*dzphi); X = RR; Y = ZZ; T = Ts2D; FRAMES = FRAMES_2D;
+FIELDNAME = '$\Gamma_r$'; XNAME = '$r/\rho_s$'; YNAME = '$z/\rho_s$';
+create_gif
+end
 if 1
 %% Phi fourier
 GIFNAME = ['FFT_phi',sprintf('_%.2d',JOBNUM)];INTERP = 0;
@@ -391,14 +392,6 @@ FIELDNAME = '$N_i^{00}$'; XNAME = '$k_r\rho_s$'; YNAME = '$k_z\rho_s$';
 create_gif
 end
 if 0
-%% Density ion frequency @ kr = 0
-GIFNAME = ['Ni00_kr0',sprintf('_%.2d',JOBNUM)]; INTERP = 0;
-FIELD =(squeeze(abs(Ni00(1,:,:)))); linestyle = 'o-.'; FRAMES = FRAMES_2D;
-X = (kz); T = Ts2D; YMIN = -.1; YMAX = 1.1; XMIN = min(kz); XMAX = max(kz);
-FIELDNAME = '$N_i^{00}(kr=0)$'; XNAME = '$k_r\rho_s$';
-create_gif_1D
-end
-if 0
 %% kr vs P Si
 GIFNAME = ['Sip0_kr',sprintf('_%.2d',JOBNUM)]; INTERP = 0;
 plt = @(x) squeeze(max((abs(x)),[],4));
@@ -422,20 +415,4 @@ FIELD = plt(Nipj); X = sort(kz'); Y = Pi'; T = Ts5D; FRAMES = FRAMES_5D;
 FIELDNAME = 'N_i'; XNAME = '$k_z\rho_s$'; YNAME = '$P$, ${k_r}^{max}$';
 create_gif_5D
 end
-if 0
-%% maxkz, kr vs p, for all Nepj over time
-GIFNAME = ['Nepj_kr',sprintf('_%.2d',JOBNUM)]; INTERP = 0;
-plt = @(x) squeeze(max((abs(x)),[],4));
-FIELD = plt(Nepj); X = kr'; Y = Pi'; T = Ts5D; FRAMES = FRAMES_5D;
-FIELDNAME = 'N_e'; XNAME = '$k_r\rho_s$'; YNAME = '$P$, ${k_z}^{max}$';
-create_gif_5D
-end
-if 0
-%% maxkz, kz vs p, for all Nepj over time
-GIFNAME = ['Nepj_kz',sprintf('_%.2d',JOBNUM)]; INTERP = 0;
-plt = @(x) fftshift(squeeze(max((abs(x)),[],3)),3);
-FIELD = plt(Nepj); X = sort(kz'); Y = Pi'; T = Ts5D; FRAMES = FRAMES_5D;
-FIELDNAME = 'N_e'; XNAME = '$k_z\rho_s$'; YNAME = '$P$, ${k_r}^{max}$';
-create_gif_5D
-end
 %%
\ No newline at end of file
diff --git a/wk/daint_run.m b/wk/daint_run.m
index 6b343440..73efd98c 100644
--- a/wk/daint_run.m
+++ b/wk/daint_run.m
@@ -4,23 +4,25 @@ addpath(genpath('../matlab')) % ... add
 %% Set Up parameters
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% CLUSTER PARAMETERS
-CLUSTER.TIME  = '06:00:00'; % allocation time hh:mm:ss
-CLUSTER.NODES = '1';        % MPI process
-CLUSTER.CPUPT = '1';        % CPU per task
-CLUSTER.NTPN  = '24';       % N tasks per node
-CLUSTER.PART  = 'normal';    % debug or normal
+CLUSTER.TIME  = '24:00:00'; % allocation time hh:mm:ss
+CLUSTER.NODES = '1';        % number of nodes
+CLUSTER.NTPN  = '32';       % N tasks per node (mpi processes)
+CLUSTER.NTPC  = '1';        % N tasks per core (openmp threads)
+CLUSTER.CPUPT = '1';        % CPU per task     (number of CPU per mpi proc)
+CLUSTER.PART  = 'normal';   % debug or normal
+if(strcmp(CLUSTER.PART,'debug')); CLUSTER.TIME  = '00:30:00'; end;
 CLUSTER.MEM   = '12GB';     % Memory
 CLUSTER.JNAME = 'gamma_inf';% Job name
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% PHYSICAL PARAMETERS
-NU      = 0.1;   % Collision frequency
+NU      = 1.0;   % Collision frequency
 ETAB    = 0.6;   % Magnetic gradient
-NU_HYP  = 0.2;   % Hyperdiffusivity coefficient
+NU_HYP  = 0.1;   % Hyperdiffusivity coefficient
 %% GRID PARAMETERS
-N       = 150;   % Frequency gridpoints (Nkr = N/2)
-L       = 70;    % Size of the squared frequency domain
-P       = 12;    % Electron and Ion highest Hermite polynomial degree
-J       = 06;    % Electron and Ion highest Laguerre polynomial degree
+N       = 200;   % Frequency gridpoints (Nkr = N/2)
+L       = 120;    % Size of the squared frequency domain
+P       = 10;    % Electron and Ion highest Hermite polynomial degree
+J       = 05;    % Electron and Ion highest Laguerre polynomial degree
 MU_P    = 0;     % Hermite  hyperdiffusivity -mu_p*(d/dvpar)^4 f
 MU_J    = 0;     % Laguerre hyperdiffusivity -mu_j*(d/dvperp)^4 f
 %% TIME PARAMETERS
diff --git a/wk/local_run.m b/wk/local_run.m
index bce436f3..856d8c64 100644
--- a/wk/local_run.m
+++ b/wk/local_run.m
@@ -5,36 +5,30 @@ CLUSTER.TIME  = '99:00:00'; % allocation time hh:mm:ss
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% PHYSICAL PARAMETERS
 NU      = 1.0;   % Collision frequency
-TAU     = 1.0;    % e/i temperature ratio
-ETAB    = 0.6;    % Magnetic gradient
+ETAB    = 0.5;    % Magnetic gradient
 ETAN    = 1.0;    % Density gradient
-ETAT    = 0.0;    % Temperature gradient
-HD_CO   = 0.5;    % Hyper diffusivity cutoff ratio
 NU_HYP  = 0.1;
 %% GRID PARAMETERS
-N       = 150;     % Frequency gridpoints (Nkr = N/2)
-L       = 70;     % Size of the squared frequency domain
-PMAXE   = 4;     % Highest electron Hermite polynomial degree
-JMAXE   = 4;     % Highest ''       Laguerre ''
-PMAXI   = 4;     % Highest ion      Hermite polynomial degree
-JMAXI   = 4;     % Highest ''       Laguerre ''
-MU_P    = 0.1/PMAXI^2;     % Hermite  hyperdiffusivity -mu_p*(d/dvpar)^4 f
-MU_J    = 0.1/JMAXI^3;     % Laguerre hyperdiffusivity -mu_j*(d/dvperp)^4 f
+N       = 200;     % Frequency gridpoints (Nkr = N/2)
+L       = 125;     % Size of the squared frequency domain
+PMAXE   = 2;     % Highest electron Hermite polynomial degree
+JMAXE   = 1;     % Highest ''       Laguerre ''
+PMAXI   = 2;     % Highest ion      Hermite polynomial degree
+JMAXI   = 1;     % Highest ''       Laguerre ''
+
 %% TIME PARAMETERS
-TMAX    = 600;  % Maximal time unit
-DT      = 2e-2;   % Time step
+TMAX    = 50;  % Maximal time unit
+DT      = 1e-2;   % Time step
 SPS0D   = 1/DT;    % Sampling per time unit for profiler
-SPS2D   = 1;      % Sampling per time unit for 2D arrays
-SPS5D   = 1;    % Sampling per time unit for 5D arrays
+SPS2D   = 1/2;      % Sampling per time unit for 2D arrays
+SPS5D   = 1/10;    % Sampling per time unit for 5D arrays
 SPSCP   = 0;    % Sampling per time unit for checkpoints/10
 RESTART = 0;      % To restart from last checkpoint
 JOB2LOAD= 0;
 %% OPTIONS
-% SIMID   = 'local_nu_%0.0e';  % Name of the simulation
+% SIMID   = ['local_eta_',num2str(ETAB),'_nu_%0.0e'];  % Name of the simulation
 % SIMID   = sprintf(SIMID,NU);
-% SIMID   = 'Marconi_DGGK_nu_1e+00';  % Name of the simulation
-% SIMID   = 'test_sapj_cut';  % Name of the simulation
-SIMID   = 'test_moments_damping';  % Name of the simulation
+SIMID   = 'test_parallel_p';  % Name of the simulation
 CO      = -3;  % Collision operator (0 : L.Bernstein, -1 : Full Coulomb, -2 : Dougherty, -3 : GK Dougherty)
 CLOS    = 0;   % Closure model (0: =0 truncation, 1: semi coll, 2: Copy closure J+1 = J, P+2 = P)
 KERN    = 0;   % Kernel model (0 : GK)
@@ -47,9 +41,14 @@ KPAR    = 0.0;    % Parellel wave vector component
 LAMBDAD = 0.0;
 NON_LIN = 1 *(1-KREQ0);   % activate non-linearity (is cancelled if KREQ0 = 1)
 kmax    = N*pi/L;% Highest fourier mode
-MU      = NU_HYP/(HD_CO*kmax)^4 % Hyperdiffusivity coefficient
+HD_CO   = 0.5;    % Hyper diffusivity cutoff ratio
+% kmaxcut = 2.5;
+MU      = NU_HYP/(kmax)^4 % Hyperdiffusivity coefficient
 NOISE0  = 1.0e-5;
-
+TAU     = 1.0;    % e/i temperature ratio
+ETAT    = 0.0;    % Temperature gradient
+MU_P    = 0.0/PMAXI^2;     % Hermite  hyperdiffusivity -mu_p*(d/dvpar)^4 f
+MU_J    = 0.0/JMAXI^3;     % Laguerre hyperdiffusivity -mu_j*(d/dvperp)^4 f
 %% Setup and file management
 setup
 system('rm fort.90');
\ No newline at end of file
diff --git a/wk/marconi_run.m b/wk/marconi_run.m
index 646ea136..d53f5473 100644
--- a/wk/marconi_run.m
+++ b/wk/marconi_run.m
@@ -15,25 +15,24 @@ CLUSTER.JNAME = 'gamma_inf';% Job name
 %% PHYSICAL PARAMETERS
 NU      = 1.0;   % Collision frequency
 ETAB    = 0.6;   % Magnetic gradient
-NU_HYP  = 0.1;   % Hyperdiffusivity coefficient
+NU_HYP  = 0.2;   % Hyperdiffusivity coefficient
 %% GRID PARAMETERS
-N       = 150;     % Frequency gridpoints (Nkr = N/2)
+N       = 200;     % Frequency gridpoints (Nkr = N/2)
 L       = 70;     % Size of the squared frequency domain
 P       = 10;       % Electron and Ion highest Hermite polynomial degree
 J       = 5;       % Electron and Ion highest Laguerre polynomial degree
 MU_P    = 0;     % Hermite  hyperdiffusivity -mu_p*(d/dvpar)^4 f
 MU_J    = 0;     % Laguerre hyperdiffusivity -mu_j*(d/dvperp)^4 f
 %% TIME PARAMETERS
-TMAX    = 500;  % Maximal time unit
+TMAX    = 1000;  % Maximal time unit
 DT      = 1e-2;  % Time step
 SPS0D   = 1;      % Sampling per time unit for profiler
 SPS2D   = 1/2;   % Sampling per time unit for 2D arrays
-SPS5D   = 1/10;  % Sampling per time unit for 5D arrays
-SPSCP   = 1/10;  % Sampling per time unit for checkpoints
-RESTART = 1;     % To restart from last checkpoint
+SPS5D   = 1/4;  % Sampling per time unit for 5D arrays
+SPSCP   = 0;  % Sampling per time unit for checkpoints
+RESTART = 0;     % To restart from last checkpoint
 JOB2LOAD= 0;
 %% OPTIONS
-% SIMID   = 'Marconi_DGGK_nu_%0.0e';  % Name of the simulation
 SIMID   = ['Marconi_DGGK_eta_',num2str(ETAB),'_nu_%0.0e'];  % Name of the simulation
 % SIMID   = 'Marconi_restart';  % Name of the simulation
 SIMID   = sprintf(SIMID,NU);
@@ -61,6 +60,6 @@ ETAN    = 1.0;    % Density gradient
 TAU     = 1.0;    % e/i temperature ratio
 %% Run file management scripts
 setup
-write_sbash
+write_sbash_marconi
 system('rm fort.90 setup_and_run.sh batch_script.sh');
 disp('done');
diff --git a/wk/untitled.m b/wk/untitled.m
new file mode 100644
index 00000000..73a43949
--- /dev/null
+++ b/wk/untitled.m
@@ -0,0 +1,32 @@
+N = 100;
+L = 20;
+
+A0 = 2;
+N0 =  4;
+K0 = 2*pi/L*N0;
+
+f = @(x_) A0 * sin(K0*x_);
+
+
+x = linspace(0,L, N);
+
+dk= 2*pi/L;
+k = dk*(-N/2:N/2-1);
+
+F = zeros(1,N);
+
+[~,ik0p] = min(abs(k-K0));
+[~,ik0m] = min(abs(k+K0));
+
+F(ik0p) = -A0/2 * 1i/dk;
+F(ik0m) =  A0/2 * 1i/dk;
+
+
+f_ = ifft(fftshift(F));
+figure
+plot(x,f(x)); hold on;
+plot(x,N*dk*f_)
+
+%%
+figure
+plot(k,imag(F))
\ No newline at end of file
-- 
GitLab