Question
Write a C++ CODE that transcribes Newton's second law into the equations without any numerical optimization (namely the EULER METHOD). We will consider a planet
Write a C++ CODE that transcribes Newton's second law into the equations without any numerical optimization (namely the EULER METHOD).
We will consider a planet of mass m orbiting an unmovable star of mass M (let's say it's the Earth and the Sun). The plane of motion is determined by the position and velocity vectors of the planet:
~r = (x; y) and ~v = (vx; vy), which are given as the initial conditions.
The essential simplication is that the time is discretized into small increments ('time steps'). Suppose that all time steps are equal.
At the beginning of the i-th step the position of the planet is ~ri and its velocity is ~vi. At that time the force acting on the planet is ~Fi = -(GMm/ri^2 )*^ri, where ^ri is the unit vector in the radial direction. The acceleration is ~ai = ~Fi/m = -(GM/ri^2 )*^ri. We assume that the time step t is so small that during that time any changes in force and acceleration are negligible, so we can apply the equations of motion with constant acceleration. Then we can easily find that at the end of step i, which is the beginning of time step (i + 1), the velocity and position are:
~ri+1 = ~ri +~vit +(1/2)~ai*t^2
~vi+1 = ~vi +~ai*t
For the practical implementation we must work with x and y components of the above equations. Angle (theta i) is measured from the x-axis to the position vector in i-th step;
cos(theta i)= xi/ri,
sin(theta i) = yi/ri
ri =sqrt(xi^2 + yi^2)
~ai = -(GM/ri^2)*^ri
ax;i = -(GM/ri^2)cos(theta i) = -GM (xi/ri^3)
ay;i = -(GM/ri^2)sin(theta i) = -GM(yi/ri^3)
~ri+1 = ~ri +~vit +(1/2)~ait^2 ,
xi+1 = xi + vx;it + (1/2)ax;it^2
yi+1 = yi + vy;it + (1/2)ay;it^2
~vi+1 = ~vi +~ait ,
vx;i+1 = vx;i + ax;it
vy;i+1 = vy;i + ay;it
The best way to test the model is to initially set the Earth say along the x-axis at the initial distance of 1 AU, and the initial velocity along the y-axis set to be equal to the orbital speed of the Earth (which we found to be 29.8 km/s). For the initial conditions ('zeroth step') x0 = 1 AU, y0 = 0, vx;0 = 0 and vy;0 = 29.8 km/s we know that the orbit should be circular. Once you get the circular orbit, try increasing the initial speed to Vo = 35 km/s. In this case you should get an elliptic orbit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started