Implements an anomalous transport (advection-diffusion) model for the kinetic electrons in the plasma simulation.
More...
#include <diffusion.hpp>
|
bool | is_triggered_update (int step) const |
| Determines whether the update of the diffusion coefficients should be executed on the given step. More...
|
|
int | trigger_count_update (int step) const |
| Calculates how many times the update of the diffusion coefficient has been executed up to the given step. More...
|
|
| Diffusion () |
| Default constructor. Creates an uninitialized Diffusion object. More...
|
|
| Diffusion (NLReader::NamelistReader &nlr, const MagneticField< DeviceType > &magnetic_field, const Grid< DeviceType > &grid) |
|
void | init (NLReader::NamelistReader &nlr, const MagneticField< DeviceType > &magnetic_field, const Grid< DeviceType > &grid) |
| Constructs a Diffusion object by reading diffusion-related parameters from the namelist. More...
|
|
void | apply (const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, ElectricField< DeviceType > &electric_field, const DomainDecomposition< DeviceType > &pol_decomp, const VelocityGrid &vgrid, Plasma &plasma, Smoothing &smoothing, DiagF0DF &diag_f0_df, const Moments &moments, const VGridDistribution< DeviceType > &f0_f, VGridDistribution< HostType > &f0_df0g, double dt) |
|
void | update (const Plasma &plasma, const DomainDecomposition< DeviceType > &pol_decomp, const Grid< DeviceType > &grid) |
| Updates the diffusion coefficients from an input BP file and passes the data to a Fortran routine. More...
|
|
bool | is_triggered (int step) |
|
Implements an anomalous transport (advection-diffusion) model for the kinetic electrons in the plasma simulation.
This class extends the generic Source
interface, providing functionality to apply an anomalous diffusion source term during the kinetic equation update. It sets diffusion boundaries based on poloidal flux surfaces and initializes a boundary mask for the domain.
Typical usage:
- Construct a
Diffusion
object from a namelist and the necessary grid/magnetic-field data.
- Call
apply()
at each time step (or when triggered) to modify the distribution function.
Example:
Default constructor. Creates an uninitialized Diffusion object.
This default constructor does not set any boundary conditions or read from the namelist. It is primarily intended for creating an object that will be assigned or initialized later.
void Diffusion::apply |
( |
const Simulation< DeviceType > & |
sml, |
|
|
const Grid< DeviceType > & |
grid, |
|
|
const MagneticField< DeviceType > & |
magnetic_field, |
|
|
ElectricField< DeviceType > & |
electric_field, |
|
|
const DomainDecomposition< DeviceType > & |
pol_decomp, |
|
|
const VelocityGrid & |
vgrid, |
|
|
Plasma & |
plasma, |
|
|
Smoothing & |
smoothing, |
|
|
DiagF0DF & |
diag_f0_df, |
|
|
const Moments & |
moments_h, |
|
|
const VGridDistribution< DeviceType > & |
f0_f, |
|
|
VGridDistribution< HostType > & |
f0_df0g_h, |
|
|
double |
dt |
|
) |
| |
Calls the diffusion timestepper. The solve uses PETSc and the setup for that is still in Fortran.
- Parameters
-
[in] | sml | Simulation parameters |
[in] | grid | The grid object |
[in] | magnetic_field | The magnetic field object |
[in] | electric_field | Used for dpot to remove adiabatic response |
[in] | pol_decomp | The domain decomposition |
[in] | velocity_grid | Velocity grid |
[in,out] | plasma | Plasma object. f0_delta_n/u/T are updated |
[in] | moments_h | Moments |
[in] | f0_f | The part of the distribution function represented on the velocity grid |
[in,out] | f0_df0g_h | The change to the distribution function |
[in] | dt | The time step return View marking whether each mesh node is in bounds |
Constructs a Diffusion object by reading diffusion-related parameters from the namelist.
This constructor reads in electron settings (to verify that electrons are kinetic), boundary flux values for the diffusion model, and other solver-related parameters (e.g., start time) from the specified namelist reader. It then creates a Boundary
object to handle domain exclusion regions and calls an external Fortran routine initialize_diffusion()
to set up the diffusion mask.
- Parameters
-
[in,out] | nlr | Namelist reader from which diffusion parameters and other simulation controls are retrieved. |
[in] | magnetic_field | Provides poloidal-flux normalization factors (psi_norm ) and in/out flux boundaries required for setting up the diffusion domain. |
[in] | grid | The spatial grid defining the geometry of the problem; includes node information needed to map boundary settings to the correct domain regions. |
- Note
- If
sml_electron_on
is false
, the constructor will terminate the code via exit_XGC()
, since anomalous diffusion requires kinetic electrons.
- The constructor uses multiple namelists: first
sml_param
to verify that electrons are on, then diff_param
to read specific diffusion boundaries and timing parameters.
- The boundary settings constructed here are subsequently used within
initialize_diffusion()
to exclude regions (e.g., near-wall, private flux).
< Outer boundary (for Poisson solver), normalized poloidal flux
< Outer boundary (for Poisson solver, 2nd private region), normalized poloidal flux
< To move the outer boundary of the Poisson solver away from the inner wall (in m)
< Start time (in time steps) for anomalous diffusion
< Switch for periodic updates of the diffusion coefficients
< Period in time steps between subsequent updates of the diffusion coefficients
bool Diffusion::is_triggered_update |
( |
int |
step | ) |
const |
|
inline |
Determines whether the update of the diffusion coefficients should be executed on the given step.
This function checks the trigger associated with updating the diffusion coefficients.
- Parameters
-
step | The current step number. |
- Returns
- True if the trigger condition is met for the given step, false otherwise.
int Diffusion::trigger_count_update |
( |
int |
step | ) |
const |
|
inline |
Calculates how many times the update of the diffusion coefficient has been executed up to the given step.
This function calculates how many times the function updating the diffusion coefficients has been called up to the given time step, taking into account the start time and whether the update functionality is active.
- Parameters
-
step | The current time step index. |
- Returns
- The number of times the diffusivity update has been triggered.
Updates the diffusion coefficients from an input BP file and passes the data to a Fortran routine.
This function uses the C++ routine ReadSpeciesData to read updated diffusion coefficient data from the specified BP file. The data consists of a common 1D array (x) and a 3D array (y) with dimensions [4, n_species, N] corresponding to four different diffusion coefficient types for each species. The routine then calls the Fortran routine update_diffusion_eq_ftn, passing pointers to the x and y data, as well as the number of species.
- Parameters
-
input_filename | The name of the input BP file containing updated diffusion coefficients. |
n_species | The number of particle species. |
- Exceptions
-
std::runtime_error | if reading the diffusion coefficient data fails. |
Boundary object for handling domain exclusion regions; now a member variable for later reuse.
Adios stream used for reading the updated diffusion coefficients.
double Diffusion::inner_psi_bound |
|
private |
Inner boundary for diffusion in terms of normalized poloidal flux.
double Diffusion::outer_psi_bound |
|
private |
Outer boundary for diffusion in terms of normalized poloidal flux.
Triggers when it is time to update the diffusion coefficients.
bool Diffusion::update_on |
|
private |
Switch for periodic updates of the diffusion coefficients.
bool Diffusion::use_smoothing |
|
private |
Whether to smooth the fluid moments before solving the transport equations.
The documentation for this class was generated from the following files:
- /u/gitlab-xgc/builds/YGMz2TJ8/0/xgc/XGC-Devel/XGC_core/cpp/diffusion.hpp
- /u/gitlab-xgc/builds/YGMz2TJ8/0/xgc/XGC-Devel/XGC_core/cpp/diffusion.cpp