Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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*image text in transcribedt^2

~vi+1 = ~vi +~ai*image text in transcribedt

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 +~viimage text in transcribedt +(1/2)~aiimage text in transcribedt^2 ,

xi+1 = xi + vx;iimage text in transcribedt + (1/2)ax;iimage text in transcribedt^2

yi+1 = yi + vy;iimage text in transcribedt + (1/2)ay;iimage text in transcribedt^2

~vi+1 = ~vi +~aiimage text in transcribedt ,

vx;i+1 = vx;i + ax;iimage text in transcribedt

vy;i+1 = vy;i + ay;iimage text in transcribedt

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago