Hi Orekit community,
I’m currently trying to develop a Keplerian propagation using the Runge-Kutta integrator and a hand-made build ODE.
Here is what I developped so far:
def Keplerian_propagation(E0, central_mu, initialDate, finalDate, inertialFrame, nbr_pts, tle_time,pos = True):
'''
ARGS :
E0 : Initial Vector [a0,e0,i0,pa0,raan0,M0]
exposed surface : exterior surface in contact with the thin atmospherical residues
central_mu : mu of the central body (here the earth)
initialDate : AbsoluteDate of the initial time
finalDate : AbsoluteDate of the final time hen the propagation must stop
inertialFrame : Inertial Frame of reference used in the construction of orbits and propagation
nbr_pts : Number of points for the propagation
tle_time : List containing seconds in julian date
'''
# Keplerian parameters
prop_a,prop_e,prop_i,prop_pa,prop_raan,prop_M,prop_orbits = [],[],[],[],[],[],[]
# Equinoctial parameters :
prop_Hx, prop_Hy, prop_Ex, prop_Ey = [],[],[],[]
if pos:
step = finalDate.durationFrom(initialDate)/nbr_pts
else:
step = - initialDate.durationFrom(finalDate)/nbr_pts
a0,e0,i0,pa0,raan0,M0 = E0[0],E0[1],E0[2],E0[3],E0[4],E0[5]
extrapDate=initialDate
orbit0 = KeplerianOrbit(float(a0), float(e0) , float(i0), float(pa0), float(raan0), float(M0), PositionAngle.MEAN, inertialFrame, extrapDate, central_mu)
T_period = float(2*np.pi*np.sqrt(a0**3/central_mu))
ExpendableOde = ExpandableODE(OrdinaryDifferentialEquation.init(tle_time[0],E0,tle_time[-1]))
integrator = ClassicalRungeKuttaIntegrator(5*T_period)
if pos:
while (extrapDate.compareTo(finalDate) <= 0.0):
Ei = [prop_a[-1],prop_e[-1],prop_i[-1],prop_pa[-1],prop_raan[-1],prop_M[-1]]
currentTime = extrapDate.durationFrom(initialDate)
OdeState = ODEState(currentTime,Ei)
orbit = integrator.integrate(ExpendableOde, OdeState, extrapDate.shiftedBy(step))
PV = orbit.getPVCoordinates()
keplerian = KeplerianOrbit(PV,inertialFrame,extrapDate,central_mu)
prop_a.append(keplerian.getA())
prop_e.append(keplerian.getE())
prop_i.append(keplerian.getI())
prop_Hx.append(keplerian.getHx())
prop_Hy.append(keplerian.getHy())
prop_Ex.append(keplerian.getEquinoctialEx())
prop_Ey.append(keplerian.getEquinoctialEy())
prop_M.append(keplerian.getMeanAnomaly())
##### RAAN and PA calculations and normalization from Equinoctial parameters
to_check_raan = float(np.arctan2(prop_Hy[-1],prop_Hx[-1]))
moduled_raan = to_check_raan % float(mytwopi)
prop_raan.append(moduled_raan)
# Now we have raan, we also know that ex = e * cos(raan + pa) so pa = arccos(ex/e) - raan
to_check_pa = float(np.arctan2(prop_Ey[-1],prop_Ex[-1])-prop_raan[-1])
moduled_pa = to_check_pa % float(mytwopi)
prop_pa.append(moduled_pa)
prop_M[-1] = prop_M[-1] % float(mytwopi)
prop_orbits.append(KeplerianOrbit(prop_a[-1],prop_e[-1],prop_i[-1],prop_pa[-1],prop_raan[-1],prop_M[-1], PositionAngle.MEAN, inertialFrame, extrapDate, central_mu))
extrapDate = extrapDate.shiftedBy(float(step))
return prop_a,prop_e,prop_i,prop_pa,prop_raan,prop_M,prop_orbits
And while building the ODE with ExpandableODE
i get the following error :
descriptor 'init' for 'OrdinaryDifferentialEquation' objects doesn't apply to a 'float' object
. Is there someone who knows how to fix that ?
Thank you in advance
Have a great day
JL