MATLAB - Motion of a body around a central one

  • Context: MATLAB 
  • Thread starter Thread starter MMS
  • Start date Start date
  • Tags Tags
    Body Matlab Motion
Click For Summary
SUMMARY

This discussion focuses on the implementation of the ode45 function in MATLAB to simulate the motion of a body around a central mass, specifically addressing the conservation of energy and angular momentum. The user achieves a relative error of approximately 1e-8% for energy over 50 periods but struggles with a constant angular momentum error of 11.36%, which remains unaffected by changes in relative and absolute tolerances or step size. Suggestions include exploring the Verlet method as an alternative to the Runge-Kutta method, which is known for energy error divergence in long-term periodic orbits.

PREREQUISITES
  • Familiarity with MATLAB programming and the ode45 function
  • Understanding of numerical methods, specifically the Runge-Kutta method
  • Knowledge of orbital mechanics and conservation laws (energy and angular momentum)
  • Experience with error analysis in numerical simulations
NEXT STEPS
  • Research the Verlet method for simulating periodic orbits in MATLAB
  • Explore advanced ode solvers in MATLAB that enforce energy conservation
  • Investigate techniques for reducing angular momentum error in numerical simulations
  • Learn about adaptive step size control in numerical integration methods
USEFUL FOR

This discussion is beneficial for MATLAB users, physicists, and engineers involved in orbital mechanics simulations, particularly those seeking to improve the accuracy of numerical methods in long-term simulations.

MMS
Messages
146
Reaction score
4
Hello everyone,

I've written a code using ode45 which describes the motion of a body m around a central one M (e.g a satellite around earth). I've done it with initial values that set the trajectory of the particle to be elliptic.

Clearly, energy and angular momentum need be conserved in this and so I get. However, I'm looking to reduce the error as much as possible and get a more accurate solution.

For the energy, I've managed to get a really small one using the relative and absolute tolerance. For example, for some parameters of RelTol and AbsTol, the relative error can reach a maximum value of about ~1e-8% only for 50 periods. However, the relative error in angular momentum doesn't seem to be affected by whatever I set the RelTol and AbsTol to be and the maximum value that it reaches (it is periodic, see the graph below) is constant at 11.36%.

I've already tried playing with the step size as well and it doesn't seem to affect it.

You can see two images below that describe the energy and angular momentum in 50 periods. The y-axis describes the relative error (not in percentage) in each parameter and the x-axis describes the number of periods (50 in this case).

Does anyone have any suggestion as to how to control and diminish the relative error in angular momentum?

Thanks in advance.

ptp5dPz.jpg

olFVQ7A.jpg
 
Physics news on Phys.org
I think that function uses the Runge-Kutta Method. The Runge-Kutta method is prone to energy error divergence at a long timescale when the true orbit should be periodic. The Verlet method allows bounded error in energy for periodic orbits. I am not sure if using Verlet instead would lead to better angular momentum error. I am not sure about the issue you are having with angular momentum error or how to improve it except smaller step size.

I am also wondering about ode solvers which might be able to enforce constraints like conserved energy somehow.
 
MisterX said:
I think that function uses the Runge-Kutta Method. The Runge-Kutta method is prone to energy error divergence at a long timescale when the true orbit should be periodic. The Verlet method allows bounded error in energy for periodic orbits. I am not sure if using Verlet instead would lead to better angular momentum error. I am not sure about the issue you are having with angular momentum error or how to improve it except smaller step size.

I am also wondering about ode solvers which might be able to enforce constraints like conserved energy somehow.

It does use the Runge-Kutta method and you can see from the results that the error in energy is very small so I don't really have a problem with that.
However, the angular momentum stays the same regardless of the step size I take...
 

Similar threads

  • · Replies 13 ·
Replies
13
Views
5K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
10K