Question: Python please. Thanks!! Question 10: Use the Verlet method (see script, section 5.3.1, from page 79) to calculate the orbit of the Earth around the
Python please. Thanks!!
Question 10: Use the Verlet method (see script, section 5.3.1, from page 79) to calculate the orbit of the Earth around the Sun. The equations of motion for the position r=(x,y) of the planet in its orbital plane are: where r=x2+y2 dt2d2x(t)=GMr3x,dt2d2y(t)=GMr3y, Task: Calculate the orbit of the Earth around the Sun in steps of one hour for a total period of four years. Use the solution for the orbit, r(t), and the velocity, v(t), to calculate additionally the potential and kinetic energy of Earth at each evaluation point. Create a function potentialEnergy( r, par) and a function kineticEnergy ( v, par) which implement these requested calculations separately from solving the ODE's and can be called from tests. Also create a function solve (par) which returns the value arrays for r(t) and v(t) as a tuple such that the tests can call solve(par) and obtain the results. Note that the potential energy depends only on the Earth location, r(t), and its kinetic energy only on its velocity, v(t). The variable par should be a tuple containing the required constant values in order (G,M,m), see Data below. Data: Use G=6.67381011m3kg1s2 as Newton's gravitational constant, M=1.98911030kg as mass of the Sun. For Earth mass, use m=5.97221024kg. The initial conditions should be r0=(1.5211011,0)m and v0=(0,2.9291104)ms1. Time evaluation points are in the task description and note that you work in SI units. Create two plots: (a) draw the kinetic energy, potential energy and total energy, superimposed on a single canvas and observe how the kinetic and potential energies change as a function of time while the total energy appears to be constant. (b) Plot only the total energy as a function of time and observe the oscillating character while the mean remains constant to high precision which demonstrates the inherent energy conservation of the Verlet method. Note: you may wish to solve the problem using solve_ivp() but that is not recommended. It is entirely possible and possibly illuminating in comparison(!) to the Verlet method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
