1
+ from scipy .constants import g
1
2
"""
2
3
Title : Computing the terminal velocity of an object falling
3
4
through a fluid.
13
14
where :
14
15
Vt = Terminal velocity (in m/s)
15
16
m = Mass of the falling object (in Kg)
16
- g = Acceleration due to gravity (value taken : 9.8 m/s^2 )
17
+ g = Acceleration due to gravity (value taken : imported from scipy )
17
18
ρ = Density of the fluid through which the object is falling (in Kg/m^3)
18
19
A = Projected area of the object (in m^2)
19
20
Cd = Drag coefficient (dimensionless)
@@ -27,11 +28,11 @@ def terminal_velocity(
27
28
) -> float :
28
29
"""
29
30
>>> terminal_velocity(1, 25, 0.6, 0.77)
30
- 1.3026778945578592
31
+ 1.3031197996044768
31
32
>>> terminal_velocity(2, 100, 0.45, 0.23)
32
- 1.9461345311993645
33
+ 1.9467947148674276
33
34
>>> terminal_velocity(5, 50, 0.2, 0.5)
34
- 4.427188724235731
35
+ 4.428690551393267
35
36
>>> terminal_velocity(-5, 50, -0.2, -2)
36
37
Traceback (most recent call last):
37
38
...
@@ -49,7 +50,7 @@ def terminal_velocity(
49
50
raise ValueError (
50
51
"mass, density, area and the drag coefficient all need to be positive"
51
52
)
52
- return ((2 * mass * 9.8 ) / (density * area * drag_coefficient )) ** 0.5
53
+ return ((2 * mass * g ) / (density * area * drag_coefficient )) ** 0.5
53
54
54
55
55
56
if __name__ == "__main__" :
0 commit comments