<p>Gravitational softening is a numerical trick introduced in particle simulations to avoid too close encounters that would otherwise result in unrealistic motion of particles.</p>
<p>The gravitational force between two particles of masses <span class="math-container">$m_i$</span> and <span class="math-container">$m_j$</span> (where in simulations, usually <span class="math-container">$m_i=m_2$</span>), separated by a distance <span class="math-container">$r_{ij}$</span>, is
<span class="math-container">$$
F_\mathrm{real} = \frac{G m_i m_j}{r_{ij}^2},
$$</span>
where <span class="math-container">$G$</span> is the gravitational constant. This expression diverges for <span class="math-container">$r\rightarrow0$</span>. The particles in a simulation represent a large amount of mass, thousands or even millions of Solar masses, so in reality if two masses come close, other forces (e.g viscosity) will dominate, and masses will disperse. In a simulation, particles may come arbitrarily and unnaturally close, and numerical rounding may blow up, so instead we substitute the force by
<span class="math-container">$$
F_\mathrm{soft} = \frac{G m_i m_j}{r_{ij}^2 + \varepsilon^2},
$$</span>
where <span class="math-container">$\varepsilon$</span> is the gravitational softening length. For <span class="math-container">$r_{ij}\gg\varepsilon$</span>, this approaches the regular force, whereas for <span class="math-container">$r\ll\varepsilon$</span>, the force is constant.</p>
<p>The value of <span class="math-container">$\varepsilon$</span> sets a limit to how small structures you can resolve in your simulation, and choosing a proper value for <span class="math-container">$\varepsilon$</span> is an art; a too small value reduces the desired effect, while a too large value reduces the resolution. Often the value of <span class="math-container">$\varepsilon$</span> is set to a certain fraction of the mean interparticle distance, e.g. 1/10 or 1/100. The choice will also affect the density profile of structures, so in order to make sure that your result doesn't depend too heavily on your chosen value, you need to run convergence test with various values, varying number of particles, etc.</p>
<p>The paper that @James K links to, <a href="https://ui.adsabs.harvard.edu/abs/2019MNRAS.487.1227Z/abstract" rel="noreferrer">Zhang et al. (2019)</a>, has a good list of resources if you want to dig further into the effect of the softening length.</p>
<p>As an example, I've plotted the forces for particles of mass <span class="math-container">$m_{i,j}=10^5\,M_\odot$</span>, and a gravitational softening length of <span class="math-container">$\varepsilon=100\,\mathrm{pc}$</span>:</p>
<p><a href="https://i.sstatic.net/4yYh1.png" rel="noreferrer"><img src="https://i.sstatic.net/4yYh1.png" alt="grav_soft" /></a></p>

CC BY-SA 4.0
2022-08-05T21:54:48.880Z
Thank you for the simple explanation, now it's clear to me.
Sriram Ramaswamy
CC BY-SA 4.0
2022-08-06T07:08:45.173Z
@SriramRamaswamy You're welcome :) Note that the parameters I chose for the figure coincide rather closely with the simulation called "Aq-A-3" in the paper you link to in your comment, for which the radius of the halo is ~250 kpc, i.e. 3½ times larger than the x axis in my plot. In other words, the chosen softening length only affects scales much smaller than the halo radius, as it should. On the other hand, with such a simulation you shouldn't expect to be able to simulate globular clusters realistically.
pela
CC BY-SA 4.0
2022-08-06T22:26:15.010Z
"...too close encounters that would otherwise result in unrealistic motion of particles" Certainly close encounters happen from time to time in reality; what is it about the resulting simulated motion that would be "unrealistic"? Is this simply a way to avoid occasional numerically stiff situations for which the global integration time step would be too large? By essentially removing close encounters (and their resulting effects!) from the physics of the simulation?
uhoh
CC BY-SA 4.0
2022-08-07T09:38:20.153Z
@uhoh That's an issue, but it's more about physics: If the particles represented point masses, e.g. stars or black holes, it wouldn't be unrealistic to come so close as to get slingshot away. But if they represent, say, 1e6 M☉, you should rather think of them as tracers of a mixture of various gas phases, a stellar population, or a field of dark matter (for gas, star, and DM particles, respectively). If 1e6 M☉ of gas comes close, it is compressed, mixed, converted to stars, etc, while if 1e6 M☉ of stars or DM comes close, it would be dispersed rather than all 1e6 stars being flung out.
pela
CC BY-SA 4.0
2022-08-07T10:19:24.643Z
Oh, so the "masses" are part of an atomistic approximation used where a [continuum model](https://en.wikipedia.org/wiki/Continuum_mechanics) would have been more appropriate, except for the challenges of adding gravity to a continuum? So what's actually unrealistic is the treatment of a continuous medium atomistically?
uhoh
CC BY-SA 4.0
2022-08-07T18:36:56.550Z
@uhoh You could say that, but I don't think I fancy the word "unrealistic". I'd rather say "quite realistic within its domain", which among other things means "down to a certain limiting scale". Another approach is grid-based codes where, rather than using particles, you have cells between which you calculate the diffusion of gas (and other matter). Here you also have a limiting scale, set by the size of the cells, which may refine adaptively to certain criteria (usually decreasing in regions of high density), or even move around _like_ particles.
pela
CC BY-SA 4.0
2022-08-07T21:48:02.797Z
This is *really interesting!* In normal continuum dynamics of compressible fluids people don't have forces like gravity that get stronger at short range, and in normal molecular dynamics with forces that only appear at short range *atomistic* models, every atom is treated explicitly so again no problem. The problem of self-gravitating "fluid" is something I'd never thought very hard about. Okay I got it now, thank you!
uhoh
CC BY-SA 4.0
2022-08-08T06:13:06.883Z
@uhoh  You’re welcome :) Note also that, although the number of particles/cells sets the resolution, a simulation will usually have subgrid physics, e.g. star formation and feedback, supermassive black holes, and turbulence.
pela
CC BY-SA 4.0
2022-08-04T20:40:59.573Z
2022-08-05T11:38:19.907Z
2022-08-05T11:38:19.907Z
pela
<p>I was reading the Aquarius simulation preprint (Springel et al. 2008) <a href="https://arxiv.org/abs/0809.0898" rel="noreferrer">The Aquarius Project: the subhalos of galactic halos</a> as a reference for my internship. I came across the term <strong>Gravitational softening length</strong> in the Initial conditions section and couldn't get a clear explanation when I searched online.</p>
<p>Can someone explain what it means in this context?</p>
<blockquote>
<p>2.2 The Aquarius simulation suite</p>
<p>In Table 1, we provide an overview of the basic numerical parameters of our simulations. This includes a symbolic
simulation name, the particle mass in the high-resolution
region, <strong>the gravitational softening length</strong>, the total particle
numbers in the high- and low-resolution regions, as well as
various characteristic masses and radii for the final halos,
and the corresponding particle numbers. Our naming convention is such that we use the tags “Aq-A” to “Aq-F” to
refer to simulations of the six Aquarius halos. An additional
suffix “1” to “5” denotes the resolution level. “Aq-A-1” is
our highest resolution calculation with ∼ 1.5 billion halo
particles. We have level 2 simulations of all 6 halos, corresponding to 160 to 224 million particles per halo.</p>
<p><strong>We kept the gravitational softening length fixed in comoving coordinates throughout the evolution of all our halos.</strong> The dynamics is then governed by a Hamiltonian and the
phase-space density of the discretized particle system should
be strictly conserved as a function of time (Springel, 2005),
modulo the noise introduced by finite force and time integration errors. Timestepping was carried out with a kick-driftkick leap-frog integrator where the timesteps were based on
the local gravitational acceleration, together with a conservatively chosen maximum allowed timestep for all particles</p>
</blockquote>

CC BY-SA 4.0
2022-08-04T09:59:14.747Z
Hi @Sriram, you should give some more details.  Please cite exactly the paper (if there is an online version, eg on Arkive then link to it too.  And please quote relevant parts of the paper.  Without these details, the question may not be answerable and might be closed.
James K
CC BY-SA 4.0
2022-08-04T10:02:50.703Z
Is the paper https://arxiv.org/abs/1810.07055 ? If so can you explain what is unclear about the definition given in the introduction.  If not, then that paper will probably let you write your own answer below.
James K
CC BY-SA 4.0
2022-08-04T13:58:30.723Z
There are different answer to this, depending on whether you read this in a particle-based or grid-based code paper. A link would help greatly.
AtmosphericPrisonEscape
CC BY-SA 4.0
2022-08-04T21:25:25.600Z
It's an interesting question, but as it stands, it is IMHO too brief and too short on the details, like the actual references. It looks 'lazy' and shows much less effort than already the first answer by pela. If you address the issues raised in the previous comments by an edit, I shall remove my downvote.
planetmaker
CC BY-SA 4.0
2022-08-05T21:53:39.903Z
I was reading the Aquarius simulation paper https://arxiv.org/abs/0809.0898 as a reference for my internship. I came across the term Gravitational softening length in the Initial conditions section and couldn't get a clear explanation when I searched online.
Sriram Ramaswamy
<galaxy><gravity><astrophysics><cosmology><n-body-simulations>
What is Gravitational softening length?
Sriram Ramaswamy
# What is Gravitational softening length?

(Asked by: username_0 on 2022-08-04)

I was reading the Aquarius simulation preprint (Springel et al. 2008) [The Aquarius Project: the subhalos of galactic halos](https://arxiv.org/abs/0809.0898) as a reference for my internship. I came across the term **Gravitational softening length** in the Initial conditions section and couldn't get a clear explanation when I searched online.

Can someone explain what it means in this context?

> 2.2 The Aquarius simulation suite
>
> In Table 1, we provide an overview of the basic numerical parameters of our simulations. This includes a symbolic
> simulation name, the particle mass in the high-resolution
> region, **the gravitational softening length**, the total particle
> numbers in the high- and low-resolution regions, as well as
> various characteristic masses and radii for the final halos,
> and the corresponding particle numbers. Our naming convention is such that we use the tags “Aq-A” to “Aq-F” to
> refer to simulations of the six Aquarius halos. An additional
> suffix “1” to “5” denotes the resolution level. “Aq-A-1” is
> our highest resolution calculation with ∼ 1.5 billion halo
> particles. We have level 2 simulations of all 6 halos, corresponding to 160 to 224 million particles per halo.
>
> **We kept the gravitational softening length fixed in comoving coordinates throughout the evolution of all our halos.** The dynamics is then governed by a Hamiltonian and the
> phase-space density of the discretized particle system should
> be strictly conserved as a function of time (Springel, 2005),
> modulo the noise introduced by finite force and time integration errors. Timestepping was carried out with a kick-driftkick leap-frog integrator where the timesteps were based on
> the local gravitational acceleration, together with a conservatively chosen maximum allowed timestep for all particles

**Tags:** galaxy, gravity, astrophysics, cosmology, n-body-simulations

> **Comments:**
> **username_1**: Hi @Sriram, you should give some more details.  Please cite exactly the paper (if there is an online version, eg on Arkive then link to it too.  And please quote relevant parts of the paper.  Without these details, the question may not be answerable and might be closed.  
> **username_1**: Is the paper https://arxiv.org/abs/1810.07055 ? If so can you explain what is unclear about the definition given in the introduction.  If not, then that paper will probably let you write your own answer below.  
> **username_2**: There are different answer to this, depending on whether you read this in a particle-based or grid-based code paper. A link would help greatly.  
> **username_3**: It's an interesting question, but as it stands, it is IMHO too brief and too short on the details, like the actual references. It looks 'lazy' and shows much less effort than already the first answer by username_4. If you address the issues raised in the previous comments by an edit, I shall remove my downvote.  
> **username_0**: I was reading the Aquarius simulation paper https://arxiv.org/abs/0809.0898 as a reference for my internship. I came across the term Gravitational softening length in the Initial conditions section and couldn't get a clear explanation when I searched online.  

---

## 1 answers

### Answer by username_4 on 2022-08-04. Score: 15 | Accepted answer

Gravitational softening is a numerical trick introduced in particle simulations to avoid too close encounters that would otherwise result in unrealistic motion of particles.

The gravitational force between two particles of masses $m\_i$ and $m\_j$ (where in simulations, usually $m\_i=m\_2$), separated by a distance $r\_{ij}$, is
$$
F\_\mathrm{real} = \frac{G m\_i m\_j}{r\_{ij}^2},
$$
where $G$ is the gravitational constant. This expression diverges for $r\rightarrow0$. The particles in a simulation represent a large amount of mass, thousands or even millions of Solar masses, so in reality if two masses come close, other forces (e.g viscosity) will dominate, and masses will disperse. In a simulation, particles may come arbitrarily and unnaturally close, and numerical rounding may blow up, so instead we substitute the force by
$$
F\_\mathrm{soft} = \frac{G m\_i m\_j}{r\_{ij}^2 + \varepsilon^2},
$$
where $\varepsilon$ is the gravitational softening length. For $r\_{ij}\gg\varepsilon$, this approaches the regular force, whereas for $r\ll\varepsilon$, the force is constant.

The value of $\varepsilon$ sets a limit to how small structures you can resolve in your simulation, and choosing a proper value for $\varepsilon$ is an art; a too small value reduces the desired effect, while a too large value reduces the resolution. Often the value of $\varepsilon$ is set to a certain fraction of the mean interparticle distance, e.g. 1/10 or 1/100. The choice will also affect the density profile of structures, so in order to make sure that your result doesn't depend too heavily on your chosen value, you need to run convergence test with various values, varying number of particles, etc.

The paper that @username_1 links to, [Zhang et al. (2019)](https://ui.adsabs.harvard.edu/abs/2019MNRAS.487.1227Z/abstract), has a good list of resources if you want to dig further into the effect of the softening length.

As an example, I've plotted the forces for particles of mass $m\_{i,j}=10^5\,M\_\odot$, and a gravitational softening length of $\varepsilon=100\,\mathrm{pc}$:

[![grav_soft](https://i.sstatic.net/4yYh1.png)](https://i.sstatic.net/4yYh1.png)

> **Comments:**
> **username_0**: Thank you for the simple explanation, now it's clear to me.  
> **username_4**: @SriramRamaswamy You're welcome :) Note that the parameters I chose for the figure coincide rather closely with the simulation called "Aq-A-3" in the paper you link to in your comment, for which the radius of the halo is ~250 kpc, i.e. 3½ times larger than the x axis in my plot. In other words, the chosen softening length only affects scales much smaller than the halo radius, as it should. On the other hand, with such a simulation you shouldn't expect to be able to simulate globular clusters realistically.  
> **username_5**: "...too close encounters that would otherwise result in unrealistic motion of particles" Certainly close encounters happen from time to time in reality; what is it about the resulting simulated motion that would be "unrealistic"? Is this simply a way to avoid occasional numerically stiff situations for which the global integration time step would be too large? By essentially removing close encounters (and their resulting effects!) from the physics of the simulation?  
> **username_4**: @username_5 That's an issue, but it's more about physics: If the particles represented point masses, e.g. stars or black holes, it wouldn't be unrealistic to come so close as to get slingshot away. But if they represent, say, 1e6 M☉, you should rather think of them as tracers of a mixture of various gas phases, a stellar population, or a field of dark matter (for gas, star, and DM particles, respectively). If 1e6 M☉ of gas comes close, it is compressed, mixed, converted to stars, etc, while if 1e6 M☉ of stars or DM comes close, it would be dispersed rather than all 1e6 stars being flung out.  
> **username_5**: Oh, so the "masses" are part of an atomistic approximation used where a [continuum model](https://en.wikipedia.org/wiki/Continuum_mechanics) would have been more appropriate, except for the challenges of adding gravity to a continuum? So what's actually unrealistic is the treatment of a continuous medium atomistically?  
> **username_4**: @username_5 You could say that, but I don't think I fancy the word "unrealistic". I'd rather say "quite realistic within its domain", which among other things means "down to a certain limiting scale". Another approach is grid-based codes where, rather than using particles, you have cells between which you calculate the diffusion of gas (and other matter). Here you also have a limiting scale, set by the size of the cells, which may refine adaptively to certain criteria (usually decreasing in regions of high density), or even move around _like_ particles.  
> **username_5**: This is *really interesting!* In normal continuum dynamics of compressible fluids people don't have forces like gravity that get stronger at short range, and in normal molecular dynamics with forces that only appear at short range *atomistic* models, every atom is treated explicitly so again no problem. The problem of self-gravitating "fluid" is something I'd never thought very hard about. Okay I got it now, thank you!  
> **username_4**: @username_5  You’re welcome :) Note also that, although the number of particles/cells sets the resolution, a simulation will usually have subgrid physics, e.g. star formation and feedback, supermassive black holes, and turbulence.  

---

