54 Flow1D(shared_ptr<Solution>
phase,
const string&
id=
"",
size_t points=1);
137 void _finalize(span<const double> x)
override;
148 m_zfix.assign(zfixed.begin(), zfixed.end());
149 m_tfix.assign(tfixed.begin(), tfixed.end());
170 size_t componentIndex(
const string& name,
bool checkAlias=
true)
const override;
172 bool hasComponent(
const string& name,
bool checkAlias=
true)
const override;
178 void show(span<const double> x)
override;
180 void getValues(
const string& component, span<double>
values)
const override;
181 void setValues(
const string& component, span<const double>
values)
override;
183 void setProfile(
const string& component, span<const double> pos,
184 span<const double>
values)
override;
187 shared_ptr<SolutionArray>
toArray(
bool normalize=
false)
override;
188 void fromArray(
const shared_ptr<SolutionArray>& arr)
override;
227 [](
bool v) { return v; });
238 [](
bool v) { return v; });
366 void resize(
size_t components,
size_t points)
override;
369 void setGas(span<const double> x,
size_t j);
426 void eval(
size_t jGlobal, span<const double> xGlobal, span<double> rsdGlobal,
427 span<int> diagGlobal,
double rdt)
override;
463 for (
size_t j = j0; j <= j1; j++) {
480 virtual void updateTransport(span<const double> x,
size_t j0,
size_t j1);
489 size_t jmin,
size_t jmax);
548 virtual void evalContinuity(span<const double> x, span<double> rsd, span<int> diag,
549 double rdt,
size_t jmin,
size_t jmax);
566 virtual void evalMomentum(span<const double> x, span<double> rsd, span<int> diag,
567 double rdt,
size_t jmin,
size_t jmax);
585 virtual void evalLambda(span<const double> x, span<double> rsd, span<int> diag,
586 double rdt,
size_t jmin,
size_t jmax);
605 virtual void evalEnergy(span<const double> x, span<double> rsd, span<int> diag,
606 double rdt,
size_t jmin,
size_t jmax);
621 virtual void evalSpecies(span<const double> x, span<double> rsd, span<int> diag,
622 double rdt,
size_t jmin,
size_t jmax);
634 span<int> diag,
double rdt,
size_t jmin,
654 virtual void evalUo(span<const double> x, span<double> rsd, span<int> diag,
655 double rdt,
size_t jmin,
size_t jmax);
661 double T(span<const double> x,
size_t j)
const {
665 double&
T(span<double> x,
size_t j) {
675 double rho_u(span<const double> x,
size_t j)
const {
680 double u(span<const double> x,
size_t j)
const {
686 double V(span<const double> x,
size_t j)
const {
697 double Lambda(span<const double> x,
size_t j)
const {
705 double Uo(span<const double> x,
size_t j)
const {
711 double Y(span<const double> x,
size_t k,
size_t j)
const {
717 double&
Y(span<double> x,
size_t k,
size_t j) {
722 span<double>
Y(span<double> x,
size_t j) {
725 span<const double>
Y(span<const double> x,
size_t j) {
730 double Y_prev(
size_t k,
size_t j)
const {
736 double X(span<const double> x,
size_t k,
size_t j)
const {
741 double flux(
size_t k,
size_t j)
const {
774 double dVdz(span<const double> x,
size_t j)
const {
775 size_t jloc = (
u(x, j) > 0.0 ? j : j + 1);
776 return (
V(x, jloc) -
V(x, jloc-1))/
m_dz[jloc-1];
789 double dYdz(span<const double> x,
size_t k,
size_t j)
const {
790 size_t jloc = (
u(x, j) > 0.0 ? j : j + 1);
791 return (
Y(x, k, jloc) -
Y(x, k, jloc-1))/
m_dz[jloc-1];
803 double dTdz(span<const double> x,
size_t j)
const {
804 size_t jloc = (
u(x, j) > 0.0 ? j : j + 1);
805 return (
T(x, jloc) -
T(x, jloc-1))/
m_dz[jloc-1];
831 double shear(span<const double> x,
size_t j)
const {
832 double A_left =
m_visc[j-1]*(
V(x, j) -
V(x, j-1)) / (
z(j) -
z(j-1));
833 double A_right =
m_visc[j]*(
V(x, j+1) -
V(x, j)) / (
z(j+1) -
z(j));
834 return 2.0*(A_right - A_left) / (
z(j+1) -
z(j-1));
847 double A_left =
m_tcon[j-1]*(
T(x, j) -
T(x, j-1)) / (
z(j) -
z(j-1));
848 double A_right =
m_tcon[j]*(
T(x, j+1) -
T(x, j)) / (
z(j+1) -
z(j));
849 return -2.0*(A_right - A_left) / (
z(j+1) -
z(j-1));
860 size_t mindex(
size_t k,
size_t j,
size_t m) {
874 virtual void grad_hk(span<const double> x,
size_t j);
Header file for class Cantera::Array2D.
Base class for kinetics managers and also contains the kineticsmgr module documentation (see Kinetics...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Base class for one-dimensional domains.
vector< double > values(const string &component) const
Retrieve component values.
double z(size_t jlocal) const
Get the coordinate [m] of the point with local index jlocal
double m_press
pressure [Pa]
virtual double value(const string &component) const
Set a single component value at a boundary.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
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.
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector.
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
void setLeftControlPointTemperature(double temperature)
Sets the temperature of the left control point.
virtual void updateDiffFluxes(span< const double > x, size_t j0, size_t j1)
Update the diffusive mass fluxes.
ThermoPhase * m_thermo
Phase object used for calculating thermodynamic properties.
void setTemperature(size_t j, double t)
Set the temperature fixed point at grid point j, and disable the energy equation so that the solution...
void setLeftControlPointCoordinate(double z_left)
Sets the coordinate of the left control point.
vector< double > m_zfix
Relative coordinates used to specify a fixed temperature profile.
virtual void evalEnergy(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the energy equation residual.
double Lambda(span< const double > x, size_t j) const
Get the radial pressure gradient [N/m⁴] at point j from the local state vector x
double density(size_t j) const
Get the density [kg/m³] at point j
void setupGrid(span< const double > z) override
Set up initial grid.
size_t m_kExcessLeft
Index of species with a large mass fraction at the left boundary, for which the mass fraction may be ...
void setMeta(const AnyMap &state) override
Retrieve meta data.
double m_zLeft
Location of the left control point when two-point control is enabled.
void fixTemperature(size_t j=npos)
Specify that the the temperature should be held fixed at point j.
vector< double > m_tfix
Fixed temperature values at the relative coordinates specified in m_zfix.
void setRightControlPointCoordinate(double z_right)
Sets the coordinate of the right control point.
void eval(size_t jGlobal, span< const double > xGlobal, span< double > rsdGlobal, span< int > diagGlobal, double rdt) override
Evaluate the residual functions for axisymmetric stagnation flow.
double leftEmissivity() const
Return emissivity at left boundary.
void setUnstrainedFlow()
Set flow configuration for burner-stabilized flames, using specified inlet mass fluxes.
bool doEnergy(size_t j)
true if the energy equation is solved at point j or false if a fixed temperature condition is imposed...
ThermoPhase & phase()
Access the phase object used to compute thermodynamic properties for points in this domain.
double T_prev(size_t j) const
Get the temperature at point j from the previous time step.
void setFixedTempProfile(span< const double > zfixed, span< const double > tfixed)
Set fixed temperature profile.
bool twoPointControlEnabled() const
Returns the status of the two-point control.
size_t rightExcessSpecies() const
Index of the species on the right boundary with the largest mass fraction.
bool m_do_soret
true if the Soret diffusion term should be calculated.
Kinetics * m_kin
Kinetics object used for calculating species production rates.
vector< double > m_qdotRadiation
radiative heat loss vector
size_t componentIndex(const string &name, bool checkAlias=true) const override
Index of component with name name.
void setEnergyEnabled(bool flag)
Set energy enabled flag for entire domain.
double pressure() const
The current pressure [Pa].
double Uo(span< const double > x, size_t j) const
Get the oxidizer inlet velocity [m/s] linked to point j from the local state vector x.
double m_tLeft
Temperature of the left control point when two-point control is enabled.
void setRightControlPointTemperature(double temperature)
Sets the temperature of the right control point.
virtual bool doElectricField() const
Retrieve flag indicating whether electric field is solved or not (used by IonFlow specialization)
bool hasComponent(const string &name, bool checkAlias=true) const override
Check whether the Domain contains a component.
double V(span< const double > x, size_t j) const
Get the spread rate (tangential velocity gradient) [1/s] at point j from the local state vector x.
virtual void updateProperties(size_t jg, span< const double > x, size_t jmin, size_t jmax)
Update the properties (thermo, transport, and diffusion flux).
void resize(size_t components, size_t points) override
Change the grid size. Called after grid refinement.
void setValues(const string &component, span< const double > values) override
Specify component values.
bool m_usesLambda
Flag that is true for counterflow configurations that use the pressure eigenvalue in the radial mome...
vector< double > m_fixedtemp
Fixed values of the temperature at each grid point that are used when solving with the energy equatio...
double conduction(span< const double > x, size_t j) const
Compute the conduction term from the energy equation using a central three-point differencing scheme.
virtual void evalLambda(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the radial pressure gradient equation residual.
void enableSoret(bool withSoret)
Enable thermal diffusion, also known as Soret diffusion.
vector< double > m_cp
Specific heat capacity at each grid point.
virtual void evalElectricField(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the electric field equation residual to be zero everywhere.
void enableTwoPointControl(bool twoPointControl)
Sets the status of the two-point control.
double m_tRight
Temperature of the right control point when two-point control is enabled.
void setBoundaryEmissivities(double e_left, double e_right)
Set the emissivities for the boundary values.
bool noneOfEnergyEnabled()
Check if energy is disabled for entire domain.
ThermoBasis m_fluxGradientBasis
Determines whether diffusive fluxes are computed using gradients of mass fraction or mole fraction.
void setFluxGradientBasis(ThermoBasis fluxGradientBasis)
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
shared_ptr< SolutionArray > toArray(bool normalize=false) override
Save the state of this domain to a SolutionArray.
void enableRadiation(bool doRadiation)
Turn radiation on / off.
void solveEnergyEqn(size_t j=npos)
Specify that the energy equation should be solved at point j.
void setGasAtMidpoint(span< 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 evalSpecies(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the species equations' residuals.
vector< double > m_rho
Density at each grid point.
double rho_u(span< const double > x, size_t j) const
Get the axial mass flux [kg/m²/s] at point j from the local state vector x.
void _setTransport(shared_ptr< Transport > trans) override
Update transport model to existing instance.
vector< bool > m_do_energy
For each point in the domain, true if energy equation is solved or false if temperature is held const...
double m_epsilon_right
Emissivity of the surface to the right of the domain.
vector< double > m_tcon
Thermal conductivity at each grid point [W/m/K].
vector< double > m_diff
Coefficient used in diffusion calculations for each species at each grid point.
double Y_prev(size_t k, size_t j) const
Get the mass fraction of species k at point j from the previous time step.
double Y(span< 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.
Kinetics & kinetics()
Access the Kinetics object used to compute reaction rates for points in this domain.
vector< double > m_dz
Grid spacing. Element j holds the value of z(j+1) - z(j).
double rightEmissivity() const
Return emissivity at right boundary.
double T(span< const double > x, size_t j) const
Get the temperature at point j from the local state vector x.
Array2D m_flux
Array of size m_nsp by m_points for saving diffusive mass fluxes.
bool withSoret() const
Indicates if thermal diffusion (Soret effect) term is being calculated.
double dTdz(span< const double > x, size_t j) const
Calculates the spatial derivative of temperature T with respect to z at point j using upwind differen...
ThermoBasis fluxGradientBasis() const
Compute species diffusive fluxes with respect to their mass fraction gradients (fluxGradientBasis = T...
vector< double > m_visc
Dynamic viscosity at each grid point [Pa∙s].
double dVdz(span< const double > x, size_t j) const
Calculates the spatial derivative of velocity V with respect to z at point j using upwind differencin...
span< double > Y(span< double > x, size_t j)
Get the array of mass fractions at point j from the local state vector x.
double m_epsilon_left
Emissivity of the surface to the left of the domain.
Transport * m_trans
Transport object used for calculating transport properties.
double m_tfixed
Temperature at the point used to fix the flame location.
bool radiationEnabled() const
Returns true if the radiation term in the energy equation is enabled.
virtual bool componentActive(size_t n) const
Returns true if the specified component is an active part of the solver state.
void computeRadiation(span< const double > x, size_t jmin, size_t jmax)
Computes the radiative heat loss vector over points jmin to jmax and stores the data in the qdotRadia...
Array2D m_wdot
Array of size m_nsp by m_points for saving species production rates.
Array2D m_hk
Array of size m_nsp by m_points for saving molar enthalpies.
void _setKinetics(shared_ptr< Kinetics > kin) override
Update transport model to existing instance.
double dYdz(span< const double > x, size_t k, size_t j) const
Calculates the spatial derivative of the species mass fraction with respect to z for species k at po...
void setFreeFlow()
Set flow configuration for freely-propagating flames, using an internal point with a fixed temperatur...
void getValues(const string &component, span< double > values) const override
Retrieve component values.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
virtual void updateTransport(span< const 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.
double flux(size_t k, size_t j) const
Get the diffusive mass flux [kg/m²/s] of species k at point j
size_t mindex(size_t k, size_t j, size_t m)
Array access mapping for a 3D array stored in a 1D vector.
void updateState(size_t loc) override
Update state at given location to state of associated Solution object.
bool m_do_multicomponent
true if transport fluxes are computed using the multicomponent diffusion coefficients,...
void setViscosityFlag(bool dovisc)
Specify if the viscosity term should be included in the momentum equation.
double V_prev(size_t j) const
Get the spread rate [1/s] at point j from the previous time step.
double & Y(span< double > x, size_t k, size_t j)
Get the mass fraction of species k at point j from the local state vector x.
vector< double > m_wt
Molecular weight of each species.
void show(span< const double > x) override
Print the solution.
virtual void evalMomentum(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the momentum equation residual.
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
bool m_isFree
Flag that is true for freely propagating flames anchored by a temperature fixed point.
Array2D m_dhk_dz
Array of size m_nsp by m_points-1 for saving enthalpy fluxes.
vector< double > m_wtm
Mean molecular weight at each grid point.
vector< double > m_multidiff
Vector of size m_nsp × m_nsp × m_points for saving multicomponent diffusion coefficients.
double radiativeHeatLoss(size_t j) const
Return radiative heat loss at grid point j.
bool m_twoPointControl
Flag for activating two-point flame control.
double m_zfixed
Location of the point where temperature is fixed.
size_t m_nsp
Number of species in the mechanism.
bool allOfEnergyEnabled()
Check if energy is enabled for entire domain.
virtual void evalContinuity(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the continuity equation residual.
double u(span< const double > x, size_t j) const
Get the axial velocity [m/s] at point j from the local state vector x.
double & T(span< double > x, size_t j)
Get the temperature at point j from the local state vector x.
void setProfile(const string &component, span< const double > pos, span< const double > values) override
Specify a profile for a component.
void getResiduals(const string &component, span< double > values) const override
Retrieve internal work array values for a component.
double shear(span< const double > x, size_t j) const
Compute the shear term from the momentum equation using a central three-point differencing scheme.
void _finalize(span< const double > x) override
In some cases, a domain may need to set parameters that depend on the initial solution estimate.
double leftControlPointCoordinate() const
Returns the z-coordinate of the left control point.
AnyMap getMeta() const override
Retrieve meta data.
double X(span< 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.
double leftControlPointTemperature() const
Returns the temperature at the left control point.
string componentName(size_t n) const override
Name of component n. May be overloaded.
bool isFree() const
Retrieve flag indicating whether flow is freely propagating.
void updateThermo(span< const double > x, size_t j0, size_t j1)
Update the thermodynamic properties from point j0 to point j1 (inclusive), based on solution x.
bool isStrained() const
Retrieve flag indicating whether flow uses radial momentum.
void resetBadValues(span< double > x) override
When called, this function should reset "bad" values in the state vector such as negative species con...
string transportModel() const
Retrieve transport model.
double rightControlPointCoordinate() const
Returns the z-coordinate of the right control point.
Array2D m_dthermal
Array of size m_nsp by m_points for saving thermal diffusion coefficients.
virtual void evalUo(span< const double > x, span< double > rsd, span< int > diag, double rdt, size_t jmin, size_t jmax)
Evaluate the oxidizer axial velocity equation residual.
string domainType() const override
Domain type flag.
void _getInitialSoln(span< double > x) override
Write the initial solution estimate into array x.
bool m_dovisc
Determines whether the viscosity term in the momentum equation is calculated.
void setPressure(double p)
Set the pressure.
void setAxisymmetricFlow()
Set flow configuration for axisymmetric counterflow flames, using specified inlet mass fluxes.
double m_zRight
Location of the right control point when two-point control is enabled.
virtual void solveElectricField()
Set to solve electric field in a point (used by IonFlow specialization)
virtual void fixElectricField()
Set to fix voltage in a point (used by IonFlow specialization)
size_t m_kExcessRight
Index of species with a large mass fraction at the right boundary, for which the mass fraction may be...
vector< size_t > m_kRadiating
Indices within the ThermoPhase of the radiating species.
void setTransportModel(const string &model) override
Set transport model by name.
void setFlatProfile(const string &component, double value) override
Specify a flat profile for a component.
void setGas(span< const double > x, size_t j)
Set the gas object state to be consistent with the solution at point j.
double rightControlPointTemperature() const
Returns the temperature at the right control point.
double T_fixed(size_t j) const
The fixed temperature value at point j.
vector< double > m_ybar
Holds the average of the species mass fractions between grid points j and j+1.
bool m_do_radiation
Determines whether radiative heat loss is calculated.
virtual void grad_hk(span< const double > x, size_t j)
Compute the spatial derivative of species specific molar enthalpies using upwind differencing.
Public interface for kinetics managers.
virtual void getNetProductionRates(span< double > wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
virtual double density() const
Density (kg/m^3).
Base class for a phase with thermodynamic properties.
virtual void getPartialMolarEnthalpies(span< double > hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
double cp_mass() const
Specific heat at constant pressure and composition [J/kg/K].
Base class for transport property managers.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
offset
Offsets of solution components in the 1D solution array.
@ c_offset_U
axial velocity [m/s]
@ c_offset_E
electric field
@ c_offset_Y
mass fractions
@ c_offset_Uo
oxidizer axial velocity [m/s]
@ c_offset_T
temperature [kelvin]
ThermoBasis
Differentiate between mole fractions and mass fractions for input mixture composition.