Cubic calc_molar_mass, closes #1124 (#1132)

This commit is contained in:
JonWel
2016-06-22 15:18:06 +02:00
committed by Ian Bell
parent 0d3d1592fe
commit 2315c274c8
2 changed files with 23 additions and 8 deletions

View File

@@ -404,6 +404,16 @@ CoolPropDbl CoolProp::AbstractCubicBackend::solver_rho_Tp(CoolPropDbl T, CoolPro
return rho;
}
CoolPropDbl CoolProp::AbstractCubicBackend::calc_molar_mass(void)
{
double summer = 0;
for (unsigned int i = 0; i < N; ++i)
{
summer += mole_fractions[i] * components[i].molemass;
}
return summer;
}
void CoolProp::AbstractCubicBackend::set_binary_interaction_double(const std::size_t i, const std::size_t j, const std::string &parameter, const double value){
if (parameter == "kij" || parameter == "k_ij"){
get_cubic()->set_kij(i,j,value);

View File

@@ -31,6 +31,7 @@ class CubicResidualHelmholtz;
class AbstractCubicBackend : public HelmholtzEOSMixtureBackend {
protected:
shared_ptr<AbstractCubic> cubic;
std::vector<CubicLibrary::CubicsValues> components; ///< The components that are in use
public:
/// Set the pointer to the residual helmholtz class, etc.
@@ -157,6 +158,8 @@ public:
/// Cubic backend flashes for PQ, and QT
void saturation(CoolProp::input_pairs inputs);
CoolPropDbl calc_molar_mass(void);
void set_binary_interaction_double(const std::size_t i1, const std::size_t i2, const std::string &parameter, const double value);
double get_binary_interaction_double(const std::size_t i1, const std::size_t i2, const std::string &parameter);
@@ -200,11 +203,12 @@ public:
bool generate_SatL_and_SatV = true){
std::vector<double> Tc, pc, acentric;
N = fluid_identifiers.size();
components.resize(N);
for (std::size_t i = 0; i < fluid_identifiers.size(); ++i){
CubicLibrary::CubicsValues val = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
Tc.push_back(val.Tc);
pc.push_back(val.pc);
acentric.push_back(val.acentric);
components[i] = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
Tc.push_back(components[i].Tc);
pc.push_back(components[i].pc);
acentric.push_back(components[i].acentric);
}
cubic.reset(new SRK(Tc, pc, acentric, R_u));
setup(generate_SatL_and_SatV);
@@ -241,11 +245,12 @@ public:
bool generate_SatL_and_SatV = true){
std::vector<double> Tc, pc, acentric;
N = fluid_identifiers.size();
components.resize(N);
for (std::size_t i = 0; i < fluid_identifiers.size(); ++i){
CubicLibrary::CubicsValues val = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
Tc.push_back(val.Tc);
pc.push_back(val.pc);
acentric.push_back(val.acentric);
components[i] = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
Tc.push_back(components[i].Tc);
pc.push_back(components[i].pc);
acentric.push_back(components[i].acentric);
}
cubic.reset(new PengRobinson(Tc, pc, acentric, R_u));
setup(generate_SatL_and_SatV);