Tuesday, July 30, 2013

Rocket Launch (Continued: Part 2)

Julian Date: 2456504

Brief update: I have been working on a function to have a user input solar system lazily between working on more interesting programs (like the one this post is about). It will work with all of the written programs and will be finished . . . eventually.

Last time I mentioned this function*, the code ended at the point where the engines stop firing. So from there, the program asks if you want to plot the trajectory of the rocket. This uses the N-Body approach to find and plot the trajectory, taking into account the sun, moon, and all 9 planets (Yes I know, Pluto etc. do not effect it too much, but it is easier to code this way, it is more accurate, and it does not take much computing power.) There is a direction cosine matrix which transfers the latitude into radius. For simplicity, I assumed that at the end of firing, the rocket is on the x axis. This means the perpendicular horizontal motion is in the y direction, parallel horizontal motion is in the x direction, and all vertical motion is in the z direction. Also, I add velocity in the y direction to compensate for Earth's rotation (compensates for tilt but need to write something to launch from a certain point on earth and/or have a preset destination and assume/calculate an ideal launch.)

*Rocket Launch (part 1)

So here it is:

As I said, after all of the choices made in the previous rocket launch post (see above*), it gives an option to plot the trajectory. It then prompts the run time and number of time steps.

So the launch used in this example: Falcon 9 Light, 15000 kg payload, thrust vector at 20 seconds for 20 seconds at 4 degrees 30 degrees from East, and run for 1e4 seconds. The result was as follows:


This is the resulting n-body projection using all 9 planets, the sun, and the moon. 

Rocket: Blue
Planet: Black

Left: Projected trajectory of the Falcon 9 Light. Notice it "crashes" into the planet.
Right: Projected trajectory of the Earth, and the rocket about it.



Rocket: Saturn V, 55000 kg payload, turn at 20 seconds for 20 seconds at 30 degrees to east with a 4 degree vector. Run for 1e7 seconds.
Left: Position of rocket from Earth. The spirals are from the rotation around the sun. What this graph shows is that the rocket gets further away, eventually it would reverse.
Right: Total orbit of the rocket and planet. The rocket has a shorter orbit and will constantly be moving away from Earth until it catches up in the orbit.

As I said before, I need to program some way to launch to a certain destination or from a certain point, but for now this is it. There will eventually be an option to include the moon in a simulation as well as a function for a missile launch.


Friday, July 26, 2013

A True-er Geocentric View

Julian Date: 2456500

I decided to edit the code for the geocentric view to include the ~23.44 tilt in the axis of the earth. The program now also outputs the apparent latitude of the planets on the starting date (which is defaulted to the user's current day). Notice the increased range of motion from the non-tilted version.


Left: Apparent relative radii from the tilted Earth of all 9 planets and the Sun.
Center: Apparent location of planets as seen from the Earth.
Right: Color assignments and initial apparent latitude


Left: Apparent relative radii from the tilted Earth.
Center: Apparent locations of planets as seen from Earth.
Right: Color assignment and initial apparent latitude

Tuesday, July 23, 2013

A True Geocentric View

Julian Date: 2456497

Before beginning this blog, the main Earth function was not geocentric based. Instead it was just an earth-moon based model. While still including the Earth-Moon model, in light of changing it to geocentric I decided to make a geocentric view of planets moving with respect to a stationary Earth over the course of a year.

The function finds the relative radii of each planet and the sun with respect to the earth, then plots them. It then normalizes the radii and plots again, with all the plants being shown at where they are in the nights sky. To avoid confusion, the planets/lines are color coded. It may be a little difficult to make out the planets in the first figure because of the large scale (~40 AU), the second only takes the first 4 planets so it is much easier to view (~2 AU). Keep in mind that, while it may seem relatively 2 dimensional, there is differences in the z-axis radii (This can best be seen in the center plot on the first figure. On the left of Earth there is a small dot detached from the "rings", this is the track of Pluto.)


Left: Actual relative radii from the earth of all 9 planets and the sun.
Center*: Location of view from the Earth.
Right: Color assignments


Left: Actual radii
Center: Location from Earth
Right: Color assignments


*this model does not take the earth's tilt in its axis (~23 degrees) into account, planets do not necessarily appear on the equatorial plane.




Monday, July 22, 2013

The story so far (part 4: Rocket Launch [in progress])

Julian Date: 2456496

Rocket Launch Simulation (in progress):


This is where things start to get interactive and fun.


When beginning the launch functions, the user is given an option to either use preset rockets or design their own. I will begin by showing a few random designs I have created. 


The editable qualities are as follows: Number of stages, if there are parallel thrusters (and how many), the command capsule (diameter, length, angle of nose), body (diameter, length, angle to next stage), thrusters (outlet diameter, length), structure mass (payload/capsule mass, structure mass and ratio for each stage and booster), and fuel (specific impulse and mass flow rate for each stage and booster). Once the program is finished, I will go back and put in additional variables which will vary the performance of the spacecraft.



Above are some potential rocket designs. 

The preset designs are currently limited to the Saturn V,  Falcon 9 (light), and the Falcon 9 (Heavy). However I am planning on adding in rockets periodically. 

Left: Saturn V
Center: Falcon 9 (light)
Right: Falcon 9 (heavy)
While the two are not exact, there is a resemblance between the program's rockets and the actual. I will go back eventually to both fix these and add more.

Once the rocket is chosen or created, the program will output the masses and thrust of each stage.

Rocket statistics for a Falcon 9 (heavy) rocket.


After choosing if there is going to be thrust vectoring to cause a gravity assisted turn, the program runs until the last stage of the rocket fires. It then outputs a series of graphs (which I have been using for troubleshooting) which shows the voyage. 

Velocity, mass, height, longitude, and latitude are self explanatory. Phi is the angle to the local vertical (WRT earth) and psi is the angle to the local east.

This is how far I have gotten so far. I will explain some of the assumptions I have made in this and other sections in the future because I am tired of doing this for today. 

More to come soon. 

The story so far (part 3: N-Body simulation)

Julian Date: 2456496

N-Body Simulation:

While N-Body simulations are employed in both the geocentric and heliocentric models, this simulation uses only user input radius, velocity, and masses. Following are examples of Sun-Earth-Moon and Earth-Moon systems.

Sun-Earth-Moon:

Left: The dashed lines show all the places where the Moon (green) comes in front of the Earth (blue). The simulation was run for 1 year, and as you can see, Moon circles the earth 12 times (12 months). The sun did not move significantly, and does not show in the figure.

Right: If you look closely, the green line is rotating around the blue line. This represents a time period of almost 3 months.


Earth-Moon: 
The figure on the left is similar to the N-body simulation for the geocentric model, however, as shown in the figure on the right, due to the movement of the Earth, the Moon moves in a helix. The Earth also moves in a helix around the Sun as it circles the Milky Way.


You are able to model any number of bodies, however it make take an large amount of time to iterate a system of many point masses. I am looking into potentially using a tree-method or figure out some simplification to apply to simulation cases with a larger number of point masses. This will be used to simulate an asteroid belt or numerous celestial bodies.

The story so far (part 2: Geocentric simulation)

Julian Date: 2456496

Geocentric Simulation (quite similar to the heliocentric simulation):

Outputs the date and time as well as the location and velocity of the moon at the current time. This runs off data taken on 2000 AD and is extrapolated to estimate current locations (at the time it was accurate to +- 20 m). It assumed to be accurate, but corrections for current locations will be edited in at a later time.


Upper left: Default view of Earth-Moon system.
Upper right: View from side
Lower left: View from top
Lower right: View along inclined plane.


This is a N-body simulation of the Earth-Moon system. It takes the initial radius and velocity and then runs through a specified number of iterations to result. In the figure, the black line represents the Earth's movement (starting at zero velocity) and the blue line represents the Moon's. Since the Earth began at zero velocity, it is interesting to notice how much the gravity from the Moon effects its motion. This example was run for 1e7 seconds (115.7 days) and iterated 1e6 times (10 seconds each). Because there were only two objects in this simulation, the result is fully in plane (as seen in the right image).

There is also a function to animate the system and will be a function to launch a rocket off of Earth with intention to land on the moon or another celestial body.


The story so far (part 1: Heliocentric simulation)

Julian Date: 2456496

In the next four posts (parts 1-4) I will explain each of the four main functions I currently have. These are the heliocentric, geocentric, rocket launch, and N-body simulation functions.

First option screen


Heliocentric simulation:

Outputs the date and time as well as the locations and velocities of the 9 planets at that time (figure shows the date output by the program and the date and time according to my computer). This runs off data taken on 2000 AD and is extrapolated to estimate current locations (at the time it was accurate to +- 20 m). It assumed to be accurate, but corrections for current locations will be edited in at a later time.


Upper left: Default view of solar system.
Upper right: View from top
Lower left: View from side
Lower right: View of Venus through Mars

Notice the three dimensions and skewed elliptical orbits. Also, the size of the planets (x1000) and sun (x10) are increased for easy view ability. There is also a function to animate the system.



This is a N-body simulation of the planets. It takes the initial radius and velocity and then runs through a specified number of iterations to result. On the left is an example of the first four planets (Sun: black, Mercury: dark blue, Venus: green, Earth: Red, Mars: light blue) run for 1e8 seconds (3.1688 years) and iterated 1e6 times (1.6655 minutes each). The inclinations of these planets are relatively small (as seen in the right image).


Yeah, so this is the heliocentric model, I think Copernicus (before him Aristarchus) would be proud. Is there anything anybody would like to see added? I hope that eventually all of the functions play a part together, but until then I will just keep on coding.



The point of this blog

Julian Date: 2456496

The point of this blog: Not only do I want to share my project with whoever would find it intriguing, but I hope to attract the attention of those with the same interests to throw their two cents in. Hopefully this blog will not only help motivate me, but also bring me more insight of this field.

Not that I have the alpha version out of the way, I am going to skip beta and head on to the real deal. I am making this program as realistic as possible (disclaimer: Being 100% realistic is not possible). Adding a third dimension to this code has proven difficult, but in the ~2 months I have spent casually writing this I feel like I have made decent progress. However, with my computer breaking and having to send it in for a few weeks, this project has had its fair share of setbacks.

I have been working continuously on the many functions. Some have bugs, some are perfect, some have a small math error which propagates downstream and cause a catastrophic cluster-fuck of numbers, but I am trying to fix it all. Regardless, welcome and I hope you find this as interesting as I do.


Space Sandbox alpha

Julian Date: 2456496

So this began as a programming project for my Spaceflight Mechanics class based around a two dimensional circular orbit model of our solar system (or a user created solar system). Written in MatLab's .m code, it includes functions for non-Hohmann elyptical transfers in planetary and solar orbit (also simplified for Hohmann transfers), Kepler's equations, plotting and animating the system, designing a different solar system,  launching a rocket, and gravity assists. It is a bit buggy in certain parts though.

Examples:

Planets Venus through Pluto and their distance from the sun, angular velocity, and true anomaly. As you will see in version 1.0, having circular orbits simplifies everything significantly. 


Again all the planets. As you would first think, the first three are not extremely close to the sun. Pluto sits at around 39 Au while the earth sits at 1 Au. Also, looking at a realistic figure of the solar system (as seen in version 1.0) shows how inaccurate the circular 2-d model is.


The launch program assumes a bunch of things and is not too accurate. You can do non-Hohmann interplanetary transfers, but this is a Hohmann. All of the outputs are relatively consistent with real launches, ie a circular 2-d can be used to estimate but will not work in real world conditions. You may also notice how large the third burn is. It is because this program does not use drag to slow the rocket down, as occurs in real situations.


Essentially this is what the alpha program does. Version 1.0 is a 3-d elliptical version of this, and includes many more functions which add to the experience. Read on to check out Version 1.0. 

The code is available upon request (alpha version).