Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UNOPTIMIZED] Sims-Flanagan High-Fidelity Leg Feature #38

Merged
merged 24 commits into from
Nov 14, 2024

Conversation

sbcow
Copy link
Collaborator

@sbcow sbcow commented Oct 18, 2024

Contents

  • This PR adds the capability of a user to model a Sims-Flanagan leg with a higher fidelity model; specifically, the thrust is now represented by a continuous and constant thrust per segment. The integration is done using a Taylor-adaptive integrator from Heyoka.
  • This PR includes testing, the Python API, documentation, plotting functionality, and benchmarks.
  • The functionality is unoptimized; the benchmark of the lower and higher fidelity model shows:

Lower fidelity model

Computes the same analytical and numerical gradients and tests for speed:
5 nseg - timing: analytical 0.041078 - numerical 0.09194
10 nseg - timing: analytical 0.078556 - numerical 0.282018
15 nseg - timing: analytical 0.12666399999999997 - numerical 0.5756969999999999
20 nseg - timing: analytical 0.17625000000000005 - numerical 0.957421
70 nseg - timing: analytical 1.0853019999999995 - numerical 10.098478

Higher fidelity model

Computes the same analytical and numerical gradients and tests for speed:
5 nseg - timing: analytical 4.063857 - numerical 117.57327499999998
10 nseg - timing: analytical 4.674794000000002 - numerical 242.16195299999998
JIT session error: Cannot allocate memory
terminate called after throwing an instance of 'std::invalid_argument'
  what():  Could not find the symbol 'd_out_f' in the compiled module

Sean Cowan and others added 15 commits September 18, 2024 17:44
…ch and throttle constraint gradients with accompanying tests. Minor fixes.
…include various segment counts and cut ratios. Small formatting fixes.
… fix with setting throttles. Resolved minor compiler complaints.
Copy link

codecov bot commented Oct 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.20%. Comparing base (285a825) to head (4870cdd).
Report is 25 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
+ Coverage   98.10%   98.20%   +0.09%     
==========================================
  Files          30       33       +3     
  Lines        1798     2116     +318     
==========================================
+ Hits         1764     2078     +314     
- Misses         34       38       +4     
Files with missing lines Coverage Δ
include/kep3/leg/sims_flanagan.hpp 100.00% <100.00%> (ø)
include/kep3/leg/sims_flanagan_hf.hpp 100.00% <100.00%> (ø)
src/core_astro/propagate_lagrangian.cpp 97.69% <100.00%> (-0.76%) ⬇️
src/leg/sf_checks.cpp 100.00% <100.00%> (ø)
src/leg/sims_flanagan.cpp 98.14% <100.00%> (-0.37%) ⬇️
src/leg/sims_flanagan_hf.cpp 100.00% <100.00%> (ø)
src/ta/stark.cpp 100.00% <ø> (ø)

... and 15 files with indirect coverage changes

benchmark/leg_sims_flanagan_hf_udp_bench.hpp Show resolved Hide resolved
include/kep3/leg/sf_checks.hpp Show resolved Hide resolved
include/kep3/leg/sims_flanagan_hf.hpp Outdated Show resolved Hide resolved
include/kep3/leg/sims_flanagan_hf.hpp Outdated Show resolved Hide resolved
include/kep3/leg/sims_flanagan_hf.hpp Outdated Show resolved Hide resolved
include/kep3/leg/sims_flanagan_hf.hpp Show resolved Hide resolved
include/kep3/leg/sims_flanagan_hf.hpp Outdated Show resolved Hide resolved
include/kep3/leg/sims_flanagan_hf.hpp Outdated Show resolved Hide resolved
@sbcow
Copy link
Collaborator Author

sbcow commented Nov 4, 2024

With the latest commit, I hope that this PR can be merged or at least reviewed in its entirety; the benchmark now performs more in line with expectations. The HF method is still slower by a factor of almost 20 for 5 segment legs with the analytical gradient, however, this improves for more legs to only a factor of 5. The numerical gradient is slower by a factor of 5 and improves to a factor of 2 for more legs. Below is the updated output of the benchmarks:

Lower fidelity method

Computes the same analytical and numerical gradients and tests for speed:
5 nseg - timing: analytical 0.079302 - numerical 0.37446699999999994
10 nseg - timing: analytical 0.11105100000000001 - numerical 0.8789960000000002
20 nseg - timing: analytical 0.19491599999999992 - numerical 2.4924320000000013
40 nseg - timing: analytical 0.4830399999999998 - numerical 9.198903

Solves the same optimization problems with and without analytical gradients:
xx........xx.....^[.......................xxxx................xx..xx................xx....xx....xx......................xx....xx................xxxxxxxx............................xx..........xx..xx....
5 nseg - success rates: analytical 82/100 - numerical 82/100
..........xx............................xxxx....................xx................xx..........xx......................xx....xx................xxxxxxxx............................xx..........xx..xx....
10 nseg - success rates: analytical 85/100 - numerical 85/100
..........xx..............x.....x.......xxxx....................xx................xx..........xx......................xx....xx................xxxxxxxx............................xx..........xx..xx....
15 nseg - success rates: analytical 83/100 - numerical 85/100

Higher fidelity method

Computes the same analytical and numerical gradients and tests for speed:
5 nseg - timing: analytical 1.419368 - numerical 1.5734220000000003
10 nseg - timing: analytical 1.5456520000000007 - numerical 3.0710530000000005
20 nseg - timing: analytical 1.7754720000000004 - numerical 6.831982999999997
40 nseg - timing: analytical 2.3899 - numerical 18.493235999999992

Solves the same optimization problems with and without analytical gradients:
..........xx............................xxxx................xx..xx................xx..........xx......................xx....xx........xx......xxxxxxxx............................xx..........xx..xx....
5 nseg - success rates: analytical 83/100 - numerical 83/100
..........xx............................xxxx....................xx................xx..........xx......................xx....xx................xxxxxxxx............................xx..........xx..xx....
10 nseg - success rates: analytical 85/100 - numerical 85/100
..........xx................x...........xxxx....................xx................xx..........xx......................xx....xx................xxxxxxxx............................xx..........xx..xx....
15 nseg - success rates: analytical 84/100 - numerical 85/100

@darioizzo darioizzo merged commit ad30054 into esa:main Nov 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants