rundke_res

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 in $HOME/Database directory if necessary *****************************
0021 %
0022 id_simul = 'Thermal_res';%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_display = 'NO_DISPLAY';%For output code display
0035 path_display = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0036 %
0037 id_ohm = '';%For Ohmic electric contribution
0038 path_ohm = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0039 %
0040 ids_wave = {''};%For RF waves contribution (put all the type of waves needed)
0041 paths_wave = {''};%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0042 %
0043 id_transpfaste = '';%For fast electron radial transport
0044 path_transpfaste = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0045 %
0046 id_ripple = '';%For fast electron magnetic ripple losses
0047 path_ripple = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0048 %
0049 %************************************************************************************************************************************
0050 %************************************************************************************************************************************
0051 %************************************************************************************************************************************
0052 %
0053 [dkepath,equil,dkedisplay,ohm,waves,transpfaste,ripple] = load_structures_yp('dkepath',id_path,path_path,'equil',id_equil,path_equil,'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);
0054 %
0055 %************************************************************************************************************************************
0056 %
0057 if exist('dmumpsmex'),
0058     invproc = -2;% MUMPSMEX
0059 else
0060     invproc = 1;
0061 end
0062 %
0063 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)
0064 coll_mode = 2;%Relativistic collision operator: (0) Relativistic Maxwellian background, (1) High-velocity limit, (2) Linearized Belaiev-Budker (3) Non-relativistic Lorentz model, (4) Non-relativistic Maxwellian background
0065 %
0066 tnmax = 100000;%asymptotic time
0067 dtn_list = [1000,10000,100000];%time steps
0068 %
0069 pzTi = equil.pzTi;
0070 %
0071 % Case Ti=Te, uniform grid
0072 %
0073 id_dkeparam = 'UNIFORM10010020';%For DKE code parameters
0074 path_dkeparam = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0075 %
0076 [dkeparam] = load_structures_yp('dkeparam',id_dkeparam,path_dkeparam);
0077 %
0078 dkeparam.boundary_mode_f = boundary_mode_f;
0079 dkeparam.coll_mode = coll_mode;
0080 dkeparam.invproc = invproc;
0081 %
0082 dkeparam.prec0_f = 0;
0083 dkeparam.tn = tnmax;
0084 %
0085 dkeparam.psin_S = psin_S;
0086 dkeparam.rho_S = rho_S;
0087 %
0088 ndtn = length(dtn_list);
0089 %
0090 normf0_u_1 = cell(1,ndtn);
0091 normf0_u_2 = cell(1,ndtn);
0092 normf0_nu_1 = cell(1,ndtn);
0093 normf0_nu_2 = cell(1,ndtn);
0094 %
0095 residue_u_1 = cell(1,ndtn);
0096 residue_u_2 = cell(1,ndtn);
0097 residue_nu_1 = cell(1,ndtn);
0098 residue_nu_2 = cell(1,ndtn);
0099 %
0100 for idtn = 1:length(dtn_list);
0101     %
0102     dtn = dtn_list(idtn);
0103     dkeparam.dtn = dtn;
0104     %
0105     [dummy,dummy,dummy,dke_out] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0106     %
0107     normf0_u_1{idtn} = dke_out.normf0{end};
0108     residue_u_1{idtn} = dke_out.residu_f{end};
0109 end
0110 %
0111 % Case Ti=Te/2, uniform grid
0112 %
0113 equil.pzTi = pzTi/2;
0114 %
0115 for idtn = 1:length(dtn_list);
0116     %
0117     dtn = dtn_list(idtn);
0118     dkeparam.dtn = dtn;
0119     %
0120     [dummy,dummy,dummy,dke_out] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0121     %
0122     normf0_u_2{idtn} = dke_out.normf0{end};
0123     residue_u_2{idtn} = dke_out.residu_f{end};
0124 end
0125 %
0126 % Case Ti=Te, non-uniform grid
0127 %
0128 id_dkeparam = 'NONUNIFORM10010020';%For DKE code parameters
0129 path_dkeparam = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0130 %
0131 [dkeparam] = load_structures_yp('dkeparam',id_dkeparam,path_dkeparam);
0132 %
0133 dkeparam.boundary_mode_f = boundary_mode_f;
0134 dkeparam.coll_mode = coll_mode;
0135 dkeparam.invproc = invproc;
0136 %
0137 dkeparam.prec0_f = 0;
0138 dkeparam.tn = tnmax;
0139 %
0140 dkeparam.psin_S = psin_S;
0141 dkeparam.rho_S = rho_S;
0142 %
0143 equil.pzTi = pzTi;
0144 %
0145 for idtn = 1:length(dtn_list);
0146     %
0147     dtn = dtn_list(idtn);
0148     dkeparam.dtn = dtn;
0149     %
0150     [dummy,dummy,dummy,dke_out] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0151     %
0152     normf0_nu_1{idtn} = dke_out.normf0{end};
0153     residue_nu_1{idtn} = dke_out.residu_f{end};
0154 end
0155 %
0156 % Case Ti=Te/2, non-uniform grid
0157 %
0158 equil.pzTi = pzTi/2;
0159 %
0160 for idtn = 1:length(dtn_list);
0161     %
0162     dtn = dtn_list(idtn);
0163     dkeparam.dtn = dtn;
0164     %
0165     [dummy,dummy,dummy,dke_out] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0166     %
0167     normf0_nu_2{idtn} = dke_out.normf0{end};
0168     residue_nu_2{idtn} = dke_out.residu_f{end};
0169 end
0170 %
0171 % density conservation
0172 %
0173 figure(1),clf
0174 %
0175 leg = {'\Deltat/\tau_c = 1000','\Deltat/\tau_c = 10000','\Deltat/\tau_c = 100000','Location','SouthWest'};
0176 xlim = [0,dkeparam.nit_f];
0177 ylim = [-4,4]*1e-8;
0178 xlab = 'iteration #';
0179 ylab = '\Deltan/n_0';
0180 tit = '';
0181 colors = {'r','b','g'};
0182 siz = 20+14i;
0183 %
0184 for idtn = 1:length(dtn_list)-1;
0185     graph1D_jd(0:length(normf0_u_1{idtn}),[0,normf0_u_1{idtn}-1],0,0,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0186 end
0187 graph1D_jd(0:length(normf0_u_1{end}),[0,normf0_u_1{end}-1],0,0,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0188 %
0189 set(gca,'xtick',[0:0.2:1]*tnmax)
0190 set(gca,'ytick',[-4:2:4]*1e-8)
0191 %
0192 figure(2),clf
0193 %
0194 ylim = [-4,4]*1e-3;
0195 %
0196 for idtn = 1:length(dtn_list)-1;
0197     graph1D_jd(0:length(normf0_u_2{idtn}),[0,normf0_u_2{idtn}-1],0,0,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0198 end
0199 graph1D_jd(0:length(normf0_u_2{end}),[0,normf0_u_2{end}-1],0,0,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0200 %
0201 set(gca,'xtick',[0:0.2:1]*tnmax)
0202 set(gca,'ytick',[-4:2:4]*1e-3)
0203 %
0204 figure(3),clf
0205 %
0206 ylim = [-4,4]*1e-8;
0207 %
0208 for idtn = 1:length(dtn_list)-1;
0209     graph1D_jd(0:length(normf0_nu_1{idtn}),[0,normf0_nu_1{idtn}-1],0,0,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0210 end
0211 graph1D_jd(0:length(normf0_nu_1{end}),[0,normf0_nu_1{end}-1],0,0,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0212 %
0213 set(gca,'xtick',[0:0.2:1]*tnmax)
0214 set(gca,'ytick',[-4:2:4]*1e-8)
0215 %
0216 figure(4),clf
0217 %
0218 ylim = [-4,4]*1e-3;
0219 %
0220 for idtn = 1:length(dtn_list)-1;
0221     graph1D_jd(0:length(normf0_nu_2{idtn}),[0,normf0_nu_2{idtn}-1],0,0,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0222 end
0223 graph1D_jd(0:length(normf0_nu_2{end}),[0,normf0_nu_2{end}-1],0,0,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0224 %
0225 set(gca,'xtick',[0:0.2:1]*tnmax)
0226 set(gca,'ytick',[-4:2:4]*1e-3)
0227 %
0228 % residue
0229 %
0230 figure(5),clf
0231 %
0232 ylim = 10.^[-24,-6];
0233 ytick = 10.^[-24:4:-6];
0234 ylab = 'convergence parameter';
0235 %
0236 for idtn = 1:length(dtn_list)-1;
0237     graph1D_jd(1:length(residue_u_1{idtn}),residue_u_1{idtn},0,1,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0238 end
0239 graph1D_jd(1:length(residue_u_1{end}),residue_u_1{end},0,1,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0240 %
0241 set(gca,'xtick',[0:0.2:1]*tnmax)
0242 set(gca,'ytick',ytick)
0243 %
0244 figure(6),clf
0245 %
0246 for idtn = 1:length(dtn_list)-1;
0247     graph1D_jd(1:length(residue_u_2{idtn}),residue_u_2{idtn},0,1,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0248 end
0249 graph1D_jd(1:length(residue_u_2{end}),residue_u_2{end},0,1,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0250 %
0251 set(gca,'xtick',[0:0.2:1]*tnmax)
0252 set(gca,'ytick',ytick)
0253 %
0254 figure(7),clf
0255 %
0256 for idtn = 1:length(dtn_list)-1;
0257     graph1D_jd(1:length(residue_nu_1{idtn}),residue_nu_1{idtn},0,1,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0258 end
0259 graph1D_jd(1:length(residue_nu_1{end}),residue_nu_1{end},0,1,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0260 %
0261 set(gca,'xtick',[0:0.2:1]*tnmax)
0262 set(gca,'ytick',ytick)
0263 %
0264 figure(8),clf
0265 %
0266 for idtn = 1:length(dtn_list)-1;
0267     graph1D_jd(1:length(residue_nu_2{idtn}),residue_nu_2{idtn},0,1,'','','',NaN,xlim,ylim,'-','none',colors{idtn},2,siz,gca);
0268 end
0269 graph1D_jd(1:length(residue_nu_2{end}),residue_nu_2{end},0,1,xlab,ylab,tit,leg,xlim,ylim,'-','none',colors{end},2,siz,gca,0.9,0.7,0.7);
0270 %
0271 set(gca,'xtick',[0:0.2:1]*tnmax)
0272 set(gca,'ytick',ytick)
0273 %
0274 print_jd(p_opt,'fig_thermal_res_TiTe_u','./figures',1)
0275 print_jd(p_opt,'fig_thermal_res_TiTe2_u','./figures',2)
0276 print_jd(p_opt,'fig_thermal_res_TiTe_nu','./figures',3)
0277 print_jd(p_opt,'fig_thermal_res_TiTe2_nu','./figures',4)
0278 %
0279 print_jd(p_opt,'fig_thermal_res_TiTe_u_res','./figures',5)
0280 print_jd(p_opt,'fig_thermal_res_TiTe2_u_res','./figures',6)
0281 print_jd(p_opt,'fig_thermal_res_TiTe_nu_res','./figures',7)
0282 print_jd(p_opt,'fig_thermal_res_TiTe2_nu_res','./figures',8)
0283 %
0284 %************************************************************************************************************************************
0285 %
0286 eval(['save ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);
0287 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.