mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
[pre-commit.ci] pre-commit autoupdate (#9543)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.291 → v0.0.292](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.291...v0.0.292) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6) - [github.com/tox-dev/pyproject-fmt: 1.1.0 → 1.2.0](https://github.com/tox-dev/pyproject-fmt/compare/1.1.0...1.2.0) * updating DIRECTORY.md * Fix typos in test_min_spanning_tree_prim.py * Fix typos * codespell --ignore-words-list=manuel --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
![66853113+pre-commit-ci[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
GitHub

parent
60291738d2
commit
895dffb412
@ -2,39 +2,35 @@
|
||||
Title : Calculating the speed of sound
|
||||
|
||||
Description :
|
||||
The speed of sound (c) is the speed that a sound wave travels
|
||||
per unit time (m/s). During propagation, the sound wave propagates
|
||||
through an elastic medium. Its SI unit is meter per second (m/s).
|
||||
The speed of sound (c) is the speed that a sound wave travels per unit time (m/s).
|
||||
During propagation, the sound wave propagates through an elastic medium.
|
||||
|
||||
Only longitudinal waves can propagate in liquids and gas other then
|
||||
solid where they also travel in transverse wave. The following Algo-
|
||||
rithem calculates the speed of sound in fluid depanding on the bulk
|
||||
module and the density of the fluid.
|
||||
Sound propagates as longitudinal waves in liquids and gases and as transverse waves
|
||||
in solids. This file calculates the speed of sound in a fluid based on its bulk
|
||||
module and density.
|
||||
|
||||
Equation for calculating speed od sound in fluid:
|
||||
c_fluid = (K_s*p)**0.5
|
||||
Equation for the speed of sound in a fluid:
|
||||
c_fluid = sqrt(K_s / p)
|
||||
|
||||
c_fluid: speed of sound in fluid
|
||||
K_s: isentropic bulk modulus
|
||||
p: density of fluid
|
||||
|
||||
|
||||
|
||||
Source : https://en.wikipedia.org/wiki/Speed_of_sound
|
||||
"""
|
||||
|
||||
|
||||
def speed_of_sound_in_a_fluid(density: float, bulk_modulus: float) -> float:
|
||||
"""
|
||||
This method calculates the speed of sound in fluid -
|
||||
This is calculated from the other two provided values
|
||||
Examples:
|
||||
Example 1 --> Water 20°C: bulk_moduls= 2.15MPa, density=998kg/m³
|
||||
Example 2 --> Murcery 20°: bulk_moduls= 28.5MPa, density=13600kg/m³
|
||||
Calculates the speed of sound in a fluid from its density and bulk modulus
|
||||
|
||||
>>> speed_of_sound_in_a_fluid(bulk_modulus=2.15*10**9, density=998)
|
||||
Examples:
|
||||
Example 1 --> Water 20°C: bulk_modulus= 2.15MPa, density=998kg/m³
|
||||
Example 2 --> Mercury 20°C: bulk_modulus= 28.5MPa, density=13600kg/m³
|
||||
|
||||
>>> speed_of_sound_in_a_fluid(bulk_modulus=2.15e9, density=998)
|
||||
1467.7563207952705
|
||||
>>> speed_of_sound_in_a_fluid(bulk_modulus=28.5*10**9, density=13600)
|
||||
>>> speed_of_sound_in_a_fluid(bulk_modulus=28.5e9, density=13600)
|
||||
1447.614670861731
|
||||
"""
|
||||
|
||||
|
Reference in New Issue
Block a user