27 for(
int i=0; i<offload_data->
ninj; i++) {
30 offload_data->
power[i]);
32 " Anum %d Znum %d mass %1.1e amu energy %1.1e eV\n",
33 offload_data->
anum[i], offload_data->
znum[i],
37 " Energy fractions: %1.1e (Full) %1.1e (1/2) %1.1e (1/3)\n",
38 offload_data->
efrac[0], offload_data->
efrac[1],
39 offload_data->
efrac[2]);
60 real* offload_array) {
63 for(
int i=0; i<nbi->
ninj; i++) {
77 nbi->
inj[i].
id = offload_data->
id[i];
81 nbi->
inj[i].
beamlet_x = &(offload_array[idx + 0*n_beamlet]);
82 nbi->
inj[i].
beamlet_y = &(offload_array[idx + 1*n_beamlet]);
83 nbi->
inj[i].
beamlet_z = &(offload_array[idx + 2*n_beamlet]);
98 real** offload_array) {
99 for(
int i=0; i<offload_data->
ninj; i++) {
102 offload_data->
ninj = 0;
103 free(*offload_array);
124 if(r < inj->efrac[0]) {
126 }
else if(r < inj->efrac[0] + inj->
efrac[1]) {
133 real dir[3], normalv[3], normalh[3], tmp[3];
138 real phi = atan2(dir[1], dir[0]);
139 real theta = acos(dir[2]);
141 normalv[0] = sin(theta+
CONST_PI/2) * cos(phi);
142 normalv[1] = sin(theta+
CONST_PI/2) * sin(phi);
165 tmp[0] = cos(div_h) * ( cos(div_v) * dir[0] + sin(div_v) * normalv[0] )
166 + sin(div_h) * normalh[0];
167 tmp[1] = cos(div_h) * ( cos(div_v) * dir[1] + sin(div_v) * normalv[1] )
168 + sin(div_h) * normalh[1];
169 tmp[2] = cos(div_h) * ( cos(div_v) * dir[2] + sin(div_v) * normalv[2] )
170 + sin(div_h) * normalh[2];
174 real absv = sqrt( 1.0 - 1.0 / (gamma * gamma) ) *
CONST_C;
175 vxyz[0] = absv * dir[0];
176 vxyz[1] = absv * dir[1];
177 vxyz[2] = absv * dir[2];
Main header file for ASCOT5.
Header file containing physical and mathematical constants.
#define CONST_U
Atomic mass unit in kilograms [kg]
#define CONST_C
Speed of light [m/s]
#define CONST_E
Elementary charge [C]
#define math_unit(a, b)
Calculate unit vector b from a 3D vector a.
#define math_cross(a, b, c)
Calculate cross product for 3D vectors c = a x b.
void nbi_free_offload(nbi_offload_data *offload_data, real **offload_array)
Free offload array.
void nbi_init(nbi_data *nbi, nbi_offload_data *offload_data, real *offload_array)
Initialize NBI data struct on target.
int nbi_init_offload(nbi_offload_data *offload_data, real **offload_array)
Load NBI data and prepare parameters for offload.
void nbi_inject(real *xyz, real *vxyz, nbi_injector *inj, random_data *rng)
Sample injected marker's coordinates.
Methods to evaluate elementary physical quantities.
#define physlib_gamma_Ekin(m, ekin)
Evaluate Lorentz factor from kinetic energy [J].
Macros for printing console output.
#define print_out(v,...)
Print to standard output.
Header file for random.c.
#define random_uniform(data)
#define random_normal(data)
nbi_injector inj[NBI_MAX_INJ]
Structure for describing an NBI injector.
NBI parameters consisting of a bundle of injectors.
real div_halo_v[NBI_MAX_INJ]
real div_halo_h[NBI_MAX_INJ]
int n_beamlet[NBI_MAX_INJ]
real div_halo_frac[NBI_MAX_INJ]
real efrac[NBI_MAX_INJ *3]