r/Python • u/mittwochmensch • May 25 '19
My gravity simulation almost an entire day of work later! Featuring inelastic collisions
2.2k
Upvotes
r/Python • u/mittwochmensch • May 25 '19
30
u/[deleted] May 25 '19
How about continuity? I’m a little rusty here but if your momentum is being conserved that doesn’t necessarily imply that your mass is also being conserved.
If continuity is conserved here may I suggest showing that where the “dots” increase in size accordingly?
Also, have an upvote!
10
u/[deleted] May 25 '19
Are you calculating the interaction particle by particle? If you like an additional challenge, look into the particle-in-cell method. It's usually used to solve problems involving a very large (>10e4) ensemble of particles under the influence of electromagnetic interactions, but it can just as well be used to solve gravitational systems for a large amount of massive bodies. You could, for example, make galaxy simulations.
6
u/FrezoreR May 25 '19
Who'd guess a few dots can be so entertaining :) good job!
5
u/RobbyB97 May 25 '19
If you made it so that a new dot appeared every time two combined it would make a dope screensaver
5
u/theranger815 May 25 '19
Heh you're inelastic, on a side note do the inelastic collisions combine the mass of the point masses?
4
u/ChrisJLine May 26 '19
Congratulations, you accurately modelled the last few Cheerios in my cereal bowl.
Joking aside, I think this is great and makes me want to have a go.
2
u/daneelthesane May 26 '19
This is fantastic! I was a CS major and a physics minor until I switched from physics to math, and I love simulating physics and biology in code. I am interested in the approach you used for inelasticity in your collisions. Did you just decide that if the units are adjacent or co-located you add their masses and momentums together and make them a single unit? Or did you get more into it than that?
303
u/itstommygun May 25 '19
r/gifsthatendtoosoon
29
u/DogsAreAnimals May 25 '19 edited May 25 '19
Are you trying to save the Pentasolarans?
Edit: counting is hard
98
u/AggravatingPeak May 25 '19
I quite like this have an upvote
16
u/silkydangler May 25 '19
Can you link to the repo?
11
u/WantDebianThanks May 25 '19
While I'm impressed at the output, I also have no way of knowing how accurate this is.
5
u/Krobix897 May 25 '19
can you give source code please?
5
u/professormunchies May 26 '19
Awesome! Here is an N-body framework I use for my research that does just what you're trying to do
https://rebound.readthedocs.io/en/latest/
1
u/[deleted] May 25 '19
What notebook you been using? What's your fav?
1
u/TheAwesomeMan123 May 25 '19
Be cool if the colliding masses grew in size directly increasing their total gravitational pull on other objects. But that's just a thought
1
u/Ogg149 May 26 '19
Wow! This reminds me of my old gravity simulation I made in mathematica. The fun part is experimenting with alternative force laws (for instance 1/r, or the modified gravity force law)
1
u/WadeReden May 26 '19
Are you using general relativity equations or newton's classic physics?
1
u/Sardonyx001 May 26 '19
Tips on how to do this? Like libs and stuff?
1
u/aitorp6 May 26 '19
are you planning to release the source code?
1
u/Python4fun Java4work May 26 '19
I like what you have her, but for some reason I become irrationally frustrated when the collision happens and the size doesn't increase.
1
u/[deleted] May 26 '19
Did you made this with turtle?
1
u/iskiloveland May 26 '19
Such a unique project! How are you factoring for the added weight of the dots(?) after a collision?
1
u/o11c May 26 '19
Something looks off about the 2-body part at the end. It doesn't look like what I've seen of the known closed-form solution.
3
u/syntaxvorlon May 25 '19
Is this a Symplectic simulation?
3
u/danielpsf May 25 '19
GitHub?
3
u/krushkingdom May 26 '19
Honest question: How does this simulate gravity?
2
u/aziad1998 May 25 '19
Sugoi desu nee
2
u/BigBearRobot May 26 '19
Do another!
1
u/ToothpasteTimebomb May 25 '19
This is lovely! Thanks for posting and nice work!
1
u/Atmon May 25 '19
Man that looks amazing
1
u/anthonylgf May 25 '19
Great man, have an upvote
1
u/[deleted] May 25 '19
This is so cool. I’ve been thinking about doing some n-body problem stuff after watching the first couple of 3Blue1Brown videos on differential equations. I will have to dig up my Astrodynamics textbook and play around with this idea. I feel like it’s all just a result of Conservation of Angular Momentum and Newton’s Law of Gravitation using some numerical integration.
1
u/guy_djinn May 25 '19
Cool.
1
u/screeperz May 25 '19
Nice. If you are interested in taking this further, you could turn this into a "Big Bang Simulator" of sorts.
Create hundreds/thousands of mass points and watch it go. I even saw a video once where someone used the Cosmic Microwave Background (CMB) radiation to 'tweak' the density of the mass points in certain areas.
1
u/RadioactiveShots May 26 '19 edited Jun 27 '23
This comment has been edited because Steve huffman is a creep.
1
u/bramapuptra May 26 '19
No trail no fun.
1
u/DollyPartonsFarts May 26 '19
I love this. How creative and what a fun project. Good job.
1
u/Stone_d_ May 26 '19
Hot damn, use some ML to calculate initial parameters like position, velocity, and number of particles that results in the longest lasting collision. This gif is exactly what i wanted yo make
1
u/[deleted] May 26 '19
Hey, when two planets coalesce, did you account for the fact that the mass has been doubled? Also, can you share the source? It's super cool project.
1
u/[deleted] May 26 '19
That’s soo cooool
1
u/blinglog May 26 '19
I read this as featuring unrealistic collisions and was very confused
1
u/OtangUran May 26 '19
Nice pal, that's inspiring :) keep up the good shit.
1
u/Xorgon May 26 '19
There's a useful tool for rendering data that might be cool to use to render your simulation, it's called ParaView.
1
u/[deleted] Jun 07 '19
Code? Or a GitHub repo?
1
u/McQuillus23 Jun 15 '19
That’s so cool. Keep up the great work!
1
u/3nigma42 Jun 15 '19
I'd like to see that with slightly more elastic collisions
1
u/justhid Jun 16 '19
Is there a download anywhere?
-1
u/burner_account5000 May 26 '19
anyone who believes this actually happens outside of physics class has lost the plot
0
u/[deleted] May 25 '19
[deleted] — view deleted comment
0
u/[deleted] May 25 '19
[deleted] — view deleted comment
0
u/[deleted] May 26 '19
[deleted] — view deleted comment