XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cpp_magnetic_field.hpp
Go to the documentation of this file.
1 #ifndef CPP_MAGNETIC_FIELD_HPP
2 #define CPP_MAGNETIC_FIELD_HPP
3 #include "cpp_equil.hpp"
4 #include "cpp_bicub.hpp"
5 #include "cpp_I_interpol.hpp"
6 
7 // Magnetic field class
8 template<class Device>
9 class MagneticField {
10  public:
11 
12  // Field variables
13  double bt_sign;
14  double bp_sign;
15  int ff_step;
16  int ff_order;
17  double bd_min_r;
18  double bd_max_r;
19  double bd_min_z;
20  double bd_max_z;
21 
22  double inpsi;
23  double outpsi;
24 
25 
26  // Structures inside B-field
30 
31  MagneticField(double bt_sign_in, double bp_sign_in, int ff_step_in, int ff_order_in, double bd_min_r_in, double bd_max_r_in, double bd_min_z_in, double bd_max_z_in, double inpsi_in, double outpsi_in,
32  // Bicub:
33  double *rc_in, double *zc_in, BicubCoeff *acoeff_in, int nr_in, int nz_in, double rmin_in, double zmin_in, double dr_inv_in, double dz_inv_in,
34  // Interp:
35  OneDCoeff *one_d_cub_acoef_in, int ncoeff_in, double max_psi_in, double min_psi_in, double one_d_cub_dpsi_inv_in,
36  // Equil:
37  double eq_min_r, double eq_max_r, double eq_min_z, double eq_max_z,
38  double eq_x_psi, double epsil_psi, double eq_x_r, double eq_x_slope, double eq_x_z,
39  double eq_x2_r, double eq_x2_slope, double eq_x2_z, double eq_x2_psi, double eq_axis_r,
40  double eq_axis_z, int eq_mpsi);
41 
42  // Default constructor
44 
45  // Get complete B-field info
46  KOKKOS_INLINE_FUNCTION void field(const Simd<double>& fld_r, const Simd<double>& fld_z,
47  SimdVector &bvec, SimdVector (&jacb)[3], Simd<double>& psivec, SimdVector2D &gradpsi, SimdVector &tdb, Simd<bool>& rz_outside) const;
48 
49  KOKKOS_INLINE_FUNCTION void bvec_interpol(double r,double z,double phi,double &br,double &bz,double &bphi) const;
50 
51  KOKKOS_INLINE_FUNCTION void bmag_interpol(const Simd<double>& r, const Simd<double>& z, const Simd<double>& phi,Simd<double>& bmag) const;
52 
53  KOKKOS_INLINE_FUNCTION void follow_field(const SimdVector2D &x_org,const Simd<double>& phi_org, const Simd<double>& phi_dest,SimdVector2D &x_dest) const;
54 
55  KOKKOS_INLINE_FUNCTION void derivs(const double (&x)[2],double phi,double (&dx)[2]) const;
56 
57 };
58 
59 #include "cpp_magnetic_field.tpp"
60 #endif
double inpsi
Boundary condition used in a few spots.
Definition: cpp_magnetic_field.hpp:22
double bd_max_z
Maximum z (of what exactly?)
Definition: cpp_magnetic_field.hpp:20
KOKKOS_INLINE_FUNCTION void bvec_interpol(double r, double z, double phi, double &br, double &bz, double &bphi) const
Definition: cpp_magnetic_field.tpp:112
Definition: cpp_globals.hpp:59
KOKKOS_INLINE_FUNCTION void follow_field(const SimdVector2D &x_org, const Simd< double > &phi_org, const Simd< double > &phi_dest, SimdVector2D &x_dest) const
Definition: cpp_magnetic_field.tpp:157
int ff_order
Order of RK scheme used for field following. Can be 1, 2, or 4.
Definition: cpp_magnetic_field.hpp:16
KOKKOS_INLINE_FUNCTION void field(const Simd< double > &fld_r, const Simd< double > &fld_z, SimdVector &bvec, SimdVector(&jacb)[3], Simd< double > &psivec, SimdVector2D &gradpsi, SimdVector &tdb, Simd< bool > &rz_outside) const
Definition: cpp_magnetic_field.tpp:47
Definition: cpp_bicub.hpp:7
Definition: cpp_magnetic_field.hpp:9
MagneticField()
Definition: cpp_magnetic_field.hpp:43
Definition: cpp_I_interpol.hpp:11
double bd_min_r
Minimum r (of what exactly?)
Definition: cpp_magnetic_field.hpp:17
double outpsi
Boundary condition used in a few spots.
Definition: cpp_magnetic_field.hpp:23
double bd_min_z
Minimum z (of what exactly?)
Definition: cpp_magnetic_field.hpp:19
double bt_sign
Whether toroidal field is reversed?
Definition: cpp_magnetic_field.hpp:13
Definition: cpp_bicub.hpp:13
Interp< Device > I_interp
The object for interpolating I (for deriving toroidal magnetic field)
Definition: cpp_magnetic_field.hpp:28
double bp_sign
Whether poloidal field is reversed?
Definition: cpp_magnetic_field.hpp:14
Definition: cpp_I_interpol.hpp:6
Equilibrium< Device > equil
The object containing information about the magnetic equilibrium.
Definition: cpp_magnetic_field.hpp:29
Definition: cpp_globals.hpp:54
Bicub< Device > psi_bicub
The object for interpolating psi (magnetic flux surfaces)
Definition: cpp_magnetic_field.hpp:27
int ff_step
Number of steps taken when projecting the particle location onto the midplane.
Definition: cpp_magnetic_field.hpp:15
KOKKOS_INLINE_FUNCTION void derivs(const double(&x)[2], double phi, double(&dx)[2]) const
Definition: cpp_magnetic_field.tpp:271
Definition: cpp_equil.hpp:7
KOKKOS_INLINE_FUNCTION void bmag_interpol(const Simd< double > &r, const Simd< double > &z, const Simd< double > &phi, Simd< double > &bmag) const
Definition: cpp_magnetic_field.tpp:140
double bd_max_r
Maximum r (of what exactly?)
Definition: cpp_magnetic_field.hpp:18