Closed TimothySHamilton closed 4 years ago
Hi @TimothySHamilton, thanks for using poliastro and sorry for keeping you up late at night! I confirm I could reproduce both issues (which are in fact four, keep on reading) in my computer.
Quick workaround: do
from poliastro.twobody.propagation import kepler
orbit2=orbit1.propagate(1.*u.h, method=kepler)
This will change the default propagation method from mean_motion
to kepler
, which is also analytic and similar in nature.
The rest of the details are in #475.
I put "flips" between quotes because, as you noticed, this isn't just a sign change.
Quick workaround: do
from poliastro.twobody.propagation import cowell
orbit_moon_enter.propagate(0 * u.h, method=cowell)
The cowell
propagator is a numerical one and does not suffer from this "flipping" issue. It just will be a bit slower.
I didn't have time to properly debug this issue yet, but I'm sure it's related to the hyperbolic branch of mean_motion
, because this particular orbit has eccentricity of 1.00149526. When I have a proper analysis, I will open a separate issue.
Apart from the issue you experienced, while investigating it I also discovered #476 and #477.
@TimothySHamilton please keep us posted in case these workarounds do not work for you, or if you encounter further problems!
Hi @TimothySHamilton, would you confirm whether these workaround worked for you?
Hi, @Juanlu001—sorry it's taken me a week and a half; I was catching up with other work. I have just tried out your solution for both the Earth-centered and the Moon-centered cases, and it works. It's not even noticeably slower. Thanks!
The patched conics work now in going from the Earth (green, left) to the Moon (gray, right, with larger circle for its sphere of influence):
By the way, I've been plotting the trajectories here by propagating through several steps and plotting their values. Is there a better or faster way to do this?
Awesome, glad to know it's working!
For the time being you could use the .sample
method, which accepts a list of times among other things:
https://docs.poliastro.space/en/latest/safe.html#poliastro.twobody.orbit.Orbit.sample
However, except for the cowell
method, this is essentially propagating in a loop. Also, this API is subject to change in the following release, so I would say it's fine to do what you're doing.
If you ever want to share your code we can publish it one of the examples of the documentation:
https://docs.poliastro.space/en/latest/jupyter.html
If not, we could as well publish a success story:
https://docs.poliastro.space/en/latest/index.html#success-stories
And if nothing of the above is possible, I hope at least you allow me to use this beautiful image in the social networks! :)
@Juanlu001—I'd be honored to have it included as a code example, and you are also welcome to use it as a success story, and to use the image in the social networks. Thanks for the compliments! Let me clean up the code a little this weekend—given an input r & v near the Earth, it will output the spacecraft's r & v at pericynthion and draw a vector from the center of the moon to the spacecraft at that point. And I'll annotate the figure a little more.
If you'd like a bit more on the context, I'm making 3 or 4 programs using this code to plan out each leg of an Apollo 8-like flight, going from low earth orbit to lunar orbit and back. This is used for mission planning in the Apollo simulator that I've built for Shawnee State University, which the physics & engineering students are using in class. And we'll also use the state vectors it calculates to jump ahead in time during the simulation, skipping over the uneventful times in between maneuvers.
Where can I submit the code, an updated image, and any write-up on the context?
@TimothySHamilton thanks a lot, it sounds great! To publish the code you can use any service you want, although I would recommend https://github.com or https://gist.github.com/. We will then link it from here:
https://github.com/poliastro/poliastro/wiki/Projects-using-or-citing-poliastro
For the moment, I published your plot on Twitter :rocket:
Hi @TimothySHamilton! It's been a long time, perhaps you moved on, but just wanted to let you know that, after getting bitten by this from time to time over the past two years, and finally after two tireless weeks of coding, we have fixed this issue :tada: Thanks again for reporting it back in the day, and I encourage you to keep an eye on the upcoming poliastro 0.14, which is going to be :rocket: awesome :rocket:
🐞 Problem Orbit propagate hangs for some r, v vectors around Earth; flips vectors around Moon
When I propagate a orbit with certain initial r & v vectors around the Earth, the calculation hangs and will not let me stop it except by closing the terminal window. It seems to happen for velocity vectors that are at low speed (maybe <1 km/s or so) and pointing generally inward towards the Earth. For example, the following causes it to hang:
On the other hand, putting similar r, v vectors around the Moon doesn't hang, but propagation turns them in different directions. For example, given this r and v,
and defining an orbit around the moon:
gives
Now propagating it by time=0:
returns different vectors for r and v:
Interestingly, they have the same magnitude as the ones put into the orbit, but they point in different directions.
A couple of plots will make it a little clearer. I am using the propagation method to do patched conics for a physics classroom exercise to simulate the Apollo moon flights. I've plotted the Earth in green and the Moon in gray (small circle). The Moon's sphere of influence is the large gray circle. The spacecraft starts out in low earth orbit and moves out in a highly elliptical path (blue), where it enters the Moon's sphere of influence. I have transformed the final r and v into the Moon's frame (the Moon is not moving--I'm putting it at a fixed point), used them to define the new orbit around the Moon, and propatated it to pericynthion (red trajectory).
The first plot shows the entire scenario, and the second plot shows a close-up of the region around the Moon. Note that it's not a simple case of flipping the sign.
Is there a hack I can do myself to fix this temporarily?
🖥 Please paste the output of following commands
conda info -a
conda list
pip freeze | grep astropy
astropy==3.0.1 pytest-astropy==0.2.1pip freeze | grep poliastro
poliastro==0.11.0python -c "import poliastro.testing; poliastro.testing.test()"
🎯 Goal
💡 Possible solutions
📋 Steps to solve the problem
Addresses #<put issue number here>