ASCOT5
Loading...
Searching...
No Matches
step_gceom.h
Go to the documentation of this file.
1
5#ifndef STEP_GCEOM_H
6#define STEP_GCEOM_H
7
8#include <math.h>
9#include "../../ascot5.h"
10#include "../../consts.h"
11#include "../../math.h"
12#include "../../physlib.h"
13
14
27DECLARE_TARGET_SIMD
28inline static void step_gceom(real* ydot, real* y, real mass, real charge,
29 real* B_dB, real* E, int aldforce) {
30
31 real B[3];
32 B[0] = B_dB[0];
33 B[1] = B_dB[4];
34 B[2] = B_dB[8];
35
36 real normB = sqrt(math_dot(B, B));
37 real gamma = physlib_gamma_ppar(mass, y[4], y[3], normB);
38
39 real gradB[3];
40 gradB[0] = (B[0]*B_dB[1] + B[1]*B_dB[5] + B[2]*B_dB[9]) / normB;
41 gradB[1] = (B[0]*B_dB[2] + B[1]*B_dB[6] + B[2]*B_dB[10])
42 / (normB * y[0]);
43 gradB[2] = (B[0]*B_dB[3] + B[1]*B_dB[7] + B[2]*B_dB[11]) / normB;
44
45 real gradBcrossB[3];
46 math_cross(gradB, B, gradBcrossB);
47
48 real curlB[3];
49 curlB[0] = B_dB[10] / y[0] - B_dB[7];
50 curlB[1] = B_dB[3] - B_dB[9];
51 curlB[2] = (B[1] - B_dB[2]) / y[0] + B_dB[5];
52
53 real Bstar[3];
54 Bstar[0] = B[0] + (y[3] / charge)
55 * (curlB[0] / normB - gradBcrossB[0] / (normB*normB));
56 Bstar[1] = B[1] + (y[3] / charge)
57 * (curlB[1] / normB - gradBcrossB[1] / (normB*normB));
58 Bstar[2] = B[2] + (y[3] / charge)
59 * (curlB[2] / normB - gradBcrossB[2] / (normB*normB));
60
61 real Estar[3];
62 Estar[0] = E[0] - y[4] * gradB[0] / ( charge * gamma );
63 Estar[1] = E[1] - y[4] * gradB[1] / ( charge * gamma );
64 Estar[2] = E[2] - y[4] * gradB[2] / ( charge * gamma );
65
66 real Bhat[3];
67 Bhat[0] = B[0] / normB;
68 Bhat[1] = B[1] / normB;
69 Bhat[2] = B[2] / normB;
70
71 real BhatDotBstar = math_dot(Bhat, Bstar);
72
73 real EstarcrossBhat[3];
74 math_cross(Estar, Bhat, EstarcrossBhat);
75
76 ydot[0] = ( y[3] * Bstar[0] / ( gamma * mass )
77 + EstarcrossBhat[0] ) / BhatDotBstar;
78 ydot[1] = ( y[3] * Bstar[1] / ( gamma * mass )
79 + EstarcrossBhat[1] ) / ( y[0]*BhatDotBstar );
80 ydot[2] = ( y[3] * Bstar[2] / ( gamma * mass )
81 + EstarcrossBhat[2] ) / BhatDotBstar;
82 ydot[3] = charge * math_dot(Bstar,Estar) / BhatDotBstar;
83 ydot[4] = 0;
84 ydot[5] = charge * normB / ( gamma * mass );
85
86 real t_ald = phys_ald_force_chartime(charge, mass, normB, gamma) * aldforce;
87 real C = 2 * y[4] * normB / (mass * CONST_C2);
88 ydot[3] += -t_ald * y[3] * C;
89 ydot[4] += -2 * t_ald * y[4] * (1 + C);
90}
91
92
93#endif
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Header file containing physical and mathematical constants.
#define CONST_C2
Speed of light squared [m^2/s^2].
Definition consts.h:26
Header file for math.c.
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
Definition math.h:31
#define math_cross(a, b, c)
Calculate cross product for 3D vectors c = a x b.
Definition math.h:34
Methods to evaluate elementary physical quantities.
#define physlib_gamma_ppar(m, mu, ppar, B)
Evaluate Lorentz factor from parallel momentum.
Definition physlib.h:77
static DECLARE_TARGET_SIMD void step_gceom(real *ydot, real *y, real mass, real charge, real *B_dB, real *E, int aldforce)
Calculate guiding center equations of motion for a single particle.
Definition step_gceom.h:28