You are on page 1of 13

University at Buffalo

Project 1
MAE 425
BKimiecik

11

Contents
Task 1 ...................................................................................................................................................... 4 Task 2 ...................................................................................................................................................... 5 Task 3 ...................................................................................................................................................... 7 Task 4 ...................................................................................................................................................... 9 Task 5 .................................................................................................................................................... 11 Conclusion ............................................................................................................................................. 13

Problem Statement
This project entails using the students accrued knowledge from MAE 425 in order to find and display characteristics of a given elliptical orbit. The purpose of this project is to determine the orbit position using 3 different approaches for a satellite orbiting Earth. This project starts with the following equation and initial conditions:

Where the given equation for acceleration is that of the "Two-Body Problem". This equation defines the equation of motion for a body revolving around another in an elliptical parabolic orbit. It is important to note that this equation is only valid if momentum is conserved, which is a valid assumption for any orbital system. All orbital systems in a vacuum must obey Kepler's 3 laws. These laws are the following: 1.) An elliptical orbit consists of 2 foci with a planetary body (e.g.: star, planet, asteroid) at one of the foci. 2.) The line joining a mass and a planetary body at one foci in an elliptical orbit sweeps outs equal areas at equivalent time intervals anywhere upon the orbit. This law is caused by the conservation of momentum. As stated before, momentum conservation is valid for all eccentric orbits in a vacuum with the exception of highly elliptical orbits. As an effect, it is inferred that any orbit which falls into this classification lies within the same plane throughout orbit. 3.) The square of the orbital period of a revolving body is directly proportional to the cube of the semimajor axis of its orbit. As a result it is possible to calculate the orbital period of all orbiting bodies which fall in the reasonable classifications stated above.

Required Tasks
Do the following tasks with computer generated code (show all of your code): 1. Convert these initial conditions to orbital elements a, e, M0, i, , and . 2. Convert the orbital elements back to r0 and r , and make sure that you get the correct initial conditions back. 3. Using the initial conditions r0 and r numerically integrate the orbital equation of motion using any standard MATLAB integration routine such as ode45. Pick a final time of 8 hours and an interval of 10 seconds. 4. Use the orbit elements directly to determine orbital position and velocity. 5. Use the f and g series approach with the eccentric anomaly to determine the position and velocity.

Task 1
Converting the 2 vectors given for the radius and radial velocity initial conditions into orbital elements is outlined below in the following Matlab code. Below the following code is the provided values for each respective element in this orbital system. The code is compiled utilizing the following steps. Initial conditions were called in the file then magnitudes of the displacement and velocity vectors were obtained. Equations for eccentricity and momentum were then applied to the code and values were discovered. The "A" matrix is then compiled using the unit vectors for a perifocal system and then the classical orbital elements were obtained with equations supplied by the lectures.

%Declare global variables global i a mu = 398600.64; %Initial condition for r (units km) r0 = [-5064.7148661;-7879.297593;-6035.892137]; r0mag = norm(r0); %Initial conditions for rdot (units km/sec) rdot0 = [2.103993;-4.564176;2.507441]; v0 = norm(rdot0);

%Eccentricity and momentum h = cross(r0,rdot0); e = ((cross(rdot0,h)/mu)-(r0/r0mag)); emag = norm(e); hmag = norm(h); %"A" Matrix ie= e/emag; ih= h/hmag; ip= cross(ih,ie); A= [ie';ip';ih'] %The following are the classical orbital elements which define this orbit a = 1/((2/r0mag)-((v0^2)/mu)) emag = norm(e) i = acos(A(3,3)) Ohm = atan2(A(3,1),-A(3,2)) ohm = atan2(A(1,3),A(2,3)) sigma0 = (r0'*rdot0)/sqrt(mu) E0 = atan2((sigma0/sqrt(a)),1-(r0mag/a)) M0 = E0-(emag*sin(E0))

a (semi-major axis) e (eccentricity) M0 (initial mean anomoly) i (inclination angle) (right ascension of the ascending node) (argument of periapsis)

9.9658e03 0.2 2.0413 0.8727 -1.5708 3.1416

Task 2
It is now required to utilize these orbital elements and now find the vectors of r0 and r which we are

initially given.

Doing this however does present a minor obstacle, that is in solving Kepler's Equation for E. This equation is as follows:

This equation has no closed order solution, hence solving for both M0 and E0 requires a Newtonian Iteration as discussed in previous lecture. The iteration is done in Matlab by using a "for loop". When the change in E "delE" approaches a value less that that defined in the condition of the loop, operations will

cease. In other words, M0 and E0 are approaching a similar value which is the condition that must be true to find the respective initial values. At initial conditions, M0=E0. Upon convergence of the loop and E0 and M0 values are found, the values are then inputted into the initial displacement and velocity vectors. Ideally, the resulting vectors should match that of the provided initial displacement and velocity vectors. The task is successful as shown below.

%Declare variables mu=3.9860e+05; a=9.9658e03; emag= .2000; i= .8727; Ohm = -1.5708; ohm = 3.1416; M0=2.0413; E0=M0; %"A" Matrix A(1,1) = (cos(Ohm)*cos(ohm))-(sin(Ohm)*sin(ohm)*cos(i)); A(1,2) = (sin(Ohm)*cos(ohm))+(cos(Ohm)*sin(ohm)*cos(i)); A(1,3) = sin(ohm)*sin(i); A(2,1) = (-cos(Ohm)*sin(ohm))-(sin(Ohm)*cos(ohm)*cos(i)); A(2,2) = (-sin(Ohm)*sin(ohm))+(cos(Ohm)*cos(ohm)*cos(i)); A(2,3) = cos(ohm)*sin(i); A(3,1) = sin(Ohm)*sin(i); A(3,2) = -cos(Ohm)*sin(i); A(3,3) = cos(i); %Newtonian Iteration used to converge on E for j= 1:10; delE = (M0-(E0-emag*sin(E0)))/(1-emag*cos(E0)); if abs(delE) < 10^-5 break else E0=E0+delE; end end %r0 matrix x= a*(cos(E0)-emag); y= a*sqrt(1-(emag^2))*sin(E0); rvec=[x;y;0]; r0= (A'*rvec) %v0 (rdot0) matrix xdot= (-sqrt(mu*a)/rmag)*sin(E0); ydot= (sqrt(mu*a*(1-emag^2))/rmag)*cos(E0); vvec= [xdot;ydot;0]; rdot0= (A'*vvec)

This gives the following matrices for r0 and r :

As shown, these values for the r0 and r matrices match that of the initial conditions provided in

the project outline.

Task 3
Task 3 requires integrating the EOM for a two-body system and constant momentum using the provided initial conditions. This task effectively gives the mapping of an elliptical orbit using the provided initial conditions. It is worth noting that the body will follow an elliptical body since the EOM used is that for Keplarian Motion. Not only is an elliptical orbit mapping to be expected, but the condition of having the orbital path move along a plane is also inferred. The reason for this condition lies within that of Kepler's second law: The line joining a mass and a planetary body at one foci in an elliptical orbit sweeps outs equal areas at equivalent time intervals anywhere upon the orbit. This task allows for an accurate simulation of an orbiting body around our Earth. This is due to the parameters that are established within the project. " " = G(M+m) where G is the "Universal Gravitational Constant" and "M" is the mass of Earth. Since our parameter " " is calculated specifically with the mass of Earth, it is important to note that this simulation is accurate only for Earth or any planetary body with similar mass and geometry. This task was completed in Matlab utilizing an "ODE45" command. It is noticed within Fig (1) that the orbit is not constant, that is, the orbit converges upon itself after each revolution. This may be due to having a lack of constraints for the orbit e.g.: the classical orbital elements to take into account the

orbital motion. In this specific case, the orbit will continue to converge within this system until it reaches a singularity.

function task3 r0=[-5064.71486610000;-7879.29759300000;-6035.89213700000]; rdot0= [2.10399300000000;-4.56417600000000;2.50744100000000]; x0=[r0;rdot0]; t=0:10:28800; [~,Y]= ode45(@ellipse,t,x0); figure(2) plot3(Y(:,1),Y(:,2),Y(:,3)) grid on hold on xlabel 'km' ylabel 'km' zlabel 'km' function X=ellipse(~,x) mu = 398600; X(1,1)=x(4,1); X(2,1)=x(5,1); X(3,1)=x(6,1); r3 =(norm(x(1:3)))^3; X(4,1)=-mu/r3*x(1,1); X(5,1)=-mu/r3*x(2,1); X(6,1)=-mu/r3*x(3,1);

Figure 1: Mapping of orbit for Task 3 (t=8 hours).

Notice how multiple orbits around Earth are completed within an 8 hour orbital period. The body is going at an impressive velocity around Earth.

Task 4
Task 4 requires mapping the orbit using the classical orbital elements.

The orbital elements as shown above are used to calculate initial conditions for orbital position and velocity. This will allow for a much truer orbit, that is one which remains on a constant path with any n number of revolutions. The reason for this is because initial conditions are now taken into effect allowing for more constraints of the orbital path. As in Task 2, a Newtonian Iteration is required to calculate E. Furthermore, an iteration of Mo was done with respect to time. Mo and E are directly related and thus the iteration that is required to find the initial conditions for both of these elements are directly related. It will be shown that in the Matlab code, 2 loops are occurring for these iterations. More specifically, the "E" iteration is a nested loop that lies inside the iteration for "Mo". More specifically, the nested E loop is the first loop to undergo analysis in the system as it analyzes values of t. If the E value upon iteration falls into an acceptable range set by the loop constraints, then M is analyzed with the given E and t value. When M and E are found for a given time "t" the other classical elements in the system are calculated until each constituent required to calculate the distance and velocity vectors are known. The position and velocity are then calculated for a span of 0-8hrs in intervals of 10 seconds.

Ohm = -1.5708; ohm = 3.1416; emag= .2000; M0= 2.0413; i= .8727; mu= 3.9860e+05; A(1,1) = (cos(Ohm)*cos(ohm))-(sin(Ohm)*sin(ohm)*cos(i)); A(1,2) = (sin(Ohm)*cos(ohm))+(cos(Ohm)*sin(ohm)*cos(i)); A(1,3) = sin(omega)*sin(i); A(2,1) = (-cos(Ohm)*sin(omega))-(sin(Ohm)*cos(ohm)*cos(i)); A(2,2) = (-sin(Ohm)*sin(omega))+(cos(Ohm)*cos(ohm)*cos(i)); A(2,3) = cos(ohm)*sin(i); A(3,1) = sin(Ohm)*sin(i); A(3,2) = -cos(Ohm)*sin(i); A(3,3) = cos(i); for j=1:size(M) Ehat = M(j); for k=1:5 deltaE = (M(j)-(Ehat-emag*sin(Ehat)))/(1-emag*cos(Ehat)); if abs(delE) < 10^-5 break else Ehat=Ehat+delE; end end E(j)=Ehat; r = a*(1-emag*cos(Ehat)); x = a*(cos(Ehat)-emag); y = a*sqrt(1-(emag^2))*sin(Ehat); rnorm= norm(r); xdot= (-sqrt(mu*a)/rnorm)*sin(Ehat); ydot= (sqrt(mu*a*(1-emag^2))/rnorm)*cos(Ehat); r1 = A'*[x;y;0]; rdot = A'*[xdot;ydot;0];

rposition(1,j)=r1(1); rposition(2,j)=r1(2); rposition(3,j)=r1(3); rvelocity(1,j)=rdot(1); rvelocity(2,j)=rdot(2); rvelocity(3,j)=rdot(3); end figure(1) plot3(rposition(1,:),rposition(2,:),rposition(3,:)) title 'Orbital Path' xlabel 'km' ylabel 'km' zlabel 'km' grid on

Figure 2: Orbital path of a given body rotating around Earth using classical orbital element constraints and initial conditions.

Task 5
Task 5 is similar to that of 4, however this time around the F and G approach is utilized. That is, the system is now being analyzed in a perifocal frame of reference. The perifocal frame is that which is analogous to a polar coordinate system, and uses angles (anomalies) in order to track position. The approach to track the orbit is similar to that of Task 4, the only difference is the use of the perifocal (F and G) coordinate system. The following code is utilized to track the orbit using the F and G approach with the eccentric anomaly. It is worth noting that Fig(3) shich is the product of the Matlab code for this task has similar orbit to those of previous tasks, however does have some spatial offset. This offset is due to either a position vector which maps the initial condition or one of the classical orbital elements being arrayed by some constant within the code. Again, the orbit is equivalent, as expected, to that of all previous tasks.

%Call variables r0 = [-5064.7148661 ; -7879.297593 ; -6035.892137]; rdot0 = [2.103993 ; -4.564176 ; 2.507441]; a = 9.9658e03; mu = 3.9860e05; r0mag = 1.1143e04; sigma0 = 16.1111; t0 = 0; tmax = 28800; p = 1-(r0mag/a); q = sigma0/sqrt(a); %Vector sizes Z = zeros(tmax/10,1); rpos = zeros(tmax/10,3); rvel = zeros(tmax/10,3); for j = 10:10:tmax Z((j/10),1) = sqrt(mu/a^3)*(j-t0); Etildehat = 3; for k = 1:100 newEtilde = Etildehat-... (Etildehat+p*sin(Etildehat)-q*cos(Etildehat-1)-Z((j/10),1))/... 1-p*cos(Etildehat)+q*sin(Etildehat); diff(k) = Etildehat-newEtilde; if abs(diff(k)) < 1e-6 break else Etildehat = newEtilde; end end Etilde = newEtilde; rmag = a+(r0mag-a)*cos(Etilde)+sigma0*sqrt(a)*sin(Etilde); F = 1-(a/r0mag)*(1-cos(Etilde)); Fdot = -((sqrt(mu*a))/(rmag*r0mag))*sin(Etilde); G = j+sqrt(a^3/mu)*(sin(Etilde)-Etilde); Gdot = 1-(a/rmag)*(1-cos(Etilde)); r = F*r0+G*rdot0; rdot = Fdot*r0+Gdot*rdot0; rpos((j/10),1) = r(1,1); rpos((j/10),2) = r(2,1); rpos((j/10),3) = r(3,1); rvel((j/10),1) = rdot(1,1); rvel((j/10),2) = rdot(2,1); rvel((j/10),3) = rdot(3,1); end plot3(rpos(:,1),rpos(:,2),rpos(:,3)) grid on; title('Mapping of Orbit Using f and g Approach'); xlabel('km');ylabel('km');zlabel('km');

Figure 3: Orbital path of a given body around Earth using the f and g approach with the eccentric anomaly.

Conclusion
This project acts as an effective se of tasks in order to get the student to become both adept in orbital mechanics and in Matlab. The student is required to analyze multiple coordinate systems and methods to accurately map an elliptical orbit. It is reasonable to say that the simulation created in this project of a secondary body revolving around earth is an accurate depiction to that of a realistic case. As expected in this project, the orbit obeys Keplarian Laws of Motion and displays no signs of irregularity.

You might also like