chombo-discharge
Loading...
Searching...
No Matches
CD_ItoKMCJSON.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_ITOKMCJSON_H
14#define CD_ITOKMCJSON_H
15
16// Std includes
17#include <map>
18#include <memory>
19#include <string>
20
21// Third-party includes
22#include <nlohmann/json.hpp>
23
24// Our includes
26#include <CD_ItoKMCPhysics.H>
27#include <CD_LookupTable.H>
28#include <CD_NamespaceHeader.H>
29
30namespace Physics {
31 namespace ItoKMC {
32
37 {
38 public:
45
54 using FunctionEN = std::function<Real(const Real a_E, const Real a_N)>;
55
62
68 using FunctionEX = std::function<Real(const Real E, const RealVect& x)>;
69
81 Real(const Real E, const Real V, const Real dx, const Real dt, const RealVect& x, const Vector<Real>& phi)>;
82
89
95
102
106 ItoKMCJSON();
107
111 virtual ~ItoKMCJSON() noexcept;
112
116 virtual void
118
126
135
144
149 virtual Vector<std::string>
151
169
174 virtual int
176
181 virtual bool
183
193
205
226 virtual void
243
244 protected:
249
254
259
264
269
274
279
284
289
294
300
305
310
316
322
327
331 std::map<std::string, int> m_itoSpeciesMap;
332
336 std::map<std::string, int> m_cdrSpeciesMap;
337
341 std::map<std::string, int> m_plasmaIndexMap;
342
346 std::map<std::string, int> m_photonIndexMap;
347
352
357
362
367
373
378
383
388
393
398
403
408
412 std::pair<bool, std::string> m_autoAlpha;
413
417 std::pair<bool, std::string> m_autoEta;
418
423
428
433
438
443
448
453
459 virtual std::string
461
465 virtual void
466 parseJSON();
467
471 virtual void
473
478 virtual void
480
485 virtual void
487
493 virtual bool
495
501 virtual bool
503
509 virtual bool
511
517 virtual bool
519
525 virtual bool
527
533 virtual bool
535
541 virtual bool
543
548 virtual void
550
557 virtual void
559 const std::vector<std::string>& a_products,
561
568 virtual void
570 const std::vector<std::string>& a_products,
572
576 virtual void
578
582 virtual void
584
589 virtual void
591
596 virtual void
598
604 virtual void
606
610 virtual void
612
616 virtual void
618
622 virtual void
624
628 virtual void
630
634 virtual void
636
640 virtual void
642
646 virtual void
648
652 virtual void
654
658 virtual void
660
664 virtual void
666
671 virtual void
673
677 virtual void
679
683 virtual void
685
692 virtual void
694 std::vector<std::string>& a_products,
696
708 virtual void
710 std::list<size_t>& a_plasmaReactants,
711 std::list<size_t>& a_photonReactants,
712 std::list<size_t>& a_backgroundProducts,
713 std::list<size_t>& a_plasmaProducts,
714 std::list<size_t>& a_photonProducts,
715 const std::vector<std::string>& a_reactants,
717
730
736 virtual std::pair<bool, std::string>
738
744 virtual std::pair<bool, std::string>
746
754
763
771 virtual std::vector<std::tuple<std::string, std::vector<std::string>, std::vector<std::string>>>
773 const std::vector<std::string>& a_products,
775
787 virtual void
796
803 std::vector<size_t>
805 };
806 } // namespace ItoKMC
807} // namespace Physics
808
809#include <CD_NamespaceFooter.H>
810
811#endif
Declaration of a background species class for usage with ItoKMCJSON.
Declaration of the Physics::ItoKMC::ItoKMCPhysics abstract base class.
SpeciesType
Tag for distinguishing species solved with an Ito diffusion or CDR fluid formalism.
Definition CD_ItoKMCPhysics.H:71
Declaration of a table for looking up coefficients etc.
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
Class for interpolation of f = f(x) data in one independent variable x.
Definition CD_LookupTable1D.H:32
Particle class for usage with Monte Carlo radiative transfer.
Definition CD_Photon.H:30
Encapsulation of a background species for usage with ItoKMCJSON.
Definition CD_ItoKMCBackgroundSpecies.H:32
Implementation of ItoKMCPhysics which parses input data from a JSON file.
Definition CD_ItoKMCJSON.H:37
virtual Real computeEta(const Real a_E, const RealVect &a_pos) const noexcept override
Compute Townsend attachment coefficient.
Definition CD_ItoKMCJSON.cpp:3427
virtual std::pair< bool, std::string > parsePlasmaReactionPlot(const nlohmann::json &a_reactionJSON) const
Parse whether or not a reaction rate should be plotted.
Definition CD_ItoKMCJSON.cpp:3129
virtual void initializeDiffusionCoefficients()
Initialize diffusion coefficients.
Definition CD_ItoKMCJSON.cpp:1517
std::vector< std::list< size_t > > m_plasmaReactionPhotonProducts
List of photon species on the right-hand side of a reaction.
Definition CD_ItoKMCJSON.H:392
FunctionEX m_alpha
Townsend ionization coefficient. Defined during parseAlpha.
Definition CD_ItoKMCJSON.H:432
virtual void initializeAutomaticTownsend(const std::string &a_coeff)
Initialize automatic Townsend coefficient (ionizatino or attachment) from the reaction rates.
Definition CD_ItoKMCJSON.cpp:870
std::vector< std::list< size_t > > m_plasmaReactionPlasmaProducts
List of plasma species on the right-hand side of a reaction.
Definition CD_ItoKMCJSON.H:387
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 override
Get plot variables.
Definition CD_ItoKMCJSON.cpp:3759
virtual void initializeTownsendCoefficient(const std::string &a_coeff)
Parse one of the Townsend coefficients.
Definition CD_ItoKMCJSON.cpp:709
FunctionEX m_eta
Townsend attachment coefficient. Defined during parseEta.
Definition CD_ItoKMCJSON.H:437
std::function< Real(const Real a_E, const Real a_N)> FunctionEN
Function for encapsulating operations f = f(E,N). field in Townsend units.
Definition CD_ItoKMCJSON.H:54
virtual bool isPlasmaSpecies(const std::string &a_name) const noexcept
Return true if species is a plasma species.
Definition CD_ItoKMCJSON.cpp:190
bool m_plotEta
Plot Townsend attachment coefficient.
Definition CD_ItoKMCJSON.H:263
virtual bool isBracketed(const std::string &a_str) const noexcept
Check if a string contains starts with '(' and ends with ')'.
Definition CD_ItoKMCJSON.cpp:235
virtual void initializeSurfaceEmission(const std::string &a_surface)
Initialize surface reactions.
Definition CD_ItoKMCJSON.cpp:2046
bool m_plotGas
Plot gas pressure, density, and temperature.
Definition CD_ItoKMCJSON.H:253
virtual void initializeGasLaw()
Initialize gas law.
Definition CD_ItoKMCJSON.cpp:307
virtual void sanctifyPhotoReaction(const std::vector< std::string > &a_reactants, const std::vector< std::string > &a_products, const std::string &a_reaction) const noexcept
Check that a photo-reaction makes sense. I.e. that all species are properly defined and that it conse...
Definition CD_ItoKMCJSON.cpp:2464
virtual void initializePhotonSpecies()
Initialize the photon species.
Definition CD_ItoKMCJSON.cpp:1702
virtual void secondaryEmissionEB(Vector< List< ItoParticle > > &a_secondaryParticles, Vector< Real > &a_secondaryCDRFluxes, Vector< List< Photon > > &a_secondaryPhotons, const Vector< List< ItoParticle > > &a_primaryParticles, const Vector< Real > &a_primaryCDRFluxes, const Vector< List< Photon > > &a_primaryPhotons, const RealVect &a_E, const RealVect &a_cellCenter, 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 override
Resolve secondary emission at the EB.
Definition CD_ItoKMCJSON.cpp:3525
FunctionX m_gasPressure
Background gas pressure.
Definition CD_ItoKMCJSON.H:442
std::vector< FunctionEVXTP > m_kmcReactionRates
Function-based plasma reaction rates. Same index as the actual reactions.
Definition CD_ItoKMCJSON.H:366
virtual LookupTable1D< Real, 1 > parseTableEByN(const nlohmann::json &a_tableEntry, const std::string &a_dataID) const
Parse a table which is stored in E/N format.
Definition CD_ItoKMCJSON.cpp:3238
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 override
Update reaction rates.
Definition CD_ItoKMCJSON.cpp:3476
virtual void initializeDensities()
Parse initial densities for CDR and Ito species.
Definition CD_ItoKMCJSON.cpp:1374
std::function< Real(const Real a_T)> FunctionT
Function for encapsulating a function f = f(T) where T is the temperature of some species.
Definition CD_ItoKMCJSON.H:94
std::pair< bool, std::string > m_autoAlpha
Flag if the user wants to compute the alpha coefficient from the reactions.
Definition CD_ItoKMCJSON.H:412
std::set< std::string > m_allSpecies
All species that have been defined.
Definition CD_ItoKMCJSON.H:299
virtual void previewFunctionEX(const nlohmann::json &a_json, const FunctionEX &a_function) const
Simple function for previewing a rate/coefficient defined as a function f = f(E,x)
Definition CD_ItoKMCJSON.cpp:1033
virtual Vector< std::string > getPlotVariableNames() const noexcept override
Get plot variable names.
Definition CD_ItoKMCJSON.cpp:3721
std::function< Real(const RealVect &a_position)> FunctionX
Function for encapsulating a function f = f(x) where x is the physical coordinates.
Definition CD_ItoKMCJSON.H:61
std::map< std::string, int > m_cdrSpeciesMap
Map for indexing from an ID to an Ito solver index.
Definition CD_ItoKMCJSON.H:336
virtual void initializePlasmaReactions()
Initialize plasma reactions.
Definition CD_ItoKMCJSON.cpp:1872
virtual bool containsBracket(const std::string &a_str) const noexcept
Check if a string contains standard brackets.
Definition CD_ItoKMCJSON.cpp:212
std::vector< std::pair< int, FunctionEN > > m_dielectricFieldEmission
List of dielectric field emission reactions.
Definition CD_ItoKMCJSON.H:422
virtual std::vector< std::tuple< std::string, std::vector< std::string >, std::vector< std::string > > > parseReactionWildcards(const std::vector< std::string > &a_reactants, const std::vector< std::string > &a_products, const nlohmann::json &a_reactionJSON) const noexcept
Make a reaction set into a superset. This parses wildcards '@' in reaction string.
Definition CD_ItoKMCJSON.cpp:3341
FunctionX m_gasNumberDensity
Background gas number density.
Definition CD_ItoKMCJSON.H:452
virtual Real getNeutralDensity(const RealVect &a_pos) const noexcept override
Get the neutral density at a position in space.
Definition CD_ItoKMCJSON.cpp:3405
virtual void sanctifyPlasmaReaction(const std::vector< std::string > &a_reactants, const std::vector< std::string > &a_products, const std::string &a_reaction) const noexcept
Check that a plasma reaction makes sense. I.e. that all species are properly defined and that it cons...
Definition CD_ItoKMCJSON.cpp:2347
virtual void throwParserWarning(const std::string &a_warning) const noexcept
Throw a parser warning.
Definition CD_ItoKMCJSON.cpp:142
ItoKMCJSON()
Default constructor.
Definition CD_ItoKMCJSON.cpp:29
bool m_previewRates
Preview rates or not.
Definition CD_ItoKMCJSON.H:273
bool m_skipReactions
A flag for skipping reactions completely.
Definition CD_ItoKMCJSON.H:268
virtual void initializePlasmaSpecies()
Initialize the plasma species.
Definition CD_ItoKMCJSON.cpp:575
std::function< Real(const Real E, const Real V, const Real dx, const Real dt, const RealVect &x, const Vector< Real > &phi)> FunctionEVXTP
Function for encapsulating a function f = f(E, V, x) where E is the electric field at physical coordi...
Definition CD_ItoKMCJSON.H:81
virtual void throwParserError(const std::string &a_error) const noexcept
Throw a parser error.
Definition CD_ItoKMCJSON.cpp:129
std::map< std::string, int > m_backgroundSpeciesMap
Map of string-int identifiers for background species.
Definition CD_ItoKMCJSON.H:304
virtual void initializeMobilities()
Initialize mobility functions.
Definition CD_ItoKMCJSON.cpp:1419
virtual void checkMolarFraction(const RealVect &a_position) const noexcept
Check that molar fraction is one. Throws a warning if it isn't.
Definition CD_ItoKMCJSON.cpp:241
virtual void initializeParticlePlacement()
Initialize the particle placement algorithm.
Definition CD_ItoKMCJSON.cpp:812
virtual void getReactionSpecies(std::list< size_t > &a_backgroundReactants, std::list< size_t > &a_plasmaReactants, std::list< size_t > &a_photonReactants, std::list< size_t > &a_backgroundProducts, std::list< size_t > &a_plasmaProducts, std::list< size_t > &a_photonProducts, const std::vector< std::string > &a_reactants, const std::vector< std::string > &a_products) const noexcept
Turn reactants and products strings into indices.
Definition CD_ItoKMCJSON.cpp:2608
virtual ~ItoKMCJSON() noexcept
Destructor.
Definition CD_ItoKMCJSON.cpp:89
std::map< std::string, int > m_photonIndexMap
Map for indexing a photon species name to a global index in the solver vectors.
Definition CD_ItoKMCJSON.H:346
std::map< int, std::string > m_backgroundSpeciesMapInverse
Map of int-string identifiers for background species.
Definition CD_ItoKMCJSON.H:309
std::vector< FunctionEX > m_fluidRates
Function-based plasma reaction rates as if they appeared in the reaction rate equation....
Definition CD_ItoKMCJSON.H:372
nlohmann::json m_json
Nohmanns implementation of JSON files.
Definition CD_ItoKMCJSON.H:288
virtual bool isBackgroundSpecies(const std::string &a_name) const noexcept
Return true if species is a background species.
Definition CD_ItoKMCJSON.cpp:179
FunctionX m_gasTemperature
Background gas temperature.
Definition CD_ItoKMCJSON.H:447
std::vector< size_t > multinomial(const size_t N, const std::discrete_distribution< size_t > &a_distribution) const noexcept
Sample a multinomial distribution with N samples.
Definition CD_ItoKMCJSON.cpp:3806
int m_numPlasmaSpecies
Total number of plasma species.
Definition CD_ItoKMCJSON.H:278
virtual void initializePhotoReactions()
Initialize photo-reactions.
Definition CD_ItoKMCJSON.cpp:1967
std::function< Real(const Real a_T1, const Real a_T2)> FunctionTT
Function for encapsulating a function f = f(T1, T2) where T1/T2 are temperatures of two species.
Definition CD_ItoKMCJSON.H:101
int m_numPhotonSpecies
Total number of photon species.
Definition CD_ItoKMCJSON.H:283
std::vector< bool > m_backgroundSpeciesPlot
Plot background species or not.
Definition CD_ItoKMCJSON.H:321
virtual Vector< Real > computeDiffusionCoefficients(const Real a_time, const RealVect &a_pos, const RealVect &a_E) const noexcept override
Compute the Ito solver diffusion coefficients.
Definition CD_ItoKMCJSON.cpp:3456
std::function< Real(const Real E, const RealVect &x)> FunctionEX
Function for encapsulating a function f = f(E, x) where E is the electric field at physical coordinat...
Definition CD_ItoKMCJSON.H:68
virtual void initializeBackgroundSpecies()
Initialize the background species.
Definition CD_ItoKMCJSON.cpp:368
std::vector< std::list< size_t > > m_plasmaReactionBackgroundReactants
List of background species involved in a reaction.
Definition CD_ItoKMCJSON.H:377
virtual Real parsePlasmaReactionDt(const nlohmann::json &a_reactionJSON) const
Parse whether or not a reaction should be a part of the time step calculation. Returns 1 if the react...
Definition CD_ItoKMCJSON.cpp:3214
virtual std::pair< bool, std::string > parsePlasmaReactionGradientCorrection(const nlohmann::json &a_reactionJSON) const
Parse whether or not a reaction uses a gradient correction for the rate.
Definition CD_ItoKMCJSON.cpp:3151
virtual bool needGradients() const noexcept override
Return true if the physics model requires species density gradients.
Definition CD_ItoKMCJSON.cpp:3665
std::vector< std::pair< int, FunctionEN > > m_electrodeFieldEmission
List of electrode field emission reactions.
Definition CD_ItoKMCJSON.H:427
virtual Real computeAlpha(const Real a_E, const RealVect &a_pos) const noexcept override
Compute Townsend ionization coefficient.
Definition CD_ItoKMCJSON.cpp:3416
std::string m_jsonFile
Input JSON file name.
Definition CD_ItoKMCJSON.H:293
virtual bool isPhotonSpecies(const std::string &a_name) const noexcept
Return true if species is a photon species.
Definition CD_ItoKMCJSON.cpp:201
virtual void initializeTemperatures()
Initialize the plasma species temperatures.
Definition CD_ItoKMCJSON.cpp:1614
std::vector< std::pair< bool, std::string > > m_kmcReactionGradientCorrections
Whether or not a reaction uses a gradient correction for the rate (Soloviev et. al....
Definition CD_ItoKMCJSON.H:397
virtual bool containsWildcard(const std::string &a_str) const noexcept
Check if a string contains the wildcard @ and return true if it does.
Definition CD_ItoKMCJSON.cpp:168
virtual void initializeFieldEmission()
Initialize field emission reactions.
Definition CD_ItoKMCJSON.cpp:2203
std::function< Real(const RealVect &a_position, const Real a_time)> FunctionXt
Function alias for e.g. initial data.
Definition CD_ItoKMCJSON.H:44
std::vector< FunctionEX > m_diffusionCoefficients
Diffusion coefficients for the various species.
Definition CD_ItoKMCJSON.H:356
std::map< std::string, SpeciesType > m_plasmaSpeciesTypes
Map for identifying a species name with a solver type.
Definition CD_ItoKMCJSON.H:326
virtual bool doesFileExist(const std::string &a_filename) const noexcept
Check if a file exists.
Definition CD_ItoKMCJSON.cpp:155
virtual std::pair< FunctionEVXTP, FunctionEX > parsePlasmaReactionRate(const nlohmann::json &a_reactionJSON, const std::list< size_t > &a_backgroundReactants, const std::list< size_t > &a_plasmaReactants) const
Parse a plasma reaction rate and turn it into a function.
Definition CD_ItoKMCJSON.cpp:2673
std::map< int, std::pair< bool, int > > m_plasmaReactionSolovievCorrection
Map of reactions that will be plotted.
Definition CD_ItoKMCJSON.H:407
std::vector< std::pair< bool, std::string > > m_kmcReactionRatePlots
Map of reactions that will be plotted.
Definition CD_ItoKMCJSON.H:402
std::vector< FunctionEX > m_mobilityFunctions
Mobilities for the various species.
Definition CD_ItoKMCJSON.H:351
std::vector< FunctionEX > m_plasmaTemperatures
Plasma species temperatures.
Definition CD_ItoKMCJSON.H:361
virtual Vector< Real > computeMobilities(const Real a_time, const RealVect &a_pos, const RealVect &a_E) const noexcept override
Compute the Ito solver mobilities.
Definition CD_ItoKMCJSON.cpp:3438
std::vector< std::list< size_t > > m_plasmaReactionPlasmaReactants
List of plasma species on the left-hand side of a reaction.
Definition CD_ItoKMCJSON.H:382
std::vector< ItoKMCBackgroundSpecies > m_backgroundSpecies
Map of background species.
Definition CD_ItoKMCJSON.H:315
std::map< std::string, int > m_itoSpeciesMap
Map for indexing from an ID to an Ito solver index.
Definition CD_ItoKMCJSON.H:331
std::pair< bool, std::string > m_autoEta
Flag if the user wants to compute the alpha coefficient from the reactions.
Definition CD_ItoKMCJSON.H:417
virtual void parseJSON()
Parse the JSON file.
Definition CD_ItoKMCJSON.cpp:272
bool m_verbose
Verbose or not.
Definition CD_ItoKMCJSON.H:248
virtual int getNumberOfPlotVariables() const noexcept override
Get number of extra diagnostic plot variables.
Definition CD_ItoKMCJSON.cpp:3684
virtual std::string trim(const std::string &a_string) const noexcept
Trim a string. This removes whitespace before/after.
Definition CD_ItoKMCJSON.cpp:106
virtual void printFluidRates() const noexcept
Print the fluid-representation of the reaction rates.
Definition CD_ItoKMCJSON.cpp:957
virtual void parseRuntimeOptions() noexcept override
Parse run-time options.
Definition CD_ItoKMCJSON.cpp:95
virtual void parseVerbose() noexcept
Parse chattiness.
Definition CD_ItoKMCJSON.cpp:259
virtual void initializeParticles()
Parse initial particles.
Definition CD_ItoKMCJSON.cpp:1112
bool m_plotAlpha
Plot Townsend ionization coefficient.
Definition CD_ItoKMCJSON.H:258
std::map< std::string, int > m_plasmaIndexMap
Map for indexing a plasma species name to a global index in the solver vectors.
Definition CD_ItoKMCJSON.H:341
virtual void parseReactionString(std::vector< std::string > &a_reactants, std::vector< std::string > &a_products, const std::string &a_reaction) const noexcept
Parses a reaction string into reactangs and products.
Definition CD_ItoKMCJSON.cpp:2569
std::function< Real(const Real dx, const Vector< Real > &phi)> FunctionDXP
Function alias for f = f(dx, phi) where dx is the grid resolution and phi is the plasma species densi...
Definition CD_ItoKMCJSON.H:88
Abstract base class coupling Kinetic Monte Carlo chemistry to Ito/CDR plasma solvers.
Definition CD_ItoKMCPhysics.H:84
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