Programming the forces the sun applies on earth

AI Thread Summary
To create a 2D simulation of Earth's orbit around the Sun, understanding the gravitational force is essential, calculated using the formula GM1M2/R^2. The simulation involves breaking down momentum into vector components, which requires determining the angle theta, typically calculated using trigonometric functions based on the position vectors. Angular velocity is also relevant, as it influences the motion dynamics. The Euler method can be used for numerical integration of position and velocity updates, but for long-term stability, studying Kepler's laws of planetary motion is recommended. Properly accounting for forces and using accurate methods will enhance the simulation's reliability.
salimwtf
Messages
1
Reaction score
0
Hey guys,

I am trying to create a 2d simulation of the Earth going around the sun. However I am facing an issue. I am not sure what are the forces that apply on the Earth in a 2d aspect.

I know there is the gravitational pull GM1M2/R^2.

I know there is momentum, which is P = V * R, but I have questions regarding it. How do I break it down to a vector? Pi + Pj.. I realize I could probably do something like calculating P and then just doing Pcose(theta)i + Psin(theta)J but what is theta? how do I calculate it? or more like which angle is it?

Also does angular velocity have to do with anything here? if so how do I calculate it?.


Sorry for the many questions. Its sad to admit.. but I took all the calculus based physics classes like 1.5 years ago plus a quantum mechanics class.. And I forgot most of the stuff after I got a job..
 
Physics news on Phys.org
What you do is you choose an initial position and velocity, x and y components for both, and a small timestep \Delta t

Then you update the position

x = x + v_x \Delta t

same for y.

update the velocity:

v_x = v_x + a_x \Delta t
Where
a_x = \frac {F_x} {m}

now F_x = F cos { \phi }

F is what you wrote, and

cos {\phi} = \frac {x_s - x_e} {R}

updating v_y is identical except that F_y = F sin(phi) and

sin {\phi} = \frac {y_s - y_e} {R}

you can find R with pythagoras.

Of course you'll be making error, because the position and velocity will change during the timestep.
This is a rather primitive method (euler method) where the error is proportional to the timestep.
Look up runge-kutta method
 
In 2D, the position, the velocity and the force are vectors with 2 components. It is convenient to set up your coordinate system so that the Sun is at its origin. The position of the Earth is then simply ##x## and ##y##, its velocity is ##v_x## and ##v_y##, and the force is ##F_x## and ##F_y##. The magnitude of the force depends on ##r##, the distance from the Sun, which is given by Pythagoras ## r = \sqrt {x^2 + y^2} ##; thus the magnitude of the force is $$ F = G {mM \over x^2 + y^2 }. $$ The direction of the force is the direction opposite to the position vector, so the direction cosines are obtained from the position vector: $$ \cos \alpha = - {x \over \sqrt{x^2 + y^2}}, \cos \beta = - {y \over \sqrt{x^2 + y^2}} $$ so the components of the force are $$ F_x = F \cos \alpha = - {x \over \sqrt{x^2 + y^2}} G {mM \over x^2 + y^2 } = - G mM x \left(x^2 + y^2 \right)^{-{3 \over 2}} $$ and $$ F_y = F \cos \beta = - G mM y \left(x^2 + y^2 \right)^{-{3 \over 2}} $$ This can be re-formulated in polar coordinates, but that will probably confuse you rather than help at this stage. Stick with the Cartesian coordinates for now, take a stab at integrating your equations numerically with the simple method (Euler's), then things will starting making a lot more sense.
 
Hello Salim,

Depending on the purposes of your simulation you want to put an adequate amount of advance knowledge in it. Just integrating in x and y may be fine for a short period, but if you need something that is stable for a few centuries of simulated time, it would be better to first study and understand Kepler's[/PLAIN] laws. You can then decide to ignore or take into account the eccentricity of Earth's orbit.

If your simulation is a start towards something that includes the moon and perhaps also other planets, do some more research, or be prepared to throw away lots of rapid prototypes...

I came upon this thread via willem2
 
Last edited by a moderator:
Thread 'Question about pressure of a liquid'
I am looking at pressure in liquids and I am testing my idea. The vertical tube is 100m, the contraption is filled with water. The vertical tube is very thin(maybe 1mm^2 cross section). The area of the base is ~100m^2. Will he top half be launched in the air if suddenly it cracked?- assuming its light enough. I want to test my idea that if I had a thin long ruber tube that I lifted up, then the pressure at "red lines" will be high and that the $force = pressure * area$ would be massive...
I feel it should be solvable we just need to find a perfect pattern, and there will be a general pattern since the forces acting are based on a single function, so..... you can't actually say it is unsolvable right? Cause imaging 3 bodies actually existed somwhere in this universe then nature isn't gonna wait till we predict it! And yea I have checked in many places that tiny changes cause large changes so it becomes chaos........ but still I just can't accept that it is impossible to solve...
Back
Top