diff --git a/physics/Bernoullis_equation.py b/physics/Bernoullis_equation.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/physics/Torricelli.py b/physics/Torricelli.py new file mode 100644 index 000000000000..55247150c592 --- /dev/null +++ b/physics/Torricelli.py @@ -0,0 +1,41 @@ +""" +Calculates velocity of fluid from Potential Gravitational Energy + +Equation for finding velocity +V = sqrt(2 * gravity * Δy) + +Source: +- https://en.wikipedia.org/wiki/Archimedes%27_principle +""" + + +# Acceleration Constant on Earth (unit m/s^2) +g = 9.80665 + + +def torricelli_theorem(height: float, gravity: float = g) -> float: + """ + Args: + height: The change in height between initial and point of flow (where, + velocity is being measured) + gravity: Acceleration from gravity. Gravitational force on system, + Default is Earth Gravity + returns: + velocity of exiting fluid. + + >>> torricelli_theorem(height=5) + 9.90285312422637 + >>> torricelli_theorem(height=3, gravity=9.8) + 7.6681158050723255 + """ + if gravity <= 0: + raise ValueError("Impossible Gravity") + + return (2 * height * gravity) ** 0.5 + + +if __name__ == "__main__": + import doctest + + # run doctest + doctest.testmod() diff --git a/physics/archimedes_principle.py b/physics/archimedes_principle.py new file mode 100644 index 000000000000..6ecfc65e7461 --- /dev/null +++ b/physics/archimedes_principle.py @@ -0,0 +1,49 @@ +""" +Calculates buoyant force on object submerged within static fluid. +Discovered by greek mathematician, Archimedes. The principle is named after him. + +Equation for calculating buoyant force: +Fb = ρ * V * g + +Source: +- https://en.wikipedia.org/wiki/Archimedes%27_principle +""" + + +# Acceleration Constant on Earth (unit m/s^2) +g = 9.80665 + + +def archimedes_principle( + fluid_density: float, volume: float, gravity: float = g +) -> float: + """ + Args: + fluid_density: density of fluid (kg/m^3) + volume: volume of object / liquid being displaced by object + gravity: Acceleration from gravity. Gravitational force on system, + Default is Earth Gravity + returns: + buoyant force on object in Newtons + + >>> archimedes_principle(fluid_density=997, volume=0.5, gravity=9.8) + 4885.3 + >>> archimedes_principle(fluid_density=997, volume=0.7) + 6844.061035 + """ + + if fluid_density <= 0: + raise ValueError("Impossible fluid density") + if volume < 0: + raise ValueError("Impossible Object volume") + if gravity <= 0: + raise ValueError("Impossible Gravity") + + return fluid_density * gravity * volume + + +if __name__ == "__main__": + import doctest + + # run doctest + doctest.testmod()