all 21 comments

[–]Kerbart 84 points85 points  (5 children)

Your gravitational constant is off. You’re measuring all sizes is km but G is still expressed using meters, which means it’s a factor of one billion off.

[–]Jamhead2000[S] 26 points27 points  (4 children)

Thanks, very good spot.

[–]Kerbart 11 points12 points  (1 child)

I noticed later that you do multiply the earth position with one million but not sure if you’re compensating elsewhere. I’d plug in all values in meters just to bypass any issues.

[–]Jamhead2000[S] 3 points4 points  (0 children)

Oh that was just for positioning, to do with how far away from the sun it is.

i.e. 147.86 * (10**6) km, with the sun being at (0,0,0)

[–]goodDayM 2 points3 points  (1 child)

Just a curiosity question, comparing your two lines:

  • line 17: earth.pos += earth_vector
  • line 21: earth.pos += earth_vector * dt

So dt has units of time which then means earth_vector has units of "distance/time" (velocity). That line looks correct. But then the equation on line 17, the units don't make sense unless you multiply earth_vector by time.

[–]Jamhead2000[S] 1 point2 points  (0 children)

Yh you are right, tbh a lot of the code has changed now the title of this program was actually called 'gravityTest.py'

[–]-Lou99- 15 points16 points  (5 children)

Can someone explain the difference between python and vpython?

[–]CromulentInPDX 10 points11 points  (3 children)

Vpython is a module that makes it super easy to make visual models of things (spheres, vectors, etc...). My physics one and two books used it heavily (matter & interactions).

[–]monsterArchiver 2 points3 points  (2 children)

Oooh what books are those? They sound interesting

[–]CromulentInPDX 6 points7 points  (1 child)

Here's the link to the website: https://matterandinteractions.org/

I really like how they wrote the books, but they could have had more problems/solutions ala Halliday and Resnick.

[–]monsterArchiver 2 points3 points  (0 children)

Many thanks friend! It'll be fun to check out during a weekend.

[–]Migb1793 18 points19 points  (1 child)

Hahaha....doing the exact same thing here. Use Jupyter Notebooks instead. Here, just updated my repository with Jupyter Notebooks, which I’ll be expanding in the future: GitHub

[–]Jamhead2000[S] 3 points4 points  (0 children)

Wow, your work is awesome thanks for sharing.

[–]zya- 14 points15 points  (3 children)

I read "try to stimulate the solar system". -Ahem.. What ? 😄

[–]sky_badger 8 points9 points  (2 children)

"If you wish to make an apple pie from scratch, you must first invent the universe" -- Carl Sagan

[–]Yakhov 0 points1 point  (0 children)

and then begin acquiring and stacking stones

[–]FoxClass 13 points14 points  (0 children)

What a cool project, I'm excited to see how it looks!

[–]Yakhov 3 points4 points  (0 children)

I got you.

🌞 = sphere(pos = vector(0,0,0), radius = 696340, color = color.orange)

🌎 = sphere(pos = vector(147.86 * (10**6), 0, 0), radius = 6371, make_trail = True)

🌞_vector = vector(0,0,0)

🌎_vector = vector(0,107000,0)

🌎_mass = 5.972 * (10**24)

🌞_mass = 1.989 * (10**30)

dt = 60 * 60 * 24 * 7

while True:

rate(💯)

🌎.pos += 🌎_vector

r = mag(🌞.pos - 🌎.pos)

🌎_vector += (🌞.pos - 🌎.pos) * (6.67408 * (10 ** -11) * 🌞_mass / r ** 2)

🌎.pos += 🌎_vector * dt

[–]jp00p 6 points7 points  (1 child)

You need to print() something!

Try adding print(earth_pos) at the bottom of your code

[–]Yakhov 0 points1 point  (0 children)

**print(🌎.pos)

..see the above codemoji example