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
4cb541f6
Commit
4cb541f6
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Apply the corrections for the Plummer-equivalent softenings.
parent
61dcf239
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!324
Gravity multi dt
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gravity/Default/gravity.h
+7
-3
7 additions, 3 deletions
src/gravity/Default/gravity.h
tests/testKernelGrav.c
+1
-1
1 addition, 1 deletion
tests/testKernelGrav.c
with
8 additions
and
4 deletions
src/gravity/Default/gravity.h
+
7
−
3
View file @
4cb541f6
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
/**
/**
* @brief Computes the gravity time-step of a given particle due to self-gravity
* @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 gp Pointer to the g-particle data.
* @param grav_props Constants used in the gravity scheme.
* @param grav_props Constants used in the gravity scheme.
*/
*/
...
@@ -38,9 +40,10 @@ gravity_compute_timestep_self(const struct gpart* const gp,
...
@@ -38,9 +40,10 @@ gravity_compute_timestep_self(const struct gpart* const gp,
gp
->
a_grav
[
1
]
*
gp
->
a_grav
[
1
]
+
gp
->
a_grav
[
1
]
*
gp
->
a_grav
[
1
]
+
gp
->
a_grav
[
2
]
*
gp
->
a_grav
[
2
];
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
;
return
dt
;
}
}
...
@@ -127,7 +130,8 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
...
@@ -127,7 +130,8 @@ __attribute__((always_inline)) INLINE static void gravity_first_init_gpart(
__attribute__
((
always_inline
))
INLINE
static
void
gravity_init_softening
(
__attribute__
((
always_inline
))
INLINE
static
void
gravity_init_softening
(
struct
gpart
*
gp
,
const
struct
gravity_props
*
grav_props
)
{
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 */
#endif
/* SWIFT_DEFAULT_GRAVITY_H */
This diff is collapsed.
Click to expand it.
tests/testKernelGrav.c
+
1
−
1
View file @
4cb541f6
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
* Taken from Gadget-2.0.7's forcetree.c lines 2755-2800
* Taken from Gadget-2.0.7's forcetree.c lines 2755-2800
*
*
* @param r The distance between particles
* @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
)
{
float
gadget
(
float
r
,
float
epsilon
)
{
...
...
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