- Thank you received: 0
Universe Simulator
20 years 10 months ago #7877
by Rudolf
Reply from Rudolf Henning was created by Rudolf
Thanks very much for the info so far.
I think as a first cut I'll just try to get something without a user interface (or any fancy one) Doing this kind of thing in real time in graphics could be very straineous on a machine if you don't do it right. I'm not going to brag that I can do any serious graphics programming (have done things like that at varsity years ago)
The first thing I'm going to do is some system specification (the kinda thing your suppose to do when building some software app but no-one does - you know)
There are a lot of things that I'll have to considder even for such a simple simulator. Just to name a few.
(1) The coordinate system (fixed or relative to mass centre). Because the integer type variables of computer programs are finite (limited to a certain size) if anything approach the limits there could be a problem. Also, what scale a unit would represent. Too small and there would be not enough accurace to represent movements. Too big and the coordinate system can ran out of space (the integer problem)
(2) Time slice size. Again there could be a too fine or too big problem. This might have to wait until I have started testing things.
(3) data storage problem. Because the calculations would involved multiple objects and a lot of repetition access times to stored data would be important (otherwise the whole simulation would be too slow and it could take millions of years to simulate millions or years []) The type of structures and access means would have to be chosen carefully.
(4) for each star|particle the resultant force on it will be the sum of all forces from surrounding particles (within the limited range)
etc. (will think of more later)
Some of the things that I would like to test:
(1) Simple system of particles (like 2) just orbiting each other at various distances.
(2) Galaxy type of system (no collisions)
(3) Galaxy system interaction with others (later) (no collisions)
(4) Galaxy system with interaction with others (much later) (collisions)
(5) Galaxy cluster system (will see if I ever reach this plus how do I simulate elysium??)
If all this becomes reality we will have something to make some interesting predictions - something that can actually be shown to normal layman people.
Now to get starting... Wish me luck.
Rudolf
I think as a first cut I'll just try to get something without a user interface (or any fancy one) Doing this kind of thing in real time in graphics could be very straineous on a machine if you don't do it right. I'm not going to brag that I can do any serious graphics programming (have done things like that at varsity years ago)
The first thing I'm going to do is some system specification (the kinda thing your suppose to do when building some software app but no-one does - you know)
There are a lot of things that I'll have to considder even for such a simple simulator. Just to name a few.
(1) The coordinate system (fixed or relative to mass centre). Because the integer type variables of computer programs are finite (limited to a certain size) if anything approach the limits there could be a problem. Also, what scale a unit would represent. Too small and there would be not enough accurace to represent movements. Too big and the coordinate system can ran out of space (the integer problem)
(2) Time slice size. Again there could be a too fine or too big problem. This might have to wait until I have started testing things.
(3) data storage problem. Because the calculations would involved multiple objects and a lot of repetition access times to stored data would be important (otherwise the whole simulation would be too slow and it could take millions of years to simulate millions or years []) The type of structures and access means would have to be chosen carefully.
(4) for each star|particle the resultant force on it will be the sum of all forces from surrounding particles (within the limited range)
etc. (will think of more later)
Some of the things that I would like to test:
(1) Simple system of particles (like 2) just orbiting each other at various distances.
(2) Galaxy type of system (no collisions)
(3) Galaxy system interaction with others (later) (no collisions)
(4) Galaxy system with interaction with others (much later) (collisions)
(5) Galaxy cluster system (will see if I ever reach this plus how do I simulate elysium??)
If all this becomes reality we will have something to make some interesting predictions - something that can actually be shown to normal layman people.
Now to get starting... Wish me luck.
Rudolf
Please Log in or Create an account to join the conversation.
- Larry Burford
- Offline
- Platinum Member
Less
More
- Thank you received: 0
20 years 10 months ago #7878
by Larry Burford
Replied by Larry Burford on topic Reply from Larry Burford
Good Luck,
[Rudolf] "(4) for each star|particle the resultant force on it will be the sum of all forces from surrounding particles (within the limited range)"
Suggestion: calculate acceleration rather than force. That way you don't have to know the mass of the target particle.
LB
[Rudolf] "(4) for each star|particle the resultant force on it will be the sum of all forces from surrounding particles (within the limited range)"
Suggestion: calculate acceleration rather than force. That way you don't have to know the mass of the target particle.
LB
Please Log in or Create an account to join the conversation.
20 years 10 months ago #7963
by Rudolf
Replied by Rudolf on topic Reply from Rudolf Henning
Ok, thanks. Altough in this system all particles would have the same 1 unit mass.
Rudolf
Rudolf
Please Log in or Create an account to join the conversation.
20 years 10 months ago #7924
by Rudolf
Replied by Rudolf on topic Reply from Rudolf Henning
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Suggestion: calculate acceleration rather than force. That way you don't have to know the mass of the target particle.<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
I suspect that I'll have to use some vector programming here. How can I get a resultant vector for an acceleration for a particle/object due to another object? My vector programming is rusted up so I'm in for a crash course (again)
Once I have a set of vectors (vector for each gravitational influence of another body) I should be able to just add these (vectors) up and the result would be the net acceleration which I can use to calculate the final positional change in the X time-slice time frame.
Please let me know if I'm totally of track here.
Rudolf
I suspect that I'll have to use some vector programming here. How can I get a resultant vector for an acceleration for a particle/object due to another object? My vector programming is rusted up so I'm in for a crash course (again)
Once I have a set of vectors (vector for each gravitational influence of another body) I should be able to just add these (vectors) up and the result would be the net acceleration which I can use to calculate the final positional change in the X time-slice time frame.
Please let me know if I'm totally of track here.
Rudolf
Please Log in or Create an account to join the conversation.
- Larry Burford
- Offline
- Platinum Member
Less
More
- Thank you received: 0
20 years 10 months ago #8309
by Larry Burford
Replied by Larry Burford on topic Reply from Larry Burford
Hello Rudolf,
[Rudolf]"How can I get a resultant vector for an acceleration for a particle/object due to another object?"
* each star needs an initial position and velocity.
* use rectangular coordinates, calc x and y values separately
* magnitude of a vector is sqrt(x^2 + y^2)
* angle (probably not needed unless you start to get fancy) is arctan (y/x). Stick with x and y components for logic simplicity and performance reasons where possible
(Star 1 is the primary, star 2 is the satellite)
===
position of star 1 and star 2 from memory
* p1[x], p1[y]
* p2[x], p2[y]
===
velocity of star 1 and star 2 from memory
* v1[x], v1[y]
* v2[x], v2[y]
===
distance between star 1 and star 2
* r[x] = p1[x] - p2[x]
* r[y] = p1[y] - p2[y]
* r = sqrt(r[x]^2 + r[y]^2)
===
acceleration of star 2 (satellite)
* a = G * M/r^2
* a[x] = a * (r[x]/r)
* a[y] = a * (r[y]/r)
(acceleration acts along distance vector and components of acceleration vector are in same proportions as components of distance vector)
(use a = GM/r^2 out to r = 1 kPc)
(fade to zero at r = 3 kPc)
(use zero for r > 3 kPc - no need to use a = GM/r, it should just happen)
(FYI the stars in our neighborhood are about 5 ly appart)
(or, use a = GM/r^2 out to infinity to simualte Newtonian gravity)
===
velocity change of star 2
* delta v[x] = a[x] * TimeInterval
* delta v[y] = a[y] * TimeInterval
===
save new velocity of star 2
* v[x] = v[x] + delta v[x]
* v[y] = v[y] + delta v[y]
===
save new postion of star 2
* p[x] = v[x] * TimeInterval
* p[y] = v[y] * TimeInterval
Then switch stars (1 is satellite, 2 is primary) and repeat the above starting at the acceleration step to find star 1's new position and velocity.
Then repeat all of this for every star.
Be sure to use each star's original position and velocity, not their newly calculated values.
Only after all stars have been processed can you replace the original values with the new values. This means you'll need two of the big arrays.
[Rudolf]"Once I have a set of vectors (vector for each gravitational influence of another body) I should be able to just add these (vectors) up and the result would be the net acceleration which I can use to calculate the final positional change in the X time-slice time frame."
Hmmm. A galaxy collision is going to be a lot less organized than this, I'm afraid. Different parts of it will be accelerating in different directions and by different amounts and at different times. The leading edges will have been interacting for many TimeIntervals before the centers even begin to feel something, for example.
See if you can get just get one (very small) galaxy to rotate, first. Surprise, looks like time for some graphics. Modern graphics are pretty fast though. Even in Windows.
Regards,
LB
[Rudolf]"How can I get a resultant vector for an acceleration for a particle/object due to another object?"
* each star needs an initial position and velocity.
* use rectangular coordinates, calc x and y values separately
* magnitude of a vector is sqrt(x^2 + y^2)
* angle (probably not needed unless you start to get fancy) is arctan (y/x). Stick with x and y components for logic simplicity and performance reasons where possible
(Star 1 is the primary, star 2 is the satellite)
===
position of star 1 and star 2 from memory
* p1[x], p1[y]
* p2[x], p2[y]
===
velocity of star 1 and star 2 from memory
* v1[x], v1[y]
* v2[x], v2[y]
===
distance between star 1 and star 2
* r[x] = p1[x] - p2[x]
* r[y] = p1[y] - p2[y]
* r = sqrt(r[x]^2 + r[y]^2)
===
acceleration of star 2 (satellite)
* a = G * M/r^2
* a[x] = a * (r[x]/r)
* a[y] = a * (r[y]/r)
(acceleration acts along distance vector and components of acceleration vector are in same proportions as components of distance vector)
(use a = GM/r^2 out to r = 1 kPc)
(fade to zero at r = 3 kPc)
(use zero for r > 3 kPc - no need to use a = GM/r, it should just happen)
(FYI the stars in our neighborhood are about 5 ly appart)
(or, use a = GM/r^2 out to infinity to simualte Newtonian gravity)
===
velocity change of star 2
* delta v[x] = a[x] * TimeInterval
* delta v[y] = a[y] * TimeInterval
===
save new velocity of star 2
* v[x] = v[x] + delta v[x]
* v[y] = v[y] + delta v[y]
===
save new postion of star 2
* p[x] = v[x] * TimeInterval
* p[y] = v[y] * TimeInterval
Then switch stars (1 is satellite, 2 is primary) and repeat the above starting at the acceleration step to find star 1's new position and velocity.
Then repeat all of this for every star.
Be sure to use each star's original position and velocity, not their newly calculated values.
Only after all stars have been processed can you replace the original values with the new values. This means you'll need two of the big arrays.
[Rudolf]"Once I have a set of vectors (vector for each gravitational influence of another body) I should be able to just add these (vectors) up and the result would be the net acceleration which I can use to calculate the final positional change in the X time-slice time frame."
Hmmm. A galaxy collision is going to be a lot less organized than this, I'm afraid. Different parts of it will be accelerating in different directions and by different amounts and at different times. The leading edges will have been interacting for many TimeIntervals before the centers even begin to feel something, for example.
See if you can get just get one (very small) galaxy to rotate, first. Surprise, looks like time for some graphics. Modern graphics are pretty fast though. Even in Windows.
Regards,
LB
Please Log in or Create an account to join the conversation.
20 years 10 months ago #8255
by Rudolf
Replied by Rudolf on topic Reply from Rudolf Henning
Thanks, I think I can get something going with this. I've already started on a framework 'class' that use the idea of two arrays (current position and working array) which basically will do what you suggested. Display or feedback logic would be seperate from this class. I use event driven feedback so the calling app control the frequency of steps plus what to do with the resultant data from each key frame returned - Not every time frame (slice) needs to be used for output which means the calculations could be more accurate than the eventual display could calculate (or use - simplifying the graphical display later on)
I'll explain a bit more later how I plan to do all this.
Rudolf
I'll explain a bit more later how I plan to do all this.
Rudolf
Please Log in or Create an account to join the conversation.
Time to create page: 0.793 seconds