Why Do Vectors Cause Issues in My Orbital Simulation?

  • Context: Undergrad 
  • Thread starter Thread starter exclamaforte
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around challenges faced in creating an orbital simulation for a computer science project, particularly focusing on the application of vector mathematics and the inverse square law in simulating orbital mechanics. Participants explore issues related to the shape of the orbits produced and the complexity of simulating multiple bodies.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant describes issues with their orbital simulation, noting that the particle's path resembles an isosceles triangle, suggesting potential problems with vector calculations.
  • Another participant provides a force equation for the simulation, indicating that the separation vector should be calculated based on the positions of the star and the particle.
  • A different participant suggests that the problem may lie in the display granularity of the simulation rather than the equations used, mentioning that other simulations yield smoother results with similar parameters.
  • One participant introduces the concept of the three-body problem, stating that simulations with more than two massive objects are particularly challenging.
  • Another participant counters this by arguing that from a simulation perspective, both two-body and three-body problems can be handled with simple integration techniques, though finding analytic solutions for arbitrary initial conditions is impossible.
  • A later reply emphasizes the importance of checking for conservation of energy in the simulation, suggesting that discrepancies in energy calculations may indicate errors in the implementation.

Areas of Agreement / Disagreement

Participants express differing views on the complexity of simulating multiple bodies, with some asserting that the three-body problem is difficult while others argue that it is manageable with appropriate techniques. The discussion remains unresolved regarding the specific cause of the issues in the original simulation.

Contextual Notes

Participants mention potential errors in code and the importance of energy conservation, but do not provide specific details on the assumptions or definitions that may affect the simulation's accuracy.

exclamaforte
Messages
3
Reaction score
0
Hello, I am attempting to make an orbital simulation for a final project in a computer science course. I have applied the inverse square law, and that seems to be working fine, but there is a problem with the vectors involved. I have the x component becoming negative when the particle's x value is greater than the sun's x value and vise versa for the y; but this configuration yields oblong orbits and sharp corners in the motion of the particle. The path of the particle ends up looking like a isosceles triangle, with the shorter side near the sun. If anyone knows the specific equations used in orbital simulators and can explain them, it would be much appreciated.
 
Astronomy news on Phys.org
You shouldn't need to be brute-forcing the equations like that, the force on a particle `i' should simply be
<br /> \vec{F} = G\frac{m_i M}{r^3}\cdot r_x + G\frac{m_i M}{r^3}\cdot r_y + G\frac{m_i M}{r^3}\cdot r_z<br />
where the separation vector
<br /> \vec{r} = \vec{R} - \vec{r}_i = (R_x - r_{i,x})\hat{x} + (R_y - r_{i,y})\hat{y} + (R_z - r_{i,z})\hat{z}<br />
For the star of mass 'M' and position 'R.'

Does that help?

Its hard to tell exactly what the problem you're having is based on just the triangular shape.
 
It helps a lot, thank you. I am using those equations, so I know they are not the problem now. I think it might be a problem with the granularity of the monitor. I've been looking at other sims with the same parameters, and they appear to give the same result, just displayed smoother. I'm thinking about just switching my problem if I can work it out soon. I still have a week or so, so it will be fine. Thanks for your help though.
 
Orbital simulations with more than two massive objects are incredibly difficult. It's called the 3 body problem.
 
Chronos said:
Orbital simulations with more than two massive objects are incredibly difficult. It's called the 3 body problem.

I disagree... from a simulation standpoint, there's really no difference between a two body problem and a three body problem, both are relatively trivial and can be performed on a laptop with very simple integration techniques (for 3-body euler's method would be fine, if a little slow).

The only thing difficult about the three body problem is finding analytic solutions to arbitrary initial configurations--but that's explicitly impossible.
 
exclamaforte said:
Hello, I am attempting to make an orbital simulation for a final project in a computer science course. I have applied the inverse square law, and that seems to be working fine, but there is a problem with the vectors involved. I have the x component becoming negative when the particle's x value is greater than the sun's x value and vise versa for the y; but this configuration yields oblong orbits and sharp corners in the motion of the particle. The path of the particle ends up looking like a isosceles triangle, with the shorter side near the sun. If anyone knows the specific equations used in orbital simulators and can explain them, it would be much appreciated.

Without seeing the code it's very hard to guess where the error is...i assume it's just some sort of typo error (y acceleration being changed instead of x, something like that)

One thing you should always do for orbital simulations is to let conservation of energy fall back out of the code. That is, at every step, calculate the kinetic energy of both components, and the potential well between them...that should stay constant - if it doesn't, then there's something wrong with the simulation.

~Lyuokdea
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 7 ·
Replies
7
Views
5K
Replies
13
Views
4K
Replies
33
Views
6K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 9 ·
Replies
9
Views
1K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K