The order of calculating velocity and position alters the solution?

Click For Summary
The discussion focuses on the impact of calculation order in Euler's Algorithm for a spring-mass system, specifically how it affects energy conservation in simulations. Two cases were tested: the first updates position before velocity, leading to increasing energy, while the second updates velocity first, resulting in oscillating energy values. Participants noted that the order of updates influences the accuracy and behavior of the simulation, with the second case exhibiting less error despite being deemed "incorrect." The conversation highlights the importance of simultaneous updates in numerical methods and suggests exploring alternative algorithms like the leap-frog method for better energy conservation. Ultimately, the nuances of numerical integration and error propagation are central to understanding the observed discrepancies in energy behavior.
  • #31
TachyonLord said:
Thank you so much for your suggestion. I appreciate it a lot ! :) By the way, what is the maximum error for this algorithm ?
But I still kinda want to know about the reason for energy having these little disturbances. Thanks again :)
For this scheme, the error is going to be on the order of ##(\Delta t)^2##, compared to ##\Delta t## for the forward Euler scheme.

The explicit difference equations are going to be $$v(t+\Delta t)=\frac{1-(\pi \Delta t)^2}{1+(\pi \Delta t)^2}v(t)-\frac{4\pi^2\Delta t}{1+(\pi \Delta t)^2}x(t)$$
$$x(t+\Delta t)=\frac{\Delta t }{1+(\pi \Delta t)^2}v(t)+\frac{1-(\pi \Delta t)^2}{1+(\pi \Delta t)^2}x(t)$$

Try it. You'll like it.
 
  • Like
Likes TachyonLord
Physics news on Phys.org
  • #32
Have you tried this difference scheme yet? You will find that it exactly conserves energy with no discretization error (and only tiny roundoff error). You will also find that this scheme is much more accurate than forward Euler, for equal values of the time step.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
13
Views
2K
Replies
2
Views
939
  • · Replies 17 ·
Replies
17
Views
1K
Replies
40
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 6 ·
Replies
6
Views
2K