8#include "cantera/oneD/refine.h"
22 for (
size_t k = 0; k <
m_nsp; k++) {
27 for (
size_t k = 0; k <
m_nsp; k++){
57 :
IonFlow(sol->thermo().get(), sol->thermo()->nSpecies(), points)
65 "An appropriate transport model\nshould be set when instantiating the "
66 "Solution ('gas') object.");
68 m_solution->registerChangedCallback(
this, [
this]() {
76 return "free-ion-flow";
79 return "axisymmetric-ion-flow";
81 return "unstrained-ion-flow";
102 for (
size_t j = j0; j < j1; j++) {
128 for (
size_t j = j0; j < j1; j++) {
129 double dz =
z(j+1) -
z(j);
133 m_flux(k,j) *= (
X(x,k,j) -
X(x,k,j+1))/dz;
153 for (
size_t j = j0; j < j1; j++) {
155 double dz =
z(j+1) -
z(j);
158 for (
size_t k = 0; k <
m_nsp; k++) {
160 m_flux(k,j) *= (
X(x,k,j) -
X(x,k,j+1))/dz;
164 double E_ambi =
E(x,j);
166 double Yav = 0.5 * (
Y(x,k,j) +
Y(x,k,j+1));
167 double drift = rho * Yav * E_ambi
173 double sum_flux = 0.0;
174 for (
size_t k = 0; k <
m_nsp; k++) {
177 double sum_ion = 0.0;
183 m_flux(k,j) +=
Y(x,k,j) / (1-sum_ion) * sum_flux;
190 if (stage == 1 || stage == 2) {
194 "solution stage must be set to: "
195 "1) frozenIonMethod, "
196 "2) electricFieldEqnMethod");
202 double rdt,
size_t jmin,
size_t jmax)
218 size_t j0 = std::max<size_t>(jmin, 1);
219 size_t j1 = std::min(jmax,
m_points - 2);
220 for (
size_t j = j0; j <= j1; j++) {
227 double rdt,
size_t jmin,
size_t jmax)
246 bool changed =
false;
248 for (
size_t i = 0; i <
m_points; i++) {
271 bool changed =
false;
273 for (
size_t i = 0; i <
m_points; i++) {
295 vector<double>& mobi_e)
299 size_t n = tfix.size();
301 for (
size_t i = 0; i < n; i++) {
302 tlog.push_back(log(tfix[i]));
304 vector<double> w(n, -1.0);
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
Base class for exceptions thrown by Cantera classes.
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
string id() const
Returns the identifying tag for this domain.
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
void setSolution(shared_ptr< Solution > sol)
Set the solution manager.
size_t m_points
Number of grid points.
string m_id
Identity tag for the domain.
unique_ptr< Refiner > m_refiner
Refiner object used for placing grid points.
void setBounds(size_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
void needJacUpdate()
Set this if something has changed in the governing equations (for example, the value of a constant ha...
size_t index(size_t n, size_t j) const
Returns the index of the solution vector, which corresponds to component n at grid point j.
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
ThermoPhase * m_thermo
Phase object used for calculating thermodynamic properties.
double density(size_t j) const
Get the density [kg/m³] at point j
double X(const double *x, size_t k, size_t j) const
Get the mole fraction of species k at point j from the local state vector x.
void setTransport(shared_ptr< Transport > trans) override
Set the transport manager used for transport property calculations.
void setKinetics(shared_ptr< Kinetics > kin) override
Set the Kinetics object used for reaction rate calculations.
Kinetics * m_kin
Kinetics object used for calculating species production rates.
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
bool m_usesLambda
Flag that is true for counterflow configurations that use the pressure eigenvalue in the radial mome...
vector< double > m_diff
Coefficient used in diffusion calculations for each species at each grid point.
Array2D m_flux
Array of size m_nsp by m_points for saving diffusive mass fluxes.
Transport * m_trans
Transport object used for calculating transport properties.
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
virtual void evalSpecies(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the species equations' residuals.
vector< double > m_wt
Molecular weight of each species.
double Y(const double *x, size_t k, size_t j) const
Get the mass fraction of species k at point j from the local state vector x.
bool m_isFree
Flag that is true for freely propagating flames anchored by a temperature fixed point.
virtual void evalElectricField(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax)
Evaluate the electric field equation residual to be zero everywhere.
void _finalize(const double *x) override
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
size_t m_nsp
Number of species in the mechanism.
void setGasAtMidpoint(const double *x, size_t j)
Set the gas state to be consistent with the solution at the midpoint between j and j + 1.
virtual void updateTransport(double *x, size_t j0, size_t j1)
Update the transport properties at grid points in the range from j0 to j1, based on solution x.
This class models the ion transportation in a flame.
vector< size_t > m_kCharge
index of species with charges
vector< double > m_diff_e_fix
Coefficients of polynomial fit for electron diffusivity as a function of temperature.
void electricFieldMethod(const double *x, size_t j0, size_t j1)
Solving phase two: the electric field equation is added coupled by the electrical drift.
double E(const double *x, size_t j) const
electric field [V/m]
vector< bool > m_do_electric_field
flag for solving electric field or not
size_t m_kElectron
index of electron
void frozenIonMethod(const double *x, size_t j0, size_t j1)
Solving phase one: the fluxes of charged species are turned off.
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
void setElectronTransport(vector< double > &tfix, vector< double > &diff_e, vector< double > &mobi_e)
Sometimes it is desired to carry out the simulation using a specified electron transport profile,...
void evalElectricField(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax) override
Evaluate the electric field equation residual by Gauss's law.
double rho_e(double *x, size_t j) const
total charge density
void updateTransport(double *x, size_t j0, size_t j1) override
Update the transport properties at grid points in the range from j0 to j1, based on solution x.
vector< double > m_mobility
mobility
double dEdz(const double *x, size_t j) const
Axial gradient of the electric field [V/m²].
void updateDiffFluxes(const double *x, size_t j0, size_t j1) override
Update the diffusive mass fluxes.
void evalSpecies(double *x, double *rsd, int *diag, double rdt, size_t jmin, size_t jmax) override
Evaluate the species equations' residual.
size_t m_stage
solving stage
void _finalize(const double *x) override
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
void setSolvingStage(const size_t stage) override
Solving stage mode for handling ionized species (used by IonFlow specialization)
bool m_import_electron_transport
flag for importing transport of electron
void solveElectricField(size_t j=npos) override
Set to solve electric field in a point (used by IonFlow specialization)
void fixElectricField(size_t j=npos) override
Set to fix voltage in a point (used by IonFlow specialization)
string domainType() const override
Domain type flag.
vector< size_t > m_kNeutral
index of neutral species
vector< double > m_mobi_e_fix
Coefficients of polynomial fit for electron mobility as a function of temperature.
IonFlow(ThermoPhase *ph=0, size_t nsp=1, size_t points=1)
Create a new IonFlow domain.
bool componentActive(size_t n) const override
Returns true if the specified component is an active part of the solver state.
vector< double > m_speciesCharge
electrical properties
double temperature() const
Temperature (K).
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
size_t speciesIndex(const string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual double density() const
Density (kg/m^3).
double charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
Base class for a phase with thermodynamic properties.
virtual string transportModel() const
Identifies the model represented by this Transport object.
virtual void getMobilities(double *const mobil_e)
Get the Electrical mobilities (m^2/V/s).
Header for a file containing miscellaneous numerical functions.
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
R poly5(D x, R *c)
Templated evaluation of a polynomial of order 5.
double polyfit(size_t n, size_t deg, const double *xp, const double *yp, const double *wp, double *pp)
Fits a polynomial function to a set of data points.
const double epsilon_0
Permittivity of free space [F/m].
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
@ c_offset_U
axial velocity [m/s]
@ c_offset_E
electric field
@ c_offset_Y
mass fractions
@ c_offset_T
temperature [kelvin]
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...