24 "install in container before calling init.");
49 "Boundary domains can only be connected on the left to flow "
50 "domains, not '{}' domains.", r.
type());
64 m_flow_right =
dynamic_cast<Flow1D*
>(&r);
65 if (m_flow_right !=
nullptr) {
70 "Boundary domains can only be connected on the right to flow "
71 "domains, not '{}' domains.", r.
type());
118 if (
m_yin[k] != 0.0) {
156 "Right inlets with right-to-left flow are only supported for "
157 "strained flow configurations.");
161 }
else if (m_flow_right) {
165 throw CanteraError(
"Inlet1D::init",
"Inlet1D is not properly connected.");
180 integer* diagg,
double rdt)
230 for (
size_t k = 0; k <
m_nsp; k++) {
259 for (
size_t k = 0; k <
m_nsp; k++) {
270 meta[
"mass-flux"] =
m_mdot;
276 phase->setState_TPY(
m_temp, pressure,
m_yin.data());
277 vector<double> data(phase->stateSize());
278 phase->saveState(data);
280 arr->setState(0, data);
291 auto phase = arr->thermo();
292 auto meta = arr->meta();
293 m_temp = phase->temperature();
294 if (meta.hasKey(
"mass-flux")) {
295 m_mdot = meta.at(
"mass-flux").asDouble();
298 auto aux = arr->getAuxiliary(0);
299 m_mdot = phase->density() * aux.at(
"velocity").as<
double>();
301 phase->getMassFractions(
m_yin.data());
312 integer* diagg,
double rdt)
337 double* x = xg +
loc();
338 double* r = rg +
loc();
339 integer* diag = diagg +
loc();
393 "Left outlets with right-to-left flow are not supported.");
398 throw CanteraError(
"Outlet1D::init",
"Outlet1D is not connected.");
410 double* x = xg +
loc();
411 double* r = rg +
loc();
412 integer* diag = diagg +
loc();
429 rb[k] = xb[k] - xb[k - nc];
468 "Left outlets with right-to-left flow are not supported.");
486 integer* diagg,
double rdt)
493 double* x = xg +
loc();
494 double* r = rg +
loc();
495 integer* diag = diagg +
loc();
520 meta[
"temperature"] =
m_temp;
527 vector<double> data(phase->stateSize());
528 phase->saveState(data);
530 arr->setState(0, data);
541 auto phase = arr->thermo();
542 m_temp = phase->temperature();
543 auto Y = phase->massFractions();
555 integer* diagg,
double rdt)
562 double* x = xg +
loc();
563 double* r = rg +
loc();
582 meta[
"temperature"] =
m_temp;
588 auto meta = arr->meta();
589 m_temp = meta[
"temperature"].asDouble();
590 meta.erase(
"temperature");
609 auto phase = std::dynamic_pointer_cast<SurfPhase>(
solution->thermo());
612 "Detected incompatible ThermoPhase type '{}'",
solution->thermo()->type());
614 auto kin = std::dynamic_pointer_cast<InterfaceKinetics>(
solution->kinetics());
617 "Detected incompatible kinetics type '{}'",
618 solution->kinetics()->kineticsType());
631 sol->setThermo(kin->reactionPhase());
632 sol->setKinetics(kin);
633 sol->setTransportModel(
"none");
635 m_kin = dynamic_pointer_cast<InterfaceKinetics>(kin).get();
636 m_sphase = dynamic_pointer_cast<SurfPhase>(kin->reactionPhase()).get();
664 for (
size_t n = 0; n <
m_nsp; n++) {
670 double* x = xg +
loc();
676 integer* diagg,
double rdt)
683 double* x = xg +
loc();
684 double* r = rg +
loc();
685 integer* diag = diagg +
loc();
689 for (
size_t k = 0; k <
m_nsp; k++) {
698 size_t leftloc = 0, rightloc = 0;
708 rightloc = m_flow_right->
loc();
709 m_flow_right->
setGas(xg + rightloc, 0);
716 for (
size_t k = 0; k <
m_nsp; k++) {
724 for (
size_t k = 0; k <
m_nsp; k++) {
731 double* rb = r +
m_nsp;
732 double* xb = x +
m_nsp;
762 "Domain needs to be installed in a container.");
766 return soln[
index(i, 0)];
773 "Domain needs to be installed in a container before calling toArray.");
777 meta[
"temperature"] =
m_temp;
780 meta[
"phase"][
"source"] = source.
empty() ?
"<unknown>" : source.
asString();
789 arr->setState(0, data);
800 "Domain needs to be installed in a container before calling fromArray.");
808 auto surf = std::dynamic_pointer_cast<SurfPhase>(arr->thermo());
811 "Restoring of coverages requires surface phase");
813 m_temp = surf->temperature();
814 surf->getCoverages(soln);
822 for (
size_t k = 0; k <
m_nsp; k++) {
Boundary objects for one-dimensional simulations.
const AnyValue & getMetadata(const string &key) const
Get a value from the metadata applicable to the AnyMap tree containing this node.
A map of string keys to values whose type can vary at runtime.
A wrapper for a variable whose type is determined at runtime.
const string & asString() const
Return the held value, if it is a string.
bool empty() const
Return boolean indicating whether AnyValue is empty.
ThermoPhase * m_phase_left
Thermo object used by left flow domain.
double m_mdot
Mass flow rate at the boundary.
double m_temp
Temperature of the boundary.
void _init(size_t n)
Initialize member variables based on the adjacent domains.
Flow1D * m_flow_left
Flow domain to the left of this boundary.
ThermoPhase * m_phase_right
Thermo object used by right flow domain.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
size_t m_right_nsp
Number of species in right flow domain.
virtual void setTemperature(double t)
Set the temperature.
size_t m_left_nsp
Number of species in left flow domain.
Boundary1D()
Default constructor.
size_t m_right_nv
Number of state vector components in right flow domain.
size_t m_left_nv
Flow domain to the right of this boundary.
Base class for exceptions thrown by Cantera classes.
Base class for one-dimensional domains.
size_t lastPoint() const
The index of the last (that is, right-most) grid point belonging to this domain.
size_t m_iloc
Starting location within the solution vector for unknowns that correspond to this domain.
shared_ptr< Solution > m_solution
Composite thermo/kinetics/transport handler.
OneDim * m_container
Parent OneDim simulation containing this and adjacent domains.
size_t nComponents() const
Number of components at each grid point.
shared_ptr< Solution > solution() const
Return thermo/kinetics/transport manager used in the domain.
virtual bool isConnector()
True if the domain is a connector domain.
virtual void setMeta(const AnyMap &meta)
Retrieve meta data.
size_t m_index
Left-to-right location of this domain.
string id() const
Returns the identifying tag for this domain.
size_t m_nv
Number of solution components.
size_t nPoints() const
Number of grid points in this domain.
double lowerBound(size_t n) const
Lower bound on the nth component.
shared_ptr< vector< double > > m_state
data pointer shared from OneDim
virtual void resize(size_t nv, size_t np)
Resize the domain to have nv components and np grid points.
double upperBound(size_t n) const
Upper bound on the nth component.
void setSolution(shared_ptr< Solution > sol)
Set the solution manager.
const OneDim & container() const
The container holding this domain.
string m_id
Identity tag for the domain.
string type() const
String indicating the domain implemented.
void setBounds(size_t n, double lower, double upper)
Set the upper and lower bounds for a solution component, n.
double prevSoln(size_t n, size_t j) const
Value of component n at point j in the previous solution.
size_t firstPoint() const
The index of the first (that is, left-most) grid point belonging to this domain.
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.
virtual size_t loc(size_t j=0) const
Location of the start of the local solution vector in the global solution vector.
virtual AnyMap getMeta() const
Retrieve meta data.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
void init() override
Initialize.
This class represents 1D flow domains that satisfy the one-dimensional similarity solution for chemic...
double density(size_t j) const
Get the density [kg/m³] at point j
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.
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.
void setGas(const double *x, size_t j)
Set the gas object state to be consistent with the solution at point j.
void setViscosityFlag(bool dovisc)
Specify if the viscosity term should be included in the momentum equation.
size_t leftExcessSpecies() const
Index of the species on the left boundary with the largest mass fraction.
bool isFree() const
Retrieve flag indicating whether flow is freely propagating.
bool isStrained() const
Retrieve flag indicating whether flow uses radial momentum.
double T_fixed(size_t j) const
The fixed temperature value at point j.
void setMoleFractions(const string &xin) override
Set the mole fractions by specifying a string.
vector< double > m_yin
inlet mass fractions
int m_ilr
A marker that indicates whether this is a left inlet or a right inlet.
string m_xstr
inlet mass fractions.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
size_t nSpecies() override
Get the number of species.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
void setTemperature(double T) override
Set the temperature.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
size_t m_nsp
Number of species in the adjacent flow domain.
void init() override
Initialize.
Flow1D * m_flow
the adjacent flow domain
void setSpreadRate(double V0) override
set spreading rate
void show(const double *x) override
Print the solution.
double m_V0
The spread rate of the inlet [1/s].
Inlet1D()
Default constructor.
ThermoPhase & thermo(size_t n=0)
This method returns a reference to the nth ThermoPhase object defined in this kinetics mechanism.
size_t nPhases() const
The number of phases participating in the reaction mechanism.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
size_t nTotalSpecies() const
The total number of species in all phases participating in the kinetics mechanism.
virtual void getNetProductionRates(double *wdot)
Species net production rates [kmol/m^3/s or kmol/m^2/s].
void resize() override
Call to set the size of internal data structures after first defining the system or if the problem si...
Domain1D & domain(size_t i) const
Return a reference to domain i.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
void init() override
Initialize.
An outlet with specified composition.
void setMoleFractions(const string &xin) override
Set the mole fractions by specifying a string.
OutletRes1D()
Default constructor.
string m_xstr
Mole fractions in the reservoir.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
vector< double > m_yres
Mass fractions in the reservoir.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
size_t m_nsp
Number of species in the adjacent flow domain.
void init() override
Initialize.
Flow1D * m_flow
The adjacent flow domain.
virtual void setMoleFractions(const double *const x)
Set the mole fractions to the specified values.
size_t nSpecies() const
Returns the number of species in the phase.
void saveState(vector< double > &state) const
Save the current internal state of the phase.
string speciesName(size_t k) const
Name of the species with index k.
virtual size_t stateSize() const
Return size of vector defining internal state of the phase.
void setMoleFractionsByName(const Composition &xMap)
Set the species mole fractions by name.
const vector< double > & molecularWeights() const
Return a const reference to the internal vector of molecular weights.
size_t speciesIndex(const string &name) const
Returns the index of a species named 'name' within the Phase object.
virtual void setTemperature(double temp)
Set the internally stored temperature of the phase (K).
void getMassFractions(double *const y) const
Get the species mass fractions.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
string name() const
Return the name of the phase.
SurfPhase * m_sphase
phase representing the surface species
void setKinetics(shared_ptr< Kinetics > kin) override
Set the kinetics manager.
void resetBadValues(double *xg) override
When called, this function should reset "bad" values in the state vector such as negative species con...
size_t componentIndex(const string &name, bool checkAlias=true) const override
Index of component with name name.
InterfaceKinetics * m_kin
surface kinetics mechanism
bool m_enabled
True if coverage equations are being solved.
vector< double > m_fixed_cov
Fixed values of the coverages used when coverage equations are not being solved.
ReactingSurf1D()
Default constructor.
vector< double > m_work
temporary vector used to store coverages and production rates.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
double value(const string &component) const override
Set a single component value at a boundary.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
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
the number of surface phase species
string componentName(size_t n) const override
Name of component n. May be overloaded.
void init() override
Initialize.
void show(const double *x) override
Print the solution.
static shared_ptr< SolutionArray > create(const shared_ptr< Solution > &sol, int size=0, const AnyMap &meta={})
Instantiate a new SolutionArray reference.
static shared_ptr< Solution > create()
Create an empty Solution object.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
void fromArray(const shared_ptr< SolutionArray > &arr) override
Restore the solution for this domain from a SolutionArray.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
void init() override
Initialize.
void show(const double *x) override
Print the solution.
double pressure() const override
Return the thermodynamic pressure (Pa).
double size(size_t k) const
Returns the number of sites occupied by one molecule of species k.
void setCoverages(const double *theta)
Set the surface site fractions to a specified state.
double siteDensity() const
Returns the site density.
void setCoveragesNoNorm(const double *theta)
Set the surface site fractions to a specified state.
void getCoverages(double *theta) const
Return a vector of surface coverages.
shared_ptr< SolutionArray > toArray(bool normalize=false) const override
Save the state of this domain to a SolutionArray.
void eval(size_t jg, double *xg, double *rg, integer *diagg, double rdt) override
Evaluate the residual function at point j.
void init() override
Initialize.
Base class for a phase with thermodynamic properties.
virtual void setState_TP(double t, double p)
Set the temperature (K) and pressure (Pa)
const AnyMap & input() const
Access input data associated with the phase description.
void writelog(const string &fmt, const Args &... args)
Write a formatted message to the screen.
Namespace for the Cantera kernel.
const size_t npos
index returned by functions to indicate "no position"
const int LeftInlet
Unique identifier for the left inlet.
const int RightInlet
Unique identifier for the right inlet.
@ c_offset_U
axial velocity [m/s]
@ c_offset_Y
mass fractions
@ c_offset_Uo
oxidizer axial velocity [m/s]
@ c_offset_T
temperature [kelvin]