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
5154cd4e
Commit
5154cd4e
authored
12 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added the definition of the number of neighbors to the theory file.
Former-commit-id: f375ca1fa52399a6e16ff679582ed538faa974fc
parent
4a58893a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
theory/kernel/spline_3.nb
+19
-17
19 additions, 17 deletions
theory/kernel/spline_3.nb
theory/latex/sph.tex
+39
-17
39 additions, 17 deletions
theory/latex/sph.tex
with
58 additions
and
34 deletions
theory/kernel/spline.nb
→
theory/kernel/spline
_3
.nb
+
19
−
17
View file @
5154cd4e
...
...
@@ -10,10 +10,10 @@
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 157, 7]
NotebookDataLength[ 369
14
, 86
0
]
NotebookOptionsPosition[ 355
2
9, 80
7
]
NotebookOutlinePosition[ 35
868
, 82
2
]
CellTagsIndexPosition[ 358
25
, 81
9
]
NotebookDataLength[ 369
70
, 86
2
]
NotebookOptionsPosition[ 3559
5
, 80
9
]
NotebookOutlinePosition[ 35
934
, 82
4
]
CellTagsIndexPosition[ 358
91
, 8
2
1]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
...
...
@@ -681,22 +681,24 @@ Cell[BoxData[
RowBox[{"N", "[",
RowBox[{"Expand", "[",
RowBox[{
FractionBox["3", "4"], " ",
RowBox[{"-",
FractionBox["3", "4"]}], " ",
RowBox[{
SuperscriptBox[
RowBox[{"(",
RowBox[{"2", "-", "q"}], ")"}], "2"], "/", "Pi"}]}], "]"}],
"]"}]], "Input",
CellChangeTimes->{{3.560160709698295*^9, 3.560160723505558*^9}, {
3.560161185019305*^9, 3.560161189166279*^9}}],
3.560161185019305*^9, 3.560161189166279*^9}
, 3.560237508328278*^9
}],
Cell[BoxData[
RowBox[{"0.954929658551372`", "\[VeryThinSpace]", "-",
RowBox[{"0.954929658551372`", " ", "q"}], "+",
RowBox[{
RowBox[{"-", "0.954929658551372`"}], "+",
RowBox[{"0.954929658551372`", " ", "q"}], "-",
RowBox[{"0.238732414637843`", " ",
SuperscriptBox["q", "2"]}]}]], "Output",
CellChangeTimes->{{3.560160720336149*^9, 3.560160724559553*^9},
3.5601612038241377`*^9}]
3.5601612038241377`*^9
, 3.5602375092839746`*^9
}]
}, Open ]],
Cell[CellGroupData[{
...
...
@@ -806,7 +808,7 @@ Cell[BoxData[
}, Open ]]
},
WindowSize->{740, 867},
WindowMargins->{{Automatic, -13
98
}, {
57,
Automatic}},
WindowMargins->{{Automatic, -13
24
}, {Automatic
, 61
}},
FrontEndVersion->"8.0 for Linux x86 (64-bit) (November 7, 2010)",
StyleDefinitions->"Default.nb"
]
...
...
@@ -843,7 +845,7 @@ Cell[12697, 311, 265, 7, 30, "Input"],
Cell[12965, 320, 7987, 137, 221, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[20989, 462, 414, 10, 30, In
heritFromParent
],
Cell[20989, 462, 414, 10, 30,
"
In
put"
],
Cell[21406, 474, 9020, 153, 223, "Output"]
}, Open ]],
Cell[CellGroupData[{
...
...
@@ -851,16 +853,16 @@ Cell[30463, 632, 247, 5, 30, "Input"],
Cell[30713, 639, 1094, 35, 65, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[31844, 679,
360
, 1
1
, 54, "Input"],
Cell[322
07
, 69
2
,
296
,
6
, 30, "Output"]
Cell[31844, 679,
404
, 1
2
, 54, "Input"],
Cell[322
51
, 69
3
,
318
,
7
, 30, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[32
540
, 70
3
, 541, 17, 54, "Input"],
Cell[33
084
, 72
2
, 238, 6, 30, "Output"]
Cell[32
606
, 70
5
, 541, 17, 54, "Input"],
Cell[33
150
, 72
4
, 238, 6, 30, "Output"]
}, Open ]],
Cell[CellGroupData[{
Cell[33
359
, 73
3
, 79, 2, 30, "Input"],
Cell[33
441
, 73
7
, 2072, 67, 118, "Output"]
Cell[33
425
, 73
5
, 79, 2, 30, "Input"],
Cell[33
507
, 73
9
, 2072, 67, 118, "Output"]
}, Open ]]
}
]
...
...
This diff is collapsed.
Click to expand it.
theory/latex/sph.tex
+
39
−
17
View file @
5154cd4e
...
...
@@ -34,7 +34,7 @@ Every particle contains the following information:
\end{tabular}
\end{table}
For optimi
s
ation purposes, any function of these qu
n
atities could be stored. For instance,
$
1
/
h
$
instead of
$
h
$
or
For optimi
z
ation purposes, any function of these qua
n
tities could be stored. For instance,
$
1
/
h
$
instead of
$
h
$
or
$
\frac
{
P
}{
\rho\Omega
}$
instead of
$
\Omega
$
may be options worth exploring.
\section
{
Kernel function
}
...
...
@@ -70,7 +70,7 @@ function that goes to $0$ if $x > \zeta h$. \\
Coming back to the simplest case, the derivatives of the kernel function are given by:
\begin{eqnarray*}
\vec\nabla
W(
\vec
{
x
}
,h)
&
=
&
\frac
{
1
}{
h
^
4
}
f'
\left
(
\frac
{
|
\vec
{
x
}
|
}{
h
}
\right
)
\frac
{
\vec
{
x
}}{
|
\vec
{
x
}
|
}
\\
\vec\nabla
_
x
W(
\vec
{
x
}
,h)
&
=
&
\frac
{
1
}{
h
^
4
}
f'
\left
(
\frac
{
|
\vec
{
x
}
|
}{
h
}
\right
)
\frac
{
\vec
{
x
}}{
|
\vec
{
x
}
|
}
\\
\frac
{
\partial
W(
\vec
{
x
}
,h)
}{
\partial
h
}
&
=
&
-
\frac
{
1
}{
h
^
4
}
\left
[3f
\left
(
\frac
{
|
\vec
{
x
}
|
}{
h
}
\right
) +
\frac
{
|
\vec
{
x
}
|
}{
h
}
f'
\left
(
\frac
{
|
\vec
{
x
}
|
}{
h
}
\right
)
\right
]
\end{eqnarray*}
...
...
@@ -87,7 +87,7 @@ with
\right
.
\\
&
=
&
\left\lbrace
\begin{array}
{
rcl
}
-0.95493 q + 0.716197 q
^
2
&
\mbox
{
if
}
&
0
\leq
q < 1
\\
0.95493
-
0.95493 q
+
0.238732 q
^
2
&
\mbox
{
if
}
&
1
\leq
q < 2
\\
-
0.95493
+
0.95493 q
-
0.238732 q
^
2
&
\mbox
{
if
}
&
1
\leq
q < 2
\\
0
&
\mbox
{
if
}
&
q
\geq
2
\\
\end{array}
\right
.
...
...
@@ -99,7 +99,7 @@ change this without really touching the code.
Having a compilation option somewhere which activates a given form of
$
f
$
and changes the value of
$
\zeta
$
accordingly
would be great.
\section
{
SPH equations
}
\section
{
First SPH loop (density)
}
In the first loop of the algorithm, the secondary quantities of particle
$
i
$
are computed from the primary ones in the
following way:
...
...
@@ -109,9 +109,25 @@ following way:
h
_
i
&
=
&
\eta
\left
(
\frac
{
m
_
i
}{
\rho
_
i
}
\right
)
^{
1/3
}
\end{eqnarray}
where
$
\eta
\approx
1
.
2
$
is a constant. These two equations can be solved iterativelly using a Newton-Raphson or
bissection scheme. In practice, the loop is performed over all particles
$
j
$
which are at a distance
$
r
_{
ij
}
<
\zeta
h
$
from the particle of interest. One has to iterate those two equations until their outcomes are stable.
\\
where
$
\eta
\approx
1
.
2
$
is a constant. These two equations can be solved iteratively using a Newton-Raphson or
bisection scheme. In practice, the loop is performed over all particles
$
j
$
which are at a distance
$
r
_{
ij
}
<
\zeta
h
$
from the particle of interest. One has to iterate those two equations until their outcomes are stable.
\\
Another measure of the accuracy of
$
h
$
is to use the weighted number of neighbors which (in 3D) reads
\begin{equation}
N
_{
ngb
}
=
\frac
{
4
}{
3
}
\pi
\left
(
\zeta
h
\right
)
^
3
\sum
_
j W(r
_{
ij
}
,h
_
i)
\end{equation}
The (magical) value of
$
N
_{
ngb
}$
is a numerical parameter and its value can be expressed as a function of the more
physically relevant parameter
$
\eta
$
. In 3D this reads
\begin{equation}
N
_{
ngb
}
=
\frac
{
4
}{
3
}
\pi\left
(
\zeta
\eta\right
)
^
3
\end{equation}
We usually use
$
N
_{
ngb
}
=
48
$
, which corresponds to a sub-optimal value of
$
\eta
=
1
.
127
$
. The optimal value should be
$
N
_{
ngb
}
=
57
.
9
$
but this is computationally more expensive and the improvement over
$
N
_{
ngb
}
=
48
$
is not obvious.
\\
To increase the convergence rate, one can use the derivative of the density with respect to the smoothing length in the
Newton iterations:
...
...
@@ -127,7 +143,13 @@ This term is given by
\Omega
_
i = 1 +
\frac
{
h
_
i
}{
3
\rho
_
i
}
\sum
_
b m
_
b
\frac
{
\partial
W(r
_{
ij
}
,h
_
i)
}{
\partial
h
}
\end{equation}
Once those quantities have been obtained, the force estiamtion loop can be started.
This concludes the first SPH loop in the standard implementation. More complicated quantities such as
$
\vec\nabla\times\vec
v
_
i
$
or
$
\vec\nabla\cdot\vec
v
_
i
$
are sometimes computed here if they are needed in the force
loop.
\section
{
Second SPH loop (forces)
}
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
\begin{equation}
...
...
@@ -138,16 +160,16 @@ where $\gamma$ is the polytropic index. Usually, $\gamma = \frac{5}{3}$.
The second loop is used to compute the accelerations (tertiary quantities). The exact expressions are
\begin{eqnarray}
\vec
{
a
}
&
=
&
-
\sum
_
j m
_
j
\left
[
\frac
{
P
_
i
}{
\Omega
_
i
\rho
_
i
^
2
}
\vec
{
\nabla
}
W(r
_{
ij
}
, h
_
i) +
\frac
{
P
_
j
}{
\Omega
_
j
\rho
_
j
^
2
}
\vec
{
\nabla
}
W(r
_{
ij
}
, h
_
j)
\right
]
\\
\frac
{
d
u
}{
dt
}
&
=
&
\frac
{
P
_
i
}{
\rho
_
i
^
2
}
\sum
_
j m
_
j
(
\vec
{
v
_
i
}
-
\vec
{
v
_
j
}
)
\cdot\vec
{
\nabla
}
W(r
_{
ij
}
, h
_
i)
\\
\frac
{
dh
}{
dt
}
&
=
&
\frac
{
h
_
i
}{
3
}
\sum
_
j
\frac
{
m
_
j
}{
\rho
_
j
}
\left
(
\vec
{
v
_
j
}
-
\vec
{
v
_
i
}
\right
)
\cdot\vec
{
\nabla
}
W(r
_{
ij
}
,
\vec
{
a
}
&
=
&
-
\sum
_
j m
_
j
\left
[
\frac
{
P
_
i
}{
\Omega
_
i
\rho
_
i
^
2
}
\vec
{
\nabla
_
r
}
W(r
_{
ij
}
, h
_
i) +
\frac
{
P
_
j
}{
\Omega
_
j
\rho
_
j
^
2
}
\vec
{
\nabla
_
r
}
W(r
_{
ij
}
, h
_
j)
\right
]
\\
\frac
{
du
}{
dt
}
&
=
&
\frac
{
P
_
i
}{
\rho
_
i
^
2
}
\sum
_
j m
_
j (
\vec
{
v
_
i
}
-
\vec
{
v
_
j
}
)
\cdot\vec
{
\nabla
_
r
}
W(r
_{
ij
}
, h
_
i)
\\
\frac
{
d
h
}{
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(r
_{
ij
}
,
h
_
i)
\end{eqnarray}
In practice the loop is here performed over all pairs of particles such that
$
r
_{
ij
}
<
\zeta
h
_
i
$
or
$
r
_{
ij
}
<
\zeta
h
_
j
$
. In general, the equations are more involved as they will contain terms to mimi
m
c the effect of viscosity or
h
_
j
$
. In general, the equations are more involved as they will contain terms to mimic the effect of viscosity or
thermal conduction. These terms are pure functions of the properties of particles
$
i
$
and
$
j
$
and are thus very simple
to insert once the code is stabilized.
\\
...
...
@@ -165,14 +187,14 @@ The time step is then given by the Courant relation:
where the CFL parameter usually takes a value between
$
0
.
2
$
and
$
0
.
3
$
. The integration in time can then take place. The
leapfrog integrator is usually used as it behaves well when coupled to gravity.
\\
In the case where only one global timestep is used for all particles, the minimal timestep of all particles is reduced
In the case where only one global time
step is used for all particles, the minimal time
step of all particles is reduced
and used.
\\
Notice that
$
h
$
has to be recomputed through the iterative process
presented in the previous section at every timestep. The time
presented in the previous section at every time
step. The time
derivative of the smoothing length only give a rough estimate of its
change. It only provides a good guess for the Newton-Raphson (or
bis
s
ection) scheme.
bisection) scheme.
\section
{
Conserved quantities
}
...
...
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