mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[Thermo] Add speed of sound property
Add ThermoPhase::soundSpeed virtual function with documentation Add IdealGasPhase implementation Add to cython interface Add units declaration
This commit is contained in:
parent
cd8756e6c6
commit
3bf5d8bcd3
@ -401,6 +401,8 @@ public:
|
||||
return 1.0 / temperature();
|
||||
}
|
||||
|
||||
virtual double soundSpeed() const;
|
||||
|
||||
//! @}
|
||||
//! @name Chemical Potentials and Activities
|
||||
//!
|
||||
|
@ -292,6 +292,17 @@ public:
|
||||
throw NotImplementedError("ThermoPhase::thermalExpansionCoeff");
|
||||
}
|
||||
|
||||
//! Return the speed of sound. Units: m/s.
|
||||
/*!
|
||||
* The speed of sound is defined as
|
||||
* \f[
|
||||
* c = \sqrt{\left(\frac{\partial P}{\partial\rho}\right)_s}
|
||||
* \f]
|
||||
*/
|
||||
virtual double soundSpeed() const {
|
||||
throw NotImplementedError("ThermoPhase::soundSpeed");
|
||||
}
|
||||
|
||||
//! @}
|
||||
//! @name Electric Potential
|
||||
//!
|
||||
|
@ -492,7 +492,7 @@ class SolutionArray(SolutionArrayBase):
|
||||
'gibbs_mass', 'cv', 'cv_mole', 'cv_mass', 'cp', 'cp_mole', 'cp_mass',
|
||||
'critical_temperature', 'critical_pressure', 'critical_density',
|
||||
'P_sat', 'T_sat', 'isothermal_compressibility',
|
||||
'thermal_expansion_coeff', 'electric_potential',
|
||||
'thermal_expansion_coeff', 'sound_speed', 'electric_potential',
|
||||
# From Kinetics
|
||||
'heat_release_rate',
|
||||
# From Transport
|
||||
|
@ -773,8 +773,8 @@ for _attr in ['density', 'density_mass', 'density_mole', 'volume_mass',
|
||||
'entropy_mass', 'g', 'gibbs_mole', 'gibbs_mass', 'cv',
|
||||
'cv_mole', 'cv_mass', 'cp', 'cp_mole', 'cp_mass',
|
||||
'isothermal_compressibility', 'thermal_expansion_coeff',
|
||||
'viscosity', 'thermal_conductivity', 'heat_release_rate',
|
||||
'mean_molecular_weight']:
|
||||
'sound_speed', 'viscosity', 'thermal_conductivity',
|
||||
'heat_release_rate', 'mean_molecular_weight']:
|
||||
setattr(FlameBase, _attr, _array_property(_attr))
|
||||
FlameBase.volume = _array_property('v') # avoid confusion with velocity gradient 'V'
|
||||
FlameBase.int_energy = _array_property('u') # avoid collision with velocity 'u'
|
||||
|
@ -76,6 +76,7 @@ cdef extern from "cantera/thermo/ThermoPhase.h" namespace "Cantera":
|
||||
double molarVolume() except +translate_exception
|
||||
double isothermalCompressibility() except +translate_exception
|
||||
double thermalExpansionCoeff() except +translate_exception
|
||||
double soundSpeed() except +translate_exception
|
||||
double electricPotential() except +translate_exception
|
||||
void setElectricPotential(double) except +translate_exception
|
||||
|
||||
|
@ -1713,6 +1713,11 @@ cdef class ThermoPhase(_SolutionBase):
|
||||
def __get__(self):
|
||||
return self.thermo.thermalExpansionCoeff()
|
||||
|
||||
property sound_speed:
|
||||
"""Speed of sound [m/s]."""
|
||||
def __get__(self):
|
||||
return self.thermo.soundSpeed()
|
||||
|
||||
property min_temp:
|
||||
"""
|
||||
Minimum temperature for which the thermodynamic data for the phase are
|
||||
|
@ -32,7 +32,7 @@ def UnitsInterfaceBuilder(env, target, source):
|
||||
"concentrations": '"kmol/m**3"', "critical_pressure": '"Pa"',
|
||||
"critical_temperature": '"K"', "critical_density": 'self.basis_units + "/m**3"',
|
||||
"electric_potential": '"V"', "electrochemical_potentials": '"J/kmol"',
|
||||
"isothermal_compressibility": '"1/Pa"', "max_temp": '"K"',
|
||||
"isothermal_compressibility": '"1/Pa"', "sound_speed": '"m/s"', "max_temp": '"K"',
|
||||
"mean_molecular_weight": '"kg/kmol"', "min_temp": '"K"',
|
||||
"molecular_weights": '"kg/kmol"', "partial_molar_cp": '"J/kmol/K"',
|
||||
"partial_molar_enthalpies": '"J/kmol"', "partial_molar_entropies": '"J/kmol/K"',
|
||||
@ -52,7 +52,7 @@ def UnitsInterfaceBuilder(env, target, source):
|
||||
"P_sat", "T", "T_sat", "atomic_weight", "chemical_potentials", "concentrations",
|
||||
"critical_pressure", "critical_temperature", "critical_density",
|
||||
"electric_potential", "electrochemical_potentials", "isothermal_compressibility",
|
||||
"max_temp", "mean_molecular_weight", "min_temp", "molecular_weights",
|
||||
"sound_speed", "max_temp", "mean_molecular_weight", "min_temp", "molecular_weights",
|
||||
"partial_molar_cp", "partial_molar_enthalpies", "partial_molar_entropies",
|
||||
"partial_molar_int_energies", "partial_molar_volumes", "reference_pressure",
|
||||
"thermal_expansion_coeff", "cp", "cv", "density", "h", "s", "g", "u", "v",
|
||||
|
@ -37,6 +37,12 @@ doublereal IdealGasPhase::cv_mole() const
|
||||
return cp_mole() - GasConstant;
|
||||
}
|
||||
|
||||
double IdealGasPhase::soundSpeed() const {
|
||||
return sqrt(
|
||||
cp_mole() / cv_mole() * GasConstant / meanMolecularWeight() * temperature()
|
||||
);
|
||||
}
|
||||
|
||||
doublereal IdealGasPhase::standardConcentration(size_t k) const
|
||||
{
|
||||
return pressure() / RT();
|
||||
|
Loading…
Reference in New Issue
Block a user