Cantera  3.2.0a4
Loading...
Searching...
No Matches
Solution Class Reference

A container class for chemically-reacting solutions. More...

#include <Solution.h>

Inheritance diagram for Solution:
[legend]

Detailed Description

A container class for chemically-reacting solutions.

The Solution class collects all objects needed to describe a chemically-reacting solution. Instances can be created to represent any type of solution – a mixture of gases, a liquid solution, or a solid solution, for example.

Solution objects only define a small number of methods of their own, and are provided so that a single object can be used to access thermodynamic, kinetic, and transport properties of a solution:

The most common way to instantiate Solution objects is by using a phase definition, species and reactions defined in an input file:

shared_ptr<Solution> sol = newSolution("gri30.yaml", "gri30");
shared_ptr< Solution > newSolution(const string &infile, const string &name, const string &transport, const vector< shared_ptr< Solution > > &adjacent)
Create and initialize a new Solution manager from an input file.
Definition Solution.cpp:242

Definition at line 43 of file Solution.h.

Public Member Functions

 Solution (const Solution &)=delete
 
Solutionoperator= (const Solution &)=delete
 
shared_ptr< Solutionclone (const vector< shared_ptr< Solution > > &adjacent={}, bool withKinetics=true, bool withTransport=true) const
 Create a new Solution object with cloned ThermoPhase, Kinetics, and Transport objects that use the same species definitions, thermodynamic parameters, and reactions as this one.
 
string name () const
 Return the name of this Solution object.
 
void setName (const string &name)
 Set the name of this Solution object.
 
virtual void setThermo (shared_ptr< ThermoPhase > thermo)
 Set the ThermoPhase object.
 
virtual void setKinetics (shared_ptr< Kinetics > kinetics)
 Set the Kinetics object.
 
virtual void setTransport (shared_ptr< Transport > transport)
 Set the Transport object directly.
 
string transportModel ()
 Retrieve transport model name.
 
void setTransportModel (const string &model="default")
 Set the Transport object by name.
 
shared_ptr< ThermoPhasethermo ()
 Accessor for the ThermoPhase pointer.
 
shared_ptr< Kineticskinetics ()
 Accessor for the Kinetics pointer.
 
shared_ptr< Transporttransport ()
 Accessor for the Transport pointer.
 
void addAdjacent (shared_ptr< Solution > adjacent)
 Add a phase adjacent to this phase.
 
shared_ptr< Solutionadjacent (size_t i)
 Get the Solution object for an adjacent phase by index.
 
shared_ptr< Solutionadjacent (const string &name)
 Get the Solution object for an adjacent phase by name.
 
size_t nAdjacent () const
 Get the number of adjacent phases.
 
string adjacentName (size_t i) const
 Get the name of an adjacent phase by index.
 
AnyMap parameters (bool withInput=false) const
 
const AnyMapheader () const
 Access input data associated with header definition.
 
AnyMapheader ()
 
const string source () const
 Retrieve source used for object creation; usually an input file name.
 
void setSource (const string &source)
 Overwrite source (only required if object is not created using newSolution)
 
void holdExternalHandle (const string &name, shared_ptr< ExternalHandle > handle)
 Store a handle to a wrapper for this Solution object from an external language interface (for example, a Python Solution object)
 
shared_ptr< ExternalHandlegetExternalHandle (const string &name) const
 Get the handle for a wrapper for this Solution object from an external language interface.
 
void registerChangedCallback (void *id, const function< void()> &callback)
 Register a function to be called if any of the Solution's thermo, kinetics, or transport objects is replaced.
 
void removeChangedCallback (void *id)
 Remove the callback function associated with the specified object.
 

Static Public Member Functions

static shared_ptr< Solutioncreate ()
 Create an empty Solution object.
 

Protected Attributes

shared_ptr< ThermoPhasem_thermo
 ThermoPhase manager.
 
shared_ptr< Kineticsm_kinetics
 Kinetics manager.
 
shared_ptr< Transportm_transport
 Transport manager.
 
vector< shared_ptr< Solution > > m_adjacent
 Adjacent phases, for access by index.
 
map< string, shared_ptr< Solution > > m_adjacentByName
 Adjacent phases, for access by name.
 
AnyMap m_header
 Additional input fields; usually from a YAML input file.
 
map< string, shared_ptr< ExternalHandle > > m_externalHandles
 Wrappers for this Solution object in extension languages, for evaluation of user-defined reaction rates.
 
map< void *, function< void()> > m_changeCallbacks
 Callback functions that are invoked when the therm, kinetics, or transport members of the Solution are replaced.
 

Member Function Documentation

◆ create()

static shared_ptr< Solution > create ( )
inlinestatic

Create an empty Solution object.

Definition at line 54 of file Solution.h.

◆ clone()

shared_ptr< Solution > clone ( const vector< shared_ptr< Solution > > &  adjacent = {},
bool  withKinetics = true,
bool  withTransport = true 
) const

Create a new Solution object with cloned ThermoPhase, Kinetics, and Transport objects that use the same species definitions, thermodynamic parameters, and reactions as this one.

Parameters
adjacentFor surface phases, an optional list of new adjacent phases to link to the InterfaceKinetics object. Any adjacent phases not provided will have their ThermoPhase model automatically cloned.
withKineticsFlag indicating whether to clone the Kinetics object associated with this phase. If false, the cloned Solution will not include a kinetics manager.
withTransportFlag indicating whether to clone the Transport object associated with this phase. If false, the cloned Solution will not include a transport property manager.
Since
New in Cantera 3.2.

Definition at line 25 of file Solution.cpp.

◆ name()

string name ( ) const

Return the name of this Solution object.

Definition at line 66 of file Solution.cpp.

◆ setName()

void setName ( const string &  name)

Set the name of this Solution object.

Definition at line 75 of file Solution.cpp.

◆ setThermo()

void setThermo ( shared_ptr< ThermoPhase thermo)
virtual

Set the ThermoPhase object.

Reimplemented in Interface.

Definition at line 84 of file Solution.cpp.

◆ setKinetics()

void setKinetics ( shared_ptr< Kinetics kinetics)
virtual

Set the Kinetics object.

Reimplemented in Interface.

Definition at line 92 of file Solution.cpp.

◆ setTransport()

void setTransport ( shared_ptr< Transport transport)
virtual

Set the Transport object directly.

Definition at line 114 of file Solution.cpp.

◆ transportModel()

string transportModel ( )

Retrieve transport model name.

Since
New in Cantera 3.2

Definition at line 105 of file Solution.cpp.

◆ setTransportModel()

void setTransportModel ( const string &  model = "default")

Set the Transport object by name.

Parameters
modelname of transport model; if omitted, the default model is used
Since
New in Cantera 3.0

Definition at line 124 of file Solution.cpp.

◆ thermo()

shared_ptr< ThermoPhase > thermo ( )
inline

Accessor for the ThermoPhase pointer.

Definition at line 99 of file Solution.h.

◆ kinetics()

shared_ptr< Kinetics > kinetics ( )
inline

Accessor for the Kinetics pointer.

Definition at line 104 of file Solution.h.

◆ transport()

shared_ptr< Transport > transport ( )
inline

Accessor for the Transport pointer.

Definition at line 109 of file Solution.h.

◆ addAdjacent()

void addAdjacent ( shared_ptr< Solution adjacent)

Add a phase adjacent to this phase.

Usually this means a higher-dimensional phase that participates in reactions in this phase.

Definition at line 135 of file Solution.cpp.

◆ adjacent() [1/2]

shared_ptr< Solution > adjacent ( size_t  i)
inline

Get the Solution object for an adjacent phase by index.

Definition at line 118 of file Solution.h.

◆ adjacent() [2/2]

shared_ptr< Solution > adjacent ( const string &  name)

Get the Solution object for an adjacent phase by name.

Definition at line 154 of file Solution.cpp.

◆ nAdjacent()

size_t nAdjacent ( ) const
inline

Get the number of adjacent phases.

Definition at line 126 of file Solution.h.

◆ adjacentName()

string adjacentName ( size_t  i) const
inline

Get the name of an adjacent phase by index.

Definition at line 131 of file Solution.h.

◆ parameters()

AnyMap parameters ( bool  withInput = false) const

Definition at line 164 of file Solution.cpp.

◆ header() [1/2]

const AnyMap & header ( ) const

Access input data associated with header definition.

Definition at line 197 of file Solution.cpp.

◆ header() [2/2]

AnyMap & header ( )

Definition at line 202 of file Solution.cpp.

◆ source()

const string source ( ) const

Retrieve source used for object creation; usually an input file name.

Definition at line 207 of file Solution.cpp.

◆ setSource()

void setSource ( const string &  source)

Overwrite source (only required if object is not created using newSolution)

Definition at line 212 of file Solution.cpp.

◆ holdExternalHandle()

void holdExternalHandle ( const string &  name,
shared_ptr< ExternalHandle handle 
)

Store a handle to a wrapper for this Solution object from an external language interface (for example, a Python Solution object)

Definition at line 217 of file Solution.cpp.

◆ getExternalHandle()

shared_ptr< ExternalHandle > getExternalHandle ( const string &  name) const

Get the handle for a wrapper for this Solution object from an external language interface.

Returns a null pointer if the requested handle does not exist.

Definition at line 223 of file Solution.cpp.

◆ registerChangedCallback()

void registerChangedCallback ( void *  id,
const function< void()> &  callback 
)

Register a function to be called if any of the Solution's thermo, kinetics, or transport objects is replaced.

Parameters
idA unique ID corresponding to the object affected by the callback. Typically, this is a pointer to an object that also holds a reference to the Solution object.
callbackThe callback function to be called after any component of the Solution is replaced. When the callback becomes invalid (for example, the corresponding object is being deleted, the removeChangedCallback() method must be invoked.
Since
New in Cantera 3.0

Definition at line 232 of file Solution.cpp.

◆ removeChangedCallback()

void removeChangedCallback ( void *  id)

Remove the callback function associated with the specified object.

Since
New in Cantera 3.0

Definition at line 237 of file Solution.cpp.

Member Data Documentation

◆ m_thermo

shared_ptr<ThermoPhase> m_thermo
protected

ThermoPhase manager.

Definition at line 177 of file Solution.h.

◆ m_kinetics

shared_ptr<Kinetics> m_kinetics
protected

Kinetics manager.

Definition at line 178 of file Solution.h.

◆ m_transport

shared_ptr<Transport> m_transport
protected

Transport manager.

Definition at line 179 of file Solution.h.

◆ m_adjacent

vector<shared_ptr<Solution> > m_adjacent
protected

Adjacent phases, for access by index.

Definition at line 182 of file Solution.h.

◆ m_adjacentByName

map<string, shared_ptr<Solution> > m_adjacentByName
protected

Adjacent phases, for access by name.

Definition at line 185 of file Solution.h.

◆ m_header

AnyMap m_header
protected

Additional input fields; usually from a YAML input file.

Definition at line 187 of file Solution.h.

◆ m_externalHandles

map<string, shared_ptr<ExternalHandle> > m_externalHandles
protected

Wrappers for this Solution object in extension languages, for evaluation of user-defined reaction rates.

Definition at line 191 of file Solution.h.

◆ m_changeCallbacks

map<void*, function<void()> > m_changeCallbacks
protected

Callback functions that are invoked when the therm, kinetics, or transport members of the Solution are replaced.

Definition at line 195 of file Solution.h.


The documentation for this class was generated from the following files: