Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
N Body Simulation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Armin Damon Riess
N Body Simulation
Commits
3cb5b855
Commit
3cb5b855
authored
2 years ago
by
Armin Damon Riess
Browse files
Options
Downloads
Patches
Plain Diff
corrected tree code force: set to 0, use softening
parent
5527f5f8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/nBodySim.cpp
+5
-1
5 additions, 1 deletion
lib/nBodySim.cpp
lib/node.cpp
+7
-6
7 additions, 6 deletions
lib/node.cpp
lib/node.hpp
+1
-1
1 addition, 1 deletion
lib/node.hpp
with
13 additions
and
8 deletions
lib/nBodySim.cpp
+
5
−
1
View file @
3cb5b855
...
...
@@ -129,7 +129,11 @@ void nBodySim::updateForces() {
}
void
nBodySim
::
treeUpdateForces
()
{
// #pragma omp parallel for
#pragma omp parallel for
for
(
unsigned
i
=
0
;
i
<
3
*
nParticles_
;
++
i
)
{
forces_
[
i
]
=
0.0
;
}
#pragma omp parallel for
for
(
unsigned
i
=
0
;
i
<
nParticles_
;
++
i
)
{
tree_
->
updateForce
(
i
);
}
...
...
This diff is collapsed.
Click to expand it.
lib/node.cpp
+
7
−
6
View file @
3cb5b855
...
...
@@ -127,12 +127,12 @@ Vector Node::calculateForce(unsigned particle) {
dy
/=
r
;
dz
/=
r
;
double
m
=
mass_
;
double
factor
=
mass_
*
mass_
/
(
r2
+
softening_
*
softening_
)
;
// add the force from each particle in the child
force
[
0
]
+=
m
*
m
*
dx
/
(
r2
+
softening_
*
softening_
)
;
force
[
1
]
+=
m
*
m
*
dy
/
(
r2
+
softening_
*
softening_
)
;
force
[
2
]
+=
m
*
m
*
dz
/
(
r2
+
softening_
*
softening_
)
;
force
[
0
]
+=
factor
*
dx
;
force
[
1
]
+=
factor
*
dy
;
force
[
2
]
+=
factor
*
dz
;
}
// if the child exists, get the force from the child
}
else
{
...
...
@@ -148,10 +148,11 @@ Vector Node::calculateForce(unsigned particle) {
}
else
{
// calculate force from this node (from the center of mass)
double
r
3
=
lambda
*
lambda
*
lambda
;
double
r
2
=
lambda
*
lambda
;
for
(
unsigned
j
=
0
;
j
<
3
;
++
j
)
{
force
[
j
]
+=
totalMass_
*
(
centerOfMass_
[
j
]
-
positions_
[
3
*
particle
+
j
])
/
r3
;
double
factor
=
totalMass_
*
mass_
/
(
r2
+
softening_
*
softening_
);
force
[
j
]
+=
factor
*
(
centerOfMass_
[
j
]
-
positions_
[
3
*
particle
+
j
])
/
lambda
;
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/node.hpp
+
1
−
1
View file @
3cb5b855
...
...
@@ -51,7 +51,7 @@ private:
double
totalMass_
;
const
double
theta0_
=
0.4
;
const
double
minNParticles_
=
8
;
const
double
maxDepth_
=
24
;
const
double
maxDepth_
=
16
;
bool
isLeaf_
;
};
...
...
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