Skip to content

Commit

Permalink
Update sound_speed examples
Browse files Browse the repository at this point in the history
  • Loading branch information
corykinney committed Jun 14, 2023
1 parent a67bea5 commit 852d1f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
8 changes: 3 additions & 5 deletions samples/python/thermo/sound_speed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Compute the "equilibrium" and "frozen" sound speeds for a gas
Requires: cantera >= 2.5.0
Requires: cantera >= 3.0.0
Keywords: thermodynamics, equilibrium
"""

Expand Down Expand Up @@ -42,10 +42,8 @@ def equilSoundSpeeds(gas, rtol=1.0e-6, max_iter=5000):
# equilibrium sound speed
aequil = math.sqrt((p1 - p0)/(gas.density - r0))

# compute the frozen sound speed using the ideal gas expression as a check
gamma = gas.cp/gas.cv
afrozen2 = math.sqrt(gamma * ct.gas_constant * gas.T /
gas.mean_molecular_weight)
# check against the built-in sound speed function
afrozen2 = gas.sound_speed

return aequil, afrozen, afrozen2

Expand Down
7 changes: 2 additions & 5 deletions samples/python/thermo/sound_speed_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ def equilibrium_sound_speeds(gas, rtol=1.0e-6, max_iter=5000):
# equilibrium sound speed
aequil = np.sqrt((p1 - p0)/(gas.density - r0)).to("ft/s")

# compute the frozen sound speed using the ideal gas expression as a check
gamma = gas.cp/gas.cv
gamma * ctu.units.molar_gas_constant
afrozen2 = np.sqrt(gamma * ctu.units.molar_gas_constant * gas.T /
gas.mean_molecular_weight).to("ft/s")
# check against the built-in sound speed function
afrozen2 = gas.sound_speed.to("ft/s")

return aequil, afrozen, afrozen2

Expand Down

0 comments on commit 852d1f9

Please sign in to comment.