To test the algorithm, I'm trying to calculate the acceleration (derivative of $U$), considering only J2, however the result is wrong (II compare with the equation, described here, p.9). The result of $a_x$ isresults with -3e-3GMAT
, but should be about. For degree 2 and order 0 -1e-2
(J2) the error in propagation was 5m. But for degree/order=8 the error is 350km!
- 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(\sin\phi)$$P_{ij}=\frac{(1-\mu^2)^{\frac{j}{2}}}{i!*2^i}P_i$
- Calculate the $sum+=P_{ij}*(C\cos(j\lambda)+S\sin(j\lambda))(\frac{R_{eq}}{r})^i$$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$
I suppose that latitude
and longitude
should be expressed through x
,y
As it seen,z
and differentiated then. Tried to replace the latitude withis $\text{asin}(\frac{z}{r})$,$asin(\frac{z}{r})$ and longitude withis $\text{atan}(\frac{y}{x})$, but it didn't solve the problem.$atan(\frac{y}{x})$
#Initialize theusing librariesSatelliteToolbox
using SymEngine
using Geodesy
path="C:/xampp/htdocs/sat_prop/";
#Initialize theJGM_coeff_file=string(path,"coeff.txt");
const variablesdate myu-= sinDatetoJD(latitude2100,01,01,0,0,0)
const degree = 8
y = [-4617E+03, lambda1709E+03, -5040E+03]
const longitudeReq = 6378136.3
@varsconst xGMe = 398600.4415E+9
function harmonics(dy,y,dU,date)
z myudy= lambda
[
# Degree 2, order 0- only J2
d=2; o=0;
dU[1](y[1],y[2],y[3]),
# C dU[2](y[1],y[2],y[3]),
S dU[3](y[1],y[2],y[3])
gravitational parameter and equatorial radius ]
C=-0.10826360229840e-02end
S=0
GMefunction =potential()
398600.4415E+9 @vars x y z myu
Req
= 6378136.3CS=open(readdlm,JGM_coeff_file)
longitude=atan( y/x );
r=(x^2+y^2+z^2)^(1/2)
U_sum=0
for i=2:ddegree
for j=0:odegree
#calculate the Legendreindex=1+j; polynomialfor ll=2:i-1 index+=ll+1; end
legendre_part=(myu^2-1)^i
for k=1:i+j
legendre_part=diff(legendre_part,myu)
end
legendre=(((1-myu^2)^(j/2))/(factorial(i)*2^i))*legendre_part(myu)
#Calculate the sumif(legendre!=0)
U_sum+=legendre* U_sum+= legendre(C*cosz/r)*(j*lambdaCS[index,3]*cos(j*longitude)+S*sin+CS[index,4]*sin(j*lambdaj*longitude))*(Req/r)^i
end
end
end
#Calculate the potential
U=GMe*(U_sum)/r
#Calculate the derivative
f=expandreturn lambdify(expand(diff(U,x))
#The values of x,[x,y,zz]), myu and lambda
vector = [-4617E+03lambdify(expand(diff(U, 1709E+03y)), -5040E+03]
latlon=LLA[x,y,z]),lambdify(ECEFexpand(vectordiff(U,z)), wgs84[x,y,z])
end
f
dU=potential(vector[1]);
dy=zero(y)
@time harmonics(dy,vector[2]y,vector[3]dU,sin(latlon.lat*pi/180date)
@time harmonics(dy,latlon.lon*pi/180y,dU,date)