def part_a( self ): ''' a) ideal trajectory: no drag (C=0) and no spin (-> Magnus force = 0) [2 points] ''' initial_velocity = self.initial_velocity dimpled = False spin = 0 def C( v, dimpled ): return 0 for initial_angle in self.initial_angles_degrees: part_a_ball = Golf( initial_velocity, initial_angle, C, dimpled, spin ) part_a_ball.display_plot() for filetype in self.filetypes: part_a_ball.save_plot( filetype )
file_directory = "/home/res/Documents/duke/2012S/PHY260/homeworks/homework3/" # TODO: edit the following line, implement differently when processing data for different parts of the assignment. file_name_base = "PHY260_Grisaitis_homework3_" file_type_extensions = ['png'] initial_angles_degrees = ( 9, 15, 30, 45 ) initial_speed = 70 dt = 0.01 # This array contains the parameters specific to each part of the problem. question_parameters = [ \ ['A', 0.0, False, False, 'Ideal'], \ ['B', 0.5, False, False, 'With air resistance'], \ ['C', 0.5, True, False, 'With air resistance and dimples'], \ ['D', 0.5, True, True, 'With air resistance, dimples, and spin']] for ( part, C, dimpled, spin, info ) in question_parameters: # initialize a model object for each part of the problem golf_ball = Golf( initial_angles_degrees, initial_speed, C, dimpled, spin ) golf_ball.solve_with_Euler( dt ) file_name_base = "PHY260_Grisaitis_homework3_" + part # plot the model and save results to file golf_ball.plot_and_save_models( \ file_directory = file_directory, \ file_name_base = file_name_base, \ file_types = file_type_extensions, \ info_text = ( ( 'Part %s:' % part ) + info ) \ )