rundke_conv

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_conv';%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 = [0.5];%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 = 'TScyl';%For plasma equilibrium
0032 path_equil = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0033 %
0034 id_dkeparam = 'UNIFORM10010020';%For DKE code parameters
0035 path_dkeparam = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0036 %
0037 id_display = 'NO_DISPLAY';%For output code display
0038 path_display = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0039 %
0040 id_ohm = '';%For Ohmic electric contribution
0041 path_ohm = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0042 %
0043 ids_wave = {''};%For RF waves contribution (put all the type of waves needed)
0044 paths_wave = {''};%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0045 %
0046 id_transpfaste = '';%For fast electron radial transport
0047 path_transpfaste = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0048 %
0049 id_ripple = '';%For fast electron magnetic ripple losses
0050 path_ripple = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0051 %
0052 %************************************************************************************************************************************
0053 %************************************************************************************************************************************
0054 %************************************************************************************************************************************
0055 %
0056 [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);
0057 %
0058 %************************************************************************************************************************************
0059 %
0060 if exist('dmumpsmex','file');dkeparam.invproc = -2;end
0061 %
0062 betath = 0.001;%validated for NR limit
0063 %
0064 [qe,me,mp,mn,e0,mu0,re,mc2] = pc_dke_yp;%Universal physics constants
0065 %
0066 equil.pTe = betath^2*mc2*ones(size(equil.pTe));
0067 equil.pzTi = 1e-10*ones(size(equil.pzTi));
0068 %
0069 dkeparam.boundary_mode_f = 0;%Enforcing the Maxwellian initial value at the first "boundary_mode_f" grid points
0070 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
0071 dkeparam.coll_mode = 2;% Linearized Belaiev-Budker
0072 %
0073 dkeparam.psin_S = psin_S;
0074 dkeparam.rho_S = rho_S;
0075 %
0076 epsi = 0.04;%corresponds to pc/pT = 5
0077 %
0078 ohm = ohm_flat(equil,epsi);
0079 %
0080 % Building the distribution function to a quasi steady-state for the
0081 % runaway problem : tn = 10000
0082 %
0083 nit_f = 500;%number of Legendre iterations
0084 dtn = 100000;%single time step for Legendre convergence studies
0085 %
0086 dkeparam.tn = 100000;%time for asymptotic solution with norm_mode_f = 1
0087 dkeparam.dtn = dtn;
0088 dkeparam.nit_f = nit_f;
0089 dkeparam.prec0_f = -1;%to reach end of Legendre iterations
0090 %
0091 [dummy,dummy,dummy,dke_out] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0092 %
0093 xRRs = dke_out.XxRR_fsav(end,:);
0094 xRRv = NaN(1,nit_f);
0095 for it=1:nit_f,
0096     xRRv(it) = (dke_out.normf0{end}(1) - dke_out.normf0{end}(it+1))/dtn;    
0097 end
0098 dcurr = abs(dke_out.curr0{end} - dke_out.curr0{end}(end))/dke_out.curr0{end}(end);
0099 dnorm = abs(dke_out.normf0{end} - dke_out.normf0{end}(end))/dke_out.normf0{end}(end);
0100 %
0101 %************************************************************************************************************************************
0102 %
0103 %
0104 figure(1),clf
0105 %
0106 leg = {'Volumic losses','Boundary losses'};
0107 xlim = [0,nit_f];
0108 ylim = [0,5]*1e-6;
0109 xlab = '# iterations';
0110 ylab = '\Gamma_R';
0111 tit = '';
0112 siz = 20+14i;
0113 %
0114 graph1D_jd(1:nit_f,xRRv,0,0,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0115 graph1D_jd(xlim,[xRRs,xRRs],0,0,'','','',leg,xlim,ylim,'--','none','b',2,siz,gca);
0116 %
0117 set(gca,'ytick',[0:5]*1e-6)
0118 %
0119 figure(2),clf
0120 %
0121 ylim = 10.^[-24,-8];
0122 ylab = 'R_f';
0123 %
0124 graph1D_jd(1:nit_f,dke_out.residu_f{end},0,1,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0125 %
0126 set(gca,'xtick',[0:0.2:1]*xlim(2))
0127 set(gca,'ytick',[1e-24 1e-20 1e-16 1e-12 1e-8])
0128 set(gca,'YMinorGrid','off')
0129 set(gca,'YMinorTick','on')
0130 %
0131 figure(3),clf
0132 %
0133 ylim = 10.^[-20,0];
0134 ylab = '(j-j_f)/j_f';
0135 %
0136 graph1D_jd(0:nit_f,dcurr,0,1,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0137 %
0138 set(gca,'xtick',[0:0.2:1]*xlim(2))
0139 set(gca,'ytick',[1e-20 1e-15 1e-10 1e-5 1])
0140 set(gca,'YMinorGrid','off')
0141 set(gca,'YMinorTick','on')
0142 %
0143 figure(4),clf
0144 %
0145 ylim = 10.^[-20,0];
0146 ylab = '(n-n_f)/n_f';
0147 %
0148 graph1D_jd(0:nit_f,dnorm,0,1,xlab,ylab,tit,NaN,xlim,ylim,'-','none','r',2,siz,gca,0.9,0.7,0.7);
0149 %
0150 set(gca,'xtick',[0:0.2:1]*xlim(2))
0151 set(gca,'ytick',[1e-20 1e-15 1e-10 1e-5 1])
0152 set(gca,'YMinorGrid','off')
0153 set(gca,'YMinorTick','on')
0154 %
0155 % print_jd(2,'fig_j_conv','.',1)
0156 % print_jd(2,'fig_Rf_conv','.',2)
0157 % print_jd(2,'fig_jn_conv','.',3)
0158 % print_jd(2,'fig_nn_conv','.',4)
0159 %
0160 print_jd(2,'fig_runaway_RR_conv_ss','./figures',1)
0161 print_jd(2,'fig_runaway_Rf_conv_ss','./figures',2)
0162 print_jd(2,'fig_runaway_jn_conv_ss','./figures',3)
0163 print_jd(2,'fig_runaway_nn_conv_ss','./figures',4)
0164 %
0165 %************************************************************************************************************************************
0166 %
0167 eval(['save ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);
0168 info_dke_yp(2,['Data saved in ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);

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