Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# File called flyby_fnsimport numpy as npimport matplotlib.pyplot as pltdef grav_acc(s_x, s_y, planet_mass): Find the instantaneous spacecraft acceleration at s_x, s_y away from the

# File called "flyby_fns"import numpy as npimport matplotlib.pyplot as pltdef grav_acc(s_x, s_y, planet_mass): """ Find the instantaneous spacecraft acceleration at s_x, s_y away from the planet Inputs: s_x (meters), s_y (meters): the x, y components of a single position vector respectively; planet_mass (kilograms): the mass of the planet Ouput: a_x (m/s^2), a_y (m/s^2) the x, y components of instantaneous spacecraft acceleration """ s = (s_x**2 + s_y**2)**0.5 inst_a = (6.67e-11 * planet_mass)/(s**2) # Beta is angle between accleration vector and y dir. sin_beta = -s_x/s cos_beta = -s_y/s a_x = inst_a * sin_beta a_y = inst_a * cos_beta return (a_x, a_y)def checkinit(s_x0, s_y0, v_x0, v_y0, planet_radius): """ Checks if the starting position (origin at center of planet) of the spacecraft is above the planetary surface, and the starting velocity is in the positive y-direction; raises a ValueError otherwise. Inputs: s_x0 (meters), s_y0 (meters): the initial x and y spacecraft position; v_x0 (m/s), v_y0 (m/s): the initial x and y spacecraft velocity (magnitude) Output: none """ s_mag = (s_x0**2 + s_y0**2) ** 0.5 # Check if spacecraft is above the planetary surface if (s_mag 
# Part C - i)import numpy as npimport timeimport flyby_fns as flyby# Initialize variablesplanet_mass = 3.3e23planet_radius = 2440000initial_s_y0 = -3 * planet_radius # Initial y-coordinate of the spacecraft positiontotal_integration_time = 40 * 60 # Total integration time in secondsoutput_filename = 'part3C_sx0_CA.txt' # Define filename# Create a list to store results from the fileresult_table = [] # Loop over different initial y-coordinatesfor i in range(10): # Calculate current y-coordinate and update total integration time current_s_y0 = initial_s_y0 * 2 ** i current_total_time = total_integration_time * 2 ** i # Call get_traj to compute the trajectory time_start = time.perf_counter() result_time, acc, vel, pos = flyby.get_traj(s_x0 = -3050000, s_y0 = current_s_y0, v_x0 = 0, v_y0 = 7000, time_step = 60, total_time = current_total_time, planet_mass = 3.3e23, planet_radius = 2440000) time_end = time.perf_counter() # Find the minimum altitude from the trajectory min_altitude = np.min(np.sqrt(pos[:, 0]**2 + pos[:, 1]**2) - planet_radius) # Append results to the result table result_table.append(f"{current_s_y0 / planet_radius:.1f} \t{min_altitude / 1000:.1f} ") # Print current progress print(f"Completed iteration {i + 1}/10")# Write the result table to the output filewith open(output_filename, 'w') as f: f.writelines("s_y0(Rp)\t min alt(km) ") f.writelines(result_table)

image text in transcribedimage text in transcribedimage text in transcribed
3C ii) Effect of time step - Set up another simulation: - Set SW to be 96R,,. (Although it should be larger, this makes the computations take longer.) - Set the total time for the integration, If, to be 1280 minutes. - Define a variable amrget for the target closest approach altitude. Set \"target to be 195 km. - Now investigate the effect of the time increment (At) used in the numerical integration. - Start with At = 60 seconds, compute the spacecraft trajectory, then halve the value of At. Keep if = 1280 mins. Repeat until the closest approach altitude ac is within 2% of the target altitude, that is until the percentage error 100 =l

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Electromagnetics

Authors: B.B. Laud

3rd Edition

8122430554, 9788122430554

More Books

Students also viewed these Physics questions

Question

7. How can the models we use have a detrimental effect on others?

Answered: 1 week ago