Simple Energy Question based on SHM

  • Thread starter Thread starter RJLiberator
  • Start date Start date
  • Tags Tags
    Energy Shm
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
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:
motion.JPG


ENERGY:
energy.JPG


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?
 
Physics news on Phys.org
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.
3times.JPG
 
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?

captur3333.JPG