1 /**
2  *  @file ISSPTester.cpp
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at https://cantera.org/license.txt for license and copyright information.
7 
8 //  Example
9 //
10 //  Read a mechanism and a thermodynamics file for the
11 //  class IdealSolidSolnPhase in order to test that it's
12 //  working correctly
13 //
14 
15 #include "cantera/thermo/IdealSolnGasVPSS.h"
16 #include <iostream>
17 #include <cstdio>
18 
19 using namespace std;
20 using namespace Cantera;
21 
main(int argc,char ** argv)22 int main(int argc, char** argv)
23 {
24 #if defined(_MSC_VER) && _MSC_VER < 1900
25     _set_output_format(_TWO_DIGIT_EXPONENT);
26 #endif
27 
28     try {
29         double Tkelvin = 1200.;
30         IdealSolnGasVPSS issp("IdealSolidSolnPhaseExample.yaml",
31                               "VpssSolidSolutionExample");
32         issp.setState_TPX(Tkelvin, OneAtm,
33                           "C2H2-graph:0.3, C-graph:0.6, H2-solute:0.1");
34         double hm = issp.enthalpy_mole();
35         printf("molar enthalpy   = %13.5g J kg-1\n", hm);
36 
37         double um = issp.intEnergy_mole();
38         printf("molar intEnergy  = %13.5g J kg-1\n", um);
39 
40 
41         double sm = issp.entropy_mole();
42         printf("molar entropy    = %13.5g J kg-1 K-1\n", sm);
43 
44         double gm = issp.gibbs_mole();
45         printf("molar gibbs      = %13.5g J kg-1\n", gm);
46 
47         double cpm = issp.cp_mole();
48         printf("molar Cp         = %13.5g J kg-1 K-1\n", cpm);
49 
50         double dens = issp.density();
51         printf("mixture density = %13.5g kg m-3\n", dens);
52 
53         double mdens = issp.molarDensity();
54         printf("molar density = %13.5g kmol m-3\n", mdens);
55 
56         double mmw = issp.meanMolecularWeight();
57         printf("mean molecular weight = %13.5g kg kmol-1\n", mmw);
58 
59         size_t n = issp.nSpecies();
60 
61         double HiSS[20], muiSS[20],SiSS[20], CpiSS[20], VoliSS[20];
62         double RT = GasConstant * Tkelvin;
63         issp.getStandardChemPotentials(muiSS);
64         issp.getEnthalpy_RT(HiSS);
65         issp.getEntropy_R(SiSS);
66         issp.getCp_R(CpiSS);
67         issp.getStandardVolumes(VoliSS);
68 
69 
70         for (size_t i = 0; i < n; i++) {
71             HiSS[i] *= RT;
72             SiSS[i] *= RT;
73             CpiSS[i] *= GasConstant;
74         }
75 
76         printf(" Printout of standard state properties\n");
77         printf("            Name         mu_i       H_i_SS   "
78                "    S_i_SS      Cp_i_SS     Vol_i_SS\n");
79         for (size_t i = 0; i < n; i++) {
80             string sn = issp.speciesName(i);
81             printf(" %15s %12.5g %12.5g %12.5g %12.5g %12.5g\n", sn.c_str(), muiSS[i],
82                    HiSS[i], SiSS[i], CpiSS[i], VoliSS[i]);
83         }
84 
85 
86 
87         double HiPM[20], mui[20],SiPM[20], CpiPM[20], VoliPM[20];
88 
89         issp.getChemPotentials(mui);
90         issp.getPartialMolarEnthalpies(HiPM);
91         issp.getPartialMolarEntropies(SiPM);
92         issp.getPartialMolarCp(CpiPM);
93         issp.getPartialMolarVolumes(VoliPM);
94         printf(" Printout of Partial molar properties\n");
95         printf("            Name         mu_i       H_i_PM   "
96                "    S_i_PM      Cp_i_PM     Vol_i_PM\n");
97         for (size_t i = 0; i < n; i++) {
98             string sn = issp.speciesName(i);
99             printf(" %15s %12.5g %12.5g %12.5g %12.5g %12.5g\n", sn.c_str(), mui[i],
100                    HiPM[i], SiPM[i], CpiPM[i], VoliPM[i]);
101         }
102     } catch (CanteraError& err) {
103         std::cout << err.what() << std::endl;
104         return -1;
105     }
106 
107     return 0;
108 }
109 /***********************************************************/
110