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
c5a703a2
Commit
c5a703a2
authored
7 years ago
by
Matthieu Schaller
Committed by
Matthieu Schaller
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Full expression for the Gadget2 truncation function and its derivatives.
parent
33ca1571
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!566
Periodic gravity calculation
,
!565
Mesh force task
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/kernel_long_gravity.h
+36
-1
36 additions, 1 deletion
src/kernel_long_gravity.h
theory/Multipoles/mesh_summary.tex
+1
-1
1 addition, 1 deletion
theory/Multipoles/mesh_summary.tex
with
37 additions
and
2 deletions
src/kernel_long_gravity.h
+
36
−
1
View file @
c5a703a2
...
...
@@ -31,7 +31,7 @@
#include
<float.h>
#include
<math.h>
//
#define GADGET2_LONG_RANGE_CORRECTION
#define GADGET2_LONG_RANGE_CORRECTION
struct
truncated_derivatives
{
...
...
@@ -47,6 +47,40 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_derivatives(
const
float
r
,
const
float
rs_inv
,
struct
truncated_derivatives
*
const
derivs
)
{
#ifdef GADGET2_LONG_RANGE_CORRECTION
/* Powers of u=r/2r_s */
const
float
u
=
0
.
5
f
*
r
*
rs_inv
;
const
float
u2
=
u
*
u
;
const
float
u3
=
u2
*
u
;
const
float
u4
=
u3
*
u
;
/* Powers of (1/r_s) */
const
float
rs_inv2
=
rs_inv
*
rs_inv
;
const
float
rs_inv3
=
rs_inv2
*
rs_inv
;
const
float
rs_inv4
=
rs_inv3
*
rs_inv
;
const
float
rs_inv5
=
rs_inv4
*
rs_inv
;
/* Derivatives of \chi */
derivs
->
chi_0
=
erfcf
(
u
);
derivs
->
chi_1
=
-
rs_inv
;
derivs
->
chi_2
=
rs_inv2
*
u
;
derivs
->
chi_3
=
-
rs_inv3
*
(
u2
-
0
.
5
f
);
derivs
->
chi_4
=
rs_inv4
*
(
u3
-
1
.
5
f
*
u
);
derivs
->
chi_5
=
-
rs_inv5
*
(
u4
-
u2
+
0
.
75
f
);
const
float
one_over_sqrt_pi
=
((
float
)(
M_2_SQRTPI
*
0
.
5
));
const
float
common_factor
=
one_over_sqrt_pi
*
expf
(
-
u2
);
/* Multiply in the common factors */
derivs
->
chi_1
*=
common_factor
;
derivs
->
chi_2
*=
common_factor
;
derivs
->
chi_3
*=
common_factor
;
derivs
->
chi_4
*=
common_factor
;
derivs
->
chi_5
*=
common_factor
;
#else
/* Powers of 2/r_s */
const
float
c0
=
1
.
f
;
const
float
c1
=
2
.
f
*
rs_inv
;
...
...
@@ -80,6 +114,7 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_derivatives(
derivs
->
chi_4
=
-
2
.
f
*
exp_x
*
c4
*
(
24
.
f
*
a5
-
36
.
f
*
a4
+
14
.
f
*
a3
-
a2
);
derivs
->
chi_5
=
-
2
.
f
*
exp_x
*
c5
*
(
120
.
f
*
a6
-
240
.
f
*
a5
+
150
.
f
*
a4
-
30
.
f
*
a3
+
a2
);
#endif
}
/**
...
...
This diff is collapsed.
Click to expand it.
theory/Multipoles/mesh_summary.tex
+
1
−
1
View file @
c5a703a2
...
...
@@ -24,7 +24,7 @@ This function alongside the trunctation function used in
$
\chi
(
r, r
_
s
)
=
\mathrm
{
erfc
}
(
\frac
{
1
}{
2
}
\frac
{
r
}{
r
_
s
}
)
$
.
}
is shown
on Fig.~
\ref
{
fig:fmm:potential
_
short
}
. This choice of
$
\sigma
(
w
)
$
can
seem rather cumbersome at first but writing
$
\alpha
(
w
)
\equiv
(
1
+
e
^
w
)
^{
-
1
}$
, one can express
ed
all derivatives of
$
\alpha
(
w
)
\equiv
(
1
+
e
^
w
)
^{
-
1
}$
, one can express all derivatives of
$
\sigma
(
w
)
$
as simple polynomials in
$
\alpha
(
w
)
$
(with an identical
$
e
^
w
$
pre-factor), which are easy and cheap to evaluate (see Appendix
\ref
{
sec:pot
_
derivatives
}
). For instance, in the case of the direct
...
...
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