Simple Energy Question based on SHM

  • Thread starter RJLiberator
  • Start date
  • Tags Tags
    Energy Shm
2 replies · 2K views · last reply
RJLiberator
Gold Member
Messages
1,094
Reaction score
63

Homework Statement


I am taksed with putting some simple harmonic motion (in this case linear harmonic motion) into graphs.
For my first graph, I am graphing theta vs. time and analyzing three different numerical methods for the solution (Euler, Euler-cramer, Runge Katta).
For my second graph, I am looking at the Energy vs. time based on these results.
Attached in the solutions are my results.

Homework Equations

The Attempt at a Solution



MOTION:
Line plot titled Linear Harmonic Oscillation of angle in radians against time in seconds, showing three methods: Euler (black plus signs) with growing amplitude, Euler-Cromer (red crosses) and Runge-Kutta (blue circles) with steady oscillations between about -10 and 10 radians.


ENERGY:
Line graph titled Linear Harmonic Oscillation plotting energy against time from 0 to 100 seconds, with y-axis in units of x10^6. Black Euler Method points rise steeply and exponentially to about 25 x10^6, while red Euler-Cromer and blue Runge-Kutta points stay nearly overlapping and rise roughly linearly to about 5 x10^6.


Unfortuantely the labels are hard to read from jpg format. But the Euler method= black, the euler-cromer = red = runge-kutta method = blue.

My question is this: I know that my linear harmonic oscillator graph for motion is correct. I have a feeling my energy calculation is wrong, which is why I am posting here.
My energy calculation for euler method seems consistent. The energy continues to grow, infinite energy! Which is the problem with the Euler method here.

But my energy calculation for Runge-kutta and Euler-cromer method, I would have thought, were supposed to be a constant.
Or is my interpretation wrong and my graph actually correct?
 
I am going to post my second problem as it is highly related:
For this code, I am graphing Ideal Motion (red), Motion with dampening (black) , and then motion with dampening and a driving force (blue).

The energy calculations should be the same from my initial post, which is why it is relevant.

As we see, the black energy curve flatlines, which seems consistent with the graph of its motion. However, should it be flatlining at the 1800 mark like it does, or at the 0 mark? That's confusing to me.

Similiarly, red and blue don't seem to be losing or gaining much energy in the graph of motion, but they shoot up linearly quite fast.
Three-panel plot: Motion shows angle in radians against time, Energy shows energy against time rising to a plateau near 1900, and Phase Space shows angular frequency against angle with spiral and circular orbits in red, blue and black.
 
I think I might have solved it while I was creating the post above!
I deleted a part of my code for my energy calculation, and I get this:
So the red curve we see a consistent energy which works with it's graph of motion.
The blue energy curve also works with the motion seen as at first it starts high then goes consistent.
The black curve now 0's out.

Looking good?

Three-panel plot of simulated motion with red, blue and black curves: Motion panel shows angle in rad against time in s, Energy panel shows energy against time, and Phase Space panel shows angular frequency against angle in rad.