I'm calculating the acceleration due to the harmonics in ECEF frame. Gravity potential in spherical harmonics is shown here (I just removed "$1+$", as considering only harmonics effect).
$U_{har}=\frac{\mu}{r}[\sum_{i=2}^d\sum_{j=0}^o (\frac{R_{eq}}{r})^iP_{ij}(\sin\phi)(S_{ij}\sin{j\lambda}+C_{ij}\cos{j\lambda})]$,
where $d$ and $o$- degree and order, $\phi$ and $\lambda$- latitude and longitude respectively.
I compare the results with GMAT
. For degree 2 and order 0 (J2) the error in propagation was 5m. But for degree/order=8 the error is 350km!
The steps:
In a loop $i\in[2,2]$, $j\in[0,0]$
- Calculate the $P_i=\frac{d^{i+j}}{d\mu^{i+j}}(\mu^2-1)^i$
- Calculate the Legendre polynom $P_{ij}=\frac{(1-\mu^2)^{\frac{j}{2}}}{i!*2^i}P_i$
- Calculate the $sum+=P_{ij}(\frac{z}{r})*(C\cos(j*atan(\frac{y}{x}))+S\sin(j*atan(\frac{y}{x})))(\frac{R_{eq}}{r})^i$
- Calculate the potential $U_{har}=\mu\frac{sum}{r}$
- Calculate the $a_x$: $f=\frac{dU_{har}}{dx}$
- Calculate the value in the point $f(r_x,r_y,r_z)$
As it seen, the latitude is $asin(\frac{z}{r})$ and longitude is $atan(\frac{y}{x})$
The coefficients (JGM-3):
2 0 -0.10826360229840e-02 0.0
2 1 -0.24140000522221e-09 0.15430999737844e-08
2 2 0.15745360427672e-05 -0.90386807301869e-06
I have written a code on Julia language, which builds the expression (depending on the degree and order).
using SatelliteToolbox
using SymEngine
path="C:/xampp/htdocs/sat_prop/";
JGM_coeff_file=string(path,"coeff.txt");
const date = DatetoJD(2100,01,01,0,0,0)
const degree = 8
y = [-4617E+03, 1709E+03, -5040E+03]
const Req = 6378136.3
const GMe = 398600.4415E+9
function harmonics(dy,y,dU,date)
dy= [
dU[1](y[1],y[2],y[3]),
dU[2](y[1],y[2],y[3]),
dU[3](y[1],y[2],y[3])
]
end
function potential()
@vars x y z myu
CS=open(readdlm,JGM_coeff_file)
longitude=atan( y/x );
r=(x^2+y^2+z^2)^(1/2)
U_sum=0
for i=2:degree
for j=0:degree
index=1+j; for ll=2:i-1 index+=ll+1; end
P_i=(myu^2-1)^i
for k=1:i+j P_i=diff(P_i,myu) end
P_ij=(((1-myu^2)^(j/2))/(factorial(i)*2^i))*P_i
if(P_ij!=0)
U_sum+= P_ij(z/r)*(CS[index,3]*cos(j*longitude)+CS[index,4]*sin(j*longitude))*(Req/r)^i
end
end
end
U=GMe*(U_sum)/r
return lambdify(expand(diff(U,x)),[x,y,z]),lambdify(expand(diff(U,y)),[x,y,z]),lambdify(expand(diff(U,z)),[x,y,z])
end
dU=potential();
dy=zero(y)
@time harmonics(dy,y,dU,date)
@time harmonics(dy,y,dU,date)
+1
Great editing, this looks much better, very nice! I'll try to take a careful look today, thanks for taking the time to dig in with MathJax! $\endgroup$