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_ParticleSoA.H>
34#include <CD_KMCDualState.H>
36#include <CD_KMCSolver.H>
37#include <CD_NamespaceHeader.H>
38
39namespace Physics {
40namespace ItoKMC {
41
45using FPR = Real;
46
51
56
61
70using DiffusionFunction = std::function<RealVect(const ItoParticle& p, const Real& a_dt)>;
71
76{
78 CDR
79};
80
89{
90public:
94 inline ItoKMCPhysics() noexcept;
95
99 inline virtual ~ItoKMCPhysics() noexcept;
100
104 inline void
105 defineKMC() const noexcept;
106
110 inline void
111 killKMC() const noexcept;
112
118 virtual Real
119 getNeutralDensity(const RealVect& a_pos) const noexcept = 0;
120
127 virtual Real
128 computeAlpha(const Real a_E, const RealVect& a_x) const = 0;
129
136 virtual Real
137 computeEta(const Real a_E, const RealVect& a_x) const = 0;
138
143 const Vector<RefCountedPtr<ItoSpecies>>&
144 getItoSpecies() const;
145
150 const Vector<RefCountedPtr<CdrSpecies>>&
151 getCdrSpecies() const;
152
157 const Vector<RefCountedPtr<RtSpecies>>&
158 getRtSpecies() const;
159
164 const Vector<DiffusionFunction>&
165 getItoDiffusionFunctions() const noexcept;
166
171 virtual Vector<std::string>
172 getPlotVariableNames() const noexcept;
173
184 virtual Vector<Real>
185 getPlotVariables(const RealVect& a_E,
186 const RealVect& a_pos,
187 const Vector<Real>& a_phi,
188 const Vector<RealVect>& a_gradPhi,
189 const Real a_dx,
190 const Real a_kappa) const noexcept;
191
196 virtual int
197 getNumberOfPlotVariables() const noexcept;
198
203 inline int
204 getNumItoSpecies() const;
205
210 inline int
211 getNumCdrSpecies() const;
212
217 inline int
218 getNumPlasmaSpecies() const;
219
224 inline int
225 getNumPhotonSpecies() const;
226
231 virtual bool
232 needGradients() const noexcept;
233
247 virtual bool
248 needGradient(const int a_plasmaIndex) const noexcept;
249
254 inline const std::map<int, std::pair<SpeciesType, int>>&
255 getSpeciesMap() const noexcept;
256
260 inline virtual void
261 parseRuntimeOptions() noexcept;
262
269 inline virtual Real
270 initialSigma(const Real a_time, const RealVect& a_pos) const;
271
285 virtual void
286 computeMobilities(Vector<Real>& a_mobilities,
287 const Real a_time,
288 const RealVect& a_pos,
289 const RealVect& a_E) const noexcept = 0;
290
300 virtual void
301 computeDiffusionCoefficients(Vector<Real>& a_diffusionCoefficients,
302 const Real a_time,
303 const RealVect& a_pos,
304 const RealVect& a_E) const noexcept = 0;
305
326 virtual void
327 secondaryEmissionEB(Vector<ParticleSoA<ItoParticle>>& a_secondaryParticles,
328 Vector<Real>& a_cdrFluxes,
329 Vector<ParticleSoA<Photon>>& a_secondaryPhotons,
330 const Vector<ParticleSoA<ItoParticle>>& a_primaryParticles,
331 const Vector<Real>& a_cdrFluxesExtrap,
332 const Vector<ParticleSoA<Photon>>& a_primaryPhotons,
333 const RealVect& a_E,
334 const RealVect& a_physicalCellCenter,
335 const RealVect& a_cellCentroid,
336 const RealVect& a_bndryCentroid,
337 const RealVect& a_bndryNormal,
338 const Real a_bndryArea,
339 const Real a_dx,
340 const Real a_dt,
341 const bool a_isDielectric,
342 const int a_matIndex) const noexcept = 0;
343
357 inline void
358 advanceKMC(Vector<FPR>& a_numParticles,
359 Vector<FPR>& a_numNewPhotons,
360 Real& a_physicsDt,
361 const Vector<Real>& a_phi,
362 const Vector<RealVect>& a_gradPhi,
363 const Real a_dt,
364 const RealVect a_E,
365 const RealVect a_pos,
366 const Real a_dx,
367 const Real a_kappa) const;
368
386 inline void
387 reconcileParticles(Vector<ParticleSoA<ItoParticle>*>& a_particles,
388 const Vector<FPR>& a_newNumParticles,
389 const Vector<FPR>& a_oldNumParticles,
390 const RealVect a_electricField,
391 const RealVect a_cellPos,
392 const RealVect a_centroidPos,
393 const RealVect a_lo,
394 const RealVect a_hi,
395 const RealVect a_bndryCentroid,
396 const RealVect a_bndryNormal,
397 const Real a_dx,
398 const Real a_kappa) const noexcept;
399
415 inline void
416 reconcilePhotons(Vector<ParticleSoA<Photon>*>& a_newPhotons,
417 const Vector<FPR>& a_numNewPhotons,
418 const RealVect a_cellPos,
419 const RealVect a_centroidPos,
420 const RealVect a_lo,
421 const RealVect a_hi,
422 const RealVect a_bndryCentroid,
423 const RealVect a_bndryNormal,
424 const Real a_dx,
425 const Real a_kappa) const noexcept;
426
434 inline void
435 reconcilePhotoionization(Vector<ParticleSoA<ItoParticle>*>& a_itoParticles,
436 Vector<ParticleSoA<NoPayload>*>& a_cdrParticles,
437 const Vector<ParticleSoA<Photon>*>& a_absorbedPhotons) const noexcept;
438
462 inline void
463 reconcileCdrParticles(Vector<ParticleSoA<NoPayload>*>& a_cdrParticles,
464 const Vector<ParticleSoA<ItoParticle>*>& a_itoParticles,
465 const Vector<long long>& a_numNewParticles,
466 const RealVect a_electricField,
467 const RealVect a_cellPos,
468 const RealVect a_centroidPos,
469 const RealVect a_lo,
470 const RealVect a_hi,
471 const RealVect a_bndryCentroid,
472 const RealVect a_bndryNormal,
473 const Real a_dx,
474 const Real a_kappa) const noexcept;
475
476protected:
480 enum class Algorithm
481 {
482 SSA,
484 Midpoint,
485 PRC,
489 HybridPRC,
491 };
492
497 {
498 Random,
499 Centroid,
500 Downstream,
501 Parent
502 };
503
508
513
517 std::map<int, std::pair<SpeciesType, int>> m_speciesMap;
518
522 std::string m_className;
523
528
533
537 static thread_local bool m_hasKMCSolver;
538
542 static thread_local KMCSolverType m_kmcSolver;
543
547 static thread_local KMCState m_kmcState;
548
555 static thread_local KMCState m_kmcStateScratch;
556
562 static thread_local std::vector<Real> m_kmcPropensityScratch;
563
571 static thread_local std::vector<long long> m_weightScratch;
572
578 static thread_local std::vector<Real> m_parentWeightScratch;
579
584 static thread_local std::vector<std::shared_ptr<const KMCReaction>> m_kmcReactionsThreadLocal;
585
592 static thread_local std::vector<std::shared_ptr<const KMCReaction>> m_kmcReactionsDt;
593
597 static thread_local std::vector<Real> m_reactiveDtFactorsDt;
598
602 static thread_local std::vector<Real> m_kmcPropensityScratchDt;
603
607 std::vector<KMCReaction> m_kmcReactions;
608
612 std::vector<ItoKMCPhotoReaction> m_photoReactions;
613
617 std::vector<Real> m_reactiveDtFactors;
618
625 std::map<int, std::pair<std::discrete_distribution<int>, std::map<int, int>>> m_photoPathways;
626
631
635 Vector<DiffusionFunction> m_itoDiffusionFunctions;
636
640 Vector<RefCountedPtr<ItoSpecies>> m_itoSpecies;
641
645 Vector<RefCountedPtr<CdrSpecies>> m_cdrSpecies;
646
650 Vector<RefCountedPtr<RtSpecies>> m_rtSpecies;
651
658
663
668
675
681
686
692
697 Real m_eps;
698
703
707 inline void
708 define() noexcept;
709
714 inline void
715 defineSpeciesMap() noexcept;
716
720 inline void
721 definePhotoPathways() noexcept;
722
726 inline void
727 parsePPC() noexcept;
728
732 inline void
733 parseDebug() noexcept;
734
738 inline void
739 parseAlgorithm() noexcept;
740
753 virtual void
754 updateReactionRates(std::vector<std::shared_ptr<const KMCReaction>>& a_kmcReactions,
755 const RealVect a_E,
756 const RealVect a_pos,
757 const Vector<Real>& a_phi,
758 const Vector<RealVect>& a_gradPhi,
759 const Real a_dt,
760 const Real a_dx,
761 const Real a_kappa) const noexcept = 0;
762
769 inline void
770 removeParticles(ParticleSoA<ItoParticle>& a_particles, const long long a_numToRemove) const;
771
794 inline RealVect
795 drawNewParticlePosition(const bool a_hasParent,
796 const bool a_hasDownstream,
797 const RealVect a_parentPos,
798 const RealVect a_upstreamPos,
799 const RealVect a_upstreamLo,
800 const RealVect a_upstreamHi,
801 const RealVect a_downstreamDirection,
802 const RealVect a_cellPos,
803 const RealVect a_centroidPos,
804 const RealVect a_lo,
805 const RealVect a_hi,
806 const RealVect a_bndryCentroid,
807 const RealVect a_bndryNormal,
808 const Real a_dx,
809 const Real a_kappa) const noexcept;
810
820 inline bool
821 sampleParentPosition(RealVect& a_pos,
822 const ParticleSoA<ItoParticle>& a_particles,
823 const std::vector<Real>& a_cumulativeWeights) const noexcept;
824
833 inline void
834 buildParentWeights(std::vector<Real>& a_cumulativeWeights,
835 const ParticleSoA<ItoParticle>& a_particles,
836 const std::size_t a_numEligible) const noexcept;
837
854 inline bool
855 computeUpstreamPosition(RealVect& a_pos,
856 RealVect& a_lo,
857 RealVect& a_hi,
858 const int& a_Z,
859 const ParticleSoA<ItoParticle>& a_particles,
860 const RealVect& a_electricField,
861 const RealVect& a_cellPos,
862 const Real& a_dx) const noexcept;
863
870 inline RealVect
871 noDiffusion(const ItoParticle& a_particle, const Real a_dt) const noexcept;
872
882 inline RealVect
883 isotropicDiffusion(const ItoParticle& a_particle, const Real a_dt) const noexcept;
884
891 inline RealVect
892 forwardIsotropicDiffusion(const ItoParticle& a_particle, const Real a_dt) const noexcept;
893};
894} // namespace ItoKMC
895} // namespace Physics
896
897#include <CD_NamespaceFooter.H>
898
900
901#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:76
@ CDR
Convection-diffusion-reaction (fluid) solver.
Definition CD_ItoKMCPhysics.H:78
@ Ito
Ito stochastic drift-diffusion solver.
Definition CD_ItoKMCPhysics.H:77
std::function< RealVect(const ItoParticle &p, const Real &a_dt)> DiffusionFunction
Basic function for diffusing a particle.
Definition CD_ItoKMCPhysics.H:70
Declaration of a class that encapsulates a set of secondary emission reactions.
SoA payload for Ito diffusion particles (drifting Brownian walkers)
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 ParticleSoA, an arena-backed Struct-of-Arrays particle container.
SoA payload for Monte Carlo radiative-transfer photons.
Declaration of a class which supplies a user interface to radiative transfer code.
Reaction type for advancing a KMCDualState for Kinetic Monte Carlo.
Definition CD_KMCDualStateReaction.H:34
Declaration of a "dual state" for advancing with the Kinetic Monte Carlo module.
Definition CD_KMCDualState.H:32
Class for running Kinetic Monte-Carlo simulations.
Definition CD_KMCSolver.H:61
Arena-backed Struct-of-Arrays particle container for a single grid patch.
Definition CD_ParticleSoA.H:655
Abstract base class coupling Kinetic Monte Carlo chemistry to Ito/CDR plasma solvers.
Definition CD_ItoKMCPhysics.H:89
int m_maxNewParticles
Maximum new number of particles generated by the chemistry advance.
Definition CD_ItoKMCPhysics.H:662
static thread_local std::vector< std::shared_ptr< const KMCReaction > > m_kmcReactionsDt
The subset of m_kmcReactionsThreadLocal that takes part in the physics time step calculation.
Definition CD_ItoKMCPhysics.H:592
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:680
Vector< RefCountedPtr< RtSpecies > > m_rtSpecies
List of solver-tracked photon species.
Definition CD_ItoKMCPhysics.H:650
int m_downstreamSpecies
An internal integer describing which species is the "ionizing" species.
Definition CD_ItoKMCPhysics.H:657
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:1119
Vector< DiffusionFunction > m_itoDiffusionFunctions
Diffusion functions for the various Ito species.
Definition CD_ItoKMCPhysics.H:635
Real m_eps
Solver setting for the Cao et. al. algorithm.
Definition CD_ItoKMCPhysics.H:697
bool m_debug
Turn on/off debugging.
Definition CD_ItoKMCPhysics.H:527
virtual void secondaryEmissionEB(Vector< ParticleSoA< ItoParticle > > &a_secondaryParticles, Vector< Real > &a_cdrFluxes, Vector< ParticleSoA< Photon > > &a_secondaryPhotons, const Vector< ParticleSoA< ItoParticle > > &a_primaryParticles, const Vector< Real > &a_cdrFluxesExtrap, const Vector< ParticleSoA< 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.
std::vector< Real > m_reactiveDtFactors
List of reactions that are a part of the time step limitation.
Definition CD_ItoKMCPhysics.H:617
int m_maxNewPhotons
Maximum new number of photons generated by the chemistry advance.
Definition CD_ItoKMCPhysics.H:667
void reconcilePhotons(Vector< ParticleSoA< 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:1016
void defineKMC() const noexcept
Define the KMC solver and state.
Definition CD_ItoKMCPhysicsImplem.H:121
RealVect isotropicDiffusion(const ItoParticle &a_particle, const Real a_dt) const noexcept
Isotropic diffusion function for a particle.
Definition CD_ItoKMCPhysicsImplem.H:1107
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:392
std::string m_className
Class name. Used for options parsing.
Definition CD_ItoKMCPhysics.H:522
const Vector< DiffusionFunction > & getItoDiffusionFunctions() const noexcept
Get diffusion functions for all Ito species.
Definition CD_ItoKMCPhysicsImplem.H:356
std::vector< ItoKMCPhotoReaction > m_photoReactions
List of photoionization reactions.
Definition CD_ItoKMCPhysics.H:612
const Vector< RefCountedPtr< RtSpecies > > & getRtSpecies() const
Get all photon species.
Definition CD_ItoKMCPhysicsImplem.H:350
Vector< RefCountedPtr< ItoSpecies > > m_itoSpecies
List of solver-tracked particle drift-diffusion species.
Definition CD_ItoKMCPhysics.H:640
Vector< RefCountedPtr< CdrSpecies > > m_cdrSpecies
List of solver-tracked fluid drift-diffusion species.
Definition CD_ItoKMCPhysics.H:645
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:386
Real m_exitTol
Exit tolerance for implicit KMC-leaping algorithms.
Definition CD_ItoKMCPhysics.H:702
static thread_local std::vector< Real > m_reactiveDtFactorsDt
Time-step scaling factors for m_kmcReactionsDt, parallel to it.
Definition CD_ItoKMCPhysics.H:597
virtual ~ItoKMCPhysics() noexcept
Destructor. Does nothing.
Definition CD_ItoKMCPhysicsImplem.H:58
static thread_local KMCState m_kmcStateScratch
Perturbed KMC state used by the time step tail of advanceKMC.
Definition CD_ItoKMCPhysics.H:555
static thread_local KMCSolverType m_kmcSolver
Kinetic Monte Carlo solver used in advanceReactionNetwork.
Definition CD_ItoKMCPhysics.H:542
void defineSpeciesMap() noexcept
Build internal representation of how we distinguish the Ito and CDR solvers.
Definition CD_ItoKMCPhysicsImplem.H:94
const Vector< RefCountedPtr< ItoSpecies > > & getItoSpecies() const
Get all particle drift-diffusion species.
Definition CD_ItoKMCPhysicsImplem.H:338
virtual void computeMobilities(Vector< Real > &a_mobilities, const Real a_time, const RealVect &a_pos, const RealVect &a_E) const noexcept=0
Compute the Ito solver mobilities.
Real m_SSAlim
Solver setting for the Cao et. al. algorithm.
Definition CD_ItoKMCPhysics.H:691
void parseAlgorithm() noexcept
Parse reaction algorithm.
Definition CD_ItoKMCPhysicsImplem.H:289
void removeParticles(ParticleSoA< ItoParticle > &a_particles, const long long a_numToRemove) const
Remove particles from the input list.
Definition CD_ItoKMCPhysicsImplem.H:953
int m_maxIter
Maximum number of iterations for implicit KMC-leaping algorithms.
Definition CD_ItoKMCPhysics.H:685
int m_Ncrit
Solver setting for the Cao et. al algorithm.
Definition CD_ItoKMCPhysics.H:674
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:246
virtual Real getNeutralDensity(const RealVect &a_pos) const noexcept=0
Get the neutral density at a position in space.
bool computeUpstreamPosition(RealVect &a_pos, RealVect &a_lo, RealVect &a_hi, const int &a_Z, const ParticleSoA< 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:902
virtual Real computeAlpha(const Real a_E, const RealVect &a_x) const =0
Compute Townsend ionization coefficient.
static thread_local std::vector< long long > m_weightScratch
Reusable buffer for ParticleManagement::partitionParticleWeights.
Definition CD_ItoKMCPhysics.H:571
static thread_local std::vector< Real > m_kmcPropensityScratchDt
Propensity buffer for m_kmcReactionsDt, parallel to it.
Definition CD_ItoKMCPhysics.H:602
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:625
RealVect drawNewParticlePosition(const bool a_hasParent, const bool a_hasDownstream, const RealVect a_parentPos, const RealVect a_upstreamPos, const RealVect a_upstreamLo, const RealVect a_upstreamHi, const RealVect a_downstreamDirection, 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
Draw a position for a particle created by the reaction network in a grid cell.
Definition CD_ItoKMCPhysicsImplem.H:691
Algorithm
KMC time-stepping algorithms available for advancing the reaction network.
Definition CD_ItoKMCPhysics.H:481
@ 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.
Algorithm m_algorithm
Algorithm to use for KMC advance.
Definition CD_ItoKMCPhysics.H:507
virtual void parseRuntimeOptions() noexcept
Parse run-time options.
Definition CD_ItoKMCPhysicsImplem.H:254
ParticlePlacement
Strategies for placing secondary particles created during the KMC advance.
Definition CD_ItoKMCPhysics.H:497
@ Downstream
Place particles in the downstream region relative to the primary particle drift.
@ Parent
Place particles on an existing particle, drawn with probability proportional to its weight.
@ Random
Place particles at a uniformly random position within the cell.
@ Centroid
Place particles at the cell centroid.
void reconcileParticles(Vector< ParticleSoA< 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:577
const Vector< RefCountedPtr< CdrSpecies > > & getCdrSpecies() const
Get all fluid drift-diffusion species.
Definition CD_ItoKMCPhysicsImplem.H:344
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:584
std::vector< KMCReaction > m_kmcReactions
List of reactions for the KMC solver.
Definition CD_ItoKMCPhysics.H:607
int getNumPhotonSpecies() const
Return number of RTE solvers.
Definition CD_ItoKMCPhysicsImplem.H:380
virtual Vector< std::string > getPlotVariableNames() const noexcept
Get plot variable names.
Definition CD_ItoKMCPhysics.cpp:35
ItoKMCSurfaceReactionSet m_surfaceReactions
Surface reactions.
Definition CD_ItoKMCPhysics.H:630
int getNumPlasmaSpecies() const
Return total number of plasma species.
Definition CD_ItoKMCPhysicsImplem.H:374
int getNumItoSpecies() const
Return number of Ito solvers.
Definition CD_ItoKMCPhysicsImplem.H:362
virtual int getNumberOfPlotVariables() const noexcept
Get number of extra plot variables contributed by this physics model.
Definition CD_ItoKMCPhysics.cpp:56
void define() noexcept
Define method – defines all the internal machinery.
Definition CD_ItoKMCPhysicsImplem.H:64
virtual void computeDiffusionCoefficients(Vector< Real > &a_diffusionCoefficients, const Real a_time, const RealVect &a_pos, const RealVect &a_E) const noexcept=0
Compute the Ito solver diffusion coefficients.
void buildParentWeights(std::vector< Real > &a_cumulativeWeights, const ParticleSoA< ItoParticle > &a_particles, const std::size_t a_numEligible) const noexcept
Build the running weight sum that sampleParentPosition() draws from.
Definition CD_ItoKMCPhysicsImplem.H:766
bool sampleParentPosition(RealVect &a_pos, const ParticleSoA< ItoParticle > &a_particles, const std::vector< Real > &a_cumulativeWeights) const noexcept
Draw the position of a parent particle, with probability proportional to particle weight.
Definition CD_ItoKMCPhysicsImplem.H:783
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:517
RealVect noDiffusion(const ItoParticle &a_particle, const Real a_dt) const noexcept
No diffusion function for a particle.
Definition CD_ItoKMCPhysicsImplem.H:1101
void killKMC() const noexcept
Kill the KMC solver.
Definition CD_ItoKMCPhysicsImplem.H:172
void definePhotoPathways() noexcept
Define pathways for photo-reactions.
Definition CD_ItoKMCPhysicsImplem.H:193
void reconcilePhotoionization(Vector< ParticleSoA< ItoParticle > * > &a_itoParticles, Vector< ParticleSoA< NoPayload > * > &a_cdrParticles, const Vector< ParticleSoA< Photon > * > &a_absorbedPhotons) const noexcept
Reconcile photoionization reactions.
Definition CD_ItoKMCPhysicsImplem.H:1055
void parsePPC() noexcept
Parse the maximum number of particles generated per cell.
Definition CD_ItoKMCPhysicsImplem.H:264
void reconcileCdrParticles(Vector< ParticleSoA< NoPayload > * > &a_cdrParticles, const Vector< ParticleSoA< ItoParticle > * > &a_itoParticles, const Vector< long long > &a_numNewParticles, 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
Turn the CDR mass created by the reaction network into particles.
Definition CD_ItoKMCPhysicsImplem.H:806
static thread_local bool m_hasKMCSolver
Is the KMC solver defined or not.
Definition CD_ItoKMCPhysics.H:537
int getNumCdrSpecies() const
Return number of CDR solvers.
Definition CD_ItoKMCPhysicsImplem.H:368
ParticlePlacement m_particlePlacement
Particle placement algorithm.
Definition CD_ItoKMCPhysics.H:512
void parseDebug() noexcept
Parse the maximum number of particles generated per cell.
Definition CD_ItoKMCPhysicsImplem.H:279
virtual bool needGradients() const noexcept
Return true if the physics model requires species density gradients.
Definition CD_ItoKMCPhysics.cpp:64
bool m_isDefined
Is defined or not.
Definition CD_ItoKMCPhysics.H:532
static thread_local std::vector< Real > m_kmcPropensityScratch
Propensity buffer used by the time step tail of advanceKMC.
Definition CD_ItoKMCPhysics.H:562
static thread_local std::vector< Real > m_parentWeightScratch
Running sum of the eligible parent weights in a grid cell, used by ParticlePlacement::Parent.
Definition CD_ItoKMCPhysics.H:578
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:43
static thread_local KMCState m_kmcState
KMC state used in advanceReactionNetwork.
Definition CD_ItoKMCPhysics.H:547
virtual bool needGradient(const int a_plasmaIndex) const noexcept
Return true if the physics model reads the density gradient of one particular plasma species.
Definition CD_ItoKMCPhysicsImplem.H:112
ItoKMCPhysics() noexcept
Constructor. Does nothing.
Definition CD_ItoKMCPhysicsImplem.H:32
Class for holding a set of surface reactions.
Definition CD_ItoKMCSurfaceReactionSet.H:27
Namespace containing physics models for use with chombo-discharge.
Definition CD_AdvectionDiffusion.H:16
SoA payload for ItoSolver particles, i.e. drifting Brownian walkers.
Definition CD_ItoParticle.H:31
Empty payload: ParticleSoA<> is a position+weight+metadata point particle.
Definition CD_ParticleSoA.H:289
SoA payload for Monte Carlo radiative-transfer photons.
Definition CD_Photon.H:29