Solving Kepler’s equation by Newton-Raphson method
To solve Kepler’s equation by Newton-Raphson method
Python Program:
# -------------------------------------------------------------
# Exp -3: To solve K e p l e r s equation by Newton - Raphson method
# -------------------------------------------------------------
import numpy as np
import math
# -------------------------------------------------------------
def kepler_eq (M , E , e , err ):
# M [ rad ], E [ rad ], e = between 0 to 1, E inital assumption
print (" --------------------------------------------------------------")
print (" value of M:", M , ", value of e:",e , ", intial value of E:",E )
print (" --------------------------------------------------------------")
h = ( M + e* math . sin (E ) - E) / (e* math . cos (E ) - 1 )
i = 0;
while ( abs (h) > err ):
h = ( M + e* math . sin (E ) - E) / (e* math . cos (E ) - 1.0 )
E = E - h
i=i +1
print (" interation = ", i , " value of E = ", E)
# print (E)
print (" --------------------------------------------------------------")
print (" value of E is : ", E )
# ----------------------------------------------------------------------
M = 0.3 # mean anomaly
E = 100 # eccentric anomaly
e = 0.5 # eccenticity
err = 0.000000001 # 10^( -8)
kepler_eq (M , E , e , err )
# -----------------------------------------------------------------------
Output:
Comments
Post a Comment