Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vcs_TP.cpp
Go to the documentation of this file.
1 //! @file vcs_TP.cpp
4 
5 namespace Cantera
6 {
7 int VCS_SOLVE::vcs_TP(int ipr, int ip1, int maxit, double T_arg, double pres_arg)
8 {
9  /*
10  * Store the temperature and pressure in the private global variables
11  */
12  m_temperature = T_arg;
13  m_pressurePA = pres_arg;
14  /*
15  * Evaluate the standard state free energies
16  * at the current temperatures and pressures.
17  */
18  int iconv = vcs_evalSS_TP(ipr, ip1, m_temperature, pres_arg);
19 
20  /*
21  * Prepare the problem data:
22  * ->nondimensionalize the free energies using
23  * the divisor, R * T
24  */
25  vcs_nondim_TP();
26  /*
27  * Prep the fe field
28  */
29  vcs_fePrep_TP();
30  /*
31  * Decide whether we need an initial estimate of the solution
32  * If so, go get one. If not, then
33  */
34  if (m_doEstimateEquil) {
35  int retn = vcs_inest_TP();
36  if (retn != VCS_SUCCESS) {
37  plogf("vcs_inest_TP returned a failure flag\n");
38  }
39  }
40  /*
41  * Solve the problem at a fixed Temperature and Pressure
42  * (all information concerning Temperature and Pressure has already
43  * been derived. The free energies are now in dimensionless form.)
44  */
45  iconv = vcs_solve_TP(ipr, ip1, maxit);
46 
47  /*
48  * Redimensionalize the free energies using
49  * the reverse of vcs_nondim to add back units.
50  */
51  vcs_redim_TP();
52  /*
53  * Return the convergence success flag.
54  */
55  return iconv;
56 }
57 
58 int VCS_SOLVE::vcs_evalSS_TP(int ipr, int ip1, double Temp, double pres)
59 {
60  /*
61  * We need to special case VCS_UNITS_UNITLESS, here.
62  * cpc_ts_GStar_calc() returns units of Kelvin. Also, the temperature
63  * comes into play in calculating the ideal equation of state
64  * contributions, and other equations of state also. Therefore,
65  * we will emulate the VCS_UNITS_KELVIN case, here by changing
66  * the initial Gibbs free energy units to Kelvin before feeding
67  * them to the cpc_ts_GStar_calc() routine. Then, we will revert
68  * them back to unitless at the end of this routine.
69  */
70 
71  for (size_t iph = 0; iph < m_numPhases; iph++) {
72  vcs_VolPhase* vph = m_VolPhaseList[iph];
75  }
76 
77  if (m_VCS_UnitsFormat == VCS_UNITS_UNITLESS) {
78  for (size_t i = 0; i < m_numSpeciesTot; ++i) {
79  m_SSfeSpecies[i] /= Temp;
80  }
81  }
82  return VCS_SUCCESS;
83 }
84 
86 {
87  for (size_t i = 0; i < m_numSpeciesTot; ++i) {
88  /*
89  * For single species phases, initialize the chemical
90  * potential with the value of the standard state chemical
91  * potential. This value doesn't change during the calculation
92  */
93  if (m_SSPhase[i]) {
96  }
97  }
98 }
99 
100 }
std::vector< double > m_feSpecies_new
Dimensionless new free energy for all the species in the mechanism at the new tentatite T...
Definition: vcs_solve.h:1593
int vcs_TP(int ipr, int ip1, int maxit, double T, double pres)
Solve an equilibrium problem at a particular fixed temperature and pressure.
Definition: vcs_TP.cpp:7
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
Definition: vcs_internal.h:18
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
Definition: vcs_solve.h:1869
void vcs_nondim_TP()
Nondimensionalize the problem data.
Definition: vcs_nondim.cpp:60
void vcs_redim_TP()
Redimensionalize the problem data.
Definition: vcs_nondim.cpp:145
int m_VCS_UnitsFormat
Units for the chemical potential data.
Definition: vcs_solve.h:2014
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...
Header for the object representing each phase within vcs.
int m_doEstimateEquil
Setting for whether to do an initial estimate.
Definition: vcs_solve.h:1605
int vcs_inest_TP()
Create an initial estimate of the solution to the thermodynamic equilibrium problem.
Definition: vcs_inest.cpp:320
#define VCS_SUCCESS
Definition: vcs_defs.h:21
size_t m_numSpeciesTot
Total number of species in the problems.
Definition: vcs_solve.h:1493
int vcs_evalSS_TP(int ipr, int ip1, double Temp, double pres)
Definition: vcs_TP.cpp:58
std::vector< double > m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
Definition: vcs_solve.h:1577
double m_temperature
Temperature (Kelvin)
Definition: vcs_solve.h:1734
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
Definition: vcs_solve.h:1836
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:86
double m_pressurePA
Pressure (units are determined by m_VCS_UnitsFormat.
Definition: vcs_solve.h:1748
#define plogf
define this Cantera function to replace printf
Definition: vcs_internal.h:24
void sendToVCS_GStar(double *const gstar) const
Fill in the partial molar volume vector for VCS.
int vcs_solve_TP(int print_lvl, int printDetails, int maxit)
Main routine that solves for equilibrium at constant T and P using a variant of the VCS method...
size_t m_numPhases
Number of Phases in the problem.
Definition: vcs_solve.h:1526
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
void vcs_fePrep_TP()
Initialize the chemical potential of single species phases.
Definition: vcs_TP.cpp:85
std::vector< double > m_feSpecies_old
Free energy vector from the start of the current iteration.
Definition: vcs_solve.h:1584