imake_ohm_jd

PURPOSE ^

SYNOPSIS ^

function ohm = imake_ohm_jd(dkepath,basestr,equil,external,workdir,opt_gui,select)

DESCRIPTION ^

 This function interactively builds the ohm structure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ohm = imake_ohm_jd(dkepath,basestr,equil,external,workdir,opt_gui,select)
0002 %
0003 % This function interactively builds the ohm structure
0004 %
0005 if nargin < 7,
0006     select = struct;
0007 end
0008 %
0009 if nargin < 6,
0010     opt_gui = true;
0011 end
0012 %
0013 if nargin < 5,
0014     workdir = pwd;
0015 end
0016 %
0017 if nargin < 4,
0018     external = '';
0019 end
0020 %
0021 if isempty(equil),
0022     if isfield(external,'equil'),
0023         equil = external.equil;
0024     else
0025         error('no equilibrium provided')
0026     end
0027 end
0028 %
0029 select.style.textwidth = 420;
0030 %
0031 ohm = '';
0032 %
0033 if isfield(select,'i_opt'),
0034     i_opt = select.i_opt;
0035 elseif ~isempty(external),
0036     %
0037     titletext = 'For the OHMIC field :';      
0038     s = {'Use data loaded from the external database',...
0039          'Use data from an existing file',...
0040          'Build the ohmic data locally'};
0041     %
0042     i_opt = iselect_jd(s,titletext,opt_gui,select.style,1) - 1;
0043     %
0044 else
0045     %
0046     titletext = 'For the OHMIC field :';      
0047     s = {'Use data from an existing file',...
0048          'Build the ohmic data locally'};
0049     %
0050     i_opt = iselect_jd(s,titletext,opt_gui,select.style,1);
0051     %
0052     %
0053 end
0054 %
0055 if any(~isfield(equil,{'shotnum','shotime'})),
0056     disp('WARNING : Equilibrium is obsolete, using fix_equil_jd to fix shotnum and shotime.')
0057     equil = fix_equil_jd(equil,1);
0058 end
0059 %
0060 shotnum = equil.shotnum;
0061 shotime = equil.shotime;
0062 %
0063 if i_opt == 0,% data loaded from external database
0064     %
0065     if isfield(external,'shot'),
0066         %
0067         ishot = find(external.shot == str2num(shotnum));
0068         %
0069         if isempty(ishot),
0070             disp(['-----> launching data not found for shot :',shotnum]);
0071             return
0072         end
0073         %
0074         if length(ishot) > 1,
0075             disp(['-----> WARNING : Several entries are found for shot :',shotnum,', first entry selected']);
0076             ishot = ishot(1);
0077         end
0078         %
0079     else
0080         ishot = 1;
0081     end
0082     %
0083     if strcmp(basestr,'EAST') || strcmp(basestr,'HL2A'),
0084         vloop = external.Vloop;
0085     else
0086         vloop = external.vloop(ishot);
0087     end
0088     %
0089     if strcmp(basestr,'TCV'),
0090         vloop = - vloop;%sign convention in TCV
0091     end
0092     %
0093     o_opt = 0;
0094     %
0095 elseif i_opt == 1,
0096     %
0097     if strcmp(basestr,'ITER'),
0098         %
0099         [data_file,data_path] = igetfile_jd(opt_gui,'*.*',['Please select the data file for shot ',shotnum,' at time ',shotime,' :'],workdir);
0100         %
0101         if data_file == 0,
0102             return
0103         end
0104         %
0105         filename = [data_path,data_file];
0106         %
0107         [pspsinT,dummy,dummy,dummy,dummy,dummy,dummy,dummy,pvloop] = textread(filename,'%n%n%n%n%n%n%n%n%n');
0108         %
0109         prho = pspsinT;
0110         ohm.rhotype = 't';
0111         %
0112         o_opt = 2;
0113         %
0114     else
0115         %
0116         disp('-----> function not yet implemented for this machine.')
0117         return
0118     end
0119     %
0120 elseif i_opt == 2,
0121     %
0122     o_opt = input('Option for ohm calculation? 0 (VLOOP), 1 (E/ED) : [0] ');
0123     %
0124     if isempty(o_opt),
0125         o_opt = 0;
0126     end
0127     %
0128     if ~isnumeric(o_opt) || ~any(o_opt == [0,1]),
0129         disp('-----> Invalid ohm option');
0130         return
0131     end
0132     %
0133     if o_opt == 0,% ohm from VLOOP
0134         %
0135         vloop = input('Please specify the value for Vloop (V) : ');
0136         if isempty(vloop) || ~isnumeric(vloop),
0137             disp('-----> Invalid vloop value');
0138             return
0139         end
0140         %
0141     else
0142         %
0143         epsi = input('Please specify the value for E/ED (Dreicer field) : ');
0144         if isempty(epsi) || ~isnumeric(epsi),
0145             disp('-----> Invalid vloop value');
0146             return
0147         end        
0148         %
0149     end
0150 end
0151 %
0152 if o_opt == 0,% ohm from constant VLOOP
0153     %
0154     sigma = - sign(equil.ptBPHI(1,1));%epsi is defined versus B, electron charge included epsi = -E.B
0155     %
0156     if ~isfield(select,'idohm') || ~select.idohm 
0157         id_ohm = input('Please specify a name for the ohm structure : [VLOOP]','s');
0158     else
0159         id_ohm = '';
0160     end
0161     %
0162     if isempty(id_ohm),
0163         id_ohm = 'VLOOP';
0164     end
0165     ohm.id = id_ohm;
0166     %
0167     psin = equil.psi_apRp/equil.psi_apRp(end);
0168     ohm.rho = psi2rho_jd(equil,psin);%Arbitrary normalized minor radius
0169     ohm.epsi = -sigma*vloop*ones(1,length(ohm.rho))/(2*pi*equil.Rp);%(V/m) E=-grad V
0170     %
0171 elseif o_opt == 1,% ohm from E/ED
0172     %
0173     ohm = ohm_flat(equil,epsi);
0174     %
0175     if ~isfield(select,'idohm') || ~select.idohm 
0176         id_ohm = input('Please specify a name for the ohm structure : [ED]','s');
0177     else
0178         id_ohm = '';
0179     end
0180     %
0181     if isempty(id_ohm),
0182         id_ohm = 'ED';
0183     end
0184     ohm.id = id_ohm;
0185     %
0186     %
0187 elseif o_opt == 2,% ohm from varying VLOOP
0188     %
0189     sigma = - sign(equil.ptBPHI(1,1)*equil.psi_apRp(end));
0190     %
0191     if ~isfield(select,'idohm') || ~select.idohm 
0192         id_ohm = input('Please specify a name for the ohm structure : [VLOOP]','s');
0193     else
0194         id_ohm = '';
0195     end
0196     %
0197     if isempty(id_ohm),
0198         id_ohm = 'VLOOP';
0199     end
0200     ohm.id = id_ohm;
0201     %
0202     ohm.rho = prho;%Arbitrary normalized minor radius
0203     ohm.epsi = sigma*pvloop/(2*pi*equil.Rp);%(V/m)
0204     %
0205 end
0206 %
0207 %
0208 %
0209 ohm.info.txt = {...
0210     ['Central loop voltage (V) : ',num2str(ohm.epsi(1)*(2*pi*equil.Rp))],...
0211     ['Edge loop voltage (V)    : ',num2str(ohm.epsi(end)*(2*pi*equil.Rp))]};
0212 
0213 
0214 
0215 %

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