mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[thermo] initial exposing of Peng-Robinson eos parameters to python interface
This commit is contained in:
parent
66835e2d8d
commit
5c2ac7cea6
@ -173,6 +173,14 @@ public:
|
||||
void setBinaryCoeffs(const string& species_i, const string& species_j, double a);
|
||||
//! @}
|
||||
|
||||
//! Compute additional method based on name
|
||||
/*!
|
||||
* @param name The name of the quantity to compute
|
||||
* @return Computed value wrapped in AnyValue type for Peng-Robinson phase
|
||||
* quantities
|
||||
*/
|
||||
AnyValue compute_extra_method(const std::string& name) override;
|
||||
|
||||
protected:
|
||||
// Special functions inherited from MixtureFugacityTP
|
||||
double sresid() const override;
|
||||
|
@ -1556,6 +1556,16 @@ public:
|
||||
const Composition& oxComp, ThermoBasis basis=ThermoBasis::molar) const;
|
||||
//! @}
|
||||
|
||||
//! Compute additional method based on name
|
||||
/*!
|
||||
* @param name The name of the quantity to compute
|
||||
* @return Computed value wrapped in AnyValue type
|
||||
*/
|
||||
virtual AnyValue compute_extra_method(const std::string& name)
|
||||
{
|
||||
throw NotImplementedError("ThermoPhase::compute_extra_method");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Carry out work in HP and UV calculations.
|
||||
|
@ -175,6 +175,8 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
||||
double equivalenceRatio() except +translate_exception
|
||||
double stoichAirFuelRatio(const double* fuelComp, const double* oxComp, ThermoBasis basis) except +translate_exception
|
||||
|
||||
CxxAnyValue compute_extra_method(string) except +translate_exception
|
||||
|
||||
|
||||
cdef extern from "cantera/thermo/SurfPhase.h":
|
||||
cdef cppclass CxxSurfPhase "Cantera::SurfPhase":
|
||||
|
@ -1172,6 +1172,10 @@ cdef class ThermoPhase(_SolutionBase):
|
||||
X = self.thermo.getMoleFractionsByName(threshold)
|
||||
return {pystr(item.first):item.second for item in X}
|
||||
|
||||
def compute_extra_method(self, name):
|
||||
cdef CxxAnyValue value = self.thermo.compute_extra_method(stringify(name))
|
||||
return anyvalue_to_python(name, value)
|
||||
|
||||
######## Read-only thermodynamic properties ########
|
||||
|
||||
property P:
|
||||
|
@ -780,4 +780,18 @@ int PengRobinson::solveCubic(double T, double pres, double a, double b, double a
|
||||
an, bn, cn, dn, tc, vc);
|
||||
}
|
||||
|
||||
AnyValue PengRobinson::compute_extra_method(const std::string& name)
|
||||
{
|
||||
if(name == "aAlpha_mix") {
|
||||
return AnyValue(m_aAlpha_mix);
|
||||
} else if(name == "b_mix") {
|
||||
return AnyValue(m_b);
|
||||
} else if(name == "daAlpha_dT") {
|
||||
return AnyValue(daAlpha_dT());
|
||||
} else if(name == "d2aAlpha_dT2") {
|
||||
return AnyValue(d2aAlpha_dT2());
|
||||
}
|
||||
throw CanteraError("PengRobinson::compute_extra_method", "Unknown method: {}", name);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user