XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
equil.hpp
Go to the documentation of this file.
1 #ifndef EQUIL_HPP
2 #define EQUIL_HPP
3 #include "space_settings.hpp"
4 #include "simd.hpp"
5 #include "NamelistReader.hpp"
6 #include "rz_bounds.hpp"
7 #include "grid_structs.hpp"
9 
10 // Options for generating analytic equilibrium for testing
11 enum PsiOption{
12  NoXPoints = 0,
15 };
16 
17 namespace Equil{
18 class XPoint{
19  public:
20 
21  double r;
22  double z;
23  double psi;
24  double slope;
25 };
26 }
27 
28 
29 class Equilibrium {
30 
31  public:
32 
33  Equilibrium(NLReader::NamelistReader& nlr, const MagneticEquilFiles::Ptr& equil_files, const View<Equil::XPoint*, HostType>& xpts, const RZPair& axis_in);
34 
35  // Constructor for tests
37  : bounds(0.5, 2.5, -1.0, 1.0),
38 
39  // Axis
40  axis{1.5, 0.1},
41 
42  epsil_psi(1.0e-05),
43 
44  // Xpt1
45  // XGC simulates circular case by putting the xpoint outside the model
46  // Place xpoint below min_z if no X-points
47  // Circular case still uses xpt_psi as a reference, but it's far away; so increase it
48  xpt{1.6, (psi_opt == NoXPoints) ? (bounds.min_z - 1.0) : -0.8},
49  xpt_slope(-0.5),
50  xpt_psi((psi_opt == NoXPoints) ? 5.0 : .8),
52 
53  // Xpt2
54  xpt2{1.4, 0.7},
55  xpt2_slope(-0.5),
56  xpt2_psi(1.0),
57  set_xpt2(psi_opt == TwoXPoints),
58 
59  // Used by profile testing
60  out_decay_factor(0.25),
61  out_decay_width(2.0),
64  {}
65 
66  // Default constructor
68 
69  KOKKOS_INLINE_FUNCTION bool is_in_region_1_or_2(double r,double z,double psi) const;
70  KOKKOS_INLINE_FUNCTION bool is_in_region_1(double r,double z,double psi) const;
71  KOKKOS_INLINE_FUNCTION bool is_in_region_3b(double r, double z, double psi) const;
72  KOKKOS_INLINE_FUNCTION void check_boundaries(const SimdVector2D& x, Simd<bool>& rz_outside) const;
73  KOKKOS_INLINE_FUNCTION void get_theta(const SimdVector2D& x, Simd<double>& theta) const;
74 
75  void write(const View<double*,CLayout,HostType>& eq_psi_grid, const View<double*,CLayout,HostType>& eq_I, const View<double**,CLayout,HostType>& eq_psi_rz, double bt_sign, double bp_sign);
76 
77  void set_decay_factors(double out_decay_factor_in, double priv_flux_decay_factor_in, double out_decay_width_in, double priv_flux_decay_width_in, bool set_xpt2_in);
78 
79  // Equil variables
81  double xpt_psi;
82  double psi_norm;
83  double epsil_psi = 1.0e-05;
85  double xpt_slope;
86  bool set_xpt2;
88  double xpt2_slope;
89  double xpt2_psi;
90  RZPair axis; // coordinates of axis
91 
92  // Use in eq profile calculations
95  double out_decay_width;
97 };
98 
99 #include "equil.tpp"
100 
101 #endif
Definition: equil.hpp:13
PsiOption
Definition: equil.hpp:11
KOKKOS_INLINE_FUNCTION bool is_in_region_1(double r, double z, double psi) const
Definition: equil.tpp:29
Definition: equil.hpp:18
KOKKOS_INLINE_FUNCTION bool is_in_region_3b(double r, double z, double psi) const
Definition: equil.tpp:45
Equilibrium()
Definition: equil.hpp:67
Definition: rz_bounds.hpp:4
RZPair xpt2
coordinates of 2nd X-point
Definition: equil.hpp:87
Definition: NamelistReader.hpp:193
double z
Definition: equil.hpp:22
double out_decay_width
width for exponential decay for psi&gt;sml_outpsi
Definition: equil.hpp:95
void set_decay_factors(double out_decay_factor_in, double priv_flux_decay_factor_in, double out_decay_width_in, double priv_flux_decay_width_in, bool set_xpt2_in)
Definition: equil.cpp:101
Definition: grid_structs.hpp:28
bool set_xpt2
Whether to use a 2nd X-point.
Definition: equil.hpp:86
double out_decay_factor
profiles decay exponentially to f(sml_outpsi)/decay_factor for psi&gt;sml_outpsi
Definition: equil.hpp:93
double priv_flux_decay_factor
profiles decay exponentially to f(sml_outpsi)/decay_factor in priv. flux region
Definition: equil.hpp:94
RZBounds bounds
Min and max for r and z.
Definition: equil.hpp:80
double psi_norm
Psi value to use for normalization.
Definition: equil.hpp:82
double xpt2_psi
psi coordinate at 2nd X-point
Definition: equil.hpp:89
double xpt_slope
Slope (which slope?) at 1st X-point.
Definition: equil.hpp:85
double xpt2_slope
Slope (which slope?) at 2nd X-point.
Definition: equil.hpp:88
KOKKOS_INLINE_FUNCTION void check_boundaries(const SimdVector2D &x, Simd< bool > &rz_outside) const
Definition: equil.tpp:56
double psi
Definition: equil.hpp:23
RZPair xpt
coordinates of 1st X-point
Definition: equil.hpp:84
KOKKOS_INLINE_FUNCTION void get_theta(const SimdVector2D &x, Simd< double > &theta) const
Definition: equil.tpp:66
Definition: simd.hpp:18
Definition: equil.hpp:14
Definition: simd.hpp:139
Equilibrium(PsiOption psi_opt)
Definition: equil.hpp:36
double min_z
Definition: rz_bounds.hpp:7
double epsil_psi
Not sure?
Definition: equil.hpp:83
RZPair axis
Definition: equil.hpp:90
double r
Definition: equil.hpp:21
Definition: equil.hpp:12
double slope
Definition: equil.hpp:24
Definition: equil.hpp:29
KOKKOS_INLINE_FUNCTION bool is_in_region_1_or_2(double r, double z, double psi) const
Definition: equil.tpp:6
void write(const View< double *, CLayout, HostType > &eq_psi_grid, const View< double *, CLayout, HostType > &eq_I, const View< double **, CLayout, HostType > &eq_psi_rz, double bt_sign, double bp_sign)
Definition: equil.cpp:68
std::shared_ptr< MagneticEquilFiles > Ptr
Definition: magnetic_equil_files.hpp:11
double priv_flux_decay_width
width for exponential decay in private flux region
Definition: equil.hpp:96
double xpt_psi
Psi coordinate of 1st X-point.
Definition: equil.hpp:81