implemented reportCSV in MolalityPSSTP and PureFluidPhase
This commit is contained in:
parent
8f8b83e0a2
commit
20bf13dbd7
2 changed files with 232 additions and 138 deletions
|
|
@ -916,95 +916,144 @@ namespace Cantera {
|
|||
*/
|
||||
void MolalityVPSSTP::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";
|
||||
csvFile << "\n"+name()+"\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";
|
||||
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 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]);
|
||||
double x[kk];
|
||||
double molal[kk];
|
||||
double mu[kk];
|
||||
double muss[kk];
|
||||
double aMolal[kk];
|
||||
double acMolal[kk];
|
||||
double hbar[kk];
|
||||
double sbar[kk];
|
||||
double ubar[kk];
|
||||
double cpbar[kk];
|
||||
double vbar[kk];
|
||||
vector<std::string> pNames;
|
||||
vector<double*> data;
|
||||
|
||||
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";
|
||||
getMoleFractions(x);
|
||||
pNames.push_back("X");
|
||||
data.push_back(x);
|
||||
try{
|
||||
getMolalities(molal);
|
||||
pNames.push_back("Molal");
|
||||
data.push_back(molal);
|
||||
}
|
||||
|
||||
|
||||
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";
|
||||
catch (CanteraError) {;}
|
||||
try{
|
||||
getChemPotentials(mu);
|
||||
pNames.push_back("Chem. Pot. (J/kmol)");
|
||||
data.push_back(mu);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
catch (CanteraError) {;}
|
||||
try{
|
||||
getStandardChemPotentials(muss);
|
||||
pNames.push_back("Chem. Pot. SS (J/kmol)");
|
||||
data.push_back(muss);
|
||||
}
|
||||
catch (CanteraError) {;}
|
||||
try{
|
||||
getMolalityActivityCoefficients(acMolal);
|
||||
pNames.push_back("Molal Act. Coeff.");
|
||||
data.push_back(acMolal);
|
||||
}
|
||||
catch (CanteraError) {;}
|
||||
try{
|
||||
getActivities(aMolal);
|
||||
pNames.push_back("Molal Activity");
|
||||
data.push_back(aMolal);
|
||||
int iHp = speciesIndex("H+");
|
||||
if (iHp >= 0) {
|
||||
double pH = -log(aMolal[iHp]) / log(10.0);
|
||||
csvFile << setw(tabL) << "pH = " << setw(tabS) << pH << endl;
|
||||
}
|
||||
}
|
||||
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) {;}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,91 +434,136 @@ namespace Cantera {
|
|||
*/
|
||||
void PureFluidPhase::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";
|
||||
csvFile << "\n"+name()+"\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";
|
||||
|
||||
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;
|
||||
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";
|
||||
csvFile << setw(tabL) << "vapor fraction = " << setw(tabS) << xx << 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CanteraError) {
|
||||
;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue