XGC1
sml.hpp
Go to the documentation of this file.
1 #ifndef SML_HPP
2 #define SML_HPP
3 #include "space_settings.hpp"
4 #include "NamelistReader.hpp"
5 #include "globals.hpp"
6 #include "xgc_io.hpp"
7 
8 // Simulation class
9 template<class Device>
10 class Simulation {
11  public:
12 
13  // Constructor
14  // transit_time_in and psi_norm are 1.0 so that the regression tests pass. Update the
15  // reference data and remove these default values when possible. Or better, address the related TODO in xgc.cpp
16  Simulation(NLReader::NamelistReader& nlr, bool reduced_deltaf_in=false, double transit_time_in=1.0, double psi_norm=1.0);
17 
18  void read_checkpoint_files(const XGC_IO_Stream& stream);
19  void write_checkpoint_files(const XGC_IO_Stream& stream) const;
20 
21 #ifdef XGCA
22  static constexpr bool is_XGCa = true;
23 #else
24  static constexpr bool is_XGCa = false;
25 #endif
26 
27 #ifdef EXPLICIT_EM
28  static constexpr bool explicit_electromagnetic = true;
29 #else
30  static constexpr bool explicit_electromagnetic = false;
31 #endif
32 
33 #ifdef F0_UPDATE_ANALYTIC_OLD
34  static constexpr bool old_f0_update_analytic = true;
35 #else
36  static constexpr bool old_f0_update_analytic = false;
37 #endif
38 
39  static constexpr int nhybrid = 2;
40 
42  bool separate_n0;
43 
44  // Input parameters
45  int bounce;
47  double bounce_buffer;
48  double dt;
49  double transit_time;
51  bool ptb_3db_on;
52  bool drift_on;
53  bool neutrals;
54  bool diag_heat_on;
55  int mstep;
56  int nrk;
57  bool electron_on;
59  int nthreads;
60 
61  bool field_solver;
62 
64 
65  bool dwdt_fix_bg; // 1-w factor in dwdt
66  bool dwdt_exb_only; // excluding grad-b drift in dwdt
67 
71  // IdealMHD: pullback using Ohm's law dA_s/dt + b.grad(phi) = 0
73  bool em_control_variate_final_cv; // Should be local variable/argument
74  bool em_control_variate_flag; // Should be local variable/argument
77  bool em_es_step;
85  bool no_turb;
86  bool em_n0;
88 
90 
96  bool iter_solver;
107 
117  int add_pot0;
121  double dpot_bd_width;
123 
124  double dpot_te_limit;
127 
128  // Used in update_f0
129  bool no_fp_in_f;
131  double f0_grid_alpha;
144  bool ignore_f0g;
148  bool symmetric_f;
149 
150  double update_g_alpha;
152  // Diffusion
153  bool diff_on;
154 
155  // Resampling
156  bool resamp_on;
159 
160  // Simulation variables
161  double time;
162  int gstep;
163 
168 
169  // Core-edge coupling
171 
172  // Push performance - could be elsewhere
174 
175  // Loop-voltage (for driving the equilibrium current)
178  //double current_drive_gamma; //!< Damping factor for heuristic current drive, 1.0 means plasma current is restored exactly each time step
184 
185 
186  // How to set the inner boundary condition for the turbulence field solvers
188 
189 };
190 
191 #endif
Definition: NamelistReader.hpp:199
Definition: sml.hpp:10
bool loop_voltage_on
Inductive current drive: loop voltage (from Faraday's law curl(E)=-dB/dt)
Definition: sml.hpp:176
int mstep
Max number of time steps.
Definition: sml.hpp:55
bool cce_coupling_on
Core-edge coupling flag.
Definition: sml.hpp:170
bool update_poisson_solver
Whether poisson solver is updated.
Definition: sml.hpp:106
bool reduced_deltaf
True if any species is reduced_deltaf. Will be removed.
Definition: sml.hpp:41
bool em_exclude_private
Definition: sml.hpp:165
bool neutrals
Toggle for using neutrals.
Definition: sml.hpp:53
bool positive_phi00_sol
Definition: sml.hpp:113
double bounce_buffer
Buffer width between sml_outpsi and where the particle actually bounces (must be >=0)
Definition: sml.hpp:47
int nrk
Order of Runge-Kutta time integration of particles + fields.
Definition: sml.hpp:56
int add_pot0
Definition: sml.hpp:117
bool em_es_step
Definition: sml.hpp:77
bool em_n0
Include n=0 electromagnetic mode.
Definition: sml.hpp:86
double dpot_bd_width
Decay length (normalized flux) for (n=0,m>0) potential towards the magnetic axis.
Definition: sml.hpp:121
double em_pullback_dampfac
Damping term gamma on -b.grad(phi) in pullback mode 4.
Definition: sml.hpp:72
bool em_control_variate_final_cv
Definition: sml.hpp:73
bool em_control_variate_flag
Definition: sml.hpp:74
bool em_dAsdt_filter_on
Switch for applying Fourier filters on RHS of dAs/dt equation (pullback mode 4)
Definition: sml.hpp:84
bool zero_inner_bd_turb
Definition: sml.hpp:187
double dpot_te_limit_n0
Limits the magnitude of the normalized axisymmetric potential e*dphi_0/T_e.
Definition: sml.hpp:125
bool grad_psitheta
Definition: sml.hpp:91
bool iter_solver
Definition: sml.hpp:96
bool em_use_dpot_te_limit
In EM simulation: whether to force usage of the min-max limiter on the turbulent potential fluctuatio...
Definition: sml.hpp:126
bool resamp_for_final_restart_write
Perform resampling before dumping the final restart file.
Definition: sml.hpp:157
double bd_ext_delta_Ai
Definition: sml.hpp:166
bool diag_heat_on
Use heat diagnostics in sheath.
Definition: sml.hpp:54
bool f0_update_analytic_local
If .false. --> flux-surface average update, .true. --> local.
Definition: sml.hpp:137
bool use_unfused_electron_push_kernel
Definition: sml.hpp:173
bool separate_n0
Use separate n0 solver even in reduced_deltaf.
Definition: sml.hpp:42
bool ptb_3db_on
Toggle for ptb_3db.
Definition: sml.hpp:51
static constexpr bool explicit_electromagnetic
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:30
Simulation(NLReader::NamelistReader &nlr, bool reduced_deltaf_in=false, double transit_time_in=1.0, double psi_norm=1.0)
bool em_control_variate
Switch for use of control variate method.
Definition: sml.hpp:69
int sheath_mode
Type of sheath (0 is none)
Definition: sml.hpp:50
int gstep
Current time step.
Definition: sml.hpp:162
double transit_time
Torodial transit time of an ion with the characteristic energy.
Definition: sml.hpp:49
int nthreads
Number of OMP threads on the host.
Definition: sml.hpp:59
double f0_grid_alpha
Definition: sml.hpp:131
bool dpot_bd_apply
Damp (n=0,m>0) potential towards the magnetic axis.
Definition: sml.hpp:120
bool poisson_bias
Whether to use a (0,0) bias potential on top of phi_00.
Definition: sml.hpp:122
bool thermal_bath_on
Switch on thermal-bath and coarse-graining operation, see ccm_param parameters.
Definition: sml.hpp:63
bool iter_solver_converge
Definition: sml.hpp:108
bool drift_on
Toggle for using drift.
Definition: sml.hpp:52
void write_checkpoint_files(const XGC_IO_Stream &stream) const
PullbackMethod em_pullback_method
Electrostatic: mixed-variable pullback with dA_s/dt=0,.
Definition: sml.hpp:70
int em_control_variate_niter
Number of iterations for Ampere solve with control-variate method.
Definition: sml.hpp:75
bool dwdt_fix_bg
Definition: sml.hpp:65
static constexpr bool is_XGCa
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:24
bool exclude_private
Whether to exclude private region in ion charge deposition.
Definition: sml.hpp:89
static constexpr bool old_f0_update_analytic
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:36
double dt
Time step (s)
Definition: sml.hpp:48
static constexpr int nhybrid
Number of iterations in electrostatic electron weight evolution scheme.
Definition: sml.hpp:39
bool em_dAsdt_hypvis
Use radial hyperviscosity in dA_s/dt (push_As)
Definition: sml.hpp:87
void read_checkpoint_files(const XGC_IO_Stream &stream)
double f0_update_analytic_damp_width
Definition: sml.hpp:139
bool dwdt_exb_only
Definition: sml.hpp:66
bool use_em_bounds
Definition: sml.hpp:164
int bounce_zero_weight
If ==1 and bounce>0, set particle weights to zero after bouncing from the outer boundary.
Definition: sml.hpp:46
bool ignore_f0g
Definition: sml.hpp:144
bool electron_on
Use kinetic electrons.
Definition: sml.hpp:57
bool f0_update_analytic
Definition: sml.hpp:135
double f0_update_analytic_alpha
Separate alpha from sml_f0_grid_alpha for Maxwellian contribution.
Definition: sml.hpp:138
bool current_drive_on
Definition: sml.hpp:179
bool limit_marker_den
Whether to limit marker density.
Definition: sml.hpp:58
bool em_b_para_eff
Effective dB_|| via a modified grad-B drift (Joiner et al., PoP, 2010)
Definition: sml.hpp:76
bool resamp_restart_read
Whether to read a restart file written from a simulation with different grid.
Definition: sml.hpp:158
bool em_mixed_variable
Switch for use of mixed-variable formulation.
Definition: sml.hpp:68
bool field_solver
If false, charge deposition and field solve is skipped.
Definition: sml.hpp:61
bool no_turb
Set all non-axisymmetric field perturbations to zero (electromagnetic version only)
Definition: sml.hpp:85
double update_g_alpha
Definition: sml.hpp:150
bool symmetric_f
Enforce axisymmetry of the total distribution function on the grid.
Definition: sml.hpp:148
double dpot_te_limit
Max absolute value of dpot/temp in getf0.
Definition: sml.hpp:124
double bd_ext_delta_Ao
Definition: sml.hpp:167
int bounce
Bounce routine switch 0 for off, 1 for inner boundary, 2 for both boundaries.
Definition: sml.hpp:45
double time
Current simulation time.
Definition: sml.hpp:161
bool resamp_on
Do resampling.
Definition: sml.hpp:156
bool diff_on
Definition: sml.hpp:153
int f0_grid_alpha_start
Definition: sml.hpp:141
bool no_fp_in_f
Definition: sml.hpp:129
double loop_voltage_psimax
Inductive current drive: outer boundary (in pol. flux) of the loop voltage.
Definition: sml.hpp:177
Definition: xgc_io.hpp:24
PullbackMethod
Definition: globals.hpp:221