Skip to content

Commit

Permalink
[transport] added coding to get acentric factor from critical-propert…
Browse files Browse the repository at this point in the history
…ies.yaml, if needed
  • Loading branch information
wandadars committed Aug 19, 2024
1 parent 7340a0e commit 1b334f8
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/cantera/transport/GasTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class GasTransport : public Transport
* name of a file containing transport property parameters and a list of
* species names.
*/
void getTransportData();
virtual void getTransportData();

//! Corrections for polar-nonpolar binary diffusion coefficients
/*!
Expand Down
26 changes: 26 additions & 0 deletions include/cantera/transport/HighPressureGasTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ class HighPressureGasTransport : public MixTransport

protected:

/**
* Obtain required parameters from the 'critical-parameters' species input section,
* and checks the critical-properties.yaml file if an acentric factor is not
* specified.
*
* The way that GasTransport parses the input file is that if an acentric
* factor is not specified, it is quietly set to 0.0. A user may have the proper
* acentric factor in the critical-properties.yaml file, so that file is checked if
* a zero value is present.
*
*/
void getTransportData() override;

/**
* Computes and stores the estimate of the critical properties for each species.
*
Expand Down Expand Up @@ -754,6 +767,19 @@ class ChungHighPressureGasTransport : public MixTransport

protected:

/**
* Obtain required parameters from the 'critical-parameters' species input section,
* and checks the critical-properties.yaml file if an acentric factor is not
* specified.
*
* The way that GasTransport parses the input file is that if an acentric
* factor is not specified, it is quietly set to 0.0. A user may have the proper
* acentric factor in the critical-properties.yaml file, so that file is checked if
* a zero value is present.
*
*/
void getTransportData() override;

/**
* Computes and stores the estimate of the critical properties for each species.
*
Expand Down
71 changes: 71 additions & 0 deletions src/transport/HighPressureGasTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
#include "cantera/base/stringUtils.h"
#include "cantera/transport/MultiTransport.h"

#include "cantera/transport/GasTransport.h"
#include "cantera/transport/TransportData.h"
#include "cantera/thermo/ThermoPhase.h"
#include "cantera/thermo/Species.h"
#include <boost/algorithm/string.hpp>


using namespace std;

namespace Cantera
Expand Down Expand Up @@ -104,6 +111,38 @@ void HighPressureGasTransport::init(ThermoPhase* thermo, int mode, int log_level
initializeCriticalProperties();
}

void HighPressureGasTransport::getTransportData()
{
// Call the base class's method to fill the properties
GasTransport::getTransportData();

// Contents of 'critical-properties.yaml', loaded later if needed
AnyMap critPropsDb;
std::unordered_map<string, AnyMap*> dbSpecies;

// If a species has a zero acentric factor, check the critical-properties.yaml
// database to see if it has a value specified for the species.
for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
if (m_w_ac[k] == 0.0) {
// Load 'crit-properties.yaml' file if not already loaded
if (critPropsDb.empty()) {
critPropsDb = AnyMap::fromYamlFile("critical-properties.yaml");
dbSpecies = critPropsDb["species"].asMap("name");
}

// All names in critical-properties.yaml are upper case
auto ucName = boost::algorithm::to_upper_copy(m_thermo->species(k)->name);
if (dbSpecies.count(ucName)) {
auto& spec = *dbSpecies.at(ucName);
auto& critProps = spec["critical-parameters"].as<AnyMap>();
if (critProps.hasKey("acentric-factor")) {
m_w_ac[k] = critProps.convert("acentric-factor", "1");
}
}
}
}
}

void HighPressureGasTransport::initializeCriticalProperties()
{
size_t nSpecies = m_thermo->nSpecies();
Expand Down Expand Up @@ -587,6 +626,38 @@ void ChungHighPressureGasTransport::init(ThermoPhase* thermo, int mode, int log_
initializePureFluidProperties();
}

void ChungHighPressureGasTransport::getTransportData()
{
// Call the base class's method to fill the properties
GasTransport::getTransportData();

// Contents of 'critical-properties.yaml', loaded later if needed
AnyMap critPropsDb;
std::unordered_map<string, AnyMap*> dbSpecies;

// If a species has a zero acentric factor, check the critical-properties.yaml
// database to see if it has a value specified for the species.
for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
if (m_w_ac[k] == 0.0) {
// Load 'crit-properties.yaml' file if not already loaded
if (critPropsDb.empty()) {
critPropsDb = AnyMap::fromYamlFile("critical-properties.yaml");
dbSpecies = critPropsDb["species"].asMap("name");
}

// All names in critical-properties.yaml are upper case
auto ucName = boost::algorithm::to_upper_copy(m_thermo->species(k)->name);
if (dbSpecies.count(ucName)) {
auto& spec = *dbSpecies.at(ucName);
auto& critProps = spec["critical-parameters"].as<AnyMap>();
if (critProps.hasKey("acentric-factor")) {
m_w_ac[k] = critProps.convert("acentric-factor", "1");
}
}
}
}
}

void ChungHighPressureGasTransport::initializeCriticalProperties()
{
m_Tcrit.resize(m_nsp);
Expand Down

0 comments on commit 1b334f8

Please sign in to comment.