XGC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
6 // Simulation class
7 template<class Device>
8 class Simulation {
9  public:
10 
11  // Constructor
12  // transit_time_in and psi_norm are 1.0 so that the regression tests pass. Update the
13  // reference data and remove these default values when possible. Or better, address the related TODO in xgc.cpp
14  Simulation(NLReader::NamelistReader& nlr, bool reduced_deltaf_in=false, double transit_time_in=1.0, double psi_norm=1.0);
15 
16 #ifdef XGCA
17  static constexpr bool is_XGCa = true;
18 #else
19  static constexpr bool is_XGCa = false;
20 #endif
21 
22 #ifdef EXPLICIT_EM
23  static constexpr bool explicit_electromagnetic = true;
24 #else
25  static constexpr bool explicit_electromagnetic = false;
26 #endif
27 
28 #ifdef F0_UPDATE_ANALYTIC_OLD
29  static constexpr bool old_f0_update_analytic = true;
30 #else
31  static constexpr bool old_f0_update_analytic = false;
32 #endif
33 
34  static constexpr int nhybrid = 2;
35 
37  bool separate_n0;
38 
39  // Input parameters
40  int bounce;
42  double bounce_buffer;
43  double dt;
44  double transit_time;
47  bool ptb_3db_on;
48  bool drift_on;
49  bool neutrals;
50  bool diag_heat_on;
51  bool xz_00_up;
52  int mstep;
53  int nrk;
54  bool electron_on;
56  int nthreads;
57 
58  bool field_solver;
60 
62 
63  bool dwdt_fix_bg; // 1-w factor in dwdt
64  bool dwdt_exb_only; // excluding grad-b drift in dwdt
65 
75  bool em_control_variate_final_cv; // Should be local variable/argument
76  bool em_control_variate_flag; // Should be local variable/argument
79  bool em_es_step;
83  bool no_turb;
84  bool em_n0;
86 
88 
94  bool iter_solver;
115 
134  int add_pot0;
138 
140  double dpot_bd_width;
142 
144  // If true, an adiabatic wall condition is used (no polarization, n_i=0, n_e!=0)
145  // in the axisymmetric solver; this is an experimental option and should
146  // be used together with sml_sheath_mode=1 and sml_sheath_init_pot_factor=0.
147 
148  double dpot_te_limit;
150 
151  // Used in update_f0
152  bool no_fp_in_f;
154  double f0_grid_alpha;
167  bool ignore_f0g;
171  bool symmetric_f;
172 
173  double update_g_alpha;
175  // Diffusion
176  bool diff_on;
177 
178  // Resampling
179  bool resamp_on;
182 
183  // Simulation variables
184  double time;
185  int gstep;
186 
188  int mr_factor;
190  double mr_psi_max;
191 
192  // RMP penetration calculation
198 
203 
204  // Core-edge coupling
206 
207  // Push performance - could be elsewhere
209 
210  // Loop-voltage (for driving the equilibrium current)
213  double loop_voltage;
214  double loop_voltage_psimax;
217  //double current_drive_gamma; //!< Damping factor for heuristic current drive, 1.0 means plasma current is restored exactly each time step
219  double current_drive_p;
226 
227 
228  // Fourier filter
233 };
234 
235 #include "sml.tpp"
236 #endif
bool multirate_timestepping
Use multirate timestepping.
Definition: sml.hpp:187
double f0_update_analytic_damp_width
Definition: sml.hpp:162
bool em_dAsdt_filter_on
Switch for applying Fourier filters on RHS of dAs/dt equation (pullback mode 4)
Definition: sml.hpp:82
double mode_select_bd_width
Definition: sml.hpp:232
bool resamp_for_final_restart_write
Perform resampling before dumping the final restart file.
Definition: sml.hpp:180
double f0_grid_alpha
Definition: sml.hpp:154
Simulation(NLReader::NamelistReader &nlr, bool reduced_deltaf_in=false, double transit_time_in=1.0, double psi_norm=1.0)
Definition: sml.tpp:5
bool em_control_variate_flag
Definition: sml.hpp:76
double current_drive_p
Current drive PID controller: factor for proportional controller ( )
Definition: sml.hpp:223
bool em_mixed_variable
Switch for use of mixed-variable formulation.
Definition: sml.hpp:66
double current_drive_i
Current drive PID controller: factor for integral controller ( )
Definition: sml.hpp:224
bool drift_on
Toggle for using drift.
Definition: sml.hpp:48
double current_drive_d
Current drive PID controller: factor for derivative controller ( )
Definition: sml.hpp:225
int nrk
Order of Runge-Kutta time integration of particles + fields.
Definition: sml.hpp:53
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:149
Definition: sml.hpp:8
static constexpr bool is_XGCa
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:19
bool reduced_deltaf
True if any species is reduced_deltaf. Will be removed.
Definition: sml.hpp:36
static constexpr bool explicit_electromagnetic
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:25
bool em_n0
Include n=0 electromagnetic mode.
Definition: sml.hpp:84
bool poisson_adia_wall
EXPERIMENTAL! DON&#39;T USE UNLESS ADVISED BY AN EXPERT.
Definition: sml.hpp:143
static constexpr int nhybrid
Number of iterations in electrostatic electron weight evolution scheme.
Definition: sml.hpp:34
bool thermal_bath_on
Switch on thermal-bath and coarse-graining operation, see ccm_param parameters.
Definition: sml.hpp:61
Definition: NamelistReader.hpp:193
bool poisson_use_bc
(XGCa only) False: 00-bc is phi=0 everywhere; true: 00-boundary
Definition: sml.hpp:137
int mstep_rmp_es
Definition: sml.hpp:193
bool exclude_private
Whether to exclude private region in ion charge deposition.
Definition: sml.hpp:87
int bounce_zero_weight
If ==1 and bounce&gt;0, set particle weights to zero after bouncing from the outer boundary.
Definition: sml.hpp:41
bool em_exclude_private
Definition: sml.hpp:200
int mr_factor
Definition: sml.hpp:188
int gstep
Current time step.
Definition: sml.hpp:185
double mode_select_outpsi
Definition: sml.hpp:231
bool em_es_step
Definition: sml.hpp:79
bool diag_heat_on
Use heat diagnostics in sheath.
Definition: sml.hpp:50
bool xz_00_up
Use upper region of xz when obtaining 00 mode.
Definition: sml.hpp:51
bool update_poisson_solver
Whether poisson solver is updated.
Definition: sml.hpp:114
double loop_voltage_psimax
Inductive current drive: outer boundary (in pol. flux) of the loop voltage.
Definition: sml.hpp:216
int mode_select_mode
Definition: sml.hpp:229
double mode_select_inpsi
Definition: sml.hpp:230
int f0_grid_alpha_start
Definition: sml.hpp:164
double loop_voltage
Definition: sml.hpp:213
bool symmetric_f
Enforce axisymmetry of the total distribution function on the grid.
Definition: sml.hpp:171
bool iter_solver_converge
Definition: sml.hpp:116
bool cce_coupling_on
Core-edge coupling flag.
Definition: sml.hpp:205
int nthreads
Number of OMP threads on the host.
Definition: sml.hpp:56
int em_pullback_mode
Definition: sml.hpp:68
bool grad_psitheta
Definition: sml.hpp:89
bool heuristic_priv_pot
Definition: sml.hpp:125
int poisson_solver_type
Definition: sml.hpp:104
bool ignore_f0g
Definition: sml.hpp:167
int add_pot0
Definition: sml.hpp:134
bool separate_n0
Use separate n0 solver even in reduced_deltaf.
Definition: sml.hpp:37
double transit_time
Torodial transit time of an ion with the characteristic energy.
Definition: sml.hpp:44
double bd_ext_delta_Ao
Definition: sml.hpp:202
bool use_unfused_electron_push_kernel
Definition: sml.hpp:208
bool sheath_adjust
Whether to adjust the sheath.
Definition: sml.hpp:46
bool resamp_on
Do resampling.
Definition: sml.hpp:179
bool dwdt_exb_only
Definition: sml.hpp:64
bool em_dAsdt_hypvis
Use radial hyperviscosity in dA_s/dt (push_As)
Definition: sml.hpp:85
double update_g_alpha
Definition: sml.hpp:173
double time
Current simulation time.
Definition: sml.hpp:184
bool no_fp_in_f
Definition: sml.hpp:152
bool use_em_bounds
Definition: sml.hpp:199
bool em_control_variate_final_cv
Definition: sml.hpp:75
bool no_turb
Set all non-axisymmetric field perturbations to zero (electromagnetic version only) ...
Definition: sml.hpp:83
int mstep_rmp_em
Definition: sml.hpp:195
double bd_ext_delta_Ai
Definition: sml.hpp:201
int sheath_mode
Type of sheath (0 is none)
Definition: sml.hpp:45
double dpot_te_limit
Max absolute value of dpot/temp in getf0.
Definition: sml.hpp:148
bool electron_on
Use kinetic electrons.
Definition: sml.hpp:54
double f0_update_analytic_alpha
Separate alpha from sml_f0_grid_alpha for Maxwellian contribution.
Definition: sml.hpp:161
int rmp_es_to_em_dt_ratio
Ratio of EM to ES time step size in RMP penetration calculation.
Definition: sml.hpp:197
double mr_psi_max
maximum normalized psi value of each multirate region
Definition: sml.hpp:190
bool em_b_para_eff
Effective dB_|| via a modified grad-B drift (Joiner et al., PoP, 2010)
Definition: sml.hpp:78
bool dwdt_fix_bg
Definition: sml.hpp:63
int mstep
Max number of time steps.
Definition: sml.hpp:52
bool limit_marker_den
Whether to limit marker density.
Definition: sml.hpp:55
bool f0_update_analytic
Definition: sml.hpp:158
bool current_drive_on
Definition: sml.hpp:218
double dt
Time step (s)
Definition: sml.hpp:43
bool poisson_natural_boundary
Definition: sml.hpp:128
bool field_solver
If false, charge deposition and field solve is skipped.
Definition: sml.hpp:58
int bounce
Bounce routine switch 0 for off, 1 for inner boundary, 2 for both boundaries.
Definition: sml.hpp:40
bool loop_voltage_fsa
Make loop voltage and current drive flux-functions if true (default: true)
Definition: sml.hpp:212
bool f0_update_analytic_local
If .false. –&gt; flux-surface average update, .true. –&gt; local.
Definition: sml.hpp:160
double em_pullback_dampfac
Damping term gamma on -b.grad(phi) in pullback mode 4.
Definition: sml.hpp:74
bool loop_voltage_on
Inductive current drive: loop voltage (from Faraday&#39;s law curl(E)=-dB/dt)
Definition: sml.hpp:211
bool neutrals
Toggle for using neutrals.
Definition: sml.hpp:49
bool poisson_bias
Whether to use a (0,0) bias potential on top of phi_00.
Definition: sml.hpp:141
int em_control_variate_niter
Number of iterations for Ampere solve with control-variate method.
Definition: sml.hpp:77
bool ptb_3db_on
Toggle for ptb_3db.
Definition: sml.hpp:47
double bounce_buffer
Buffer width between sml_outpsi and where the particle actually bounces (must be &gt;=0) ...
Definition: sml.hpp:42
bool em_control_variate
Switch for use of control variate method.
Definition: sml.hpp:67
bool positive_phi00_sol
Definition: sml.hpp:121
bool resamp_restart_read
Whether to read a restart file written from a simulation with different grid.
Definition: sml.hpp:181
double dpot_bd_width
Decay length (normalized flux) for (n=0,m&gt;0) potential towards the magnetic axis. ...
Definition: sml.hpp:140
bool helmholtz_spectral
Whether to solve Helmholtz-type equations with toroidally spectral solver.
Definition: sml.hpp:59
bool dpot_bd_apply
Damp (n=0,m&gt;0) potential towards the magnetic axis.
Definition: sml.hpp:139
bool iter_solver
Definition: sml.hpp:94
bool diff_on
Definition: sml.hpp:176
static constexpr bool old_f0_update_analytic
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:31