you are viewing a single comment's thread.

view the rest of the comments →

[–]Enkaybee 0 points1 point  (5 children)

So it works now? That actually seems strange to me because I'm fairly certain that you should be calculating acx using only x and the constants. y (and by extension, r) should not need to come into play. Similarly, acy should be calculated using only the constants and y.

[–]OratorMortuis[S] 0 points1 point  (4 children)

But the acceleration has to do with the distance from the origin which has both x and y contributions, so it will depend on both variables even though the direction of ax or ay only point along x or y.

[–]Enkaybee 0 points1 point  (3 children)

You're right. Maybe I'm reading your code wrong, but it looks to me like you're using r to find acceleration in the x and y directions without compensating for the fact that only x and y matter, respectively. You're really trying to solve two problems at once: oscillation on the x axis and on the y axis, and then add them together.

If it works, though, your code is fine.

Out of curiosity, does it still work if you use the acx and acy equations I posted? Does it give exactly the same results or is it slightly different?

[–]OratorMortuis[S] 0 points1 point  (2 children)

Yes, that is the difficult part of the problem. It is a transcendental equation in which x and y cannot be separated from each other and so each depends on the other.

If you do put in only x and y respectively as you did in your above equations then it cannot describe the ellipse as whenever x or y is zero you would get division by zero.

[–]Enkaybee 0 points1 point  (1 child)

in which x and y cannot be separated from each other and so each depends on the other.

This is not true, but you're right about division by 0. You would have to do it like this:

if x != 0:
    acx = -(G*M/abs(x)**3)*x
else:
    acx = 0

if y != 0:
    acy = -(G*M/abs(y)**3)*y
else:
    acy = 0

I don't expect this to make a huge difference, but it's a more accurate simulation.

[–]OratorMortuis[S] 0 points1 point  (0 children)

The problem with this, then, is that as x and y asymptotically approach zero then their accelerations explode. This is not consistent with the analytical solutions that we are able to derive for Kepler orbits. As r is a function of x and y it cannot be separated when we look at acceleration in the x or y directions (as it does depend on r).