added reportCSV method to ThermoPhase class and all other derived classes that currently contain the report method. reportCSV will output phase data to a text file and a comma separated file that are passed in.
This commit is contained in:
parent
a6042af1e7
commit
58719349cb
12 changed files with 626 additions and 2 deletions
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
#include "GibbsExcessVPSSTP.h"
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
|
|
@ -406,6 +407,101 @@ namespace Cantera {
|
|||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
void GibbsExcessVPSSTP::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
|
||||
|
||||
csvFile.precision(6);
|
||||
int tabS = 20;
|
||||
int tabM = 30;
|
||||
int tabL = 40;
|
||||
try {
|
||||
if (name() != "") {
|
||||
textFile << "\n"+name()+"\n\n";
|
||||
csvFile << "\n\n\n";
|
||||
}
|
||||
textFile << setw(tabM) << "temperature (K)\n";
|
||||
csvFile << setw(tabM) << temperature() << ",\n";
|
||||
textFile << setw(tabM) << "pressure (Pa)\n";
|
||||
csvFile << setw(tabM) << pressure() << ",\n";
|
||||
textFile << setw(tabM) << "density (kg/m^3)\n";
|
||||
csvFile << setw(tabM) << density() << ",\n";
|
||||
textFile << setw(tabM) << "mean mol. weight (amu)\n";
|
||||
csvFile << setw(tabM) << meanMolecularWeight() << ",\n";
|
||||
textFile << setw(tabM) << "potential (V)\n";
|
||||
csvFile << setw(tabM) << electricPotential() << ",\n";
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << endl;
|
||||
csvFile << endl;
|
||||
textFile << setw(tabM) << "enthalpy (J/kg)" << "," << setw(tabM) << "enthalpy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << enthalpy_mass() << "," << setw(tabM) << enthalpy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "internal E (J/kg)" << "," << setw(tabM) << "internal E (J/kmol)\n";
|
||||
csvFile << setw(tabM) << intEnergy_mass() << "," << setw(tabM) << intEnergy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "entropy (J/kg)" << "," << setw(tabM) << "entropy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << entropy_mass() << "," << setw(tabM) << entropy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "Gibbs (J/kg)" << "," << setw(tabM) << "Gibbs (J/kmol)\n";
|
||||
csvFile << setw(tabM) << gibbs_mass() << "," << setw(tabM) << gibbs_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_p (J/K/kg)" << "," << setw(tabL) << "heat capacity c_p (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cp_mass() << "," << setw(tabL) << cp_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_v (J/K/kg)" << "," << setw(tabL) << "heat capacity c_v (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cv_mass() << "," << setw(tabL) << cv_mole() << ",\n";
|
||||
}
|
||||
/*
|
||||
// NOT USED!!!!!
|
||||
int kk = nSpecies();
|
||||
array_fp x(kk);
|
||||
array_fp y(kk);
|
||||
array_fp mu(kk);
|
||||
getMoleFractions(&x[0]);
|
||||
getMassFractions(&y[0]);
|
||||
getChemPotentials(&mu[0]);
|
||||
doublereal rt = GasConstant * temperature();
|
||||
int k;
|
||||
|
||||
// ThermoPhase original above...changed to below comments in GibbsExcessVPSSTP::report()
|
||||
// int kk = nSpecies();
|
||||
// array_fp x(kk);
|
||||
// array_fp molal(kk);
|
||||
// array_fp mu(kk);
|
||||
// array_fp muss(kk);
|
||||
// array_fp acMolal(kk);
|
||||
// array_fp actMolal(kk);
|
||||
// getMoleFractions(&x[0]);
|
||||
//
|
||||
// getChemPotentials(&mu[0]);
|
||||
// getStandardChemPotentials(&muss[0]);
|
||||
// getActivities(&actMolal[0]);
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << "\n" << setw(40) << "X" << "," << setw(tabS) << "Y" << "," << setw(tabS) << "Chem. Pot. / RT\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
if (x[k] > SmallNumber) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << "," << setw(tabS) << mu[k]/rt << ",\n";
|
||||
}
|
||||
else {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
textFile << "\n" << setw(40) << "X" << "," << setw(tabS) << "Y\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -541,6 +541,18 @@ namespace Cantera {
|
|||
*/
|
||||
virtual std::string report(bool show_thermo = true) const;
|
||||
|
||||
//! returns a summary of the state of the phase to specified
|
||||
//! comma separated files
|
||||
/*!
|
||||
* @param textFile ofstream file to print textual variable names that
|
||||
* will correspod to data in comma separated file (csv).
|
||||
* @param csvFile ofstream file to print comma separated data for
|
||||
* the phase
|
||||
* @param show_thermo If true, extra information is printed out
|
||||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual void reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo = true) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "mix_defs.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -1765,6 +1766,101 @@ namespace Cantera {
|
|||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
void IonsFromNeutralVPSSTP::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
|
||||
|
||||
csvFile.precision(6);
|
||||
int tabS = 20;
|
||||
int tabM = 30;
|
||||
int tabL = 40;
|
||||
try {
|
||||
if (name() != "") {
|
||||
textFile << "\n"+name()+"\n\n";
|
||||
csvFile << "\n\n\n";
|
||||
}
|
||||
textFile << setw(tabM) << "temperature (K)\n";
|
||||
csvFile << setw(tabM) << temperature() << ",\n";
|
||||
textFile << setw(tabM) << "pressure (Pa)\n";
|
||||
csvFile << setw(tabM) << pressure() << ",\n";
|
||||
textFile << setw(tabM) << "density (kg/m^3)\n";
|
||||
csvFile << setw(tabM) << density() << ",\n";
|
||||
textFile << setw(tabM) << "mean mol. weight (amu)\n";
|
||||
csvFile << setw(tabM) << meanMolecularWeight() << ",\n";
|
||||
textFile << setw(tabM) << "potential (V)\n";
|
||||
csvFile << setw(tabM) << electricPotential() << ",\n";
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << endl;
|
||||
csvFile << endl;
|
||||
textFile << setw(tabM) << "enthalpy (J/kg)" << "," << setw(tabM) << "enthalpy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << enthalpy_mass() << "," << setw(tabM) << enthalpy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "internal E (J/kg)" << "," << setw(tabM) << "internal E (J/kmol)\n";
|
||||
csvFile << setw(tabM) << intEnergy_mass() << "," << setw(tabM) << intEnergy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "entropy (J/kg)" << "," << setw(tabM) << "entropy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << entropy_mass() << "," << setw(tabM) << entropy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "Gibbs (J/kg)" << "," << setw(tabM) << "Gibbs (J/kmol)\n";
|
||||
csvFile << setw(tabM) << gibbs_mass() << "," << setw(tabM) << gibbs_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_p (J/K/kg)" << "," << setw(tabL) << "heat capacity c_p (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cp_mass() << "," << setw(tabL) << cp_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_v (J/K/kg)" << "," << setw(tabL) << "heat capacity c_v (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cv_mass() << "," << setw(tabL) << cv_mole() << ",\n";
|
||||
}
|
||||
/*
|
||||
// NOT USED!!!!!
|
||||
int kk = nSpecies();
|
||||
array_fp x(kk);
|
||||
array_fp y(kk);
|
||||
array_fp mu(kk);
|
||||
getMoleFractions(&x[0]);
|
||||
getMassFractions(&y[0]);
|
||||
getChemPotentials(&mu[0]);
|
||||
doublereal rt = GasConstant * temperature();
|
||||
int k;
|
||||
|
||||
// ThermoPhase original above...changed to below comments in GibbsExcessVPSSTP::report()
|
||||
// int kk = nSpecies();
|
||||
// array_fp x(kk);
|
||||
// array_fp molal(kk);
|
||||
// array_fp mu(kk);
|
||||
// array_fp muss(kk);
|
||||
// array_fp acMolal(kk);
|
||||
// array_fp actMolal(kk);
|
||||
// getMoleFractions(&x[0]);
|
||||
//
|
||||
// getChemPotentials(&mu[0]);
|
||||
// getStandardChemPotentials(&muss[0]);
|
||||
// getActivities(&actMolal[0]);
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << "\n" << setw(40) << "X" << "," << setw(tabS) << "Y" << "," << setw(tabS) << "Chem. Pot. / RT\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
if (x[k] > SmallNumber) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << "," << setw(tabS) << mu[k]/rt << ",\n";
|
||||
}
|
||||
else {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
textFile << "\n" << setw(40) << "X" << "," << setw(tabS) << "Y\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -720,6 +720,17 @@ namespace Cantera {
|
|||
*/
|
||||
virtual std::string report(bool show_thermo = true) const;
|
||||
|
||||
//! returns a summary of the state of the phase to specified
|
||||
//! comma separated files
|
||||
/*!
|
||||
* @param textFile ofstream file to print textual variable names that
|
||||
* will correspod to data in comma separated file (csv).
|
||||
* @param csvFile ofstream file to print comma separated data for
|
||||
* the phase
|
||||
* @param show_thermo If true, extra information is printed out
|
||||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual void reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo = true) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "MargulesVPSSTP.h"
|
||||
#include "ThermoFactory.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
@ -1171,6 +1171,101 @@ namespace Cantera {
|
|||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
void MargulesVPSSTP::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
|
||||
|
||||
csvFile.precision(6);
|
||||
int tabS = 20;
|
||||
int tabM = 30;
|
||||
int tabL = 40;
|
||||
try {
|
||||
if (name() != "") {
|
||||
textFile << "\n"+name()+"\n\n";
|
||||
csvFile << "\n\n\n";
|
||||
}
|
||||
textFile << setw(tabM) << "temperature (K)\n";
|
||||
csvFile << setw(tabM) << temperature() << ",\n";
|
||||
textFile << setw(tabM) << "pressure (Pa)\n";
|
||||
csvFile << setw(tabM) << pressure() << ",\n";
|
||||
textFile << setw(tabM) << "density (kg/m^3)\n";
|
||||
csvFile << setw(tabM) << density() << ",\n";
|
||||
textFile << setw(tabM) << "mean mol. weight (amu)\n";
|
||||
csvFile << setw(tabM) << meanMolecularWeight() << ",\n";
|
||||
textFile << setw(tabM) << "potential (V)\n";
|
||||
csvFile << setw(tabM) << electricPotential() << ",\n";
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << endl;
|
||||
csvFile << endl;
|
||||
textFile << setw(tabM) << "enthalpy (J/kg)" << "," << setw(tabM) << "enthalpy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << enthalpy_mass() << "," << setw(tabM) << enthalpy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "internal E (J/kg)" << "," << setw(tabM) << "internal E (J/kmol)\n";
|
||||
csvFile << setw(tabM) << intEnergy_mass() << "," << setw(tabM) << intEnergy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "entropy (J/kg)" << "," << setw(tabM) << "entropy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << entropy_mass() << "," << setw(tabM) << entropy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "Gibbs (J/kg)" << "," << setw(tabM) << "Gibbs (J/kmol)\n";
|
||||
csvFile << setw(tabM) << gibbs_mass() << "," << setw(tabM) << gibbs_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_p (J/K/kg)" << "," << setw(tabL) << "heat capacity c_p (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cp_mass() << "," << setw(tabL) << cp_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_v (J/K/kg)" << "," << setw(tabL) << "heat capacity c_v (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cv_mass() << "," << setw(tabL) << cv_mole() << ",\n";
|
||||
}
|
||||
/*
|
||||
// NOT USED!!!!!
|
||||
int kk = nSpecies();
|
||||
array_fp x(kk);
|
||||
array_fp y(kk);
|
||||
array_fp mu(kk);
|
||||
getMoleFractions(&x[0]);
|
||||
getMassFractions(&y[0]);
|
||||
getChemPotentials(&mu[0]);
|
||||
doublereal rt = GasConstant * temperature();
|
||||
int k;
|
||||
|
||||
// ThermoPhase original above...changed to below comments in GibbsExcessVPSSTP::report()
|
||||
// int kk = nSpecies();
|
||||
// array_fp x(kk);
|
||||
// array_fp molal(kk);
|
||||
// array_fp mu(kk);
|
||||
// array_fp muss(kk);
|
||||
// array_fp acMolal(kk);
|
||||
// array_fp actMolal(kk);
|
||||
// getMoleFractions(&x[0]);
|
||||
//
|
||||
// getChemPotentials(&mu[0]);
|
||||
// getStandardChemPotentials(&muss[0]);
|
||||
// getActivities(&actMolal[0]);
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << "\n" << setw(40) << "X" << "," << setw(tabS) << "Y" << "," << setw(tabS) << "Chem. Pot. / RT\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
if (x[k] > SmallNumber) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << "," << setw(tabS) << mu[k]/rt << ",\n";
|
||||
}
|
||||
else {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
textFile << "\n" << setw(40) << "X" << "," << setw(tabS) << "Y\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(40) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -738,6 +738,17 @@ namespace Cantera {
|
|||
*/
|
||||
virtual std::string report(bool show_thermo = true) const;
|
||||
|
||||
//! returns a summary of the state of the phase to specified
|
||||
//! comma separated files
|
||||
/*!
|
||||
* @param textFile ofstream file to print textual variable names that
|
||||
* will correspod to data in comma separated file (csv).
|
||||
* @param csvFile ofstream file to print comma separated data for
|
||||
* the phase
|
||||
* @param show_thermo If true, extra information is printed out
|
||||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual void reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo = true) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
|
||||
#include "MolalityVPSSTP.h"
|
||||
#include <iomanip>
|
||||
using namespace std;
|
||||
|
||||
namespace Cantera {
|
||||
|
|
@ -910,6 +911,99 @@ namespace Cantera {
|
|||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
void MolalityVPSSTP::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
|
||||
|
||||
csvFile.precision(6);
|
||||
int tabS = 20;
|
||||
int tabM = 30;
|
||||
int tabL = 40;
|
||||
try {
|
||||
if (name() != "") {
|
||||
textFile << "\n"+name()+"\n\n";
|
||||
csvFile << "\n\n\n";
|
||||
}
|
||||
textFile << setw(tabM) << "temperature (K)\n";
|
||||
csvFile << setw(tabM) << temperature() << ",\n";
|
||||
textFile << setw(tabM) << "pressure (Pa)\n";
|
||||
csvFile << setw(tabM) << pressure() << ",\n";
|
||||
textFile << setw(tabM) << "density (kg/m^3)\n";
|
||||
csvFile << setw(tabM) << density() << ",\n";
|
||||
textFile << setw(tabM) << "mean mol. weight (amu)\n";
|
||||
csvFile << setw(tabM) << meanMolecularWeight() << ",\n";
|
||||
textFile << setw(tabM) << "potential (V)\n";
|
||||
csvFile << setw(tabM) << electricPotential() << ",\n";
|
||||
|
||||
int kk = nSpecies();
|
||||
array_fp x(kk);
|
||||
array_fp molal(kk);
|
||||
array_fp mu(kk);
|
||||
array_fp muss(kk);
|
||||
array_fp acMolal(kk);
|
||||
array_fp actMolal(kk);
|
||||
getMoleFractions(&x[0]);
|
||||
getMolalities(&molal[0]);
|
||||
getChemPotentials(&mu[0]);
|
||||
getStandardChemPotentials(&muss[0]);
|
||||
getMolalityActivityCoefficients(&acMolal[0]);
|
||||
getActivities(&actMolal[0]);
|
||||
|
||||
int iHp = speciesIndex("H+");
|
||||
if (iHp >= 0) {
|
||||
double pH = -log(actMolal[iHp]) / log(10.0);
|
||||
textFile << setw(tabM) << "pH\n";
|
||||
csvFile << setw(tabM) << pH << ",\n";
|
||||
}
|
||||
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << endl;
|
||||
csvFile << endl;
|
||||
textFile << setw(tabM) << "enthalpy (J/kg)" << "," << setw(tabM) << "enthalpy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << enthalpy_mass() << "," << setw(tabM) << enthalpy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "internal E (J/kg)" << "," << setw(tabM) << "internal E (J/kmol)\n";
|
||||
csvFile << setw(tabM) << intEnergy_mass() << "," << setw(tabM) << intEnergy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "entropy (J/kg)" << "," << setw(tabM) << "entropy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << entropy_mass() << "," << setw(tabM) << entropy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "Gibbs (J/kg)" << "," << setw(tabM) << "Gibbs (J/kmol)\n";
|
||||
csvFile << setw(tabM) << gibbs_mass() << "," << setw(tabM) << gibbs_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_p (J/K/kg)" << "," << setw(tabL) << "heat capacity c_p (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cp_mass() << "," << setw(tabL) << cp_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_v (J/K/kg)" << "," << setw(tabL) << "heat capacity c_v (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cv_mass() << "," << setw(tabL) << cv_mole() << ",\n";
|
||||
}
|
||||
|
||||
int k;
|
||||
if (show_thermo) {
|
||||
textFile << "\n" << setw(2*tabS) << "X" << "," << setw(tabS) << "Molalities" << "," << setw(tabM) << "Chem. Pot. (J/kmol)" << "," << setw(tabM) << "Chem Pot SS (J/kmol)" << "," << setw(tabS) << "ActCoeffMolal\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
if (x[k] > SmallNumber) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << molal[k] << "," << setw(tabM) << mu[k] << "," << setw(tabM) << muss[k] << "," << setw(tabM) << acMolal[k] << ",\n";
|
||||
}
|
||||
else {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << molal[k] << "," << setw(tabM) << 0 << "," << setw(tabM) << muss[k] << "," << setw(tabM) << acMolal[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
textFile << "\n" << setw(2*tabS) << "X" << "," << setw(tabS) << "Molalities\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << molal[k] << ",\n";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -800,6 +800,18 @@ namespace Cantera {
|
|||
*/
|
||||
virtual std::string report(bool show_thermo = true) const;
|
||||
|
||||
//! returns a summary of the state of the phase to specified
|
||||
//! comma separated files
|
||||
/*!
|
||||
* @param textFile ofstream file to print textual variable names that
|
||||
* will correspod to data in comma separated file (csv).
|
||||
* @param csvFile ofstream file to print comma separated data for
|
||||
* the phase
|
||||
* @param show_thermo If true, extra information is printed out
|
||||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual void reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo = true) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Get the array of unscaled non-dimensional molality based
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "../../../ext/tpx/utils.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
|
|
@ -427,8 +428,97 @@ namespace Cantera {
|
|||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
void PureFluidPhase::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
|
||||
|
||||
csvFile.precision(6);
|
||||
int tabS = 20;
|
||||
int tabM = 30;
|
||||
int tabL = 40;
|
||||
try {
|
||||
if (name() != "") {
|
||||
textFile << "\n"+name()+"\n\n";
|
||||
csvFile << "\n\n\n";
|
||||
}
|
||||
textFile << setw(tabM) << "temperature (K)\n";
|
||||
csvFile << setw(tabM) << temperature() << ",\n";
|
||||
textFile << setw(tabM) << "pressure (Pa)\n";
|
||||
csvFile << setw(tabM) << pressure() << ",\n";
|
||||
textFile << setw(tabM) << "density (kg/m^3)\n";
|
||||
csvFile << setw(tabM) << density() << ",\n";
|
||||
textFile << setw(tabM) << "mean mol. weight (amu)\n";
|
||||
csvFile << setw(tabM) << meanMolecularWeight() << ",\n";
|
||||
|
||||
if (eosType() == cPureFluid) {
|
||||
double xx = ((PureFluidPhase *) (this))->vaporFraction();
|
||||
textFile << setw(tabM) << "vapor fraction\n";
|
||||
csvFile << setw(tabM) << xx << ",\n";
|
||||
}
|
||||
|
||||
doublereal phi = electricPotential();
|
||||
if (phi != 0.0) {
|
||||
textFile << setw(tabM) << "potential (V)\n";
|
||||
csvFile << setw(tabM) << phi << ",\n";
|
||||
}
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << endl;
|
||||
csvFile << endl;
|
||||
textFile << setw(tabM) << "enthalpy (J/kg)" << "," << setw(tabM) << "enthalpy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << enthalpy_mass() << "," << setw(tabM) << enthalpy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "internal E (J/kg)" << "," << setw(tabM) << "internal E (J/kmol)\n";
|
||||
csvFile << setw(tabM) << intEnergy_mass() << "," << setw(tabM) << intEnergy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "entropy (J/kg)" << "," << setw(tabM) << "entropy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << entropy_mass() << "," << setw(tabM) << entropy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "Gibbs (J/kg)" << "," << setw(tabM) << "Gibbs (J/kmol)\n";
|
||||
csvFile << setw(tabM) << gibbs_mass() << "," << setw(tabM) << gibbs_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_p (J/K/kg)" << "," << setw(tabL) << "heat capacity c_p (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cp_mass() << "," << setw(tabL) << cp_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_v (J/K/kg)" << "," << setw(tabL) << "heat capacity c_v (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cv_mass() << "," << setw(tabL) << cv_mole() << ",\n";
|
||||
}
|
||||
|
||||
int kk = nSpecies();
|
||||
array_fp x(kk);
|
||||
array_fp y(kk);
|
||||
array_fp mu(kk);
|
||||
getMoleFractions(&x[0]);
|
||||
getMassFractions(&y[0]);
|
||||
getChemPotentials(&mu[0]);
|
||||
doublereal rt = GasConstant * temperature();
|
||||
int k;
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << "\n" << setw(2*tabS) << "X" << "," << setw(tabS) << "Y" << "," << setw(tabS) << "Chem. Pot. / RT\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
if (x[k] > SmallNumber) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << y[k] << "," << setw(tabS) << mu[k]/rt << ",\n";
|
||||
}
|
||||
else {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
textFile << "\n" << setw(2*tabS) << "X" << "," << setw(tabS) << "Y\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // WITH_PURE_FLUIDS
|
||||
|
|
|
|||
|
|
@ -303,6 +303,18 @@ namespace Cantera {
|
|||
*/
|
||||
virtual std::string report(bool show_thermo = true) const;
|
||||
|
||||
//! returns a summary of the state of the phase to specified
|
||||
//! comma separated files
|
||||
/*!
|
||||
* @param textFile ofstream file to print textual variable names that
|
||||
* will correspod to data in comma separated file (csv).
|
||||
* @param csvFile ofstream file to print comma separated data for
|
||||
* the phase
|
||||
* @param show_thermo If true, extra information is printed out
|
||||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual void reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo = true) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Main call to the tpx level to set the state of the system
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#endif
|
||||
|
||||
#include "ThermoPhase.h"
|
||||
#include <iomanip>
|
||||
|
||||
//@{
|
||||
#ifndef MAX
|
||||
|
|
@ -1135,5 +1136,88 @@ namespace Cantera {
|
|||
return s;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format a summary of the mixture state for output.
|
||||
*/
|
||||
void ThermoPhase::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
|
||||
|
||||
csvFile.precision(6);
|
||||
int tabS = 20;
|
||||
int tabM = 30;
|
||||
int tabL = 40;
|
||||
try {
|
||||
if (name() != "") {
|
||||
textFile << "\n"+name()+"\n\n";
|
||||
csvFile << "\n\n\n";
|
||||
}
|
||||
textFile << setw(tabM) << "temperature (K)\n";
|
||||
csvFile << setw(tabM) << temperature() << ",\n";
|
||||
textFile << setw(tabM) << "pressure (Pa)\n";
|
||||
csvFile << setw(tabM) << pressure() << ",\n";
|
||||
textFile << setw(tabM) << "density (kg/m^3)\n";
|
||||
csvFile << setw(tabM) << density() << ",\n";
|
||||
textFile << setw(tabM) << "mean mol. weight (amu)\n";
|
||||
csvFile << setw(tabM) << meanMolecularWeight() << ",\n";
|
||||
|
||||
doublereal phi = electricPotential();
|
||||
if (phi != 0.0) {
|
||||
textFile << setw(tabM) << "potential (V)\n";
|
||||
csvFile << setw(tabM) << phi << ",\n";
|
||||
}
|
||||
if (show_thermo) {
|
||||
textFile << endl;
|
||||
csvFile << endl;
|
||||
textFile << setw(tabM) << "enthalpy (J/kg)" << "," << setw(tabM) << "enthalpy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << enthalpy_mass() << "," << setw(tabM) << enthalpy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "internal E (J/kg)" << "," << setw(tabM) << "internal E (J/kmol)\n";
|
||||
csvFile << setw(tabM) << intEnergy_mass() << "," << setw(tabM) << intEnergy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "entropy (J/kg)" << "," << setw(tabM) << "entropy (J/kmol)\n";
|
||||
csvFile << setw(tabM) << entropy_mass() << "," << setw(tabM) << entropy_mole() << ",\n";
|
||||
textFile << setw(tabM) << "Gibbs (J/kg)" << "," << setw(tabM) << "Gibbs (J/kmol)\n";
|
||||
csvFile << setw(tabM) << gibbs_mass() << "," << setw(tabM) << gibbs_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_p (J/K/kg)" << "," << setw(tabL) << "heat capacity c_p (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cp_mass() << "," << setw(tabL) << cp_mole() << ",\n";
|
||||
textFile << setw(tabL) << "heat capacity c_v (J/K/kg)" << "," << setw(tabL) << "heat capacity c_v (J/K/kmol)\n";
|
||||
csvFile << setw(tabL) << cv_mass() << "," << setw(tabL) << cv_mole() << ",\n";
|
||||
}
|
||||
|
||||
int kk = nSpecies();
|
||||
array_fp x(kk);
|
||||
array_fp y(kk);
|
||||
array_fp mu(kk);
|
||||
getMoleFractions(&x[0]);
|
||||
getMassFractions(&y[0]);
|
||||
getChemPotentials(&mu[0]);
|
||||
doublereal rt = GasConstant * temperature();
|
||||
int k;
|
||||
|
||||
if (show_thermo) {
|
||||
textFile << "\n" << setw(2*tabS) << "X" << "," << setw(tabS) << "Y" << "," << setw(tabS) << "Chem. Pot. / RT\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
if (x[k] > SmallNumber) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << y[k] << "," << setw(tabS) << mu[k]/rt << ",\n";
|
||||
}
|
||||
else {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
textFile << "\n" << setw(2*tabS) << "X" << "," << setw(tabS) << "Y\n";
|
||||
csvFile << "\n\n";
|
||||
for (k = 0; k < kk; k++) {
|
||||
textFile << setw(tabS) << speciesName(k) << ",\n";
|
||||
csvFile << setw(2*tabS) << x[k] << "," << setw(tabS) << y[k] << ",\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2111,6 +2111,17 @@ namespace Cantera {
|
|||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual std::string report(bool show_thermo = true) const;
|
||||
|
||||
//! returns a summary of the state of the phase to a comma separated file
|
||||
/*!
|
||||
* @param textFile ofstream file to print textual variable names that
|
||||
* will correspod to data in comma separated file (csv).
|
||||
* @param csvFile ofstream file to print comma separated data for
|
||||
* the phase
|
||||
* @param show_thermo If true, extra information is printed out
|
||||
* about the thermodynamic state of the system.
|
||||
*/
|
||||
virtual void reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo = true) const;
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue