Programming the forces the sun applies on earth

Click For Summary

Discussion Overview

The discussion revolves around creating a 2D simulation of the Earth's orbit around the Sun, focusing on the forces acting on the Earth, particularly gravitational forces, and the mathematical modeling required for the simulation. Participants explore various aspects of physics and programming related to this topic.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant expresses uncertainty about the forces acting on the Earth in a 2D simulation, mentioning gravitational pull and momentum but seeking clarification on vector breakdown and angular velocity.
  • Another participant suggests a method for updating position and velocity using initial conditions and timesteps, introducing the Euler method for numerical integration.
  • A third participant elaborates on the vector nature of position, velocity, and force in 2D, providing formulas for calculating force components based on the Earth's position relative to the Sun.
  • A later reply advises considering Kepler's laws of planetary motion for long-term simulations and suggests that understanding the eccentricity of Earth's orbit may be important.

Areas of Agreement / Disagreement

Participants present various approaches and methods for simulating the Earth's orbit, but there is no consensus on the best method or the necessity of incorporating advanced concepts like Kepler's laws for different simulation durations.

Contextual Notes

Some discussions involve assumptions about the accuracy of numerical methods and the limitations of simple integration techniques over extended periods. There is also a mention of potential errors in the Euler method due to changing position and velocity during timesteps.

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:

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 36 ·
2
Replies
36
Views
4K
  • · Replies 77 ·
3
Replies
77
Views
6K
  • · Replies 28 ·
Replies
28
Views
3K
  • · Replies 62 ·
3
Replies
62
Views
7K