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
26c51a0c
Commit
26c51a0c
authored
Aug 16, 2013
by
peastman
Browse files
Fixed numeric problems using PME with Drude particles
parent
f4f5b568
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
platforms/cuda/src/CudaContext.cpp
platforms/cuda/src/CudaContext.cpp
+2
-0
platforms/cuda/src/kernels/coulombLennardJones.cu
platforms/cuda/src/kernels/coulombLennardJones.cu
+3
-2
platforms/opencl/src/kernels/coulombLennardJones.cl
platforms/opencl/src/kernels/coulombLennardJones.cl
+3
-2
No files found.
platforms/cuda/src/CudaContext.cpp
View file @
26c51a0c
...
@@ -224,6 +224,8 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
...
@@ -224,6 +224,8 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
compilationDefines
[
"ACOS"
]
=
useDoublePrecision
?
"acos"
:
"acosf"
;
compilationDefines
[
"ACOS"
]
=
useDoublePrecision
?
"acos"
:
"acosf"
;
compilationDefines
[
"ASIN"
]
=
useDoublePrecision
?
"asin"
:
"asinf"
;
compilationDefines
[
"ASIN"
]
=
useDoublePrecision
?
"asin"
:
"asinf"
;
compilationDefines
[
"ATAN"
]
=
useDoublePrecision
?
"atan"
:
"atanf"
;
compilationDefines
[
"ATAN"
]
=
useDoublePrecision
?
"atan"
:
"atanf"
;
compilationDefines
[
"ERF"
]
=
useDoublePrecision
?
"erf"
:
"erff"
;
compilationDefines
[
"ERFC"
]
=
useDoublePrecision
?
"erfc"
:
"erfcf"
;
// Create the work thread used for parallelization when running on multiple devices.
// Create the work thread used for parallelization when running on multiple devices.
...
...
platforms/cuda/src/kernels/coulombLennardJones.cu
View file @
26c51a0c
...
@@ -23,8 +23,9 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) {
...
@@ -23,8 +23,9 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) {
// Subtract off the part of this interaction that was included in the reciprocal space contribution.
// Subtract off the part of this interaction that was included in the reciprocal space contribution.
if
(
1
-
erfcAlphaR
>
1e-6
)
{
if
(
1
-
erfcAlphaR
>
1e-6
)
{
tempForce
=
-
prefactor
*
((
1.0
f
-
erfcAlphaR
)
-
alphaR
*
expAlphaRSqr
*
TWO_OVER_SQRT_PI
);
real
erfAlphaR
=
ERF
(
alphaR
);
// Our erfc approximation is not accurate enough when r is very small, which happens with Drude particles.
tempEnergy
+=
-
prefactor
*
(
1.0
f
-
erfcAlphaR
);
tempForce
=
-
prefactor
*
(
erfAlphaR
-
alphaR
*
expAlphaRSqr
*
TWO_OVER_SQRT_PI
);
tempEnergy
+=
-
prefactor
*
erfAlphaR
;
}
}
}
}
else
{
else
{
...
...
platforms/opencl/src/kernels/coulombLennardJones.cl
View file @
26c51a0c
...
@@ -23,8 +23,9 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) {
...
@@ -23,8 +23,9 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) {
//
Subtract
off
the
part
of
this
interaction
that
was
included
in
the
reciprocal
space
contribution.
//
Subtract
off
the
part
of
this
interaction
that
was
included
in
the
reciprocal
space
contribution.
if
(
1-erfcAlphaR
>
1e-6
)
{
if
(
1-erfcAlphaR
>
1e-6
)
{
tempForce
=
-prefactor*
((
1.0f-erfcAlphaR
)
-alphaR*expAlphaRSqr*TWO_OVER_SQRT_PI
)
;
real
erfAlphaR
=
erf
(
alphaR
)
; // Our erfc approximation is not accurate enough when r is very small, which happens with Drude particles.
tempEnergy
+=
-prefactor*
(
1.0f-erfcAlphaR
)
;
tempForce
=
-prefactor*
(
erfAlphaR-alphaR*expAlphaRSqr*TWO_OVER_SQRT_PI
)
;
tempEnergy
+=
-prefactor*erfAlphaR
;
}
}
}
}
else
{
else
{
...
...
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