0001
0002
0003
0004 clear all
0005 clear mex
0006 clear functions
0007 close all
0008 warning off
0009 global nfig
0010
0011 opt_proc = 0;
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
0021
0022 id_simul = 'LH_karney_transp_bounce_time';
0023 path_simul = '';
0024
0025 psin_S = [];
0026 rho_S = [0:0.025:0.65,0.7:0.1:1];
0027
0028 id_path = '';
0029 path_path = '';
0030
0031 id_equil = 'JETh77';
0032 path_equil = '';
0033
0034 id_dkeparam = 'NONUNIFORM10010020';
0035 path_dkeparam = '';
0036
0037 id_display = 'PARTIAL_VISUAL';
0038 path_display = '';
0039
0040 id_ohm = '';
0041 path_ohm = '';
0042
0043 ids_wave = {''};
0044 paths_wave = {''};
0045
0046 id_transpfaste = 'magneticturbulence';
0047 path_transpfaste = '';
0048
0049 id_ripple = '';
0050 path_ripple = '';
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 wavestruct.omega_lh = [4]*2*pi*1e9;
0061
0062
0063
0064 wavestruct.opt_lh = 2;
0065
0066
0067
0068
0069 wavestruct.norm_ref = 1;
0070
0071 wavestruct.yvparmin_lh = [4];
0072 wavestruct.yvparmax_lh = [7];
0073
0074 wavestruct.yNparmin_lh = [NaN];
0075 wavestruct.yNparmax_lh = [NaN];
0076 wavestruct.yNpar_lh = [NaN];
0077 wavestruct.ydNpar_lh = [NaN];
0078
0079
0080 wavestruct.yD0_in_c_lh = [2];
0081
0082 wavestruct.yD0_in_lh_prof = [1];
0083 wavestruct.ypeak_lh = [0.4];
0084 wavestruct.ywidth_lh = [0.1];
0085
0086 wavestruct.ythetab_lh = [0]*pi/180;
0087
0088
0089
0090
0091 if exist('dmumpsmex');dkeparam.invproc = -2;end
0092
0093 dkeparam.boundary_mode_f = 0;
0094 dkeparam.norm_mode_f = 1;
0095 dkeparam.dtn = 10;
0096 dkeparam.nit_f = 1;
0097
0098 dkeparam.psin_S = psin_S;
0099 dkeparam.rho_S = rho_S;
0100
0101 ntime_step = 10;
0102
0103 transpfaste.Dr0 = 0;
0104
0105
0106
0107 R_sep(1) = 3.0;
0108 a_sep(1) = 0.9;
0109 Z_sep(1) = 0.0;
0110
0111 xpoint(1,1) = 1.687;
0112 xpoint(2,1) = 0.466;
0113 xpoint(3,1) = 0;
0114 xpoint(4,1) = 0;
0115 xpoint(5,1) = 2.001;
0116 xpoint(6,1) = 0.568;
0117 xpoint(7,1) = 22.46;
0118 xpoint(8,1) = 67.92;
0119
0120 npsi(1) = 101;
0121 ntheta(1) = 65;
0122
0123 Ip(1) = 2;
0124
0125 qmin(1) = 1;
0126 eq(1) = 3;
0127 qopt(1) = 1;
0128
0129 Bt(1) = 3.5;
0130
0131
0132
0133 Zi(1,:) = [1,1,1,6];
0134 mi(1,:) = [1,2,3,12];
0135 fi(1,:) = [0,1,0];
0136
0137 Te0(1) = 5;
0138 Tea(1) = 0.5;
0139 eTe1(1) = 2;
0140 eTe2(1) = 2;
0141
0142 ne0(1) = 2.0e19;
0143 nea(1) = 2.0e17;
0144 ene1(1) = 2;
0145 ene2(1) = 0.5;
0146
0147 Ti0(1) = 2;
0148 Tia(1) = 0.2;
0149 eTi1(1) = 2;
0150 eTi2(1) = 2;
0151
0152 Zeff0(1) = 1.5;
0153 Zeffa(1) = 1.5;
0154 eZeff(1) = 0;
0155 xZeff(1) = 0.5;
0156
0157 [ppsin,ppsi_apRp,theta,x,y,Bx,By,BPHI,pBpp,pq_Rpap,pj,pmag,Ip_test] = idealequilcyl_yp(a_sep(1),R_sep(1),Z_sep(1),Bt(1),Ip(1),qmin(1)*R_sep(1)/a_sep(1),eq(1),qopt(1),npsi(1),ntheta(1));
0158
0159 [prho,pTe,pne,pzTi,pzni,zZi,zmi,fi,pkin] = idealprof_yp(Zi(1,:),mi(1,:),fi(1,:),Te0(1),Tea(1),eTe1(1),eTe2(1),ne0(1),nea(1),ene1(1),ene2(1),Ti0(1),Tia(1),eTi1(1),eTi2(1),Zeff0(1),Zeffa(1),eZeff(1),xZeff(1),npsi(1));
0160
0161 pj_min = min(pj);
0162 if pj_min < 0,pj = pj - pj_min;end,
0163 [equil_magnetic,prho_out,pspsin_out,pspsinT_out,pp_out] = equil_magnetic_helmex77_yp(a_sep(1),R_sep(1),Z_sep(1),xpoint(:,1),Bt(1),Ip(1),ppsi_apRp*R_sep(1)/a_sep(1),pj,pkin,ntheta(1),0);
0164
0165 equil_prof.pTe = pTe;
0166 equil_prof.pne = pne;
0167 equil_prof.pzTi = pzTi;
0168 equil_prof.pzni = pzni;
0169 equil_prof.zZi = zZi;
0170 equil_prof.zmi = zmi;
0171
0172 clear equil
0173
0174 equil{1} = conc_struct_jd(equil_magnetic,equil_prof);
0175 equil{1}.id = id_equil;
0176
0177 equilibrium_jd(equil{1},'',2,'linear',50);
0178 drawnow
0179
0180
0181
0182 waves{1} = make_idealLHwave_jd(equil{1},wavestruct);
0183
0184 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa] = main_dke_yp(id_simul,dkepath,equil{1},dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0185
0186 j_fe(:,1) = Zcurr.x_0;
0187 P_fe(:,1) = ZP0.x_rf_fsav;
0188 Itot_fe(1) = sum(Zcurr.x_0.*equilDKE.xdA_dke*mksa.j_ref);
0189 Ptot_2piRp_fe(1) = sum(ZP0.x_rf_fsav.'.*equilDKE.xdV_2piRp_dke*mksa.P_ref);
0190
0191 for it = 2:ntime_step,
0192 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa] = main_dke_yp(id_simul,dkepath,equil{1},dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,dke_out.Zf0_interp,[]);
0193
0194 j_fe(:,it) = Zcurr.x_0;
0195 P_fe(:,it) = ZP0.x_rf_fsav;
0196 Itot_fe(it) = sum(Zcurr.x_0.*equilDKE.xdA_dke*mksa.j_ref);
0197 Ptot_2piRp_fe(it) = sum(ZP0.x_rf_fsav.'.*equilDKE.xdV_2piRp_dke*mksa.P_ref);
0198 end
0199
0200
0201
0202 waves{1} = make_idealLHwave_jd(equil{1},wavestruct);
0203
0204 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa] = main_dke_yp(id_simul,dkepath,equil{1},dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,[],[]);
0205
0206 j_ve(:,1) = Zcurr.x_0;
0207 P_ve(:,1) = ZP0.x_rf_fsav;
0208 Itot_ve(1) = sum(Zcurr.x_0.*equilDKE.xdA_dke*mksa.j_ref);
0209 Ptot_2piRp_ve(1) = sum(ZP0.x_rf_fsav.'.*equilDKE.xdV_2piRp_dke*mksa.P_ref);
0210
0211
0212
0213 for it = 2:ntime_step,
0214 R_sep(it) = 3.0 - 1.5*(it/ntime_step);
0215 a_sep(it) = 0.9;
0216 Z_sep(it) = 0.0;
0217
0218 xpoint(1,it) = 1.687;
0219 xpoint(2,it) = 0.466;
0220 xpoint(3,it) = 0;
0221 xpoint(4,it) = 0;
0222 xpoint(5,it) = 2.001;
0223 xpoint(6,it) = 0.568 - 0.102*(it/ntime_step);
0224 xpoint(7,it) = 22.46 - 22.46*(it/ntime_step);
0225 xpoint(8,it) = 67.92 - 67.92*(it/ntime_step);
0226
0227 npsi(it) = 101;
0228 ntheta(it) = 65;
0229
0230 Ip(it) = 2;
0231
0232 qmin(it) = 1;
0233 eq(it) = 3;
0234 qopt(it) = 1;
0235
0236 Bt(it) = 3.5;
0237
0238
0239
0240 Zi(it,:) = [1,1,1,6];
0241 mi(it,:) = [1,2,3,12];
0242 fi(it,:) = [0,1,0];
0243
0244 Te0(it) = 5;
0245 Tea(it) = 0.5;
0246 eTe1(it) = 2;
0247 eTe2(it) = 2;
0248
0249 ne0(it) = 2.0e19;
0250 nea(it) = 2.0e17;
0251 ene1(it) = 2;
0252 ene2(it) = 0.5;
0253
0254 Ti0(it) = 2;
0255 Tia(it) = 0.2;
0256 eTi1(it) = 2;
0257 eTi2(it) = 2;
0258
0259 Zeff0(it) = 1.5;
0260 Zeffa(it) = 1.5;
0261 eZeff(it) = 0;
0262 xZeff(it) = 0.5;
0263
0264 [ppsin,ppsi_apRp,theta,x,y,Bx,By,BPHI,pBpp,pq_Rpap,pj,pmag,Ip_test] = idealequilcyl_yp(a_sep(it),R_sep(it),Z_sep(it),Bt(it),Ip(it),qmin(it)*R_sep(it)/a_sep(it),eq(it),qopt(it),npsi(it),ntheta(it));
0265
0266 [prho,pTe,pne,pzTi,pzni,zZi,zmi,fi,pkin] = idealprof_yp(Zi(it,:),mi(it,:),fi(it,:),Te0(it),Tea(it),eTe1(it),eTe2(it),ne0(it),nea(it),ene1(it),ene2(it),Ti0(it),Tia(it),eTi1(it),eTi2(it),Zeff0(it),Zeffa(it),eZeff(it),xZeff(it),npsi(it));
0267
0268 pj_min = min(pj);
0269 if pj_min < 0,pj = pj - pj_min;end,
0270 [equil_magnetic,prho_out,pspsin_out,pspsinT_out,pp_out] = equil_magnetic_helmex77_yp(a_sep(it),R_sep(it),Z_sep(it),xpoint(:,it),Bt(it),Ip(it),ppsi_apRp*R_sep(it)/a_sep(it),pj,pkin,ntheta(it),0);
0271
0272 equil_prof.pTe = pTe;
0273 equil_prof.pne = pne;
0274 equil_prof.pzTi = pzTi;
0275 equil_prof.pzni = pzni;
0276 equil_prof.zZi = zZi;
0277 equil_prof.zmi = zmi;
0278
0279 equil{it} = conc_struct_jd(equil_magnetic,equil_prof);
0280 equil{it}.id = id_equil;
0281
0282 equilibrium_jd(equil{it},'',2,'linear',50);
0283 drawnow
0284
0285 waves{1} = make_idealLHwave_jd(equil{it},wavestruct);
0286
0287 [Znorm,Zcurr,ZP0,dke_out,radialDKE,equilDKE,momentumDKE,gridDKE,Zmomcoef,Zbouncecoef,Zmripple,mksa] = main_dke_yp(id_simul,dkepath,equil{it},dkeparam,dkedisplay,ohm,waves,transpfaste,ripple,dke_out.Zf0_interp,[]);
0288
0289 j_ve(:,it) = Zcurr.x_0*mksa.j_ref;
0290 P_ve(:,it) = ZP0.x_rf_fsav*mksa.P_ref;
0291 Itot_ve(it) = sum(Zcurr.x_0.*equilDKE.xdA_dke*mksa.j_ref);
0292 Ptot_2piRp_ve(it) = sum(ZP0.x_rf_fsav.'.*equilDKE.xdV_2piRp_dke*mksa.P_ref);
0293 end
0294
0295 Eta_fe = equilDKE.xne(1)*Itot_fe./Ptot_2piRp_fe/(2*pi)/1e19;
0296 Eta_ve = equilDKE.xne(1)*Itot_ve./Ptot_2piRp_fe/(2*pi)/1e19;
0297
0298 strcolor = ['b','g','r','c','m','y','k'];
0299 figure(1000),
0300 for it = 1:ntime_step,
0301 graph1D_jd(equilDKE.xrho,j_fe(:,it),0,0,'\rho','Current density (MA.m-2)','Fixed plasma shape',NaN,'','','-','none',strcolor(rem(it,length(strcolor))+1),2);
0302 end
0303
0304 figure(1001),
0305 for it = 1:ntime_step,
0306 graph1D_jd(equilDKE.xrho,j_ve(:,it),0,0,'\rho','Current density (MA.m-2)','Time evolving plasma shape',NaN,'','','-','none',strcolor(rem(it,length(strcolor))+1),2);
0307 end
0308
0309 figure(1002),
0310 graph1D_jd([1:ntime_step]*dkeparam.dtn,abs(Itot_fe),0,0,'t*\nu','Current (MA)','JETh77 @ t = 0',NaN,'','','-','none','b',2);
0311 graph1D_jd([1:ntime_step]*dkeparam.dtn,abs(Itot_ve),0,0,'t*\nu','Current (MA)','JETh77 @ t = 0',NaN,[1,ntime_step]*dkeparam.dtn,'','--','none','r',2);
0312 legend('Fixed','Evolving')
0313
0314 figure(1003),
0315 graph1D_jd([1:ntime_step]*dkeparam.dtn,abs(Ptot_2piRp_fe),0,0,'t*\nu','Power (MW)','JETh77 @ t = 0',NaN,'','','-','none','b',2);
0316 graph1D_jd([1:ntime_step]*dkeparam.dtn,abs(Ptot_2piRp_ve),0,0,'t*\nu','Power (MW)','JETh77 @ t = 0',NaN,[1,ntime_step]*dkeparam.dtn,'','--','none','r',2);
0317 legend('Fixed','Evolving')
0318
0319 figure(1004),
0320 graph1D_jd([1:ntime_step]*dkeparam.dtn,Eta_fe,0,0,'t*\nu','\eta (A/W/m2)','JETh77 @ t = 0',NaN,'','','-','none','b',2);
0321 graph1D_jd([1:ntime_step]*dkeparam.dtn,Eta_ve,0,0,'t*\nu','\eta (A/W/m2)','JETh77 @ t = 0',NaN,[1,ntime_step]*dkeparam.dtn,'','--','none','r',2);
0322 legend('Fixed','Evolving')
0323
0324
0325
0326 eval(['save ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);
0327 info_dke_yp(2,['Data saved in ',path_simul,'DKE_RESULTS_',id_equil,'_',id_simul,'.mat']);