load_tprof_tsbase_yp

PURPOSE ^

SYNOPSIS ^

function [flag,ap,Rp,Zp,Bt,Ip,qmin,eq,qopt,Zi,mi,fi,Te0,Tea,eTe1,eTe2,ne0,nea,ene1,ene2,Ti0,Tia,eTi1,eTi2,Zeff0,Zeffa,eZeff,xZeff,Vloop] = load_tprof_tsbase_yp(shotnum,certif,shotime,tmin,tmax,basestr);

DESCRIPTION ^

   Load processed experimental data (tprof treatment) of the tokamak Tore Supra for building a magnetic equilibrium with HELENA code (mex file version)

   by Y. Peysson (CEA/DSM/IRFM,yves.peysson@cea.fr) and J. Decker (CEA/DSM/IRFM,joan.decker@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function  [flag,ap,Rp,Zp,Bt,Ip,qmin,eq,qopt,Zi,mi,fi,Te0,Tea,eTe1,eTe2,ne0,nea,ene1,ene2,Ti0,Tia,eTi1,eTi2,Zeff0,Zeffa,eZeff,xZeff,Vloop] = load_tprof_tsbase_yp(shotnum,certif,shotime,tmin,tmax,basestr);
0002 %
0003 %   Load processed experimental data (tprof treatment) of the tokamak Tore Supra for building a magnetic equilibrium with HELENA code (mex file version)
0004 %
0005 %   by Y. Peysson (CEA/DSM/IRFM,yves.peysson@cea.fr) and J. Decker (CEA/DSM/IRFM,joan.decker@cea.fr)
0006 %
0007 method = 'spline';
0008 flag = 1;
0009 %
0010 if strcmp(basestr,'TS'),
0011     %
0012     shotnum = str2num(shotnum) + certif/10;  
0013     %
0014     [tprof.ap,tprof.t] = tsbase(shotnum,'SPROFAMIN');%Plasma minor radius (m)
0015     [tprof.Rp,tprof.t] = tsbase(shotnum,'SPROFRMAJ');%Plasma major radius (m)
0016     [tprof.Zp,tprof.t] = tsbase(shotnum,'SPROFZPOS');%Plasma vertical position (m)
0017     %
0018     [tprof.Bt,tprof.t] = tsbase(shotnum,'SPROFBTOR');%Toroidal magnetic field (T)
0019     [tprof.Ip,tprof.t] = tsbase(shotnum,'SPROFIP');%Plasma current (MA)
0020     [tprof.qpsi,tprof.t] = tsbase(shotnum,'GPROFQ');%safety factor qpsi profile
0021     %
0022     [tprof.vloop,tprof.t] = tsbase(shotnum,'SPROFVS');%Loop voltage (V)
0023     [tprof.Zeff,tprof.t] = tsbase(shotnum,'SPROFZEFF');%Effective charge
0024     [tprof.Zmain] = tsbase(shotnum,'SPROFZMAIN');%Charges of the main ions
0025     [tprof.Mmain] = tsbase(shotnum,'SPROFMMAIN');%Atomic masses of the main ions (uma)
0026     [tprof.Cmain] = tsbase(shotnum,'SPROFCMAIN');%Concentrations of the main ions
0027     [tprof.Zimp] = tsbase(shotnum,'SPROFZIMP');%Charges of the impurities
0028     [tprof.Mimp] = tsbase(shotnum,'SPROFMIMP');%Atomic masses of impurities (uma)
0029     %
0030     [tprof.Te,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFTEFIT');%ELectron temperature (keV)
0031     [tprof.ne,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFNEFIT');%ELectron density profile (m-3)
0032     [tprof.Ti,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFTIFIT_');%Ion temperature profile (keV)
0033     [tprof.ni,tprof.t,tprof.rho] = tsbase(shotnum,'GPROFNIFIT');%Ion density profile (m-3)
0034     %
0035     if isempty(tprof.ap) | isempty(tprof.Rp) |isempty(tprof.Zp) |isempty(tprof.Bt) |isempty(tprof.Ip) |isempty(tprof.qpsi) |isempty(tprof.vloop) | isempty(tprof.Zeff) | isempty(tprof.Zmain) | isempty(tprof.Mmain) | isempty(tprof.Cmain) | isempty(tprof.Zimp) | isempty(tprof.Mimp) | isempty(tprof.Te) | isempty(tprof.ne) | isempty(tprof.ni),
0036         ap = [];
0037         Rp = [];
0038         Zp = [];
0039         Bt = [];
0040         Ip = [];
0041         qmin = [];
0042         eq = [];
0043         qopt = [];
0044         Zi = [];
0045         mi = [];
0046         fi = [];    
0047         Te0 = [];
0048         Tea = [];
0049         eTe1 = [];
0050         eTe2 = [];
0051         ne0 = [];
0052         nea = [];
0053         ene1 = [];
0054         ene2 = [];
0055         Ti0 = [];
0056         Tia = [];
0057         eTi1 = [];
0058         eTi2 = [];
0059         Zeff0 = [];
0060         Zeffa = [];
0061         eZeff = [];
0062         xZeff = [];
0063         Vloop = [];
0064         LH_out = [];
0065         EC_out = [];
0066         flag = 0;
0067         return
0068     end
0069     %
0070     if isempty(tprof.Ti),
0071         tprof.Ti = tprof.Te/2;%Rather good approximation for Tore SUpra
0072     end
0073     %
0074     % Build data for C3PO/LUKE
0075     %
0076     % Time interpolation (at the time slice shotime)
0077     %
0078     ap = interp_tprof_time_fxdrg(tprof.t,tprof.ap,shotime,method);%Time interpolation
0079     Rp = interp_tprof_time_fxdrg(tprof.t,tprof.Rp,shotime,method);%Time interpolation
0080     Zp = interp_tprof_time_fxdrg(tprof.t,tprof.Zp,shotime,method);%Time interpolation
0081     %
0082     Bt = interp_tprof_time_fxdrg(tprof.t,tprof.Bt,shotime,method);%Time interpolation
0083     Ip = interp_tprof_time_fxdrg(tprof.t,tprof.Ip,shotime,method);%Time interpolation
0084     qpsi = interp_tprof_time_fxdrg(tprof.t,tprof.qpsi,shotime,method);%Time interpolation
0085     %
0086     % Time averaging between tmin and tmax
0087     %
0088     Te_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.Te,tmin,method);%Time interpolation
0089     Te_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.Te,tmax,method);%Time interpolation
0090     ne_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.ne,tmin,method);%Time interpolation
0091     ne_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.ne,tmax,method);%Time interpolation
0092     Ti_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.Ti,tmin,method);%Time interpolation
0093     Ti_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.Ti,tmax,method);%Time interpolation
0094     ni_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.ni,tmin,method);%Time interpolation
0095     ni_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.ni,tmax,method);%Time interpolation
0096     %
0097     vloop_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.vloop,tmin,method);%Time interpolation
0098     vloop_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.vloop,tmax,method);%Time interpolation
0099     Zeff_tmin = interp_tprof_time_fxdrg(tprof.t,tprof.Zeff,tmin,method);%Time interpolation
0100     Zeff_tmax = interp_tprof_time_fxdrg(tprof.t,tprof.Zeff,tmax,method);%Time interpolation
0101     %
0102     dt = [tmin;tprof.t(find((tprof.t > tmin).*(tprof.t < tmax)));tmax];
0103     %
0104     Te = mean([Te_tmin;tprof.Te(find((tprof.t > tmin).*(tprof.t < tmax)),:);Te_tmax]);%Mean value
0105     ne = mean([ne_tmin;tprof.ne(find((tprof.t > tmin).*(tprof.t < tmax)),:);ne_tmax]);%Mean value
0106     Ti = mean([Ti_tmin;tprof.Ti(find((tprof.t > tmin).*(tprof.t < tmax)),:);Ti_tmax]);%Mean value
0107     ni = mean([ni_tmin;tprof.ni(find((tprof.t > tmin).*(tprof.t < tmax)),:);ni_tmax]);%Mean value
0108     %
0109     Vloop = mean([vloop_tmin;tprof.vloop(find((tprof.t > tmin).*(tprof.t < tmax)),:);vloop_tmax]);%Mean value
0110     Zeff = mean([Zeff_tmin;tprof.Zeff(find((tprof.t > tmin).*(tprof.t < tmax)),:);Zeff_tmax]);%Mean value
0111     %
0112     % Fit
0113     %
0114     [qmin,qmax,eq,qopt,chi2_q] = fit_qprofile_fxdrg(tprof.rho,qpsi);%Fit q-profile
0115     [Te0,Tea,eTe1,eTe2,chi2_Te] = fit_profile_fxdrg(tprof.rho,Te,1,[2,2]);%Fit Te profile
0116     [ne0,nea,ene1,ene2,chi2_ne] = fit_profile_fxdrg(tprof.rho,ne,1,[2,2]);%Fit ne profile
0117     [Ti0,Tia,eTi1,eTi2,chi2_Ti] = fit_profile_fxdrg(tprof.rho,Ti,1,[2,2]);%Fit Ti profile
0118     [ni0,nia,eni1,eni2,chi2_ni] = fit_profile_fxdrg(tprof.rho,ni,1,[2,2]);%Fit ni profile
0119     %
0120     % Atomic data
0121     %
0122     [sZmain,iZmain] = sort(tprof.Zmain);%Z ascending order sorting
0123     [sZimp,iZimp] = sort(tprof.Zimp);%Z ascending order sorting
0124     sMmain = tprof.Mmain(iZmain);
0125     sCmain = tprof.Mmain(iZmain);
0126     sMimp = tprof.Mimp(iZimp);
0127     %
0128     isZmain1 = find(sZmain == 1);%Identify Hydrogen isotopes
0129     isZmain2 = find(sZmain > 1);%Identify other main ions (like Helium)
0130     [ssZmain1,isZmain1] = sort(sZmain(isZmain1));%ascending order sorting
0131     [ssZmain2,isZmain2] = sort(sZmain(isZmain2));%ascending order sorting
0132     %
0133     % No tritium in Tore Supra
0134     %
0135     if isempty(isZmain1),%Helium,...
0136         Zi = [1,1;1;sZmain;sZimp]';%  Ion types: (1) H/D/T, (2) He, ..., (6) C [1,p] (WARNING: Zi must be [1,1,1,imp1,imp2] for hydrogen plasmas)
0137         mi = [1;2;3;sMmain;tprof.Mimp(iZimp)]';%  Ion mass (uma) [1,p] (WARNING: Zi must be [1,2,3,mimp1,mimp2] for hydrogen plasmas)
0138         fi = [0;0;0]';%  Hydrogen isotopic fraction (H/D/T) [1,3] (WARNING: only used when hydrogen plasmas are considered)
0139     else,%Hydrogen isotopes exist in the plasma
0140         if length(isZmain1) == 1,%One type of main ion
0141             Zi = [1;1;1;sZmain(isZmain2);sZimp]';%  Ion types: (1) H/D/T, (2) He, ..., (6) C [1,p] (WARNING: Zi must be [1,1,1,imp1,imp2] for hydrogen plasmas)
0142             mi = [1;2;3;tprof.Mmain(isZmain2);tprof.Mimp(iZimp)]';%  Ion mass (uma) [1,p] (WARNING: Zi must be [1,2,3,mimp1,mimp2] for hydrogen plasmas)
0143             %
0144             if tprof.Mmain(isZmain1) == 1,%hydrogen
0145                 fi = [1;0;0]';%  Hydrogen isotopic fraction (H/D/T) [1,3] (WARNING: only used when hydrogen plasmas are considered)
0146             elseif tprof.Mmain(isZmain1) == 2,%hydrogen,%Deuterium
0147                 fi = [0;1;0]';%  Hydrogen isotopic fraction (H/D/T) [1,3] (WARNING: only used when hydrogen plasmas are considered)
0148             end
0149         else,%two types of main ion (max)
0150             Zi = [sZmain(isZmain1);1;sZmain(isZmain2);sZimp]';%  Ion types: (1) H/D/T, (2) He, ..., (6) C [1,p] (WARNING: Zi must be [1,1,1,imp1,imp2] for hydrogen plasmas)
0151             mi = [tprof.Mmain(isZmain1);3;tprof.Mmain(isZmain2);tprof.Mimp(iZimp)]';%  Ion mass (uma) [1,p] (WARNING: Zi must be [1,2,3,mimp1,mimp2] for hydrogen plasmas)
0152             fi = [tprof.Cmain(isZmain1);0]';%  Hydrogen isotopic fraction (H/D/T) [1,3] (WARNING: only used when hydrogen plasmas are considered)
0153             fi(2) = 1 - fi(1);
0154         end
0155     end
0156     %
0157     % Flat Zeff profile for Tore Supra
0158     %
0159     Zeff0 = Zeff;
0160     Zeffa = Zeff;
0161     eZeff = 0;
0162     xZeff = NaN;
0163 else
0164     disp('Not yet implemented for this machine.')
0165     return
0166 end
0167

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