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
d5b0d5b5
Commit
d5b0d5b5
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added unit test for long-range gravity forces
parent
b691da82
No related branches found
No related tags found
2 merge requests
!212
Gravity infrastructure
,
!172
[WIP] Self gravity (Barnes-Hut version)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testKernelGrav.c
+28
-2
28 additions, 2 deletions
tests/testKernelGrav.c
with
28 additions
and
2 deletions
tests/testKernelGrav.c
+
28
−
2
View file @
d5b0d5b5
...
@@ -17,14 +17,16 @@
...
@@ -17,14 +17,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
******************************************************************************/
******************************************************************************/
#include
"const.h"
#include
"kernel_gravity.h"
#include
"kernel_gravity.h"
#include
"kernel_long_gravity.h"
#include
<math.h>
#include
<math.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<strings.h>
#include
<strings.h>
#define numPoints (1 <<
6
)
#define numPoints (1 <<
7
)
/**
/**
* @brief The Gadget-2 gravity kernel function
* @brief The Gadget-2 gravity kernel function
...
@@ -54,7 +56,7 @@ float gadget(float r, float h) {
...
@@ -54,7 +56,7 @@ float gadget(float r, float h) {
int
main
()
{
int
main
()
{
const
float
h
=
3
.
f
;
const
float
h
=
3
.
f
;
const
float
r_max
=
5
.
f
;
const
float
r_max
=
6
.
f
;
for
(
int
k
=
1
;
k
<
numPoints
;
++
k
)
{
for
(
int
k
=
1
;
k
<
numPoints
;
++
k
)
{
...
@@ -82,5 +84,29 @@ int main() {
...
@@ -82,5 +84,29 @@ int main() {
}
}
printf
(
"
\n
All values are consistent
\n
"
);
printf
(
"
\n
All values are consistent
\n
"
);
/* Now test the long range function */
const
float
a_smooth
=
const_gravity_a_smooth
;
for
(
int
k
=
1
;
k
<
numPoints
;
++
k
)
{
const
float
r
=
(
r_max
*
k
)
/
numPoints
;
const
float
u
=
r
/
a_smooth
;
float
swift_w
;
kernel_long_grav_eval
(
u
,
&
swift_w
);
float
gadget_w
=
erfc
(
u
/
2
)
+
u
*
exp
(
-
u
*
u
/
4
)
/
sqrt
(
M_PI
);
printf
(
"%2d: r= %f r_lr= %f u= %f Ws(r)= %f Wg(r)= %f
\n
"
,
k
,
r
,
a_smooth
,
u
,
swift_w
,
gadget_w
);
if
(
fabsf
(
gadget_w
-
swift_w
)
>
2e-7
)
{
printf
(
"Invalid value ! Gadget= %e, SWIFT= %e
\n
"
,
gadget_w
,
swift_w
);
return
1
;
}
}
return
0
;
return
0
;
}
}
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