Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
real*8 a0,a1,a3,a5,a7,a9,a11
real*8 b1,b3,b5,b7,b9,b11
PARAMETER (IMAX = 10)
PARAMETER (a11 = 156.d0,a9 = 17160.d0,a7 = 1235520.d0)
PARAMETER (a5 = 51891840.d0,a3 = 1037836800.d0)
PARAMETER (b11 = 11.d0*a11,b9 = 9.d0*a9,b7 = 7.d0*a7)
PARAMETER (b5 = 5.d0*a5, b3 = 3.d0*a3)
c----
c... Executable code
c Function to solve "Kepler's eqn" for F (here called
c x) for given e and CAPN. Only good for smallish CAPN
iflag = 0
if( capn .lt. 0.d0) then
iflag = 1
capn = -capn
endif
a1 = 6227020800.d0 * (1.d0 - 1.d0/e)
a0 = -6227020800.d0*capn/e
b1 = a1
c Set iflag nonzero if capn < 0., in which case solve for -capn
c and change the sign of the final answer for F.
c Begin with a reasonable guess based on solving the cubic for small F
a = 6.d0*(e-1.d0)/e
b = -6.d0*capn/e
sq = sqrt(0.25*b*b +a*a*a/27.d0)
biga = (-0.5*b + sq)**0.3333333333333333d0
bigb = -(+0.5*b + sq)**0.3333333333333333d0
x = biga + bigb
c write(6,*) 'cubic = ',x**3 +a*x +b
orbel_flon = x
c If capn is tiny (or zero) no need to go further than cubic even for
c e =1.
if( capn .lt. TINY) go to 100
do i = 1,IMAX
x2 = x*x
f = a0 +x*(a1+x2*(a3+x2*(a5+x2*(a7+x2*(a9+x2*(a11+x2))))))
fp = b1 +x2*(b3+x2*(b5+x2*(b7+x2*(b9+x2*(b11 + 13.d0*x2)))))
dx = -f/fp
c write(6,*) 'i,dx,x,f : '
c write(6,432) i,dx,x,f
432 format(1x,i3,3(2x,1p1e22.15))
orbel_flon = x + dx
c If we have converged here there's no point in going on
if(abs(dx) .le. TINY) go to 100
x = orbel_flon
enddo
c Abnormal return here - we've gone thru the loop
c IMAX times without convergence
if(iflag .eq. 1) then
orbel_flon = -orbel_flon
capn = -capn
endif
write(6,*) 'FLON : RETURNING WITHOUT COMPLETE CONVERGENCE'
diff = e*sinh(orbel_flon) - orbel_flon - capn
write(6,*) 'N, F, ecc*sinh(F) - F - N : '
write(6,*) capn,orbel_flon,diff
return
c Normal return here, but check if capn was originally negative
100 if(iflag .eq. 1) then
orbel_flon = -orbel_flon
capn = -capn
endif
return
end ! orbel_flon
c------------------------------------------------------------------
c
***********************************************************************
c ORBEL_ZGET.F
***********************************************************************
* PURPOSE: Solves the equivalent of Kepler's eqn. for a parabola
* given Q (Fitz. notation.)
*
* Input:
* q ==> parabola mean anomaly. (real scalar)
* Returns:
* orbel_zget ==> eccentric anomaly. (real scalar)
*
* ALGORITHM: p. 70-72 of Fitzpatrick's book "Princ. of Cel. Mech."
* REMARKS: For a parabola we can solve analytically.
* AUTHOR: M. Duncan
* DATE WRITTEN: May 11, 1992.
* REVISIONS: May 27 - corrected it for negative Q and use power
* series for small Q.
***********************************************************************
real*8 function orbel_zget(q)
include 'swift.inc'
c... Inputs Only:
real*8 q
c... Internals:
integer iflag
real*8 x,tmp
c----
c... Executable code
iflag = 0
if(q.lt.0.d0) then
iflag = 1
q = -q
endif
if (q.lt.1.d-3) then
orbel_zget = q*(1.d0 - (q*q/3.d0)*(1.d0 -q*q))
else
x = 0.5d0*(3.d0*q + sqrt(9.d0*(q**2) +4.d0))
tmp = x**(1.d0/3.d0)
orbel_zget = tmp - 1.d0/tmp
endif
if(iflag .eq.1) then
orbel_zget = -orbel_zget
q = -q
endif
return
end ! orbel_zget
c----------------------------------------------------------------------