Cantera  2.1.2
vcs_TP.cpp
Go to the documentation of this file.
1 //! @file vcs_TP.cpp
6 
7 namespace VCSnonideal
8 {
9 int VCS_SOLVE::vcs_TP(int ipr, int ip1, int maxit, double T_arg, double pres_arg)
10 {
11  int retn, iconv;
12  /*
13  * Store the temperature and pressure in the private global variables
14  */
15  m_temperature = T_arg;
16  m_pressurePA = pres_arg;
17  /*
18  * Evaluate the standard state free energies
19  * at the current temperatures and pressures.
20  */
21  iconv = vcs_evalSS_TP(ipr, ip1, m_temperature, pres_arg);
22 
23  /*
24  * Prepare the problem data:
25  * ->nondimensionalize the free energies using
26  * the divisor, R * T
27  */
28  vcs_nondim_TP();
29  /*
30  * Prep the fe field
31  */
32  vcs_fePrep_TP();
33  /*
34  * Decide whether we need an initial estimate of the solution
35  * If so, go get one. If not, then
36  */
37  if (m_doEstimateEquil) {
38  retn = vcs_inest_TP();
39  if (retn != VCS_SUCCESS) {
40  plogf("vcs_inest_TP returned a failure flag\n");
41  }
42  }
43  /*
44  * Solve the problem at a fixed Temperature and Pressure
45  * (all information concerning Temperature and Pressure has already
46  * been derived. The free energies are now in dimensionless form.)
47  */
48  iconv = vcs_solve_TP(ipr, ip1, maxit);
49 
50  /*
51  * Redimensionalize the free energies using
52  * the reverse of vcs_nondim to add back units.
53  */
54  vcs_redim_TP();
55  /*
56  * Return the convergence success flag.
57  */
58  return iconv;
59 }
60 
61 int VCS_SOLVE::vcs_evalSS_TP(int ipr, int ip1, double Temp, double pres)
62 {
63  // int i;
64  //double R;
65  /*
66  * At this level of the program, we are still using values
67  * for the free energies that have units.
68  */
69  // R = vcsUtil_gasConstant(m_VCS_UnitsFormat);
70 
71  /*
72  * We need to special case VCS_UNITS_UNITLESS, here.
73  * cpc_ts_GStar_calc() returns units of Kelvin. Also, the temperature
74  * comes into play in calculating the ideal equation of state
75  * contributions, and other equations of state also. Therefore,
76  * we will emulate the VCS_UNITS_KELVIN case, here by changing
77  * the initial gibbs free energy units to Kelvin before feeding
78  * them to the cpc_ts_GStar_calc() routine. Then, we will revert
79  * them back to unitless at the end of this routine.
80  */
81 
82 
83  /*
84  * Loop over the species calculating the standard state Gibbs free
85  * energies. -> These are energies that only depend upon the Temperature
86  * and possibly on the pressure (i.e., ideal gas, etc).
87  */
88  // HKM -> We can change this to looks over phases, calling the vcs_VolPhase
89  // object. Working to get rid of VCS_SPECIES_THERMO object
90  //for (i = 0; i < m_numSpeciesTot; ++i) {
91  // VCS_SPECIES_THERMO *spt = SpeciesThermo[i];
92  // ff[i] = R * spt->GStar_R_calc(i, Temp, pres);
93  //}
94 
95  for (size_t iph = 0; iph < m_numPhases; iph++) {
96  vcs_VolPhase* vph = m_VolPhaseList[iph];
99  }
100 
101  if (m_VCS_UnitsFormat == VCS_UNITS_UNITLESS) {
102  for (size_t i = 0; i < m_numSpeciesTot; ++i) {
103  m_SSfeSpecies[i] /= Temp;
104  }
105  }
106  return VCS_SUCCESS;
107 }
108 
110 {
111  for (size_t i = 0; i < m_numSpeciesTot; ++i) {
112  /*
113  * For single species phases, initialize the chemical
114  * potential with the value of the standard state chemical
115  * potential. This value doesn't change during the calculation
116  */
117  if (m_SSPhase[i]) {
120  }
121  }
122 }
123 
124 }
std::vector< double > m_SSfeSpecies
Standard state chemical potentials for species K at the current temperature and pressure.
Definition: vcs_solve.h:1581
void vcs_fePrep_TP()
Initialize the chemical potential of single species phases.
Definition: vcs_TP.cpp:109
int vcs_inest_TP()
Create an initial estimate of the solution to the thermodynamic equilibrium problem.
Definition: vcs_inest.cpp:345
#define VCS_DATA_PTR(vvv)
Points to the data in a std::vector<> object.
Definition: vcs_internal.h:24
double m_temperature
Temperature (Kelvin)
Definition: vcs_solve.h:1738
std::vector< double > m_feSpecies_old
Free energy vector from the start of the current iteration.
Definition: vcs_solve.h:1588
int m_VCS_UnitsFormat
Units for the chemical potential data.
Definition: vcs_solve.h:2018
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.
Phase information and Phase calculations for vcs.
Definition: vcs_VolPhase.h:97
int m_doEstimateEquil
Setting for whether to do an initial estimate.
Definition: vcs_solve.h:1609
Internal declarations for the VCSnonideal package.
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:9
#define VCS_SUCCESS
Definition: vcs_defs.h:37
size_t m_numSpeciesTot
Total number of species in the problems.
Definition: vcs_solve.h:1497
std::vector< vcs_VolPhase * > m_VolPhaseList
Array of Phase Structures. Length = number of phases.
Definition: vcs_solve.h:1873
void sendToVCS_GStar(double *const gstar) const
Fill in the partial molar volume vector for VCS.
size_t m_numPhases
Number of Phases in the problem.
Definition: vcs_solve.h:1530
void vcs_nondim_TP()
Nondimensionalize the problem data.
Definition: vcs_nondim.cpp:76
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...
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:1597
void vcs_redim_TP()
Redimensionalize the problem data.
Definition: vcs_nondim.cpp:167
std::vector< char > m_SSPhase
Boolean indicating whether a species belongs to a single-species phase.
Definition: vcs_solve.h:1840
#define plogf
define this Cantera function to replace printf
Definition: vcs_internal.h:30
void setState_TP(const double temperature_Kelvin, const double pressure_PA)
Sets the temperature and pressure in this object and underlying ThermoPhase objects.
double m_pressurePA
Pressure (units are determined by m_VCS_UnitsFormat.
Definition: vcs_solve.h:1752
int vcs_evalSS_TP(int ipr, int ip1, double Temp, double pres)
Definition: vcs_TP.cpp:61