#include <FlashVl.h>

Inheritance diagram for FlashVl:

Public Member Functions

 FlashVl (void)
 
Value calculateResidualsRrg (void)
 assumes x_, y_, zk_ and kz_ More...
 
const ValueFraction (Libpf::Utility::PhaseIndex p, bool clip=false) 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 estimate (const Value &Pres, const Value &Temp) override
 override Flash to call fillkvl More...
 
void hardclipalfa (Value &alfa)
 clip alfa between zero and one More...
 
void setmidalfa (void)
 set alfa midway between alfamin_ and alfamax_ More...
 
void prepare_Flash_residuals (void) override
 
const Valuekvl (int i) const
 
- Public Member Functions inherited from Flash
 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...
 

Static Public Attributes

static bool drive_
 

Protected Member Functions

void computealfaminmax (const Vector &z)
 
virtual void fillkvl (const Value &Pres, const Value &Temp, bool force)
 
void calculateSplit (const Vector &z)
 fill in x_, y_, zk_, kz_ sumx_, sumy_ More...
 
void setup_ (std::vector< Value * > pbeta_, std::vector< const double * > pbetamin_, std::vector< const double * > pbetamax_) override
 override Flash to add alfa_ as unknown More...
 
const Valuezk (void) const
 
const Valuekz (void) const
 
- Protected Member Functions inherited from Flash
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

std::vector< ValuekVL_
 equilibrium factors More...
 
Libpf::Utility::PhaseIndex firstpid_
 PhaseIndex of the first phase (the vapor phase) More...
 
Libpf::Utility::PhaseIndex secondpid_
 PhaseIndex of the second phase (the liquid phase) More...
 
Value alfac1_
 alfa complement to one More...
 
Value sumy_
 sum of vapor phase molar fractions More...
 
Value alfa_
 phase fraction, unknown between 0 and 1 More...
 
Value alfaClipped_
 clipped alfa More...
 
std::vector< Valuex_
 liquid phase molar fractions More...
 
std::vector< Valuey_
 vapor phase molar fractions More...
 
- Protected Attributes inherited from Flash
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

Two-phase vapor-liquid Flash
Supports only constant kVL coefficients, independent from temperature and phase composition Possible flash option:

  • PT
  • DT
  • KT
  • PH
  • DH
  • KH
  • PS
  • DS
  • KS

#include <libpf/streams/FlashVl.h>

Remarks
XA Flashes are not possible because lacking a temperature / kVL relationship
the temperature can not be determined from the vapor fraction
Warning
Thread safe:
Extendable:
Platform dependencies:

Constructor & Destructor Documentation

◆ FlashVl()

FlashVl::FlashVl ( void  )

Member Function Documentation

◆ calculateResidualsRrg()

Value FlashVl::calculateResidualsRrg ( void  )

assumes x_, y_, zk_ and kz_

◆ calculateSplit()

void FlashVl::calculateSplit ( const Vector z)
protected

fill in x_, y_, zk_, kz_ sumx_, sumy_

◆ computealfaminmax()

void FlashVl::computealfaminmax ( const Vector z)
protected

◆ estimate()

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

override Flash to call fillkvl

Reimplemented from Flash.

◆ fillkvl()

virtual void FlashVl::fillkvl ( const Value Pres,
const Value Temp,
bool  force 
)
inlineprotectedvirtual

fill in the kVL_; if !force, will skip the calculation for components absent from both vapor and liquid phase

Parameters
Prespressure
Temptemperature
forceforces calculation even for components absent from both vapor and liquid phase

Reimplemented in FlashLlTx, FlashVlT, StreamTabularLiquidLiquid, and StreamTabularLiquidVapor.

◆ Fraction()

const Value & FlashVl::Fraction ( Libpf::Utility::PhaseIndex  p,
bool  clip = false 
) 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

Reimplemented from Flash.

◆ hardclipalfa()

void FlashVl::hardclipalfa ( Value alfa)

clip alfa between zero and one

◆ kvl()

const Value & FlashVl::kvl ( int  i) const
Returns
the equilibrium factor for component i

◆ kz()

const Value & FlashVl::kz ( void  ) const
protected

◆ prepare_Flash_residuals()

void FlashVl::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

Reimplemented from Flash.

Reimplemented in FlashVlT, and FlashVlTx.

◆ setmidalfa()

void FlashVl::setmidalfa ( void  )

set alfa midway between alfamin_ and alfamax_

◆ setup_()

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

override Flash to add alfa_ as unknown

Reimplemented from Flash.

Reimplemented in FlashVlTx.

◆ Sumx()

const Value & FlashVl::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

Reimplemented from Flash.

◆ X()

Vector FlashVl::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

Reimplemented from Flash.

◆ zk()

const Value & FlashVl::zk ( void  ) const
protected

Member Data Documentation

◆ alfa_

Value FlashVl::alfa_
protected

phase fraction, unknown between 0 and 1

◆ alfac1_

Value FlashVl::alfac1_
mutableprotected

alfa complement to one

◆ alfaClipped_

Value FlashVl::alfaClipped_
protected

clipped alfa

◆ drive_

bool FlashVl::drive_
static

whether RRG is driven outside unfeasible range if alfa_ outside [alfamin_, alfamax_]

◆ firstpid_

Libpf::Utility::PhaseIndex FlashVl::firstpid_
protected

PhaseIndex of the first phase (the vapor phase)

◆ kVL_

std::vector<Value> FlashVl::kVL_
protected

equilibrium factors

◆ secondpid_

Libpf::Utility::PhaseIndex FlashVl::secondpid_
protected

PhaseIndex of the second phase (the liquid phase)

◆ sumy_

Value FlashVl::sumy_
protected

sum of vapor phase molar fractions

◆ x_

std::vector<Value> FlashVl::x_
protected

liquid phase molar fractions

◆ y_

std::vector<Value> FlashVl::y_
protected

vapor phase molar fractions


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