{"id":3960,"date":"2019-12-13T14:08:08","date_gmt":"2019-12-13T22:08:08","guid":{"rendered":"http:\/\/universesandbox.com\/blog\/?p=3960"},"modified":"2022-11-14T13:09:06","modified_gmt":"2022-11-14T21:09:06","slug":"sph-devlog-1","status":"publish","type":"post","link":"https:\/\/universesandbox.com\/blog\/2019\/12\/sph-devlog-1\/","title":{"rendered":"SPH Fluid Simulation | DevLog"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/b37Gkn7.gif\" width=\"650\" \/><br \/>\nVideo: Simulating a planetary collision using a new method called smoothed-particle hydrodynamics (SPH).<\/p>\n<p>Hopefully by now you\u2019ve had time to check out Surface Grids &amp; Lasers | Update 24 of Universe Sandbox. If you haven\u2019t, time to get out from that rock you\u2019ve been living under and start terraforming all those other rocks floating through space.<\/p>\n<p>We plan to continue to add to the Surface Grids feature with even more detailed surface simulation through next year and beyond. Surface Grids is a massive new feature that changes a lot with the core simulation of objects in Universe Sandbox, and so far we\u2019ve just scratched the surface of what it can do. We\u2019re excited to explore its possibilities even more.<\/p>\n<p>But right now, let\u2019s turn our attention to something our physics developer, Alexander, has been working on. Introducing\u2026 smoothed-particle hydrodynamic fluid simulation. Let\u2019s just call it SPH for now.<\/p>\n<p>SPH is NOT included in Universe Sandbox yet. This is a behind-the-scenes look at a feature that we are still working on.<\/p>\n<h2>What is SPH and how does it work?<\/h2>\n<p>For a deep dive into the mechanics of SPH, <a href=\"https:\/\/46dd8e9b-a-b93174e9-s-sites.googlegroups.com\/a\/greenleaf.dk\/site\/projects\/sph_astronomy\/SPH.pdf?attachauth=ANoY7cpk915CP6H2yawowxcqmhwP06kqxJeN6eW6CExOuqv6EONAkspJwOvHcA52WlcxmyFfvLRQc70BEZIUrMCjeTYVH_Jduyr9eIHT8sE6ZZ4w9X2cvmWN-C8lDm8UnUDO0g4BoB9HtB3FDuGUqDjv3m6C59booGvgjuLPnYa6MRukcyRX1Ve3eoFW583hlFH2N-9T1IKLGWTbBOR9sns60-2F4yp6SUA5YYlpzOWHoSOkSnypW2U%3D&amp;attredirects=1\">check out this paper<\/a> from our very own physics developer, written back in 2010 (interestingly, not written in relation to Universe Sandbox, but for another project that was similar in many ways &#8212; there\u2019s a reason why we hired him many years ago to help build this new version of Universe Sandbox, and it had more to do with relevant experience than it did with his propensity for typos\u2026 *wink*).<\/p>\n<p>Or if you\u2019re curious about SPH, but perhaps not curious enough to read 35 pages on it, here\u2019s a crash course:<\/p>\n<p>SPH is a computational method commonly used for modeling fluids (though it can also handle solids). That might make you think that we\u2019d use this for simulating something like water flow on a planet\u2019s surface, but \u201cfluid\u201d here actually has more to do with simulating much larger objects.<\/p>\n<p>On an astronomical scale, many of the objects you can simulate, like stars and galaxies, behave like fluids. This is also true for planets, whether it\u2019s a gas giant or a rocky planet with, or even without, a molten core. And even in the case of large chunks of solid rock colliding with each other, there is such intense temperature and pressure that the materials behave more like fluid rather than rigid solids: they\u2019ll stretch and distort and be torn apart, rather than splinter, crack, and shatter.<\/p>\n<p>So in short, SPH will help create more detailed, realistic simulations of collisions, fragmentation, and formation of different types of objects in Universe Sandbox.<\/p>\n<p>How? First, the material, such as a planet, is broken into a number of \u201cparticles\u201d that each have properties such as mass, temperature, velocity, and position. You can see these particles clearly in any of the videos in this post.<\/p>\n<p>But the \u201csmoothed\u201d part of \u201csmoothed-particle hydrodynamics\u201d means that these particles are just sample points of what is actually a continuous material, where they each contribute to the properties at a given point based on a weighted, smoothed, average. Together, they describe the properties that exist at any given point in a flow of material, but they themselves are not the material. Think of it like buoys in an ocean: the buoys will each monitor the properties at their location, and they are distinct from the continuous fluid, ie the ocean, that they are monitoring. So for the future of SPH in Universe Sandbox, the current debugging visuals, where you can see individual particles, will ideally be replaced by something that better represents the continuous fluid that is actually being modeled.<\/p>\n<p>By tracking how each of these particles move, and more importantly how they move <em>in relation to their neighbors<\/em>,\u00a0you can calculate pressure and viscosity (friction) at any point in<br \/>\nthe fluid. And then you can estimate how this will move over time under different forces. Combine this with gravity and you start to see a simulation with emergent behavior that matches what we observe in real life.<\/p>\n<h2>Why SPH?<\/h2>\n<p>Because you get accurate simulation with emergent behavior, rather than disparate modeling of phenomena that needs to be stitched together. For example, with SPH, material will collect under the influence of gravity, but it will not all fall to the center of mass. Instead, as more material collects, the pressure increases and starts pushing out material, preventing a total collapse. The result is a spherical shape, and not because we specifically told it to become a sphere, but because that\u2019s what happens when you simulate physics on a more granular level.<\/p>\n<p>Or look at the case of Roche fragmentation, where a moon may be torn apart from the gravity of its host object \u201cpulling\u201d more on its near side than its far side. In our current simulation, pre-SPH, where we model how single points of mass move purely under the influence of gravity, we need special handling to calculate when and how this should happen, according to analytical models. But with SPH, this phenomenon just happens as the result of forces acting on the moon.<\/p>\n<p>Why SPH specifically and not another method? When simulating space, there is more literal space than there is simulated material. SPH is great for handling cases like this where material is sparse. Other methods instead require simulating each point of space, seeing how each of these points changes (versus tracking only points specifically in a material), which would be very slow for anything like entire star systems.<\/p>\n<p>Universe Sandbox is a unique physics simulator because we aim to make it an accessible, real-time, interactive experience. When compared to non-real-time simulations run on supercomputers, this presents a lot of limitations, and SPH is not immune to these. The biggest issue we will need to navigate as we continue development is the resolution of the model &#8212; to be really accurate and demonstrate smaller, local changes, you need a lot of sample points. But each point comes at the cost of a good chunk of computing power. So as with all features in Universe Sandbox, we\u2019ll need to find a balance, with enough points to model things in interesting ways, but not so many that it becomes a slideshow.<\/p>\n<h2>So&#8230; what does it do?<\/h2>\n<p>Technical explanations are fun (&#8230;did I get that right?), but what you really want to know is <em>what does this SPH thing mean for me and my planets?<\/em> That\u2019s also answered above: it will help create more detailed, realistic simulations of collisions, fragmentation, and formation of different types of objects in Universe Sandbox. But what you <em>really, really want<\/em> is a bunch of videos of this is in action. Understandable.<\/p>\n<p>Quick disclaimer: SPH is a feature in its early stages of development. Visuals are for debugging purposes. Anything shown many not be representative of how it\u2019ll appear and behave when included in an official Universe Sandbox update.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/ImT32U6.gif\" width=\"650\" \/><br \/>\nTwo equal-sized bodies showing pulsating behavior as pressure and gravity tries to find a balance.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/6qbCrko.gif\" width=\"650\" \/><br \/>\nTwo earths spinning the same direction and colliding. The result is a combined body with non-zero angular momentum from the individual momentums adding together in the same direction.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/dBs3ysh.gif\" width=\"650\" \/><br \/>\nIncreasing the density and speed of Mars before it impacts Earth and shoots right through it.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/heUAnMa.gif\" width=\"650\" \/><br \/>\nThe existing simulation \u201cEarth &amp; Moon x25 Offset\u201d showing all Earths collapsing and combining.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-3966\" src=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-SPH-Tidal-Fragmentation-650x366.png\" alt=\"\" width=\"650\" height=\"366\" srcset=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-SPH-Tidal-Fragmentation-650x366.png 650w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-SPH-Tidal-Fragmentation-300x169.png 300w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-SPH-Tidal-Fragmentation-768x432.png 768w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-SPH-Tidal-Fragmentation.png 1276w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><br \/>\nResults of the Moon fragmenting around Earth.<\/p>\n<p>So in short, SPH will improve or make possible simulations of the following:<\/p>\n<ul>\n<li>Total fragmentation<\/li>\n<li>Tidal deformation and Roche fragmentation<\/li>\n<li>Accretion disks \/ object formation from debris<\/li>\n<li>Giant-impact hypothesis (moon formation!)<\/li>\n<\/ul>\n<p>And in the longer term, we hope to apply it elsewhere, including more accurate galaxy collisions and star formation.<\/p>\n<h2>What\u2019s Next<\/h2>\n<p>As you can see, SPH is already working pretty well within Universe Sandbox. But you can also see that it\u2019s not exactly integrated with everything else yet. The visuals right now are intended solely for debugging purposes, and the transition from our standard planet visuals to the SPH particles is a little rough. Making visuals that look more like molten planets being torn apart will definitely take time, but we have some ideas in mind that we\u2019re excited to explore.<\/p>\n<p>The visuals are just one component of what we\u2019ll need to work on to integrate SPH with Universe Sandbox. Making it work with other complex aspects of the simulation, like the new Surface Grids feature, will be its own can of worms. But we\u2019re no strangers to technical challenges. And since we think SPH is worth experimenting with on its own, we hope to release an early version of it using the debug visuals and let you turn it on if you\u2019re interested in checking it out. We don\u2019t know when this will happen yet, but hopefully not too long into next year.<\/p>\n<p>And hopefully before then, we\u2019ll have a small update ready that will add some oft-requested color customization\u2026<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-3965\" src=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-Color-Customization-650x366.png\" alt=\"\" width=\"650\" height=\"366\" srcset=\"https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-Color-Customization-650x366.png 650w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-Color-Customization-300x169.png 300w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-Color-Customization-768x432.png 768w, https:\/\/universesandbox.com\/blog\/wp-content\/uploads\/2019\/12\/Universe-Sandbox-Color-Customization.png 1920w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/p>\n<p>Last Updated: November 14, 2022<\/p>\n<p><a class=\"twitter-follow-button\" href=\"https:\/\/twitter.com\/universesandbox?ref_src=twsrc%5Etfw\" data-show-count=\"false\" data-size=\"large\">Follow @universesandbox<\/a><script async=\"\" src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><br \/>\n<iframe loading=\"lazy\" style=\"border: none; overflow: hidden;\" src=\"https:\/\/www.facebook.com\/plugins\/page.php?href=https%3A%2F%2Fwww.facebook.com%2FUniverseSandbox%2F&amp;tabs&amp;width=340&amp;height=70&amp;small_header=true&amp;adapt_container_width=true&amp;hide_cover=false&amp;show_facepile=false&amp;appId\" width=\"340\" height=\"70\" frameborder=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Video: Simulating a planetary collision using a new method called smoothed-particle hydrodynamics (SPH). Hopefully by now you\u2019ve had time to check out Surface Grids &amp; Lasers | Update 24 of Universe Sandbox. If you haven\u2019t, time to get out from that rock you\u2019ve been living under and start terraforming all those other rocks floating through [&hellip;]<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4,3,21,8],"tags":[],"class_list":["post-3960","post","type-post","status-publish","format-standard","hentry","category-astronomy","category-development","category-devlog","category-science"],"_links":{"self":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts\/3960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/comments?post=3960"}],"version-history":[{"count":8,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts\/3960\/revisions"}],"predecessor-version":[{"id":5419,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/posts\/3960\/revisions\/5419"}],"wp:attachment":[{"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/media?parent=3960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/categories?post=3960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/universesandbox.com\/blog\/wp-json\/wp\/v2\/tags?post=3960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}