How to find frequency & period of pendulum in C

AI Thread Summary
To find the frequency and period of a non-linear pendulum in C, one approach is to track the times when the pendulum's angle or angular velocity changes sign, which can help determine the oscillation period. The user is currently using the Runge-Kutta method with initial conditions set for small amplitudes but needs to adapt for larger amplitudes to avoid inaccuracies from linear approximations. A suggested formula for the period of a non-linear pendulum involves an integral that may need to be approximated through summation in C, as direct integration is not feasible in the language. The discussion emphasizes the importance of using appropriate initial conditions and methods to accurately model the dynamics of the pendulum. Overall, adapting existing mathematical models into the simulation is crucial for accurate results.
E=F_flat
Messages
3
Reaction score
0
1. The problem statement

Hi everyone, I'm currently working on an assignment that involves modelling a non-linear pendulum in C. I have to investigate the dynamics of a simple non-linear pendulum all the way up to a chaotic damped, driven situation. However, I'm completely baffled as to how to find the frequency of oscillation and period through my simulation (for large amplitudes). Do I simply use a counting method which involves storing the times at which the pendulum angle (or angular velocity) change sign, or is there some other more efficient method? I'm not asking for code, I just want some guidance as to what course of action to take.

Homework Equations



For the moment, I'm modelling the simple non-linear pendulum with equation:

\frac{d^{2}θ}{dt^{2}} = -\frac{g}{l}sinθMy Runge-Kutta code is based on the following equations:

\frac{dθ}{dt} = ω

\frac{dω}{dt} = -\frac{g}{l}sinθ

ω = angular velocity
g = acceleration due to gravity
l = length of pendulum
θ = angle of pendulum in relation to the vertical
 
Last edited:
Physics news on Phys.org
What initial conditions are you using for your RK method?

The period of oscillation would be the interval from when the pendulum starts at its initial deflection theta and returns to the same angle.
 
SteamKing said:
What initial conditions are you using for your RK method?

For my RK method I initialised the variables as follows:

θ = 0.1
ω = 0
dt = 0.04 (time step)

However, I have to investigate the dynamics of the pendulum at progressively larger amplitudes.
 
Your initial value of theta is about 5.7 degrees, which should simulate a pendulum for small amplitudes.
 
And when θ is "small", sin(θ) ≈ θ. That approximation will turn your nonlinear system into a linear one.
 
Thanks for responding. I only entered those initial values to test that my RK method was working. However, I will have to enter large values of θ, and the small amplitude approximation will no longer be accurate.

I happened to come across the following website:
http://webphysics.davidson.edu/alumni/BeKinneman/pendulum/report.htm

This report derives the following equation for period of a non-linear pendulum with unrestricted amplitudes:

T = 4\sqrt{\frac{l}{g}}\int^{1}_{0}\frac{1}{\sqrt{ { <1-z^{2}> . [ 1 - (k)^{2}z^{2}] }}}dz

I was thinking of adapting this formula into my C-program. You can't perform integrals on C, so I would have to perform a summation between max amplitude and zero amplitude. Am I on the right lines, or am I talking complete rubbish?
 

Similar threads

Replies
11
Views
2K
Replies
1
Views
2K
Replies
9
Views
2K
Replies
32
Views
2K
Replies
14
Views
1K
Replies
19
Views
2K
Replies
15
Views
1K
Replies
27
Views
2K
Back
Top