question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Propagating long times does not converge

See original GitHub issue

🐞 Problem

Propagating long times fails in different ways:

In [5]: iss.propagate(100 * u.year)
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-27-503eb53e62e7> in <module>()
----> 1 iss.propagate(100 * u.year)

~/Personal/poliastro/poliastro-library/src/poliastro/twobody/orbit.py in propagate(self, epoch_or_duration, rtol)
    245             time_of_flight = time.TimeDelta(epoch_or_duration)
    246 
--> 247         return propagate(self, time_of_flight, rtol=rtol)
    248 
    249     def sample(self, *, num_points=None, time_values=None):

~/Personal/poliastro/poliastro-library/src/poliastro/twobody/propagation.py in propagate(orbit, time_of_flight, method, rtol, **kwargs)
    156                   time_of_flight.to(u.s).value,
    157                   rtol=rtol,
--> 158                   **kwargs)
    159     return orbit.from_vectors(orbit.attractor, r * u.km, v * u.km / u.s, orbit.epoch + time_of_flight)
    160 

~/Personal/poliastro/poliastro-library/src/poliastro/twobody/propagation.py in kepler(k, r0, v0, tof, rtol, numiter)
    139     f, g, fdot, gdot = _kepler(k, r0, v0, tof, numiter, rtol)
    140 
--> 141     assert np.abs(f * gdot - fdot * g - 1) < 1e-5  # Fixed tolerance
    142 
    143     # Return position and velocity vectors

AssertionError: 

In [6]: halleys[0].propagate(73 * u.year)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-26-9dcacad8e904> in <module>()
----> 1 halleys[0].propagate(73 * u.year)

~/Personal/poliastro/poliastro-library/src/poliastro/twobody/orbit.py in propagate(self, epoch_or_duration, rtol)
    245             time_of_flight = time.TimeDelta(epoch_or_duration)
    246 
--> 247         return propagate(self, time_of_flight, rtol=rtol)
    248 
    249     def sample(self, *, num_points=None, time_values=None):

~/Personal/poliastro/poliastro-library/src/poliastro/twobody/propagation.py in propagate(orbit, time_of_flight, method, rtol, **kwargs)
    156                   time_of_flight.to(u.s).value,
    157                   rtol=rtol,
--> 158                   **kwargs)
    159     return orbit.from_vectors(orbit.attractor, r * u.km, v * u.km / u.s, orbit.epoch + time_of_flight)
    160 

~/Personal/poliastro/poliastro-library/src/poliastro/twobody/propagation.py in kepler(k, r0, v0, tof, rtol, numiter)
    137     """
    138     # Compute Lagrange coefficients
--> 139     f, g, fdot, gdot = _kepler(k, r0, v0, tof, numiter, rtol)
    140 
    141     assert np.abs(f * gdot - fdot * g - 1) < 1e-5  # Fixed tolerance

RuntimeError: Maximum number of iterations reached

🎯 Goal

One thing is that the long term errors of propagation are big. But nonetheless, the propagator should always give an answer, instead of an internal error (at least for a full period, see the failure of the Halley’s comet). I wonder if this is possible at all?

💡 Possible solutions

The propagator of poliastro uses the universal variables approach, which is popular but has several limitations. Perhaps for long propagation times it should be replaced with a Newton-Raphson iteration and a good starting point as suggested by http://dx.doi.org/10.1007/s10569-013-9476-9.

📋 Steps to solve the problem

  • Comment below about what you’ve started working on.
  • Add, commit, push your changes
  • Submit a pull request and add this in comments - Addresses #<put issue number here>
  • Ask for a review in comments section of pull request
  • Celebrate your contribution to this project 🎉

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nikita-astronautcommented, Feb 22, 2018

Well, I realized there is no need to find the pericenter passage time. The rv2coe gives current true anomaly $\nu(t_0)$, which can be recalculated into current mean anomaly $M(t_0)$. Then, I recall that mean anomaly grows linearly with time, which gives me mean anomaly at the time $t_0 + \Deltat$: $M(t_0 + \Delta t) = M(t_0) + \sqrt{\mu (1 - e)^3 / q^3} \Delta t$. As I have $M(t_0 + \Delta t)$, I iteratively solve $E - e \sin E = M$, get $\nu$ (this is actually already implemented within M_to_nu) and thus new r, v.

I think I’ll do it this way.

0reactions
astrojuanlucommented, Jul 21, 2018

Notice that the original convergence issues of kepler were addressed in #362.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Neural network model does not converge - Cross Validated
See the answer to this question. Therefore the higher the rep , the longer it will take. You should increase the stepmax to...
Read more >
Is there any concrete example which demonstrates that loopy ...
In terms of practice, no they don't always converge. On small problems, they sometimes converge and sometimes don't. On large problems, like modeling ......
Read more >
In backpropogation, what does it mean when the error of a ...
If I loop over a single data point instead of the entire learning set, it does converge to zero error for that particular...
Read more >
Accelerating the convergence of the back-propagation method
Unfortunately, in many applications, the number of iterations required before convergence can be large. Modifications to the back-propagation ...
Read more >
Improving convergence of transient models - Knowledge Base
If the time-dependent solver fails to converge it will either fail immediately, at the initial conditions, or it will fail at some point...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found