[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 25 KB, 596x600, Picture 1.png [View same] [iqdb] [saucenao] [google]
3163409 No.3163409 [Reply] [Original]

Ok, i got my gravity simulator working and I'm taking suggestions for initial conditions, it can take as many bodies as you want and plots out their trajectories over distances.

if you want to make suggestions put them in this format
mass x0,y0 vx0,vy0
that's space seperated for the mass, position and velocity and comma seperated for the x and y. It actually can do higher dimensions, but it only displays in 2d, and I haven't actually tested the higher dimensionality that much.
here's a picture of an almost stable earth-moon system
10000.0 0.0,0.0 0.0,-0.07
100.0 200.0,0.0 0.0,7.071067
1.0 220.0,0.0 0.0,8.97805

>> No.3163416
File: 30 KB, 594x599, Picture 2.png [View same] [iqdb] [saucenao] [google]
3163416

and this was a proof of concept for making bodies in a system following function
captcha: theory tinglin
.001 30,0 0,5.7735026919
.001 60,0 0,4.08248290464
.001 90,0 0,3.33333333333
.001 120,0 0,2.88675134595
.001 150,0 0,2.58198889747
.001 180,0 0,2.35702260396
.001 210,0 0,2.18217890236
.001 240,0 0,2.04124145232
.001 270,0 0,1.9245008973
1000 0,0 0,0

>> No.3163442
File: 91 KB, 593x595, Picture 3.png [View same] [iqdb] [saucenao] [google]
3163442

This was my attempt at simulating 100 bodies to get something like a galaxy to form, clearly I don't have the right initial conditions, but it does run, so i'm kind of proud that it can handle this big of a system.

For space reasons I won't be posting that systems initial condition.

>> No.3163446

that's pretty trivial, OP

>> No.3163460

>>3163446
You're pretty trivial.

OP is more like pointless.

>> No.3163463
File: 17 KB, 598x597, Picture 4.png [View same] [iqdb] [saucenao] [google]
3163463

This is sol system with the orbits circularized a bit
332900 0,0 0,0
.055 38.7,0 0,92.747
.815 72.33,0 0,67.841
1 100,0 0,57.697
.0123 100.257,0 0,59.596
.284 152.3,0 0,46.752

>> No.3163475

>>3163442
Modify the program to search for initial conditions which prevents the loss of at least x-number of objects over t-amount of time. That might be more interesting.

>> No.3163479

10000 0 0 0 0
100 50 50 50 50
10 1000 1000 1000 1000

1 51 51 51 51

>> No.3163480
File: 66 KB, 602x601, Picture 6.png [View same] [iqdb] [saucenao] [google]
3163480

this is sol system with an object about 3 times heavier than jupiter on a very eliptical orbit. It ruins the neighborhood.

332900 0,0 0,0
.055 38.7,0 0,92.747
.815 72.33,0 0,67.841
1 100,0 0,57.697
.0123 100.257,0 0,59.596
.284 152.3,0 0,46.752
1000 200,200 -20,-5

>> No.3163487 [DELETED] 
File: 156 KB, 599x449, 1296183240803 copy.jpg [View same] [iqdb] [saucenao] [google]
3163487

>>3163446
Faggot.

At least the OP is actually doing something science-y. For fun no less.

Not OP. Just felt I had to point out that you are everything that is wrong with /sci/.

>> No.3163500
File: 12 KB, 602x602, Picture 5.png [View same] [iqdb] [saucenao] [google]
3163500

>>3163479
Sorry pascal, the frame limits are only 600X600, so that's why only 3 of your bodies showed up.

I could post the source code if anybody wants it. I wrote it in python, using py games to display the results.

>> No.3163510

>>3163500
I'd like to see the source code

>> No.3163515

>>3163487
I'm currently using euler method for simulating, which is about as bad as it can get, my next version is going to use runge-kutta, so it'll run faster, and presumably do larger systems more quickly/accurately.

>> No.3163519

How much work did you have to do for this? I've been thinking about doing something similar.

>> No.3163528
File: 32 KB, 598x600, Picture 7.png [View same] [iqdb] [saucenao] [google]
3163528

>>3163510
http://dpaste.com/549838/
The first subroutine, sysmaker is how i read the system of bodies from a file and set the initial conditions.
1000 140,0 0,4.75
1000 160,0 0,-3.25
1000 -140,0 0,-4.75
1000 -160,0 0,3.25

>> No.3163538

>>3163409
I made a gravity simulator in C++ a few years ago, where I had bodies orbiting in real time. For some reason, I was never able to achieve any kind of stable orbit. Did you run into this problem at all?

>> No.3163540

>>3163519
It's most of what i did yesterday, I did a crummier one in november. Most of the new work was doing it in pygame instead of turtle, and making the file reading system. It was kind of baffling when I did what i thought was the exact same math, but get much better results, however. Nice kind of baffling, but still weird.

>> No.3163553

I just have to agree with this poster:
>>3163487

This thread is at least science and much more interesting than religion or homework threads. Here OP has created something and is showing it to us.

Still as it is thread is semi pointless, it kinda depends on the poster but still.

>>3163475
This is interesting idea, i suggest to do this if you can.

Also my numbers for today are:
10000 20,0 0,-10
10060 -20,0 0,10
100 100,15 2,15
10 -250,10 5,4
25 0,30 10,100

>> No.3163555

>>3163515
If you're intending on using RK4 next bewared of the fact that this won't be enough either to simulate 100 bodies. You should rather try an adaptive Runge-Kutta method like Runge–Kutta–Fehlberg or Dormand–Prince; these usually conserve energy much better and are more stable. Failing that you could try some more exotic stuff, stuff I have no idea of unfortunately. Good luck

>> No.3163556

>>3163538
When i first started, all my orbits eventually turned into circles, even if they were supposed to be ellipses. That went away when i made the time step smaller though, I wonder why it is that the approximation always turns into a circle, it's probably because of the R^2 aspect, but I don't know more details than that.

Also, your starting conditions may have been off? did you try solving m/r^2=v^2/r to figure out your initial velocity? and put the vectors at right angles to each other?

>> No.3163594
File: 37 KB, 1181x595, Picture 10.png [View same] [iqdb] [saucenao] [google]
3163594

>>3163553
starts out with that one guy hauling ass outta of the system. neat spiral though, looks like the systems starting to process.

>> No.3163605

>>3163556
>>3163556
>Also, your starting conditions may have been off? did you try solving m/r^2=v^2/r to figure out your initial velocity? and put the vectors at right angles to each other?

Yes, but I had no luck. I had a rather simple method, no need for numerical approximations. I merely calculated the total force on each particle, then the acceleration, then the change in velocity, and with each step the positions changed according to the new velocity.

Acceleration seemed to work properly, but somewhere there was a small but significant error which prevented orbit formation of any kind.

I suppose it would be interesting to re-examine in detail what I did with 3 more years of math under my belt.

>> No.3163632
File: 30 KB, 596x599, Picture 1.png [View same] [iqdb] [saucenao] [google]
3163632

>>3163605
yeah, some bone head goofs i had were
adding position to position, not velocity to position
not breaking forces into x-y components
multiplying the timestep in one case, and dividing in the other
having the wrong sign on the force, making gravity repulsive instead of attractive
lots of missed colons

also, i think i've got a stable quartet!
1000 140,0 0,5.25
1000 160,0 0,-2.75
1000 -140,0 0,-5.25
1000 -160,0 0,2.75

>> No.3163640

>>3163594
10 internets for this. Thanks

Why the blue, (25 0,30 10,100???) goes into that direction? Gravity i guess. Is the down posivite y direction? That would explain the movement.

>> No.3163642

>>3163640
yeah, it's kind of the way pygames grid works, it rasters from to left to bottom right, so [0,0] is the top left, which makes x-axis movement what you'd expect, but flips y-axis movement. But most physical laws have symmetry in a way that it doesn't matter.

>> No.3163663

>>3163632
>>3163632
Well, it's good to see that it is possible to simulate at home, maybe before I find a job I'll spend some time retrying the problem.
Nice work.

>> No.3163717
File: 52 KB, 597x592, Picture 2.png [View same] [iqdb] [saucenao] [google]
3163717

Ok, this is fucked up, i reran my galaxy simulation, having the initial mass vary as 1/r^1.5, and initial velocity vary as 1/r. and, well, the results speak for themselves.

>> No.3163722

>>3163442
for reference, compare with the earlier output that had constant masses

>> No.3164234

bump i guess

http://phet.colorado.edu/sims/my-solar-system/my-solar-system_en.html