Changed output format of reportCSV...still need to implement it properly in MolalityVPSSTP and PureFluidPhase

This commit is contained in:
Christopher Lueth 2010-04-02 23:11:47 +00:00
parent 35d5677ab6
commit 1f6fe73076
12 changed files with 120 additions and 659 deletions

View file

@ -329,179 +329,6 @@ namespace Cantera {
m_pp.resize(m_kk);
}
/*
* Format a summary of the mixture state for output.
*/
std::string GibbsExcessVPSSTP::report(bool show_thermo) const {
char p[800];
string s = "";
try {
if (name() != "") {
sprintf(p, " \n %s:\n", name().c_str());
s += p;
}
sprintf(p, " \n temperature %12.6g K\n", temperature());
s += p;
sprintf(p, " pressure %12.6g Pa\n", pressure());
s += p;
sprintf(p, " density %12.6g kg/m^3\n", density());
s += p;
sprintf(p, " mean mol. weight %12.6g amu\n", meanMolecularWeight());
s += p;
doublereal phi = electricPotential();
sprintf(p, " potential %12.6g V\n", phi);
s += p;
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) {
sprintf(p, " \n");
s += p;
sprintf(p, " 1 kg 1 kmol\n");
s += p;
sprintf(p, " ----------- ------------\n");
s += p;
sprintf(p, " enthalpy %12.6g %12.4g J\n",
enthalpy_mass(), enthalpy_mole());
s += p;
sprintf(p, " internal energy %12.6g %12.4g J\n",
intEnergy_mass(), intEnergy_mole());
s += p;
sprintf(p, " entropy %12.6g %12.4g J/K\n",
entropy_mass(), entropy_mole());
s += p;
sprintf(p, " Gibbs function %12.6g %12.4g J\n",
gibbs_mass(), gibbs_mole());
s += p;
sprintf(p, " heat capacity c_p %12.6g %12.4g J/K\n",
cp_mass(), cp_mole());
s += p;
try {
sprintf(p, " heat capacity c_v %12.6g %12.4g J/K\n",
cv_mass(), cv_mole());
s += p;
}
catch(CanteraError) {
sprintf(p, " heat capacity c_v <not implemented> \n");
s += p;
}
}
} catch (CanteraError) {
;
}
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) {
;
}
}
}

View file

@ -534,25 +534,6 @@ namespace Cantera {
*/
virtual void initThermo();
//! returns a summary of the state of the phase as a string
/*!
* @param show_thermo If true, extra information is printed out
* 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 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:

View file

@ -1687,180 +1687,6 @@ namespace Cantera {
}
/**
* Format a summary of the mixture state for output.
*/
std::string IonsFromNeutralVPSSTP::report(bool show_thermo) const {
char p[800];
string s = "";
try {
if (name() != "") {
sprintf(p, " \n %s:\n", name().c_str());
s += p;
}
sprintf(p, " \n temperature %12.6g K\n", temperature());
s += p;
sprintf(p, " pressure %12.6g Pa\n", pressure());
s += p;
sprintf(p, " density %12.6g kg/m^3\n", density());
s += p;
sprintf(p, " mean mol. weight %12.6g amu\n", meanMolecularWeight());
s += p;
doublereal phi = electricPotential();
sprintf(p, " potential %12.6g V\n", phi);
s += p;
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) {
sprintf(p, " \n");
s += p;
sprintf(p, " 1 kg 1 kmol\n");
s += p;
sprintf(p, " ----------- ------------\n");
s += p;
sprintf(p, " enthalpy %12.6g %12.4g J\n",
enthalpy_mass(), enthalpy_mole());
s += p;
sprintf(p, " internal energy %12.6g %12.4g J\n",
intEnergy_mass(), intEnergy_mole());
s += p;
sprintf(p, " entropy %12.6g %12.4g J/K\n",
entropy_mass(), entropy_mole());
s += p;
sprintf(p, " Gibbs function %12.6g %12.4g J\n",
gibbs_mass(), gibbs_mole());
s += p;
sprintf(p, " heat capacity c_p %12.6g %12.4g J/K\n",
cp_mass(), cp_mole());
s += p;
try {
sprintf(p, " heat capacity c_v %12.6g %12.4g J/K\n",
cv_mass(), cv_mole());
s += p;
}
catch(CanteraError) {
sprintf(p, " heat capacity c_v <not implemented> \n");
s += p;
}
}
} catch (CanteraError) {
;
}
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) {
;
}
}
}

View file

@ -712,25 +712,6 @@ namespace Cantera {
*/
void initThermoXML(XML_Node& phaseNode, std::string id);
//! returns a summary of the state of the phase as a string
/*!
* @param show_thermo If true, extra information is printed out
* 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 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:

View file

@ -1091,181 +1091,6 @@ namespace Cantera {
}
}
/**
* Format a summary of the mixture state for output.
*/
std::string MargulesVPSSTP::report(bool show_thermo) const {
char p[800];
string s = "";
try {
if (name() != "") {
sprintf(p, " \n %s:\n", name().c_str());
s += p;
}
sprintf(p, " \n temperature %12.6g K\n", temperature());
s += p;
sprintf(p, " pressure %12.6g Pa\n", pressure());
s += p;
sprintf(p, " density %12.6g kg/m^3\n", density());
s += p;
sprintf(p, " mean mol. weight %12.6g amu\n", meanMolecularWeight());
s += p;
doublereal phi = electricPotential();
sprintf(p, " potential %12.6g V\n", phi);
s += p;
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) {
sprintf(p, " \n");
s += p;
sprintf(p, " 1 kg 1 kmol\n");
s += p;
sprintf(p, " ----------- ------------\n");
s += p;
sprintf(p, " enthalpy %12.6g %12.4g J\n",
enthalpy_mass(), enthalpy_mole());
s += p;
sprintf(p, " internal energy %12.6g %12.4g J\n",
intEnergy_mass(), intEnergy_mole());
s += p;
sprintf(p, " entropy %12.6g %12.4g J/K\n",
entropy_mass(), entropy_mole());
s += p;
sprintf(p, " Gibbs function %12.6g %12.4g J\n",
gibbs_mass(), gibbs_mole());
s += p;
sprintf(p, " heat capacity c_p %12.6g %12.4g J/K\n",
cp_mass(), cp_mole());
s += p;
try {
sprintf(p, " heat capacity c_v %12.6g %12.4g J/K\n",
cv_mass(), cv_mole());
s += p;
}
catch(CanteraError) {
sprintf(p, " heat capacity c_v <not implemented> \n");
s += p;
}
}
} catch (CanteraError) {
;
}
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) {
;
}
}
}

View file

@ -729,26 +729,6 @@ namespace Cantera {
*/
void initThermoXML(XML_Node& phaseNode, std::string id);
//! returns a summary of the state of the phase as a string
/*!
* @param show_thermo If true, extra information is printed out
* 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 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:

View file

@ -914,8 +914,9 @@ namespace Cantera {
/*
* Format a summary of the mixture state for output.
*/
void MolalityVPSSTP::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
void MolalityVPSSTP::reportCSV(std::ofstream& csvFile) const {
/*
csvFile.precision(6);
int tabS = 20;
int tabM = 30;
@ -1003,6 +1004,7 @@ namespace Cantera {
catch (CanteraError) {
;
}
*/
}
}

View file

@ -803,14 +803,10 @@ namespace Cantera {
//! 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;
virtual void reportCSV(std::ofstream& csvFile) const;
protected:

View file

@ -432,8 +432,9 @@ namespace Cantera {
/*
* Format a summary of the mixture state for output.
*/
void PureFluidPhase::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
void PureFluidPhase::reportCSV(std::ofstream& csvFile) const {
/*
csvFile.precision(6);
int tabS = 20;
int tabM = 30;
@ -517,6 +518,7 @@ namespace Cantera {
catch (CanteraError) {
;
}
*/
}
}

View file

@ -306,14 +306,10 @@ namespace Cantera {
//! 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;
virtual void reportCSV(std::ofstream& csvFile) const;
protected:

View file

@ -1139,78 +1139,127 @@ namespace Cantera {
/*
* Format a summary of the mixture state for output.
*/
void ThermoPhase::reportCSV(std::ofstream& textFile, std::ofstream& csvFile, bool show_thermo) const {
void ThermoPhase::reportCSV(std::ofstream& csvFile) const {
csvFile.precision(6);
int tabS = 20;
csvFile.precision(3);
int tabS = 15;
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";
csvFile << "\n"+name()+"\n\n";
}
csvFile << setw(tabL) << "temperature (K) =" << setw(tabS) << temperature() << endl;
csvFile << setw(tabL) << "pressure (Pa) =" << setw(tabS) << pressure() << endl;
csvFile << setw(tabL) << "density (kg/m^3) =" << setw(tabS) << density() << endl;
csvFile << setw(tabL) << "mean mol. weight (amu) =" << setw(tabS) << meanMolecularWeight() << endl;
csvFile << setw(tabL) << "potential (V) =" << setw(tabS) << electricPotential() << endl;
csvFile << endl;
csvFile << setw(tabL) << "enthalpy (J/kg) = " << setw(tabS) << enthalpy_mass() << setw(tabL) << "enthalpy (J/kmol) = " << setw(tabS) << enthalpy_mole() << endl;
csvFile << setw(tabL) << "internal E (J/kg) = " << setw(tabS) << intEnergy_mass() << setw(tabL) << "internal E (J/kmol) = " << setw(tabS) << intEnergy_mole() << endl;
csvFile << setw(tabL) << "entropy (J/kg) = " << setw(tabS) << entropy_mass() << setw(tabL) << "entropy (J/kmol) = " << setw(tabS) << entropy_mole() << endl;
csvFile << setw(tabL) << "Gibbs (J/kg) = " << setw(tabS) << gibbs_mass() << setw(tabL) << "Gibbs (J/kmol) = " << setw(tabS) << gibbs_mole() << endl;
csvFile << setw(tabL) << "heat capacity c_p (J/K/kg) = " << setw(tabS) << cp_mass() << setw(tabL) << "heat capacity c_p (J/K/kmol) = " << setw(tabS) << cp_mole() << endl;
csvFile << setw(tabL) << "heat capacity c_v (J/K/kg) = " << setw(tabS) << cv_mass() << setw(tabL) << "heat capacity c_v (J/K/kmol) = " << setw(tabS) << cv_mole() << endl;
csvFile.precision(8);
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;
double x[kk];
double y[kk];
double mu[kk];
double a[kk];
double ac[kk];
double hbar[kk];
double sbar[kk];
double ubar[kk];
double cpbar[kk];
double vbar[kk];
vector<std::string> pNames;
vector<double*> data;
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";
}
}
getMoleFractions(x);
pNames.push_back("X");
data.push_back(x);
try{
getMassFractions(y);
pNames.push_back("Y");
data.push_back(y);
}
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) {;}
try{
getChemPotentials(mu);
pNames.push_back("Chem. Pot (J/kmol)");
data.push_back(mu);
}
catch (CanteraError) {;}
try{
getActivities(a);
pNames.push_back("Activity");
data.push_back(a);
}
catch (CanteraError) {;}
try{
getActivityCoefficients(ac);
pNames.push_back("Act. Coeff.");
data.push_back(ac);
}
catch (CanteraError) {;}
try{
getPartialMolarEnthalpies(hbar);
pNames.push_back("Part. Mol Enthalpy (J/kmol)");
data.push_back(hbar);
}
catch (CanteraError) {;}
try{
getPartialMolarEntropies(sbar);
pNames.push_back("Part. Mol. Entropy (J/K/kmol)");
data.push_back(sbar);
}
catch (CanteraError) {;}
try{
getPartialMolarIntEnergies(ubar);
pNames.push_back("Part. Mol. Energy (J/kmol)");
data.push_back(ubar);
}
catch (CanteraError) {;}
try{
getPartialMolarCp(cpbar);
pNames.push_back("Part. Mol. Cp (J/K/kmol");
data.push_back(cpbar);
}
catch (CanteraError) {;}
try{
getPartialMolarVolumes(vbar);
pNames.push_back("Part. Mol. Cv (J/K/kmol)");
data.push_back(vbar);
}
catch (CanteraError) {;}
csvFile << endl << setw(tabS) << "Species,";
for ( int i = 0; i < (int)pNames.size(); i++ ){
csvFile << setw(tabM) << pNames[i] << ",";
}
csvFile << endl;
/*
csvFile.fill('-');
csvFile << setw(tabS+(tabM+1)*pNames.size()) << "-\n";
csvFile.fill(' ');
*/
for (int k = 0; k < kk; k++) {
csvFile << setw(tabS) << speciesName(k) + ",";
if (x[k] > SmallNumber) {
for ( int i = 0; i < (int)pNames.size(); i++ ){
csvFile << setw(tabM) << data[i][k] << ",";
}
csvFile << endl;
}
else{
for ( int i = 0; i < (int)pNames.size(); i++ ){
csvFile << setw(tabM) << 0 << ",";
}
csvFile << endl;
}
}
}

View file

@ -2114,14 +2114,10 @@ namespace Cantera {
//! 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;
virtual void reportCSV(std::ofstream& csvFile) const;
protected: