Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
e90e5d24
Commit
e90e5d24
authored
12 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added a section on multiple time stepping to the theory document.
Former-commit-id: 0492623ec719f4a063e028bfa4d2681662c66538
parent
8f96c781
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theory/latex/sph.tex
+57
-1
57 additions, 1 deletion
theory/latex/sph.tex
with
57 additions
and
1 deletion
theory/latex/sph.tex
+
57
−
1
View file @
e90e5d24
...
@@ -118,6 +118,7 @@ Having a compilation option somewhere which activates a given form of $f$ and ch
...
@@ -118,6 +118,7 @@ Having a compilation option somewhere which activates a given form of $f$ and ch
would be great.
would be great.
\section
{
First SPH loop (density)
}
\section
{
First SPH loop (density)
}
\label
{
sec:density
}
In the first loop of the algorithm, the secondary quantities of particle
$
i
$
are computed from the primary ones in the
In the first loop of the algorithm, the secondary quantities of particle
$
i
$
are computed from the primary ones in the
following way:
following way:
...
@@ -169,11 +170,13 @@ $\vec\nabla\times\vec v_i$ or $\vec\nabla\cdot\vec v_i$ are sometimes computed h
...
@@ -169,11 +170,13 @@ $\vec\nabla\times\vec v_i$ or $\vec\nabla\cdot\vec v_i$ are sometimes computed h
loop.
loop.
\section
{
Second SPH loop (forces)
}
\section
{
Second SPH loop (forces)
}
\label
{
sec:forces
}
Once those quantities have been obtained, the force estimation loop can be started.
Once those quantities have been obtained, the force estimation loop can be started.
First, the pressure has to be evaluated evaluated using the equation of state
First, the pressure has to be evaluated evaluated using the equation of state
\begin{equation}
\begin{equation}
\label
{
eq:pressure
}
P
_
i =
\rho
_
i u
_
i (
\gamma
- 1)
P
_
i =
\rho
_
i u
_
i (
\gamma
- 1)
\end{equation}
\end{equation}
...
@@ -183,7 +186,8 @@ The second loop is used to compute the accelerations (tertiary quantities). The
...
@@ -183,7 +186,8 @@ The second loop is used to compute the accelerations (tertiary quantities). The
\begin{eqnarray}
\begin{eqnarray}
\vec
{
a
_
i
}
&
=
&
-
\sum
_
j m
_
j
\left
[
\frac
{
P
_
i
}{
\Omega
_
i
\rho
_
i
^
2
}
\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
, h
_
i) +
\vec
{
a
_
i
}
&
=
&
-
\sum
_
j m
_
j
\left
[
\frac
{
P
_
i
}{
\Omega
_
i
\rho
_
i
^
2
}
\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
, h
_
i) +
\frac
{
P
_
j
}{
\Omega
_
j
\rho
_
j
^
2
}
\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
, h
_
j)
\right
]
\label
{
eq:acceleration
}
\\
\frac
{
P
_
j
}{
\Omega
_
j
\rho
_
j
^
2
}
\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
, h
_
j)
\right
]
\label
{
eq:acceleration
}
\\
\frac
{
du
_
i
}{
dt
}
&
=
&
\frac
{
P
_
i
}{
\rho
_
i
^
2
}
\sum
_
j m
_
j (
\vec
{
v
_
i
}
-
\vec
{
v
_
j
}
)
\cdot\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
, h
_
i)
\frac
{
du
_
i
}{
dt
}
&
=
&
\frac
{
P
_
i
}{
\textcolor
{
red
}{
\Omega
_
i
}
\rho
_
i
^
2
}
\sum
_
j m
_
j
(
\vec
{
v
_
i
}
-
\vec
{
v
_
j
}
)
\cdot\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
, h
_
i)
\label
{
eq:dudt
}
\\
\label
{
eq:dudt
}
\\
\frac
{
dh
_
i
}{
dt
}
&
=
&
\frac
{
h
_
i
}{
3
}
\sum
_
j
\frac
{
m
_
j
}{
\rho
_
j
}
\left
(
\vec
{
v
_
j
}
-
\vec
{
v
_
i
}
\right
)
\frac
{
dh
_
i
}{
dt
}
&
=
&
\frac
{
h
_
i
}{
3
}
\sum
_
j
\frac
{
m
_
j
}{
\rho
_
j
}
\left
(
\vec
{
v
_
j
}
-
\vec
{
v
_
i
}
\right
)
\cdot\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
,
\cdot\vec
{
\nabla
_
r
}
W(
\vec
{
r
}_{
ij
}
,
...
@@ -206,6 +210,7 @@ The time step is then given by the Courant relation:
...
@@ -206,6 +210,7 @@ The time step is then given by the Courant relation:
\begin{equation}
\begin{equation}
\Delta
t
_
i = C
_{
CFL
}
\frac
{
h
_
i
}{
c
_
i
}
\Delta
t
_
i = C
_{
CFL
}
\frac
{
h
_
i
}{
c
_
i
}
\label
{
eq:dt
}
\end{equation}
\end{equation}
where the Courant parameter (
$
C
_{
DFL
}$
)usually takes a value between
$
0
.
2
$
and
$
0
.
3
$
. The integration in time can then
where the Courant parameter (
$
C
_{
DFL
}$
)usually takes a value between
$
0
.
2
$
and
$
0
.
3
$
. The integration in time can then
...
@@ -263,7 +268,56 @@ first SPH loop. \\
...
@@ -263,7 +268,56 @@ first SPH loop. \\
u
_
i
&
=
&
\tilde
{
u
}_
i +
\textstyle\frac
{
1
}{
2
}
\Delta
t ~
\frac
{
du
_
i
}{
dt
}
u
_
i
&
=
&
\tilde
{
u
}_
i +
\textstyle\frac
{
1
}{
2
}
\Delta
t ~
\frac
{
du
_
i
}{
dt
}
\end{eqnarray*}
\end{eqnarray*}
\section
{
Multiple time steps
}
In most of the astrophysical applications, the range of time steps of the different particles is huge. In order to
speed-up computations, multiple time steps are used at the cost of a slightly less precise outcome.
\\
The interval between the beginning of the simulation
$
t
_{
ini
}$
and the end
$
t
_{
final
}$
is decomposed in
$
2
^
N
$
equal
intervals (In GADGET,
$
N
=
29
$
). The smallest allowed time step is thus
\begin{equation}
\Delta
t
_{
\min
}
=
\frac
{
t
_{
final
}
- t
_{
ini
}}{
2
^
N
}
\end{equation}
\\
The particles are then dispatched in different time bins according to their time steps
$
\Delta
t
_
i
$
(equation
\ref
{
eq:dt
}
). A particle
$
i
$
is in bin
$
n
$
if it verifies the condition
\begin{equation}
2
^{
n-1
}
\Delta
t
_{
\min
}
<
\Delta
t
_
i < 2
^
n
\Delta
t
_{
\min
}
\end{equation}
Particles in bin
$
n
=
1
$
will then all be evolved using
$
\Delta
t
_{
\min
}$
as their time steps, particles in bin
$
n
=
2
$
will use
$
2
\Delta
t
_{
\min
}$
as their time steps, particles in bin
$
n
=
3
$
will use
$
4
\Delta
t
_{
\min
}$
as their time steps and so on.
\\
At the beginning of the simulation (i.e. when
$
t
=
t
_{
ini
}$
), a density loop (section
\ref
{
sec:density
}
) is performed to compute the time step of every particle. The particles are then assigned a time bin
and the simulation starts using the smallest populated time bin.
\\
At every iteration, a set of time bins will be called
\emph
{
active
}
and all the particles populating them will be
integrated in time using the equations of section
\ref
{
sec:density
}
and
\ref
{
sec:forces
}
.
\\
Over the course of the
simulation, particles will have to move between time bins. Particles are only allowed to move to another bin if this
new bin is active. In other words, particles can always move down the time bin hierarchy but can only go upwards if the
two bins of interest are synchronized.
\\
When an active particles is integrated in time, it will probably have to interact with inactive neighbors. The state
of these inactive particles has to be
\emph
{
predicted
}
forward in time from the last time they have been active. To do
so, the following approximate evolution equations are used:
\begin{eqnarray}
\vec
{
x
}_
i
&
\leftarrow
&
\vec
{
x
}_{
i
}
+
\vec
{
v
}_
i
\cdot
\Delta
t
\\
\vec
{
v
}_{
i,pred
}
&
\leftarrow
&
\vec
{
v
}_{
i,pred
}
+
\vec
{
a
}_
i
\cdot
\Delta
t
\\
\rho
_
i
&
\leftarrow
&
\rho
_
i
\cdot
\exp\left
(
\frac
{
-3
}{
h
_
i
}
\frac
{
dh
_
i
}{
dt
}
\Delta
t
\right
)
\\
h
_
i
&
\leftarrow
&
h
_
i
\cdot
\exp\left
(
\frac
{
1
}{
h
_
i
}
\frac
{
dh
_
i
}{
dt
}
\Delta
t
\right
)
\\
u
_{
i,pred
}
&
\leftarrow
&
u
_{
i,pred
}
\cdot
\exp\left
(
\frac
{
1
}{
u
_
i
}
\frac
{
du
_
i
}{
dt
}
\Delta
t
\right
)
\\
\Omega
_
i
&
\leftarrow
&
1
\end{eqnarray}
These predicted quantities are then used in equations
\ref
{
eq:pressure
}
,
\ref
{
eq:acceleration
}
and
\ref
{
eq:dudt
}
to
estimate the acceleration and change in internal energy of an active particle. In order to preserve the old value of
the velocity and internal energy for accurate time integration, we need to add 2 additional variables to the particles,
the predicted velocity
$
\vec
{
v
}_{
i,pred
}$
(vector) and the predicted internal energy
$
u
_{
i,pred
}$
(scalar). The true
velocity
$
\vec
{
v
}_
i
$
and true internal energy
$
u
_
i
$
are NOT updated when predicting the state of a particle at an
intermediate time step.
\section
{
Conserved quantities
}
\section
{
Conserved quantities
}
...
@@ -281,6 +335,8 @@ The conservation of those quantities in the code depends on the quality of the t
...
@@ -281,6 +335,8 @@ The conservation of those quantities in the code depends on the quality of the t
integrator of the previous section should preserve these quantities to machine precision.
\\
integrator of the previous section should preserve these quantities to machine precision.
\\
Notice that the entropic function
$
A
(
s
)
$
is not the ``physical'' entropy
$
s
$
but is related to it through a monotonic
Notice that the entropic function
$
A
(
s
)
$
is not the ``physical'' entropy
$
s
$
but is related to it through a monotonic
function. It is just a more convenient way to represent entropy.
function. It is just a more convenient way to represent entropy.
THESE QUANTITIES ARE CONSERVED ONLY IF ONE SINGLE TIME STEP IS USED FOR ALL PARTICLES !!
\section
{
Improved SPH equations
}
\section
{
Improved SPH equations
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment