Cantera  4.0.0a1
Loading...
Searching...
No Matches
FlowDevice Class Reference

Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors. More...

#include <FlowDevice.h>

Inheritance diagram for FlowDevice:
[legend]

Detailed Description

Base class for 'flow devices' (valves, pressure regulators, etc.) connecting reactors.

Definition at line 25 of file FlowDevice.h.

Public Member Functions

 FlowDevice (shared_ptr< ReactorBase > r0, shared_ptr< ReactorBase > r1, const string &name="(none)")
 
string type () const override
 String indicating the connector implemented.
 
double massFlowRate ()
 Mass flow rate (kg/s).
 
virtual void updateMassFlowRate (double time)
 Update the mass flow rate at time 'time'.
 
virtual void setMassFlowRate (double mdot)
 Set the fixed mass flow rate (kg/s) through a flow device.
 
virtual double massFlowRate_ddP () const
 Derivative of mass flow rate with respect to pressure difference.
 
double deviceCoefficient () const
 Get the device coefficient (defined by derived class).
 
void setDeviceCoefficient (double c)
 Set the device coefficient (defined by derived class).
 
virtual void setPrimary (shared_ptr< ConnectorNode > primary)
 Set the primary mass flow controller.
 
double outletSpeciesMassFlowRate (size_t k)
 Mass flow rate (kg/s) of outlet species k.
 
virtual void addMassFlowRateJacobian (SparseTriplets &trips, size_t row, double coeff, bool includePressureSpecies=true)
 Add Jacobian terms proportional to derivatives of the mass flow rate.
 
void addOutletSpeciesMassFlowRateJacobian (SparseTriplets &trips, size_t row, size_t k, double coeff, bool includeComposition=true, bool includePressureSpecies=true)
 Add Jacobian terms proportional to derivatives of outletSpeciesMassFlowRate(k).
 
void addInletEnthalpyJacobian (SparseTriplets &trips, size_t row, double coeff, bool includeComposition=true)
 Add Jacobian terms for the inlet enthalpy dependence on upstream state.
 
double enthalpy_mass ()
 specific enthalpy
 
virtual bool ready ()
 
ReactorBasein () const
 Return a reference to the upstream reactor.
 
const ReactorBaseout () const
 Return a const reference to the downstream reactor.
 
ReactorBaseout ()
 Return a mutable reference to the downstream reactor.
 
double evalPressureFunction ()
 Return current value of the pressure function.
 
virtual void setPressureFunction (shared_ptr< Func1 > f)
 Set a function of pressure to modify the pressure response.
 
double evalTimeFunction ()
 Return current value of the time function.
 
virtual void setTimeFunction (shared_ptr< Func1 > g)
 Set a function of time to modulate the mass flow rate.
 
void setSimTime (double time)
 Set current reactor network time.
 
 ConnectorNode (const string &name="(none)")
 Transitional constructor.
 
 ConnectorNode (shared_ptr< ReactorBase > r0, shared_ptr< ReactorBase > r1, const string &name="(none)")
 Instantiate a ConnectorNode object with associated ReactorBase objects.
 
 ConnectorNode (const ConnectorNode &)=delete
 
- Public Member Functions inherited from ConnectorNode
 ConnectorNode (const string &name="(none)")
 Transitional constructor.
 
 ConnectorNode (shared_ptr< ReactorBase > r0, shared_ptr< ReactorBase > r1, const string &name="(none)")
 Instantiate a ConnectorNode object with associated ReactorBase objects.
 
 ConnectorNode (const ConnectorNode &)=delete
 
ConnectorNodeoperator= (const ConnectorNode &)=delete
 
virtual string type () const
 String indicating the connector implemented.
 
string name () const
 Retrieve connector name.
 
void setName (const string &name)
 Set connector name.
 
void setDefaultName (map< string, int > &counts)
 Set the default name of a connector. Returns false if it was previously set.
 

Protected Member Functions

double pressureFunction_ddP (double deltaP) const
 Return the derivative of the pressure function at deltaP.
 

Protected Attributes

double m_mdot = Undef
 
shared_ptr< Func1m_pfunc
 Function set by setPressureFunction; used by updateMassFlowRate.
 
shared_ptr< Func1m_tfunc
 Function set by setTimeFunction; used by updateMassFlowRate.
 
double m_coeff = 1.0
 Coefficient set by derived classes; used by updateMassFlowRate.
 
double m_time = 0.
 Current reactor network time.
 
- Protected Attributes inherited from ConnectorNode
pair< shared_ptr< ReactorBase >, shared_ptr< ReactorBase > > m_nodes
 Pair of reactors forming end points of the connector.
 
string m_name
 ConnectorNode name.
 
bool m_defaultNameSet = false
 true if default name has been previously set.
 

Private Attributes

size_t m_nspin = 0
 
size_t m_nspout = 0
 
ReactorBasem_in = nullptr
 
ReactorBasem_out = nullptr
 
vector< size_t > m_in2out
 
vector< size_t > m_out2in
 

Constructor & Destructor Documentation

◆ FlowDevice()

FlowDevice ( shared_ptr< ReactorBase r0,
shared_ptr< ReactorBase r1,
const string &  name = "(none)" 
)

Definition at line 15 of file FlowDevice.cpp.

Member Function Documentation

◆ type()

string type ( ) const
inlineoverridevirtual

String indicating the connector implemented.

Usually corresponds to the name of the derived class.

Reimplemented from ConnectorNode.

Reimplemented in MassFlowController, PressureController, and Valve.

Definition at line 32 of file FlowDevice.h.

◆ massFlowRate()

double massFlowRate ( )
inline

Mass flow rate (kg/s).

Definition at line 37 of file FlowDevice.h.

◆ updateMassFlowRate()

virtual void updateMassFlowRate ( double  time)
inlinevirtual

Update the mass flow rate at time 'time'.

This must be overloaded in derived classes to update m_mdot.

Reimplemented in MassFlowController, PressureController, and Valve.

Definition at line 48 of file FlowDevice.h.

◆ setMassFlowRate()

virtual void setMassFlowRate ( double  mdot)
inlinevirtual

Set the fixed mass flow rate (kg/s) through a flow device.

Reimplemented in MassFlowController.

Definition at line 51 of file FlowDevice.h.

◆ massFlowRate_ddP()

virtual double massFlowRate_ddP ( ) const
inlinevirtual

Derivative of mass flow rate with respect to pressure difference.

Returns d(mdot)/d(P_in - P_out) for the current state. A return value of zero indicates that pressure coupling does not contribute Jacobian entries.

Since
New in Cantera 4.0.

Reimplemented in MassFlowController, PressureController, and Valve.

Definition at line 61 of file FlowDevice.h.

◆ deviceCoefficient()

double deviceCoefficient ( ) const
inline

Get the device coefficient (defined by derived class).

Since
New in Cantera 3.2.

Definition at line 67 of file FlowDevice.h.

◆ setDeviceCoefficient()

void setDeviceCoefficient ( double  c)
inline

Set the device coefficient (defined by derived class).

Since
New in Cantera 3.2.

Definition at line 73 of file FlowDevice.h.

◆ setPrimary()

virtual void setPrimary ( shared_ptr< ConnectorNode primary)
inlinevirtual

Set the primary mass flow controller.

Since
New in Cantera 3.2.

Reimplemented in PressureController.

Definition at line 79 of file FlowDevice.h.

◆ outletSpeciesMassFlowRate()

double outletSpeciesMassFlowRate ( size_t  k)

Mass flow rate (kg/s) of outlet species k.

Returns zero if this species is not present in the upstream mixture.

Definition at line 64 of file FlowDevice.cpp.

◆ addMassFlowRateJacobian()

void addMassFlowRateJacobian ( SparseTriplets &  trips,
size_t  row,
double  coeff,
bool  includePressureSpecies = true 
)
virtual

Add Jacobian terms proportional to derivatives of the mass flow rate.

Adds entries for coeff * d(mdot)/dy_j to the specified global row of the reactor network Jacobian. The flow device supplies the scalar derivative of mass flow rate with respect to connector variables such as pressure drop while the adjacent reactors supply derivatives of those variables with respect to their state variables.

Parameters
[in,out]tripsSparse Jacobian entries. Implementations append entries using global row and column indices in the reactor network.
rowGlobal row index receiving these chain-rule terms.
coeffMultiplicative factor applied to d(mdot)/dy_j.
includePressureSpeciesInclude pressure derivatives with respect to species state variables when pressure is a derived quantity. These terms may be dense and are controlled by preconditioner sparsity settings.
Since
New in Cantera 4.0.

Reimplemented in PressureController.

Definition at line 76 of file FlowDevice.cpp.

◆ addOutletSpeciesMassFlowRateJacobian()

void addOutletSpeciesMassFlowRateJacobian ( SparseTriplets &  trips,
size_t  row,
size_t  k,
double  coeff,
bool  includeComposition = true,
bool  includePressureSpecies = true 
)

Add Jacobian terms proportional to derivatives of outletSpeciesMassFlowRate(k).

Adds entries for coeff * d(mdot * Y_k)/dy_j, where Y_k is the upstream mass fraction mapped to downstream species k.

Parameters
[in,out]tripsSparse Jacobian entries. Implementations append entries using global row and column indices in the reactor network.
rowGlobal row index receiving these chain-rule terms.
kSpecies index in the downstream reactor's phase.
coeffMultiplicative factor applied to d(mdot * Y_k)/dy_j.
includeCompositionInclude derivatives of upstream mass fraction Y_k with respect to upstream reactor state variables.
includePressureSpeciesInclude pressure derivatives with respect to species state variables when pressure is a derived quantity.
Since
New in Cantera 4.0.

Definition at line 89 of file FlowDevice.cpp.

◆ addInletEnthalpyJacobian()

void addInletEnthalpyJacobian ( SparseTriplets &  trips,
size_t  row,
double  coeff,
bool  includeComposition = true 
)

Add Jacobian terms for the inlet enthalpy dependence on upstream state.

Adds entries for coeff * mdot * d(h_in)/dy_j, where h_in is the specific enthalpy of the upstream reactor. This captures how the energy carried into a downstream reactor changes when the upstream temperature or composition changes.

Parameters
[in,out]tripsSparse Jacobian entries.
rowGlobal row index receiving these chain-rule terms.
coeffMultiplicative factor applied to mdot * d(h_in)/dy_j.
includeCompositionInclude derivatives of upstream enthalpy with respect to upstream species moles. These terms add composition-mediated fill-in and are controlled by preconditioner sparsity settings.
Since
New in Cantera 4.0.

Definition at line 132 of file FlowDevice.cpp.

◆ enthalpy_mass()

double enthalpy_mass ( )

specific enthalpy

Definition at line 109 of file FlowDevice.cpp.

◆ ready()

virtual bool ready ( )
inlinevirtual

Definition at line 145 of file FlowDevice.h.

◆ in()

ReactorBase & in ( ) const
inline

Return a reference to the upstream reactor.

Definition at line 150 of file FlowDevice.h.

◆ out() [1/2]

const ReactorBase & out ( ) const
inline

Return a const reference to the downstream reactor.

Definition at line 155 of file FlowDevice.h.

◆ out() [2/2]

ReactorBase & out ( )
inline

Return a mutable reference to the downstream reactor.

Definition at line 160 of file FlowDevice.h.

◆ evalPressureFunction()

double evalPressureFunction ( )

Return current value of the pressure function.

The mass flow rate [kg/s] is calculated given the pressure drop [Pa] and a coefficient set by a flow device specific function; unless a user-defined pressure function is set, this is the pressure difference across the device. The calculation of mass flow rate depends to the flow device.

Since
New in Cantera 3.0.

Definition at line 47 of file FlowDevice.cpp.

◆ setPressureFunction()

virtual void setPressureFunction ( shared_ptr< Func1 f)
inlinevirtual

Set a function of pressure to modify the pressure response.

Set a function of pressure that is used in determining the mass flow rate through the device. The evaluation of mass flow depends on the derived flow device class.

Since
Changed in Cantera 3.2. Previous version used a raw pointer.

Reimplemented in MassFlowController.

Definition at line 179 of file FlowDevice.h.

◆ evalTimeFunction()

double evalTimeFunction ( )

Return current value of the time function.

The mass flow rate [kg/s] is calculated for a Flow device, and multiplied by a function of time, which returns 1.0 unless a user-defined function is provided. The calculation of mass flow rate depends on the flow device.

Since
New in Cantera 3.0.

Definition at line 56 of file FlowDevice.cpp.

◆ setTimeFunction()

virtual void setTimeFunction ( shared_ptr< Func1 g)
inlinevirtual

Set a function of time to modulate the mass flow rate.

Set a function of time that is used in determining the mass flow rate through the device. The evaluation of mass flow depends on the derived flow device class.

Since
Changed in Cantera 3.2. Previous version used a raw pointer.

Reimplemented in PressureController.

Definition at line 197 of file FlowDevice.h.

◆ setSimTime()

void setSimTime ( double  time)
inline

Set current reactor network time.

Since
New in Cantera 3.0.

Definition at line 205 of file FlowDevice.h.

◆ pressureFunction_ddP()

double pressureFunction_ddP ( double  deltaP) const
protected

Return the derivative of the pressure function at deltaP.

Parameters
deltaPPressure difference P_in - P_out [Pa].
Since
New in Cantera 4.0.

Definition at line 114 of file FlowDevice.cpp.

◆ ConnectorNode() [1/2]

ConnectorNode ( const string &  name = "(none)")
inline

Transitional constructor.

Todo:
Implement deprecation warning.

Definition at line 32 of file ConnectorNode.h.

◆ ConnectorNode() [2/2]

ConnectorNode ( shared_ptr< ReactorBase r0,
shared_ptr< ReactorBase r1,
const string &  name = "(none)" 
)
inline

Instantiate a ConnectorNode object with associated ReactorBase objects.

Parameters
r0First reactor.
r1Second reactor.
nameName of the connector.

Definition at line 38 of file ConnectorNode.h.

Member Data Documentation

◆ m_mdot

double m_mdot = Undef
protected

Definition at line 215 of file FlowDevice.h.

◆ m_pfunc

shared_ptr<Func1> m_pfunc
protected

Function set by setPressureFunction; used by updateMassFlowRate.

Definition at line 218 of file FlowDevice.h.

◆ m_tfunc

shared_ptr<Func1> m_tfunc
protected

Function set by setTimeFunction; used by updateMassFlowRate.

Definition at line 221 of file FlowDevice.h.

◆ m_coeff

double m_coeff = 1.0
protected

Coefficient set by derived classes; used by updateMassFlowRate.

Definition at line 224 of file FlowDevice.h.

◆ m_time

double m_time = 0.
protected

Current reactor network time.

Definition at line 227 of file FlowDevice.h.

◆ m_nspin

size_t m_nspin = 0
private

Definition at line 230 of file FlowDevice.h.

◆ m_nspout

size_t m_nspout = 0
private

Definition at line 231 of file FlowDevice.h.

◆ m_in

ReactorBase* m_in = nullptr
private

Definition at line 232 of file FlowDevice.h.

◆ m_out

ReactorBase* m_out = nullptr
private

Definition at line 233 of file FlowDevice.h.

◆ m_in2out

vector<size_t> m_in2out
private

Definition at line 234 of file FlowDevice.h.

◆ m_out2in

vector<size_t> m_out2in
private

Definition at line 234 of file FlowDevice.h.


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