Zarro
Zarro
  • 37
  • 57 702
Orbit Clearing in Action: Barnes-Hut Gravity Simulation using CUDA (4k reupload)
In an attempt to get some better compression out of CZcams I uploaded this video with a 4k resolution. While the original video is still 1080p, it should get better results here. When you watch it in 4k you can see all the particles that are normally filtered away by the compression. It took some time to get it to show as 4k for some reason, and i kinda forgot about it, but here it is anyway.
In this simulation, I explore the behavior of an orbiting mass in the presence of a circumstellar disc. While I intended to observe the mass clearing its orbit, and maybe the formation of trojans - small celestial bodies that orbit around a larger body's Lagrangian points - I made the disk too heavy compared to the orbiting mass, resulting in the mass spiraling towards the center. Although no trojans formed, the disk took on an elongated shape. The color of the disk indicates the speed of the particles.
The simulation is coded using C++ and CUDA, which are powerful programming languages used for high-performance computing. I calculated the gravitational forces using the Barnes-Hut algorithm, which approximates the influence of groups of masses that are far away with the help of a spatial quadtree.
In the simulation, the mass is distributed as follows: the center mass comprises 93.2% of the total mass, the orbiting mass 4.2%, and the disk 2.6% (262142 particles). I kept the mass distribution constant throughout the simulation.
#programming #simulation #gravity
zhlédnutí: 4 130

Video

Orbit Clearing in Action: Barnes-Hut Gravity Simulation using CUDA
zhlédnutí 742Před rokem
Note: there is a reupload of this video available to combat a lot of the bad compression going on here: czcams.com/video/cEZZ_dfWBu8/video.html In this simulation, I explore the behavior of an orbiting mass in the presence of a circumstellar disc. While I intended to observe the mass clearing its orbit, and maybe the formation of trojans - small celestial bodies that orbit around a larger body'...
Quadtree Visualization for my Gravity Simulation
zhlédnutí 25KPřed rokem
Let me start with saying that CZcams compression didn't really like this one, sorry for that. This video shows the dynamic quadtree implementation I made for use in the Barnes-Hut Algorithm. In this simulation 2^18 or 262144 particles were simulated. Calculated using the Barnes-Hut algorithm, which was programmed using c and Cuda. Color in the simulation is based on speed. #simulation #programm...
1 Million particles N-Body Simulation
zhlédnutí 14KPřed rokem
I finally got my Barnes-Hut program to a stage i can do big simulations in a reasonable time, so here it is. before this my biggest simulations were of around a quarter of a million particles, and with the brute force method i couldn't really go above that. This simulation does a million particles faster than my old program could do a quarter. 2^20 = 1048576 particles. Calculated using the Barn...
Playing with wip verlet integrator
zhlédnutí 2,5KPřed rokem
just trying some things. 16384 particles with collision running in realtime using a verlet integrator. The line in the middle is pointing toward the direction of gravity, which is changing to keep everything moving and interesting.
Space mission with self landing Rocket in the Plasma Demo
zhlédnutí 297Před rokem
The rocket is fully stabilized via the thrusters at the bottom via a load of PIDs. After a lot of tuning I finally got it reasonably stable.
Playing fetch with a rocket in Plasma
zhlédnutí 165Před rokem
Still isn't completely stable, but gps guidance is working now
Cool oscillation while balancing a rocket
zhlédnutí 61Před rokem
Cool oscillation while balancing a rocket
Fully functioning hoverboard in Plasma
zhlédnutí 285Před rokem
it uses 5 PID's to stabilize both the pitch, yaw, roll and the speed. Speed is controlled by leaning the board. Pitch, yaw, roll are controlled by varying the thruster power. The distance to the ground is calculated using roll and pitch so the plumb distance stays the same. Everything but the yaw is controlled via thrusters. Name: FUNCTIONING HOVERBOARD ID: 2877768376
Simplest 2 legged Walker in Plasma
zhlédnutí 146Před rokem
Only 3 parts! Made in Plasma during the open demo
Submarine map WIP in Plasma
zhlédnutí 135Před rokem
Submarine map WIP in Plasma
useless machine in Plasma
zhlédnutí 233Před rokem
took like 5 minutes, enjoy.
3rd person car in Plasma
zhlédnutí 94Před rokem
a quick and simple 3rd person camera. the drone targets a point behind the car and always looks at the car.
Whatever this is lol
zhlédnutí 109Před rokem
Whatever this is lol
Robot dog looking for its snack in Plasma
zhlédnutí 193Před rokem
Robot dog looking for its snack in Plasma
Auto aiming mortar in the Plasma Demo
zhlédnutí 1,4KPřed rokem
Auto aiming mortar in the Plasma Demo
Slime Mold Simulation using CUDA
zhlédnutí 1,5KPřed 2 lety
Slime Mold Simulation using CUDA
SlimeMold 1
zhlédnutí 209Před 3 lety
SlimeMold 1
SlimeMold 2
zhlédnutí 84Před 3 lety
SlimeMold 2
SlimeMold 3
zhlédnutí 123Před 3 lety
SlimeMold 3
Brute force N-body simulation 15 (n=65.536)
zhlédnutí 222Před 3 lety
Brute force N-body simulation 15 (n=65.536)
Brute force N-body simulation 14 (n=65.536)
zhlédnutí 199Před 3 lety
Brute force N-body simulation 14 (n=65.536)
Brute force N-body simulation 13 (n=32,765 )
zhlédnutí 183Před 4 lety
Brute force N-body simulation 13 (n=32,765 )
Brute force N-body simulation 12 (n=65,536)
zhlédnutí 275Před 4 lety
Brute force N-body simulation 12 (n=65,536)
Brute force N-body simulation 11 (n=262,144)
zhlédnutí 408Před 4 lety
Brute force N-body simulation 11 (n=262,144)
Brute force N-body simulation 10 (n=65,536)
zhlédnutí 120Před 4 lety
Brute force N-body simulation 10 (n=65,536)
Brute force N-body simulation 9 (n=65,536)
zhlédnutí 124Před 4 lety
Brute force N-body simulation 9 (n=65,536)
Brute force N-body simulation 8 (n=16,384)
zhlédnutí 177Před 4 lety
Brute force N-body simulation 8 (n=16,384)
Brute force N-body simulation 7 (n=65,536)
zhlédnutí 252Před 4 lety
Brute force N-body simulation 7 (n=65,536)
Brute force N-body simulation 6 (N=262,144)
zhlédnutí 663Před 4 lety
Brute force N-body simulation 6 (N=262,144)

Komentáře

  • @antonglushchenko4263

    Wow. That's great! Which timestepping scheme did you use (hierarchical or all timesteps for all particles are equal?) I wonder also if there any accretion onto central/orbiting masses?

  • @mahdiyarrazavi-ij4hh
    @mahdiyarrazavi-ij4hh Před 20 dny

    Planet formation❌️ Galaxy formation✅️

  • @fardplayer69
    @fardplayer69 Před 29 dny

    I wonder how you made this

  • @physixtential
    @physixtential Před měsícem

    Did you stop working on this? I'm writing something similar with fast multipole method.

    • @zarro110
      @zarro110 Před měsícem

      I'm currently not working on it, but I might pick it up again later. I've looked at FMM before but haven't had the time to play with it yet. It looks interesting though

  • @matejsteinhauser3974
    @matejsteinhauser3974 Před měsícem

    Also happened with ringed Galaxy

  • @concerned_patient
    @concerned_patient Před 2 měsíci

    Cool stuff. Well done.

  • @Wild-Eye
    @Wild-Eye Před 2 měsíci

    Dang…it was just getting good 🤓

  • @DaMonster
    @DaMonster Před 2 měsíci

    What is this?

  • @chxwy1
    @chxwy1 Před 3 měsíci

    wanted to see it reset

  • @starpawsy
    @starpawsy Před 3 měsíci

    Is that a 2D simulation or a 2D projection of 3D?

  • @GIGAMEMES_
    @GIGAMEMES_ Před 3 měsíci

    What graphics library did you use?

    • @zarro110
      @zarro110 Před 3 měsíci

      I draw everything using Allegro5

  • @franckmalers2299
    @franckmalers2299 Před 3 měsíci

    Where is the code ! and also, with what do you generate the images? can it take hdf5 files as inputs?

    • @zarro110
      @zarro110 Před 2 měsíci

      I render the frames during the simulation using Allegro 5. So no files (apart from the images ofc) are used. Afterwards I just convert the images into a video.

    • @franckmalers2299
      @franckmalers2299 Před 2 měsíci

      @@zarro110 but where is the source code?

  • @bowfuz
    @bowfuz Před 4 měsíci

    How does the quadtree actually speed things up, i'm curious what the algorithm does

    • @zarro110
      @zarro110 Před 4 měsíci

      The quadtree allows to make approximations for longer distances, reducing the amount of calculations that have to be made per particle. There are many resources on the Barnes-Hut algorithm that you can look up if you're interested.

  • @kovacsattila8993
    @kovacsattila8993 Před 4 měsíci

    So you mean us mortal beings can't run simulations close to this performance?

    • @zarro110
      @zarro110 Před 4 měsíci

      You can if you have a decent GPU, meaning most gaming setups probably will be able to do this. This was rendered on my (albeit pretty powerful) laptop

  • @thesquee1838
    @thesquee1838 Před 5 měsíci

    Very cool, I haven't seen ones that resize like that and its pretty cool

  • @thesquee1838
    @thesquee1838 Před 5 měsíci

    What exactly are you doing on the GPU? Any stuff with building / modifying the tree itself?

    • @zarro110
      @zarro110 Před 5 měsíci

      No, I haven't found (and to be fair, I haven't looked for it in a while too) any good resources on building trees efficiently on the GPU. The tree here is build on the CPU and then shipped over to the GPU for the force calculations. Barned-Hut is still O(n log n) so with a million particles the bulk of the calculations is still done on the GPU that way.

  • @burgershark1524
    @burgershark1524 Před 5 měsíci

    Idk what all this means but i like the colours

  • @jamesodonnell4771
    @jamesodonnell4771 Před 6 měsíci

    Damn I didn't know you were chill like that

  • @ApertureMusicCollections
    @ApertureMusicCollections Před 8 měsíci

    mm mm mmm that sweet sweet youtube compression. I bet this is really cool otherwise though!

  • @sayochikun3288
    @sayochikun3288 Před 10 měsíci

    This is better than sex

  • @alvarobyrne
    @alvarobyrne Před 10 měsíci

    Very nice work, by the way....Question from someone that hasn't understood a bit from school till now: does this run real time? or else how long it takes to render? please tell us: thanks in advance

    • @SVAFnemesis
      @SVAFnemesis Před 7 měsíci

      spliting the calculation using quad tree and running it on CUDA, my guess is that this can in theory run in real time.

    • @zarro110
      @zarro110 Před 5 měsíci

      This sim ran at around 10 fps I think

    • @SVAFnemesis
      @SVAFnemesis Před 5 měsíci

      @@zarro110 10 fps is not bad at all considering the particle numbers. I recently learned that FMM algorithm can drop the calculation down to O(N) instead of O(N log N). Might take a long while before I get how it works.

    • @alvarobyrne
      @alvarobyrne Před 5 měsíci

      @@zarro110 I see, I see, ok, thanks for answering, sorry to bog you, but on what sort of machine? But from your answer I get that it is not (easily run at) real time, thanks again

    • @zarro110
      @zarro110 Před 5 měsíci

      ​@@alvarobyrne I did this with my laptop with a GeForce RTX 2070 Max-Q and a i7-10750H

  • @jamie7472
    @jamie7472 Před rokem

    Where you get the music? Artist?

    • @jamesodonnell4771
      @jamesodonnell4771 Před 6 měsíci

      Jamtastic - Jimmy Jam Junction 2069 pre-release re-mastered. Niki Minaj cover ft. Snoop Doggy Double

  • @kubic-c3186
    @kubic-c3186 Před rokem

    Im a fellow programmer, and im wondering if I could take a look at the code behind your quadtree? Im currently building a 2D physics engine, which needs a extremely fast remove and insert for quadtrees.

  • @MrYefh
    @MrYefh Před rokem

    I would love to play around with this, please share the code!

  • @oliviergiroud1693
    @oliviergiroud1693 Před rokem

    Have you tried to incorporate some dark matter hypothesis ? Or MOND gravity ? It would be interesting to see what fits the best with observations and what contributes to the quickest galaxy formatiib, to reflect latest James Webb observations

  • @bmdsch1320
    @bmdsch1320 Před rokem

    Do the 3 body problem

  • @Baloongis2
    @Baloongis2 Před rokem

    How do i get this for myself?

  • @Ivan.Wright
    @Ivan.Wright Před rokem

    Cool stuff man. Good luck on your projects

  • @zdlax
    @zdlax Před rokem

    I wonder if gravity sims would be much faster if the underlying models were general relativity and not Newtonian. Classical integrators scale as N^2 right? Wouldn't a GR based sim only need to calculate the contribution of each particle to the spacetime geometry, which I think is O(N) and then step each particle forward along the updated geometry, again even more certain is O(N)? Just a fleeting thought. Could be totally off.

    • @mad_vegan
      @mad_vegan Před rokem

      It sounds like you're assuming that gravity is static in GR. As each particle moves, its gravitational effect changes too. In both cases each particle interacts with every other particle and this interaction changes at each time step. The difference is that in GR you have to take a lot of other effects into account, like how gravity also affects time, not just space. And not only mass causes gravity, but also pressure, momentum, and radiation, for example. And you even have to take gravitational waves into account.

  • @palkialovefest5293
    @palkialovefest5293 Před rokem

    I think it's very cool how it simulated how the forming planet and the particles around exchanged momentum making the planet spiral inwards, like it may happen with gas giants

  • @mrgoodpeople
    @mrgoodpeople Před rokem

    For why use Barnes-Hut algorithm, if you use CUDA? In cheap videocard CUDA can calculate 20-30K particle with brute-force (N^2) in realtime.

  • @__hannibaal__
    @__hannibaal__ Před rokem

    Is this Hamiltonian or General relativity -Gravitational field- ; did you know I have to use Mathematica and MatLab to solve these complex partial differential geodesic equations ; But now i have one year of studying C++/C; first time is just joke;(i thinks C++ is just Fortran or Python) after realize how is beautiful this language. In one year I realize 80% of hard principles and problems of C++; only i need to deeev in Concurrency and Graphics API ;

  • @robbie_
    @robbie_ Před rokem

    I imagine a gravity simulation would be a pathological case for any grid hashing function, so you really have to use a hierarchical subdivision of some kind.

    • @johnsherfey3675
      @johnsherfey3675 Před 6 měsíci

      I love octrees / n-dimensional octrees. They make space all cut up and nice to work with.

    • @tyn_joueurswitch1505
      @tyn_joueurswitch1505 Před 2 měsíci

      I will act like I understand this comment( I don’t).

    • @robbie_
      @robbie_ Před 2 měsíci

      @@tyn_joueurswitch1505 Such a function would be optimal if all entities were equally spread out across all of space. With a gravity sim they may start that way but they will eventually all clump together into a single or small number of grid cells.

  • @antonglushchenko4263

    Individual time stepping or constant for all particles?

    • @zarro110
      @zarro110 Před rokem

      It's constant for all particles. Especially these older sims are not too sophisticated, most speed comes from the fact that it is able to run on the gpu

  • @mrgoodpeople
    @mrgoodpeople Před rokem

    I make simulation with only 20K particles, but with friction for gaseous component. It's show how spiral galaxy may turn to barred galaxy: czcams.com/video/aYUiUKkQcEc/video.html And in this video I show how the gas convert to the stars and vice versa: czcams.com/video/nZI3SOoqPtI/video.html

    • @zarro110
      @zarro110 Před rokem

      How accurate is friction for galaxy sized simulations though? I thought that on that scale point masses are good enough as the distance between stars is big enough anyways

    • @mrgoodpeople
      @mrgoodpeople Před rokem

      @@zarro110 Real galaxies consist of 200-300 billions of stars. Even if we make simulation with 1million particles, these particles aren't separate stars, they are globular clusters which contain 200-300 thousands of stars. For example, if distance between two such particles less than radius of cluster, then force of attraction must decrease. Between particles space is'n empty. In this sense it is like simulation of gas or fluid.

    • @mrgoodpeople
      @mrgoodpeople Před rokem

      @@zarro110 "How accurate is friction for galaxy sized simulations though" - it's difficult question. I use sticky-particle method.

  • @mrgoodpeople
    @mrgoodpeople Před rokem

    Need add dispertion for particle's velocity to prevent formation of globuls.

  • @jonathanbaincosmologyvideo3868

    cool it forms an elliptical galaxy but how does a spiral galaxy form? and can you explain the 'rotation curves of galaxies' problem? ;-j

    • @mrgoodpeople
      @mrgoodpeople Před rokem

      We need add gaseous component with friction. In this simulation there is only stellar particles without collisions. I make simple simulation with 20K bodies for spiral galaxy: czcams.com/video/nZI3SOoqPtI/video.html And for barred galaxy: czcams.com/video/74f5qApTWfE/video.html

  • @eigentensor
    @eigentensor Před rokem

    Do you perhaps have a nice reference on building quadtrees on GPU? Cheers, nice videos :)

    • @zarro110
      @zarro110 Před rokem

      I'm currently building the quadtree on the CPU, and then sending it to the gpu for the force calculations. I'm also still looking for a nice reference on building quadtrees on the gpu lol

  • @rafmy-0788
    @rafmy-0788 Před rokem

    Are you rebuilding the tree each frame or do you have some updating logic going on ?

    • @zarro110
      @zarro110 Před rokem

      I'm fully rebuilding the tree each frame

    • @rafmy-0788
      @rafmy-0788 Před rokem

      @@zarro110 May I ask why did you choose to do that ? Do you think there would be no performance benefit of some updating logic or ? Also is this real-time and how many frames if so ?

    • @zarro110
      @zarro110 Před rokem

      @@rafmy-0788 I think real-time was 10 fps or so. The quadtree is constantly changing size and all of the particles are in constant motion. I'm doubtful that there is much that can be reused for an performance gain. I haven't tested that however

  • @ReaXTutorials
    @ReaXTutorials Před rokem

    And I don't even get any credit from this...

  • @ArndtStelter
    @ArndtStelter Před rokem

    Two supermassive black holes, ... well done ...

  • @ArndtStelter
    @ArndtStelter Před rokem

    Very cool, this is a HL Object, a new star with forming planets - simulation.... Very very well done, i really like to use this clip in one of my videos, is it OK to you?

    • @zarro110
      @zarro110 Před rokem

      Glad you like the video! You're welcome to use the clip in your video as long as you give proper credit. I do have to warn you that the simulation is limited to 2D and does not account for effects such as those from relativity, so it may not be fully realistic.

    • @ArndtStelter
      @ArndtStelter Před rokem

      @@zarro110 I thank you very much for the permission. A reference to the source is self-evident and of course always given with a link. Thank you for the warning, but I am very familiar with the matter, deal with me in this gebiet estimated 40 years. Currently I am working as a volunteer scientist for NASA and ESO on various projects. This simulation is already very close to a HL, a young star with protoplanetary disk.

  • @olivierhepler3627
    @olivierhepler3627 Před rokem

    what is the force acting on the particles ?

    • @olivierhepler3627
      @olivierhepler3627 Před rokem

      also is there a particular textbook or lectures u watched when u started making these sims? cool vids!

    • @zarro110
      @zarro110 Před rokem

      It's a gravity simulation. I learned most of this stuff just by googling and watching random videos on the internet. Simple gravity simulations aren't that hard to do and there is a lot of tutorials out there for them. C++ and Cuda are a bit harder but still doable on your own

  • @Strykenine
    @Strykenine Před rokem

    Hypnotic.

  • @billymonday8388
    @billymonday8388 Před rokem

    is the source available? looks nice

    • @zarro110
      @zarro110 Před rokem

      No the source code is a real mess haha. I struggle to read it myself sometimes

  • @lazygamer4965
    @lazygamer4965 Před rokem

    How long did it take to load this or this real time

    • @zarro110
      @zarro110 Před rokem

      I don't exactly know how long it took to calculate this, I made it quite a while ago. I do know that it wasn't real time, as the brute force method can be quite slow for large numbers of objects. My new simulations would be able to do this real time, using the Barnes-Hut method.

    • @the_untextured
      @the_untextured Před rokem

      This is a gravity simulation to a point or towards each other? Also I was woking on something simular today and I used C++ with CUDA to do this with about 2 million particles at a decent frame rate (real time). A trick is also to use samples for gravity rather than calculating the total force for ALL psrticles individually. You just take samples from about 0.1% of all particles and multiply the force by 1000. Some particles may act strangely at times, but overall it works quite well.

    • @zarro110
      @zarro110 Před rokem

      ​@@the_untextured It is an Nbody simulation, meaning they all influence eachother. While not your method, my new simulations use the Barnes-Hut method which makes use of a quadtree to make approximations that have smaller error than simply random sampling.

    • @the_untextured
      @the_untextured Před rokem

      @@zarro110 don't really know about that method but I will definitely look it up. I am not an ezpert in the field and this is the first time I properly take a look at many particles. The thing with my method is that it is not random sampling: it is systematic, so the particle set is subdivided into groups of n particles, on the first tick, the first group are used for thw calculations, on the next tick the second group is etc, which will end up removing random bias. However it still is not perfect, but for real time, it will be more accurate than not doing this because a low framerate will often cause huge inaccuracies. (in my case itr caused particles flying away because they would end up too close to each other and since g is proportional to 1/r^2, a small distance means a huge force, which caused them to fly off. (the repulsive force between them did not have the time to repel the particles)

  • @jonathanbaincosmologyvideo3868

    very cool, have you tried simulating 3D orbits around binary pairs?