Example usage
The easyphysics package has four functions which can provide solutions for Physics Equations. Input will be taken from the User and the solutions will be provided by the functions. The four functions are as follows:
freefall() calculates the time it takes for a falling object using the equation of motion height = 1/2*gt^2, given the height and gravity of the free fall. It returns the time it takes for the free fall, and a plot compares the time of the free fall on different planets with a list. The distance traveled by the falling object (height) and the acceleration of gravity (g, default = 9.8) are the function’s arguments.
from easyphysics.freefall import freefall
time, plot = freefall(10, g = 15)
print(f"The time for an object to have a 10-meter-free-fall on a planet with a surface gravity of 15 m/s^2 is {round(time,2)} seconds.")
print(f"The time for an object to have a 10-meter-free-fall on different planets are shown in the image below.")
The time for an object to have a 10-meter-free-fall on a planet with a surface gravity of 15 m/s^2 is 1.15 seconds.
The time for an object to have a 10-meter-free-fall on different planets are shown in the image below.
<Figure size 1000x1000 with 0 Axes>
<Figure size 640x480 with 0 Axes>
gravitational_energy() calculates the energy possessed or acquired by an object due to a change in its position when it is present in a gravitational field = mgh
from easyphysics.gravitational_energy import gravitational_energy
ge = gravitational_energy(10, 1000, g = 9.8)
print(f"The gravitational energy possessed or acquired by an object of 10 kg when gravity is 9.8 m/s^2 is {ge}")
The gravitational energy possessed or acquired by an object of 10 kg when gravity is 9.8 m/s^2 is 98000.0
kinetic_energy() calculates the Kinetic Energy of an object. When work is done on an object, energy is transferred, and the object moves with a new constant speed. We call the energy that is transferred kinetic energy, and it depends on the mass and speed achieved. The kinetic energy equation is given as: KE = 1/2mv^2, Where KE is the kinetic energy, m is the body’s mass, and v is the body’s velocity.
from easyphysics.kinetic_energy import kinetic_energy
KE = kinetic_energy(0.6, 3)
print(f"The kinetic energy of an object whose mass is 0.6 kg and a velocity of 3 m/s is {round(KE,2)}.")
The kinetic energy of an object whose mass is 0.6 kg and a velocity of 3 m/s is 2.7.
static_friction_ground() calculates the friction force for static object. The formula is fr = mu * N, where the mu is the coefficient of friction which incorporating the characteristics of the surface.
from easyphysics.static_friction import static_friction_ground
from easyphysics.static_friction import plot_frict
force = static_friction_ground(0.2, 2)
print(f"On earth, the static friction force for a static object of 2 kg with the coefficient of friction of 0.2 {round(force,2)}.")
plot_frict(0.2,2,9.8)
On earth, the static friction force for a static object of 2 kg with the coefficient of friction of 0.2 3.92.