rundke

PURPOSE ^

Script for running the DKE solver (can be modified by the user for specific simulations)

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

Script for running the DKE solver (can be modified by the user for specific simulations)
by Y.Peysson CEA-DRFC <yves.peysson@cea.fr> and Joan Decker MIT-RLE (jodecker@mit.edu)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %Script for running the DKE solver (can be modified by the user for specific simulations)
0002 %by Y.Peysson CEA-DRFC <yves.peysson@cea.fr> and Joan Decker MIT-RLE (jodecker@mit.edu)
0003 %
0004 clear all
0005 clear mex
0006 clear functions
0007 close all
0008 warning off
0009 global nfig
0010 %
0011 p_opt = 2;
0012 %
0013 permission = test_permissions_yp;
0014 %
0015 if ~permission 
0016     disp('Please move the script to a local folder where you have write permission before to run it')
0017     return;
0018 end
0019 %
0020 % ***********************This part must be specified by the user, run make files if necessary) *****************************
0021 %
0022 id_simul = 'Runaway_bounce';%Simulation ID
0023 path_simul = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0024 %
0025 psin_S = [];%Normalized poloidal flux grid where calculations are performed (0 < psin_S < 1) (If one value: local calculation only, not used if empty)
0026 rho_S = [linspace(0,0.2,11),linspace(0.25,1,16)];%Normalized radial flux grid where calculations are performed (0 < rho_S < 1) (If one value: local calculation only, not used if empty)
0027 %
0028 id_path = '';%For all paths used by DKE solver
0029 path_path = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0030 %
0031 id_equil_cyl = 'TScyl';%For plasma equilibrium
0032 id_equil = 'TScirc_e1';%For plasma equilibrium
0033 path_equil = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0034 %
0035 id_dkeparam = 'NONUNIFORM10010020';%For DKE code parameters
0036 path_dkeparam = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0037 %
0038 id_display = 'PARTIAL_VISUAL';%For output code display
0039 path_display = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0040 %
0041 id_ohm = '';%For Ohmic electric contribution
0042 path_ohm = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0043 %
0044 ids_wave = {''};%For RF waves contribution (put all the type of waves needed)
0045 paths_wave = {''};%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0046 %
0047 id_transpfaste = '';%For fast electron radial transport
0048 path_transpfaste = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0049 %
0050 id_ripple = '';%For fast electron magnetic ripple losses
0051 path_ripple = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0052 %
0053 %************************************************************************************************************************************
0054 %************************************************************************************************************************************
0055 %************************************************************************************************************************************
0056 %
0057 [dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple] = load_structures_yp('dkepath',id_path,path_path,'equil',id_equil,path_equil,'dkeparam',id_dkeparam,path_dkeparam,'dkedisplay',id_display,path_display,'ohm',id_ohm,path_ohm,'waves',ids_wave,paths_wave,'transpfaste',id_transpfaste,path_transpfaste,'ripple',id_ripple,path_ripple);
0058 [equil_cyl] = load_structures_yp('equil',id_equil_cyl,path_equil);
0059 %
0060 %************************************************************************************************************************************
0061 %
0062 if exist('dmumpsmex');dkeparam.invproc = -2;end
0063 %
0064 dkeparam.boundary_mode_f = 0;%Number of points where the Maxwellian distribution is enforced from p = 0 (p=0, free conservative mode but param_inv(1) must be less than 1e-4, otherwise 1e-3 is OK most of the time. Sensitive to the number of points in p)
0065 dkeparam.norm_mode_f = 1;%Local normalization of f0 at each iteration: (0) no, the default value when the numerical conservative scheme is correct, (1) yes
0066 dkeparam.tn = 10000;%time for asymptotic solution with norm_mode_f = 1
0067 dkeparam.dtn = 1000;%10 time steps required for accurate runaway solution - see rundke_dtn
0068 %
0069 dkeparam.psin_S = psin_S;
0070 dkeparam.rho_S = rho_S;
0071 %
0072 epsi = 0.04;
0073 betath = 0.001;%validated for NR limit
0074 %
0075 [qe,me,mp,mn,e0,mu0,re,mc2] = pc_dke_yp;%Universal physics constants
0076 %
0077 equil.pTe = betath^2*mc2*ones(size(equil.pTe));
0078 equil.pzTi = betath^2*mc2*ones(size(equil.pzTi));
0079 %equil.pzTi = 1e-10*ones(size(equil.pzTi));
0080 %
0081 equil_cyl.pTe = betath^2*mc2*ones(size(equil_cyl.pTe));
0082 equil_cyl.pzTi = betath^2*mc2*ones(size(equil_cyl.pzTi));
0083 %equil_cyl.pzTi = 1e-10*ones(size(equil_cyl.pzTi));
0084 %
0085 ohm_cyl = ohm_flat(equil_cyl,epsi);
0086 ohm = ohm_flat(equil,epsi);
0087 %
0088 dkeparam.np_S = 201;
0089 dkeparam.nmhu_S = 201;
0090 dkeparam.bounce_mode = 1;
0091 %
0092 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa,XXsinksource] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0093 if dke_out.residu_f{end}(end) <= dkeparam.prec0_f,
0094     RR = dke_out.XxRR_fsav(end,:);
0095 else
0096     RR = NaN;
0097 end  
0098 %
0099 dkeparam.bounce_mode = 0;
0100 dkeparam.mhu_S = momentumDKE.mhu_S;
0101 [Znorm_cyl,Zcurr_cyl,ZP0_cyl,dke_out_cyl] = main_dke_yp(id_simul,dkepath,equil_cyl,dkeparam,dkedisplay,ohm_cyl,waves,transpfaste,ripple,[],[]);
0102 if dke_out_cyl.residu_f{end}(end) <= dkeparam.prec0_f,
0103     RR_0 = dke_out_cyl.XxRR_fsav(end,:);
0104 else
0105     RR_0 = NaN;
0106 end        
0107 %
0108 %************************************************************************************************************************************
0109 %
0110 iar = equilDKE.xrho*equilDKE.ap/equilDKE.Rp;%Circular inverse aspect ratio
0111 RRn = RR./RR_0;
0112 %
0113 %************************************************************************************************************************************
0114 %
0115 figure(1),clf
0116 %
0117 leg = {'LUKE'};
0118 xlim = [0,1];
0119 ylim = 10.^[-4,0];
0120 xlab = 'r/R_p';
0121 ylab = '\Gamma_R/\Gamma_R^{cyl}';
0122 tit = 'Electron bounce averaged runaway rate';
0123 siz = 20+14i;
0124 %
0125 graph1D_jd(iar,RRn,0,1,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0126 %
0127 set(gca,'xtick',[0:0.2:1])
0128 set(gca,'ytick',[1e-5 1e-4 1e-3 1e-2 1e-1 1])
0129 set(gca,'YMinorGrid','off')
0130 set(gca,'YMinorTick','on')
0131 %
0132 print_jd(p_opt,'fig_runaway_bounce','./figures',1)
0133 %
0134 %************************************************************************************************************************************
0135 %
0136 eval(['save ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);
0137 info_dke_yp(2,['Data saved in ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);
0138 
0139 
0140

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.