0001 function [] = test_equilconsistency_yp(filein,equilformat)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 close all
0018
0019 if nargin <= 0,
0020 filein = input_dke_yp('Enter the file name (with extension) of the toroidal MHD equilibrium','');
0021 end
0022
0023 if nargin <= 1,
0024 equilformat = input_dke_yp('Enter the file format of the toroidal MHD equilibrium ','LUKE, EQDSK, EFIT, ACCOME,...');
0025 end
0026
0027 [filepath,filename,fileext] = fileparts(filein);
0028
0029
0030 if strcmp(equilformat,'LUKE'),
0031
0032 data = importdata(filein);
0033
0034 if ~isfield(data,'psi_apRp'),
0035 error(['The file ',filename,fileext,' does not contains an equil structure (LUKE equilibrium format)']);
0036 else
0037 equil = data;
0038 end
0039 elseif strcmp(equilformat,'EFIT') || strcmp(equilformat,'EQDSK'),
0040
0041 if strcmp(fileext,'.mat'),
0042 equil = equil_EFIT_jd(filename,1,2,-1);
0043 else
0044 flag1 = 0;
0045 flag2 = 0;
0046 type = 0;
0047
0048 if strcmp(fileext,'efit') == 0,
0049 unix(['cp ',filename,fileext,' ',filename,'.efit']);
0050 filein_tmp1 = [filename,'.efit'];
0051 flag1 = 1;
0052 end
0053
0054 if exist([filename,'_kinetic_profiles.mat'],'file')
0055 type = 1.5;
0056 flag2 = 1;
0057 unix(['cp ',filename,'_kinetic_profiles.mat',' ',filename,'.prof']);
0058 filein_tmp2 = [filename,'.prof'];
0059 end
0060
0061 equil = equil_EFIT_jd(filename,type,2,-1);
0062
0063 if flag1,unix(['rm -f ',filein_tmp1]);end
0064 if flag2,unix(['rm -f ',filein_tmp2]);end
0065 end
0066
0067 elseif strcmp(equilformat,'ACCOME'),
0068
0069 if isempty(fileext)
0070 data1 = importdata([filename,'.bfield']);
0071 data2 = importdata([filename,'.params']);
0072 elseif strcmp(fileext,'.bfield')
0073 data1 = importdata(filein);
0074
0075 if exist([filename,'.params'],'file'),
0076 data2 = importdata([filename,'.params']);
0077 end
0078 elseif strcmp(fileext,'.params')
0079 if exist([filename,'.bfield'],'file'),
0080 data1 = importdata([filename,'.bfield']);
0081 end
0082
0083 data2 = importdata(filein);
0084 end
0085
0086 [equil_magnetic,prho,psin] = equil_magnetic_ACCOME_yp(filename,0,-1,filename,filename);
0087
0088 equil_prof = equil_prof_ACCOME_yp(filename,NaN,[],psin,0,-1,filename,filename,NaN);
0089
0090 equil = conc_struct_jd(equil_magnetic,equil_prof);
0091
0092 equil.id = filename;
0093
0094 save(['EQUIL_',filename,'.mat'],'equil');
0095 else
0096 error('Unknown toroidal MHD equilibrium file format');
0097 end
0098
0099 disp('Calculation of the equilibrium consistency (wait few seconds).');
0100
0101 [equil,gradpthermalsgradrho,gradpmagsgradrho,gradpkinsgradrho,jparz_fsav,jparz_ohm_fsav] = equilconsistency_yp(equil,'',1);
0102
0103