Skip to content
Snippets Groups Projects
Commit 3110cb16 authored by Olivier Sauter's avatar Olivier Sauter
Browse files

fix cases getting empty substructure when ids_get with mex is used

parent 8b028593
No related branches found
No related tags found
2 merge requests!50Fix complete ids corsica keep ids structures,!48Fix complete ids corsica keep ids structures
Pipeline #31935 passed with stage
......@@ -44,13 +44,18 @@ L = liuc(Pliuqe,G);
%% -------------------- ADD the missing information on the existing IDS_out CORSICA -----------------------
% Make sure default substructure maintained if insert new indices
pf_active_default = gdat([],'ids','source','pf_active');
pf_active_default = pf_active_default.pf_active;
%% Consider each circuit to be composed by only one coil
tmp = data_coils();
if isempty(IDS_out.pf_active.coil); IDS_out.pf_active.coil(1:numel(tmp.names)) = pf_active_default.coil(1); end
for ii = 1:numel(tmp.names)
for jj=1:numel(IDS_out.pf_active.coil)
% Remove strange character in coil names
IDS_out.pf_active.coil{jj}.name = regexprep(IDS_out.pf_active.coil{jj}.name,'[\n\r]+','');
if strcmp(tmp.names{ii},IDS_out.pf_active.coil{jj}.name)
if isempty(IDS_out.pf_active.coil{jj}.element); IDS_out.pf_active.coil{jj}.element(1) = pf_active_default.coil{1}.element(1); end
IDS_out.pf_active.coil{jj}.element{1}.geometry.geometry_type = 2; % Rectangle description
IDS_out.pf_active.coil{jj}.element{1}.geometry.rectangle.r = tmp.R(ii);
IDS_out.pf_active.coil{jj}.element{1}.geometry.rectangle.z = tmp.Z(ii);
......@@ -70,14 +75,11 @@ Ncoils = numel(IDS_out.pf_active.coil);
% time will be set in circuit.current.time so should not put it at top and set homogeneous to 0?
IDS_out.pf_active.time = [];
IDS_out.pf_active.ids_properties.homogeneous_time = 0;
% Make sure default substructure maintained if insert new indices
pf_active_default = gdat([],'ids','source','pf_active');
pf_active_default = pf_active_default.pf_active;
if Ncircuit_eff > Ncircuit_in
IDS_out.pf_active.circuit(Ncircuit_in+1:Ncircuit_eff) = pf_active_default.circuit(1);
IDS_out.pf_active.circuit(Ncircuit_in+1:Ncircuit_eff,1) = pf_active_default.circuit(1);
end
if Ncircuit_eff > Nsupply_in
IDS_out.pf_active.supply(Nsupply_in+1:Ncircuit_eff) = pf_active_default.supply(Nsupply_in);
IDS_out.pf_active.supply(Nsupply_in+1:Ncircuit_eff,1) = pf_active_default.supply(1);
end
for ii=1:Ncircuit_eff
IDS_out.pf_active.circuit{ii}.name = tmp{ii,1}{1};
......@@ -107,12 +109,19 @@ end
%% Limiter description
tmp = data_limiter();
% Make sure default substructure maintained if insert new indices
wall_default = gdat([],'ids','source','wall');
wall_default = wall_default.wall;
IDS_out.wall.ids_properties.homogeneous_time = 0; % no times are set so just say not homogeneous
if isempty(IDS_out.wall.description_2d); IDS_out.wall.description_2d(1) = wall_default.description_2d(1); end
if isempty(IDS_out.wall.description_2d{1}.limiter.unit); IDS_out.wall.description_2d{1}.limiter.unit(1) = wall_default.description_2d{1}.limiter.unit(1); end
IDS_out.wall.description_2d{1}.limiter.unit{1}.outline.r = tmp.r;
IDS_out.wall.description_2d{1}.limiter.unit{1}.outline.z = tmp.z;
% problem with mex ids_put when time default or empty, make outline and ggd empty
IDS_out.wall.description_2d{1}.mobile.unit{1}.outline = {};
if ~isempty(IDS_out.wall.description_2d{1}.mobile.unit)
IDS_out.wall.description_2d{1}.mobile.unit{1}.outline = {};
end
IDS_out.wall.description_ggd = {};
%% Vessel description
......@@ -120,22 +129,24 @@ IDS_out.wall.description_ggd = {};
%% -------------- Synthetic diagnostics------------ Need to be recomputed from CORSICA flux map
% Make sure default substructure maintained if insert new indices
magnetics_default = gdat([],'ids','source','magnetics');
magnetics_default = magnetics_default.magnetics;
% since time set in subnode method{1}.ip.time, set homogeneous to 0 (magnetics.time already empty)
IDS_out.magnetics.ids_properties.homogeneous_time = 0;
if isempty(IDS_out.magnetics.method); IDS_out.magnetics.method(1) = magnetics_default.method(1); end
IDS_out.magnetics.method{1}.ip.time = LXC.t;
IDS_out.magnetics.method{1}.ip.data = LXC.Ip;
%% Ff
tmp = data_Ff();
% Make sure default substructure maintained if insert new indices
magnetics_default = gdat([],'ids','source','magnetics');
magnetics_default = magnetics_default.magnetics;
Nflux_loop_in = numel(IDS_out.magnetics.flux_loop);
Nflux_loop_eff = numel(tmp.r);
if Nflux_loop_eff > Nflux_loop_in
IDS_out.magnetics.flux_loop(Nflux_loop_in+1:Nflux_loop_eff) = magnetics_default.flux_loop(1);
IDS_out.magnetics.flux_loop(Nflux_loop_in+1:Nflux_loop_eff,1) = magnetics_default.flux_loop(1);
end
for ii=1:Nflux_loop_eff
if isempty(IDS_out.magnetics.flux_loop{ii}.position); IDS_out.magnetics.flux_loop{ii}.position(1) = magnetics_default.flux_loop{ii}.position(1); end
IDS_out.magnetics.flux_loop{ii}.position{1}.r = tmp.r(ii);
IDS_out.magnetics.flux_loop{ii}.position{1}.z = tmp.z(ii);
IDS_out.magnetics.flux_loop{ii}.name = tmp.name{ii};
......@@ -153,7 +164,7 @@ tmp = data_Bm();
Nbpol_probe_in = numel(IDS_out.magnetics.bpol_probe);
Nbpol_probe_eff = numel(tmp.name);
if Nbpol_probe_eff > Nbpol_probe_in
IDS_out.magnetics.bpol_probe(Nbpol_probe_in+1:Nbpol_probe_eff) = magnetics_default.bpol_probe(1);
IDS_out.magnetics.bpol_probe(Nbpol_probe_in+1:Nbpol_probe_eff,1) = magnetics_default.bpol_probe(1);
end
for ii=1:Nbpol_probe_eff
IDS_out.magnetics.bpol_probe{ii}.position.r = tmp.r(ii);
......@@ -181,6 +192,7 @@ IDS_out.tf.b_field_tor_vacuum_r.data = LXC.rBt;
cocos_in = 17;
cocos_out = 11;
to_transform = {'pf_active','pf_passive','magnetics','tf','wall','equilibrium'};
to_transform = {'pf_active','magnetics','tf','wall','equilibrium'}; % at this stage pf_passive is empty and not used
for i=1:length(to_transform)
IDS_out.(to_transform{i}) = ids_generic_cocos_nodes_transformation_symbolic(IDS_out.(to_transform{i}), to_transform{i}, cocos_in, cocos_out,[],[],[],[],[],3);
end
......
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