diff --git a/matlab/TCV_IMAS/tcv_get_ids_pf_passive.m b/matlab/TCV_IMAS/tcv_get_ids_pf_passive.m new file mode 100644 index 0000000000000000000000000000000000000000..c95518dce9741b4ebb630f56503004e5df02eeac --- /dev/null +++ b/matlab/TCV_IMAS/tcv_get_ids_pf_passive.m @@ -0,0 +1,85 @@ +function [ids_pf_passive,ids_pf_passive_description,varargout] = tcv_get_ids_pf_passive(shot, ids_pf_passive_empty, gdat_params, varargin) +% +% gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar options +% + +% Input pharser +if exist('gdat_params','var') + [ids_pf_passive, params_pf_passive] = tcv_ids_headpart(shot, ids_pf_passive_empty,'pf_passive','homogeneous_time',0,'gdat_params',gdat_params,varargin{:}); +else + [ids_pf_passive, params_pf_passive] = tcv_ids_headpart(shot, ids_pf_passive_empty,'pf_passive','homogeneous_time',0,varargin{:}); + aa=gdat_tcv; + gdat_params = aa.gdat_params; % to get default params +end +params_eff_ref = gdat_params; params_eff_ref.doplot=0; +try params_eff_ref=rmfield(params_eff_ref,'source');catch;end % make sure no source (from ids def) + + +% Get subfield + +G.rv = gdat(shot, 'STATIC("R_V")'); % Vessel radial coord 256x1 +G.wv = gdat(shot, 'STATIC("A_V")'); % Vessel conductor width 256x1 +G.zv = gdat(shot, 'STATIC("Z_V")'); % Vessel vert. coord 256x1 +G.hv = gdat(shot, 'STATIC("B_V")'); % Vessel conductor heigth 256x1 +G.Rv = gdat(shot, 'STATIC("RES_V")'); % Vessel resistivity 1 in 256x1 in ohm +G.res = gdat(shot, 'STATIC("RHO_V")'); % Vessel resistance 1 in ohm*m +G.dimv = gdat(shot, 'STATIC("N_V")'); % Number of turns + +Uf = gdat(shot, 'TCV_IDEALLOOP("VLOOP")'); % Flux loop voltage +Tvs = gdat(shot, 'STATIC("T_V_S")'); % Transfer matrix segments to vessel elements +Rs = gdat(shot, 'STATIC("RES_S")'); % Resistance of each segment + +Is = -Uf.data./Rs.data'; % Measured current in each segment +Iv = Tvs.data*Is'; % Mapped to each vessel element + +%ids_core_profiles.profiles_1d{1}.ion{1}.state = {}; +%ids_core_profiles.profiles_1d{1}.neutral{1}.state = {}; +%ids_core_profiles.profiles_1d(1:length(ids_core_profiles.time)) = ids_core_profiles.profiles_1d(1); + +loop_template = ids_pf_passive.loop{1}; + +for ii=1:G.dimv.data + % Duplicate loop substructure + ids_pf_passive.loop{ii} = loop_template; + + ids_pf_passive.loop{ii}.element{1}.geometry.geometry_type = 3; + ids_pf_passive.loop{ii}.element{1}.geometry.oblique.r = G.rv.data(ii)-G.wv.data(ii)/2; + ids_pf_passive.loop{ii}.element{1}.geometry.oblique.z = G.zv.data(ii)-G.hv.data(ii)/2; + ids_pf_passive.loop{ii}.element{1}.geometry.oblique.length_alpha = G.wv.data(ii); + ids_pf_passive.loop{ii}.element{1}.geometry.oblique.length_beta = G.hv.data(ii); + ids_pf_passive.loop{ii}.element{1}.geometry.oblique.alpha = 0; + ids_pf_passive.loop{ii}.element{1}.geometry.oblique.beta = 0; + ids_pf_passive.loop{ii}.element{1}.turns_with_sign = 1; + + ids_pf_passive.loop{ii}.element{1}.name = num2str(ii); + ids_pf_passive.loop{ii}.name = num2str(ii); % might not be correct + + ids_pf_passive.loop{ii}.resistivity = G.Rv.data(ii)/2/pi/G.rv.data(ii)*G.wv.data(ii)*G.hv.data(ii); + ids_pf_passive.loop{ii}.resistance = G.res.data; + ids_pf_passive.loop{ii}.current = Iv(ii,:); + ids_pf_passive.loop{ii}.time = Uf.t; + +end + +%% Code + +if nargin <= 2 + ids_pf_passive.code.name = ['tcv_get_ids_pf_passive, within gdat, with shot= ' num2str(params_pf_passive.shot) ]; +else + ids_pf_passive.code.name = ['tcv_get_ids_pf_passive, within gdat, with shot= ' num2str(params_pf_passive.shot) '; varargin: ' varargin{:}]; +end +ids_pf_passive_description.code.name = ids_pf_passive.code.name; + +ids_pf_passive.code.output_flag = zeros(size(ids_pf_passive.time)); + + + +% Not sure about this, copied from active but might need changes +% cocos automatic transform +if exist('ids_generic_cocos_nodes_transformation_symbolic','file') + [ids_pf_passive,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(ids_pf_passive,'pf_passive',gdat_params.cocos_in, ... + gdat_params.cocos_out,gdat_params.ipsign_out,gdat_params.b0sign_out,gdat_params.ipsign_in,gdat_params.b0sign_in, ... + gdat_params.error_bar,gdat_params.nverbose); + +end +