Newer
Older
function [ids_nbi,ids_nbi_description,varargout] = tcv_get_ids_nbi(shot,ids_nbi_empty, gdat_params,varargin);
%
% [ids_nbi,ids_nbi_description,varargout] = tcv_get_ids_nbi(shot,ids_nbi_empty,varargin);
%
%
% gdat_params: gdat_data.gdat_params to get all params passed from original call, in particular error_bar options
%
[ids_nbi, params_nbi] = tcv_ids_headpart(shot,ids_nbi_empty,'nbi','homogeneous_time',0,varargin{:});
% As a general rule, for a new substructure under the main ids, construct a local structure like:
% "global_quantities" with subfields being the relevant data to get and a local structure:
% "global_quantities_desc" which contains the same subfields themselves containing the gdat string aftre shot used
%
nb_units = 2; % assume 2 units: 1st NBH and DNBI
ids_nbi.unit(1:nb_units) = ids_nbi.unit(1); % copy empty structure for all units, then fill in
switch iunit
case 1
ids_nbi.unit{iunit}.identifier = 'NBH1';
ids_nbi.unit{iunit}.name = '25keV 1st NBH source';
%% power
pow=gdat_tcv(shot,'powers');
ids_nbi.unit{iunit}.power_launched.time = pow.nbi.t;
ids_nbi.unit{iunit}.power_launched.data = pow.nbi.data;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
%% energy
ids_nbi.unit{iunit}.energy.time = pow.nbi.t;
ids_nbi.unit{iunit}.energy.data = pow.nbi.energy;
%% power & current fractions
p_frac=gdat(shot,'\results::nbh:fraction');
ids_nbi.unit{iunit}.beam_power_fraction.data = p_frac.data(:,1:3)*0.01;
ids_nbi.unit{iunit}.beam_power_fraction.time = p_frac.t;
i_frac = p_frac.data(:,1:3).*[1 2 3];
i_frac = i_frac.*1./sum(i_frac);
ids_nbi.unit{iunit}.beam_current_fraction.data = i_frac;
ids_nbi.unit{iunit}.beam_current_fraction.time = p_frac.t;
%% species
ids_nbi.unit{iunit}.species.a = 2.;
ids_nbi.unit{iunit}.species.z_n = 1.;
ids_nbi.unit{iunit}.species.label = ['D'];
%% beamlets group, now only one single beamlet
% https://spcwiki.epfl.ch/wiki/NB_Model
ids_nbi.unit{iunit}.beamlets_group{1}.direction = -1; %clockwise
ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius = 736*1e-3; %736mm
% ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius_error_upper: -9.0000e+40
ids_nbi.unit{iunit}.beamlets_group{1}.angle = 0.; %injection parallel to midplane
% ids_nbi.unit{iunit}.beamlets_group{1}.angle_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.angle_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.angle_error_upper: -9.0000e+40
ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal = 250*1e-3;
% ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal_error_upper: -9.0000e+40
ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical = 250*1e-3;
% ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical_error_upper: -9.0000e+40
%% focus struct
focus = struct();
focus.focal_length_horizontal = 3.76;
% focus.focal_length_horizontal_error_index = -999999999;
% focus.focal_length_horizontal_error_lower = -9.0000e+40;
% focus.focal_length_horizontal_error_upper = -9.0000e+40;
focus.focal_length_vertical = 3.98;
% focus.focal_length_vertical_error_index: -999999999;
% focus.focal_length_vertical_error_lower: -9.0000e+40;
% focus.focal_length_vertical_error_upper: -9.0000e+40;
focus.width_min_horizontal = 21.6*1e-2;
% focus.width_min_horizontal_error_index: -999999999;
% focus.width_min_horizontal_error_lower: -9.0000e+40;
% focus.width_min_horizontal_error_upper: -9.0000e+40;
focus.width_min_vertical = 9.4*1e-2;
% focus.width_min_vertical_error_index: -999999999;
% focus.width_min_vertical_error_lower: -9.0000e+40;
% focus.width_min_vertical_error_upper: -9.0000e+40;
ids_nbi.unit{iunit}.beamlets_group{1}.focus = focus;
%% divergence component struct
div = struct();
div.particle_fraction = 1.;
div.vertical = 10.3*1e-3; %rad, in deg it is 0.59
div.horizontal = 24.4*1e-3; %rad, in deg it is 1.4
ids_nbi.unit{iunit}.beamlets_group{1}.divergence_component{1} = div;
%% tilting
% it is fixed in time. what should we do about it?
%% position
%dcd_NBH = psitbxdcd(4.5889, 0.0, 211.9535*pi/180, 0.0, -9.2308*pi/180);
pos = struct();
pos.phi= 211.9535*pi/180.;
% pos.phi_error_index= -999999999;
% pos.phi_error_lower= -9.0000e+40;
% pos.phi_error_upper= -9.0000e+40;
pos.r= 4.5889;
% pos.r_error_index= -999999999;
% pos.r_error_lower= -9.0000e+40;
% pos.r_error_upper= -9.0000e+40;
pos.z= 0.;
% pos.z_error_index= -999999999;
% pos.z_error_lower= -9.0000e+40;
% pos.z_error_upper= -9.0000e+40;
ids_nbi.unit{iunit}.beamlets_group{1}.position = pos;
%% beamlets
% M. Vallar thinks it is useless now
case 2
ids_nbi.unit{iunit}.identifier = 'DNBI';
ids_nbi.unit{iunit}.name = 'diagnostic NBI';
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
%% power
pow=gdat_tcv(shot,'\RESULTS::DNBI:POWR_TCV');
ids_nbi.unit{iunit}.power_launched.time = pow.t;
ids_nbi.unit{iunit}.power_launched.data = pow.data*1e6;
%% energy
en=gdat(shot,'\RESULTS::DNBI:ENERGY');
ids_nbi.unit{iunit}.energy.data = en.data*1e3;
ids_nbi.unit{iunit}.energy.time = en.t;
%% power & current fractions
p_frac=gdat(shot,'\results::dnbi:fraction');
ids_nbi.unit{iunit}.beam_power_fraction.data = p_frac.data(:,1:3)*0.01;
ids_nbi.unit{iunit}.beam_power_fraction.time = p_frac.t;
i_frac = p_frac.data(:,1:3).*[1 2 3];
i_frac = i_frac.*1./sum(i_frac);
ids_nbi.unit{iunit}.beam_current_fraction.data = i_frac(:,:);
ids_nbi.unit{iunit}.beam_current_fraction.time = p_frac.t;
%% species
ids_nbi.unit{iunit}.species.a = 1.;
ids_nbi.unit{iunit}.species.z_n = 1.;
ids_nbi.unit{iunit}.species.label = ['H'];
%% beamlets group, now only one single beamlet
% https://spcwiki.epfl.ch/wiki/NB_Model
ids_nbi.unit{iunit}.beamlets_group{1}.direction = 1; %ctr-clockwise
ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius = 235.3*1e-3; %736mm
% ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.tangency_radius_error_upper: -9.0000e+40
ids_nbi.unit{iunit}.beamlets_group{1}.angle = 0.; %injection parallel to midplane
% ids_nbi.unit{iunit}.beamlets_group{1}.angle_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.angle_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.angle_error_upper: -9.0000e+40
ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal = 87.2*1e-3;
% ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.width_horizontal_error_upper: -9.0000e+40
ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical = 87.2*1e-3;
% ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical_error_index: -999999999
% ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical_error_lower: -9.0000e+40
% ids_nbi.unit{iunit}.beamlets_group{1}.width_vertical_error_upper: -9.0000e+40
%% focus struct
focus = struct();
focus.focal_length_horizontal = 1.8;
% focus.focal_length_horizontal_error_index = -999999999;
% focus.focal_length_horizontal_error_lower = -9.0000e+40;
% focus.focal_length_horizontal_error_upper = -9.0000e+40;
focus.focal_length_vertical = 1.8;
% focus.focal_length_vertical_error_index: -999999999;
% focus.focal_length_vertical_error_lower: -9.0000e+40;
% focus.focal_length_vertical_error_upper: -9.0000e+40;
focus.width_min_horizontal = 12.1*1e-2;
% focus.width_min_horizontal_error_index: -999999999;
% focus.width_min_horizontal_error_lower: -9.0000e+40;
% focus.width_min_horizontal_error_upper: -9.0000e+40;
focus.width_min_vertical = 12.1*1e-2;
% focus.width_min_vertical_error_index: -999999999;
% focus.width_min_vertical_error_lower: -9.0000e+40;
% focus.width_min_vertical_error_upper: -9.0000e+40;
ids_nbi.unit{iunit}.beamlets_group{1}.focus = focus;
%% divergence component struct
div = struct();
div.particle_fraction = 1.;
div.vertical = 9.2*1e-3; %rad, in deg it is 0.53
div.horizontal = 9.2*1e-3; %rad, in deg it is 0.53
ids_nbi.unit{iunit}.beamlets_group{1}.divergence_component{1} = div;
%% tilting
% it is fixed in time. what should we do about it?
%% position
%dcd_NBH = psitbxdcd(4.5889, 0.0, 211.9535*pi/180, 0.0, -9.2308*pi/180);
pos = struct();
pos.phi= 295.2416*pi/180.;
% pos.phi_error_index= -999999999;
% pos.phi_error_lower= -9.0000e+40;
% pos.phi_error_upper= -9.0000e+40;
pos.r= 4.9274;
% pos.r_error_index= -999999999;
% pos.r_error_lower= -9.0000e+40;
% pos.r_error_upper= -9.0000e+40;
pos.z= 0.;
% pos.z_error_index= -999999999;
% pos.z_error_lower= -9.0000e+40;
% pos.z_error_upper= -9.0000e+40;
ids_nbi.unit{iunit}.beamlets_group{1}.position = pos;
%% beamlets
% M. Vallar thinks it is useless now
otherwise
warning(['iunit = ' num2str(iunit) ' not yet defined']);
end
end