Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gdat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPC
gdat
Commits
6335f9bd
Commit
6335f9bd
authored
5 years ago
by
Olivier Sauter
Browse files
Options
Downloads
Patches
Plain Diff
simplify loop over nbh units
avoid duplication of coding
parent
10ea20e9
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Imas codecamp develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/TCV_IMAS/tcv_get_ids_nbi.m
+93
-178
93 additions, 178 deletions
matlab/TCV_IMAS/tcv_get_ids_nbi.m
with
93 additions
and
178 deletions
matlab/TCV_IMAS/tcv_get_ids_nbi.m
+
93
−
178
View file @
6335f9bd
...
...
@@ -17,186 +17,101 @@ ids_nbi_description='';
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
for
iunit
=
1
:
nb_units
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
;
%% 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
)
.*
repmat
([
1
2
3
],
size
(
p_frac
.
data
,
1
),
1
);
% to be compatible with older matlab version .*[1 2 3] not ok
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?
% create lists of what is different for each units so that can scan through units
unit_identifier
=
{
'NBH1'
,
'DNBI'
};
unit_name
=
{
'25keV 1st NBH source'
,
'diagnostic NBI'
};
results_subname
=
{
'nbh'
,
'dnbi'
};
species
.
a
=
[
2.
,
1.
];
species
.
z_n
=
[
1.
,
1.
];
species
.
label
=
{
'D'
,
'H'
};
beamlets_group
.
direction
=
[
-
1
,
1
];
beamlets_group
.
tangency_radius
=
[
736
,
235.3
]
*
1e-3
;
beamlets_group
.
angle
=
[
0.
,
0.
];
beamlets_group
.
width_horizontal
=
[
250
,
87.2
]
*
1e-3
;
beamlets_group
.
width_vertical
=
[
250
,
87.2
]
*
1e-3
;
beamlets_group
.
focus
(
1
:
nb_units
)
=
struct
(
'focal_length_horizontal'
,[],
'focal_length_vertical'
,[],
'width_min_horizontal'
,[],
'width_min_vertical'
,[]);
beamlets_group
.
focus
(
1
)
.
focal_length_horizontal
=
3.76
;
beamlets_group
.
focus
(
1
)
.
focal_length_vertical
=
3.98
;
beamlets_group
.
focus
(
1
)
.
width_min_horizontal
=
21.6
*
1e-2
;
beamlets_group
.
focus
(
1
)
.
width_min_vertical
=
9.4
*
1e-2
;
beamlets_group
.
focus
(
2
)
.
focal_length_horizontal
=
1.8
;
beamlets_group
.
focus
(
2
)
.
focal_length_vertical
=
1.8
;
beamlets_group
.
focus
(
2
)
.
width_min_horizontal
=
12.1
*
1e-2
;
beamlets_group
.
focus
(
2
)
.
width_min_vertical
=
12.1
*
1e-2
;
beamlets_group
.
divergence
(
1
:
nb_units
)
=
struct
(
'particle_fraction'
,[],
'vertical'
,[],
'horizontal'
,[]);
beamlets_group
.
divergence
(
1
)
.
particle_fraction
=
1.
;
beamlets_group
.
divergence
(
1
)
.
vertical
=
0.59
*
pi
/
180.
;
beamlets_group
.
divergence
(
1
)
.
horizontal
=
1.4
*
pi
/
180.
;
beamlets_group
.
divergence
(
2
)
.
particle_fraction
=
1.
;
beamlets_group
.
divergence
(
2
)
.
vertical
=
0.53
*
pi
/
180.
;
beamlets_group
.
divergence
(
2
)
.
horizontal
=
0.53
*
pi
/
180.
;
%% 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
%dcd_NBH = psitbxdcd(4.5889, 0.0, 211.9535*pi/180, 0.0, -9.2308*pi/180);
beamlets_group
.
position
(
1
:
nb_units
)
=
struct
(
'phi'
,[],
'r'
,[],
'z'
,[]);
beamlets_group
.
position
(
1
)
.
phi
=
211.9535
*
pi
/
180.
;
beamlets_group
.
position
(
1
)
.
r
=
4.5889
*
1e-2
;
% in [m]?? OS
beamlets_group
.
position
(
1
)
.
z
=
0.
;
% in [m]?? OS
beamlets_group
.
position
(
2
)
.
phi
=
295.2416
*
pi
/
180.
;
beamlets_group
.
position
(
2
)
.
r
=
4.9274
*
1e-2
;
% in [m]?? OS
beamlets_group
.
position
(
2
)
.
z
=
0.
;
% in [m]?? OS
for
iunit
=
1
:
nb_units
ids_nbi
.
unit
{
iunit
}
.
identifier
=
unit_identifier
{
iunit
};
ids_nbi
.
unit
{
iunit
}
.
name
=
unit_name
{
iunit
};
%% power
pow
=
gdat_tcv
(
shot
,[
'\results::'
results_subname
{
iunit
}
':powr_tcv'
]);
ids_nbi
.
unit
{
iunit
}
.
power_launched
.
data
=
pow
.
data
*
1e6
;
ids_nbi
.
unit
{
iunit
}
.
power_launched
.
time
=
pow
.
t
;
ids_nbi_description
.
unit
{
iunit
}
.
power_launched
=
[
'from \results::'
results_subname
{
iunit
}
':powr_tcv'
];
%% energy
en
=
gdat_tcv
(
shot
,[
'\results::'
results_subname
{
iunit
}
':energy'
]);
ids_nbi
.
unit
{
iunit
}
.
energy
.
data
=
en
.
data
*
1e3
;
ids_nbi
.
unit
{
iunit
}
.
energy
.
time
=
en
.
t
;
ids_nbi_description
.
unit
{
iunit
}
.
energy
=
[
'from \results::'
results_subname
{
iunit
}
':energy'
];
%% power & current fractions
p_frac
=
gdat
(
shot
,[
'\results::'
results_subname
{
iunit
}
':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
;
ids_nbi_description
.
unit
{
iunit
}
.
beam_power_fraction
=
[
'from \results::'
results_subname
{
iunit
}
':fraction'
];
i_frac
=
p_frac
.
data
(:,
1
:
3
)
.*
repmat
([
1
2
3
],
size
(
p_frac
.
data
,
1
),
1
);
% to be compatible with older matlab version .*[1 2 3] not ok
i_frac
=
i_frac
.*
1.
/
repmat
(
sum
(
i_frac
),
size
(
p_frac
.
data
,
1
),
1
);
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
=
species
.
a
(
iunit
);
ids_nbi
.
unit
{
iunit
}
.
species
.
z_n
=
species
.
z_n
(
iunit
);
ids_nbi
.
unit
{
iunit
}
.
species
.
label
=
species
.
label
{
iunit
};
%% beamlets group, now only one single beamlet
% https://spcwiki.epfl.ch/wiki/NB_Model
ids_nbi
.
unit
{
iunit
}
.
beamlets_group
{
1
}
.
direction
=
beamlets_group
.
direction
(
iunit
);
%clockwise
ids_nbi
.
unit
{
iunit
}
.
beamlets_group
{
1
}
.
tangency_radius
=
beamlets_group
.
tangency_radius
(
iunit
);
% 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
=
beamlets_group
.
angle
(
iunit
);
%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
=
beamlets_group
.
width_horizontal
(
iunit
);
% 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
=
beamlets_group
.
width_vertical
(
iunit
);
% 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
ids_nbi
.
unit
{
iunit
}
.
beamlets_group
{
1
}
.
focus
=
beamlets_group
.
focus
(
iunit
);
%% divergence component struct
ids_nbi
.
unit
{
iunit
}
.
beamlets_group
{
1
}
.
divergence_component
{
1
}
=
beamlets_group
.
divergence
(
iunit
);
%% tilting
% it is fixed in time. what should we do about it?
case
2
ids_nbi
.
unit
{
iunit
}
.
identifier
=
'DNBI'
;
ids_nbi
.
unit
{
iunit
}
.
name
=
'diagnostic NBI'
;
%% 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
ids_nbi
.
unit
{
iunit
}
.
beamlets_group
{
1
}
.
position
=
beamlets_group
.
position
(
iunit
);
%% 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
%% beamlets
% M. Vallar thinks it is useless now
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment