test_imas_west

PURPOSE ^

IMAS read WEST equilibrium

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 IMAS read WEST equilibrium

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % IMAS read WEST equilibrium
0002 
0003 % IMAS parameters
0004 % For METIS example run:
0005 %shot    = 53259;
0006 shot    = 53223;
0007 run     = 0;
0008 % For EQUINOX example run:
0009 %shot    = 52705;
0010 %run     = 0;
0011 
0012 user    = 'imas_public';
0013 machine = 'west';
0014 time_requested = 37;%absolute time
0015 
0016 % Other parameters
0017 Z_for_R_plot     = 50; %Percentage for plot in cartesian grid
0018 Font_size_graphs = 14;
0019 
0020 % Prints
0021 fprintf('shot     = %d \n', shot);
0022 fprintf('run      = %d \n', run);
0023 fprintf('user     = %s \n', user);
0024 fprintf('machine  = %s \n', machine);
0025 fprintf('time_req = %f \n', time_requested);
0026 
0027 % Open IMAS file: function imas_open_env('ids', shot, run, user, machine, imas_version_number);
0028 idx = imas_open_env('ids', shot, run, user, machine, '3');
0029 
0030 % Function ids_get_slice(id_from_imas_open, IDS_name, time_requested, interpolation_method)
0031 % -interpolation_method: 1 = closest time, 2 = previous time, 3 = linear interpolation
0032 equi  = ids_get_slice(idx, 'equilibrium', time_requested, 1);
0033 corep = ids_get_slice(idx, 'core_profiles', time_requested, 1);
0034 
0035 
0036 
0037 % For METIS run:
0038 nbr_points = length(equi.time_slice{1,1}.ggd{1,1}.r{1,1}.values);
0039 flag_equinox = 0;
0040 if nbr_points==0
0041   % For EQUINOX run:
0042   nbr_points = length(equi.time_slice{1,1}.ggd{1,1}.grid.space{1,1}.objects_per_dimension{1,1}.object);%inside and outside separatrix
0043   flag_equinox = 1;
0044 end
0045 
0046 R_nodes = zeros(1, nbr_points);
0047 Z_nodes = zeros(1, nbr_points);
0048 Psi_val = zeros(1, nbr_points);
0049 B_R     = zeros(1, nbr_points);
0050 B_Z     = zeros(1, nbr_points);
0051 B_tor   = zeros(1, nbr_points);
0052 for i=1:nbr_points
0053  
0054     % For EQUINOX run:
0055     if flag_equinox,
0056       R_nodes(i) = equi.time_slice{1,1}.ggd{1,1}.grid.space{1,1}.objects_per_dimension{1,1}.object{1,i}.geometry(1);
0057       Z_nodes(i) = equi.time_slice{1,1}.ggd{1,1}.grid.space{1,1}.objects_per_dimension{1,1}.object{1,i}.geometry(2);
0058     else
0059       % For METIS run:
0060       R_nodes(i) = equi.time_slice{1,1}.ggd{1,1}.r{1,1}.values(i);
0061       Z_nodes(i) = equi.time_slice{1,1}.ggd{1,1}.z{1,1}.values(i);
0062     end
0063 
0064     Psi_val(i) = equi.time_slice{1,1}.ggd{1,1}.psi{1,1}.values(i);
0065     B_R(i)     = equi.time_slice{1,1}.ggd{1,1}.b_field_r{1,1}.values(i);
0066     B_Z(i)     = equi.time_slice{1,1}.ggd{1,1}.b_field_z{1,1}.values(i);
0067     B_tor(i)   = equi.time_slice{1,1}.ggd{1,1}.b_field_tor{1,1}.values(i);
0068 end
0069 
0070 [Rq, Zq] = meshgrid(linspace(min(R_nodes), max(R_nodes), 100), ...
0071                     linspace(min(Z_nodes), max(Z_nodes), 100));
0072 
0073 B_NORM = sqrt(B_R.^2 + B_Z.^2 + B_tor.^2);
0074 
0075 Psi_interp    = griddata(R_nodes, Z_nodes, Psi_val, Rq, Zq);
0076 B_NORM_interp = griddata(R_nodes, Z_nodes, B_NORM,  Rq, Zq);
0077 
0078 % Plot data
0079 fig1 = figure(1);
0080 subplot(2, 3, 1); plot(equi.time_slice{1,1}.profiles_1d.rho_tor, ...
0081                        equi.time_slice{1,1}.profiles_1d.q, ...
0082                        '-o', 'LineWidth', 1.5);
0083 grid on;
0084 set(gca, 'FontSize', Font_size_graphs);
0085 xlabel('Rho_{tor} [m]', 'FontSize', Font_size_graphs);
0086 ylabel('q', 'FontSize', Font_size_graphs);
0087 
0088 subplot(2, 3, 2); plot(Rq(Z_for_R_plot,:), ...
0089                        B_NORM_interp(Z_for_R_plot,:), ...
0090                        '-o', 'LineWidth', 1.5);
0091 grid on;
0092 set(gca, 'FontSize', Font_size_graphs);
0093 xlabel('R [m]', 'FontSize', Font_size_graphs);
0094 ylabel(['B NORM [T] at Z=', num2str(Zq(Z_for_R_plot), '%5.4f'), ' m'], ...
0095     'FontSize', Font_size_graphs);
0096 
0097 subplot(2, 3, 3); contour(Rq, Zq, Psi_interp, 30, 'b', 'LineWidth', 1);
0098 axis equal;
0099 grid on;
0100 set(gca, 'FontSize', Font_size_graphs);
0101 xlabel('R [m]', 'FontSize', Font_size_graphs);
0102 ylabel('Z [m]', 'FontSize', Font_size_graphs);
0103 title('Psi', 'FontSize', Font_size_graphs);
0104 
0105 
0106 %subplot(2, 3, 4); surf(Rq, Zq, B_NORM_interp);
0107 %axis equal;
0108 %shading interp;
0109 %view(0, 90);
0110 %grid on;
0111 %set(gca, 'FontSize', Font_size_graphs);
0112 %xlabel('R [m]', 'FontSize', Font_size_graphs);
0113 %ylabel('Z [m]', 'FontSize', Font_size_graphs);
0114 %title('B NORM [T]', 'FontSize', Font_size_graphs);
0115 %colorbar;
0116 
0117 subplot(2, 3, 5); plot(corep.profiles_1d{1,1}.grid.rho_tor_norm, ...
0118                        corep.profiles_1d{1,1}.electrons.density, ...
0119                        '-xr', 'LineWidth', 1.5);
0120 grid on;
0121 set(gca, 'FontSize', Font_size_graphs);
0122 xlabel('Rho_{tor norm}', 'FontSize', Font_size_graphs);
0123 ylabel('n_{e} [m^{-3}]', 'FontSize', Font_size_graphs);
0124 
0125 subplot(2, 3, 6); plot(corep.profiles_1d{1,1}.grid.rho_tor_norm, ...
0126                        corep.profiles_1d{1,1}.electrons.temperature, ...
0127                        '-sk', 'LineWidth', 1.5);
0128 grid on;
0129 set(gca, 'FontSize', Font_size_graphs);
0130 xlabel('Rho_{tor norm}', 'FontSize', Font_size_graphs);
0131 ylabel('T_{i} [eV]', 'FontSize', Font_size_graphs);
0132 
0133 % Save figure in png format
0134 saveas(fig1, ['Matlab_equi_corep_IMAS_Time', num2str(time_requested), ...
0135     '_Shot', num2str(shot), '_Run', num2str(run), '_', machine, '_', ...
0136     user, '.png'], 'png');

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