chombo-discharge
Loading...
Searching...
No Matches
CD_ItoKMCPhysics.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_ITOKMCPHYSICS_H
14#define CD_ITOKMCPHYSICS_H
15
16// Std includes
17#include <memory>
18#include <vector>
19
20// Chombo includes
21#include <RealVect.H>
22#include <RefCountedPtr.H>
23#include <List.H>
24
25// Our includes
26#include <CD_ItoSpecies.H>
27#include <CD_CdrSpecies.H>
28#include <CD_RtSpecies.H>
29#include <CD_Photon.H>
30#include <CD_ItoParticle.H>
31#include <CD_PointParticle.H>
34#include <CD_KMCDualState.H>
36#include <CD_KMCSolver.H>
37#include <CD_NamespaceHeader.H>
38
39namespace Physics {
40 namespace ItoKMC {
41
45 using FPR = Real;
46
51
56
61
66
71 {
73 CDR
74 };
75
84 {
85 public:
89 inline ItoKMCPhysics() noexcept;
90
94 inline virtual ~ItoKMCPhysics() noexcept;
95
99 inline void
100 defineKMC() const noexcept;
101
105 inline void
106 killKMC() const noexcept;
107
113 virtual Real
114 getNeutralDensity(const RealVect& a_pos) const noexcept = 0;
115
122 virtual Real
123 computeAlpha(const Real a_E, const RealVect& a_x) const = 0;
124
131 virtual Real
132 computeEta(const Real a_E, const RealVect& a_x) const = 0;
133
139 getItoSpecies() const;
140
146 getCdrSpecies() const;
147
153 getRtSpecies() const;
154
161
166 virtual Vector<std::string>
168
186
191 virtual int
193
198 inline int
200
205 inline int
207
212 inline int
214
219 inline int
221
226 virtual bool
228
233 inline const std::map<int, std::pair<SpeciesType, int>>&
235
239 inline virtual void
241
250
260
270
291 virtual void
308
322 inline void
333
351 inline void
364
380 inline void
391
399 inline void
403
404 protected:
420
425 {
426 Random,
427 Centroid,
429 };
430
435
440
445
450
455
460
465
469 static thread_local bool m_hasKMCSolver;
470
474 static thread_local KMCSolverType m_kmcSolver;
475
479 static thread_local KMCState m_kmcState;
480
486
491
496
501
509
514
519
524
529
534
541
546
551
557
563
568
574
580
585
589 inline void
591
596 inline void
598
602 inline void
604
608 inline void
610
614 inline void
616
620 inline void
622
635 virtual void
644
651 inline void
653
670 inline bool
672 RealVect& a_lo,
673 RealVect& a_hi,
674 const int& a_Z,
679
688
697
706 };
707 } // namespace ItoKMC
708} // namespace Physics
709
710#include <CD_NamespaceFooter.H>
711
713
714#endif
Declaration of a class that passes information into CdrSolver (e.g., initial conditions).
Declaration of the Physics::ItoKMC::ItoKMCPhotoReaction class.
Implementation of CD_ItoKMCPhysics.H.
Real FPR
Floating-point type used to represent particle counts in the KMC state.
Definition CD_ItoKMCPhysics.H:45
SpeciesType
Tag for distinguishing species solved with an Ito diffusion or CDR fluid formalism.
Definition CD_ItoKMCPhysics.H:71
@ CDR
Convection-diffusion-reaction (fluid) solver.
Definition CD_ItoKMCPhysics.H:73
@ Ito
Ito stochastic drift-diffusion solver.
Definition CD_ItoKMCPhysics.H:72
std::function< RealVect(const ItoParticle &p, const Real &a_dt)> DiffusionFunction
Basic function for diffusing a particle.
Definition CD_ItoKMCPhysics.H:65
Declaration of a class that encapsulates a set of secondary emission reactions.
Declaration of a particle class for Ito diffusion.
Declaration of an ItoSpecies class that passes in names and initial data to ItoSolvers.
Declaration of a simple plasma reaction type for Kinetic Monte Carlo.
Declaration of a simple state vector for running Kinetic Monte Carlo for plasma problems.
Class for running Kinetic Monte Carlo functionality.
Declaration of a photon class for particle methods.
Declaration of a computational point particle.
Declaration of a class which supplies a user interface to radiative transfer code.
A particle class for use with ItoSolvers, i.e. drifting Brownian walkers.
Definition CD_ItoParticle.H:41
Reaction type for advancing a KMCDualState for Kinetic Monte Carlo.
Definition CD_KMCDualStateReaction.H:34
Particle class for usage with Monte Carlo radiative transfer.
Definition CD_Photon.H:30
Abstract base class coupling Kinetic Monte Carlo chemistry to Ito/CDR plasma solvers.
Definition CD_ItoKMCPhysics.H:84
int m_maxNewParticles
Maximum new number of particles generated by the chemistry advance.
Definition CD_ItoKMCPhysics.H:545
void reconcilePhotons(Vector< List< Photon > * > &a_newPhotons, const Vector< FPR > &a_numNewPhotons, const RealVect a_cellPos, const RealVect a_centroidPos, const RealVect a_lo, const RealVect a_hi, const RealVect a_bndryCentroid, const RealVect a_bndryNormal, const Real a_dx, const Real a_kappa) const noexcept
Generate new photons.
Definition CD_ItoKMCPhysicsImplem.H:781
virtual Real computeEta(const Real a_E, const RealVect &a_x) const =0
Compute Townsend attachment coefficient.
int m_NSSA
Solver setting for the Cao et. al algorithm.
Definition CD_ItoKMCPhysics.H:562
bool m_incrementNewParticles
If true, increment onto existing particles rather than creating new ones.
Definition CD_ItoKMCPhysics.H:464
Vector< RefCountedPtr< RtSpecies > > m_rtSpecies
List of solver-tracked photon species.
Definition CD_ItoKMCPhysics.H:533
int m_downstreamSpecies
An internal integer describing which species is the "ionizing" species.
Definition CD_ItoKMCPhysics.H:540
virtual void updateReactionRates(std::vector< std::shared_ptr< const KMCReaction > > &a_kmcReactions, const RealVect a_E, const RealVect a_pos, const Vector< Real > &a_phi, const Vector< RealVect > &a_gradPhi, const Real a_dt, const Real a_dx, const Real a_kappa) const noexcept=0
Update reaction rates.
RealVect forwardIsotropicDiffusion(const ItoParticle &a_particle, const Real a_dt) const noexcept
Quasi-isotropic diffusion function for a particle which does not permit backward diffusion.
Definition CD_ItoKMCPhysicsImplem.H:878
Vector< DiffusionFunction > m_itoDiffusionFunctions
Diffusion functions for the various Ito species.
Definition CD_ItoKMCPhysics.H:518
virtual Vector< Real > computeDiffusionCoefficients(const Real a_time, const RealVect &a_pos, const RealVect &a_E) const noexcept=0
Compute the Ito solver diffusion coefficients.
Real m_eps
Solver setting for the Cao et. al. algorithm.
Definition CD_ItoKMCPhysics.H:579
bool m_debug
Turn on/off debugging.
Definition CD_ItoKMCPhysics.H:454
void reconcilePhotoionization(Vector< List< ItoParticle > * > &a_itoParticles, Vector< List< PointParticle > * > &a_cdrParticles, const Vector< List< Photon > * > &a_absorbedPhotons) const noexcept
Reconcile photoionization reactions.
Definition CD_ItoKMCPhysicsImplem.H:814
std::vector< Real > m_reactiveDtFactors
List of reactions that are a part of the time step limitation.
Definition CD_ItoKMCPhysics.H:500
int m_maxNewPhotons
Maximum new number of photons generated by the chemistry advance.
Definition CD_ItoKMCPhysics.H:550
void defineKMC() const noexcept
Define the KMC solver and state.
Definition CD_ItoKMCPhysicsImplem.H:110
RealVect isotropicDiffusion(const ItoParticle &a_particle, const Real a_dt) const noexcept
Isotropic diffusion function for a particle.
Definition CD_ItoKMCPhysicsImplem.H:866
void advanceKMC(Vector< FPR > &a_numParticles, Vector< FPR > &a_numNewPhotons, Real &a_physicsDt, const Vector< Real > &a_phi, const Vector< RealVect > &a_gradPhi, const Real a_dt, const RealVect a_E, const RealVect a_pos, const Real a_dx, const Real a_kappa) const
Advance the reaction network using the KMC algorithm.
Definition CD_ItoKMCPhysicsImplem.H:340
std::string m_className
Class name. Used for options parsing.
Definition CD_ItoKMCPhysics.H:449
bool computeUpstreamPosition(RealVect &a_pos, RealVect &a_lo, RealVect &a_hi, const int &a_Z, const List< ItoParticle > &a_particles, const RealVect &a_electricField, const RealVect &a_cellPos, const Real &a_dx) const noexcept
Compute the upstream position in a grid cell. Returns false if an upstream position was undefinable.
Definition CD_ItoKMCPhysicsImplem.H:658
const Vector< DiffusionFunction > & getItoDiffusionFunctions() const noexcept
Get diffusion functions for all Ito species.
Definition CD_ItoKMCPhysicsImplem.H:304
std::vector< ItoKMCPhotoReaction > m_photoReactions
List of photoionization reactions.
Definition CD_ItoKMCPhysics.H:495
const Vector< RefCountedPtr< RtSpecies > > & getRtSpecies() const
Get all photon species.
Definition CD_ItoKMCPhysicsImplem.H:298
Vector< RefCountedPtr< ItoSpecies > > m_itoSpecies
List of solver-tracked particle drift-diffusion species.
Definition CD_ItoKMCPhysics.H:523
Vector< RefCountedPtr< CdrSpecies > > m_cdrSpecies
List of solver-tracked fluid drift-diffusion species.
Definition CD_ItoKMCPhysics.H:528
virtual Real initialSigma(const Real a_time, const RealVect &a_pos) const
Set initial surface charge. Default is 0, override if you want.
Definition CD_ItoKMCPhysicsImplem.H:334
Real m_exitTol
Exit tolerance for implicit KMC-leaping algorithms.
Definition CD_ItoKMCPhysics.H:584
virtual ~ItoKMCPhysics() noexcept
Destructor. Does nothing.
Definition CD_ItoKMCPhysicsImplem.H:56
static thread_local KMCSolverType m_kmcSolver
Kinetic Monte Carlo solver used in advanceReactionNetwork.
Definition CD_ItoKMCPhysics.H:474
void defineSpeciesMap() noexcept
Build internal representation of how we distinguish the Ito and CDR solvers.
Definition CD_ItoKMCPhysicsImplem.H:92
const Vector< RefCountedPtr< ItoSpecies > > & getItoSpecies() const
Get all particle drift-diffusion species.
Definition CD_ItoKMCPhysicsImplem.H:286
Real m_SSAlim
Solver setting for the Cao et. al. algorithm.
Definition CD_ItoKMCPhysics.H:573
void parseAlgorithm() noexcept
Parse reaction algorithm.
Definition CD_ItoKMCPhysicsImplem.H:237
int m_maxIter
Maximum number of iterations for implicit KMC-leaping algorithms.
Definition CD_ItoKMCPhysics.H:567
int m_Ncrit
Solver setting for the Cao et. al algorithm.
Definition CD_ItoKMCPhysics.H:556
const std::map< int, std::pair< SpeciesType, int > > & getSpeciesMap() const noexcept
Get the internal mapping from plasma-species index to solver type and solver index.
Definition CD_ItoKMCPhysicsImplem.H:197
virtual Real getNeutralDensity(const RealVect &a_pos) const noexcept=0
Get the neutral density at a position in space.
virtual Real computeAlpha(const Real a_E, const RealVect &a_x) const =0
Compute Townsend ionization coefficient.
std::map< int, std::pair< std::discrete_distribution< int >, std::map< int, int > > > m_photoPathways
Random number generators for photoionization pathways.
Definition CD_ItoKMCPhysics.H:508
void reconcileParticles(Vector< List< ItoParticle > * > &a_particles, const Vector< FPR > &a_newNumParticles, const Vector< FPR > &a_oldNumParticles, const RealVect a_electricField, const RealVect a_cellPos, const RealVect a_centroidPos, const RealVect a_lo, const RealVect a_hi, const RealVect a_bndryCentroid, const RealVect a_bndryNormal, const Real a_dx, const Real a_kappa) const noexcept
Reconcile the number of particles.
Definition CD_ItoKMCPhysicsImplem.H:513
Algorithm
KMC time-stepping algorithms available for advancing the reaction network.
Definition CD_ItoKMCPhysics.H:409
@ HybridMidpoint
Hybrid SSA / midpoint (Cao et al.).
@ ImplicitEuler
Implicit tau-leaping with Euler steps.
@ SSA
Gillespie's Stochastic Simulation Algorithm (exact).
@ Midpoint
Explicit tau-leaping with midpoint (second-order) steps.
@ ExplicitEuler
Explicit tau-leaping with Euler steps.
@ HybridImplicitEuler
Hybrid SSA / implicit Euler (Cao et al.).
@ HybridPRC
Hybrid SSA / PRC (Cao et al.).
@ HybridExplicitEuler
Hybrid SSA / explicit Euler (Cao et al.).
@ PRC
Partially-rejected corrections tau-leaping.
virtual Vector< Real > computeMobilities(const Real a_time, const RealVect &a_pos, const RealVect &a_E) const noexcept=0
Compute the Ito solver mobilities.
Algorithm m_algorithm
Algorithm to use for KMC advance.
Definition CD_ItoKMCPhysics.H:434
virtual void parseRuntimeOptions() noexcept
Parse run-time options.
Definition CD_ItoKMCPhysicsImplem.H:205
ParticlePlacement
Strategies for placing secondary particles created during the KMC advance.
Definition CD_ItoKMCPhysics.H:425
@ Downstream
Place particles in the downstream region relative to the primary particle drift.
@ Random
Place particles at a uniformly random position within the cell.
@ Centroid
Place particles at the cell centroid.
void removeParticles(List< ItoParticle > &a_particles, const long long a_numToRemove) const
Remove particles from the input list.
Definition CD_ItoKMCPhysicsImplem.H:716
const Vector< RefCountedPtr< CdrSpecies > > & getCdrSpecies() const
Get all fluid drift-diffusion species.
Definition CD_ItoKMCPhysicsImplem.H:292
static thread_local std::vector< std::shared_ptr< const KMCReaction > > m_kmcReactionsThreadLocal
Thread-local copies of KMC reactions used in advanceReactionNetwork.
Definition CD_ItoKMCPhysics.H:485
std::vector< KMCReaction > m_kmcReactions
List of reactions for the KMC solver.
Definition CD_ItoKMCPhysics.H:490
int getNumPhotonSpecies() const
Return number of RTE solvers.
Definition CD_ItoKMCPhysicsImplem.H:328
virtual Vector< std::string > getPlotVariableNames() const noexcept
Get plot variable names.
Definition CD_ItoKMCPhysics.cpp:28
ItoKMCSurfaceReactionSet m_surfaceReactions
Surface reactions.
Definition CD_ItoKMCPhysics.H:513
int getNumPlasmaSpecies() const
Return total number of plasma species.
Definition CD_ItoKMCPhysicsImplem.H:322
virtual void secondaryEmissionEB(Vector< List< ItoParticle > > &a_secondaryParticles, Vector< Real > &a_cdrFluxes, Vector< List< Photon > > &a_secondaryPhotons, const Vector< List< ItoParticle > > &a_primaryParticles, const Vector< Real > &a_cdrFluxesExtrap, const Vector< List< Photon > > &a_primaryPhotons, const RealVect &a_E, const RealVect &a_physicalCellCenter, const RealVect &a_cellCentroid, const RealVect &a_bndryCentroid, const RealVect &a_bndryNormal, const Real a_bndryArea, const Real a_dx, const Real a_dt, const bool a_isDielectric, const int a_matIndex) const noexcept=0
Resolve secondary emission at the EB.
int getNumItoSpecies() const
Return number of Ito solvers.
Definition CD_ItoKMCPhysicsImplem.H:310
virtual int getNumberOfPlotVariables() const noexcept
Get number of extra plot variables contributed by this physics model.
Definition CD_ItoKMCPhysics.cpp:49
void define() noexcept
Define method – defines all the internal machinery.
Definition CD_ItoKMCPhysicsImplem.H:62
std::map< int, std::pair< SpeciesType, int > > m_speciesMap
Map for associating a plasma species with an Ito solver or CDR solver.
Definition CD_ItoKMCPhysics.H:444
RealVect noDiffusion(const ItoParticle &a_particle, const Real a_dt) const noexcept
No diffusion function for a particle.
Definition CD_ItoKMCPhysicsImplem.H:860
void killKMC() const noexcept
Kill the KMC solver.
Definition CD_ItoKMCPhysicsImplem.H:130
void definePhotoPathways() noexcept
Define pathways for photo-reactions.
Definition CD_ItoKMCPhysicsImplem.H:144
void parsePPC() noexcept
Parse the maximum number of particles generated per cell.
Definition CD_ItoKMCPhysicsImplem.H:215
static thread_local bool m_hasKMCSolver
Is the KMC solver defined or not.
Definition CD_ItoKMCPhysics.H:469
int getNumCdrSpecies() const
Return number of CDR solvers.
Definition CD_ItoKMCPhysicsImplem.H:316
ParticlePlacement m_particlePlacement
Particle placement algorithm.
Definition CD_ItoKMCPhysics.H:439
void parseDebug() noexcept
Parse the maximum number of particles generated per cell.
Definition CD_ItoKMCPhysicsImplem.H:227
virtual bool needGradients() const noexcept
Return true if the physics model requires species density gradients.
Definition CD_ItoKMCPhysics.cpp:57
bool m_isDefined
Is defined or not.
Definition CD_ItoKMCPhysics.H:459
virtual Vector< Real > getPlotVariables(const RealVect &a_E, const RealVect &a_pos, const Vector< Real > &a_phi, const Vector< RealVect > &a_gradPhi, const Real a_dx, const Real a_kappa) const noexcept
Get plot variables.
Definition CD_ItoKMCPhysics.cpp:36
static thread_local KMCState m_kmcState
KMC state used in advanceReactionNetwork.
Definition CD_ItoKMCPhysics.H:479
ItoKMCPhysics() noexcept
Constructor. Does nothing.
Definition CD_ItoKMCPhysicsImplem.H:29
Class for holding a set of surface reactions.
Definition CD_ItoKMCSurfaceReactionSet.H:27
A particle class that only has a position and a weight.
Definition CD_PointParticle.H:30
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26
Namespace containing physics models for use with chombo-discharge.
Definition CD_AdvectionDiffusion.H:16