# -*- coding: utf-8 -*-
"""
Template for the main solution code in Part 5 of the project.
The objective of the template files is to give you an idea of
the most important functions that you have to implement, what
input they will need and what output they should produce.
To make things work in practice you will have to add more
functionalities than the ones outlined, and you might have
to adapt the interfaces to fit your specific approach.
You are of course free (and encouraged) to structure the code
in any way you want!
"""
import ast2000tools.constants as const
import ast2000tools.utils as utils
from ast2000tools.space_mission import SpaceMission
import part_1
import part_3
import part_4
def simulate_spacecraft_trajectory(system,
start_time,
start_position,
start_velocity,
duration,
n_time_steps_per_year):
"""
Here you can implement the ballistic trajectory simulation for
challenge A of Part 5 of the project.
"""
# Load the exact planet trajectories from Part 2
planet_times, planet_positions = np.load('planet_trajectories.npy')
# Insert awesome code here...
# You will probably also need these quantities:
# const.G_sol
# system.star_mass
# system.masses
return final_time, final_position, final_velocity
def run_trajectory_planning_simulation(mission,
number_of_boxes,
number_of_particles_in_box,
box_side_length,
temperature,
box_hole_area,
initial_fuel_mass,
launch_direction,
time_of_launch,
destination_planet_idx,
boost_times,
boost_velocities):
"""
Here you can implement the trajectory planning simulation for
challenge B of Part 5 of the project.
"""
# Simulate launch
rocket_position_after_launch, \
rocket_velocity_after_launch, \
fuel_mass_after_launch, \
time_after_launch \
= part_3.simulate_full_launch(mission,
number_of_boxes,
number_of_particles_in_box,
box_side_length,
temperature,
box_hole_area,
initial_fuel_mass,
launch_direction,
time_of_launch)[4:]
# Insert awesome code here...
# You will also need the following method:
# part_1.compute_fuel_mass_needed_for_boost
# You might want to generate some plots to inspect the results.
def send_spacecraft(interplanetary_travel,
destination_planet_idx,
boost_times,
boost_velocities):
"""
Here you can implement the commanding of the spacecraft for
challenge C of Part 5 of the project.
"""
# Insert awesome code here...
# You might want to generate some cool videos and pictures
# to view in MCAst.
# Record the state after entering a stable orbit around the destination planet
interplanetary_travel.record_destination(destination_planet_idx)
# Prevent the following code from executing when calling `import part_5`
if __name__ == '__main__':
# Print a message if a newer version of ast2000tools is available
utils.check_for_newer_version()
# Construct SpaceMission instance for my mission
seed = utils.get_seed('my_username')
mission = SpaceMission(seed)
# Run planning simulations to determine launch parameters and boosts here...
# Perform the real launch with the parameters resulting from the planning
part_4.launch_and_orient_spacecraft(mission,
number_of_boxes,
number_of_particles_in_box,
box_side_length,
temperature,
box_hole_area,
initial_fuel_mass,
launch_direction,
time_of_launch)
# Initiate the real interplanetary travel
interplanetary_travel = mission.begin_interplanetary_travel()
# Send the spacecraft on its way to the destination planet
send_spacecraft(interplanetary_travel,
destination_planet_idx,
boost_times,
boost_velocities)
# Save the mission instance after entering orbit
SpaceMission.save('mission_after_part_5.pickle', mission)