#include <Flash.h>

Inheritance diagram for Flash:

Public Member Functions

 Flash (void)
 
int niter (void) const override
 return Flash iterations More...
 
void prepare_Flash_residuals (void) override
 
Value calculateResidualsPressure (void)
 
virtual Value calculateResidualsFlashMode (void)
 
virtual void clip_ (void)
 
int calculateResiduals (std::vector< Value > &y, uint32_t offset) override
 
void estimate (const Value &Pres, const Value &Temp) override
 
const ValueFraction (Libpf::Utility::PhaseIndex p, bool clip) const override
 during Flash iterations use this function to get the actual estimate of the fraction of phase p More...
 
Vector X (Libpf::Utility::PhaseIndex p) const override
 
const ValueSumx (Libpf::Utility::PhaseIndex p) const override
 
void estimateEquilibrium (const Value &Pres, const Value &Temp) override
 estimate equilibrium-related unknowns More...
 
SolverNleInterfacesolver (void) override
 
bool converged (void) const override
 returns true if the flash has been solved successfully, More...
 
- Public Member Functions inherited from ObjectiveNleAd
 ObjectiveNleAd (std::string t)
 constructor More...
 
double xmin (unsigned int i)
 return the lower bound on unknown i More...
 
double xmax (unsigned int i)
 return the upper bound on unknown i More...
 
unsigned int size (void) const override
 returns the current size of the problem More...
 
void scalex (double *x) override
 transforms the vector of "real" variables x by applying the scaling More...
 
void unscalex (double *x) override
 transforms back the vector of scaled variables x by applying the unscaling More...
 
void operator() (double *, double *, Jacobian *J) override
 implements the () operator by calling calculateResiduals; derived class may override it More...
 
void addUnknown (Value *x, Scaler scaler, const std::string &tag)
 
void changeUnknown (unsigned int i, Value *x, Scaler scaler, const std::string &tag)
 change the i-th unknown More...
 
void addObjectiveFunction (ObjectiveNleAd &of)
 append the remote objective function More...
 
- Public Member Functions inherited from ObjectiveNleAuto
 ObjectiveNleAuto (std::string t)
 constructor More...
 
virtual unsigned int size (void) const
 returns the current size of the problem More...
 
bool init (double *x)
 
void setValue (unsigned int i, double x)
 copies the value for the i-th unknown from x in the Value pointed to, without altering the derivatives More...
 
void copyresults (double *x)
 copies the unknown values from the x vector into the Values pointed to More...
 
void inactivate (void)
 inactivates all unknowns More...
 
void clearderivatives (void)
 clears the derivative information for all unknowns without setting to inactive More...
 
void setActive (unsigned int i)
 activates the i-th unknown More...
 
void scalex (double *) override
 transforms the vector of "real" variables x by applying the scaling More...
 
void unscalex (double *x) override
 transforms back the vector of scaled variables x by applying the unscaling More...
 
void operator() (double *, double *, Jacobian *J) override
 implements the () operator by calling calculateResiduals; derived class may override it More...
 
void setx (unsigned int i, Value &x)
 sets the i-th unknown to x More...
 
const Valueunknown (unsigned int i) const
 returns a reference to the i-th unknown More...
 
const std::string & unknownTag (unsigned int i) const
 returns a reference to the tag of the i-th unknown More...
 
double xmin (unsigned int i)
 return the lower bound on unknown i More...
 
double xmax (unsigned int i)
 return the upper bound on unknown i More...
 
void print (void) const
 lists unknowns More...
 
const std::string & tagof (void) const
 returns the tag of the instance More...
 
void settagof (std::string t)
 sets the tag of the instance More...
 
void appendtagof (const std::string &t)
 appends to the tag of the instance More...
 
int zero_residuals (std::vector< Value > &y, uint32_t offset)
 
virtual int calculateResiduals (std::vector< Value > &y, uint32_t offset)=0
 
void addUnknown (Value *x, const std::string &tag)
 
void changeUnknown (unsigned int i, Value *x, const std::string &tag)
 change the i-th unknown More...
 
- Public Member Functions inherited from ObjectiveNleInterface
 ObjectiveNleInterface (void)
 
virtual void operator() (double *x, double *y, Jacobian *J)=0
 computes the objective function vector y at the point x and optionally the Jacobian J More...
 
virtual void scalex (double *x)=0
 transforms the vector of "real" variables x by applying the scaling More...
 
virtual void unscalex (double *x)=0
 transforms back the vector of scaled variables x by applying the unscaling More...
 
- Public Member Functions inherited from Diagnostic
 Diagnostic (void)
 
void setVerbosity (int verbosity)
 sets the verbosity level for this instance More...
 
int verbosity (void) const
 
- Public Member Functions inherited from FlashBase
 FlashBase (void)
 
void setIdeal (bool i)
 
bool isIdeal (void)
 
virtual SolverNleInterfacesolver (void)=0
 
virtual int niter (void) const =0
 return Flash iterations More...
 
virtual void estimate (const Value &Pres, const Value &Temp)=0
 
const ValueTemperature (void) const
 
const ValuePressure (void) const
 
virtual const ValueFraction (Libpf::Utility::PhaseIndex p, bool clip=false) const =0
 during Flash iterations use this function to get the actual estimate of the fraction of phase p More...
 
virtual Vector X (Libpf::Utility::PhaseIndex p) const =0
 
virtual const ValueSumx (Libpf::Utility::PhaseIndex p) const =0
 
virtual bool converged (void) const =0
 returns true if the flash has been solved successfully, More...
 

Protected Member Functions

void setFlash_ (const Libpf::Utility::FlashMode &fm, const Value &x, const Value &y, bool strict=true) override
 Set the stream's state variables and the Flash. More...
 
int solveFlash (bool simultaneous, bool skip) override
 
std::string message (int code) override
 
void setup_ (std::vector< Value * > pbeta_, std::vector< const double * > pbetamin_, std::vector< const double * > pbetamax_) override
 
void calculateInertSolids (const std::vector< Quantity > &totalx, std::vector< Quantity > &inertx, MutableVector fluidx, Value &inertfraction, Value &fluidfraction)
 
- Protected Member Functions inherited from ObjectiveNleAd
void prepare_ (double *x, Jacobian *J) override
 uscales x (unknowns) values from calling function and puts them in x_ Quantities More...
 
void packResults_ (double *x, double *y, Jacobian *J)
 
 ~ObjectiveNleAd ()
 
- Protected Member Functions inherited from ObjectiveNleAuto
 ~ObjectiveNleAuto ()
 
- Protected Member Functions inherited from ObjectiveNleInterface
 ~ObjectiveNleInterface ()
 
- Protected Member Functions inherited from Diagnostic
virtual ~Diagnostic ()=default
 
- Protected Member Functions inherited from FlashBase
virtual ~FlashBase ()=default
 
virtual const ValuecalculateTotalP (const Value &rho) const =0
 
virtual const ValuecalculateTotalRho (void) const =0
 calculates total molar density for all phases in kmol/m3 More...
 
virtual const ValuecalculateTotalH (void) const =0
 calculates molar enthalpy for all phases in J/kmol based on current values of the hidden unknowns More...
 
virtual const ValuecalculateTotalS (void) const =0
 calculates molar entropy for all phases in J/kmol/K based on current values of the hidden unknowns More...
 
virtual void prepare_residuals (void)=0
 
virtual void prepare_Flash_residuals (void)=0
 
virtual int calculateResidualsEos (std::vector< Value > &y, uint32_t offset)=0
 
virtual void estimateEos (const Value &Pres, const Value &Temp)=0
 estimate eos roots-related unknowns More...
 
virtual int calculateResidualsEquilibrium (std::vector< Value > &y, uint32_t offset)=0
 
virtual void estimateEquilibrium (const Value &Pres, const Value &Temp)=0
 estimate equilibrium-related unknowns More...
 
virtual void setFlash_ (const Libpf::Utility::FlashMode &fm, const Value &x, const Value &y, bool strict=true)=0
 Set the stream's state variables and the Flash. More...
 
virtual int solveFlash (bool simultaneous, bool skip)=0
 
virtual std::string message (int code)=0
 
virtual void setup_ (std::vector< Value * > pbeta_, std::vector< const double * > pbetamin_, std::vector< const double * > pbetamax_)=0
 

Protected Attributes

Value sumx_
 sum of molar fractions, or liquid phase molar fractions for multiphase derived classes More...
 
std::vector< Quantity > * remotex_
 
SolverNle NLEFlash_
 Newton solver for the Flash. More...
 
- Protected Attributes inherited from ObjectiveNleAd
std::vector< Scalerscaler_
 provide scaling and unscaling More...
 
- Protected Attributes inherited from ObjectiveNleAuto
std::vector< Valueresiduals
 Residuals. More...
 
- Protected Attributes inherited from Diagnostic
int verbosityInstance
 
- Protected Attributes inherited from FlashBase
Libpf::Utility::FlashMode fm_
 
bool zero_residuals_
 used to skip Flash residuals calculations if stream is empty More...
 
Value T_
 Temperature, unknown. More...
 
Value P_
 Pressure, unknown. More...
 
Value Pset_
 specified pressure, Pa More...
 
Value Tset_
 specified temperature, K More...
 
Value Hset_
 specified molar enthalpy, J/kmol More...
 
Value Sset_
 specified molar entropy, J/(kmol*K) More...
 
Value rhoset_
 specified molar density, kmol/m3 More...
 

Additional Inherited Members

- Public Attributes inherited from ObjectiveNleInterface
int verbosityLocal
 

Detailed Description

single-phase Flash

#include <libpf/streams/Flash.h>

Remarks
Warning
Thread safe:
Extendable:
Platform dependencies:

Constructor & Destructor Documentation

◆ Flash()

Flash::Flash ( void  )

Member Function Documentation

◆ calculateInertSolids()

void Flash::calculateInertSolids ( const std::vector< Quantity > &  totalx,
std::vector< Quantity > &  inertx,
MutableVector  fluidx,
Value inertfraction,
Value fluidfraction 
)
protected

split away inert solids, for inert-solid containing Streams

Parameters
[in]totalxthe molar fractions of the total phase
[out]inertxthe molar fractions of the inert-solid containing phase
[out]fluidxthe molar fractions of the fluid containing phase
[out]inertfractionthe fraction of the inert-solid containing phase
[out]fluidfractionthe fraction of the fluid containing phase

◆ calculateResiduals()

int Flash::calculateResiduals ( std::vector< Value > &  y,
uint32_t  offset 
)
overridevirtual

evaluates the residuals, placing them into the supplied vector at the given offset

Parameters
[out]ythe vector of residuals to fill in
[in]offsetthe offset inside the vector of residuals
Returns
the number of evaluated residuals
Note
by contract, implementations should write some value in the y[offset] .. y[offset+returned:value-1] and leave the rest of the vector unchanged
if the objective function is designed to be solved by itself (i.e. not part of an assembly of objective functions, the offset parameter can be safely ignored

Implements ObjectiveNleAuto.

◆ calculateResidualsFlashMode()

virtual Value Flash::calculateResidualsFlashMode ( void  )
virtual

Reimplemented in FlashVlT.

◆ calculateResidualsPressure()

Value Flash::calculateResidualsPressure ( void  )

◆ clip_()

virtual void Flash::clip_ ( void  )
virtual

clip unknowns within feasible reanges must be overridden when more unknowns are present

◆ converged()

bool Flash::converged ( void  ) const
overridevirtual

returns true if the flash has been solved successfully,

See also
SolverNleInterface::nonConverged

Implements FlashBase.

◆ estimate()

void Flash::estimate ( const Value Pres,
const Value Temp 
)
overridevirtual

Estimates trivial unknowns; use only in sequential mode ! must be overridden when more unknowns are present

Implements FlashBase.

Reimplemented in FlashVl.

◆ estimateEquilibrium()

void Flash::estimateEquilibrium ( const Value Pres,
const Value Temp 
)
overridevirtual

estimate equilibrium-related unknowns

Implements FlashBase.

Reimplemented in StreamIapwsLiquidVapor, and StreamTwo< FlashVl >.

◆ Fraction()

const Value & Flash::Fraction ( Libpf::Utility::PhaseIndex  p,
bool  clip 
) const
overridevirtual

during Flash iterations use this function to get the actual estimate of the fraction of phase p

Parameters
pindex of the phase
clipwhether to clip the fraction between 0 and 1

Implements FlashBase.

Reimplemented in FlashVl, and StreamOneSolid.

◆ message()

std::string Flash::message ( int  code)
overrideprotectedvirtual

Implements FlashBase.

◆ niter()

int Flash::niter ( void  ) const
overridevirtual

return Flash iterations

Implements FlashBase.

◆ prepare_Flash_residuals()

void Flash::prepare_Flash_residuals ( void  )
inlineoverridevirtual

to be called before evaluating the residuals; implement in Flash or its subclasses; put any stream-specific initialization stuff here

Implements FlashBase.

Reimplemented in FlashVl, FlashVlT, and FlashVlTx.

◆ setFlash_()

void Flash::setFlash_ ( const Libpf::Utility::FlashMode fm,
const Value x,
const Value y,
bool  strict = true 
)
overrideprotectedvirtual

Set the stream's state variables and the Flash.

Implements FlashBase.

Reimplemented in FlashLlTx, and FlashVlT.

◆ setup_()

void Flash::setup_ ( std::vector< Value * >  pbeta_,
std::vector< const double * >  pbetamin_,
std::vector< const double * >  pbetamax_ 
)
overrideprotectedvirtual

set unknowns, solver sizes

Parameters
pbeta_vector of pointers to the phase betas
pbetamin_vector of pointers to the minimum allowable beta for the phases
pbetamax_vector of pointers to the maximum allowable beta for the phases

Implements FlashBase.

Reimplemented in FlashVl, and FlashVlTx.

◆ solveFlash()

int Flash::solveFlash ( bool  simultaneous,
bool  skip 
)
overrideprotectedvirtual

solve the flash if !simultaneous, only calls calculateResiduals if simultaneous

Parameters
simultaneousused if the flash is to solved during a simultaneous resolution of a larger set of equations
skipskip flash calculation and force the residuals to zero; used for streams with negligible flow

Implements FlashBase.

◆ solver()

SolverNleInterface * Flash::solver ( void  )
overridevirtual

Implements FlashBase.

◆ Sumx()

const Value & Flash::Sumx ( Libpf::Utility::PhaseIndex  p) const
overridevirtual

during Flash iterations use this function to get the actual estimate of the sum of molar fractions for phase p

Implements FlashBase.

Reimplemented in FlashVl.

◆ X()

Vector Flash::X ( Libpf::Utility::PhaseIndex  p) const
overridevirtual

during Flash iterations use this function to get the actual estimate of the molar fractions for phase p

Implements FlashBase.

Reimplemented in FlashVl, and StreamOneSolid.

Member Data Documentation

◆ NLEFlash_

SolverNle Flash::NLEFlash_
mutableprotected

Newton solver for the Flash.

◆ remotex_

std::vector<Quantity>* Flash::remotex_
protected

◆ sumx_

Value Flash::sumx_
protected

sum of molar fractions, or liquid phase molar fractions for multiphase derived classes


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