Solving the Pendulum Problem with RK4 Method

  • Context: Undergrad 
  • Thread starter Thread starter MASH4077
  • Start date Start date
  • Tags Tags
    Pendulum
Click For Summary

Discussion Overview

The discussion revolves around a simulation of a simple pendulum using the RK4 method to solve the associated second-order differential equation. Participants explore the conditions under which the simulation exhibits erratic behavior, specifically the issue of the simulation "escaping" quickly.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their simulation setup, including the differential equation used for acceleration, and seeks advice on why the simulation behaves unexpectedly.
  • Another participant challenges the formulation of acceleration, suggesting that it should be g*theta instead of -(g/L)*theta.
  • A different participant points out that the expression used is an approximation, noting that the true differential equation should include sin(theta) instead of theta, which is only valid for small angles.
  • One participant agrees with the previous point, emphasizing that the model's accuracy diminishes with larger angles and that the assumption of radians is crucial for the approximation to hold.
  • A later reply indicates that the original poster realized they were not calculating acceleration correctly based on initial conditions, which they corrected, leading to improved simulation behavior.

Areas of Agreement / Disagreement

Participants express differing views on the formulation of the acceleration in the pendulum model, with some supporting the use of sin(theta) and others suggesting alternative formulations. The discussion reflects a lack of consensus on the best approach to model the pendulum's motion accurately.

Contextual Notes

Participants highlight the limitations of the approximation used in the simulation, particularly its dependence on small angle assumptions and the need for correct initial conditions to ensure accurate results.

MASH4077
Messages
12
Reaction score
0
Pendulum Problem...

Hi all,

I've written a little simulator (in C++) that demonstrates a simple pendulum swinging from right to left and back again. To simulate the motion I'm using the simple second order differential equation:

accelaration = -(g/L) * theta

and numerically integrating this using the RK4 method. However I'm having a problem in that the simulation is escaping really quickly. I just want to ask under what conditions would this happen?. I think I'm starting off the simulation with reasonable values and they are outlined below:

angle = 22.5, start angular_vel = 0.0f, init accel = calculated using above formula.

Any advice on why the simulation could be breaking so quickly is much appreciated.

Thanks.
 
Physics news on Phys.org


I am not saying that this is the problem with your program but the
acceleration cannot be g/L *theta. Maybe g*theta.
 


I may not understand the simulation, but I do have something that may be of interest. The expression you have, "acclereration = -(g/L)*theta" is an approximation. The true differential equation should have a sin(theta) rather than theta. The approximation only holds for small angles. Could this be the source of your "escaping"?

It would seem to me, that you are providing an acceleration that is greater than what nature would provide, and the larger the angle, the more inaccurate the model. Also, the approximation that sin(theta) ~ theta is only accurate if theta is given in radians. You're model therefore assumes you are using radians. Try a reasonable number for angle like 0.3 and see what you get. Or, you could change to sin(theta) and keep your numbers.
 


Yeah, Nasu is right too, but that L shouldn't really affect anything qualitatively.
 


jdog said:
It would seem to me, that you are providing an acceleration that is greater than what nature would provide, and the larger the angle, the more inaccurate the model.
Yup. I think that that is the problem for the simulation escaping. I realized this when I actually took another look at the implementation. I wasn't calculating the acceleration of the pendulum based on the initial conditions provided to the simulation, but rather I was just "feeding in" a value. I've just re-written that particular part to ensure that given the initial conditions, the correct value is assigned to the acceleration variable. Everything is now behaving as it should do.

Many Thanks.

:)
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
11K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 35 ·
2
Replies
35
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 65 ·
3
Replies
65
Views
10K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
17K