Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pyndulum/pendulum_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def bpm(len: float) -> float:
"""
return 60.0 / get_period(len)

def length_from_period(p: float) -> float:
"""
Calculate the length of a pendulum based on period.

Parameters
----------
p : float
period [s] for a swing of the pendulum
length of the pendulum [m]
"""
return ((p / 2.0 * np.pi) ** 2) * 9.81

def energy(m: float, len: float, theta: float) -> float:
"""
Calculate the energy of a pendulum.
Expand All @@ -111,4 +123,4 @@ def energy(m: float, len: float, theta: float) -> float:
float
energy [kg . m2 /s2] of the pendulum
"""
return m * 9.81 * max_height(len, theta)
return m * 9.81 * max_height(len, theta)