[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orekit Developers] unnecessary "for" loops in "org.orekit.propagation.analytical.tle" ?



Hello Gavin,

The Deep Space code is complex by itself, and myself reported a bug in the Deep Space Orekit routine sometime ago which I found by visual inspection. I did not check as deep as you now, but I would not be surprised if other problems were there.

Not quite related to your question, but as you are trying with Swift, which I think is similar to Scala, I like to tell you for that I ported to Scala the low earth orbit part of the SGP4 algorithm some time ago using mostly Vallado's implementation. I have this code in github as SGP4Extensions.

https://github.com/pleira/SGP4Extensions/

At least, it can give you a hint on coding using functional paradigms for the low earth orbit part of SGP4.

Pablo Pita


On Wed, May 31, 2017 at 1:16 AM, Gavin Eadie <gavin+orekit@umich.edu> wrote:
The package "org.orekit.propagation.analytical.tle" is a Java implementation
of the algorithms described in the paper "Revisiting Spacetrack Report #3
(AIAA 2006-6753)."  I am using the Orekit implementation as a partial basis
for a re-coding of those algorithms in Swift.

That requires me to look closely at conversions involving language constructs
that are available in Java but not in Swift.  One of these is the "for
( ; ; )" control statement, and I've tripped over a usage in Orekit that seems
odd .. it’s computationally correct, but unnecessarily complicated.  In the
file DeepSDP4.java, a constant is defined:

                private static final int SECULAR_INTEGRATION_ORDER = 2;

   and later in that same file, two loops of the following form:

                for (int j = 0; j < SECULAR_INTEGRATION_ORDER; j += 2) {
                        derivs[j]     = term1a + term2a;
                        derivs[j + 1] = term1b + term2b;
                        if ((j + 2) < SECULAR_INTEGRATION_ORDER)  {
                                term1a  = -term1a;
                                term2a *= -4.0;
                                term1b  = -term1b;
                                term2b *= -4.0;
                        }
                }

   as I read this, the "for" loop will only execute once (with j = 0), and the
contained "if" condition will never be true.  That reduces the above code to:

                derivs[0] = term1a + term2a;
                derivs[1] = term1b + term2b;

   to check this, I made this (and one other similar near-by) change and re-
ran the unit tests with no failure.

There is one more "for" loop that will execute only once (with j = 2):

                for (int j = 2; j <= SECULAR_INTEGRATION_ORDER; ++j) {
                        xlpow *= xldot;
                        derivs[j - 1] *= xlpow;
                        delt_factor *= delt / (double) j;
                        xli += delt_factor * derivs[j - 2];
                        xni += delt_factor * derivs[j - 1];
                }


Am I being incredibly stupid and missing something obvious?



--
Pablo Pita Leira