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 permission = test_permissions_yp;
0012 %
0013 if ~permission 
0014     disp('Please move the script to a local folder where you have write permission before to run it')
0015     return;
0016 end
0017 %
0018 % ***********************This part must be specified by the user, run make files if necessary) *****************************
0019 %
0020 id_simul = 'LH_karney_ripple';%Simulation ID
0021 path_simul = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0022 %
0023 psin_S = [];%Normalized poloidal flux grid where calculations are performed (0 < psin_S < 1) (If one value: local calculation only, not used if empty)
0024 rho_S = [0.25];%Normalized radial flux grid where calculations are performed (0 < rho_S < 1) (If one value: local calculation only, not used if empty)
0025 %
0026 id_path = '';%For all paths used by DKE solver
0027 path_path = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0028 %
0029 id_equil = 'TScirc';%For plasma equilibrium
0030 path_equil = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0031 %
0032 id_dkeparam = 'NONUNIFORM10010020';%For DKE code parameters
0033 path_dkeparam = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0034 %
0035 id_display = 'PARTIAL_VISUAL';%For output code display
0036 path_display = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0037 %
0038 id_ohm = '';%For Ohmic electric contribution
0039 path_ohm = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0040 %
0041 ids_wave = {''};%For RF waves contribution (put all the type of waves needed)
0042 paths_wave = {''};%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0043 %
0044 id_transpfaste = '';%For fast electron radial transport
0045 path_transpfaste = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0046 %
0047 id_ripple = 'TSspecific';%For fast electron magnetic ripple losses
0048 path_ripple = '';%if nothing is specified, the working directory is first used and then MatLab is looking in all the path
0049 %
0050 %************************************************************************************************************************************
0051 %************************************************************************************************************************************
0052 %************************************************************************************************************************************
0053 %
0054 [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);
0055 %
0056 %************************************************************************************************************************************
0057 %
0058 wavestruct.omega_lh = [4]*2*pi*1e9; %(GHz -> rad/s). Wave frequency [1,1] Indicative, no effect in small FLR limit opt_lh > 0
0059 %Option parameter for cross-comparison between old LH code:
0060 %    - (1): 1/vpar dependence
0061 %    - (2): no 1/vpar dependence and old grid technique for Dlh calculations (Karney, Shoucri) (see rfdiff_dke_jd)
0062 wavestruct.opt_lh = 2; % [1,1]
0063 %
0064 % Choose (vparmin_lh,vparmax_lh) or (Nparmin_lh,Nparmax_lh) for square n// LH wave power spectrum,
0065 % or (Npar_lh,dNpar_lh) for Gaussian shape
0066 %
0067 wavestruct.norm_ref = 1;%Normalization procedure for the LH quasilinear diffusion coefficient and spectrum boundaries
0068 %
0069 wavestruct.yvparmin_lh = [4];%LH wave square N// Spectrum: Lower limit of the plateau (vth_ref or vth) [1,n_scenario_lh]
0070 wavestruct.yvparmax_lh = [7];%LH wave square N// Spectrum: Upper limit of the plateau (vth_ref or vth) [1,n_scenario_lh]
0071 %
0072 wavestruct.yNparmin_lh = [NaN];%LH wave square N// Spectrum: Lower limit [1,n_scenario_lh]
0073 wavestruct.yNparmax_lh = [NaN];%LH wave square N// Spectrum: Upper limit [1,n_scenario_lh]
0074 wavestruct.yNpar_lh = [NaN];%LH wave Gaussian N// Spectrum: peak [1,n_scenario_lh]
0075 wavestruct.ydNpar_lh = [NaN];%LH wave Gaussian N// Spectrum: width [1,n_scenario_lh]
0076 %
0077 %   Note: this diffusion coefficient is different from the general QL D0. It has a benchmarking purpose only
0078 wavestruct.yD0_in_c_lh = [1];%Central LH QL diffusion coefficient (nhuth_ref*pth_ref^2 or nhuth*pth^2) [1,n_scenario_lh]
0079 %
0080 wavestruct.yD0_in_lh_prof = [0];%Quasilinear diffusion coefficient radial profile: (0) uniform, (1) gaussian radial profile [1,n_scenario_lh]
0081 wavestruct.ypeak_lh = [NaN];%Radial peak position of the LH quasi-linear diffusion coefficient (r/a on midplane) [1,n_scenario_lh]
0082 wavestruct.ywidth_lh = [NaN];%Radial width of the LH quasi-linear diffusion coefficient (r/a on midplane) [1,n_scenario_lh]
0083 %
0084 wavestruct.ythetab_lh = [0]*pi/180;%(deg -> rad). Poloidal location of LH beam [0..2pi] [1,n_scenario_lh]
0085 %               (0) from local values Te and ne, (1) from central values Te0 and ne0
0086 %
0087 %************************************************************************************************************************************
0088 %
0089 if exist('dmumpsmex');dkeparam.invproc = -2;end
0090 %
0091 dkeparam.boundary_mode_f = 1;%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)
0092 dkeparam.norm_mode_f = 0;%Local normalization of f0 at each iteration: (0) no, the default value when the numerical conservative scheme is correct, (1) yes
0093 dkeparam.tn = [50000,100000];% 2 time steps to tn=100000 best for asymptotic solution
0094 %
0095 dkeparam.np_S = 201;
0096 dkeparam.nmhu_S = 201;
0097 dkeparam.pnmax_S = 30;
0098 %
0099 dkeparam.psin_S = psin_S;
0100 dkeparam.rho_S = rho_S;
0101 %
0102 waves{1} = make_idealLHwave_jd(equil,wavestruct);
0103 %
0104 % case with no ripple
0105 %
0106 [Znorm_0,Zcurr_0,ZP0_0,dke_out_0] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,[],[],[]);
0107 if dke_out_0.residu_f{end}(end) <= dkeparam.prec0_f,
0108     j_0 = Zcurr_0.x_0;
0109     P_0 = ZP0_0.x_rf_fsav;
0110 else
0111     j_0 = NaN;
0112     P_0 = NaN;
0113 end
0114 %
0115 % case with ripple
0116 %
0117 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa] = main_dke_yp(id_simul,dkepath,equil,dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0118 if dke_out.residu_f{end}(end) <= dkeparam.prec0_f,
0119     j = Zcurr.x_0;
0120     P = ZP0.x_rf_fsav;
0121     MRRs = dke_out.xMRR_flux;
0122     MRRt = dke_out.xMRR_tau;
0123 else
0124     j = NaN;
0125     P = NaN;
0126     MRRs = NaN;
0127     MRRt = NaN;
0128 end
0129 %
0130 %
0131 %************************************************************************************************************************************
0132 %
0133 format
0134 %
0135 delete res_ripple
0136 %
0137 diary res_ripple
0138 %
0139 disp(['Ripple losses'])
0140 disp(['----------------------'])
0141 %
0142 disp(['Boundary losses : Gamma*tau_c = ',num2str(MRRs)]) 
0143 disp(['Volumic losses : Gamma*tau_c = ',num2str(MRRt)]) 
0144 %
0145 disp(['Case with ripple : j = ',num2str(j),' ; P = ',num2str(P),' ; j/P = ',num2str(j/P)]) 
0146 disp(['Case with no ripple : j = ',num2str(j_0),' ; P = ',num2str(P_0),' ; j/P = ',num2str(j_0/P_0)]) 
0147 %
0148 diary off
0149 %
0150 str = [path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat'];
0151 save(str);
0152 info_dke_yp(2,['Data saved in ',str]);
0153 %
0154 proc_luke_jd(load(str),1,2,0.1,20);
0155 %

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