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
4cb541f6
Commit
4cb541f6
authored
Mar 24, 2017
by
Matthieu Schaller
Browse files
Apply the corrections for the Plummer-equivalent softenings.
parent
61dcf239
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/gravity/Default/gravity.h
View file @
4cb541f6
...
...
@@ -27,6 +27,8 @@
/**
* @brief Computes the gravity time-step of a given particle due to self-gravity
*
* We use Gadget-2's type 0 time-step criterion.
*
* @param gp Pointer to the g-particle data.
* @param grav_props Constants used in the gravity scheme.
*/
...
...
@@ -38,9 +40,10 @@ gravity_compute_timestep_self(const struct gpart* const gp,
gp
->
a_grav
[
1
]
*
gp
->
a_grav
[
1
]
+
gp
->
a_grav
[
2
]
*
gp
->
a_grav
[
2
];
const
float
ac
=
(
ac2
>
0
.
f
)
?
sqrtf
(
ac2
)
:
FLT_M
IN
;
const
float
ac
_inv
=
(
ac2
>
0
.
f
)
?
1
.
f
/
sqrtf
(
ac2
)
:
FLT_M
AX
;
const
float
dt
=
sqrtf
(
2
.
f
*
grav_props
->
eta
*
gp
->
epsilon
/
ac
);
/* Note that 0.714285714 = 2. (from Gadget) / 2.8 (Plummer softening) */
const
float
dt
=
sqrtf
(
0
.
714285714
f
*
grav_props
->
eta
*
gp
->
epsilon
*
ac_inv
);
return
dt
;
}
...
...
@@ -127,7 +130,8 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
__attribute__
((
always_inline
))
INLINE
static
void
gravity_init_softening
(
struct
gpart
*
gp
,
const
struct
gravity_props
*
grav_props
)
{
gp
->
epsilon
=
grav_props
->
epsilon
;
/* Note 2.8 is the Plummer-equivalent correction */
gp
->
epsilon
=
2
.
8
f
*
grav_props
->
epsilon
;
}
#endif
/* SWIFT_DEFAULT_GRAVITY_H */
tests/testKernelGrav.c
View file @
4cb541f6
...
...
@@ -34,7 +34,7 @@
* Taken from Gadget-2.0.7's forcetree.c lines 2755-2800
*
* @param r The distance between particles
* @param
h
The cut-off distance of the kernel
* @param
epsilon
The cut-off distance of the kernel
*/
float
gadget
(
float
r
,
float
epsilon
)
{
...
...
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