Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Added recursive series Kepler solver for elliptical orbits #1439

Merged
merged 27 commits into from
Jan 14, 2022

Conversation

JackCrusoe47
Copy link
Contributor

  • Added the series solution approximation for elliptical orbits.
  • Small correction to Danby code. Corrected nu to M for circular orbits as M = nu @ e=0

Currently, I only included the manual series solution, where the user provides the order of recursion (instead of tolerance).

Later, I can implement a hybrid variant that uses a lookup table to select appropriate order for a mean anomaly and eccentricity and then uses the initial guess for a Newton-Raphson. Here, the user will be able to specify a tolerance, and hopefully, the table provides an order of recursion that overall reduce the cost of computing the solution. I am currently having trouble with fast lookup.

Hope I didn't mess anything up with the pull request. I have never worked with Github.

Cheers

JackCrusoe47 and others added 5 commits January 14, 2022 17:23
Recursive series solution solver for elliptical Kepler's problem.
Added recSeries solver to propagation __init__ file.
Performed clean up corrections to the recursive solver
* removed numiter options were left in the previous commit
Corrected to simply the nu_to_M case for circular orbit (M=E=nu @ e=0)
@codecov
Copy link

codecov bot commented Jan 14, 2022

Codecov Report

Merging #1439 (b5b30f3) into main (9797eb0) will decrease coverage by 0.07%.
The diff coverage is 84.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1439      +/-   ##
==========================================
- Coverage   91.93%   91.85%   -0.08%     
==========================================
  Files          93       94       +1     
  Lines        4400     4444      +44     
  Branches      422      429       +7     
==========================================
+ Hits         4045     4082      +37     
- Misses        267      272       +5     
- Partials       88       90       +2     
Impacted Files Coverage Δ
src/poliastro/core/propagation/recseries.py 80.55% <80.55%> (ø)
src/poliastro/core/propagation/__init__.py 100.00% <100.00%> (ø)
src/poliastro/core/propagation/danby.py 96.49% <100.00%> (ø)
src/poliastro/twobody/propagation.py 92.30% <100.00%> (+0.55%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9797eb0...b5b30f3. Read the comment docs.

Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing @JackCrusoe47 ! That's what I call "from zero to hero" 😃 Good use of GitHub, nothing to worry about there.

I have a few minor requests:

  • Could you rename the module and function names to all_lowercase instead of camelCase? to keep consistency
  • Could you add your method here

ELLIPTIC_PROPAGATORS = [
farnocchia,
vallado,
mikkola,
markley,
pimienta,
gooding,
danby,
cowell,
]

so it gets tested automatically?

@JackCrusoe47
Copy link
Contributor Author

Thank you @astrojuanlu.

of course, I'll do the corrections right away. I also saw that two automatic tests are failing. Is it related to not adding my method in the tests, or would I need to modify anything further?

The tests that fail are:

  • codecov/patch
  • codecov/project

-Updated solver name to be more in line with project guidelines.
-Updated zero-order solution to E = M+e (Vallado) for improved convergence
@Yash-10
Copy link
Member

Yash-10 commented Jan 14, 2022

Wow! This seems to be a great addition. As the paper states,

Fast approximation of closest approach distance for co-planar orbits.

this approach could also be a good approach to check out for the satellite collision event #1350, isn't it?

pre-commit-ci bot and others added 8 commits January 14, 2022 15:25
Updated solver name to better be in line with project guidelines
Added recursive series propagator for elliptical Keplerian problem.
Corrected esle to else
Further spell errors and function names
@JackCrusoe47
Copy link
Contributor Author

JackCrusoe47 commented Jan 14, 2022

@Yash-10 A possible method could be to use recursive series to do a fast estimation. Then once a potential collision region is identified, more accurate methods like Newton-Raphson computes the precise distance and location.

P.S I apologize about the state of my commits. I still have not found a way to roll back my commits.

JackCrusoe47 and others added 3 commits January 14, 2022 22:22
fixed iteration method. tolerance for a given order varies for different M and ecc values.
Tolerance from given order computation.

Very approximate, but good for low to mid tolerance values and low eccentricities

order = 2 * floor( - log10( tolerance ) )
Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 tests have failed:

FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.9]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.99]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.999]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.9999]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.99999]

which means that, with eccentricities of 0.9 and higher, the method loses a bit of accuracy.

I assume this is how the method works, so I'll assist you in relaxing the tolerance for the tests without affecting the other methods.

@JackCrusoe47
Copy link
Contributor Author

5 tests have failed:

FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.9]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.99]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.999]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.9999]
FAILED tests/tests_twobody/test_propagation.py::test_elliptic_near_parabolic[recseries-0.99999]

which means that, with eccentricities of 0.9 and higher, the method loses a bit of accuracy.

I assume this is how the method works, so I'll assist you in relaxing the tolerance for the tests without affecting the other methods.

Unfortunately yes. The rate of convergence of the method drops to zero as the eccentricity becomes close to 1. In theory, it should work for cases up to 0.99 with a high enough order (say 20-30 for 0.99 for example). But for now the function I use to convert accuracy to order probably is underpredicting the order for 0.9 and 0.99.

@JackCrusoe47
Copy link
Contributor Author

JackCrusoe47 commented Jan 14, 2022

Well, I can make it work with a fixed tolerance instead of fixed recursion order. By adding three functions inside recseries.py

  • recseries_coe_order (user-specified order)
  • recseries_coe_rtol (user-specified rtol)
  • recseries (general solver able to work with both types)

JackCrusoe47 and others added 4 commits January 15, 2022 00:04
Compute eccentricity for recseries propagation
Updated rtol to order function
removed extra order = order =
Added ability to choose two different methods of series recursion termination
- fixed user-defined order as method='order'
- fixed user-defined tolerance as method='rtol'
pre-commit-ci bot and others added 6 commits January 14, 2022 19:31
run recseries through user-specified tolerance
Correction: [recseries_fast(k, r0, v0, tof, method='rtol', order=8, numiter=100, rtol) for tof in tofs]
Correction recseries call
@JackCrusoe47
Copy link
Contributor Author

All cases more or less should work now.

Now the recseries( ) solver can be called in the following two ways:

  • (rf,vf) = recseries(k, r0, v0, tof, method='order', order=12) # use a fixed 12th order recursive series
  • (rf,vf) = recseries(k, r0, v0, tof, method='rtol', rtol=1e-8) # recurse until a tolerance of 1e-8

This works the same for recseries_coe( )

Copy link
Member

@astrojuanlu astrojuanlu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Will merge when the tests pass 💪🏼

@JackCrusoe47
Copy link
Contributor Author

Perfect. Thank you.

@astrojuanlu
Copy link
Member

A small coverage difference is not worth blocking this PR 😉

@astrojuanlu astrojuanlu merged commit 7685305 into poliastro:main Jan 14, 2022
@astrojuanlu
Copy link
Member

Congratulations @JackCrusoe47 on your first contribution to poliastro! 🎉

@JackCrusoe47
Copy link
Contributor Author

Thank you @astrojuanlu for merging my commits 🚀. I am eager to see its use by the community. 😄

@JackCrusoe47 JackCrusoe47 deleted the add_recSeries branch January 15, 2022 03:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants