Cantera  2.3.0
vcs_solve_phaseStability.cpp
Go to the documentation of this file.
1 //! @file vcs_solve_phaseStability.cpp
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at http://www.cantera.org/license.txt for license and copyright information.
5 
8 
9 using namespace std;
10 
11 namespace Cantera
12 {
13 
14 int VCS_SOLVE::vcs_PS(VCS_PROB* vprob, int iphase, int printLvl, double& feStable)
15 {
16  warn_deprecated("VCS_SOLVE::vcs_PS",
17  "Broken and unused. To be removed after Cantera 2.3.");
18  // ifunc determines the problem type
19  int ifunc = 0;
20 
21  // This function is called to create the private data using the public data.
22  size_t nspecies0 = vprob->nspecies + 10;
23  size_t nelements0 = vprob->ne;
24  size_t nphase0 = vprob->NPhase;
25  vcs_initSizes(nspecies0, nelements0, nphase0);
26 
27  if (ifunc < 0 || ifunc > 2) {
28  plogf("vcs: Unrecognized value of ifunc, %d: bailing!\n",
29  ifunc);
30  return VCS_PUB_BAD;
31  }
32 
33  // This function is called to copy the public data and the current problem
34  // specification into the current object's data structure.
35  int retn = vcs_prob_specifyFully(vprob);
36  if (retn != 0) {
37  plogf("vcs_pub_to_priv returned a bad status, %d: bailing!\n",
38  retn);
39  return retn;
40  }
41 
42  // Prep the problem data
43  // - adjust the identity of any phases
44  // - determine the number of components in the problem
45  retn = vcs_prep_oneTime(printLvl);
46  if (retn != 0) {
47  plogf("vcs_prep_oneTime returned a bad status, %d: bailing!\n",
48  retn);
49  return retn;
50  }
51 
52  // This function is called to copy the current problem into the current
53  // object's data structure.
54  retn = vcs_prob_specify(vprob);
55  if (retn != 0) {
56  plogf("vcs_prob_specify returned a bad status, %d: bailing!\n",
57  retn);
58  return retn;
59  }
60 
61  // Prep the problem data for this particular instantiation of the problem
62  retn = vcs_prep();
63  if (retn != VCS_SUCCESS) {
64  plogf("vcs_prep returned a bad status, %d: bailing!\n", retn);
65  return retn;
66  }
67 
68  // Check to see if the current problem is well posed.
69  if (!vcs_wellPosed(vprob)) {
70  plogf("vcs has determined the problem is not well posed: Bailing\n");
71  return VCS_PUB_BAD;
72  }
73 
74  // Store the temperature and pressure in the private global variables
75  m_temperature = vprob->T;
76  m_pressurePA = vprob->PresPA;
77 
78  // Evaluate the standard state free energies at the current temperatures and
79  // pressures.
80  vcs_evalSS_TP(printLvl, printLvl, m_temperature, m_pressurePA);
81 
82  // Prepare the problem data: nondimensionalize the free energies using the
83  // divisor, R * T
84  vcs_nondim_TP();
85 
86  // Prep the fe field
87  vcs_fePrep_TP();
88 
89  // Solve the problem at a fixed Temperature and Pressure (all information
90  // concerning Temperature and Pressure has already been derived. The free
91  // energies are now in dimensionless form.)
92  int iStab = vcs_solve_phaseStability(iphase, ifunc, feStable, printLvl);
93 
94  // Redimensionalize the free energies using the reverse of vcs_nondim to add
95  // back units.
96  vcs_redim_TP();
97 
98  vcs_prob_update(vprob);
99 
100  // Return the convergence success flag.
101  return iStab;
102 }
103 
104 int VCS_SOLVE::vcs_solve_phaseStability(const int iph, const int ifunc,
105  double& funcVal,
106  int printLvl)
107 {
108  warn_deprecated("VCS_SOLVE::vcs_solve_phaseStability",
109  "Broken and unused. To be removed after Cantera 2.3.");
110  double test = -1.0E-10;
111  bool usedZeroedSpecies;
112 
113  vector_fp sm(m_numElemConstraints*m_numElemConstraints, 0.0);
114  vector_fp ss(m_numElemConstraints, 0.0);
115  vector_fp sa(m_numElemConstraints, 0.0);
116  vector_fp aw(m_numSpeciesTot, 0.0);
117  vector_fp wx(m_numElemConstraints, 0.0);
118 
119  vcs_basopt(false, &aw[0], &sa[0], &sm[0], &ss[0],
120  test, &usedZeroedSpecies);
121  vcs_evaluate_speciesType();
122 
123  vcs_dfe(VCS_STATECALC_OLD, 0, 0, m_numSpeciesRdc);
124  if (printLvl > 3) {
125  vcs_printSpeciesChemPot(VCS_STATECALC_OLD);
126  }
127  vcs_deltag(0, true, VCS_STATECALC_OLD);
128 
129  if (printLvl > 3) {
130  vcs_printDeltaG(VCS_STATECALC_OLD);
131  }
132  m_deltaGRxn_Deficient = m_deltaGRxn_old;
133  funcVal = vcs_phaseStabilityTest(iph);
134  if (funcVal > 0.0) {
135  return 1;
136  } else {
137  return 0;
138  }
139 }
140 
141 }
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
STL namespace.
Header file for the internal object that holds the vcs equilibrium problem (see Class VCS_SOLVE and E...
#define VCS_SUCCESS
Definition: vcs_defs.h:18
Header for the Interface class for the vcs thermo equilibrium solver package,.
size_t nspecies
Total number of species in the problems.
Definition: vcs_prob.h:30
double PresPA
Pressure.
Definition: vcs_prob.h:100
size_t ne
Number of element constraints in the equilibrium problem.
Definition: vcs_prob.h:36
#define VCS_STATECALC_OLD
State Calculation based on the old or base mole numbers.
Definition: vcs_defs.h:320
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
double T
Temperature (Kelvin)
Definition: vcs_prob.h:97
#define plogf
define this Cantera function to replace printf
Definition: vcs_internal.h:18
size_t NPhase
Number of phases in the problem.
Definition: vcs_prob.h:43
Namespace for the Cantera kernel.
Definition: application.cpp:29
Interface class for the vcs thermo equilibrium solver package, which generally describes the problem ...
Definition: vcs_prob.h:22