Skip to content
Snippets Groups Projects
Commit c49e10c3 authored by Chatzilouka Aliki's avatar Chatzilouka Aliki Committed by Antonia Frank
Browse files

some variable name changes to clean up code

parent 8598a6e5
No related branches found
No related tags found
1 merge request!137Add quantities to ids for MRE
...@@ -40,7 +40,7 @@ powers_gdat = gdat(shot,'powers'); ...@@ -40,7 +40,7 @@ powers_gdat = gdat(shot,'powers');
last_index = 0; last_index = 0;
%% initialize source from template %% initialize source from template
% ohm % ohm
ohm_t_grid = powers_gdat.ohm.t; ohm_n_t = numel(ohm_t_grid); t_spacing = mean(diff(ohm_t_grid)); ohm_t_grid = powers_gdat.ohm.t; ohm_n_t = numel(ohm_t_grid);
id_ohm.description = 'Source from ohmic heating'; id_ohm.description = 'Source from ohmic heating';
id_ohm.index = 7; id_ohm.name = 'ohmic'; id_ohm.index = 7; id_ohm.name = 'ohmic';
...@@ -66,18 +66,20 @@ end ...@@ -66,18 +66,20 @@ end
last_index = last_index+1; % add if statement to only increment if ohmic source has been added last_index = last_index+1; % add if statement to only increment if ohmic source has been added
%% bs %% bs
bs_gdat = gdat(shot,'bs_data'); bs_data = bs_gdat.bs.bs_data;
bs_t_grid = bs_gdat.bs.t; bs_n_t = numel(bs_t_grid);
id_bs.description = 'Bootstrap current'; id_bs.description = 'Bootstrap current';
id_bs.index = 13; id_bs.name = 'bootstrap_current'; id_bs.index = 13; id_bs.name = 'bootstrap_current';
ids_core_sources.source{last_index+1} = source_template; ids_core_sources.source{last_index+1} = source_template;
ids_core_sources.source{last_index+1}.identifier = id_bs; ids_core_sources.source{last_index+1}.identifier = id_bs;
ids_core_sources.source{last_index+1}.profiles_1d(1:ohm_n_t) = {profiles_template}; ids_core_sources.source{last_index+1}.profiles_1d(1:ohm_n_t) = {profiles_template};
ids_core_sources.source{last_index+1}.global_quantities(1:ohm_n_t) = {globals_template}; ids_core_sources.source{last_index+1}.global_quantities(1:ohm_n_t) = {globals_template};
% load data
bs_gdat = gdat(shot,'bs_data'); bs_data = bs_gdat.bs.bs_data;
% fill profiles for times n t_grid % fill profiles for times n t_grid
for ii = 1:ohm_n_t for ii = 1:bs_n_t
ids_core_sources.source{last_index+1}.profiles_1d{ii}.time = ohm_t_grid(ii); ids_core_sources.source{last_index+1}.profiles_1d{ii}.time = bs_t_grid(ii);
ids_core_sources.source{last_index+1}.profiles_1d{ii}.j_parallel = ... ids_core_sources.source{last_index+1}.profiles_1d{ii}.j_parallel = ...
bs_data.cd_dens.data(:,ii)'; bs_data.cd_dens.data(:,ii)';
end end
...@@ -88,16 +90,17 @@ last_index = last_index+1; % add if statement to only increment if bs source ha ...@@ -88,16 +90,17 @@ last_index = last_index+1; % add if statement to only increment if bs source ha
% load data % load data
ec_gdat = gdat(shot,'ec_data'); ec_data = ec_gdat.ec.ec_data; ec_gdat = gdat(shot,'ec_data'); ec_data = ec_gdat.ec.ec_data;
ec_time = ec_data.p_dens.t; ec_time = ec_data.p_dens.t;
ec_t_grid = powers_gdat.ec.t; ec_n_t = numel(ec_t_grid); t_spacing = mean(diff(ec_t_grid)); n_ec_time = numel(ec_time);
ec_t_grid = powers_gdat.ec.t; ec_n_t = numel(ec_t_grid);
nb_launchers = size(ec_gdat.ec.ec_data.rho_max_pow_dens.data,1); nb_launchers = size(ec_gdat.ec.ec_data.rho_max_pow_dens.data,1);
id_ec.description = 'Sources from electron cyclotron heating and current drive'; id_ec.description = 'Sources from electron cyclotron heating and current drive';
id_ec.index = 3; id_ec.name = 'ec'; id_ec.index = 3; id_ec.name = 'ec';
for i = 1:nb_launchers for i_lau = 1:nb_launchers
ids_core_sources.source{last_index+i} = source_template; ids_core_sources.source{last_index+i_lau} = source_template;
ids_core_sources.source{last_index+i}.identifier = id_ec; ids_core_sources.source{last_index+i_lau}.identifier = id_ec;
ids_core_sources.source{last_index+i}.profiles_1d(1:ec_n_t) = {profiles_template}; ids_core_sources.source{last_index+i_lau}.profiles_1d(1:ec_n_t) = {profiles_template};
ids_core_sources.source{last_index+i}.global_quantities(1:ec_n_t) = {globals_template}; ids_core_sources.source{last_index+i_lau}.global_quantities(1:ec_n_t) = {globals_template};
end end
ec_total_pow = transpose(powers_gdat.ec.data(:,nb_launchers+1)); %use power from powers_gdat(injected ec power) instead of ec_data power ec_total_pow = transpose(powers_gdat.ec.data(:,nb_launchers+1)); %use power from powers_gdat(injected ec power) instead of ec_data power
...@@ -105,15 +108,15 @@ ec_total_pow(isnan(ec_total_pow)) = 0; ...@@ -105,15 +108,15 @@ ec_total_pow(isnan(ec_total_pow)) = 0;
ec_total_cur = ec_data.cd_tot.data(nb_launchers+1,:); ec_total_cur = ec_data.cd_tot.data(nb_launchers+1,:);
ec_total_cur(isnan(ec_total_cur)) = 0; ec_total_cur(isnan(ec_total_cur)) = 0;
for i = 1:nb_launchers for i_lau = 1:nb_launchers
for ii = 1:ec_n_t for ii = 1:ec_n_t
ids_core_sources.source{last_index+i}.profiles_1d{ii}.time = ec_t_grid(ii); % profiles time ids_core_sources.source{last_index+i_lau}.profiles_1d{ii}.time = ec_t_grid(ii); % profiles time
ids_core_sources.source{last_index+i}.global_quantities{ii}.time = ec_t_grid(ii); % globals time ids_core_sources.source{last_index+i_lau}.global_quantities{ii}.time = ec_t_grid(ii); % globals time
% globals % globals
ids_core_sources.source{last_index+i}.global_quantities{ii}.time = ec_t_grid(ii); ids_core_sources.source{last_index+i_lau}.global_quantities{ii}.time = ec_t_grid(ii);
ids_core_sources.source{last_index+i}.global_quantities{ii}.power = ec_total_pow(ii); ids_core_sources.source{last_index+i_lau}.global_quantities{ii}.power = ec_total_pow(ii);
ids_core_sources.source{last_index+i}.global_quantities{ii}.current_parallel = ec_total_cur(ii); ids_core_sources.source{last_index+i_lau}.global_quantities{ii}.current_parallel = ec_total_cur(ii);
end end
end end
...@@ -127,17 +130,17 @@ cd_integrated = ec_data.cd_integrated.data; ...@@ -127,17 +130,17 @@ cd_integrated = ec_data.cd_integrated.data;
p_ec_injected = powers_gdat.ec.data; p_ec_injected = powers_gdat.ec.data;
it = iround_os(ec_t_grid,ec_time); it = iround_os(ec_t_grid,ec_time);
sparse_p_ec_injected = p_ec_injected(it,:); % injected ec power vals corresponding to ec_time grid sparse_p_ec_injected = p_ec_injected(it,:); % injected ec power vals corresponding to ec_time grid
rho_grid = size(p_dens, 1);
% calculate normalised profiles on ec_time grid % calculate normalised profiles on ec_time grid
norm_p_dens = zeros(size(p_dens, 1), nb_launchers+1, length(ec_time)); norm_p_dens = zeros(rho_grid, nb_launchers+1, n_ec_time);
norm_p_integrated = zeros(size(p_integrated, 1), nb_launchers+1, length(ec_time)); norm_p_integrated = zeros(rho_grid, nb_launchers+1, n_ec_time);
norm_cd_dens = zeros(size(cd_dens, 1), nb_launchers+1, length(ec_time)); norm_cd_dens = zeros(rho_grid, nb_launchers+1, n_ec_time);
norm_cd_integrated = zeros(size(cd_integrated, 1), nb_launchers+1, length(ec_time)); norm_cd_integrated = zeros(rho_grid, nb_launchers+1, n_ec_time);
for t = 1:length(ec_time) for t = 1:n_ec_time
norm_p_dens_temp = zeros(size(p_dens, 1), nb_launchers+1); norm_p_dens_temp = zeros(rho_grid, nb_launchers+1);
norm_p_integrated_temp = zeros(size(p_integrated, 1), nb_launchers+1); norm_p_integrated_temp = zeros(rho_grid, nb_launchers+1);
norm_cd_dens_temp = zeros(size(cd_dens, 1), nb_launchers+1); norm_cd_dens_temp = zeros(rho_grid, nb_launchers+1);
norm_cd_integrated_temp = zeros(size(cd_integrated, 1), nb_launchers+1); norm_cd_integrated_temp = zeros(rho_grid, nb_launchers+1);
for launcher = 1:nb_launchers+1 for launcher = 1:nb_launchers+1
norm_p_dens_temp(:, launcher) = p_dens(:, launcher, t) ./ sparse_p_ec_injected(t, launcher); norm_p_dens_temp(:, launcher) = p_dens(:, launcher, t) ./ sparse_p_ec_injected(t, launcher);
norm_p_integrated_temp(:, launcher) = p_integrated(:, launcher, t) ./ sparse_p_ec_injected(t, launcher); norm_p_integrated_temp(:, launcher) = p_integrated(:, launcher, t) ./ sparse_p_ec_injected(t, launcher);
...@@ -151,12 +154,12 @@ for t = 1:length(ec_time) ...@@ -151,12 +154,12 @@ for t = 1:length(ec_time)
end end
% interpolate normalised p_dens profiles on ec_t_grid % interpolate normalised p_dens profiles on ec_t_grid
interp_norm_p_dens = zeros(size(norm_p_dens, 1), size(norm_p_dens, 2), ec_n_t); interp_norm_p_dens = zeros(rho_grid, nb_launchers+1, ec_n_t);
interp_norm_p_integrated = zeros(size(norm_p_integrated, 1), size(norm_p_integrated, 2), ec_n_t); interp_norm_p_integrated = zeros(rho_grid, nb_launchers+1, ec_n_t);
interp_norm_cd_dens = zeros(size(norm_cd_dens, 1), size(norm_cd_dens, 2), ec_n_t); interp_norm_cd_dens = zeros(rho_grid, nb_launchers+1, ec_n_t);
interp_norm_cd_integrated = zeros(size(norm_cd_integrated, 1), size(norm_cd_integrated, 2), ec_n_t); interp_norm_cd_integrated = zeros(rho_grid, nb_launchers+1, ec_n_t);
for rho = 1:size(norm_p_dens, 1) for rho = 1:rho_grid
for launcher = 1:size(norm_p_dens, 2) for launcher = 1:nb_launchers+1
profile_p_dens = squeeze(norm_p_dens(rho, launcher, :)); profile_p_dens = squeeze(norm_p_dens(rho, launcher, :));
profile_p_integrated = squeeze(norm_p_integrated(rho, launcher, :)); profile_p_integrated = squeeze(norm_p_integrated(rho, launcher, :));
profile_cd_dens = squeeze(norm_cd_dens(rho, launcher, :)); profile_cd_dens = squeeze(norm_cd_dens(rho, launcher, :));
...@@ -173,15 +176,15 @@ for rho = 1:size(norm_p_dens, 1) ...@@ -173,15 +176,15 @@ for rho = 1:size(norm_p_dens, 1)
end end
% normalised & interpolated profiles * p_ec_injected on ec_t_grid % normalised & interpolated profiles * p_ec_injected on ec_t_grid
interp_p_dens = zeros(size(interp_norm_p_dens, 1), size(interp_norm_p_dens, 2), ec_n_t); interp_p_dens = zeros(rho_grid, nb_launchers+1, ec_n_t);
interp_p_integrated = zeros(size(interp_norm_p_integrated, 1), size(interp_norm_p_integrated, 2), ec_n_t); interp_p_integrated = zeros(rho_grid, nb_launchers+1, ec_n_t);
interp_cd_dens = zeros(size(interp_norm_cd_dens, 1), size(interp_norm_cd_dens, 2), ec_n_t); interp_cd_dens = zeros(rho_grid, nb_launchers+1, ec_n_t);
interp_cd_integrated = zeros(size(interp_norm_cd_integrated, 1), size(interp_norm_cd_integrated, 2), ec_n_t); interp_cd_integrated = zeros(rho_grid, nb_launchers+1, ec_n_t);
for t = 1:length(ec_t_grid) for t = 1:numel(ec_t_grid)
unnormalised_p_dens = zeros(size(p_dens, 1), nb_launchers+1); unnormalised_p_dens = zeros(rho_grid, nb_launchers+1);
unnormalised_p_integrated = zeros(size(p_integrated, 1), nb_launchers+1); unnormalised_p_integrated = zeros(rho_grid, nb_launchers+1);
unnormalised_cd_dens = zeros(size(cd_dens, 1), nb_launchers+1); unnormalised_cd_dens = zeros(rho_grid, nb_launchers+1);
unnormalised_cd_integrated = zeros(size(cd_integrated, 1), nb_launchers+1); unnormalised_cd_integrated = zeros(rho_grid, nb_launchers+1);
for launcher = 1:nb_launchers+1 for launcher = 1:nb_launchers+1
unnormalised_p_dens(:,launcher) = interp_norm_p_dens(:,launcher,t).* p_ec_injected(t, launcher); unnormalised_p_dens(:,launcher) = interp_norm_p_dens(:,launcher,t).* p_ec_injected(t, launcher);
unnormalised_p_integrated(:,launcher) = interp_norm_p_integrated(:,launcher,t).* p_ec_injected(t, launcher); unnormalised_p_integrated(:,launcher) = interp_norm_p_integrated(:,launcher,t).* p_ec_injected(t, launcher);
...@@ -233,7 +236,7 @@ id_total.index = 1; id_total.name = 'total'; ...@@ -233,7 +236,7 @@ id_total.index = 1; id_total.name = 'total';
%% add descriptions for profiles_1d %% add descriptions for profiles_1d
desc.source = 'available by now, 1:total, 3:ec, 7:ohm, 13:bootstrap'; desc.source = 'available by now: ohm [id=7], bootstrap [id=13], ec [id=3] (if present in shot)';
desc.profiles_1d.j_parallel = 'parallel current density'; desc.profiles_1d.j_parallel = 'parallel current density';
desc.profiles_1d.current_parallel_inside = 'integrated parallel current density'; desc.profiles_1d.current_parallel_inside = 'integrated parallel current density';
desc.globals.power = 'total power coupled to the plasma'; desc.globals.power = 'total power coupled to the plasma';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment