test_remote_imas

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 close all
0002 clear all
0003 clc
0004 %
0005 % IMAS read WEST equilibrium
0006 %
0007 imas.version = '3';
0008 imas.user = 'imas_public';%database
0009 imas.machine = 'west';%machine name
0010 imas.shot = 53223;%shot number
0011 imas.run = 0;
0012 imas.time_requested = 37;%absolute time at which data are read (s)
0013 imas.command = 'ids_get_slice';%IMAS command
0014 imas.matlabpath = '/Applications/Matlab_2013B/bin/matlab';%Matlab version used by IMAS
0015 imas.remote_profile = 'CEA_ANDROMEDE';%Remote profile for reading data (CEA_SIRRAH or CEA_ANDROMEDE for WEST/TORE SUPRA)
0016 imas.remote_enforce = 1;%Enforce remote connection (1) or not (0)
0017 %
0018 % Other parameters
0019 %
0020 Z_for_R_plot     = 50; %Percentage for plot in cartesian grid
0021 Font_size_graphs = 14;
0022 %
0023 % Prints
0024 %
0025 fprintf('shot     = %d \n', imas.shot);
0026 fprintf('run      = %d \n', imas.run);
0027 fprintf('user     = %s \n', imas.user);
0028 fprintf('machine  = %s \n', imas.machine);
0029 fprintf('time_req = %f \n', imas.time_requested);
0030 %
0031 % read data in IMAS database
0032 %
0033 imas.data.type = 'equilibrium';%data type
0034 imas.data.value = '';%leave empty if read (not used when reading database)
0035 %
0036 equi  = remote_imas(imas);
0037 if isempty(equi),
0038     error('Problem reading equilibrium structure in IMAS database');
0039 else
0040     imas.data.type = 'core_profiles';%data type
0041     imas.data.value = '';%leave empty if read (not used when reading database)
0042     %
0043     corep  = remote_imas(imas);
0044     if isempty(corep),
0045         error('Problem reading core_profiles structure in IMAS database');
0046     end
0047 end
0048 %
0049 % For METIS run:
0050 %
0051 nbr_points = length(equi.time_slice{1,1}.ggd{1,1}.r{1,1}.values);
0052 flag_equinox = 0;
0053 if nbr_points==0
0054   % For EQUINOX run:
0055   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
0056   flag_equinox = 1;
0057 end
0058 
0059 R_nodes = zeros(1, nbr_points);
0060 Z_nodes = zeros(1, nbr_points);
0061 Psi_val = zeros(1, nbr_points);
0062 B_R     = zeros(1, nbr_points);
0063 B_Z     = zeros(1, nbr_points);
0064 B_tor   = zeros(1, nbr_points);
0065 for i=1:nbr_points
0066  
0067     % For EQUINOX run:
0068     if flag_equinox,
0069       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);
0070       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);
0071     else
0072       % For METIS run:
0073       R_nodes(i) = equi.time_slice{1,1}.ggd{1,1}.r{1,1}.values(i);
0074       Z_nodes(i) = equi.time_slice{1,1}.ggd{1,1}.z{1,1}.values(i);
0075     end
0076 
0077     Psi_val(i) = equi.time_slice{1,1}.ggd{1,1}.psi{1,1}.values(i);
0078     B_R(i)     = equi.time_slice{1,1}.ggd{1,1}.b_field_r{1,1}.values(i);
0079     B_Z(i)     = equi.time_slice{1,1}.ggd{1,1}.b_field_z{1,1}.values(i);
0080     B_tor(i)   = equi.time_slice{1,1}.ggd{1,1}.b_field_tor{1,1}.values(i);
0081 end
0082 
0083 [Rq, Zq] = meshgrid(linspace(min(R_nodes), max(R_nodes), 100), ...
0084                     linspace(min(Z_nodes), max(Z_nodes), 100));
0085 
0086 B_NORM = sqrt(B_R.^2 + B_Z.^2 + B_tor.^2);
0087 
0088 Psi_interp    = griddata(R_nodes, Z_nodes, Psi_val, Rq, Zq);
0089 B_NORM_interp = griddata(R_nodes, Z_nodes, B_NORM,  Rq, Zq);
0090 
0091 % Plot data
0092 fig1 = figure(1);
0093 subplot(2, 3, 1); plot(equi.time_slice{1,1}.profiles_1d.rho_tor, ...
0094                        equi.time_slice{1,1}.profiles_1d.q, ...
0095                        '-o', 'LineWidth', 1.5);
0096 grid on;
0097 set(gca, 'FontSize', Font_size_graphs);
0098 xlabel('Rho_{tor} [m]', 'FontSize', Font_size_graphs);
0099 ylabel('q', 'FontSize', Font_size_graphs);
0100 
0101 subplot(2, 3, 2); plot(Rq(Z_for_R_plot,:), ...
0102                        B_NORM_interp(Z_for_R_plot,:), ...
0103                        '-o', 'LineWidth', 1.5);
0104 grid on;
0105 set(gca, 'FontSize', Font_size_graphs);
0106 xlabel('R [m]', 'FontSize', Font_size_graphs);
0107 ylabel(['B NORM [T] at Z=', num2str(Zq(Z_for_R_plot), '%5.4f'), ' m'], ...
0108     'FontSize', Font_size_graphs);
0109 
0110 subplot(2, 3, 3); contour(Rq, Zq, Psi_interp, 30, 'b', 'LineWidth', 1);
0111 axis equal;
0112 grid on;
0113 set(gca, 'FontSize', Font_size_graphs);
0114 xlabel('R [m]', 'FontSize', Font_size_graphs);
0115 ylabel('Z [m]', 'FontSize', Font_size_graphs);
0116 title('Psi', 'FontSize', Font_size_graphs);
0117 
0118 
0119 %subplot(2, 3, 4); surf(Rq, Zq, B_NORM_interp);
0120 %axis equal;
0121 %shading interp;
0122 %view(0, 90);
0123 %grid on;
0124 %set(gca, 'FontSize', Font_size_graphs);
0125 %xlabel('R [m]', 'FontSize', Font_size_graphs);
0126 %ylabel('Z [m]', 'FontSize', Font_size_graphs);
0127 %title('B NORM [T]', 'FontSize', Font_size_graphs);
0128 %colorbar;
0129 
0130 subplot(2, 3, 5); plot(corep.profiles_1d{1,1}.grid.rho_tor_norm, ...
0131                        corep.profiles_1d{1,1}.electrons.density, ...
0132                        '-xr', 'LineWidth', 1.5);
0133 grid on;
0134 set(gca, 'FontSize', Font_size_graphs);
0135 xlabel('Rho_{tor norm}', 'FontSize', Font_size_graphs);
0136 ylabel('n_{e} [m^{-3}]', 'FontSize', Font_size_graphs);
0137 
0138 subplot(2, 3, 6); plot(corep.profiles_1d{1,1}.grid.rho_tor_norm, ...
0139                        corep.profiles_1d{1,1}.electrons.temperature, ...
0140                        '-sk', 'LineWidth', 1.5);
0141 grid on;
0142 set(gca, 'FontSize', Font_size_graphs);
0143 xlabel('Rho_{tor norm}', 'FontSize', Font_size_graphs);
0144 ylabel('T_{i} [eV]', 'FontSize', Font_size_graphs);
0145 
0146 % Save figure in png format
0147 saveas(fig1, ['Matlab_equi_corep_IMAS_Time', num2str(imas.time_requested), ...
0148     '_Shot', num2str(imas.shot), '_Run', num2str(imas.run), '_', imas.machine, '_', ...
0149     imas.user, '.png'], 'png');

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