Question: write in python Exercise 8.10 Many comets travel in highly elongated orbits around the Sun. For much of their lives they are far out in
write in python
Exercise 8.10 Many comets travel in highly elongated orbits around the Sun. For much of their lives they are far out in the solar system, moving very slowly, but on rare occasions their orbit brings them close to the Sun for a fly-by and for a brief period of time they move very fast indeed (check your textbook for a diagram). This is a classic example of a system for which an adaptive step size method is useful, because for the large periods of time when the comet is moving slowly we can use long time-steps, so that the program runs quickly, but short time-steps are crucial in the brief but fast-moving period close to the Sun. The differential equation obeyed by a comet is straightforward to derive. The force between the Sun, with mass M at the origin, and a comet of mass m with position vector is GMm/r in direction -Fr (ie., the direction towards the Sun), and hence Newton's second law tells us that Canceling the m and taking the x component we have m dr GMm = di = -GM and similarly for the other two coordinates. We can, however, throw out one of the coordinates because the comet stays in a single plane as it orbits. If we orient our axes so that this plane is perpendicular to the z-axis, we can forget about the z coordinate and we are left with just two second-order equations to solve: where r = x + y x=-GM =-GM a) Turn these two second-order equations into four first-order equations, using the methods you have learned. Type your response here or insert an image Pts 15 b) Write a program to solve your equations using the fourth-order Runge--Kutta method with a fixed step size. You will need to look up the mass of the Sun and Newton's gravitational constant G. As an initial condition, take a comet at coordinates x = 4 billion kilometers and y = 0 (which is somewhere out around the orbit of Neptune) with initial velocity x = 0 and y = 500ms. Make a graph showing the trajectory of the comet (i.e., a plot of y against x). Choose a fixed step size h that allows you to accurately calculate at least two full orbits of the comet. Since orbits are periodic, a good indicator of an accurate calculation is that successive orbits of the comet lie on top of one another on your plot. If they do not then you need a smaller value of h. Give a short description of your findings. What value of h did you use? What did you observe in your simulation? How long did the calculation take?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
