projectpaper backupdpsaltis/phys305/szep.pdfscale colonization of our red planet (davis, 2017). due...

25
OPTIMAL TRAJECTORY CALCULATIONS FOR MARS EXPLORATION OR COLONIZATION RESCUE MISSIONS VIA MULTI - BODY GRAVITY ASSIST MODEL MARS 2018 by Andras Szep Marton Szep University of Arizona Phys 305 - Fall’18

Upload: others

Post on 19-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

OPTIMAL TRAJECTORY CALCULATIONS FOR MARS EXPLORATION OR

COLONIZATION RESCUE MISSIONS VIA MULTI-BODY GRAVITY ASSIST MODEL

MARS 2018

by Andras Szep Marton Szep

University of Arizona

Phys 305 - Fall’18

Page 2: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-2-

ABSTRACT This project set out to conduct a feasibility analysis and identify how traditional launch windows can be extended to make high priority Mars travel - such as rescue missions - possible. More specifically, to model gravitationally assisted flight trajectories using a 4th order Runge Kutta algorithm, space mapping, and gradient optimization; in order to identify the optimal launch times and launch velocities. The research findings conclude that raising launch velocity from 12km/s to 17km/s, can expand feasible launch windows by up to 7 months; even though launch windows will remain limited by the edges of economic viability.

I. INTRODUCTION 1.1 Space Exploration - A Brief Overview

Humanity embarked on the mission of exploring space in the year 1957, with the launch of the very first Satellite, Sputnik. Since then, we have set foot on the Moon and sent probes to countless moons and planets in our solar system. And even though the space race ended around 1975, due to the rapid evolution of technology in the private sector, the industry of space exploration reignited

(Howell, 2012). Thus, plans have been made for not only reaching Mars with a human transport, but to begin the small-scale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars, trajectory calculations in the past focused on the most economical Hohman transfer, which narrows down the launch window to one day every 26 months. This paper will explore the possibility of extending such launch windows for high priority missions via the alteration of launch velocities.

1.2 Mars Colonization & Difficulties

The relative closeness of the red planet to Earth as well as its hospitable features such as the presence of water ice on the poles or the 24.61 hour long days (Smith, n.d.) make it the ideal candidate for a potential colonization. Public interest in colonization have especially skyrocketed following private companies’ announcement on Mars colonization plans - most recently from SpaceX CEO Elon Musk at both the 67th and 68th International Astronautical Congresses (Davis, 2017). While the former announcement from Mr. Musk was rather inspirational, at the 68th Congress, he provided detailed information on the booster specifications, costs, funding options, and ambitious timeline with the first Mars mission planned for 2022. While the private sector has been mostly focused on Mars colonization in recent years, government funded space programs - e.g.: China’s National Space Administration or India’s ISRO - are aiming for the Moon primarily because of the relative safety that the shorter distance provides (Bennett, 2017). The creation of a Mars colony would certainly require the development of

Page 3: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-3-

potential rescue missions in case of equipment failure or accidents similar to the ones dramatized by The Martian novel and blockbuster movie of the same name. Unfortunately, the feasibility of potential rescue missions has not been address within the private sector as of now. Furthermore, there is a lack of scientific research discussing potential rescue mission launch windows that fit within current physical possibilities and slightly extended but achievable economical constraints. 1.3 Existing Mars Launch Window Calculations

Calculating orbit trajectories and launch windows is a complex task since the elliptical orbits of the red planet and the spacecraft have to be perfectly aligned for a rendezvous to happen between the two objects. Prominently, existing trajectory calculations are based on finding the most energy efficient orbits using the Hohmann transfer method, where the spacecraft leaves Earth at its perihelion and arrives at Mars at the orbit’s aphelion after completing half an orbit around the sun (JPL, 2016) - see Figure 1. While the exact trajectories of the transfer orbits always depend on the position of the two planets and the launch velocity, most research is interested in finding the launch window that allows the spacecraft to arrive at the same place as Mars at the right time in the most economically feasible way. However, in our research, we would be interested in how the launch window around the minimum cost trajectory – which happens every 26 months (NASA, n.d.) – could be extended for a high priority mission such as a rescue mission.

Figure 1: Hohman transfer (Sparks, 2012)

II. ASSUMPTIONS & MODEL 2.1 Scope of Study & Limitations

The explicit focus of this paper is to conduct feasibility research and identify specific time intervals where interplanetary travel is possible. More specifically to derive gravitationally assisted flight trajectories required for a successful Mars transport. Additionally, we aim to inquire how the launch windows specified by the Hohmann Transfer Orbit can be extended when we increase the launch velocity up to 17 km/s. Finding such extended launch windows and flight trajectories are important to identify, since they provide the limits to when a rescue or high priority mission could physically take place. Please note that our model does not include takeoff and landing calculations, or mid flight thruster reliant trajectory adjustment. Due to the nature of the problem and the countless influencing factors, the core system determining the flight path was isolated. The critical, non-neglected factors are the gravitational forces of Earth, Mars, and

Page 4: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-4-

the Sun. Furthermore, we estimate the launch of the transport vehicle from sea level, and conclude a successful flight if the trajectory intercepts the planet Mars. 2.2 Economical Assumptions

Economically, the goal was to preserve plausibility. Since the model was developed under the assumption that a high-priority payload has to be delivered to Mars in a reasonable time, the flight duration of the spacecraft was limited to a maximum of 5040 hours - which is around 7 months or 210 days. Note that this value is somewhat faster than the length of historical Mars flights - see Table 1.

Table 1: Historical Flight Times (Cain, 2017) Additionally, to ensure plausibility, it was assumed that current chemical rocket propulsion methodology is used to launch the rocket from the surface of Earth. Thus, initial launch speed was restricted to be between 12 and 17 km/s. Finally, flight trajectories that would have taken the spacecraft too close to a celestial body were disregarded - see section 2.6.1.

2.3 Model Overview A core part of the model is trajectory calculation of a spacecraft that is launched from Earth and is under the gravitational influence of Earth, Mars, and the Sun. For evaluation of the equations of motion in our system, a Runge Kutta approach was utilized, which is detailed in section 2.5. As there are an infinite number of possible launch directions, the next task was to create an optimization tool that finds the right launch direction. For simplicity, one can divide up the optimization into three distinct areas. First, given the launch velocity and date, it is necessary to find the closest approach to Mars during an economically feasible flight time - see section 2.6.1. Second, to limit the number of trajectory calculations, space mapping was implemented. In other words, closest approach calculations are done in 50 distinct directions of space initially, and adjustment is only done around the launch direction that gives the closest approach to Mars along its path - see section 2.6.2. Thirdly, after identifying a relatively good launch direction via space mapping, the actual successful transfer trajectory is determined using a steepest descent/gradient adjustment method, which is detailed in section 2.6.2. 2.4 Coordinate Systems In the trajectory calculations, two sets of coordinate systems have been used. For identifying the positions of celestial bodies, a heliocentric Cartesian state vector table was utilized that provided the x, y, and z coordinates of Earth and Mars in kilometers for every day

Historical Mars Missions

Flight Time to Mars (days)

Mariner 4 228 Mariner 6 156 Mariner 7 131 Mariner 9 167 Viking 1 335 Viking 1 360

Mars Reconnaissance

Orbiter

210

Phoenix lander 295 Curiosity Lander 254

Page 5: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-5-

between 01/01/2018 and 01/01/2021. Please note that this ephemeris table was obtained from NASA’s Jet Propulsion Laboratory’s HORIZONS Systems, and the coordinate system origin was chosen to be the Solar System Barycenter. Furthermore, what are later referred to as Earth and Mars coordinates are in fact the coordinates of the geo-center of Earth and the geo-center of Mars. Launch direction calculation was done in a heliocentric ecliptic coordinate system, where the latitude is measured in respect to the ecliptic plane of the Earth. Furthermore, position was calculated by ecliptic longitude and latitude (See Figure 2.)

Figure 2: Ecliptic coordinate system (CalTech, n.d.)

The Cartesian heliocentric-referenced equations used to calculate the trajectory of the spacecraft are

x’ = Vx y’ = Vy z’ = Vz

𝑉! ’ = −𝐺𝑀!𝑥𝑟!− 𝐺𝑀!

𝑥 − 𝑥!|𝒓 − 𝒓𝑬|!

− 𝐺𝑀!

∗𝑥 − 𝑥!|𝒓 − 𝒓𝑴|!

𝑉!’ = −𝐺𝑀!𝑦𝑟!− 𝐺𝑀!

𝑦 − 𝑦!|𝒓 − 𝒓𝑬|!

− 𝐺𝑀!

∗𝑦 − 𝑦!|𝒓 − 𝒓𝑴|!

𝑉!’ = −𝐺𝑀!𝑧𝑟!− 𝐺𝑀!

𝑧 − 𝑧!|𝒓 − 𝒓𝑬|!

− 𝐺𝑀!

∗𝑥 − 𝑧!|𝒓 − 𝒓𝑴|!

where

𝒓 = 𝑥! + 𝑦! + 𝑧!

𝒓 − 𝒓𝑬 = (𝑥 − 𝑥𝐸)2 + (𝑦 − 𝑦𝐸)

2 + (𝑧 − 𝑧𝐸)2

𝒓 − 𝒓𝑴 = (𝑥 − 𝑥𝑀)2 + (𝑦 − 𝑦𝑀)

2 + (𝑧 − 𝑧𝑀)2

Note that in the equations above, x, y, z, xE, yE, zE, and xM, yM, zM are the position components of the spacecraft, Earth, and Mars relative to the Solar System Barycenter (which is approximated to be the same as the Sun). Furthermore, r(x,y,z), rE(xE,yE,zE) and rM(xM,yM,zM) are the position vectors pointing to the geo-center of the spacecraft, Earth, and Mars respectively. G is the gravitational constant, which value we took as 6.67408*10-11 m3 kg-1 s-2, and converted to -8.64929*10-13 km3 kg-1 hr-2. For the mass of the planetary objects, we used the values and precision summarized in Table 2.

Planetary Object included in Model Mass (kg)

Sun (MS) 1.989*1030 Earth (ME) 5.972*1024 Mars (MM) 6.39*1023

Table 2: Mass of Planetary Objects included in Model

Vx, Vy, and Vz, are the velocity components of the spacecraft in the

Page 6: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-6-

inertial frame of the Sun. For the sake of simplicity, launch velocities were specified in the model in the Earth’s inertial frame, and launch direction was given in heliocentric ecliptic coordinates where phi (𝜑) is denoted as the angle between the ecliptic plane and the launch direction and theta (𝜃) is the angle from the x-axis to the launch direction’s projection in the xy plane (see Figure 3). Additionally, when calculating Vx, Vy, and Vz, the Earth’s rotation was taken into account. Thus, the complete velocity transformation between spherical ecliptic coordinates in Earth’s inertial frame and Cartesian coordinates in the Sun’s inertial frame is as follows:

Calculation of the velocity at the place of rocket launch due to Earth's rotation:

𝑒! = 66.56 ∗ !

!"# , which is the latitude of

North in Ecliptic coordinates 𝑒! = 90.00 ∗ !

!"# , which is the longitude of

North in Ecliptic coordinates 𝒆 = !!

!" , denoted the absolute value of

angular velocity per hour Hence, the angular velocities of Earth are:

𝑒!! = 𝒆 ∗ cos 𝜔! cos (𝜔!) 𝑒!! = 𝒆 ∗ sin 𝜔! cos (𝜔!)

𝑒!! = 𝒆 ∗ sin (𝜔!) Coordinates at rocket launch relative to the geocentric center of Earth (where Re is the

radius of Earth):

𝑟𝑔! = 𝑅! ∗ cos 𝜑 cos (𝜃) 𝑟𝑔! = 𝑅! ∗ cos 𝜑 sin(𝜃)

𝑟𝑔! = 𝑅! ∗ sin 𝜑 Calculation of the ground velocity relative to

the center of Earth obtained by cross product:

𝑢!! = 𝑟𝑔! ∗ 𝑒𝑧𝐸 − 𝑟𝑔! ∗ 𝑒𝑦𝐸 𝑢!! = 𝑟𝑔! ∗ 𝑒𝑥𝐸 − 𝑟𝑔! ∗ 𝑒𝑦𝐸 𝑢!! = 𝑟𝑔! ∗ 𝑒𝑦𝐸 − 𝑟𝑔! ∗ 𝑒𝑥𝐸

Conversion between Earth’s inertial frame

and Sun’s internal frame: Initial velocity of the spacecraft in Cartesian coordinates:

𝑉! = 𝑢!! +𝑥! !" !!! − 𝑥! !" !!!

24+ 𝑉!"#$%$&#'!!"!#

∗ 𝑐𝑜𝑠 𝜑 ∗ 𝑐𝑜𝑠 (𝜃)

𝑉! = 𝑢!! +𝑦! !" !!! − (𝑦! !" !!!)

24+ 𝑉!"#$%$&#'!!"!#

∗ 𝑐𝑜𝑠 𝜑 ∗ 𝑠𝑖𝑛𝑒 (𝜃)

𝑉! = 𝑢!! +𝑧! !" !!! − (𝑧! !" !!!)

24+ 𝑉!"#$%$&#'!!"!#

∗ 𝑠𝑖𝑛 𝜑

Figure 3: Conversion between inertial

frames and coordinate systems (Nah & Vadali, 2001)

2.5 Differential Equations of Motion Using Runge Kutta Method

For calculating the solution of the ordinal differential equations of motion described in section 2.4, we used the fourth-order Runge Kutta (RK) method, which is a numerical method that uses two trial steps to cancel out lower-order errors. We decided to use the RK as it is stable for various time step sizes and is

Page 7: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-7-

relatively fast. Below, the steps of the RK calculation are detailed as they relate to our model: To get the x(t+∆t), y(y+∆t), z(t+∆t) coordinates of the spacecraft, when x(t), y(t), z(t) is known, we need to solve the ordinary differential equations:

r(x,y,z)’ = v(x,y,z) v(x,y,z)’ = a(x,y,z)

For these equations, one can define the k coefficients listed below using the definition of the RK method (Voesenek, 2008). (Note that the k coefficients are provided in vector form and should be calculated for each coordinate separately.)

Observe that the coefficients for the position and velocity need to be computed alternately as the first position coefficient is needed for the second velocity coefficient and so on. Finally, once all the above listed coefficients are determined, the position vector at is given by:

Thus, given an initial v , r, ∆t, and total flight time, the flight trajectory was

determined using T/∆t iterations of the RK method. 2.6.1 Optimization 1: Closest Mars Trajectory & Collision Alerts

As mentioned under the section title Model Overview, given a launch date and a launch direction, a flight-trajectory’s closest approach to Mars (TCA) had to be determined. This was done by calculating the 𝒓 − 𝒓𝑴 distance at every iteration of the RK method, and by keeping track of the minimum 𝒓 − 𝒓𝑴 distance throughout the flight time. Additionally, the 𝒓 − 𝒓𝑬 and the r distances were tracked at each iteration of the RK; and if 𝒓 − 𝒓𝑴 decreased below the radius of Earth, or if r got smaller than five times the radius of the Sun, the trajectory calculation was ended due to collision with a celestial object. (Note that while at RS < r < 5RS, where RS is the Sun’s radius, the spacecraft doesn’t physically collide with the Sun, it gets close enough that a spacecraft's heat shield degenerates too rapidly for it to survive the flight (Green, 2016).) 2.6.2 Optimization 2: Space Mapping & Steepest Descent (Gradient Optimization) Space pre-mapping significantly reduces calculation times for angle optimization. The mapping process calculates a trajectory’s closest approach (TCA) for 10 equally spaced longitude angles (θ), as well as 5 equally spaced latitude angles (φ), to determine where to start the steepest descent optimization (SDO) process – see section 2.4. In respect to the planar orientation of our solar

Page 8: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-8-

system, spacial mapping is only done for latitude angles between ±!

!. Mapping the

TCA calculations generates a scalar field for θ and φ. Utilizing this theoretical field map, the gradient (∇l) is calculated via a step size of ±ε (ε=10-7), at the given point (θ, φ). SDO then steps towards the lowest ∇l at an initial step size of 0.06 (which can be altered, but works well for the problem at hand). If this step would result in a in an increase in TCA, we reduce the step size to half and re-evaluate the TCA at the projected location. Once the step is made, stepping distance is re-adjusted to increase by 10%. This was implemented to reduce calculation time and stepping distance tolerance error (reducing steps to infinitesimal values which result in infinite loops). Thus, the optimization process returns a collision error, stop tolerance error, or the angles of the successful trajectory.

III. VERIFICATION 3.1 Altering Timesteps Algorithm validation is accomplished via the alteration of the timestep interval. The trajectory calculation and optimization processes were designed for the timestep interval of 0.2 hours. Altering timestep gives insight to the workings of the software, and small alterations should not yield large-scale changes in final results. This verification was completed using an initial speed of 15 km/s – which is halfway between our full range of 12-17 km/s – and was using a starting day of 05/01/2018. The results of the optimization are tabulated in Table 3.

Table 3: Results of the optimization for different step sizes with the same initial

conditions

The most important observation is that the step size does have a noticable effect on the duration of the trip. The main reason behind this is that at the launch of the rocket, the gravitational force of the Earth rapidly decreases, which affects the velocity of the spacecraft more significantly with larger timesteps – and this has a visible effect on the trajectory (as show on Figures 4.1, 4.2, and 4.3).

Stepsize(hr)

θ φ Duration(days)

Optimi.Runtime

(s)0.05 5.57736 -0.12919 71 298.6670.1 5.57745 -0.12941 71.1 187.5660.15 5.57799 -0.12999 71.3 119.0810.2 5.57894 -0.13101 71.7 87.6110.25 5.58031 -0.13247 72.3 51.4880.3 5.58181 -0.13447 73.1 55.9880.5 5.58944 -0.14845 78.4 47.4010.7 5.58378 -0.18445 91.4 23.198

5.576

5.578

5.58

5.582

5.584

5.586

5.588

5.59

5.592

-1.5 -1 -0.5 0

Theta(degrees)

ln(stepsize)inln(hr)

Figure4.1:EffectofStepsizeonOpHmalTheta

Page 9: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-9-

Furthermore, it is notable that with large timesteps this difference in the direction of the launch increases. For the final model, the timestep of 0.2 hours was chosen, which enables a relatively fast computational speed while preserving an optimal level of accuracy. The order of magnitude of the accuracy can be estimated from Table 3 as 0.0016o for θ, 0.0018o for φ, and 0.7 days for the flight duration.

IV. FINDINGS At the outset of this project three guiding questions were posed:

a) At a given point in time, what is the optimal launch angle for an interplanetary transport vehicle to reach Mars?

b) During what time frames of the launch can the optimal trajectories reach the surface of Mars?

c) How does launch velocity affect the feasible launch window?

The trajectory optimization program first isolates the approximate launch angle; and then – via a steepest descent method – locates optimal launch angles. It returns the closest distance the rocket can get to Mars given a set launch date and velocity, and determines whether the rocket can reach Mars with said parameters. Figure 5.1 and 5.2 serve as examples showing the dependence of flight trajectories, based on launch angles.

Figure 5.1:

Figure 5.1: 20 trajectories of equally spaced longitude angles, on 05/01/2018. The figure shows planetary and spacecraft trajectories

for a 10-month period.

-0.21

-0.19

-0.17

-0.15

-0.13

-0.11

-0.09

-0.07

-0.05-1.5 -1 -0.5 0

Phi(de

grees)

ln(stepsize)inln(hr)

Figure4.2:EffectofStepsizeonOpHmalPhi

70

75

80

85

90

95

-1.5 -1 -0.5 0

DuraHo

n(days)

ln(stepsize)inln(hr)

Figure4.3:EffectofStepsizeonOpHmalFlighHme

Page 10: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-10-

Figure 5.2: 20 trajectories of equally spaced longitude angles, on 01/01/2019. The figure shows planetary and spacecraft trajectories

for a 10-month period.

We found a strong correlation between feasible launch windows and launch velocities. Within the economical limits of launch velocities (Minimum 12 km/s - Maximum 17km/s), we found an expansion of approximately 7 month in the launch windows at the highest velocity. Furthermore, given that these are high priority/rescue missions, we restricted economical travel times to 7 month. These are also significantly reduced when increasing launch velocities. Flight durations for acceptable launch windows are shown in Figure 6. The full list of final data is shown in Table 4.

Figure 6: The duration of successful Earth to Mars travels as function of initial velocities and launch windows

Page 11: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-11-

V. CONCLUSION This project researched time dependent launch windows based on approximate flight trajectory calculations. We found that given that even though the launch windows remain limited, and launch velocity dependent, the launch windows of Earth based rescue missions to Mars can be extended by up to 7 months. However, even at the edges of economic possibilities with 17km/s starting velocity, there will be approximate

window down time of around 19 months (reduced from 26 months). Resulting optimal launch windows within the allotted economical limitations are shown in Figure 6, and Tables 4, 5, 6 in the Appendix. The question of further expanding launch windows with other propulsion technologies will remain open. Additionally, further research may be conducted into thruster flight correction to expand these windows.

Page 12: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-12-

VI. APPENDIX 6.1 Tables

Initialvelocity(km/s)

12 13 14 15 16 17

Startd

ate

'Jan-1-2018' 0 0 0 0 0 0'Jan-31-2018' 0 0 0 0 0 119.6333'Mar-2-2018' 0 0 125.225 114.3417 106.15 99.56667'Apr-1-2018' 139.4417 113.7083 100.6583 91.78333 85.04167 79.61667'May-1-2018' 110.875 89.66667 78.925 71.7 66.28333 61.95'May-31-2018' 108.325 76.79167 65.35 58.375 53.39167 49.53333'Jun-30-2018' 0 115.5 76.76667 61.71667 53.28333 47.61667'Jul-30-2018' 0 0 161.9167 120.95 93.26667 75.425'Aug-29-2018' 0 0 0 213.5083 176.6083 147.4583'Sep-28-2018' 0 0 0 0 0 0'Oct-28-2018' 0 0 0 0 0 0'Nov-27-2018' 0 0 0 0 0 0'Dec-27-2018' 0 0 0 0 0 0'Jan-26-2019' 0 0 0 0 0 0'Feb-25-2019' 0 0 0 0 0 0'Mar-27-2019' 0 0 0 0 0 0'Apr-26-2019' 0 0 0 0 0 0'May-26-2019' 0 0 0 0 0 0'Jun-25-2019' 0 0 0 0 0 0'Jul-25-2019' 0 0 0 0 0 0'Aug-24-2019' 0 0 0 0 0 0'Sep-23-2019' 0 0 0 0 0 0'Oct-23-2019' 0 0 0 0 0 0'Nov-22-2019' 0 0 0 0 0 0'Dec-22-2019' 0 0 0 0 0 0'Jan-21-2020' 0 0 0 0 0 0'Feb-20-2020' 0 0 0 0 0 0'Mar-21-2020' 0 0 0 0 0 0'Apr-20-2020' 0 0 0 130.0917 118.5333 109.7417'May-20-2020' 0 0 124.55 110.9583 101.2 93.625'Jun-19-2020' 159.3 119.4083 102.25 91.29167 83.28333 77.025'Jul-19-2020' 128.4667 96.025 82.05833 73.2 66.75833 61.73333

Table 4: The duration of successful Earth to Mars travels as function of initial velocities and launch windows

Page 13: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-13-

θ(radians)

12 13 14 15 16 17

Startd

ate

'Jan-1-2018' 0 0 0 0 0 0'Jan-31-2018' 0 0 0 0 0 4.99323'Mar-2-2018' 0 0 5.35386 5.33162 5.31014 5.28968'Apr-1-2018' 5.56424 5.57143 5.55324 5.53082 5.50807 5.48617'May-1-2018' 5.54249 5.59135 5.59049 5.57894 5.56464 5.54967'May-31-2018' 5.20198 5.37213 5.42543 5.44802 5.45878 5.46372'Jun-30-2018' 0 5.11857 5.13098 5.17911 5.21543 5.24219'Jul-30-2018' 0 0 5.49407 5.34628 5.2595 5.21511'Aug-29-2018' 0 0 0 5.98993 5.86351 5.75958'Sep-28-2018' 0 0 0 0 0 0'Oct-28-2018' 0 0 0 0 0 0'Nov-27-2018' 0 0 0 0 0 0'Dec-27-2018' 0 0 0 0 0 0'Jan-26-2019' 0 0 0 0 0 0'Feb-25-2019' 0 0 0 0 0 0'Mar-27-2019' 0 0 0 0 0 0'Apr-26-2019' 0 0 0 0 0 0'May-26-2019' 0 0 0 0 0 0'Jun-25-2019' 0 0 0 0 0 0'Jul-25-2019' 0 0 0 0 0 0'Aug-24-2019' 0 0 0 0 0 0'Sep-23-2019' 0 0 0 0 0 0'Oct-23-2019' 0 0 0 0 0 0'Nov-22-2019' 0 0 0 0 0 0'Dec-22-2019' 0 0 0 0 0 0'Jan-21-2020' 0 0 0 0 0 0'Feb-20-2020' 0 0 0 0 0 0'Mar-21-2020' 0 0 0 0 0 0'Apr-20-2020' 0 0 0 0.09638 0.07041 0.04628'May-20-2020' 0 0 0.41661 0.39188 0.36667 0.34202'Jun-19-2020' 0.59569 0.62644 0.61571 0.59558 0.57287 0.55011'Jul-19-2020' 0.54396 0.63958 0.65486 0.65133 0.64119 0.6289

Table 5: The duration of successful Earth to Mars travels as function of θ and launch windows

Page 14: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-14-

φ(radian)

12 13 14 15 16 17

Startd

ate

'Jan-1-2018' 0 0 0 0 0 0'Jan-31-2018' 0 0 0 0 0 -0.0931'Mar-2-2018' 0 0 -0.16137 -0.12219 -0.0989 -0.08325'Apr-1-2018' -0.30445 -0.18472 -0.14131 -0.117 -0.10116 -0.08974'May-1-2018' -0.25193 -0.18145 -0.15005 -0.13101 -0.11788 -0.10809'May-31-2018' -0.22532 -0.19104 -0.16874 -0.15378 -0.14286 -0.13439'Jun-30-2018' 0 -0.11976 -0.14212 -0.14555 -0.1446 -0.14248'Jul-30-2018' 0 0 -0.0208 -0.05419 -0.07264 -0.08429'Aug-29-2018' 0 0 0 0.05063 0.01492 -0.00588'Sep-28-2018' 0 0 0 0 0 0'Oct-28-2018' 0 0 0 0 0 0'Nov-27-2018' 0 0 0 0 0 0'Dec-27-2018' 0 0 0 0 0 0'Jan-26-2019' 0 0 0 0 0 0'Feb-25-2019' 0 0 0 0 0 0'Mar-27-2019' 0 0 0 0 0 0'Apr-26-2019' 0 0 0 0 0 0'May-26-2019' 0 0 0 0 0 0'Jun-25-2019' 0 0 0 0 0 0'Jul-25-2019' 0 0 0 0 0 0'Aug-24-2019' 0 0 0 0 0 0'Sep-23-2019' 0 0 0 0 0 0'Oct-23-2019' 0 0 0 0 0 0'Nov-22-2019' 0 0 0 0 0 0'Dec-22-2019' 0 0 0 0 0 0'Jan-21-2020' 0 0 0 0 0 0'Feb-20-2020' 0 0 0 0 0 0'Mar-21-2020' 0 0 0 0 0 0'Apr-20-2020' 0 0 0 -0.16619 -0.14013 -0.12331'May-20-2020' 0 0 -0.12775 -0.1165 -0.10793 -0.10108'Jun-19-2020' -0.04077 -0.09768 -0.09966 -0.09755 -0.09479 -0.09222'Jul-19-2020' -0.03745 -0.08194 -0.08861 -0.08996 -0.08985 -0.08922

Table 6: The duration of successful Earth to Mars travels as function of φ and launch windows

Page 15: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-15-

6.2 References Bennet, J. (Mar 2017). China Building a New Spacecraft For Manned Moon Mission.

Popular Mechanics. Retrieved November 15, 2017, from http://www.popularmechanics.com/space/moon-mars/a25603/china-building-spacecraft-manned-moon-mission/

Cain, F. (Mar 2017). How long does it take to get to Mars? Universe Today (June, 2012).

Retrieved November 25 2017, from https://www.universetoday.com/14841/how-long-does-it-take-to-get-to-mars/

CalTech (n.d.). Coordinate systems. CalTech. Retrieved November 12 2017, from

http://coolcosmos.ipac.caltech.edu/cosmic_classroom/cosmic_reference/coordsys.html

Chirgwin, R. (Oct 2017). India to launch moon mission in March 2018. The Register.

Retrieved November 18, 2017, from https://www.theregister.co.uk/2017/10/29/indias_lunar_mission_to_launch_in_2018/

Davis, J. (Sep 2017). SpaceX CEO Elon Musk updates Mars colonization plans.

Planetary. Retrieved November 20, 2017, from http://www.popularmechanics.com/space/moon-mars/a25603/china-building-spacecraft-manned-moon-mission/

Green, H. (Jan 2016). How Close Can You Get To The Sun? SciShow Space. Retrieved

November 28 2017, from https://www.youtube.com/watch?v=LIpDpRUVrNU JPL, NASA. (Oct 2016). Let's Go to Mars! Calculating Launch Windows. NASA.

Retrieved November 17 2017, from https://www.jpl.nasa.gov/edu/teach/activity/lets-go-to-mars-calculating-launch-windows/

Nah, R. S., Vadali, S. R., and E. Braden. (Nov-Dec 2001). Fuel-optimal, low-thrust,

three-dimensional earth-mars Trajectories. Journal of Guidance, Control, and Dynamics, Vol. 24, No. 6 (2001), pp. 1100-1107.

NASA (n.d.). How long would a trip to Mars take? NASA. Retrieved November 17 2017,

from https://image.gsfc.nasa.gov/poetry/venus/q2811.html NASA (Aug 2014). Space to ground: food, fuel and supplies. NASA. Retrieved

November 17 2017, from https://www.nasa.gov/content/space-to-ground-food-fuel-and-supplies

Page 16: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-16-

Smith, H. P. (n.d.). Mars/Earth comparison table. Phoenix Mars Mission. Retrieved November 20, 2017, from http://phoenix.lpl.arizona.edu/mars111.php

Sparks, Tyson. (Dec 2012). Trajectories to Mars. Colorado Center for Astrodynamics

Research. Retrieved November 10 2017, from http://ccar.colorado.edu Voesened, C.J. (June 2008). Implementing a fourth order Runge-Kutta method for orbit

simulation. n.p. Retrieved November 10 2017, from http://spiff.rit.edu/richmond

6.3 Code used Please find below the code that we used in our model. The code has been written using the C language.

#include <stdio.h> #include <math.h> #include <stdbool.h> #include <string.h> #define G -6.67384*pow(10,-20)*12960000 #define Rm 3390 #define Me 5.972*pow(10,24) #define Mm 6.39*pow(10,23) #define Ms 1.989*pow(10,30) #define Re 6731 #define Rs 695700 //XXXXXXXXXXXXXXXXXXXXXXXXX SET THESE PARAMETERS CAREFULLY: #define LaunchVelocity 12*3600 #define MAX_TIME 7300 // set maximum time of trajectory calculation in hours7300 = ~ 10 month time in hours #define MAP // define it if you want a mapping for figures and initial value of optimization #define OPTIMIZE // define it if you want optimization #define DATA_DAYS 1090 // set the size of data #define DELAY_DAYS 100 // set how many days later you want the calculations to start //Global variables: static const double epsilon = 1e-7; //delta at the partial derivatives at optimization static const double tolerance = 0.5; // min improvement for convergence of optimization of distance static const double tolParChg = 0.0000001; // min change in optimization variables (theta and phi) static const int maxIter = 100; //maximum number of iterations at optimization static const double Stepsize = 0.5; // the step-size in hours for calculating the trajectory

Page 17: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-17-

double earthXCoords[DATA_DAYS-DELAY_DAYS]; double marsXCoords[DATA_DAYS-DELAY_DAYS]; double earthYCoords[DATA_DAYS-DELAY_DAYS]; double marsYCoords[DATA_DAYS-DELAY_DAYS]; double earthZCoords[DATA_DAYS-DELAY_DAYS]; double marsZCoords[DATA_DAYS-DELAY_DAYS]; double journeyDuration = 0.0; struct planetCoord {double xe; double ye; double ze; double xm; double ym; double zm;}; struct groundVel {double uxg; double uyg; double uzg;}; // Function definitions: struct groundVel groundVelocity(double theta, double phi) { // function to calculate the velocity at the place of rocket launch due ti Earth's rotation struct groundVel gV; const double phi_of_omega = 66.56*M_PI/180; //latitude of North in Ecliptic coordinates const double theta_of_omega = 90*M_PI/180; //longitude of North in Ecliptic coordinates const double omegabs = 2*M_PI/24; // absolute value of angular velocity // calculate the angular velocity vector of Earth double omegEarthx = omegabs * cos(theta_of_omega) * cos(phi_of_omega); double omegEarthy = omegabs * sin(theta_of_omega) * cos(phi_of_omega); double omegEarthz = omegabs * sin(phi_of_omega); // calculate the coordinates at rocket launch relative to the center of Earth double rgx = 1.0*Re*cos(phi)*cos(theta); //Launch Point X double rgy = 1.0*Re*cos(phi)*sin(theta); //Launch Point Y double rgz = 1.0*Re*sin(phi); //Launch Point Z // calculate the ground velocity relative to the center of Earth gV.uxg = rgy * omegEarthz - omegEarthy * rgz; gV.uyg = omegEarthx * rgz - rgx * omegEarthz; gV.uzg = rgx * omegEarthy - omegEarthx * rgy; return gV; } struct planetCoord calcCoord(double T) { // planet coordinates at time T are calculated from daily planet coordinates with linear interpolation struct planetCoord coords; coords.xe = earthXCoords[(int)T/24] + (T/24-(int)T/24) * (earthXCoords[1+(int)T/24] - earthXCoords[(int)T/24]); coords.ye = earthYCoords[(int)T/24] + (T/24-(int)T/24) * (earthYCoords[1+(int)T/24] - earthYCoords[(int)T/24]);

Page 18: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-18-

coords.ze = earthZCoords[(int)T/24] + (T/24-(int)T/24) * (earthZCoords[1+(int)T/24] - earthZCoords[(int)T/24]); coords.xm = marsXCoords[(int)T/24] + (T/24-(int)T/24) * (marsXCoords[1+(int)T/24] - marsXCoords[(int)T/24]); coords.ym = marsYCoords[(int)T/24] + (T/24-(int)T/24) * (marsYCoords[1+(int)T/24] - marsYCoords[(int)T/24]); coords.zm = marsZCoords[(int)T/24] + (T/24-(int)T/24) * (marsZCoords[1+(int)T/24] - marsZCoords[(int)T/24]); return coords; } double RHS(int eq, double x, double y, double z, double ux, double uy, double uz, double T){ struct planetCoord coords=calcCoord(T); double xe=coords.xe; double ye=coords.ye; double ze=coords.ze; double xm=coords.xm; double ym=coords.ym; double zm=coords.zm; if (eq == 1){ return ux; //i.e. the derivative of x is ux } else if (eq == 2){ // the derivative of ux return G*((x-xe)*Me/pow(pow(x-xe,2)+pow(y-ye,2)+pow(z-ze,2),3.0/2.0)+(x-xm)*Mm/pow(pow(x-xm,2)+pow(y-ym,2)+pow(z-zm,2),3.0/2.0)+x*Ms/pow(pow(x,2)+pow(y,2)+pow(z,2),3.0/2.0)); } else if (eq == 3){ return uy; //i.e. the derivative of y is uy } else if (eq == 4){ return G*((y-ye)*Me/pow(pow(x-xe,2)+pow(y-ye,2)+pow(z-ze,2),3.0/2.0)+(y-ym)*Mm/pow(pow(x-xm,2)+pow(y-ym,2)+pow(z-zm,2),3.0/2.0)+y*Ms/pow(pow(x,2)+pow(y,2)+pow(z,2),3.0/2.0)); } else if (eq == 5){ return uz; //i.e. the derivative of z is uz } else if (eq == 6){ return G*((z-ze)*Me/pow(pow(x-xe,2)+pow(y-ye,2)+pow(z-ze,2),3.0/2.0)+(z-zm)*Mm/pow(pow(x-xm,2)+pow(y-ym,2)+pow(z-zm,2),3.0/2.0)+z*Ms/pow(pow(x,2)+pow(y,2)+pow(z,2),3.0/2.0)); } else return -1.0; } double minDistance(double theta, double phi, int experiment) {

Page 19: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-19-

//this function calculates spaceship trajectory and distances //Initialize variables double Theta = theta; double Phi = phi; double VinitSpaceShip = LaunchVelocity; // calculate initial velocity struct groundVel gV = groundVelocity(theta, phi); double ux = gV.uxg + (earthXCoords[1]-earthXCoords[0])/24.0+VinitSpaceShip*cos(Phi)*cos(Theta); //Launch Velocity X in km/h double uy = gV.uyg + (earthYCoords[1]-earthYCoords[0])/24.0+VinitSpaceShip*cos(Phi)*sin(Theta); //Launch Velocity Y in km/h double uz = gV.uzg + (earthZCoords[1]-earthZCoords[0])/24.0+VinitSpaceShip*sin(Phi); //Launch Velocity Z in km/h // calculate initial position double x = earthXCoords[0]+1.0*Re*cos(Phi)*cos(Theta); //Launch Point X double y = earthYCoords[0]+1.0*Re*cos(Phi)*sin(Theta); //Launch Point Y double z = earthZCoords[0]+1.0*Re*sin(Phi); //Launch Point Z double xe,ye,ze,xm,ym,zm; double k1x, k2x, k3x, k4x, k1ux, k2ux, k3ux, k4ux; double k1y, k2y, k3y, k4y, k1uy, k2uy, k3uy, k4uy; double k1z, k2z, k3z, k4z, k1uz, k2uz, k3uz, k4uz; double T = 0; //initializing current time in hours, i.e. start time is 0 hours double endT = MAX_TIME; //end time in hours double stepSize = Stepsize; //in hours int N = 0; // starting index double dSun; double dEarth; double dMars; double minMarsDistance = sqrt(pow(x-marsXCoords[0],2)+pow(y-marsYCoords[0],2)+pow(z-marsZCoords[0],2)); double returnValue = minMarsDistance; while (T<=endT) // Cycle of the Runge-Kutta Method: { k1x = stepSize*RHS(1,x,y,z,ux,uy,uz,T); k1ux = stepSize*RHS(2,x,y,z,ux,uy,uz,T); k1y = stepSize*RHS(3,x,y,z,ux,uy,uz,T); k1uy = stepSize*RHS(4,x,y,z,ux,uy,uz,T); k1z = stepSize*RHS(5,x,y,z,ux,uy,uz,T); k1uz = stepSize*RHS(6,x,y,z,ux,uy,uz,T); k2x = stepSize*RHS(1,x+k1x/2.0,y+k1y/2.0,z+k1z/2.0,ux+(k1ux/2.0),uy+(k1uy/2.0),uz+(k1uz/2.0),T+stepSize/2);

Page 20: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-20-

k2ux = stepSize*RHS(2,x+k1x/2.0,y+k1y/2.0,z+k1z/2.0,ux+(k1ux/2.0),uy+(k1uy/2.0),uz+(k1uz/2.0),T+stepSize/2); k2y = stepSize*RHS(3,x+k1x/2.0,y+k1y/2.0,z+k1z/2.0,ux+(k1ux/2.0),uy+(k1uy/2.0),uz+(k1uz/2.0),T+stepSize/2); k2uy = stepSize*RHS(4,x+k1x/2.0,y+k1y/2.0,z+k1z/2.0,ux+(k1ux/2.0),uy+(k1uy/2.0),uz+(k1uz/2.0),T+stepSize/2); k2z = stepSize*RHS(5,x+k1x/2.0,y+k1y/2.0,z+k1z/2.0,ux+(k1ux/2.0),uy+(k1uy/2.0),uz+(k1uz/2.0),T+stepSize/2); k2uz = stepSize*RHS(6,x+k1x/2.0,y+k1y/2.0,z+k1z/2.0,ux+(k1ux/2.0),uy+(k1uy/2.0),uz+(k1uz/2.0),T+stepSize/2); k3x = stepSize*RHS(1,x+k2x/2.0,y+k2y/2.0,z+k2z/2.0,ux+(k2ux/2.0),uy+(k2uy/2.0),uz+(k2uz/2.0),T+stepSize/2); k3ux = stepSize*RHS(2,x+k2x/2.0,y+k2y/2.0,z+k2z/2.0,ux+(k2ux/2.0),uy+(k2uy/2.0),uz+(k2uz/2.0),T+stepSize/2); k3y = stepSize*RHS(3,x+k2x/2.0,y+k2y/2.0,z+k2z/2.0,ux+(k2ux/2.0),uy+(k2uy/2.0),uz+(k2uz/2.0),T+stepSize/2); k3uy = stepSize*RHS(4,x+k2x/2.0,y+k2y/2.0,z+k2z/2.0,ux+(k2ux/2.0),uy+(k2uy/2.0),uz+(k2uz/2.0),T+stepSize/2); k3z = stepSize*RHS(5,x+k2x/2.0,y+k2y/2.0,z+k2z/2.0,ux+(k2ux/2.0),uy+(k2uy/2.0),uz+(k2uz/2.0),T+stepSize/2); k3uz = stepSize*RHS(6,x+k2x/2.0,y+k2y/2.0,z+k2z/2.0,ux+(k2ux/2.0),uy+(k2uy/2.0),uz+(k2uz/2.0),T+stepSize/2); N++; T=N*stepSize; k4x = stepSize*RHS(1, x+k3x, y+k3y, z+k3z, ux+k3ux, uy+k3uy, uz+k3uz,T); k4ux = stepSize*RHS(2, x+k3x, y+k3y, z+k3z, ux+k3ux, uy+k3uy, uz+k3uz,T); k4y = stepSize*RHS(3, x+k3x, y+k3y, z+k3z, ux+k3ux, uy+k3uy, uz+k3uz,T); k4uy = stepSize*RHS(4, x+k3x, y+k3y, z+k3z, ux+k3ux, uy+k3uy, uz+k3uz,T); k4z = stepSize*RHS(5, x+k3x, y+k3y, z+k3z, ux+k3ux, uy+k3uy, uz+k3uz,T); k4uz = stepSize*RHS(6, x+k3x, y+k3y, z+k3z, ux+k3ux, uy+k3uy, uz+k3uz,T);

Page 21: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-21-

x += k1x/6.0 + k2x/3.0 + k3x/3.0 + k4x/6.0; y += k1y/6.0 + k2y/3.0 + k3y/3.0 + k4y/6.0; z += k1z/6.0 + k2z/3.0 + k3z/3.0 + k4z/6.0; ux += k1ux/6.0 + k2ux/3.0 + k3ux/3.0 + k4ux/6.0; uy += k1uy/6.0 + k2uy/3.0 + k3uy/3.0 + k4uy/6.0; uz += k1uz/6.0 + k2uz/3.0 + k3uz/3.0 + k4uz/6.0; // Calculate distances, minimal Mars distance and alerts struct planetCoord coords=calcCoord(T); xe=coords.xe; ye=coords.ye; ze=coords.ze; xm=coords.xm; ym=coords.ym; zm=coords.zm; dMars = sqrt(pow(x-xm,2)+pow(y-ym,2)+pow(z-zm,2)); dEarth= sqrt(pow(x-xe,2)+pow(y-ye,2)+pow(z-ze,2)); dSun = sqrt(pow(x,2)+pow(y,2)+pow(z,2)); if(dMars < minMarsDistance){ minMarsDistance = dMars; returnValue = dMars-Rm; journeyDuration = T; if(dMars < Rm) { //printf("Arrived at Mars :)"); return 0.0; } } if(dSun < 5*Rs){ printf("Collision Alert with Sun!!!"); return -1; //error, space ship got too close to Sun } if(dEarth < Re){ printf("Collision Alert with Earth!!!"); return -1; //error, space ship collided with Earth } // Add print method if we want to write coordinates into file for visualization } return returnValue; } double theta_partial(double theta, double phi) { double theta_prime=(minDistance(theta+epsilon,phi,0)-minDistance(theta-epsilon,phi,0))/(2*epsilon); return theta_prime; }

Page 22: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-22-

double phi_partial(double theta, double phi) { double phi_prime=(minDistance(theta,phi+epsilon,0)-minDistance(theta,phi-epsilon,0))/(2*epsilon); return phi_prime; } int main(void) { //Read in values from text files for Earth, Mars coordinates // the coordinates are already converted from Celestial Ecliptic coordinates into the rectangular variant // calculations are performed in rectangular coordinates, however the rocket launch direction is given in // ecliptic coordinates where theta refers to longitude and phi refers to latitude FILE *earthFile; earthFile = fopen("EarthMarton.txt","r"); FILE *marsFile; marsFile = fopen("MarsMarton.txt","r"); double iniTheta = 3.4; // initial value for theta at optimization double iniPhi = 0.0; // initial value for phi at optimization const int daysInDatafile = DATA_DAYS-DELAY_DAYS; double xtempx[1], xtempy[1], xtempz[1] ; int day; for (day = 0; day < DELAY_DAYS; day++) { // read coordinates that are not needed fscanf(earthFile, "%lf %lf %lf", &xtempx[0], &xtempy[0], &xtempz[0]); fscanf(marsFile, "%lf %lf %lf", &xtempx[0], &xtempy[0], &xtempz[0]); } for (day = 0; day < daysInDatafile; day++) { // read coordinates that we needed fscanf(earthFile, "%lf %lf %lf", &earthXCoords[day], &earthYCoords[day], &earthZCoords[day]); fscanf(marsFile, "%lf %lf %lf", &marsXCoords[day], &marsYCoords[day], &marsZCoords[day]); } printf("Earth & Mars coordinates read. (Last x of Earth: %.1f)\n", earthXCoords[DATA_DAYS-1]); #ifdef MAP // Make a cycle for Theta end Phi int N = 10; // must be an even number double deltaTheta = 2*M_PI/N; // theta covers 0-2*Pi double deltaPhi = (M_PI/2)/(N/2); // phi covers just -Pi/4 - +Pi/4

Page 23: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-23-

because of the planarity double Theta = 0.0; double Phi; double minDis = 1.0e13; // initial value of global distance optimum double currDis; // optimal distance at mapping steps int item = 0; // items in the mapping for(int iii = 0; iii<(N); iii++){ Theta = deltaTheta*iii; for(int nnn = 1; nnn<N/2; nnn++){ Phi = -M_PI/4+deltaPhi*nnn; currDis = minDistance(Theta,Phi,item); printf("%.3f %.3f %.1f\n", Theta, Phi, currDis); if(currDis>=0 && currDis<minDis) { minDis = currDis; iniPhi = Phi; iniTheta = Theta; } } } printf("Best mapping values: Theta %.3f Phi %.3f Distance %.1f \n", iniTheta, iniPhi, minDis); #endif // MAP #ifdef OPTIMIZE // Optimization with the gradient descent method printf("Optimization started \n"); // coefficients for gradient double const alpha = 1.1; // expansion double const beta = 0.5; // contraction double dste = 0.06; // parameter of initial step-size - this value should be tuned by experiment double theta, phi, grad, gradTheta, gradPhi, coeff; double dtheta, dphi; double last_dist, dist; double lowPhi = -1.0; // boundaries for phi (theta has no boundary) double highPhi = 1.0; double theta0 = iniTheta; // initialize value for optimization double phi0 = iniPhi; bool constraintOK = true; int iter; last_dist = minDistance(theta0,phi0,0); // get initial fitness dist = last_dist; for (iter = 0; iter < maxIter; iter++){ //begin main loop of iteration

Page 24: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-24-

gradTheta = -1 * theta_partial(theta0, phi0); gradPhi = -1 * phi_partial(theta0, phi0); grad = sqrt(gradTheta * gradTheta + gradPhi * gradPhi); if (grad == 0){ // check if the value is already optimized printf("Iteration terminated because optimum reached \n"); break; } coeff = dste / grad; // calculate the step/gradient value dtheta = coeff * gradTheta; // amount of change in theta theta = theta0 + dtheta; // new value of theta dphi = coeff * gradPhi; phi = phi0 + dphi; if (phi < lowPhi || phi > highPhi){ constraintOK = false; } dist = minDistance(theta,phi,0); //get new distance if (dist < Rm){ // check if we arrived at Mars printf("Iteration terminated because we arrived at Mars \n"); break; } if (fabs(dist-last_dist)<= tolerance){ // check if distance change is already too small printf("Iteration terminated because small change in distance \n"); break; } if (fabs(dtheta) <= tolParChg && fabs(dphi) <= tolParChg){ // check if change in parameters are too small printf("Iteration terminated because small change in angles \n"); break; } if (dist > last_dist || !constraintOK){ // check if last step was too long dste *= beta; }else{ dste *= alpha; last_dist = dist; theta0 = theta;

Page 25: ProjectPaper Backupdpsaltis/Phys305/szep.pdfscale colonization of our red planet (Davis, 2017). Due to the considerable distance of over 54.6 million kilometers between Earth and Mars,

-25-

phi0 = phi; } printf(" Min dist: %.1f theta: %.5f phi: %.5f iteration: %d \n", dist, theta, phi, iter+1); } if (iter == (maxIter -1)){ printf("Optimization did not converge \n"); } else { dist = minDistance(theta,phi,0); } printf("Final min dist: %.1f theta: %.5f phi: %.5f duration of journey: %.1f days (iteration: %d) \n", dist, theta, phi, journeyDuration/24, iter+1); printf("dste %.8f dtheta %.8f dphi %.8f \n", dste, dtheta, dphi); #endif // OPTIMIZE return 0; }