PHYS20032: Intermediate Computational Physics Exercise 4
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
PHYS20032: Intermediate Computational Physics
Exercise 4
The deadline for this exercise is Monday 21st March 2022 at 12:30 p.m. Your report and program (*.py) files should be uploaded into Blackboard at the appropriate point in the PHYS_20032_30009_2021_TB-4: Introduction to Computational Physics (PHYS20032 + PHYS30009) 2021 Course.
Further information related to this exercise and the Runge-Kutta method will be given in the final computing lecture in Week 18. S. Hanna
The aims of this exercise are:
• To use some of the computational tools and knowledge gained thus far in the Computational Physics course to solve real physical problems;
• To use the Runge-Kutta method to explore the motion of rockets and orbits.
Problem: Calculation of rocket orbits – one moving body
In both the situations studied here, you will consider a single moving body (the rocket)
moving in a fixed gravitational potential provided by the earth and the moon. First
of all, you will simulate orbits of the rocket around the earth (or other planet of your choice). This is most easily achieved by treating the planet as being very massive and stationary at the origin, while the rocket moves in orbit around it. Solving the problem entails solving the equation of motion:
mMG mMG
(1)
where M is the planetary mass, m the mass of the rocket and G the gravitational constant. r is the position of the rocket relative to the centre of the planet, as indicated in the figure.
y
v
m
M
a) Using the 4th order Runge-Kutta approach discussed in Lecture 6, solve Eq. (1) for r and rl. The motion will be in the xy plane, so it is sufficient to restrict your program to 2 dimensions. It is recommended that you write func- tions f1(l, x, y, vx, vy) , f2(l, x, y, vx, vy), etc., for the derivatives given in Eq. (12.4) of Section 12.4 of the lecture notes, as this significantly simplifies the programming required (although, as also noted, you will not need the full list of arguments shown here). As an alternative it is permissible to use the scipy.integrate.solve_ivp() function that was demonstrated in the lecture. If you take this approach, you will need to write a single function that returns the values of f1(l, x, y, vx, vy) , f2(l, x, y, vx, vy), etc., arranged as a vector, and call the function using the optional parameter method=’RK45’.
You may find it helps to include a simple menu in your code so you can choose between running this part of the exercise, and the part that follows. The following code achieves this in a simple way – you may adapt it to your needs.
Your code should generate plots of your orbital trajectories which you can include in your report.
In your report you should simulate both circular orbits and eccentric, comet-like, orbits. Are the orbits stable and repeatable? Examine the total energy of the rocket. Is it accurately conserved? What time-step do you need to ensure this accuracy?
Now for a ‘real world’ problem that uses what you have learnt so far. Your goal is to launch a rocket from low Earth orbit (orbital radius, say, between 6500 and 7000 km) such that it passes over the Moon’s surface to take photographs, ‘slingshots’ around the moon, and then passes close to Earth once more to send back the information by radio. You have sufficient fuel for only one rocket ‘burn’ to leave Earth orbit, and the rest of the flight is simply coasting.
This is another example of numerical integration of a differential equation; the equation of motion results from the combined influence of the Earth and Moon’s gravitational fields. To simplify the problem, treat the Earth and Moon as fixed in position for the duration of your flight.1 Then the equation of motion becomes (see figure): mMEG mMMG |r - RE |3 |r - RM |3 You can make the problem look simpler, by placing the Earth at the origin, so RE = 0. Then, it is also easier to place the moon on one of the axes. |
v
r – RM r – RE
r ME RE
O |
MM |
b) Extend your Python script to simulate the motion of the rocket as it flies from the Earth to the moon and back, using the 4th order Runge-Kutta method, as before. Although the gravitational field is more complicated than previously, only the rocket is moving, so you can work with the same variables as in your first program.
Use your program to find the correct launch position (the point on the orbit where the rocket is fired) and velocity for the rocket to fulfil the requirements. You will need to use trial and error to establish these: produce plots of
your trajectories, and devise tests to tell you if you have crashed into either Earth or moon. In your report, you should include discussion of the following points:
• How did you established reasonable starting conditions?
• How close can you get to the moon without crashing?
• How long does the flight to the moon and back take?
• How will you know when to halt your calculation?
As always, check that your numerical solution has sufficient accuracy. Think about ways to check this, using boundary conditions that should give known behaviour, and thinking about conservation of energy. Remember that your solution should be independent of step size.
Report
As previously, you should prepare a concise report outlining your methods and highlighting your findings with suitable graphs or tables. Credit will be given for a reasoned discussion of your findings.
Submitting your work
You should submit the following to Blackboard:
1. A brief report, in MS Word or pdf format;
2. Final version of your program for the orbits problem.
As before, please note:
• Only upload your “prog.py" files.
1 Note: This is unrealistic. The Apollo moon shots of the late 1960’s and 1970’s used to take around 5 days for the round trip from Earth to moon (around 500,000 miles), during which time the moon moves an appreciable distance in its orbit.
• Blackboard anti-plagiarism software won’t accept a “.py" extension so please rename your file with a “.txt" extension.
• Please also give your programs sensible distinguishing names, including your name or userid e.g. “my_userid_ex4.txt".
If you have any problems submitting your work, please contact Dr. Hanna ([email protected]) or ask a demon- strator.
2022-03-20