How to find frequency & period of pendulum in C

Click For Summary

Discussion Overview

The discussion revolves around modeling a non-linear pendulum in C, focusing on how to determine the frequency of oscillation and period through simulation, particularly for large amplitudes. Participants explore various methods and equations relevant to the dynamics of the pendulum.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant seeks guidance on finding the frequency and period of a non-linear pendulum simulation, questioning whether a counting method based on sign changes of angle or angular velocity is appropriate.
  • Another participant suggests that the period of oscillation can be defined as the interval from the initial deflection angle to when the pendulum returns to that angle.
  • A participant provides initial conditions for their Runge-Kutta method, including a small angle for theta, and notes the need to investigate larger amplitudes.
  • Concerns are raised about the small angle approximation, which may not be valid for larger amplitudes, potentially simplifying the non-linear system to a linear one.
  • A participant references an external report that derives a formula for the period of a non-linear pendulum with unrestricted amplitudes and considers adapting this formula for use in their C program, questioning the feasibility of performing integrals in C.

Areas of Agreement / Disagreement

Participants express differing views on the appropriateness of the small angle approximation and the methods for calculating the period and frequency, indicating that multiple competing approaches remain in the discussion.

Contextual Notes

Participants highlight limitations related to the small angle approximation and the challenges of implementing integral calculations in C, which may affect the accuracy of their simulations.

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 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
3K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 27 ·
Replies
27
Views
2K
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K