load_structures_yp

PURPOSE ^

LUKE - Load structures for LUKE

SYNOPSIS ^

function [varargout] = load_structures_yp(varargin)

DESCRIPTION ^

LUKE - Load structures for LUKE 

 Load structures for LUKE 

 INPUTS: 

   - type: 'dkepath','equil','dkeparam','display','ohm','waves','transpfaste','ripple', 'fluct' or 'hxr' (order not important)
   - id: id of the field type
   - path: path of the field type

 OUTPUTS:

   - structures: as indicated by the order specified in the types

 WARNING: several types may be used, the order in unimportant. The output
 corresponds to the number and the order of types

 by Y.Peysson CEA-DRFC <yves.peysson@cea.fr> and Joan Decker CEA-DRFC (joan.decker@cea.fr)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [varargout] = load_structures_yp(varargin)
0002 %LUKE - Load structures for LUKE
0003 %
0004 % Load structures for LUKE
0005 %
0006 % INPUTS:
0007 %
0008 %   - type: 'dkepath','equil','dkeparam','display','ohm','waves','transpfaste','ripple', 'fluct' or 'hxr' (order not important)
0009 %   - id: id of the field type
0010 %   - path: path of the field type
0011 %
0012 % OUTPUTS:
0013 %
0014 %   - structures: as indicated by the order specified in the types
0015 %
0016 % WARNING: several types may be used, the order in unimportant. The output
0017 % corresponds to the number and the order of types
0018 %
0019 % by Y.Peysson CEA-DRFC <yves.peysson@cea.fr> and Joan Decker CEA-DRFC (joan.decker@cea.fr)
0020 %
0021 if rem(nargin,3) > 0 | nargin == 0, error('Wrong number of input arguments in load_structures_yp !');end
0022 %
0023 id_path = '';
0024 path_path = '';
0025 id_equil = '';
0026 path_equil = '';
0027 id_dkeparam = '';
0028 path_dkeparam = '';
0029 id_rtparam = '';
0030 path_rtparam = '';
0031 id_hxrparam = '';
0032 path_hxrparam = '';
0033 id_display = '';
0034 path_display = '';
0035 id_ohm = '';
0036 path_ohm = '';
0037 ids_wave = '';
0038 paths_wave = '';
0039 ids_wavestruct = '';
0040 paths_wavestruct = '';
0041 ids_rayinit = '';
0042 paths_rayinit = '';
0043 ids_launch = '';
0044 paths_launch = '';
0045 ids_angles = '';
0046 paths_angles = '';
0047 id_transpfaste = '';
0048 path_transpfaste = '';
0049 id_ripple = '';
0050 path_ripple = '';
0051 id_fluct = '';
0052 path_fluct = '';
0053 id_hxr = '';
0054 path_hxr = '';
0055 id_external = '';
0056 path_external = '';
0057 %
0058 j = 1;
0059 for i=1:3:length(varargin),
0060     if strcmp(varargin{i},'dkepath'),
0061        id_path = varargin{i+1};
0062        path_path = varargin{i+2};
0063        flag_path = j;
0064     elseif strcmp(varargin{i},'dkeparam'),
0065        id_dkeparam = varargin{i+1};
0066        path_dkeparam = varargin{i+2};
0067        flag_dkeparam = j;
0068     elseif strcmp(varargin{i},'rtparam'),
0069        id_rtparam = varargin{i+1};
0070        path_rtparam = varargin{i+2};
0071        flag_rtparam = j;
0072     elseif strcmp(varargin{i},'hxrparam'),
0073        id_hxrparam = varargin{i+1};
0074        path_hxrparam = varargin{i+2};
0075        flag_hxrparam = j;
0076     elseif strcmp(varargin{i},'dkedisplay'),
0077        id_display = varargin{i+1};
0078        path_display = varargin{i+2};
0079        flag_display = j;
0080     elseif strcmp(varargin{i},'equil'),
0081        id_equil = varargin{i+1};
0082        path_equil = varargin{i+2};
0083        flag_equil = j;
0084     elseif strcmp(varargin{i},'ohm'),
0085        id_ohm = varargin{i+1};
0086        path_ohm = varargin{i+2};
0087        flag_ohm = j;
0088     elseif strcmp(varargin{i},'waves'),
0089        ids_wave = varargin{i+1};
0090        paths_wave = varargin{i+2};
0091        flag_wave = j;
0092     elseif strcmp(varargin{i},'wavestructs'),
0093        ids_wavestruct = varargin{i+1};
0094        paths_wavestruct = varargin{i+2};
0095        flag_wavestruct = j;
0096     elseif strcmp(varargin{i},'rayinits'),
0097        ids_rayinit = varargin{i+1};
0098        paths_rayinit = varargin{i+2};
0099        flag_rayinit = j;
0100     elseif strcmp(varargin{i},'launchs'),
0101        ids_launch = varargin{i+1};
0102        paths_launch = varargin{i+2};
0103        flag_launch = j;
0104     elseif strcmp(varargin{i},'angles'),
0105        ids_angles = varargin{i+1};
0106        paths_angles = varargin{i+2};
0107        flag_angles = j;
0108     elseif strcmp(varargin{i},'transpfaste'),
0109        id_transpfaste = varargin{i+1};
0110        path_transpfaste = varargin{i+2};
0111        flag_transpfaste = j;
0112     elseif strcmp(varargin{i},'ripple'),
0113        id_ripple = varargin{i+1};
0114        path_ripple = varargin{i+2};
0115        flag_ripple = j;
0116     elseif strcmp(varargin{i},'fluct'),
0117        id_fluct = varargin{i+1};
0118        path_fluct = varargin{i+2};
0119        flag_fluct = j;
0120     elseif strcmp(varargin{i},'hxr'),
0121        id_hxr = varargin{i+1};
0122        path_hxr = varargin{i+2};
0123        flag_hxr = j;
0124        j = j+1;
0125        flag_hxrparam = j;
0126     elseif strcmp(varargin{i},'external'),
0127        id_external = varargin{i+1};
0128        path_external = varargin{i+2};
0129        flag_external = j;
0130     end
0131     j = j + 1;
0132 end
0133 %
0134 if exist('flag_path','var'),%Paths
0135     %
0136     if isempty(id_path),% load dkepath from getappdata(0,'dkepath') or find LUKE_PATH.mat in current path
0137         %
0138         if isappdata(0,'dkepath'),
0139             dkepath = getappdata(0,'dkepath');
0140             filename = '';
0141             info_dke_yp(2,'Structure ''dkepath'' successfully loaded from getappdata(0,''dkepath'')');
0142         else
0143             %
0144             filenames = which('LUKE_PATH.mat','-all');
0145             %
0146             if length(filenames) > 1,
0147                 ifile = iselect_jd(filenames,'Warning : more than one LUKE_PATH.mat file found. Please select one of the following :',false);
0148             elseif isempty(filenames),
0149                 error('No LUKE_PATH.mat found on the matlab path')
0150             else
0151                 ifile = 1;
0152             end
0153             %
0154             filename = filenames{ifile};
0155             %
0156         end
0157         %
0158     else% load dkepath from [path_path,id_path,'.mat']
0159         %
0160         filename = [path_path,id_path,'.mat'];
0161         %
0162         if ~exist(filename,'file'),
0163             error(['The file ',filename,' does not exist'])
0164         end
0165     end
0166     %
0167     if ~isempty(filename),
0168         %
0169         load(filename,'dkepath');
0170         %
0171         info_dke_yp(2,['Structure ''dkepath'' successfully loaded from ',filename]);
0172         %
0173         % Set path for LUKE including mex files and matrix inverters
0174         %
0175         dkepath = setpath_luke_jd(dkepath);
0176         %
0177     end
0178     %
0179     if ~strcmp(dkepath.computer,computer),
0180         error('The path structure is not consistent with the computer !'),
0181     end
0182     %
0183     varargout{flag_path} = dkepath;
0184 end
0185 %
0186 if exist('flag_equil','var'),%Magnetic equilibrium
0187     if strfind(path_equil,'database')
0188         if strfind(path_equil,'ITM'),
0189             [machine,user,ver] = which_MDSdatabase(dkepath);%Check access to database (Environment variable must be set-up before launching MatLab)
0190             if isempty(machine) | isempty(user) | isempty(ver),
0191                 error(['WARNING: Unsuccessful connexion to ITM MDS+ database, user: ',user,', database version: ',ver,', machine: ',machine]);
0192             else
0193                 disp(['Successful connexion to ITM MDS+ database, user: ',user,', database version: ',ver,', machine: ',machine]);
0194                 if ischar(id_equil),
0195                     [numshot,path_equil] = LUKE2ITM(dkepath,'equil',id_equil);%Conversion for accessing to the ITM MDS+ reference shot number
0196                 else
0197                     numshot = id_equil;%Direct access to the ITM MDS+ reference shot number
0198                 end
0199                 %
0200                 [equil,status,result] = read_equil_ITM(numshot,1,NaN,1);
0201                 if ~status,
0202                     disp(['LUKE magnetic equilibrium ',id_equil,' successfully read from the ITM-MDS+ database']);
0203                     varargout{flag_equil} = equil;
0204                 else
0205                     error(result);
0206                 end
0207             end
0208         else    
0209             error(['The database ',path_equil,' is not recognized']);
0210         end
0211     else
0212         filename = [path_equil,'EQUIL_',id_equil,'.mat'];
0213         if exist(filename) == 0,
0214             error([filename,' does not exist']);
0215         else
0216             load(filename);
0217             info_dke_yp(2,['Structure ''equil'': ',filename,' successfully loaded']);
0218         end
0219         varargout{flag_equil} = equil;    
0220     end
0221 end
0222 %
0223 if exist('flag_dkeparam','var'),%DKE simulation parameters
0224     filename = [path_dkeparam,'DKEPARAM_',id_dkeparam,'.mat'];
0225     if exist(filename) == 0,
0226         error([filename,' does not exist']);
0227     else
0228         load(filename);
0229         info_dke_yp(2,['Structure ''dkeparam'': ',filename,' successfully loaded']);
0230     end
0231     varargout{flag_dkeparam} = dkeparam;
0232 end
0233 %
0234 if exist('flag_rtparam','var'),%DKE simulation parameters
0235     filename = [path_rtparam,'C3POPARAM_',id_rtparam,'.mat'];
0236     if exist(filename) == 0,
0237         error([filename,' does not exist']);
0238     else
0239         load(filename);
0240         info_dke_yp(2,['Structure ''rtparam'': ',filename,' successfully loaded']);
0241     end
0242     varargout{flag_rtparam}.fitparam = fitparam;
0243     varargout{flag_rtparam}.rayparam = rayparam;
0244     varargout{flag_rtparam}.C3POparam = C3POparam;
0245     varargout{flag_rtparam}.C3POdisplay = C3POdisplay;
0246     varargout{flag_rtparam}.waveparam = waveparam;
0247 end
0248 %
0249 if exist('flag_hxrparam','var'),%DKE simulation parameters
0250     filename = [path_hxrparam,'HXRPARAM_',id_hxrparam,'.mat'];
0251     if exist(filename) == 0,
0252         error([filename,' does not exist']);
0253     else
0254         load(filename);
0255         info_dke_yp(2,['Structure ''hxrparam'': ',filename,' successfully loaded']);
0256     end
0257     varargout{flag_hxrparam} = hxrparam;
0258 end
0259 %
0260 if exist('flag_display','var'),%DKE display parameters
0261     filename = [path_display,'DISPLAY_',id_display,'.mat'];
0262     if exist(filename) == 0,
0263         error([filename,' does not exist']);
0264     else
0265         load(filename);
0266         info_dke_yp(2,['Structure ''dkedisplay'': ',filename,' successfully loaded']);
0267     end
0268     varargout{flag_display} = dkedisplay;
0269 end
0270 %
0271 if exist('flag_ohm','var'),%Ohmic electric field
0272     filename = [path_ohm,'OHM_',id_equil,'_',id_ohm,'.mat'];
0273     ohm = '';
0274     if isempty(id_ohm),
0275         info_dke_yp(2,['Simulations are performed without Ohmic E-field']);
0276     elseif exist(filename) == 0,
0277         info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0278     else
0279         load(filename);
0280         info_dke_yp(2,['Structure ''ohm'': ',filename,' successfully loaded']);
0281     end
0282     varargout{flag_ohm} = ohm;
0283 end
0284 %
0285 if exist('flag_wave','var'),
0286     ii = 0;
0287     waves = '';%List of structures for multiple RF waves
0288     %
0289     if ~iscell(ids_wave),
0290         ids_wave={ids_wave};
0291     end
0292     if ~iscell(paths_wave),
0293         paths_wave=repmat({paths_wave},[1,length(ids_wave)]);
0294     end
0295     %
0296     if isempty(ids_wave{1}),
0297         info_dke_yp(2,['Simulations are performed without RF Waves']);
0298     else
0299         for iw = 1:length(ids_wave),
0300             if isempty(id_equil) && strfind(ids_wave{iw},'WAVE_'),
0301                 filename = [ids_wave{iw}];
0302             else
0303                 filename = ['WAVE_',id_equil,'_',ids_wave{iw},'.mat'];
0304             end
0305             filenames = getlist_jd(paths_wave{iw},filename);
0306             if isempty(filenames),
0307                 info_dke_yp(2,['Warning : Structure ',filename,' could not be found in the directory ',paths_wave{iw},'.']);
0308             else
0309                 for ifile = 1:length(filenames),
0310                     filename = [paths_wave{iw},filenames{ifile}];
0311                     data = load(filename);
0312                     info_dke_yp(2,['Structure ''wave'': ',filename,' successfully loaded']);
0313                     ii = ii + 1;
0314                     waves{ii} = data.wave;
0315                 end
0316             end
0317         end
0318     end
0319     varargout{flag_wave} = waves;
0320 end
0321 %
0322 if exist('flag_wavestruct','var'),
0323     ii = 0;
0324     wavestructs = '';%List of structures for multiple RF waves
0325     %
0326     if ~iscell(ids_wavestruct),
0327         ids_wavestruct={ids_wavestruct};
0328     end
0329     if ~iscell(paths_wavestruct),
0330         paths_wavestruct=repmat({paths_wavestruct},[1,length(ids_wavestruct)]);
0331     end
0332     %
0333     if isempty(ids_wavestruct{1}),
0334         info_dke_yp(2,['Simulations are performed without RF Wavestructs']);
0335     else
0336         for iw = 1:length(ids_wavestruct),
0337             filename = ['WAVESTRUCT_',id_equil,'_',ids_wavestruct{iw},'.mat'];
0338             filenames = getlist_jd(paths_wavestruct{iw},filename);
0339             if isempty(filenames),
0340                 info_dke_yp(2,['Warning : Structure ',filename,' could not be found in directory',paths_wavestruct{iw},'.']);
0341             else
0342                 for ifile = 1:length(filenames),
0343                     filename = [paths_wavestruct{iw},filenames{ifile}];
0344                     load(filename);
0345                     info_dke_yp(2,['Structure ''wavestruct'': ',filename,' successfully loaded']);
0346                     ii = ii + 1;
0347                     wavestructs{ii} = wavestruct;
0348                 end
0349             end
0350         end
0351     end
0352     varargout{flag_wavestruct} = wavestructs;
0353 end
0354 %
0355 if exist('flag_rayinit','var'),
0356     ii = 0;
0357     rayinits = '';%List of structures for multiple RF waves
0358     if isempty(ids_rayinit{1}),
0359         info_dke_yp(2,['No initial conditions requested']);
0360     else
0361         for iw = 1:length(ids_rayinit),
0362             filename = [paths_rayinit{iw},'RAYINIT_',id_equil,'_',ids_rayinit{iw},'.mat'];
0363             if exist(filename) == 0,
0364                 info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0365             else
0366                 load(filename);
0367                 info_dke_yp(2,['Structure ''rayinit'': ',filename,' successfully loaded']);
0368                 ii = ii + 1;
0369                 rayinits{ii} = rayinit;
0370             end
0371         end
0372     end
0373     varargout{flag_rayinit} = rayinits;
0374 end
0375 %
0376 if exist('flag_launch','var'),
0377     ii = 0;
0378     launchs = '';%List of structures for multiple RF waves
0379     %
0380     if ~iscell(ids_launch),
0381         ids_launch={ids_launch};
0382     end
0383     if ~iscell(paths_launch),
0384         paths_launch=repmat({paths_launch},[1,length(ids_launch)]);
0385     end
0386     %
0387     if isempty(ids_launch{1}),
0388         info_dke_yp(2,['No launching conditions requested']);
0389     else
0390         for iw = 1:length(ids_launch),
0391             filename = [paths_launch{iw},'LAUNCH_',ids_launch{iw},'.mat'];
0392             if exist(filename) == 0,
0393                 info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0394             else
0395                 load(filename);
0396                 info_dke_yp(2,['Structure ''launch'': ',filename,' successfully loaded']);
0397                 ii = ii + 1;
0398                 launchs{ii} = launch;
0399             end
0400         end
0401     end
0402     varargout{flag_launch} = launchs;
0403 end
0404 %
0405 if exist('flag_angles','var'),
0406     ii = 0;
0407     angless = '';%List of structures for multiple RF waves
0408     if isempty(ids_angles{1}),
0409         info_dke_yp(2,['No angles conditions requested']);
0410     else
0411         for iw = 1:length(ids_angles),
0412             filename = [paths_angles{iw},'ANGLES_',ids_angles{iw},'.mat'];
0413             if exist(filename) == 0,
0414                 info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0415             else
0416                 load(filename);
0417                 info_dke_yp(2,['Structure ''angles'': ',filename,' successfully loaded']);
0418                 ii = ii + 1;
0419                 angless{ii} = angles;
0420             end
0421         end
0422     end
0423     varargout{flag_angles} = angless;
0424 end
0425 %
0426 if exist('flag_transpfaste','var'),
0427     filename1 = [path_transpfaste,'TRANSP_',id_equil,'_',id_transpfaste,'.mat'];
0428     filename2 = [path_transpfaste,'TRANSP_',id_transpfaste,'.mat'];
0429     transpfaste = '';
0430     if isempty(id_transpfaste),
0431         info_dke_yp(2,['Simulations are performed without fast electron transport']);
0432     elseif exist(filename1),
0433         load(filename1);
0434         info_dke_yp(2,['Structure ''transpfaste'': ',filename1,' successfully loaded']);
0435     elseif exist(filename2),
0436         load(filename2);
0437         info_dke_yp(2,['Structure ''transpfaste'': ',filename2,' successfully loaded']);
0438     else
0439         info_dke_yp(2,['Warning : Structure ',filename1,' or ',filename2,' could not be loaded']);
0440     end
0441     varargout{flag_transpfaste} = transpfaste;
0442 end
0443 %
0444 if exist('flag_ripple','var'),
0445     filename = [path_ripple,'RIPPLE_',id_equil,'_',id_ripple,'.mat'];
0446     ripple = '';
0447     if isempty(id_ripple),
0448         info_dke_yp(2,['Simulations are performed without magnetic ripple effects']);
0449     elseif exist(filename) == 0,
0450         info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0451     else
0452         load(filename);
0453         info_dke_yp(2,['Structure ''ripple'': ',filename,' successfully loaded']);
0454     end
0455     varargout{flag_ripple} = ripple;
0456 end
0457 %
0458 if exist('flag_fluct','var'),
0459     filename = [path_fluct,'FLUCT_',id_equil,'_',id_fluct,'.mat'];
0460     fluct = '';
0461     if isempty(id_fluct),
0462         info_dke_yp(2,['Simulations are performed without density or magnetic field fluctuations']);
0463     elseif exist(filename) == 0,
0464         info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0465     else
0466         load(filename);
0467         info_dke_yp(2,['Structure ''fluct'': ',filename,' successfully loaded']);
0468     end
0469     varargout{flag_fluct} = fluct;
0470 end
0471 %
0472 if exist('flag_hxr','var'),%HXR
0473     filename = [path_hxr,'HXR_',id_hxr,'.mat'];
0474     hxr = '';
0475     hxrparam = '';
0476     if exist(filename) == 0,
0477         info_dke_yp(2,['Warning : Structure ',filename,' could not be loaded']);
0478     else
0479         load(filename);
0480         info_dke_yp(2,['Structure ''hxr'': ',filename,' successfully loaded']);
0481     end
0482     varargout{flag_hxr} = hxr;
0483     varargout{flag_hxrparam} = hxrparam;
0484 end
0485 %
0486 if exist('flag_external','var'),%DKE external parameters
0487     filename = [path_external,'EXTERNAL_',id_external,'.mat'];
0488     if exist(filename) == 0,
0489         error([filename,' does not exist']);
0490     else
0491         load(filename);
0492         info_dke_yp(2,['Structure ''external'': ',filename,' successfully loaded']);
0493     end
0494     varargout{flag_external} = external;
0495 end
0496 %
0497         
0498 
0499     
0500     
0501     
0502     
0503     
0504     
0505     
0506     
0507 
0508

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