Skip to content
Snippets Groups Projects
Commit 8f805d0c authored by Yvan's avatar Yvan
Browse files

Up to date asteroids Module

parent dd159057
Branches
Tags v-1.0
No related merge requests found
......@@ -3,7 +3,7 @@
"""
Created on Mon Feb 24 16:03:44 2020
@author: i.kovalenko
@author: Irina Kovalenko
"""
import os
import pickle
......@@ -127,7 +127,7 @@ class AsteroidRoundtripMission:
self.data_organized_earth2ast = list()
self.data_organized_ast2earth = list()
# Attributes to be calculated in the 'solution' function
# Attributes to be calculated in the 'solution' funcion
self.earth2asteroid = list()
self.asteroid2earth = list()
self.departures = list()
......@@ -302,23 +302,6 @@ class AsteroidRoundtripMission:
mission_limit = self.mission_duration_limit
# ear_dep = [(data.departure) for data in results_earth2asteroid]
# ast_arr = [(data.arrival) for data in results_earth2asteroid]
# ast_dep = [(data.departure) for data in results_asteroid2earth]
# ear_arr = [(data.arrival) for data in results_asteroid2earth]
# tof1 = [(data.tof) for data in results_earth2asteroid]
# tof2 = [(data.tof) for data in results_asteroid2earth]
# for i in range(len(ear_dep)):
# for j in range(len(ast_dep)):
# ast_dep_limit = datetime.date.fromisoformat(ast_arr[i])+
# datetime.timedelta(days=self.stay)
# if ast_dep[j] >= ast_dep_limit:
# stay_exact = ast_dep[j]-
# datetime.date.fromisoformat(ast_arr[i])
# tof_total = tof1[i] + tof2[j] + stay_exact.days
data_summary = list()
for data1 in results_earth2asteroid:
for data2 in results_asteroid2earth:
......@@ -427,9 +410,11 @@ class AsteroidRoundtripMission:
return solution
def porkchop_plot_total_dV(self, **kwargs):
"""Plot of total delta-V as a function of departure date and
flight time.
def porkchop_plot_outbound_dV(self, **kwargs):
"""Plot of outbound delta-V as a function of departure date and
flight time. The delta-V includes a manoeuvre of departure from
the parking LEO (if specified) and a manoeuvre to match asteroid's
velosity.
Parameters
----------
......@@ -440,34 +425,87 @@ class AsteroidRoundtripMission:
levels : int, optional
Level set.
"""
results = self.earth2asteroid
dates_departure = [str(data.departure) for data in results]
tofs = [data.tof for data in results]
v_inf_dep_earth = [data.v_inf0 for data in results]
v_inf_arr_ast = [data.v_inf1 for data in results]
# Calculate the Total delta-V
# delta-v at Earth (or LEO) departure
mu0 = cst.GM_EARTH
if self.parking_orbit:
r0 = self.leo_alt + cst.R_EARTH_EQ
delta_v0 = numpy.sqrt(
2*mu0/r0 + numpy.power(norm(v_inf_dep_earth, axis=1), 2))\
- numpy.sqrt(mu0/r0)
else:
delta_v0 = norm(v_inf_dep_earth, axis=1)
plot_title = r'Total $\Delta$ V'
bar_label = r'Total $\Delta$ V, km/s'
# delta-v at asteroid rdv (to match asteroid's velosity)
dv_ast_rdv = norm(v_inf_arr_ast, axis=1)
plot_title = r'Earth-to-Asteroid'
bar_label = r'$\Delta$ V, km/s'
if 'dv_limit' in kwargs:
dv_limit = kwargs.get('dv_limit')
else:
dv_limit = 30.0
dv_limit = 10.0
if 'levels' in kwargs:
levels = kwargs.get('levels')
else:
levels = 20
data_plot = numpy.array([self.departures, self.mission_duration,
self.total_dv])
dv_sum = delta_v0 + dv_ast_rdv
data_plot = numpy.array([dates_departure, tofs,
dv_sum])
porkchop_plot.plot(data_plot, plot_title, dv_limit, levels, bar_label)
# dv = self.total_dv.copy()
# dep = []
# tof = []
# dv_plot = []
# for i in range(len(dv)):
# if dv[i] < dv_limit:
# dep.append(self.departures[i])
# tof.append(self.mission_duration[i])
# dv_plot.append(self.total_dv[i])
def porkchop_plot_inbound_dV(self, **kwargs):
"""Plot of inbound delta-V as a function of departure date and
flight time. The delta-V includes a manoeuvre of departure from
the asteroid and v_inf at Earth arrival.
velosity.
# data_plot = numpy.array([dep, tof, dv_plot])
Parameters
----------
**kwargs :
# porkchop_plot.plot(data_plot, plot_title, dv_limit, levels,bar_label)
dv_limit : float, optional
Cut colours if dv > dv_limit.
levels : int, optional
Level set.
"""
results = self.asteroid2earth
dates_departure = [str(data.departure) for data in results]
tofs = [data.tof for data in results]
v_inf_dep_ast = [data.v_inf0 for data in results]
v_inf_arr_earth = [data.v_inf1 for data in results]
# delta-v at asteroid departure
delta_v0 = norm(v_inf_dep_ast, axis=1)
# v_infinity at Earth arrival
vinf_earth = norm(v_inf_arr_earth, axis=1)
plot_title = r'Asteroid-to-Earth'
bar_label = r'$\Delta$ V, km/s'
if 'dv_limit' in kwargs:
dv_limit = kwargs.get('dv_limit')
else:
dv_limit = 10.0
if 'levels' in kwargs:
levels = kwargs.get('levels')
else:
levels = 20
dv_sum = delta_v0 + vinf_earth
data_plot = numpy.array([dates_departure, tofs,
dv_sum])
porkchop_plot.plot(data_plot, plot_title, dv_limit, levels, bar_label)
......@@ -3,7 +3,7 @@
"""
Created on Wed Mar 11 10:55:01 2020
@author: i.kovalenko
@author: Irina Kovalenko
"""
import pykep as pk
......
File added
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment