finally accurate mesh forces

This commit is contained in:
2025-02-02 21:51:56 +01:00
parent 37a2687ffe
commit da8a7d4574
10 changed files with 661 additions and 317 deletions

View File

@@ -31,13 +31,13 @@
// Finally - The real content
= N-body forces and analytical solutions
== Objective
Implement naive N-body force computation and get an intuition of the challenges:
- accuracy
- computation time
- stability
// == Objective
// Implement naive N-body force computation and get an intuition of the challenges:
// - accuracy
// - computation time
// - stability
$==>$ still useful to compute basic quantities of the system, but too limited for large systems or the dynamical evolution of the system
// $==>$ still useful to compute basic quantities of the system, but too limited for large systems or the dynamical evolution of the system
== Overview - the system
@@ -47,7 +47,7 @@ Get a feel for the particles and their distribution. [#link(<task1:plot_particle
#columns(2)[
#helpers.image_cell(t1, "plot_particle_distribution")
Note: for visibility the outer particles are not shown.
// Note: for visibility the outer particles are not shown.
#colbreak()
The system at hand is characterized by:
- $N ~ 10^4$ stars
@@ -81,12 +81,12 @@ We compare the computed density with the analytical model provided by the _Hernq
#helpers.image_cell(t1, "plot_density_distribution")
]
)
// Note that by construction, the first shell contains no particles
// => the numerical density is zero there
// Having more bins means to have shells that are nearly empty
// => the error is large, NBINS = 30 is a good compromise
#block(
height: 1fr,
)
== Force computation
// N Body and variations
@@ -110,13 +110,48 @@ We compare the computed density with the analytical model provided by the _Hernq
]
)
// basic $N^2$ matches analytical solution without dropoff. but: noisy data from "bad" samples
// $N^2$ with softening matches analytical solution but has a dropoff. No noisy data.
// => softening $\approx 1 \varepsilon$ is a sweet spot since the dropoff is "late"
== Relaxation
Relaxation [#link(<task1:compute_relaxation_time>)[code]]:
// #helpers.code_cell(t1, "compute_relaxation_time")
We express system relaxation in terms of the dynamical time of the system.
$
t_"relax" = overbrace(N / (8 log N), n_"relax") dot t_"crossing"
$
where the crossing time of the system can be estimated through the half-mass velocity $t_"crossing" = v(r_"hm")/r_"hm"$.
We find a relaxation of [#link(<task1:compute_relaxation_time>)[code]].
Discussion!
// === Discussion
#grid(
columns: (1fr, 1fr),
inset: 0.5em,
block[
#image("relaxation.png")
],
block[
- Each star-star interaction contributes $delta v approx (2 G m )/b$
- Shifting by $epsilon$ *dampens* each contribution
- $=>$ relaxation time increases
]
)
// The estimate for $n_{relax}$ comes from the contribution of each star-star encounter to the velocity dispersion. This depends on the perpendicular force
// $\implies$ a bigger softening length leads to a smaller $\delta v$.
// Using $n_{relax} = \frac{v^2}{\delta v^2}$, and knowing that the value of $v^2$ is derived from the Virial theorem (i.e. unaffected by the softening length), we can see that $n_{relax}$ should increase with $\varepsilon$.
// === Effect
// - The relaxation time **increases** with increasing softening length
// - From the integration over all impact parameters $b$ even $b_{min}$ is chosen to be larger than $\varepsilon$ $\implies$ expect only a small effect on the relaxation time
// **In other words:**
// The softening dampens the change of velocity => time to relax is longer
@@ -128,10 +163,13 @@ Discussion!
columns: 2
)[
#helpers.image_cell(t2, "plot_particle_distribution")
$=>$ use $M_"sys" approx 10^4 M_"sol" + M_"BH"$
]
== Force computation
#helpers.code_reference_cell(t2, "function_mesh_force")
@@ -156,9 +194,16 @@ Discussion!
- very large grids have issues with overdiscretization
$==> 75 times 75 times 75$ as a good compromise
// Some other comments:
// - see the artifacts because of the even grid numbers (hence the switch to 75)
// overdiscretization for large grids -> vertical spread even though r is constant
// this becomes even more apparent when looking at the data without noise - the artifacts remain
]
)
#helpers.image_cell(t2, "plot_force_computation_time")
== Time integration
=== Runge-Kutta
#helpers.code_reference_cell(t2, "function_runge_kutta")

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB