Skip to content

Commit

Permalink
Merge pull request #39 from alopezrivera/dev
Browse files Browse the repository at this point in the history
Improved wording in porkchop example
  • Loading branch information
DominicDirkx committed Jan 11, 2024
2 parents 04ecdc3 + b27466d commit 582f354
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 56 deletions.
40 changes: 14 additions & 26 deletions mission_design/earth_mars_transfer_window.ipynb
Expand Up @@ -14,40 +14,26 @@
"a copy of the license with this file. If not, please or visit:\n",
"http://tudat.tudelft.nl/LICENSE.\n",
"\n",
"## **Important**\n",
"This example requires the `tudatpy.trajectory_design.porkchop` module.\n",
"Please ensure that your version of tudatpy does include this module.\n",
"\n",
"## Summary\n",
"This example shows how the tudatpy `porkchop` module can be used to choose\n",
"an optimal launch and arrival date for an Earth-Mars transfer. By default,\n",
"the porkchop module uses a Lambert arc to compute the $\\Delta V$ required to\n",
"depart from the departure body (Earth in this case) and be captured by the \n",
"target body (in this case Mars).\n",
"\n",
"Users can provide a custom function to calculate the $\\Delta V$ required for any\n",
"given transfer. This can be done by supplying a `callable` (a function)\n",
"to the `porkchop` function via the argument\n",
"This example demonstrates the usage of the tudatpy `porkchop` module to determine an optimal launch window (departure and arrival date) for an Earth-Mars transfer mission.\n",
"\n",
" function_to_calculate_delta_v\n",
"By default, the porkchop module uses a Lambert arc to compute the $\\Delta V$ required to depart from the departure body (Earth in this case) and be captured by the target body (in this case Mars).\n",
"\n",
"This opens the possibility to calculate the $\\Delta V$ required for any transfer\n",
"accounting for course correction manoeuvres along a planned trajectory.\n",
"Users can provide a custom function to calculate the $\\Delta V$ required for any given transfer. This can be done by supplying a `callable` (a function) to the `porkchop` function via the argument\n",
"\n",
"### Structure\n",
"This example consists of 3 sections:\n",
" function_to_calculate_delta_v\n",
"\n",
"1. The imports, where we import the required modules\n",
"2. Data management, where we define the file where the porkchop data will be saved\n",
"3. The porkchop itself, which will only be recalculated if the user requests it"
"This opens the possibility to calculate the $\\Delta V$ required for any transfer; potential applications include: low-thrust transfers, perturbed transfers with course correction manoeuvres, transfers making use of Gravity Assists, and more."
]
},
{
"cell_type": "markdown",
"id": "57ec02e2",
"metadata": {},
"source": [
"## Import statements"
"## Import statements\n",
"\n",
"The required import statements are made here, starting with standard imports (`os`, `pickle` from the Python Standard Library), followed by tudatpy imports."
]
},
{
Expand All @@ -74,7 +60,9 @@
"id": "5b392321",
"metadata": {},
"source": [
"## Environment setup"
"## Environment setup\n",
"\n",
"We proceed to set up the simulation environment, by loading the standard Spice kernels, defining the origin of the global frame and creating all necessary bodies. "
]
},
{
Expand Down Expand Up @@ -106,7 +94,7 @@
"metadata": {},
"source": [
"## Porkchop Plots\n",
"We proceed to define the departure and target bodies and the time window for the transfer,"
"The departure and target bodies and the time window for the transfer are then defined using tudatpy `astro.time_conversion.DateTime` objects."
]
},
{
Expand All @@ -131,7 +119,7 @@
"id": "58f64818",
"metadata": {},
"source": [
"To ensure the porkchop plot is rendered with good resolution, we calculate the time resolution of the plot to be 0.5% of the smallest time window (either the arrival or the departure window):"
"To ensure the porkchop plot is rendered with good resolution, the time resolution of the plot is defined as 0.5% of the smallest time window (either the arrival or the departure window):"
]
},
{
Expand All @@ -156,7 +144,7 @@
"id": "e642529d",
"metadata": {},
"source": [
"Generating a high-resolution plot may be time-consuming, and reusing saved data might be desirable, so we ask the user whether to reuse saved data or generate the plot from scratch."
"Generating a high-resolution plot may be time-consuming: reusing saved data might be desirable; we proceed to ask the user whether to reuse saved data or generate the plot from scratch."
]
},
{
Expand Down
42 changes: 12 additions & 30 deletions mission_design/earth_mars_transfer_window.py
Expand Up @@ -10,43 +10,23 @@
"""


## **Important**
"""
This example requires the `tudatpy.trajectory_design.porkchop` module.
Please ensure that your version of tudatpy does include this module.
"""


## Summary
"""
This example shows how the tudatpy `porkchop` module can be used to choose
an optimal launch and arrival date for an Earth-Mars transfer. By default,
the porkchop module uses a Lambert arc to compute the $\Delta V$ required to
depart from the departure body (Earth in this case) and be captured by the
target body (in this case Mars).
Users can provide a custom function to calculate the $\Delta V$ required for any
given transfer. This can be done by supplying a `callable` (a function)
to the `porkchop` function via the argument
function_to_calculate_delta_v
This example demonstrates the usage of the tudatpy `porkchop` module to determine an optimal launch window (departure and arrival date) for an Earth-Mars transfer mission.
This opens the possibility to calculate the $\Delta V$ required for any transfer
accounting for course correction manoeuvres along a planned trajectory.
"""
By default, the porkchop module uses a Lambert arc to compute the $\Delta V$ required to depart from the departure body (Earth in this case) and be captured by the target body (in this case Mars).
Users can provide a custom function to calculate the $\Delta V$ required for any given transfer. This can be done by supplying a `callable` (a function) to the `porkchop` function via the argument
### Structure
"""
This example consists of 3 sections:
function_to_calculate_delta_v
1. The imports, where we import the required modules
2. Data management, where we define the file where the porkchop data will be saved
3. The porkchop itself, which will only be recalculated if the user requests it
This opens the possibility to calculate the $\Delta V$ required for any transfer; potential applications include: low-thrust transfers, perturbed transfers with course correction manoeuvres, transfers making use of Gravity Assists, and more.
"""

## Import statements
"""
The required import statements are made here, starting with standard imports (`os`, `pickle` from the Python Standard Library), followed by tudatpy imports.
"""

# General imports
Expand All @@ -62,6 +42,8 @@

## Environment setup
"""
We proceed to set up the simulation environment, by loading the standard Spice kernels, defining the origin of the global frame and creating all necessary bodies.
"""

# Load spice kernels
Expand All @@ -81,7 +63,7 @@

## Porkchop Plots
"""
We proceed to define the departure and target bodies and the time window for the transfer,
The departure and target bodies and the time window for the transfer are then defined using tudatpy `astro.time_conversion.DateTime` objects.
"""

departure_body = 'Earth'
Expand All @@ -93,7 +75,7 @@
earliest_arrival_time = DateTime(2005, 11, 16)
latest_arrival_time = DateTime(2006, 12, 21)

# To ensure the porkchop plot is rendered with good resolution, we calculate the time resolution of the plot to be 0.5% of the smallest time window (either the arrival or the departure window):
# To ensure the porkchop plot is rendered with good resolution, the time resolution of the plot is defined as 0.5% of the smallest time window (either the arrival or the departure window):

# Set time resolution IN DAYS as 0.5% of the smallest window (be it departure, or arrival)
# This will result in fairly good time resolution, at a runtime of approximately 10 seconds
Expand All @@ -104,7 +86,7 @@
latest_arrival_time.epoch() - earliest_arrival_time.epoch()
) / constants.JULIAN_DAY * time_window_percentage / 100

# Generating a high-resolution plot may be time-consuming, and reusing saved data might be desirable, so we ask the user whether to reuse saved data or generate the plot from scratch.
# Generating a high-resolution plot may be time-consuming: reusing saved data might be desirable; we proceed to ask the user whether to reuse saved data or generate the plot from scratch.

# File
data_file = 'porkchop.pkl'
Expand Down

0 comments on commit 582f354

Please sign in to comment.