Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
e13d6795
Commit
e13d6795
authored
Aug 16, 2017
by
Matthieu Schaller
Browse files
Added a unit test to verify that the gravity calculation is correct and accurate enough.
parent
efda478c
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
src/gravity_derivatives.h
View file @
e13d6795
This diff is collapsed.
Click to expand it.
tests/Makefile.am
View file @
e13d6795
...
...
@@ -25,7 +25,7 @@ TESTS = testGreetings testMaths testReading.sh testSingle testKernel testSymmetr
testParser.sh testSPHStep test125cells.sh test125cellsPerturbed.sh testFFT
\
testAdiabaticIndex testRiemannExact testRiemannTRRS testRiemannHLLC
\
testMatrixInversion testThreadpool testDump testLogger
\
testVoronoi1D testVoronoi2D testVoronoi3D
\
testVoronoi1D testVoronoi2D testVoronoi3D
testGravityDerivatives
\
testPeriodicBC.sh testPeriodicBCPerturbed.sh
# List of test programs to compile
...
...
@@ -35,7 +35,8 @@ check_PROGRAMS = testGreetings testReading testSingle testTimeIntegration \
testSymmetry testThreadpool benchmarkInteractions
\
testAdiabaticIndex testRiemannExact testRiemannTRRS
\
testRiemannHLLC testMatrixInversion testDump testLogger
\
testVoronoi1D testVoronoi2D testVoronoi3D testPeriodicBC
testVoronoi1D testVoronoi2D testVoronoi3D testPeriodicBC
\
testGravityDerivatives
# Rebuild tests when SWIFT is updated.
$(check_PROGRAMS)
:
../src/.libs/libswiftsim.a
...
...
@@ -95,6 +96,8 @@ testDump_SOURCES = testDump.c
testLogger_SOURCES
=
testLogger.c
testGravityDerivatives_SOURCES
=
testGravityDerivatives.c
# Files necessary for distribution
EXTRA_DIST
=
testReading.sh makeInput.py testPair.sh testPairPerturbed.sh
\
test27cells.sh test27cellsPerturbed.sh testParser.sh testPeriodicBC.sh
\
...
...
tests/testGravityDerivatives.c
0 → 100644
View file @
e13d6795
This diff is collapsed.
Click to expand it.
theory/Multipoles/fmm_standalone.tex
View file @
e13d6795
...
...
@@ -2,6 +2,7 @@
\usepackage
{
graphicx
}
\usepackage
{
amsmath,paralist,xcolor,xspace,amssymb
}
\usepackage
{
times
}
\usepackage
{
comment
}
\newcommand
{
\swift
}{{
\sc
Swift
}
\xspace
}
\newcommand
{
\nbody
}{$
N
$
-body
\xspace
}
...
...
theory/Multipoles/potential_derivatives.tex
View file @
e13d6795
...
...
@@ -4,19 +4,139 @@
For completeness, we give here the full expression for the first few
derivatives of the potential that are used in our FMM scheme. We use
the notation
$
\mathbf
{
r
}
=(
r
_
x, r
_
y, r
_
z
)
$
,
$
r
=
|
\mathbf
{
r
}
|
$
and
$
u
=
r
/
H
$
. Starting from the potential (Eq.
\ref
{
eq:fmm:potential
}
,
reproduced here for clarity),
$
u
=
r
/
H
$
. We can construct the higher order derivatives by successively
applying the "chain rule". We show representative examples of the
first few relevant ones here split by order. We start by constructing
common quantities that appear in derivatives of multiple orders.
\begin{align}
\mathsf
{
D
}_{
000
}
(
\mathbf
{
r
}
) =
\varphi
(
\mathbf
{
r
}
,H) =
\left\lbrace
\begin{array}
{
rcl
}
\frac
{
1
}{
H
}
\left
(-3u
^
7 + 15u
^
6 - 28u
^
5 + 21u
^
4 - 7u
^
2 + 3
\right
)
&
\mbox
{
if
}
&
u < 1,
\\
\frac
{
1
}{
r
}
&
\mbox
{
if
}
&
u
\geq
1,
\end{array}
\right
.
\nonumber
\mathsf
{
\tilde
{
D
}}_{
1
}
(r, u, H) =
\left\lbrace
\begin{array}
{
rcl
}
\left
(-3u
^
7 + 15u
^
6 - 28u
^
5 + 21u
^
4 - 7u
^
2 + 3
\right
)
\times
H
^{
-1
}
&
\mbox
{
if
}
&
u < 1,
\\
r
^{
-1
}
&
\mbox
{
if
}
&
u
\geq
1,
\end{array}
\right
.
\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
\mathsf
{
\tilde
{
D
}}_{
3
}
(r, u, H) =
\left\lbrace
\begin{array}
{
rcl
}
-
\left
(21u
^
5 - 90u
^
4 + 140u
^
3 -84u
^
2 +14
\right
)
\times
H
^{
-3
}&
\mbox
{
if
}
&
u < 1,
\\
-1
\times
r
^{
-3
}
&
\mbox
{
if
}
&
u
\geq
1,
\end{array}
\right
.
\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H) =
\left\lbrace
\begin{array}
{
rcl
}
\left
(-105u
^
3 + 360u
^
2 - 420u + 168
\right
)
\times
H
^{
-5
}&
\mbox
{
if
}
&
u < 1,
\\
3
\times
r
^{
-5
}
&
\mbox
{
if
}
&
u
\geq
1,
\end{array}
\right
.
\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H) =
\left\lbrace
\begin{array}
{
rcl
}
-
\left
(315u - 720 + 420u
^{
-1
}
\right
)
\times
H
^{
-7
}
&
\mbox
{
if
}
&
u < 1,
\\
-15
\times
r
^{
-7
}
&
\mbox
{
if
}
&
u
\geq
1,
\end{array}
\right
.
\nonumber
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{align}
\mathsf
{
\tilde
{
D
}}_{
9
}
(r, u, H) =
\left\lbrace
\begin{array}
{
rcl
}
\left
(-315u
^{
-1
}
+ 420u
^{
-3
}
\right
)
\times
H
^{
-9
}&
\mbox
{
if
}
&
u < 1,
\\
105
\times
r
^{
-9
}
&
\mbox
{
if
}
&
u
\geq
1.
\end{array}
\right
.
\nonumber
\end{align}
Starting from the potential (Eq.
\ref
{
eq:fmm:potential
}
,
reproduced here for completeness), we can now build all the relevent derivatives
\begin{align}
\mathsf
{
D
}_{
000
}
(
\mathbf
{
r
}
) =
\varphi
(
\mathbf
{
r
}
,H) =
\mathsf
{
\tilde
{
D
}}_{
1
}
(r, u, H)
\nonumber
\end{align}
\noindent\rule
{
6cm
}{
0.4pt
}
\begin{align}
\mathsf
{
D
}_{
100
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
}{
\partial
r
_
x
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
\mathsf
{
\tilde
{
D
}}_{
3
}
(r, u, H)
\nonumber
\end{align}
\noindent\rule
{
6cm
}{
0.4pt
}
\begin{align}
\mathsf
{
D
}_{
200
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
^
2
}{
\partial
r
_
x
^
2
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
2
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H) +
\mathsf
{
\tilde
{
D
}}_{
3
}
(r, u, H)
\nonumber
\end{align}
\begin{align}
\mathsf
{
D
}_{
110
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
^
2
}{
\partial
r
_
x
\partial
r
_
y
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x r
_
y
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H)
\nonumber
\end{align}
\noindent\rule
{
6cm
}{
0.4pt
}
\begin{align}
\mathsf
{
D
}_{
300
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
^
3
}{
\partial
r
_
x
^
3
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
3
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H)
+ 3 r
_
x
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H)
\nonumber
\end{align}
\begin{align}
\mathsf
{
D
}_{
210
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
^
3
}{
\partial
r
_
x
^
2 r
_
y
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
2 r
_
y
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H) +
r
_
y
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H)
\nonumber
\end{align}
\begin{align}
\mathsf
{
D
}_{
111
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
^
3
}{
\partial
r
_
x
\partial
r
_
y
\partial
r
_
z
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x r
_
y r
_
z
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H)
\nonumber
\end{align}
\noindent\rule
{
6cm
}{
0.4pt
}
\begin{align}
\mathsf
{
D
}_{
400
}
(
\mathbf
{
r
}
)
&
=
\frac
{
\partial
^
4
}{
\partial
r
_
x
^
4
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
4
\mathsf
{
\tilde
{
D
}}_{
9
}
(r, u, H)+
6r
_
x
^
2
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H) +
3
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H)
\nonumber
\end{align}
we can construct the higher order terms by successively applying the
"chain rule". We show representative examples of the first few
relevant ones here split by order.
\begin{align}
\mathsf
{
D
}_{
310
}
(
\mathbf
{
r
}
)
&
=
\frac
{
\partial
^
4
}{
\partial
r
_
x
^
3
\partial
r
_
y
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
3 r
_
y
\mathsf
{
\tilde
{
D
}}_{
9
}
(r, u, H) +
3 r
_
x r
_
y
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H)
\nonumber
\end{align}
\begin{align}
\mathsf
{
D
}_{
220
}
(
\mathbf
{
r
}
)
&
=
\frac
{
\partial
^
4
}{
\partial
r
_
x
^
2
\partial
r
_
y
^
2
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
2 r
_
y
^
2
\mathsf
{
\tilde
{
D
}}_{
9
}
(r, u, H) +
r
_
x
^
2
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H) +
r
_
y
^
2
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H) +
\mathsf
{
\tilde
{
D
}}_{
5
}
(r, u, H)
\nonumber
\end{align}
\begin{align}
\mathsf
{
D
}_{
211
}
(
\mathbf
{
r
}
)
&
=
\frac
{
\partial
^
4
}{
\partial
r
_
x
^
2
\partial
r
_
y
\partial
r
_
z
}
\varphi
(
\mathbf
{
r
}
,H) =
r
_
x
^
2 r
_
y r
_
z
\mathsf
{
\tilde
{
D
}}_{
9
}
(r, u, H) +
r
_
y r
_
z
\mathsf
{
\tilde
{
D
}}_{
7
}
(r, u, H)
\nonumber
\end{align}
\begin{comment}
\noindent\rule
{
6cm
}{
0.4pt
}
\begin{align}
\mathsf
{
D
}_{
100
}
(
\mathbf
{
r
}
) =
\frac
{
\partial
}{
\partial
r
_
x
}
\varphi
(
\mathbf
{
r
}
,H) =
...
...
@@ -101,3 +221,5 @@ relevant ones here split by order.
\mathsf
{
D
}_{
211
}
(
\mathbf
{
r
}
)
&
=
\nonumber
\end{align}
\end{comment}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment