Jump to content
  • Advertisement
Embassy of Time

Gravity systems?

This topic is 376 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

As some may know, I am working on a game that involves a lot of scientific simulation to do what I consider to be -real- procedural generation. I am currently going through the different sciences in my blog, but having closed the book on my last version, I am now facing the move into far more detail on the 'science' part of things. And that is forcing me to study up on a lot of stuff!

I know how complex gravity systems work, and I have the theory for how to design a universe that unfolds from a fake Big Bang and then spreads out, gathers into stars and galaxies, and eventually has planets in it and so forth. However, I have very little experience in turning that into actual code. While I could just sit down and do a simulation of every bit of gravity pull and such, I can't help but wonder if someone has found easier (and less CPU intensive!) ways of doing it?? Right now, the plan is to have random "gravity centers" in a point cloud gather the contents of the universe around them as they all move outward and affect each other, but this will likely be by checking gravity pulling on every bit of content at the rate of one check per few miliseconds. It feels like there should be an easier way, maybe a set of (all things considered) simple equations that can pinpoint where everything is at a given point in time, or something like it. I honestly don't know, I have never gone into this much detail with my star / uuniverse simulations before.

So, does anyone know some good material on simulating star clusters pulling on each other as they go through space? Anything is appreciated, no idea should be tossed aside!

 

Edit: By popular request, an elaboration: I am not trying to accurately simulate our universe. I am making a game that I want to procedurally generate a universe according to realistic, by HIGHLY simplified scientific methods.

Edited by Embassy of Time

Share this post


Link to post
Share on other sites
Advertisement

just look up how its done in the real world and do the best you can with the hardware you have.

 

odds are it will pretty processor intensive - IE particle fluid simulation type stuff.

Share this post


Link to post
Share on other sites
It feels like there should be an easier way, maybe a set of (all things considered) simple equations that can pinpoint where everything is at a given point in time, or something like it.

Being able to predict a trajectory in the future implies you know all relevant forces between now and that point in the future.

Then (at least in theory) you could compute the trajectory, and thus the position at time now+something.

I have no experience in what you're trying to do, but I think the above basically ends with anything beyond a fixed number of fixed forces (not varying in position or strength). Since it seems you're way beyond that, incremental step-wise computing seems the best approach to me.

In reducing computation effort, you may want to prune non-relevant forces from the calculation (assuming you'll have heaps of small distant rocks that basically do nothing relevant).

One trick you may want to do to increase precision, is to start with summing the smaller forces first. That way they get a chance to accumulate to a relevant number before being chopped off by bigger forces. There are likely lots of other numeric tricks that apply, but that's an area I'd like to explore too, one day :)

Edited by Alberth

Share this post


Link to post
Share on other sites
This is a huge area of study. You can easily make a PhD thesis about this, and many people have.

So you have N particles that interact through gravity. You would normally model them as spheres of uniform density and fixed radius, so when two of them get really close things don't blow up.

You then need to do two things per time step:
(1) Compute the net force on each particle.
(2) Integrate the equations of motion.

(1) is the expensive part. Naively, it takes time proportional to N^2. It turns out there is some very clever trick called the "multipole method" that is explained terribly in the papers I have found, but it can approximate (to very high precision) the forces really well using time O(N). I have only ever needed a 1-D version of this and it was quite challenging. I don't know how much harder it would be in 3D.

Share this post


Link to post
Share on other sites
You then need to do two things per time step:

yep, that's the basic algo for particle based fluid simulation. applications include aerodynamics, hydrodynamics, gravity simulations, weather simulations, perhaps even nuclear explosion simulations - have to look that last one up. 

As i said, rather processor intensive.  Supercomputers and parallel processing.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

 

It feels like there should be an easier way, maybe a set of (all things considered) simple equations that can pinpoint where everything is at a given point in time, or something like it.

Being able to predict a trajectory in the future implies you know all relevant forces between now and that point in the future.

Then (at least in theory) you could compute the trajectory, and thus the position at time now+something.

I have no experience in what you're trying to do, but I think the above basically ends with anything beyond a fixed number of fixed forces (not varying in position or strength). Since it seems you're way beyond that, incremental step-wise computing seems the best approach to me.

In reducing computation effort, you may want to prune non-relevant forces from the calculation (assuming you'll have heaps of small distant rocks that basically do nothing relevant).

One trick you may want to do to increase precision, is to start with summing the smaller forces first. That way they get a chance to accumulate to a relevant number before being chopped off by bigger forces. There are likely lots of other numeric tricks that apply, but that's an area I'd like to explore too, one day :)

 

That's basically the way I'm going now. I just get the weird sense that some clever person already condensed it down to lesser equations.

This is a huge area of study. You can easily make a PhD thesis about this, and many people have.

So you have N particles that interact through gravity. You would normally model them as spheres of uniform density and fixed radius, so when two of them get really close things don't blow up.

You then need to do two things per time step:
(1) Compute the net force on each particle.
(2) Integrate the equations of motion.

(1) is the expensive part. Naively, it takes time proportional to N^2. It turns out there is some very clever trick called the "multipole method" that is explained terribly in the papers I have found, but it can approximate (to very high precision) the forces really well using time O(N). I have only ever needed a 1-D version of this and it was quite challenging. I don't know how much harder it would be in 3D.

Got links to some of those PhDs?? Even if the advanced stuff is too, well, advanced, it might trigger some inspiration. Your (1) and (2) steps are what I am looking at doing now, but I have already googled up the multipole thing and hope there is gold in them there hills!

Share this post


Link to post
Share on other sites

Okay, since I work in Astrophysics (as one of those many PhDs doing this still ;-) ), I thought I should add my weight to this one.  Basically there's no way in hell you can model a full Universe, even with crude detail using actual physics.  I have colleagues who do these things for a living and to get even half-crude simulations they need to run for weeks/months on parallel super-computers usually with 100s or 1000s or processors.

 

However, what you can (and probably should) do is use the various models and mathematical prescriptions that describe the structure in the Universe to create a pseudo-model.  For example, the large-scale structure of the Universe is a network of filaments connecting large galaxy clusters which obey some sort of structure function.  Then at smaller scales, galaxy clusters are often modeled using simple radial profiles such as a King Profile.  Galaxies themselves either have spiral or ellptical profile, depending on various parameters such as the amount of gas, angular momentum of gas, the age of the stars, whether it has merged with another galaxy earlier and other factors.  And then of course the contents of galaxies can be parameterized statistically, such as Globular clusters, or the distribution of stars (masses and binarity) and of course the distribution of planets around stars!

 

But getting a pseudo-physical algorithm that can 'simulate' the formation of a full Universe like this is a tough ask in itself, even if you only use approximations rather than real physics.  I've not quite thought about it myself tbh but I'm sure there are ways to do it that will give you the kind of results you are hoping for.  Sorry this is more of a 'what you can't do' post than 'what you can do' but thought I should just point that out now before you spend/waste too much time on it and point you more in the direction of what is possible.  This is of course simply creating procedural models of the Universe rather than just planets but same principle ;-)

 

As a small aside, I'm sure you know about these but thought I'd link just in case since the techniques these guys use will probably overlap with what you might want to do :

http://universesandbox.com/

http://spaceengine.org

Share this post


Link to post
Share on other sites

Okay, since I work in Astrophysics (as one of those many PhDs doing this still ;-) ), I thought I should add my weight to this one.

Oh no, no no no, don't you worry, I am NOT simulating a full universe!!!! I teach (taught) science and study a bunch of sciences myself, and did a thorough study before all of this, and no, no, noooo I am not going for anything more than a laughably simplified universe using the most basic of scientific equations! At the moment, I am trying to put the first tiny pieces into action, so to speak, and I just want to avoid wasting time on a lot of overly complicated math if there is one or more shortcuts that can be taken. I just got basic gravity (Newton's law of universal gravitation) working, for example. I know the games / simulations you list, and I doubt that the parts of mine that simulates the cosmos will be even that advanced! All I want is something that can claim to be based in science, not something that is scientifically accurate. I know (some of) my limitations :o

Of course, now that you have 'outed' yourself as an astrophysicist, this debate might get a whole lot more interesting ;-) Incidentally, I can't find anything on a King Profile, do you have a good link explaining that?

Edited by Embassy of Time

Share this post


Link to post
Share on other sites

 

Okay, since I work in Astrophysics (as one of those many PhDs doing this still ;-) ), I thought I should add my weight to this one.

Oh no, no no no, don't you worry, I am NOT simulating a full universe!!!! I teach (taught) science and study a bunch of sciences myself, and did a thorough study before all of this, and no, no, noooo I am not going for anything more than a laughably simplified universe using the most basic of scientific equations!

 

Then you need to be much more clear about what you're trying to do, because I also thought you're trying to simulate a universe from creation to late-stage development.  My thoughts are exactly as sergamer1, there's no chance whatsoever of doing this even close to anything usable for a game with simulation times as low as a few milliseconds.

I think whatever you're trying to do, if you want to use somewhat realistic physics (no matter how simple the math) on galactic or universal scales, you will have to sub-divide things to a huge extent.  Or, better would be to limit the scope of what you're trying to simulate.  

Share this post


Link to post
Share on other sites

Then you need to be much more clear about what you're trying to do, because I also thought you're trying to simulate a universe from creation to late-stage development.  My thoughts are exactly as sergamer1, there's no chance whatsoever of doing this even close to anything usable for a game with simulation times as low as a few milliseconds.
I think whatever you're trying to do, if you want to use somewhat realistic physics (no matter how simple the math) on galactic or universal scales, you will have to sub-divide things to a huge extent.  Or, better would be to limit the scope of what you're trying to simulate.

I added an edit to make sure people get the details of my intentions. I am currently working on sub-division tactics, and part of their purpose is to make sure that only relevant parts of the universe get simulated. I did that before, too. Trust me, I know how big and complex the universe is (metaphorically speaking), this is not a "universe copy-paste", it's just a project trying to be based on realistic science.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!