Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
2855d12e
Commit
2855d12e
authored
Jan 24, 2018
by
Peter Eastman
Browse files
More robust against numerical error
parent
f6a8d1ea
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
platforms/opencl/src/OpenCLKernels.cpp
platforms/opencl/src/OpenCLKernels.cpp
+5
-1
platforms/reference/src/SimTKReference/ReferenceRMSDForce.cpp
...forms/reference/src/SimTKReference/ReferenceRMSDForce.cpp
+5
-1
No files found.
platforms/opencl/src/OpenCLKernels.cpp
View file @
2855d12e
...
@@ -7207,7 +7207,11 @@ double OpenCLCalcRMSDForceKernel::executeImpl(ContextImpl& context) {
...
@@ -7207,7 +7207,11 @@ double OpenCLCalcRMSDForceKernel::executeImpl(ContextImpl& context) {
// Compute the RMSD.
// Compute the RMSD.
double msd = (sumNormRef+b[9]-2*values[3])/numParticles;
double msd = (sumNormRef+b[9]-2*values[3])/numParticles;
msd = max(0.0, msd); // Protect against numerical error when the particles are perfectly aligned.
if (msd < 1e-20) {
// The particles are perfectly aligned, so all the forces should be zero.
// Numerical error can lead to NaNs, so just return 0 now.
return 0.0;
}
double rmsd = sqrt(msd);
double rmsd = sqrt(msd);
b[9] = rmsd;
b[9] = rmsd;
...
...
platforms/reference/src/SimTKReference/ReferenceRMSDForce.cpp
View file @
2855d12e
...
@@ -97,7 +97,11 @@ double ReferenceRMSDForce::calculateIxn(vector<Vec3>& atomCoordinates, vector<Ve
...
@@ -97,7 +97,11 @@ double ReferenceRMSDForce::calculateIxn(vector<Vec3>& atomCoordinates, vector<Ve
sum
+=
positions
[
i
].
dot
(
positions
[
i
])
+
referencePos
[
index
].
dot
(
referencePos
[
index
]);
sum
+=
positions
[
i
].
dot
(
positions
[
i
])
+
referencePos
[
index
].
dot
(
referencePos
[
index
]);
}
}
double
msd
=
(
sum
-
2
*
values
[
3
])
/
numParticles
;
double
msd
=
(
sum
-
2
*
values
[
3
])
/
numParticles
;
msd
=
max
(
0.0
,
msd
);
// Protect against numerical error when the particles are perfectly aligned.
if
(
msd
<
1e-20
)
{
// The particles are perfectly aligned, so all the forces should be zero.
// Numerical error can lead to NaNs, so just return 0 now.
return
0.0
;
}
double
rmsd
=
sqrt
(
msd
);
double
rmsd
=
sqrt
(
msd
);
// Compute the rotation matrix.
// Compute the rotation matrix.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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