Thursday, August 8, 2013

Orbit Transfer (Part 1)

Julian Date: 2456513

Last time: Plotted current and target orbit specified by the user and indicated initial/target locations of orbit

This time:

I finished the function for an orbit transfer. While I have only included the functions for an orbit transfer, the great part about the functions, namely the Lambert's problem function, is that it can be utilized for all of the transfer functions (rendezvous also require Wiltshire-Clohessey and deep space/moon requires compensation for the gravitational pull of the celestial bodies). This being said, the accuracy of this function decreases with the distance from Earth due to the increased gravitational pull of the other celestial bodies.


So on to the show:

So from the last post, the program has either launched a rocket or the orbital elements of the current orbit have been input. For this example, the elements for both orbits are as follows.


Left: Orbital elements of the two orbits. The top is printed from past inputs and the lower was just input in this frame.
Right: Current and target orbits and departure/arrival locations.

After this, there is an option to either choose the transfer time, or optimize the time for the smallest change in velocity possible. First we will go over the first option.


Choose the time:

After asking if the user wants to launch at a different anomaly, the program prompts for the time of transfer (for this example I intend to create a hyperbola, so I input 100000 seconds, or 27 hours 46 minutes and 48 seconds).


The Lambert's problem function is run and the trajectory is then plotted over the previous plot.

 Plot of the orbits and target trajectory. 



The program then runs through a bunch of equations to get the outputs shown below.

 As you can see, the transfer orbit is a hyperbola. The negative efficiency of the second turn means that the change in velocity was greater than the final velocity itself. I will fix this problem in the future. The rest is pretty self explanatory.


Optimization of the total Delta-V:

After choosing to optimize for a delta-V, the program iterates through Lambert's problem (starting at 10000 seconds, or 2 hours 46 minutes and 28 seconds, and taking 500 second steps) until the delta-V stops decreasing. I will confirm this is the most efficient path later with a function I wrote specifically for that reason. 

The trajectory is chosen from the absolute min and then plotted.

Left: Orthographic view of the trajectory and orbits.
Right: View in plane with original orbit and slightly out of plane with the transfer orbit.


It then plots the same relevant information as before.

Notice the elliptic eccentricity. All efficient transfer orbits should be an ellipse. 


So that is it for this function. I need to find an already developed program to run my results against to see how they stand up.


Proof of the delta-V efficiency:

I edited the code slightly to iterate for a certain amount of time and then plotted the delta-V and eccentricity against time, and the eccentricity vs. the delta-V. Originally I decided to optimize based on eccentricity. I made this decision based on the intuition that a hyperbolic orbit will vertically asymptote at t_transfer=0 and a an orbit would horizontally asymptote as t_transfer approaches infinity. However, and as you will see, the optimum delta-V occurs slightly after the minimum transfer orbit's eccentricity**.

Here is the data, I will zoom in and talk about each in detail after this figure.
Top Left: Delta-V vs. Time. 
Top Right: Eccentricity vs. Time
Bottom: Eccentricity vs. Delta-V


Top Left*: The absolute minimum on the delta-V  vs. time plot is at about 3.08e5 seconds.
Top Right*: The absolute minimum on the eccentricity vs. time plot is at about 2.72e5 seconds.
Bottom**: Shows the minimum delta-V, and therefore the eccentricity at which the efficiency switches direction. This will be discussed more thoroughly in the next few figures.

*As you can see, the absolute minimum for the delta-V occurs slightly after the minimum for the eccentricity. The eccentricity at 3.08e5 seconds is 0.8148, a change of in eccentricity of 0.0042.

As seen above, the minimum delta-V is around 2.051 at an eccentricity of around 0.081495. Notice again how the minimum delta-V is not at the minimum eccentricity (but it is very close).


**The plot on the right should remind you of a hyperbola (v-asymptote at x=0 and h-asymptote at y=0) and a logarithmic function (v-asymptote at x=0 and h-asymptote at y=1). This is because, as I alluded to it earlier, at lower transfer times, the trajectory is hyperbolic. Therefore the eccentricity approaches infinity as the time approaches zero (+). Also, as to not escape the gravitational pull of the earth, the eccentricity cannot exceed 1, therefore as time increases to infinity, the eccentricity would approach 1. The point where the trajectory is more efficient  should be at the minimum points of the plot because a higher eccentricity indicates a higher energy state. The lower the energy state, the less energy is needed to be added to the system. The reason the delta-V does not have a minimum has something to do with the change in inclination, and I will have to look more into that at a later time.


Well that was a lot. I will be working on the rendezvous function next, which shouldn't take long, followed by transfers to celestial bodies. I also plan on figuring out some kind of transcendental equation to optimize the orbit transfer, with variable arrival/departure anomalies, and time. But it is late and I am tired, so I will end this post riiigggghhhttt . . . here.


Sunday, August 4, 2013

Rocket Launch (Continued: Part 3)

Julian Date: 2456509

Last time: Plots the trajectory of a rocket after the engines stop firing using an N-body approach.

This time:

Now, from the starting menu, the user has an option to do an orbital transfer. If this option is chosen, it asks if the user wants to either launch a rocket or input orbital elements to calculate the original location and velocity of the rocket. I will go through each in turn.


Orbital Elements:

As you can see, the program prompts for the 6 orbital elements (angular momentum found from eccentricity and semi-major axis). 



 It then plots the orbit and draws a line to the current location.


Rocket:

The program gives the same options to the user for launching a rocket as the rocket function. Once it is "launched" it takes the radius and velocity vector of the rocket and finds the 6 orbital elements from that. It then plots the projected orbit of the rocket, as seen below.

     The launch: Falcon 9 (light), 5000 kg payload, thrust vectoring at 20 seconds for 20 seconds at 30                degrees to east for 80 degrees.

Left: Projected orbit of the rocket in accordance with the orbital elements.
Right: Close up on the perigee end. Notice the line pointing to where the rocket currently is. Also, the rocket's trajectory does land it inside of the Earth (meaning it crashes) at some points on the perigee end. 


This figure shows the N-body version of an identical launch. Notice the similarities in  launch location and trajectory. If you look closely at the N-body projection, you can see the lines do not line up perfectly as they do with the orbital element plot. This is because of including the masses of all other celestial bodies instead of assuming a two body system and only using Earth's mass. While this model is more accurate in the long run, the orbital element model can be used to predict short term trajectories, and can be back checked with the N-body model and the trajectory can be adjusted if it gets off course.


Here the option is given for which type of orbital transfers the user wants. The options currently are a general orbit transfer, a rendezvous, a rendezvous with the moon, or a deep space mission which will include rendezvous with other planets, solar/celestial body orbiting, and gravity assists. Depending on the choice, the program will either prompt for the target orbit's orbital elements, target satellite/spacecraft's orbital elements, or plot where the moon is.

Left: General orbit transfer: Plot of Earth, current trajectory and location, and target orbit.
Center: Rendezvous: Plot of Earth, current trajectory and location, and target orbit and satellite location.
Right: Plot of Earth, current trajectory and location, and current trajectory and location of the Moon.


This is as far as I have written. Next the user will decide at what anomaly they wish to launch, anomaly to arrive at target orbit, and the time of the transfer. The orbital transfer, rendezvous, and moon rendezvous are going to have very similar coding so I plan on finishing those before beginning the deep space function.

There are currently 27 functions (soon to be more), so needless to say my folder is beginning to become clustered. Once I finish what I am currently working on, or when I feel like it, I am going to go through and delete redundant code and re-write some functions to increase versatility.