From e95bee0977b7d2c250c34a258040f438ee03d620 Mon Sep 17 00:00:00 2001
From: Antoine Hoffmann <antoine.hoffmann@epfl.ch>
Date: Tue, 21 Jun 2022 17:27:02 +0200
Subject: [PATCH] script updates

---
 matlab/compile_results.m    |  3 ++-
 matlab/extract_fig_data.m   |  5 ++++-
 matlab/plot/save_figure.m   |  6 ++---
 matlab/plot/show_geometry.m |  2 +-
 wk/analysis_HeLaZ.m         | 45 +++++++++++++++++++------------------
 wk/analysis_gbms.m          |  2 +-
 wk/cbc_qx_results.m         | 25 ++++++++++++++++++++-
 wk/header_3D_results.m      | 11 +++++++--
 wk/quick_run.m              |  4 ++--
 9 files changed, 69 insertions(+), 34 deletions(-)

diff --git a/matlab/compile_results.m b/matlab/compile_results.m
index 952dec78..66a18e6e 100644
--- a/matlab/compile_results.m
+++ b/matlab/compile_results.m
@@ -264,7 +264,8 @@ else
     DATA.dir      = DIRECTORY;
     DATA.localdir = DIRECTORY;
     DATA.param_title=['$\nu_{',DATA.CONAME,'}=$', num2str(DATA.NU), ...
-        ', $\kappa_N=$',num2str(DATA.K_N),', $L=',num2str(DATA.L),'$, $N=',...
+        ', $\kappa_N=$',num2str(DATA.K_N),', $\kappa_T=$',num2str(DATA.K_T),...
+        ', $L=',num2str(DATA.L),'$, $N=',...
         num2str(DATA.Nx),'$, $(P,J)=(',num2str(DATA.PMAXI),',',...
         num2str(DATA.JMAXI),')$,',' $\mu_{hd}=$(',num2str(DATA.MUx),...
         ',',num2str(DATA.MUy),')'];
diff --git a/matlab/extract_fig_data.m b/matlab/extract_fig_data.m
index 27f177e4..e996e711 100644
--- a/matlab/extract_fig_data.m
+++ b/matlab/extract_fig_data.m
@@ -15,6 +15,9 @@ shift = X_(n0);
 % plot(X_(n0:end),Y_(n0:end));
 plot(mvm(X_(n0:end)-shift),mvm(Y_(n0:end))); hold on;
 
+t0 = ceil(numel(X_)*0.5); t1 = numel(X_);
+avg= mean(Y_(t0:t1)); dev = std(Y_(t0:t1));
+  disp(['AVG =',sprintf('%2.2f',avg),'+-',sprintf('%2.2f',dev)]);
 % 
 % n1 = n0+1; n2 = min(n1 + 50000,numel(Y_));
 % avg_ = mean(Y_(n1:n2));
@@ -23,7 +26,7 @@ plot(mvm(X_(n0:end)-shift),mvm(Y_(n0:end))); hold on;
 % plot([X_(n1),X_(n2)],[1 1]*avg_,'--k')
 
 % ylim([0,avg_*3]);
-sum(Y_(2:end)./X_(2:end).^(3/2))
+% sum(Y_(2:end)./X_(2:end).^(3/2))
 %%
 
 if 0
diff --git a/matlab/plot/save_figure.m b/matlab/plot/save_figure.m
index d1ce56e2..7ac2be33 100644
--- a/matlab/plot/save_figure.m
+++ b/matlab/plot/save_figure.m
@@ -1,10 +1,10 @@
 %% Auxiliary script to save figure using a dir (FIGDIR), name (FIGNAME) 
 %  and parameters
-function save_figure(data,FIGURE)
+function save_figure(data,FIGURE,EXT)
 if ~exist([data.FIGDIR,'/fig'], 'dir')
    mkdir([data.FIGDIR,'/fig'])
 end
 saveas(FIGURE.fig,[data.FIGDIR,'/fig/', FIGURE.FIGNAME,'.fig']);
-saveas(FIGURE.fig,[data.FIGDIR, FIGURE.FIGNAME,'.png']);
-disp(['Figure saved @ : ',[data.FIGDIR, FIGURE.FIGNAME,'.png']])
+saveas(FIGURE.fig,[data.FIGDIR, FIGURE.FIGNAME,EXT]);
+disp(['Figure saved @ : ',[data.FIGDIR, FIGURE.FIGNAME,EXT]])
 end
\ No newline at end of file
diff --git a/matlab/plot/show_geometry.m b/matlab/plot/show_geometry.m
index 0723b805..47024ac4 100644
--- a/matlab/plot/show_geometry.m
+++ b/matlab/plot/show_geometry.m
@@ -1,7 +1,7 @@
 function [ FIGURE ] = show_geometry(DATA,OPTIONS)
 % filtering Z pinch and torus
 if DATA.Nz > 1 % Torus flux tube geometry
-    Nptor  = DATA.Nz; Tgeom = 1;
+    Nptor  = DATA.Nz*2; Tgeom = 1;
     Nturns = 1;
     a      = DATA.EPS; % Torus minor radius
     R      = 1.; % Torus major radius
diff --git a/wk/analysis_HeLaZ.m b/wk/analysis_HeLaZ.m
index 4eda312c..21d2cb6e 100644
--- a/wk/analysis_HeLaZ.m
+++ b/wk/analysis_HeLaZ.m
@@ -7,6 +7,7 @@ addpath(genpath([helazdir,'matlab/load'])) % ... add
 LOCALDIR  = [helazdir,'results/',outfile,'/'];
 MISCDIR   = ['/misc/HeLaZ_outputs/results/',outfile,'/'];
 system(['mkdir -p ',MISCDIR]);
+system(['mkdir -p ',LOCALDIR]);
 CMD = ['rsync ', LOCALDIR,'outputs* ',MISCDIR]; disp(CMD);
 system(CMD);
 % Load outputs from jobnummin up to jobnummax
@@ -22,14 +23,14 @@ FMT = '.fig';
 
 if 1
 %% Space time diagramm (fig 11 Ivanov 2020)
-options.TAVG_0   = 0.5*data.Ts3D(end); data.scale = (1/data.Nx/data.Ny)^2;
+options.TAVG_0   = 0.7*data.Ts3D(end); data.scale = (1/data.Nx/data.Ny)^2;
 options.TAVG_1   = data.Ts3D(end); % Averaging times duration
 options.NMVA     = 1;              % Moving average for time traces
 % options.ST_FIELD = '\Gamma_x';          % chose your field to plot in spacetime diag (e.g \phi,v_x,G_x)
 options.ST_FIELD = '\phi';          % chose your field to plot in spacetime diag (e.g \phi,v_x,G_x)
 options.INTERP   = 1;
 fig = plot_radial_transport_and_spacetime(data,options);
-save_figure(data,fig)
+save_figure(data,fig,'.png')
 end
 
 if 0
@@ -41,7 +42,7 @@ end
 if 0
 %% MOVIES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 % Options
-options.INTERP    = 0;
+options.INTERP    = 1;
 options.POLARPLOT = 0;
 options.NAME      = '\phi';
 % options.NAME      = 'N_i^{00}';
@@ -49,13 +50,13 @@ options.NAME      = '\phi';
 % options.NAME      = 'n_i^{NZ}';
 % options.NAME      = '\Gamma_x';
 % options.NAME      = 'n_i';
-options.PLAN      = 'xz';
+options.PLAN      = 'kxky';
 % options.NAME      = 'f_i';
 % options.PLAN      = 'sx';
 options.COMP      = 'avg';
 % options.TIME      = data.Ts5D(end-30:end);
 options.TIME      = data.Ts3D;
-% options.TIME      = [700:1100];
+% options.TIME      = [350:600];
 data.EPS          = 0.1;
 data.a = data.EPS * 2000;
 create_film(data,options,'.gif')
@@ -64,7 +65,7 @@ end
 if 0
 %% 2D snapshots
 % Options
-options.INTERP    = 1;
+options.INTERP    = 0;
 options.POLARPLOT = 0;
 options.AXISEQUAL = 1;
 options.NAME      = '\phi';
@@ -73,11 +74,11 @@ options.NAME      = '\phi';
 % options.NAME      = 'T_i';
 % options.NAME      = '\Gamma_x';
 % options.NAME      = 'k^2n_e';
-% options.PLAN      = 'kxky';
-options.NAME      = 'f_i';
-options.PLAN      = 'sx';
+options.PLAN      = 'kxky';
+% options.NAME      = 'f_i';
+% options.PLAN      = 'sx';
 options.COMP      = 'avg';
-options.TIME      = [200 400 700];
+options.TIME      = [300 400 600];
 data.a = data.EPS * 2e3;
 fig = photomaton(data,options);
 % save_figure(data,fig)
@@ -87,12 +88,12 @@ if 0
 %% 3D plot on the geometry
 options.INTERP    = 1;
 options.NAME      = 'n_i';
-options.PLANES    = [1:2:12];
-options.TIME      = [60];
+options.PLANES    = [1:1:16];
+options.TIME      = [200];
 options.PLT_MTOPO = 1;
 data.rho_o_R      = 2e-3; % Sound larmor radius over Machine size ratio
 fig = show_geometry(data,options);
-save_figure(data,fig)
+save_figure(data,fig,'.png')
 end
 
 if 0
@@ -102,14 +103,14 @@ if 0
 options.SPAR      = gene_data.vp';
 options.XPERP     = gene_data.mu';
 options.iz        = 'avg';
-options.T         = [500];
+options.T         = [600];
 options.PLT_FCT   = 'contour';
 options.ONED      = 0;
 options.non_adiab = 0;
 options.SPECIE    = 'i';
 options.RMS       = 1; % Root mean square i.e. sqrt(sum_k|f_k|^2) as in Gene
 fig = plot_fa(data,options);
-% save_figure(data,fig)
+% save_figure(data,fig,'.png')
 end
 
 if 0
@@ -118,14 +119,14 @@ if 0
 options.P2J        = 0;
 options.ST         = 1;
 options.PLOT_TYPE  = 'space-time';
-options.NORMALIZED = 0;
+options.NORMALIZED = 1;
 options.JOBNUM     = 0;
 options.TIME       = [300:500];
 options.specie     = 'i';
 options.compz      = 'avg';
 fig = show_moments_spectrum(data,options);
 % fig = show_napjz(data,options);
-save_figure(data,fig)
+save_figure(data,fig,'.png');
 end
 
 if 0
@@ -142,7 +143,7 @@ options.COMPXY = 'avg';
 options.COMPT  = 'avg';
 options.PLOT   = 'semilogy';
 fig = spectrum_1D(data,options);
-% save_figure(data,fig)
+% save_figure(data,fig,'.png')
 end
 
 if 0
@@ -159,7 +160,7 @@ options.COMPZ  = 1;
 options.COMPT  = 1;
 options.MOVMT  = 1;
 fig = real_plot_1D(data,options);
-% save_figure(data,fig)
+% save_figure(data,fig,'.png')
 end
 
 if 0
@@ -171,7 +172,7 @@ options.NMA    = 1;
 options.NMODES = 15;
 options.iz     = 'avg';
 fig = mode_growth_meter(data,options);
-save_figure(data,fig)
+save_figure(data,fig,'.png')
 end
 
 if 0
@@ -179,7 +180,7 @@ if 0
 TAVG_0 = 1200; TAVG_1 = 1500; % Averaging times duration
 % chose your field to plot in spacetime diag (uzf,szf,Gx)
 fig = ZF_spacetime(data,TAVG_0,TAVG_1);
-save_figure(data,fig)
+save_figure(data,fig,'.png')
 end
 
 if 0
@@ -202,5 +203,5 @@ options.kxky = 1;
 options.kzkx = 0;
 options.kzky = 1;
 [lg, fig] = compute_3D_zpinch_growth_rate(data,trange,options);
-save_figure(data,fig)
+save_figure(data,fig,'.png')
 end
diff --git a/wk/analysis_gbms.m b/wk/analysis_gbms.m
index 1e3d2958..e492b420 100644
--- a/wk/analysis_gbms.m
+++ b/wk/analysis_gbms.m
@@ -4,7 +4,7 @@
 % figure; plot(res.paramscan,res.growth_rate)
 
 %%
-resdir = '/home/ahoffman/Documents/gbms/benchmark_HeLaZ/shearless_linear_cyclone/';
+% resdir = '/home/ahoffman/Documents/gbms/benchmark_HeLaZ/shearless_linear_cyclone/';
 resdir = '/home/ahoffman/Documents/gbms/benchmark_HeLaZ/RH_test/';
 % resdir = '/home/ahoffman/Documents/gbms/benchmark_HeLaZ/linear_cyclone/';
 % resdir = '/home/ahoffman/molix/';
diff --git a/wk/cbc_qx_results.m b/wk/cbc_qx_results.m
index 9e0b6b5b..5f815bc0 100644
--- a/wk/cbc_qx_results.m
+++ b/wk/cbc_qx_results.m
@@ -1,3 +1,4 @@
+%% CBC BENCHMARK
 cbc      = [0080 0100 0120];
 gm42     = [15.4 32.2 43.2];
 gm42_err = [2.22 05.2 08.1];
@@ -15,4 +16,26 @@ errorbar(cbc,gne,gne_err,'x-k','LineWidth',1.5);
 % set(gca, 'YScale', 'log')
 
 legend('GM (4,2)','GM (8,4)','Gene')
-xlabel('CBC drive [\%]'); ylabel('Radial Heat Flux $Q_x^\infty$');
\ No newline at end of file
+xlabel('CBC drive [\%]'); ylabel('Radial Heat Flux $Q_x^\infty$');
+
+
+%% DIMITS
+
+KN       = 2.22;
+KT       = [1.00 0.90 0.80 0.70 0.60 0.50]*6.96;
+gm42     = [32.2 16.8 0.00 0.00 1.74 0.00];
+gm42_err = [05.2 02.8 0.00 0.00 0.53 0.00];
+gm84     = [0.00 0.00 0.00 0.00 0.00 0.00];
+gm84_err = [0.00 0.00 0.00 0.00 0.00 0.00];
+gne      = [0.00 0.00 0.00 0.00 0.00 0.00];
+gne_err  = [0.00 0.00 0.00 0.00 0.00 0.00];
+
+figure
+errorbar(KT./KN,gm42,gm42_err,'o-', 'LineWidth',1.5); hold on;
+errorbar(KT./KN,gm84,gm84_err,'o-', 'LineWidth',1.5);
+errorbar(KT./KN, gne, gne_err,'x-k','LineWidth',1.5);
+
+% set(gca, 'YScale', 'log')
+
+legend('GM (4,2)','GM (8,4)','Gene')
+xlabel('$\eta=\kappa_T/\kappa_N$'); ylabel('Radial Heat Flux $Q_x^\infty$');
diff --git a/wk/header_3D_results.m b/wk/header_3D_results.m
index be36be54..5fc6c648 100644
--- a/wk/header_3D_results.m
+++ b/wk/header_3D_results.m
@@ -3,8 +3,15 @@ helazdir = '/home/ahoffman/HeLaZ/';
 % Directory of the simulation (from results)
 % if 1% Local results
 outfile ='';
-outfile ='';
-outfile ='shearless_cyclone/64x32x16x5x3_CBC_080';
+
+%% Dimits
+% outfile ='shearless_cyclone/128x64x16x5x3_Dim_90';
+outfile ='shearless_cyclone/64x32x16x5x3_Dim_50';
+%% AVS
+% outfile = 'volcokas/64x32x16x5x3_kin_e_npol_1';
+
+%% Bechmark
+% outfile ='shearless_cyclone/64x32x16x5x3_CBC_080';
 % outfile ='shearless_cyclone/64x32x16x5x3_CBC_100';
 % outfile ='shearless_cyclone/64x32x16x5x3_CBC_120';
 
diff --git a/wk/quick_run.m b/wk/quick_run.m
index 5068eff7..6cb54a7e 100644
--- a/wk/quick_run.m
+++ b/wk/quick_run.m
@@ -13,7 +13,7 @@ EXECNAME = 'helaz3';
 CLUSTER.TIME  = '99:00:00'; % allocation time hh:mm:ss
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% PHYSICAL PARAMETERS
-NU      = 0.0;   % Collision frequency
+NU      = 0.05;   % Collision frequency
 TAU     = 1.0;    % e/i temperature ratio
 K_N     = 0;%2.22;   % Density gradient drive
 K_T     = 0;%6.96;   % Temperature '''
@@ -91,7 +91,7 @@ system(['rm fort*.90']);
 if RUN
 %     system(['cd ../results/',SIMID,'/',PARAMS,'/; time mpirun -np 4 ',HELAZDIR,'bin/',EXECNAME,' 1 4 1 0; cd ../../../wk'])
 %     system(['cd ../results/',SIMID,'/',PARAMS,'/; mpirun -np 1 ',HELAZDIR,'bin/',EXECNAME,' 1 1 1 0; cd ../../../wk'])
-    system(['cd ../results/',SIMID,'/',PARAMS,'/; mpirun -np 4 ',HELAZDIR,'bin/',EXECNAME,' 1 2 2 0; cd ../../../wk'])
+    system(['cd ../results/',SIMID,'/',PARAMS,'/; mpirun -np 4 ',HELAZDIR,'bin/',EXECNAME,' 1 1 4 0; cd ../../../wk'])
 %     system(['cd ../results/',SIMID,'/',PARAMS,'/; mpirun -np 6 ',HELAZDIR,'bin/',EXECNAME,' 1 6 1 0; cd ../../../wk'])
 end
 
-- 
GitLab