hannorein / rebound

💫 An open-source multi-purpose N-body code.
https://rebound.readthedocs.io/
GNU General Public License v3.0
846 stars 219 forks source link

True anomalies #673

Closed kmar124 closed 1 year ago

kmar124 commented 1 year ago

Hello,

I am trying to simulate systems of 2 to 8 planets orbiting around solar mass stars. I want to have a random uniform distribution of their true anomalies (f) as an initial condition. However, every time that I use the reb_tools_particle_to_orbit function, it gives me a true anomaly that is either 0 or pi most of the time. I have found that this results from an error that arises when this function determines the longitude of pericenter (pomega). This value is used to determine f (o.f = o.theta - o.pomega), and so it changed regardless of my input values. Here is the part of the code that shows this: FILE *f char line[100] while(strlen(fgets(line, 100, f)) !=2){ sscanf(line,"%lf %lf %lf", &period, &axis, &anomaly); reb_add_fmt(r, "m r P f e pomega primary", mplan, rplan, period, anomaly, 0., 0., star); printf("%f %f %f\n", period, axis, anomaly); } for(int i=1;i<r->N;i++){ struct reb_orbit o = reb_tools_particle_to_orbit(r->G, r->particles[i], r->particles[0]); printf("%f %f %f %f %f \n", o.P, o.a, o.f, o.theta, o.pomega); }

Here, I am reading the values in a file that contains a randomized distribution of true anomalies among other orbital parameters. A planetary system could have the following input: 47.301364 0.255974 3.777082 120.271258 0.476856 5.864888 211.003465 0.693648 1.136180 where the 3rd number of every line is the true anomaly. However, even with a non-zero input for f and inputting 0 for pomega, once reb_tools_particle_to_orbit is used, these change to the following: 47.301364 0.255974 3.141593 3.777082 0.635489 120.271258 0.476857 4.712389 5.864888 1.152499 211.003465 0.693649 3.141593 1.136180 -2.005413 where the 3rd, 4th, and 5th numbers of each line represent the true anomaly (f), theta, and pomega respectively. I used reb_add_fmt in this example, but this happens regardless of the input method I use. It only seems to happen to the true anomalies. Can someone explain this? Is there a way around this?

hannorein commented 1 year ago

Is it possible that you have an orbit with (almost) zero eccentricity? Then some orbital parameters are not well defined.

hannorein commented 1 year ago

Closed due to inactivity.