Skip to content
Snippets Groups Projects
Commit 57497dac authored by Francesco Carpanese's avatar Francesco Carpanese Committed by Olivier Sauter
Browse files

Organization of the folder

parent 9f9ae1e0
No related branches found
No related tags found
1 merge request!41Add corsica liuqe complete ids from meq
clear all
close all
clc
% This script will complete the IDS of CORSICA with the missing fields recomputing the missing quantities from available information
data_path_in = '/NoTivoli/carpanes/LIU_RAP_ITER/CORSICA_ids/CORSICA_130510.mat';
%path_IDS = '/NoTivoli/carpanes/LIU_RAP_ITER/CORSICA_ids/CORSICA_130506.mat';
data_path_out = '/NoTivoli/carpanes/LIU_RAP_ITER/CORSICA_ids/CORSICA_130510_extended.mat';
% Load the IDS file
IDS = load(data_path_in);
G = G_ITER_generator;
% Get the structure from generating files
P = liupiter(1000,'uuu',ones(G.na,1),'vvv',ones(G.nm,1), 'www', ones(G.nf,1)); % Some default setting that could be removed probably to use the liupiter directly
G = liug(G,P);
L = liuc(P,G);
% Extract information from CORSICA IDS
[LC,LXC,LYC] = liux_IDS_corsica(L, IDS);
%% -------------------- ADD the missing information on the existing IDS CORSICA -----------------------
%% Consider each circuit to be composed by only one coil
% TODO NEED TO ADD THE VERTICAL STABILIZATION COIL STILL
tmp = data_coils();
for ii = 1:numel(tmp.names)
for jj=1:numel(IDS.pf_active.coil)
% Remove strange character in coil names
IDS.pf_active.coil{jj}.name = regexprep(IDS.pf_active.coil{jj}.name,'[\n\r]+','');
if strcmp(tmp.names{ii},IDS.pf_active.coil{jj}.name)
IDS.pf_active.coil{jj}.element{1}.geometry.geometry_type = 2; % Rectangle description
IDS.pf_active.coil{jj}.element{1}.geometry.rectangle.r = tmp.R(ii);
IDS.pf_active.coil{jj}.element{1}.geometry.rectangle.z = tmp.Z(ii);
IDS.pf_active.coil{jj}.element{1}.geometry.rectangle.width = tmp.dR(ii);
IDS.pf_active.coil{jj}.element{1}.geometry.rectangle.height = tmp.dZ(ii);
IDS.pf_active.coil{jj}.element{1}.turns_with_sign = tmp.N(ii);
end
end
end
%% Add the data to the circuit
Ncoils = numel(IDS.pf_active.coil);
for ii=1:Ncoils-2
IDS.pf_active.circuit{ii}.name = IDS.pf_active.coil{ii}.name;
IDS.pf_active.supply{ii}.name = IDS.pf_active.coil{ii}.name;
IDS.pf_active.circuit{ii}.current.data = IDS.pf_active.coil{ii}.current.data/IDS.pf_active.coil{ii}.element{1}.turns_with_sign;
IDS.pf_active.circuit{ii}.current.time = IDS.pf_active.coil{ii}.current.time;
IDS.pf_active.circuit{ii}.connections = zeros(2, 4*Ncoils);
IDS.pf_active.circuit{ii}.connections(1, 2*ii) =1;
IDS.pf_active.circuit{ii}.connections(2, 2*ii-1) = 1;
IDS.pf_active.circuit{ii}.connections(1, 2*Ncoils + 2*ii-1) =1;
IDS.pf_active.circuit{ii}.connections(2, 2*Ncoils + 2*ii) =1;
end
% Vertical stabilization coil needs to be added still
for ii=(Ncoils-1):Ncoils
IDS.pf_active.circuit{ii}.name = IDS.pf_active.coil{ii}.name;
IDS.pf_active.supply{ii}.name = IDS.pf_active.coil{ii}.name;
IDS.pf_active.circuit{ii}.name = IDS.pf_active.coil{ii}.name;
IDS.pf_active.circuit{ii}.current.data = zeros(LXC.nt, 1);
IDS.pf_active.circuit{ii}.current.time = LXC.t;
IDS.pf_active.circuit{ii}.connections = zeros(2, 4*Ncoils);
IDS.pf_active.circuit{ii}.connections(1, 2*ii) =1;
IDS.pf_active.circuit{ii}.connections(2, 2*ii-1) = 1;
IDS.pf_active.circuit{ii}.connections(1, 2*Ncoils + 2*ii-1) =1;
IDS.pf_active.circuit{ii}.connections(2, 2*Ncoils + 2*ii) =1;
end
%% Limiter description
tmp = data_limiter();
IDS.wall.description_2d{1}.limiter.unit{1}.outline.r = tmp.r;
IDS.wall.description_2d{1}.limiter.unit{1}.outline.z = tmp.z;
%% Vessel description
% Understand what I need to do for the double layer vessel
%% -------------- Synthetic diagnostics------------ Need to be recomputed from CORSICA flux map
IDS.magnetics.method{1}.ip.time = LXC.t;
IDS.magnetics.method{1}.ip.data = LXC.Ip;
%% Ff
tmp = data_Ff();
for ii=1:numel(tmp.r)
IDS.magnetics.flux_loop{ii}.position{1}.r = tmp.r(ii);
IDS.magnetics.flux_loop{ii}.position{1}.z = tmp.z(ii);
IDS.magnetics.flux_loop{ii}.name = tmp.name{ii};
end
for ii=1:numel(tmp.r)
IDS.magnetics.flux_loop{ii}.flux.data = -LXC.Ff(ii,:)';
IDS.magnetics.flux_loop{ii}.flux.time = LXC.t;
end
%% Bm
tmp = data_Bm();
for ii=1:numel(tmp.name)
IDS.magnetics.bpol_probe{ii}.position.r = tmp.r(ii);
IDS.magnetics.bpol_probe{ii}.position.z = tmp.z(ii);
IDS.magnetics.bpol_probe{ii}.poloidal_angle = tmp.am(ii);
IDS.magnetics.bpol_probe{ii}.name = tmp.name{ii};
end
for ii=1:numel(tmp.name)
IDS.magnetics.bpol_probe{ii}.field.data = LXC.Bm(ii,:)';
IDS.magnetics.bpol_probe{ii}.field.time = LXC.t;
end
%% Ft
IDS.magnetics.method{1}.diamagnetic_flux.data = -LXC.Ft;
IDS.magnetics.method{1}.diamagnetic_flux.time = LXC.t;
%% rBt
IDS.tf.time = LXC.t;
IDS.tf.b_field_tor_vacuum_r.time = LXC.t;
IDS.tf.b_field_tor_vacuum_r.data = LXC.rBt;
%% Store the resulting data
save(data_path_out, '-struct', 'IDS')
fprintf('\n wrote file %s \n', data_path_out);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment