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 "../../math.h"
11#include "../../physlib.h"
12
13
25DECLARE_TARGET_SIMD
26inline static void step_gceom(real* ydot, real* y, real mass, real charge,
27 real* B_dB, real* E) {
28
29 real B[3];
30 B[0] = B_dB[0];
31 B[1] = B_dB[4];
32 B[2] = B_dB[8];
33
34 real normB = sqrt(math_dot(B, B));
35 real gamma = physlib_gamma_ppar(mass, y[4], y[3], normB);
36
37 real gradB[3];
38 gradB[0] = (B[0]*B_dB[1] + B[1]*B_dB[5] + B[2]*B_dB[9]) / normB;
39 gradB[1] = (B[0]*B_dB[2] + B[1]*B_dB[6] + B[2]*B_dB[10])
40 / (normB * y[0]);
41 gradB[2] = (B[0]*B_dB[3] + B[1]*B_dB[7] + B[2]*B_dB[11]) / normB;
42
43 real gradBcrossB[3];
44 math_cross(gradB, B, gradBcrossB);
45
46 real curlB[3];
47 curlB[0] = B_dB[10] / y[0] - B_dB[7];
48 curlB[1] = B_dB[3] - B_dB[9];
49 curlB[2] = (B[1] - B_dB[2]) / y[0] + B_dB[5];
50
51 real Bstar[3];
52 Bstar[0] = B[0] + (y[3] / charge)
53 * (curlB[0] / normB - gradBcrossB[0] / (normB*normB));
54 Bstar[1] = B[1] + (y[3] / charge)
55 * (curlB[1] / normB - gradBcrossB[1] / (normB*normB));
56 Bstar[2] = B[2] + (y[3] / charge)
57 * (curlB[2] / normB - gradBcrossB[2] / (normB*normB));
58
59 real Estar[3];
60 Estar[0] = E[0] - y[4] * gradB[0] / ( charge * gamma );
61 Estar[1] = E[1] - y[4] * gradB[1] / ( charge * gamma );
62 Estar[2] = E[2] - y[4] * gradB[2] / ( charge * gamma );
63
64 real Bhat[3];
65 Bhat[0] = B[0] / normB;
66 Bhat[1] = B[1] / normB;
67 Bhat[2] = B[2] / normB;
68
69 real BhatDotBstar = math_dot(Bhat, Bstar);
70
71 real EstarcrossBhat[3];
72 math_cross(Estar, Bhat, EstarcrossBhat);
73
74 ydot[0] = ( y[3] * Bstar[0] / ( gamma * mass )
75 + EstarcrossBhat[0] ) / BhatDotBstar;
76 ydot[1] = ( y[3] * Bstar[1] / ( gamma * mass )
77 + EstarcrossBhat[1] ) / ( y[0]*BhatDotBstar );
78 ydot[2] = ( y[3] * Bstar[2] / ( gamma * mass )
79 + EstarcrossBhat[2] ) / BhatDotBstar;
80 ydot[3] = charge * math_dot(Bstar,Estar) / BhatDotBstar;
81 ydot[4] = 0;
82 ydot[5] = charge * normB / ( gamma * mass );
83
84}
85
86
87#endif
Main header file for ASCOT5.
double real
Definition ascot5.h:85
Header file for math.c.
#define math_dot(a, b)
Calculate dot product a[3] dot b[3].
Definition math.h:28
#define math_cross(a, b, c)
Calculate cross product for 3D vectors c = a x b.
Definition math.h:31
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)
Calculate guiding center equations of motion for a single particle.
Definition step_gceom.h:26