JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for STARDEV Archives


STARDEV Archives

STARDEV Archives


STARDEV@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

STARDEV Home

STARDEV Home

STARDEV  September 2005

STARDEV September 2005

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Numeric instability

From:

Patrick Wallace <[log in to unmask]>

Reply-To:

Starlink development <[log in to unmask]>

Date:

Fri, 2 Sep 2005 19:03:25 +0100

Content-Type:

TEXT/PLAIN

Parts/Attachments:

Parts/Attachments

TEXT/PLAIN (242 lines)

Tim:


Give the appended version of sla_UE2PV a go.  Changes:

* Newton's method for solving Everhart & Pitkin expression (17) is
  now damped 50% first time through.

* Number of iterations increased by 1 (for neatness as it was in fact
  stopping one iteration short of the stated number).

The code correctly implements the Everhart & Pitkin procedure, but there
is clearly some lingering scope for incipient instability.  The damping
fixes your example, but I wouldn't like to guarantee that the solution is
universal.


Patrick Wallace
____________________________________________________________________________
SSTD/HMNAO                                   Internet:  [log in to unmask]
Rutherford Appleton Laboratory                    Tel:       +44-1235-445372
Chilton, Didcot,                                  Fax:       +44-1235-446362
Oxon OX11 0QX, UK
____________________________________________________________________________

      SUBROUTINE sla_UE2PV (DATE, U, PV, JSTAT)
*+
*     - - - - - -
*      U E 2 P V
*     - - - - - -
*
*  Heliocentric position and velocity of a planet, asteroid or comet,
*  starting from orbital elements in the "universal variables" form.
*
*  Given:
*     DATE     d       date, Modified Julian Date (JD-2400000.5)
*
*  Given and returned:
*     U        d(13)   universal orbital elements (updated; Note 1)
*
*       given    (1)   combined mass (M+m)
*         "      (2)   total energy of the orbit (alpha)
*         "      (3)   reference (osculating) epoch (t0)
*         "    (4-6)   position at reference epoch (r0)
*         "    (7-9)   velocity at reference epoch (v0)
*         "     (10)   heliocentric distance at reference epoch
*         "     (11)   r0.v0
*     returned  (12)   date (t)
*         "     (13)   universal eccentric anomaly (psi) of date
*
*  Returned:
*     PV       d(6)    position (AU) and velocity (AU/s)
*     JSTAT    i       status:  0 = OK
*                              -1 = radius vector zero
*                              -2 = failed to converge
*
*  Notes
*
*  1  The "universal" elements are those which define the orbit for the
*     purposes of the method of universal variables (see reference).
*     They consist of the combined mass of the two bodies, an epoch,
*     and the position and velocity vectors (arbitrary reference frame)
*     at that epoch.  The parameter set used here includes also various
*     quantities that can, in fact, be derived from the other
*     information.  This approach is taken to avoiding unnecessary
*     computation and loss of accuracy.  The supplementary quantities
*     are (i) alpha, which is proportional to the total energy of the
*     orbit, (ii) the heliocentric distance at epoch, (iii) the
*     outwards component of the velocity at the given epoch, (iv) an
*     estimate of psi, the "universal eccentric anomaly" at a given
*     date and (v) that date.
*
*  2  The companion routine is sla_EL2UE.  This takes the conventional
*     orbital elements and transforms them into the set of numbers
*     needed by the present routine.  A single prediction requires one
*     one call to sla_EL2UE followed by one call to the present routine;
*     for convenience, the two calls are packaged as the routine
*     sla_PLANEL.  Multiple predictions may be made by again
*     calling sla_EL2UE once, but then calling the present routine
*     multiple times, which is faster than multiple calls to sla_PLANEL.
*
*     It is not obligatory to use sla_EL2UE to obtain the parameters.
*     However, it should be noted that because sla_EL2UE performs its
*     own validation, no checks on the contents of the array U are made
*     by the present routine.
*
*  3  DATE is the instant for which the prediction is required.  It is
*     in the TT timescale (formerly Ephemeris Time, ET) and is a
*     Modified Julian Date (JD-2400000.5).
*
*  4  The universal elements supplied in the array U are in canonical
*     units (solar masses, AU and canonical days).  The position and
*     velocity are not sensitive to the choice of reference frame.  The
*     sla_EL2UE routine in fact produces coordinates with respect to the
*     J2000 equator and equinox.
*
*  5  The algorithm was originally adapted from the EPHSLA program of
*     D.H.P.Jones (private communication, 1996).  The method is based
*     on Stumpff's Universal Variables.
*
*  Reference:  Everhart, E. & Pitkin, E.T., Am.J.Phys. 51, 712, 1983.
*
*  P.T.Wallace   Starlink   19 March 1999
*
*  Copyright (C) 1999 Rutherford Appleton Laboratory
*-

      IMPLICIT NONE

      DOUBLE PRECISION DATE,U(13),PV(6)
      INTEGER JSTAT

*  Gaussian gravitational constant (exact)
      DOUBLE PRECISION GCON
      PARAMETER (GCON=0.01720209895D0)

*  Canonical days to seconds
      DOUBLE PRECISION CD2S
      PARAMETER (CD2S=GCON/86400D0)

*  Test value for solution and maximum number of iterations
      DOUBLE PRECISION TEST
      INTEGER NITMAX
      PARAMETER (TEST=1D-13,NITMAX=20)

      INTEGER I,NIT,N

      DOUBLE PRECISION CM,ALPHA,T0,P0(3),V0(3),R0,SIGMA0,T,PSI,DT,W,
     :                 TOL,PSJ,PSJ2,BETA,S0,S1,S2,S3,FF,R,F,G,FD,GD



*  Unpack the parameters.
      CM = U(1)
      ALPHA = U(2)
      T0 = U(3)
      DO I=1,3
         P0(I) = U(I+3)
         V0(I) = U(I+6)
      END DO
      R0 = U(10)
      SIGMA0 = U(11)
      T = U(12)
      PSI = U(13)

*  Approximately update the universal eccentric anomaly.
      PSI = PSI+(DATE-T)*GCON/R0

*  Time from reference epoch to date (in Canonical Days: a canonical
*  day is 58.1324409... days, defined as 1/GCON).
      DT = (DATE-T0)*GCON

*  Refine the universal eccentric anomaly.
      NIT = 1
      W = 1D0
      TOL = 0D0
      DO WHILE (ABS(W).GE.TOL)

*     Form half angles until BETA small enough.
         N = 0
         PSJ = PSI
         PSJ2 = PSJ*PSJ
         BETA = ALPHA*PSJ2
         DO WHILE (ABS(BETA).GT.0.7D0)
            N = N+1
            BETA = BETA/4D0
            PSJ = PSJ/2D0
            PSJ2 = PSJ2/4D0
         END DO

*     Calculate Universal Variables S0,S1,S2,S3 by nested series.
         S3 = PSJ*PSJ2*((((((BETA/210D0+1D0)
     :                      *BETA/156D0+1D0)
     :                      *BETA/110D0+1D0)
     :                      *BETA/72D0+1D0)
     :                      *BETA/42D0+1D0)
     :                      *BETA/20D0+1D0)/6D0
         S2 = PSJ2*((((((BETA/182D0+1D0)
     :                  *BETA/132D0+1D0)
     :                  *BETA/90D0+1D0)
     :                  *BETA/56D0+1D0)
     :                  *BETA/30D0+1D0)
     :                  *BETA/12D0+1D0)/2D0
         S1 = PSJ+ALPHA*S3
         S0 = 1D0+ALPHA*S2

*     Undo the angle-halving.
         TOL = TEST
         DO WHILE (N.GT.0)
            S3 = 2D0*(S0*S3+PSJ*S2)
            S2 = 2D0*S1*S1
            S1 = 2D0*S0*S1
            S0 = 2D0*S0*S0-1D0
            PSJ = PSJ+PSJ
            TOL = TOL+TOL
            N = N-1
         END DO

*     Improve the approximation to PSI (damped 1st time through).
         FF = R0*S1+SIGMA0*S2+CM*S3-DT
         R = R0*S0+SIGMA0*S1+CM*S2
         IF (R.EQ.0D0) GO TO 9010
         W = FF/R
         IF (NIT.LT.2) W=W/2d0
         PSI = PSI-W

*     Next iteration, unless too many already.
         IF (NIT.GT.NITMAX) GO TO 9020
         NIT = NIT+1
      END DO

*  Project the position and velocity vectors (scaling velocity to AU/s).
      W = CM*S2
      F = 1D0-W/R0
      G = DT-CM*S3
      FD = -CM*S1/(R0*R)
      GD = 1D0-W/R
      DO I=1,3
         PV(I) = P0(I)*F+V0(I)*G
         PV(I+3) = CD2S*(P0(I)*FD+V0(I)*GD)
      END DO

*  Update the parameters to allow speedy prediction of PSI next time.
      U(12) = DATE
      U(13) = PSI

*  OK exit.
      JSTAT = 0
      GO TO 9999

*  Null radius vector.
 9010 CONTINUE
      JSTAT = -1
      GO TO 9999

*  Failed to converge.
 9020 CONTINUE
      JSTAT = -2

 9999 CONTINUE
      END

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
January 2023
December 2022
July 2022
June 2022
April 2022
March 2022
December 2021
October 2021
July 2021
April 2021
January 2021
October 2020
September 2020
August 2020
May 2020
November 2019
October 2019
July 2019
June 2019
February 2019
January 2019
December 2018
November 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
December 2017
October 2017
August 2017
July 2017
May 2017
April 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
October 2015
September 2015
August 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
2004
April 2003
2003


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager