10.4. Small Softening
Bob: Let's see how far we can push it. How about a softening length
of 0.01? And let me suppress the snapshot output for now:
|gravity> ruby rknbody9d_driver.rb < cube1.in
eps = 0.01
dt = 0.001
dt_dia = 2
dt_out = 10
dt_end = 2
init_out = false
x_flag = false
method = rk4
at time t = 0, after 0 steps :
E_kin = 0 , E_pot = -20.7 , E_tot = -20.7
E_tot - E_init = 0
(E_tot - E_init) / E_init = -0
at time t = 2, after 2000 steps :
E_kin = 227 , E_pot = -804 , E_tot = -577
E_tot - E_init = -556
(E_tot - E_init) / E_init = 26.8
Alice: Not too surprising. With velocities of order unity, and a
softening length that is only ten times larger than the time step,
a typical particle will step through the core of the potential of
another particle in only a few steps.
Bob: And when doing so, the particle will be sped up already to
velocities typical well above unity, leaving even fewer integration
steps during which the attraction between the particles changes
dramatically. In fact, when they approach each other to a distance of
order 0.01, there speed will be at least 10 in our units, and probably
larger than that. Two particles may pass each other through their
softening radius in even less than one time step.
So yes, it would have been worrisome if the errors would not have
been large. Let me use a ten times smaller time step:
|gravity> ruby rknbody9e_driver.rb < cube1.in
eps = 0.01
dt = 0.0001
dt_dia = 2
dt_out = 10
dt_end = 2
init_out = false
x_flag = false
method = rk4
at time t = 0, after 0 steps :
E_kin = 0 , E_pot = -20.7 , E_tot = -20.7
E_tot - E_init = 0
(E_tot - E_init) / E_init = -0
at time t = 2, after 20000 steps :
E_kin = 87.4 , E_pot = -108 , E_tot = -20.7
E_tot - E_init = -0.00458
(E_tot - E_init) / E_init = 0.000221
Alice: That's more like it. Actually, not so different from what we
found earlier, without softening.
Bob: I guess this means that our eight particles did not come much
closer to each other than distances of order 0.01.
Alice: Which is reasonable. In three dimensions there are two
independent directions in which two approaching particles can miss
each other, and you have to aim carefully to come really close.
Bob: Let me make the time step half as small again, just to check
whether the error in the energy conservation drops by at least a
factor of sixteen:
|gravity> ruby rknbody9f_driver.rb < cube1.in
eps = 0.01
dt = 5.0e-05
dt_dia = 2
dt_out = 10
dt_end = 2
init_out = false
x_flag = false
method = rk4
at time t = 0, after 0 steps :
E_kin = 0 , E_pot = -20.7 , E_tot = -20.7
E_tot - E_init = 0
(E_tot - E_init) / E_init = -0
at time t = 2, after 40000 steps :
E_kin = 101 , E_pot = -122 , E_tot = -20.7
E_tot - E_init = -0.000141
(E_tot - E_init) / E_init = 6.81e-06
Alice: I think we can declare victory.
10.5. Central Collapse
Bob: Ah, let's do something fun, something we never could have done
without softening. Let us give all particles equal masses, so that
when they drop from the corners of the cube, they all will reach each
other at the center. Even so, softening should keep them from
misbehaving.
Alice: As you like!
Bob: So these are the new initial conditions:
8
0
1
1 1 1
0 0 0
1
1 1 -1
0 0 0
1
1 -1 1
0 0 0
1
1 -1 -1
0 0 0
1
-1 1 1
0 0 0
1
-1 1 -1
0 0 0
1
-1 -1 1
0 0 0
1
-1 -1 -1
0 0 0
And this is the result:
|gravity> ruby rknbody9b_driver.rb < cube2.in
eps = 0.1
dt = 0.001
dt_dia = 2
dt_out = 2
dt_end = 2
init_out = false
x_flag = false
method = rk4
at time t = 0, after 0 steps :
E_kin = 0 , E_pot = -11.4 , E_tot = -11.4
E_tot - E_init = 0
(E_tot - E_init) / E_init = -0
at time t = 2, after 2000 steps :
E_kin = 8.54 , E_pot = -19.9 , E_tot = -11.4
E_tot - E_init = -4.77e-05
(E_tot - E_init) / E_init = 4.19e-06
8
1.9999999999998905e+00
1.0000000000000000e+00
-5.7041409218602102e-01 -5.7041409218602102e-01 -5.7041409218602102e-01
-8.4345690649961835e-01 -8.4345690649961835e-01 -8.4345690649961835e-01
1.0000000000000000e+00
-5.7041409218602102e-01 -5.7041409218602102e-01 5.7041409218602102e-01
-8.4345690649961835e-01 -8.4345690649961835e-01 8.4345690649961835e-01
1.0000000000000000e+00
-5.7041409218602090e-01 5.7041409218602102e-01 -5.7041409218602102e-01
-8.4345690649961791e-01 8.4345690649961835e-01 -8.4345690649961835e-01
1.0000000000000000e+00
-5.7041409218602102e-01 5.7041409218602102e-01 5.7041409218602102e-01
-8.4345690649961835e-01 8.4345690649961835e-01 8.4345690649961835e-01
1.0000000000000000e+00
5.7041409218602102e-01 -5.7041409218602090e-01 -5.7041409218602090e-01
8.4345690649961835e-01 -8.4345690649961791e-01 -8.4345690649961791e-01
1.0000000000000000e+00
5.7041409218602102e-01 -5.7041409218602102e-01 5.7041409218602090e-01
8.4345690649961835e-01 -8.4345690649961835e-01 8.4345690649961791e-01
1.0000000000000000e+00
5.7041409218602090e-01 5.7041409218602090e-01 -5.7041409218602102e-01
8.4345690649961791e-01 8.4345690649961791e-01 -8.4345690649961835e-01
1.0000000000000000e+00
5.7041409218602102e-01 5.7041409218602102e-01 5.7041409218602102e-01
8.4345690649961835e-01 8.4345690649961835e-01 8.4345690649961835e-01
Alice: Well behaved indeed. Glad to see it all works!