Previous | ToC | Up | Next |
Bob: As for the stellar dynamics, how fancy shall we make our code?
Alice: At least we should be able to handle core collapse for a small
number of particles, say a few hundred or so, so that we can model a
small cluster, and see the inner parts shrink gravothermally.
Bob: In that case, it would be nice to be able to deal with close
binaries as well. Otherwise we have to stop the simulation before
core collapse is completed. In addition, we may want to study the
effect of primordial binaries.
Alice: But I would prefer not to get into regularization and all that.
Whatever I have seen from special treatment of close encounters convinced
me that that whole topic is rather specialized, and not something we want
to throw at the students right away. Wouldn't it be sufficient to use
only one integration scheme globally, for all particles, without
making any local exceptions?
Bob: As for the global dynamics, we are pretty much forced to
introduce an individual time step scheme. That will require quite a
bit of explaining to the students, since it goes way beyond what they
can find in the standard text books on numerically solving
differential equations, but we have little choice. If all particles
would share the same time step size, the whole system would get down
on its knees when somewhere two stars would come close together, or
worse, would form a tight binary.
However, even with individual time steps, almost all of the computer
time for a few hundred body system could go into just one tight binary.
And what is worse, the integration of such a binary could lead to an
unacceptable build-up of roundoff errors.
Here is an example. It can easily happen that two stars form a hard
binary, with a semi-major axis that is a thousand times smaller than
the size of the system. The eccentricity e will fluctuate, due to
the perturbing forces from encounters with other stars, and
occasionally, e can get close to unity. If, say, e = 0.999, then
at the distance of closest approach the stars will be a million times
closer than the size of the system. In order to calculate the force
between the stars, we have to first subtract the position vectors of
both stars, and this will lead to a loss of precision of at least six
digits, reducing an original 64-bit double precision calculation
almost to 32-bit single precision. We simply cannot afford that, if
we want to integrate the system in an accurate way.
One way to overcome this problem is to introduce a special coordinate
system. Expressed in relative coordinates, with respect to the center
of mass of the two stars, there is no longer any problem of round-off.
An even better way is to go one step further: to replace the orbit of
a very tight binary star by the analytic solution of the Kepler
problem, an elliptical orbit for which we only have to solve Kepler's
equation to know where the two particles are with respect to each
other, at any given time. This will be an excellent approximation
when there are no other stars anywhere in the area.
Now sooner or later, a third star may happen to come near. In that
case we can temporarily switch back to numerical integration. Or, if
the binary has a very eccentric orbit, we may want to avoid
significant numerical errors by introducing a celestial mechanics
perturbation treatment. In that case, we stick to an analytical
Kepler orbit as the unperturbed solution, and we integrate the
perturbation equations. But in general, the best solution is to use
direct numerical integration in four dimenstions, using
what is called a Kustaanheimo-Stiefel transformation, or other
variants that have been introduced later. These of course are only
the first steps. There are many other very nice tricks of the trade.
If you use chain regularization and Stumpf . . .
Alice: Yes, yes, I'm sure there are many wonderful tricks, but we
have to offer your students something that they can understand and
apply, all within half a year. Whoever Stumpf is, or the other two
gentlemen you mentioned, let's leave them out for now.
Bob: But we should do something, on the local level, to make the
whole calculation meaningful. The question is what we can introduce
that goes partway toward full regularization. One thing we cannot get
around is to do the analytic regularization that I just mentioned.
Perhaps that is good enough to get them started. It will actually be
instructive for the students to see how things fail, and then to see
what solutions can be found to repair the situation. The only way to
do that, I think, would be to introduce the separate coordinate
patches I talked about. While that will rapidly get too complicated,
it would be fun, and it would give students a more realistic sense
of the complexities that a real code has to deal with. Who knows,
when we really get going, we might even want to give that a try.
Alice: Aha, do I detect the possibility of a smooth evolution from a
toy model to an actual production code?
Bob: No no, that would be far more complex. But it would be a step in
the right direction, for sure.
Alice: If the main problem would be a loss of accuracy, how about use
multiple precision? Instead of 64-bit word length for floating point
numbers, using 128-bit word length?
Bob: You mean quadruple precision? Yes, that would be an option, but
it will slow you down. Depending on the machine you use, it could slow
you down anywhere from a factor of a few to a factor of a hundred or so,
if you can do it at all: not every compiler has a quadruple precision
option, and you don't want to write all the routines by hand for computing
multiplication and division and square roots and all that.
In any case, yes, there are plenty of options. Right now, I wouldn't
be able to guess what would and would not work well, under which
conditions. So I'll be learning quite a bit from this exercise, I
think, even though it's only a toy model. The more I think about it,
the more it seems like a fun project.
Alice: If we really cannot avoid introducing some local treatment
in the stellar dynamics part of the code, it would be best to split
the stellar dynamics itself into two modules, and a clear interface.
Bob: I told you, that you would want to introduce more modules,
before long! How many do we have now? A scheduler (SC), a stellar
evolution (SE) and a hydro (SH) module, and now a global stellar
dynamics (GD) and a local stellar dynamics (LD) module, five in total!
Alice: Nothing wrong with having five modules in a code. This means
that you have a lot of freedom! You can replace each module, rewrite
it, experiment with it, all without affecting anything in any of the
other modules. But let's not repeat our arguments. After we finish
our first toy code, we can take up this discussion again, and by that
time we'll have a lot of actual code to work with, to strengthen our
arguments.
Bob: Fair enough. But now I'm puzzled. Passing information between
the SD and SE module was natural enough, since we were dealing with two
rather different types of physics. But the GD and LD modules both are
dealing with the same physics, plain old Newtonian gravitational
attraction. Putting an interface between them would seem like trying
to draw a line on the water!
Alice: I want to draw a line in the sand, frankly, and insist that
we divide the stellar dynamics into these two different modules. Look
at it this way. From the point of view of the global dynamics, the
local dynamics is a way to protect ourselves from the Kepler
singularities, right? I presume that is the meaning of the word
regularization, removing the singularities.
Bob: Yes, I think that is where the term comes from.
Alice: In that case, the SH module is also a form of regularization.
When two point particles come close, the SH module will replace them
by, for example, a blob of SPH particles. We could call this a form
of hydro regularization. It looks a bit like softening, where every
point particle is replaced by a small Plummer model. Softening could
also be called regularization.
Strictly speaking, the mathematical term regularization implies that
you do not change the underlying equations of motion, so in that sense
hydro treatment and softening should not be called regularization.
But we are not mathematicians. In astrophysics, we start with
extended objects. The idealization of replacing a star by a point
mass is only a matter of convenience. And when this replacement turns
out to be inconvenient, in close approaches between stars, we are free
to use other idealizations. We are only `regularizing' what had been
`singularized' as a too extreme idealization.
Bob: But you can't simulate a star cluster with a code that is only
using softening. The code will run, but it will not give you a
sufficient amount of two-body relaxation. And it will not admit hard
binaries.
Alice: That is true if you use a large softening length, like
people do when they collide two galaxies, and they want to suppress
two-body relaxation, which would be unphysical anyway in that case,
since each single particle represents thousands of stars, if not more.
But in the case of a star cluster, you could give each star a softening
length that is equal to the physical radius of a star. In that case,
binaries could form and two-body relaxation will be just fine. You
would have to do more, since you would have to prevent stars from
passing through each other, as softened particles would. When you
thus add a hard core and a friction term to let the particles stick
together upon close approach, you have gone well above the simple
softening recipe. But if you add those other prescriptions, using a
small softening in itself is not necessarily wrong.
Bob: So you view hydro treatment and regularization as somewhat
similar, from the point of view of the GD module, which only deals
with point particles?
Alice: Yes. And the interface between GD and LD can be similar to
what we saw before. We can specify a function to create a local clump
of particles, and similarly we can specify a clump destructor function.
We can have functions providing the mass and effective radius of a clump,
as a function providing the current time. It all follows rather closely
to what we just discussed for stellar evolution.
Bob: Hmmm. I still think it is like drawing a line in the water.
But early on I agreed to do the experiment, to write a modular toy model,
and if this is what you want, this is what we'll try to do. But allow
me to laugh loudly if your approach will result in an unwieldy code,
with many extra lines to circumvent your interface restrictions, and
a very slooooow overall execution speed. And I won't hesitate to tell
my students whose brilliant idea it was to do all this ;>).
Alice: If that is what will happen, you can use it as a case study
in how not to follow the advice of computer scientists who tell you to
use modular programming. I'm convinced that this will not happen, but
there is only one way to find out: we will continue, and see who is
right.
Bob: I can't wait!
8. Stellar Dynamics
8.1. Regularization
8.2. Local versus Global
Previous | ToC | Up | Next |