Cleaned up Doxygen documentation for class vcs_MultiPhaseEquil

This commit is contained in:
Ray Speth 2013-04-18 22:08:22 +00:00
parent ba5115fe64
commit fc7067b63d
2 changed files with 195 additions and 376 deletions

View file

@ -11,58 +11,38 @@
namespace Cantera namespace Cantera
{ {
//! Set a single-phase chemical solution to chemical equilibrium. //! Set a single-phase chemical solution to chemical equilibrium.
/*! /*!
* The function uses the element abundance vector that is * The function uses the element abundance vector that is currently
* currently consistent with the composition within the phase * consistent with the composition within the phase itself. Two other
* itself. Two other thermodynamic quantities, determined by the * thermodynamic quantities, determined by the XY string, are held constant
* XY string, are held constant during the equilibration. * during the equilibration. This is a convenience function that uses one or
* This is a convenience function that uses one or the other of * the other of the two chemical equilibrium solvers.
* the two chemical equilibrium solvers.
* *
* @param s The object to set to an equilibrium state * @param s The object to set to an equilibrium state
* * @param XY An integer specifying the two properties to be held constant.
* @param XY An integer specifying the two properties to be held
* constant.
*
* @param estimateEquil integer indicating whether the solver * @param estimateEquil integer indicating whether the solver
* should estimate its own initial condition. * should estimate its own initial condition.
* If 0, the initial mole fraction vector * - If 0, the initial mole fraction vector in the
* in the %ThermoPhase object is used as the * ThermoPhase object is used as the initial condition.
* initial condition. * - If 1, the initial mole fraction vector is used if the
* If 1, the initial mole fraction vector * element abundances are satisfied.
* is used if the element abundances are * - if -1, the initial mole fraction vector is thrown out,
* satisfied. * and an estimate is formulated.
* if -1, the initial mole fraction vector * @param printLvl Determines the amount of printing that gets sent to stdout
* is thrown out, and an estimate is * from the vcs package (Note, you may have to compile with
* formulated. * debug flags to get some printing).
* * @param solver The equilibrium solver to use. If solver = 0, the ChemEquil
* @param printLvl Determines the amount of printing that * solver will be used, and if solver = 1, the
* gets sent to stdout from the vcs package * vcs_MultiPhaseEquil solver will be used (slower than
* (Note, you may have to compile with debug * ChemEquil, but more stable). If solver < 0 (default, then
* flags to get some printing).
*
* @param solver The equilibrium solver to use. If solver = 0,
* the ChemEquil solver will be used, and if
* solver = 1, the vcs_MultiPhaseEquil solver will
* be used (slower than ChemEquil,
* but more stable). If solver < 0 (default, then
* ChemEquil will be tried first, and if it fails * ChemEquil will be tried first, and if it fails
* vcs_MultiPhaseEquil will be tried. * vcs_MultiPhaseEquil will be tried.
* * @param rtol Relative tolerance of the solve. Defaults to 1.0E-9.
* @param rtol Relative tolerance of the solve. Defaults to * @param maxsteps The maximum number of steps to take to find the solution.
* 1.0E-9. * @param maxiter For the MultiPhaseEquil solver only, this is the maximum
* * number of outer temperature or pressure iterations to take
* @param maxsteps The maximum number of steps to take to find * when T and/or P is not held fixed.
* the solution.
*
* @param maxiter For the MultiPhaseEquil solver only, this is
* the maximum number of outer temperature or
* pressure iterations to take when T and/or P is
* not held fixed.
*
* @param loglevel Controls amount of diagnostic output. loglevel * @param loglevel Controls amount of diagnostic output. loglevel
* = 0 suppresses diagnostics, and increasingly-verbose * = 0 suppresses diagnostics, and increasingly-verbose
* messages are written as loglevel increases. The * messages are written as loglevel increases. The
@ -77,53 +57,35 @@ int vcs_equilibrate(thermo_t& s, const char* XY,
int maxsteps = VCS_MAXSTEPS, int maxsteps = VCS_MAXSTEPS,
int maxiter = 100, int loglevel = -99); int maxiter = 100, int loglevel = -99);
//! Set a multi-phase chemical solution to chemical equilibrium. //! Set a multi-phase chemical solution to chemical equilibrium.
/*! /*!
* This function uses the vcs_MultiPhaseEquil interface to the * This function uses the vcs_MultiPhaseEquil interface to the vcs solver.
* vcs solver. * The function uses the element abundance vector that is currently
* The function uses the element abundance vector that is * consistent with the composition within the phases themselves. Two other
* currently consistent with the composition within the phases * thermodynamic quantities, determined by the XY string, are held constant
* themselves. Two other thermodynamic quantities, determined by the * during the equilibration.
* XY string, are held constant during the equilibration.
* *
* @param s The object to set to an equilibrium state * @param s The object to set to an equilibrium state
* * @param XY A character string representing the unknowns to be held constant
* @param XY A character string representing the unknowns
* to be held constant
*
* @param estimateEquil integer indicating whether the solver * @param estimateEquil integer indicating whether the solver
* should estimate its own initial condition. * should estimate its own initial condition.
* If 0, the initial mole fraction vector * - If 0, the initial mole fraction vector in the
* in the %ThermoPhase object is used as the * ThermoPhase object is used as the initial condition.
* initial condition. * - If 1, the initial mole fraction vector is used if the
* If 1, the initial mole fraction vector * element abundances are satisfied.
* is used if the element abundances are * - If -1, the initial mole fraction vector is thrown out,
* satisfied. * and an estimate is formulated.
* if -1, the initial mole fraction vector * @param printLvl Determines the amount of printing that gets sent to stdout
* is thrown out, and an estimate is * from the vcs package (Note, you may have to compile with
* formulated. * debug flags to get some printing).
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
*
* @param solver Determines which solver is used. * @param solver Determines which solver is used.
* - 1 MultiPhaseEquil solver * - 1 MultiPhaseEquil solver
* - 2 VCSnonideal Solver (default) * - 2 VCSnonideal Solver (default)
* * @param rtol Relative tolerance of the solve. Defaults to 1.0E-9.
* @param rtol Relative tolerance of the solve. Defaults to * @param maxsteps The maximum number of steps to take to find the solution.
* 1.0E-9. * @param maxiter For the MultiPhaseEquil solver only, this is the maximum
* * number of outer temperature or pressure iterations to take
* @param maxsteps The maximum number of steps to take to find * when T and/or P is not held fixed.
* the solution.
*
* @param maxiter For the MultiPhaseEquil solver only, this is
* the maximum number of outer temperature or
* pressure iterations to take when T and/or P is
* not held fixed.
*
* @param loglevel Controls amount of diagnostic output. loglevel * @param loglevel Controls amount of diagnostic output. loglevel
* = 0 suppresses diagnostics, and increasingly-verbose * = 0 suppresses diagnostics, and increasingly-verbose
* messages are written as loglevel increases. The * messages are written as loglevel increases. The
@ -140,50 +102,34 @@ int vcs_equilibrate(MultiPhase& s, const char* XY,
//! Set a multi-phase chemical solution to chemical equilibrium. //! Set a multi-phase chemical solution to chemical equilibrium.
/*! /*!
* This function uses the vcs_MultiPhaseEquil interface to the * This function uses the vcs_MultiPhaseEquil interface to the vcs solver.
* vcs solver. * The function uses the element abundance vector that is currently
* The function uses the element abundance vector that is * consistent with the composition within the phases themselves. Two other
* currently consistent with the composition within the phases * thermodynamic quantities, determined by the XY string, are held constant
* themselves. Two other thermodynamic quantities, determined by the * during the equilibration.
* XY string, are held constant during the equilibration.
* *
* @param s The MultiPhase object to be set to an equilibrium state * @param s The MultiPhase object to be set to an equilibrium state
* * @param ixy An integer specifying the two properties to be held constant.
* @param ixy An integer specifying the two properties to be held
* constant.
*
* @param estimateEquil integer indicating whether the solver * @param estimateEquil integer indicating whether the solver
* should estimate its own initial condition. * should estimate its own initial condition.
* If 0, the initial mole fraction vector * - If 0, the initial mole fraction vector in the
* in the %ThermoPhase object is used as the * ThermoPhase object is used as the initial condition.
* initial condition. * - If 1, the initial mole fraction vector is used if the
* If 1, the initial mole fraction vector * element abundances are satisfied.
* is used if the element abundances are * - if -1, the initial mole fraction vector is thrown out,
* satisfied. * and an estimate is formulated.
* if -1, the initial mole fraction vector * @param printLvl Determines the amount of printing that gets sent to stdout
* is thrown out, and an estimate is * from the vcs package (Note, you may have to compile with
* formulated. * debug flags to get some printing).
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
*
* @param solver Determines which solver is used. * @param solver Determines which solver is used.
* - 1 MultiPhaseEquil solver * - 1 MultiPhaseEquil solver
* - 2 VCSnonideal Solver (default) * - 2 VCSnonideal Solver (default)
* * @param rtol Relative tolerance of the solve. Defaults to 1.0E-9.
* @param rtol Relative tolerance of the solve. Defaults to * @param maxsteps The maximum number of steps to take to find the solution.
* 1.0E-9.
*
* @param maxsteps The maximum number of steps to take to find
* the solution.
*
* @param maxiter For the MultiPhaseEquil solver only, this is * @param maxiter For the MultiPhaseEquil solver only, this is
* the maximum number of outer temperature or * the maximum number of outer temperature or
* pressure iterations to take when T and/or P is * pressure iterations to take when T and/or P is
* not held fixed. * not held fixed.
*
* @param loglevel Controls amount of diagnostic output. loglevel * @param loglevel Controls amount of diagnostic output. loglevel
* = 0 suppresses diagnostics, and increasingly-verbose * = 0 suppresses diagnostics, and increasingly-verbose
* messages are written as loglevel increases. The * messages are written as loglevel increases. The
@ -201,18 +147,14 @@ int vcs_equilibrate_1(MultiPhase& s, int ixy,
//! Determine the phase stability of a single phase given the current conditions //! Determine the phase stability of a single phase given the current conditions
//! in a MultiPhase object //! in a MultiPhase object
/*! /*!
*
* @param s The MultiPhase object to be set to an equilibrium state * @param s The MultiPhase object to be set to an equilibrium state
* @param iphase Phase index within the multiphase object to be * @param iphase Phase index within the multiphase object to be
* tested for stability. * tested for stability.
* @param funcStab Function value that tests equilibrium. > 0 indicates stable * @param funcStab Function value that tests equilibrium. > 0 indicates stable
* < 0 indicates unstable * < 0 indicates unstable
* * @param printLvl Determines the amount of printing that gets sent to
* @param printLvl Determines the amount of printing that * stdout from the vcs package (Note, you may have to compile
* gets sent to stdout from the vcs package * with debug flags to get some printing).
* (Note, you may have to compile with debug
* flags to get some printing).
*
* @param loglevel Controls amount of diagnostic output. loglevel * @param loglevel Controls amount of diagnostic output. loglevel
* = 0 suppresses diagnostics, and increasingly-verbose * = 0 suppresses diagnostics, and increasingly-verbose
* messages are written as loglevel increases. The * messages are written as loglevel increases. The
@ -224,10 +166,10 @@ int vcs_determine_PhaseStability(MultiPhase& s, int iphase,
} }
//! Contains classes and functions implementing the VCS multi-phase
//! equilibrium solver.
namespace VCSnonideal namespace VCSnonideal
{ {
class VCS_PROB; class VCS_PROB;
class VCS_SOLVE; class VCS_SOLVE;
@ -249,55 +191,48 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
* *
* @param mphase MultiPhase object that is the source for all of the information * @param mphase MultiPhase object that is the source for all of the information
* @param vprob VCS_PROB problem definition that gets all of the information * @param vprob VCS_PROB problem definition that gets all of the information
*
*/ */
int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase, int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
VCSnonideal::VCS_PROB* vprob); VCSnonideal::VCS_PROB* vprob);
//! Cantera's Interface to the Multiphase chemical equilibrium solver. //! %Cantera's Interface to the Multiphase chemical equilibrium solver.
/*! /*!
* Class MultiPhaseEquil is designed to be used to set a mixture * Class vcs_MultiPhaseEquil is designed to be used to set a mixture
* containing one or more phases to a state of chemical equilibrium. * containing one or more phases to a state of chemical equilibrium.
* *
* Note, as currently constructed, the underlying ThermoPhase * Note, as currently constructed, the underlying ThermoPhase objects are
* objects are shared between the MultiPhase object and this * shared between the MultiPhase object and this object. Therefore, mix is not
* object. Therefore, mix is not a const argument, and the * a const argument, and the return parameters are contained in underlying
* return parameters are contained in underlying ThermoPhase * ThermoPhase objects.
* objects.
* *
* @ingroup equilfunctions * @ingroup equilfunctions
*/ */
class vcs_MultiPhaseEquil class vcs_MultiPhaseEquil
{ {
public: public:
//! Default empty constructor
vcs_MultiPhaseEquil(); vcs_MultiPhaseEquil();
//! Constructor for the multiphase equilibrium solver //! Constructor for the multiphase equilibrium solver
/*! /*!
* This constructor will initialize the object with a MultiPhase * This constructor will initialize the object with a MultiPhase object,
* object, setting up the internal equilibration problem. * setting up the internal equilibration problem. Note, as currently
* Note, as currently constructed, the underlying ThermoPhase * constructed, the underlying ThermoPhase objects are shared between the
* objects are shared between the MultiPhase object and this * MultiPhase object and this object. Therefore, mix is not a const
* object. Therefore, mix is not a const argument, and the * argument, and the return parameters are contained in underlying
* return parameters are contained in underlying ThermoPhase * ThermoPhase objects.
* objects.
* *
* @param mix Object containing the MultiPhase object * @param mix Object containing the MultiPhase object
* @param printLvl Determines the amount of printing to stdout * @param printLvl Determines the amount of printing to stdout
* that occurs for each call: * that occurs for each call:
* - 0 No printing * - 0: No printing
* - 1 Only printing to the .csv file * - 1: Only printing to the .csv file
* - 2 print the soln only * - 2: print the soln only
* - 3 Print the setup and then the soln only * - 3: Print the setup and then the soln only
* - 4 Print a table for each iteration * - 4: Print a table for each iteration
* - 5 Print more than a table for each iteration * - 5: Print more than a table for each iteration
*
*/ */
vcs_MultiPhaseEquil(Cantera::MultiPhase* mix, int printLvl); vcs_MultiPhaseEquil(Cantera::MultiPhase* mix, int printLvl);
//! Destructor for the class
virtual ~vcs_MultiPhaseEquil(); virtual ~vcs_MultiPhaseEquil();
//! Return the index of the ith component //! Return the index of the ith component
@ -323,9 +258,8 @@ public:
* all involve the components of the mixture. * all involve the components of the mixture.
* *
* @param rxn Reaction number. * @param rxn Reaction number.
* @param nu Vector of coefficients for the formation reaction. * @param nu Vector of coefficients for the formation reaction. Length is
* Length is equal to the number of species in * equal to the number of species in the MultiPhase object.
* the MultiPhase object.
*/ */
void getStoichVector(size_t rxn, Cantera::vector_fp& nu); void getStoichVector(size_t rxn, Cantera::vector_fp& nu);
@ -337,61 +271,50 @@ public:
//! Equilibrate the solution using the current element abundances //! Equilibrate the solution using the current element abundances
//! stored in the MultiPhase object //! stored in the MultiPhase object
/*! /*!
* Use the vcs algorithm to equilibrate the current multiphase * Use the vcs algorithm to equilibrate the current multiphase mixture.
* mixture.
* *
* @param XY Integer representing what two thermo quantities * @param XY Integer representing what two thermo quantities are
* are held constant during the equilibration * held constant during the equilibration
* * @param estimateEquil integer indicating whether the solver should
* @param estimateEquil integer indicating whether the solver * estimate its own initial condition.
* should estimate its own initial condition. * - If 0, the initial mole fraction vector in the
* If 0, the initial mole fraction vector * ThermoPhase object is used as the initial condition.
* in the %ThermoPhase object is used as the * - If 1, the initial mole fraction vector is used if
* initial condition. * the element abundances are satisfied.
* If 1, the initial mole fraction vector * - if -1, the initial mole fraction vector is thrown
* is used if the element abundances are * out, and an estimate is formulated.
* satisfied. * @param printLvl Determines the amount of printing that gets sent to
* if -1, the initial mole fraction vector * stdout from the vcs package (Note, you may have to
* is thrown out, and an estimate is * compile with debug flags to get some printing).
* formulated. * @param err Internal error level
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
* @param err Internal error level
* @param maxsteps max steps allowed. * @param maxsteps max steps allowed.
* @param loglevel for * @param loglevel Determines the amount of printing to the HTML
* output file.
*/ */
int equilibrate(int XY, int estimateEquil = 0, int equilibrate(int XY, int estimateEquil = 0,
int printLvl= 0, doublereal err = 1.0e-6, int printLvl= 0, doublereal err = 1.0e-6,
int maxsteps = VCS_MAXSTEPS, int loglevel=-99); int maxsteps = VCS_MAXSTEPS, int loglevel=-99);
//! Equilibrate the solution using the current element abundances //! Equilibrate the solution using the current element abundances
//! stored in the MultiPhase object using constant T and P //! stored in the MultiPhase object using constant T and P
/*! /*!
* Use the vcs algorithm to equilibrate the current multiphase * Use the vcs algorithm to equilibrate the current multiphase mixture.
* mixture.
* *
* @param estimateEquil integer indicating whether the solver * @param estimateEquil integer indicating whether the solver should
* should estimate its own initial condition. * estimate its own initial condition.
* If 0, the initial mole fraction vector * - If 0, the initial mole fraction vector in the
* in the %ThermoPhase object is used as the * ThermoPhase object is used as the initial condition.
* initial condition. * - If 1, the initial mole fraction vector is used if the
* If 1, the initial mole fraction vector * element abundances are satisfied.
* is used if the element abundances are * - if -1, the initial mole fraction vector is thrown
* satisfied. * out, and an estimate is formulated.
* if -1, the initial mole fraction vector * @param printLvl Determines the amount of printing that gets sent to
* is thrown out, and an estimate is * stdout from the vcs package (Note, you may have to
* formulated. * compile with debug flags to get some printing).
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
* @param err Internal error level * @param err Internal error level
* @param maxsteps max steps allowed. * @param maxsteps max steps allowed.
* @param loglevel for * @param loglevel Determines the amount of printing to the HTML
* output file.
*/ */
int equilibrate_TP(int estimateEquil = 0, int equilibrate_TP(int estimateEquil = 0,
int printLvl= 0, doublereal err = 1.0e-6, int printLvl= 0, doublereal err = 1.0e-6,
@ -405,44 +328,30 @@ public:
* mixture. The pressure of the calculation is taken from * mixture. The pressure of the calculation is taken from
* the current pressure stored with the MultiPhase object. * the current pressure stored with the MultiPhase object.
* *
* @param Htarget Value of the total mixture enthalpy or total * @param Htarget Value of the total mixture enthalpy or total internal
* internal energy that will be * energy that will be kept constant. Note, this is and
* kept constant. Note, this is and must be an extensive * must be an extensive quantity. units = Joules
* quantity. units = Joules
*
* @param XY Integer flag indicating what is held constant. * @param XY Integer flag indicating what is held constant.
* Must be either HP or UP. * Must be either HP or UP.
* * @param Tlow Lower limit of the temperature. It's an error condition
* @param Tlow Lower limit of the temperature. It's an * if the temperature falls below Tlow.
* error condition if the temperature falls * @param Thigh Upper limit of the temperature. It's an error condition
* below Tlow. * if the temperature goes higher than Thigh.
*
* @param Thigh Upper limit of the temperature. It's an
* error condition if the temperature goes
* higher than Thigh.
*
* @param estimateEquil integer indicating whether the solver * @param estimateEquil integer indicating whether the solver
* should estimate its own initial condition. * should estimate its own initial condition.
* If 0, the initial mole fraction vector * - If 0, the initial mole fraction vector in the
* in the %ThermoPhase object is used as the * ThermoPhase object is used as the initial condition.
* initial condition. * - If 1, the initial mole fraction vector is used if the
* If 1, the initial mole fraction vector * element abundances are satisfied.
* is used if the element abundances are * - if -1, the initial mole fraction vector is thrown
* satisfied. * out, and an estimate is formulated.
* if -1, the initial mole fraction vector
* is thrown out, and an estimate is
* formulated.
*
* @param printLvl Determines the amount of printing that * @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package * gets sent to stdout from the vcs package
* (Note, you may have to compile with debug * (Note, you may have to compile with debug
* flags to get some printing). See main * flags to get some printing). See main
* constructor call for meaning of the levels. * constructor call for meaning of the levels.
*
* @param err Internal error level * @param err Internal error level
*
* @param maxsteps max steps allowed. * @param maxsteps max steps allowed.
*
* @param loglevel Determines the amount of printing to the HTML * @param loglevel Determines the amount of printing to the HTML
* output file. * output file.
*/ */
@ -458,42 +367,28 @@ public:
* mixture. The pressure of the calculation is taken from * mixture. The pressure of the calculation is taken from
* the current pressure stored with the MultiPhase object. * the current pressure stored with the MultiPhase object.
* *
* @param Starget Value of the total mixture entropy * @param Starget Value of the total mixture entropy that will be kept
* that will be * constant. Note, this is and must be an extensive
* kept constant. Note, this is and must be an extensive
* quantity. units = Joules/K * quantity. units = Joules/K
* * @param Tlow Lower limit of the temperature. It's an error condition
* * if the temperature falls below Tlow.
* @param Tlow Lower limit of the temperature. It's an * @param Thigh Upper limit of the temperature. It's an error condition
* error condition if the temperature falls * if the temperature goes higher than Thigh.
* below Tlow. * @param estimateEquil integer indicating whether the solver should
* * estimate its own initial condition.
* @param Thigh Upper limit of the temperature. It's an * - If 0, the initial mole fraction vector in the
* error condition if the temperature goes * %ThermoPhase object is used as the initial condition.
* higher than Thigh. * - If 1, the initial mole fraction vector is used if the
* * element abundances are satisfied.
* @param estimateEquil integer indicating whether the solver * - If -1, the initial mole fraction vector is thrown
* should estimate its own initial condition. * out, and an estimate is formulated.
* If 0, the initial mole fraction vector
* in the %ThermoPhase object is used as the
* initial condition.
* If 1, the initial mole fraction vector
* is used if the element abundances are
* satisfied.
* if -1, the initial mole fraction vector
* is thrown out, and an estimate is
* formulated.
*
* @param printLvl Determines the amount of printing that * @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package * gets sent to stdout from the vcs package
* (Note, you may have to compile with debug * (Note, you may have to compile with debug
* flags to get some printing). See main * flags to get some printing). See main
* constructor call for meaning of the levels. * constructor call for meaning of the levels.
*
* @param err Internal error level * @param err Internal error level
*
* @param maxsteps max steps allowed. * @param maxsteps max steps allowed.
*
* @param loglevel Determines the amount of printing to the HTML * @param loglevel Determines the amount of printing to the HTML
* output file. * output file.
*/ */
@ -502,46 +397,33 @@ public:
int printLvl = 0, doublereal err = 1.0E-6, int printLvl = 0, doublereal err = 1.0E-6,
int maxsteps = VCS_MAXSTEPS, int loglevel=-99); int maxsteps = VCS_MAXSTEPS, int loglevel=-99);
//! Equilibrate the solution using the current element abundances stored
//! Equilibrate the solution using the current element abundances //! in the MultiPhase object using constant V and constant T, H, U or S.
//! stored in the MultiPhase object using constant V and constant
//! T, H, U, or S.
/*! /*!
* Use the vcs algorithm to equilibrate the current multiphase * Use the vcs algorithm to equilibrate the current multiphase
* mixture. The pressure of the calculation is taken from * mixture. The pressure of the calculation is taken from
* the current pressure stored with the MultiPhase object. * the current pressure stored with the MultiPhase object.
* *
*
* @param XY Integer flag indicating what is held constant. * @param XY Integer flag indicating what is held constant.
* Must be either TV, HV, UV, or SV. * Must be either TV, HV, UV, or SV.
*
* @param xtarget Value of the total thermodynamic parameter to * @param xtarget Value of the total thermodynamic parameter to
* be held constant in addition to V. * be held constant in addition to V.
* Note, except for T, this must be an extensive * Note, except for T, this must be an extensive
* quantity. units = Joules/K or Joules * quantity. units = Joules/K or Joules
* * @param estimateEquil integer indicating whether the solver should
* @param estimateEquil integer indicating whether the solver * estimate its own initial condition.
* should estimate its own initial condition. * - If 0, the initial mole fraction vector in the
* If 0, the initial mole fraction vector * ThermoPhase object is used as the initial condition.
* in the %ThermoPhase object is used as the * - If 1, the initial mole fraction vector is used if the
* initial condition. * element abundances are satisfied.
* If 1, the initial mole fraction vector * - if -1, the initial mole fraction vector is thrown
* is used if the element abundances are * out, and an estimate is formulated.
* satisfied. * @param printLvl Determines the amount of printing that gets sent to
* if -1, the initial mole fraction vector * stdout from the vcs package (Note, you may have to
* is thrown out, and an estimate is * compile with debug flags to get some printing). See
* formulated. * main constructor call for meaning of the levels.
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing). See main
* constructor call for meaning of the levels.
*
* @param err Internal error level * @param err Internal error level
*
* @param maxsteps max steps allowed. * @param maxsteps max steps allowed.
*
* @param logLevel Determines the amount of printing to the HTML * @param logLevel Determines the amount of printing to the HTML
* output file. * output file.
*/ */
@ -557,10 +439,9 @@ public:
* @param iph Phase number to determine the equilibrium. If the phase * @param iph Phase number to determine the equilibrium. If the phase
* has a non-zero mole number.... * has a non-zero mole number....
* @param funcStab Value of the phase pop function * @param funcStab Value of the phase pop function
* @param printLvl Determines the amount of printing that * @param printLvl Determines the amount of printing that gets sent to
* gets sent to stdout from the vcs package * stdout from the vcs package (Note, you may have to
* (Note, you may have to compile with debug * compile with debug flags to get some printing).
* flags to get some printing).
* @param logLevel Determines the amount of printing to the HTML output file. * @param logLevel Determines the amount of printing to the HTML output file.
*/ */
int determine_PhaseStability(int iph, double& funcStab, int printLvl= 0, int logLevel = -99); int determine_PhaseStability(int iph, double& funcStab, int printLvl= 0, int logLevel = -99);
@ -588,36 +469,31 @@ public:
*/ */
size_t numElemConstraints() const; size_t numElemConstraints() const;
// Friend functions // Friend functions
friend int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase, friend int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
VCSnonideal::VCS_PROB* vprob); VCSnonideal::VCS_PROB* vprob);
friend int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase, friend int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
VCSnonideal::VCS_PROB* vprob); VCSnonideal::VCS_PROB* vprob);
protected: protected:
//! Vector that takes into account of the current sorting of the species
//! Vector that takes into account of the current sorting of the species
/*! /*!
* The index of m_order is the original k value of the species in the * The index of m_order is the original k value of the species in the
* multiphase. The value of m_order, k_sorted, is the current value of the * multiphase. The value of m_order, k_sorted, is the current value of
* species index. * the species index.
* *
* m_order[korig] = k_sorted * `m_order[korig] = k_sorted`
*/ */
Cantera::vector_int m_order; Cantera::vector_int m_order;
//! Object which contains the problem statement //! Object which contains the problem statement
/*! /*!
* The problem statement may contain some subtleties. For example, * The problem statement may contain some subtleties. For example, the
* the element constraints may be different than just an element * element constraints may be different than just an element conservation
* conservation contraint equations. * contraint equations. There may be kinetically frozen degrees of
* There may be kinetically frozen degrees of freedom. * freedom. There may be multiple electrolyte phases with zero charge
* There may be multiple electrolyte phases with zero charge constraints. * constraints. All of these make the problem statement different than
* All of these make the problem statement different than the * the simple element conservation statement.
* simple element conservation statement.
*/ */
VCSnonideal::VCS_PROB* m_vprob; VCSnonideal::VCS_PROB* m_vprob;
@ -629,19 +505,16 @@ protected:
//! Print level from the VCSnonlinear package //! Print level from the VCSnonlinear package
/*! /*!
* (Note, you may have to compile with debug * (Note, you may have to compile with debug flags to get some printing).
* flags to get some printing).
* *
* - 0 No IO from the routine whatsoever * - 0: No IO from the routine whatsoever
* - 1 file IO from reportCSV() carried out. * - 1: file IO from reportCSV() carried out. One line print statements
* One line print statements from equilibrate_XY() functions * from equilibrate_XY() functions
* - 2 Problem statement information from vcs_Cantera_update_vprob() * - 2: Problem statement information from vcs_Cantera_update_vprob();
* - Final state of the system from vcs_solve_TP() * Final state of the system from vcs_solve_TP()
* - 3 Several more setup tables * - 3: Several more setup tables; Problem initialization routine
* - Problem initialization routine * - 4: One table for each iteration within vcs_solve_Tp()
* - 4 One table for each iteration within vcs_solve_Tp() * - 5: Multiple tables for each iteration within vcs_solve_TP()
* - 5 Multiple tables for each iteration within vcs_solve_TP()
* - full discussion of decisions made for each variable.
*/ */
int m_printLvl; int m_printLvl;
@ -651,11 +524,9 @@ protected:
//! Iteration Count //! Iteration Count
int m_iter; int m_iter;
//! Vector of indices for species that are included in the //! Vector of indices for species that are included in the calculation.
//! calculation.
/*! /*!
* This is used to exclude pure-phase species * This is used to exclude pure-phase species with invalid thermo data
* with invalid thermo data
*/ */
Cantera::vector_int m_species; Cantera::vector_int m_species;
@ -665,18 +536,15 @@ protected:
* than this object or the VCS_PROB object. This object owns the pointer. * than this object or the VCS_PROB object. This object owns the pointer.
*/ */
VCSnonideal::VCS_SOLVE* m_vsolvePtr; VCSnonideal::VCS_SOLVE* m_vsolvePtr;
}; };
//! Global hook for turning on and off time printing. //! Global hook for turning on and off time printing.
/*! /*!
* Default is to allow printing. But, you can assign this to zero * Default is to allow printing. But, you can assign this to zero globally to
* globally to turn off all time printing. * turn off all time printing. This is helpful for test suite purposes where
* This is helpful for test suite purposes where you are interested * you are interested in differences in text files.
* in differences in text files.
*/ */
extern int vcs_timing_print_lvl; extern int vcs_timing_print_lvl;
} }
#endif #endif

View file

@ -33,12 +33,9 @@
using namespace Cantera; using namespace Cantera;
using namespace std; using namespace std;
//using namespace VCSnonideal;
namespace VCSnonideal namespace VCSnonideal
{ {
//====================================================================================================================
vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() : vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
m_vprob(0), m_vprob(0),
m_mix(0), m_mix(0),
@ -46,7 +43,7 @@ vcs_MultiPhaseEquil::vcs_MultiPhaseEquil() :
m_vsolvePtr(0) m_vsolvePtr(0)
{ {
} }
//====================================================================================================================
vcs_MultiPhaseEquil::vcs_MultiPhaseEquil(Cantera::MultiPhase* mix, int printLvl) : vcs_MultiPhaseEquil::vcs_MultiPhaseEquil(Cantera::MultiPhase* mix, int printLvl) :
m_vprob(0), m_vprob(0),
m_mix(0), m_mix(0),
@ -81,13 +78,12 @@ vcs_MultiPhaseEquil::~vcs_MultiPhaseEquil()
m_vsolvePtr = 0; m_vsolvePtr = 0;
} }
} }
//====================================================================================================================
int vcs_MultiPhaseEquil::equilibrate_TV(int XY, doublereal xtarget, int vcs_MultiPhaseEquil::equilibrate_TV(int XY, doublereal xtarget,
int estimateEquil, int estimateEquil,
int printLvl, doublereal err, int printLvl, doublereal err,
int maxsteps, int loglevel) int maxsteps, int loglevel)
{ {
addLogEntry("problem type","fixed T, V"); addLogEntry("problem type","fixed T, V");
// doublereal dt = 1.0e3; // doublereal dt = 1.0e3;
doublereal Vtarget = m_mix->volume(); doublereal Vtarget = m_mix->volume();
@ -203,7 +199,6 @@ done:
return iSuccess; return iSuccess;
} }
//====================================================================================================================
int vcs_MultiPhaseEquil::equilibrate_HP(doublereal Htarget, int vcs_MultiPhaseEquil::equilibrate_HP(doublereal Htarget,
int XY, double Tlow, double Thigh, int XY, double Tlow, double Thigh,
int estimateEquil, int estimateEquil,
@ -362,7 +357,7 @@ done:
; ;
return iSuccess; return iSuccess;
} }
//====================================================================================================================
int vcs_MultiPhaseEquil::equilibrate_SP(doublereal Starget, int vcs_MultiPhaseEquil::equilibrate_SP(doublereal Starget,
double Tlow, double Thigh, double Tlow, double Thigh,
int estimateEquil, int estimateEquil,
@ -519,11 +514,7 @@ int vcs_MultiPhaseEquil::equilibrate_SP(doublereal Starget,
throw CanteraError("MultiPhase::equilibrate_SP", throw CanteraError("MultiPhase::equilibrate_SP",
"No convergence for T"); "No convergence for T");
} }
//====================================================================================================================
/*
* Equilibrate the solution using the current element abundances
*/
int vcs_MultiPhaseEquil::equilibrate(int XY, int estimateEquil, int vcs_MultiPhaseEquil::equilibrate(int XY, int estimateEquil,
int printLvl, doublereal err, int printLvl, doublereal err,
int maxsteps, int loglevel) int maxsteps, int loglevel)
@ -571,16 +562,11 @@ int vcs_MultiPhaseEquil::equilibrate(int XY, int estimateEquil,
} }
return iSuccess; return iSuccess;
} }
//====================================================================================================================
/*
* Equilibrate the solution using the current element abundances
*/
int vcs_MultiPhaseEquil::equilibrate_TP(int estimateEquil, int vcs_MultiPhaseEquil::equilibrate_TP(int estimateEquil,
int printLvl, doublereal err, int printLvl, doublereal err,
int maxsteps, int loglevel) int maxsteps, int loglevel)
{ {
// Debugging level
int maxit = maxsteps; int maxit = maxsteps;
clockWC tickTock; clockWC tickTock;
@ -736,12 +722,6 @@ int vcs_MultiPhaseEquil::equilibrate_TP(int estimateEquil,
return iSuccess; return iSuccess;
} }
//====================================================================================================================
/**************************************************************************
*
*
*/
void vcs_MultiPhaseEquil::reportCSV(const std::string& reportFile) void vcs_MultiPhaseEquil::reportCSV(const std::string& reportFile)
{ {
size_t k; size_t k;
@ -911,10 +891,8 @@ static void print_char(const char letter, const int num)
plogf("%c", letter); plogf("%c", letter);
} }
} }
//====================================================================================================================
/* /*
*
*
* HKM -> Work on transferring the current value of the voltages into the * HKM -> Work on transferring the current value of the voltages into the
* equilibrium problem. * equilibrium problem.
*/ */
@ -1328,11 +1306,7 @@ int vcs_Cantera_to_vprob(Cantera::MultiPhase* mphase,
return VCS_SUCCESS; return VCS_SUCCESS;
} }
//====================================================================================================================
// Transfer the current state of mphase into the VCS_PROB object
/*
* The basic problem has already been set up.
*/
int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase, int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
VCSnonideal::VCS_PROB* vprob) VCSnonideal::VCS_PROB* vprob)
{ {
@ -1465,8 +1439,7 @@ int vcs_Cantera_update_vprob(Cantera::MultiPhase* mphase,
return VCS_SUCCESS; return VCS_SUCCESS;
} }
//====================================================================================================================
// This routine hasn't been checked yet
void vcs_MultiPhaseEquil::getStoichVector(size_t rxn, Cantera::vector_fp& nu) void vcs_MultiPhaseEquil::getStoichVector(size_t rxn, Cantera::vector_fp& nu)
{ {
size_t nsp = m_vsolvePtr->m_numSpeciesTot; size_t nsp = m_vsolvePtr->m_numSpeciesTot;
@ -1508,7 +1481,6 @@ size_t vcs_MultiPhaseEquil::numElemConstraints() const
return nec; return nec;
} }
size_t vcs_MultiPhaseEquil::component(size_t m) const size_t vcs_MultiPhaseEquil::component(size_t m) const
{ {
size_t nc = numComponents(); size_t nc = numComponents();
@ -1519,28 +1491,8 @@ size_t vcs_MultiPhaseEquil::component(size_t m) const
} }
} }
//====================================================================================================================
// Determine the phase stability of a phase at the current conditions
/*
* Equilibration of the solution is not done before the determination is made.
*
* @param iph Phase number to determine the equilibrium. If the phase
* has a non-zero mole number....
*
* @param funcStab Value of the phase pop function
*
* @param printLvl Determines the amount of printing that
* gets sent to stdout from the vcs package
* (Note, you may have to compile with debug
* flags to get some printing).
*
* @param loglevel Determines the amount of printing to the HTML
* output file.
*/
int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int printLvl, int loglevel) int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int printLvl, int loglevel)
{ {
clockWC tickTock; clockWC tickTock;
size_t nsp = m_mix->nSpecies(); size_t nsp = m_mix->nSpecies();
size_t nel = m_mix->nElements(); size_t nel = m_mix->nElements();
@ -1674,6 +1626,5 @@ int vcs_MultiPhaseEquil::determine_PhaseStability(int iph, double& funcStab, int
return iStable; return iStable;
} }
//====================================================================================================================
} }