GMAT Mars transfer orbit model

DiruMarco

New member
Joined
Nov 6, 2023
Messages
5
Reaction score
0
Points
1
Location
Italy
Hello everyone, I'm new here so If I'm writing anything wrong tell me. I'm an aerospace engineering student, for a Uni project we're designing a Mars lander and I'm trying to model the transfer orbit from Earth to Mars on GMAT in order to have the orbit and position for the landing and departure phase. My orbital mechanics knowledge is very limited since my bachelor is focused on aeronautics rather than space so I'm having some trouble. The launch date from Earth should be around 2040 so I've used a matlab script with a lambert solver that I found in the book Orbital Mechanics for Engineering Students, Exercise 8.08 for reference, to have the data about the transfer orbit.
This is the output of the script
Example 8.8

Departure:

Planet: Earth
Year : 2040
Month : May
Day : 7
Hour : 0
Minute: 0
Second: 0

Julian day: 2466281.500

Planet position vector (km) = [-1.03902e+08 -1.09492e+08 11864.8]
Magnitude = 1.50944e+08

Planet velocity (km/s) = [21.1239 -20.6176 0.00138267]
Magnitude = 29.5179

Spacecraft velocity (km/s) = [19.3726 -28.0145 -0.931206]
Magnitude = 34.0731

v-infinity at departure (km/s) = [-1.75132 -7.39691 -0.932589]
Magnitude = 7.6584


Time of flight = 493 days


Arrival:

Planet: Mars
Year : 2041
Month : September
Day : 12
Hour : 0
Minute: 0
Second: 0

Julian day: 2466774.500

Planet position vector (km) = [8.87105e+07 2.08065e+08 2.18782e+06]
Magnitude = 1.50944e+08

Planet velocity (km/s) = [-21.3728 11.5668 0.766488]
Magnitude = 24.3141

Spacecraft Velocity (km/s) = [-23.9898 0.456169 0.496433]
Magnitude = 23.9992

v-infinity at arrival (km/s) = [-2.61699 -11.1106 -0.270056]
Magnitude = 11.4179


Orbital elements of flight trajectory:

Angular momentum (km^2/s) = 5.03387e+09
Eccentricity = 0.374728
Right ascension of the ascending node (deg) = 46.6618
Inclination to the ecliptic (deg) = 1.60102
Argument of perihelion (deg) = 134.835
True anomaly at departure (deg) = 45.0034
True anomaly at arrival (deg) = 245.419

Semimajor axis (km) = 2.22129e+08
Period (days) = 660.875

Mind that I'm still trying to reproduce the orbit on GMAT so optimization will come after.
The problem is the GMAT modelling, I've watched the GMAT tutorial "Mars B-Plane Targeting" and I'm trying to adapt it but I don't know where to start. Any help would be appreciated
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
225
Reaction score
93
Points
28
BTW, for Earth-Mars transfer the departure at 2040-May-07 and arrival at 2041-Sep-12 are far from optimal dates:
Code:
Date of    earth departue :  2040-May-07 00:00:00
Date of     mars arrival  :  2041-Sep-12 00:00:00

Transfer time from    earth to     mars: 493.0  days
Total mission duration:                  493.0  days


TransX escape plan -     earth escape
======================================================================
MJD:                  66281.00000000 
Prograde:              3912.8667 m/s
Outward:               6518.6480 m/s
Plane:                  933.1279 m/s
Hyp. excess velocity:  7659.8973 m/s
   earth escape burn:  5617.7439 m/s
------------------GMAT------------------
GMAT TDBModJulian:     36281.5
GMAT OutgoingC3:       58.67402590608339
GMAT OutgoingRHA:      -103.33027110377307
GMAT OutgoingDHA:      -6.992047694315104

    mars arrival
======================================================================
MJD:                  66774.0000    
Solution number:               1 
Hyp. excess velocity: 11417.7132 m/s
Orbit insertion burn   7577.4282 m/s - C3 = 0
------------------GMAT------------------
GMAT TDBModJulian:     36774.5
GMAT IncomingC3:       130.36417571235333
GMAT IncomingRHA:      -103.26165984731512
GMAT IncomingDHA:      -1.3548498059787222

========================================
Total fuel cost:     13195.1721 m/s
1699374401293.png
1699374537898.png
 

DiruMarco

New member
Joined
Nov 6, 2023
Messages
5
Reaction score
0
Points
1
Location
Italy
The easiest way to use the lamber solution with GMAT is to convert v-infinity at departure to GMAT's OutgoingAsymptote (OutgoingC3/OutgoingRHA/OutgoingDHA) and then optimize it in GMAT.
Take a look at https://orbiter-forum.com/threads/pykep-to-transx-conversion.33685/#post-514495
Thank you very much, I will check it out. By the way the dates were pretty much random, it was just to try if the matlab script was working properly. How can i find the optimal date? I know that the optimal period should repeat approximately every 2.16 years but I don't know how to choose the exact date, the launch should be around 2040
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
225
Reaction score
93
Points
28

DiruMarco

New member
Joined
Nov 6, 2023
Messages
5
Reaction score
0
Points
1
Location
Italy
Just use some porkchop plotter application.
I even made one many years ago ( https://www.orbiter-forum.com/resources/lambertsolver.3050/ )
But now it's easier to use online porkchop plotters, e.g.: http://sdg.aero.upm.es/index.php/online-apps/porkchop-plot
Thank you, that's what I was looking for. I'm sorry that my questions are probably stupid but as i said before orbital mechanics is not part of my bachelor so my knowledge is very limited. I'm still trying to figure out how to install all the necessary libraries to run the python script
 

DiruMarco

New member
Joined
Nov 6, 2023
Messages
5
Reaction score
0
Points
1
Location
Italy
Just use some porkchop plotter application.
I even made one many years ago ( https://www.orbiter-forum.com/resources/lambertsolver.3050/ )
But now it's easier to use online porkchop plotters, e.g.: http://sdg.aero.upm.es/index.php/online-apps/porkchop-plot
BTW, for Earth-Mars transfer the departure at 2040-May-07 and arrival at 2041-Sep-12 are far from optimal dates:
Code:
Date of    earth departue :  2040-May-07 00:00:00
Date of     mars arrival  :  2041-Sep-12 00:00:00

Transfer time from    earth to     mars: 493.0  days
Total mission duration:                  493.0  days


TransX escape plan -     earth escape
======================================================================
MJD:                  66281.00000000
Prograde:              3912.8667 m/s
Outward:               6518.6480 m/s
Plane:                  933.1279 m/s
Hyp. excess velocity:  7659.8973 m/s
   earth escape burn:  5617.7439 m/s
------------------GMAT------------------
GMAT TDBModJulian:     36281.5
GMAT OutgoingC3:       58.67402590608339
GMAT OutgoingRHA:      -103.33027110377307
GMAT OutgoingDHA:      -6.992047694315104

    mars arrival
======================================================================
MJD:                  66774.0000   
Solution number:               1
Hyp. excess velocity: 11417.7132 m/s
Orbit insertion burn   7577.4282 m/s - C3 = 0
------------------GMAT------------------
GMAT TDBModJulian:     36774.5
GMAT IncomingC3:       130.36417571235333
GMAT IncomingRHA:      -103.26165984731512
GMAT IncomingDHA:      -1.3548498059787222

========================================
Total fuel cost:     13195.1721 m/s
View attachment 35628
View attachment 35629
Sorry to bother you again, I've been able to set up and run your python script with the default data and it worked but I'm not entirely sure how to change the input data for my specific case. I've used the porkchop plotter that you suggested me and 2043.92 looks like a favourable date with around 170/180 trip days and 4 Km/s DV. How do I have to modify the main.py file?
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
225
Reaction score
93
Points
28
How do I have to modify the main.py file?
Just select flyby parameters. It was initially designed by Keithth G to find and optimize trajectories with multiple gravity assist maneuvers. But nothing prevents to use it with simple trajectories. For example:
Python:
import sys
import pygmo as pg
from flyby import flyby

p = flyby(['earth', 'mars'],
          [66281, 493],
          [0, 0], ignore_last=False, days=1, multi_revs=1)


algo = pg.algorithm(pg.de1220(gen=10))
archi = pg.archipelago(n=2, algo=algo, t=pg.topology(pg.ring(w=0.1)), prob=pg.problem(p), pop_size=100)
archi.evolve(1000)

sols = archi.get_champions_f()
idx = sols.index(min(sols))
p.fitness(archi.get_champions_x()[idx])
p.print_transx()
 

DiruMarco

New member
Joined
Nov 6, 2023
Messages
5
Reaction score
0
Points
1
Location
Italy
Just select flyby parameters. It was initially designed by Keithth G to find and optimize trajectories with multiple gravity assist maneuvers. But nothing prevents to use it with simple trajectories. For example:
Python:
import sys
import pygmo as pg
from flyby import flyby

p = flyby(['earth', 'mars'],
          [66281, 493],
          [0, 0], ignore_last=False, days=1, multi_revs=1)


algo = pg.algorithm(pg.de1220(gen=10))
archi = pg.archipelago(n=2, algo=algo, t=pg.topology(pg.ring(w=0.1)), prob=pg.problem(p), pop_size=100)
archi.evolve(1000)

sols = archi.get_champions_f()
idx = sols.index(min(sols))
p.fitness(archi.get_champions_x()[idx])
p.print_transx()
p = flyby(['earth', 'mars'],
[66281, 493],
[0, 0], ignore_last=False, days=1, multi_revs=1)
So regarding the parameters.. between the first parentheses I insert the planet, so in case of a direct transfer orbit just Earth and Mars, in the second the first parameter is the the departure date in modified Julian format while the second can be either the number of travel days or the arrival date in the same format, I don't know what are the 0 in this case between the next parentheses, is it something like a tolerance on both departure and arrival date? Is it used to to give it the chance to find the best solution?
ignore_last=False, days=1, multi_revs=1 for these parameters I honestly don't know what they represent
 

Ajaja

Active member
Joined
Apr 20, 2008
Messages
225
Reaction score
93
Points
28
what are the 0 in this case between the next parentheses,
It's windows in days where to search for an optimal trajectory. With 0 it just calculates for selected dates.
ignore_last=False
If True - ignore minimal dV needed for the final maneuver (orbital insertion) and optimize only for departure dV (and dV at flybys for multybody trajectories).
Days or dates. With days=0 it will consider second (493 in the example) and other array values in the second argument as MJDs.
multi_revs=1
Maximum number of revolutions around Sun. For complex trajectories.
 
Top