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
1893e517
"wrappers/python/vscode:/vscode.git/clone" did not exist on "b7a24d6cf0304b32a7625ca665f49af71c6088ce"
Commit
1893e517
authored
Jun 11, 2014
by
peastman
Browse files
Fixed an error in the computation of Drude screening force
parent
774a257e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
13 deletions
+14
-13
plugins/drude/platforms/cuda/src/kernels/drudePairForce.cu
plugins/drude/platforms/cuda/src/kernels/drudePairForce.cu
+4
-4
plugins/drude/platforms/opencl/src/kernels/drudePairForce.cl
plugins/drude/platforms/opencl/src/kernels/drudePairForce.cl
+4
-4
plugins/drude/platforms/reference/src/ReferenceDrudeKernels.cpp
...s/drude/platforms/reference/src/ReferenceDrudeKernels.cpp
+5
-4
plugins/drude/platforms/reference/tests/TestReferenceDrudeForce.cpp
...ude/platforms/reference/tests/TestReferenceDrudeForce.cpp
+1
-1
No files found.
plugins/drude/platforms/cuda/src/kernels/drudePairForce.cu
View file @
1893e517
...
@@ -13,7 +13,7 @@ real u = drudeParams.x*r;
...
@@ -13,7 +13,7 @@ real u = drudeParams.x*r;
real
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
real
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
real
pairEnergy
=
drudeParams
.
y
*
screening
*
rInv
;
real
pairEnergy
=
drudeParams
.
y
*
screening
*
rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
real3
f
=
delta
*
(
pairEnergy
*
rInv
*
rInv
);
real3
f
=
delta
*
(
drudeParams
.
y
*
rInv
*
rInv
*
(
screening
*
rInv
-
0.5
f
*
(
1
+
u
)
*
EXP
(
-
u
)
*
drudeParams
.
x
)
);
force1
+=
f
;
force1
+=
f
;
force3
-=
f
;
force3
-=
f
;
...
@@ -26,7 +26,7 @@ u = drudeParams.x*r;
...
@@ -26,7 +26,7 @@ u = drudeParams.x*r;
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
pairEnergy
=
-
drudeParams
.
y
*
screening
*
rInv
;
pairEnergy
=
-
drudeParams
.
y
*
screening
*
rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
f
=
delta
*
(
pairEnergy
*
rInv
*
rInv
);
f
=
delta
*
(
-
drudeParams
.
y
*
rInv
*
rInv
*
(
screening
*
rInv
-
0.5
f
*
(
1
+
u
)
*
EXP
(
-
u
)
*
drudeParams
.
x
)
);
force1
+=
f
;
force1
+=
f
;
force4
-=
f
;
force4
-=
f
;
...
@@ -39,7 +39,7 @@ u = drudeParams.x*r;
...
@@ -39,7 +39,7 @@ u = drudeParams.x*r;
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
pairEnergy
=
-
drudeParams
.
y
*
screening
*
rInv
;
pairEnergy
=
-
drudeParams
.
y
*
screening
*
rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
f
=
delta
*
(
pairEnergy
*
rInv
*
rInv
);
f
=
delta
*
(
-
drudeParams
.
y
*
rInv
*
rInv
*
(
screening
*
rInv
-
0.5
f
*
(
1
+
u
)
*
EXP
(
-
u
)
*
drudeParams
.
x
)
);
force2
+=
f
;
force2
+=
f
;
force3
-=
f
;
force3
-=
f
;
...
@@ -52,6 +52,6 @@ u = drudeParams.x*r;
...
@@ -52,6 +52,6 @@ u = drudeParams.x*r;
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
screening
=
1
-
(
1
+
0.5
f
*
u
)
*
EXP
(
-
u
);
pairEnergy
=
drudeParams
.
y
*
screening
*
rInv
;
pairEnergy
=
drudeParams
.
y
*
screening
*
rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
f
=
delta
*
(
pairEnergy
*
rInv
*
rInv
);
f
=
delta
*
(
drudeParams
.
y
*
rInv
*
rInv
*
(
screening
*
rInv
-
0.5
f
*
(
1
+
u
)
*
EXP
(
-
u
)
*
drudeParams
.
x
)
);
force2
+=
f
;
force2
+=
f
;
force4
-=
f
;
force4
-=
f
;
plugins/drude/platforms/opencl/src/kernels/drudePairForce.cl
View file @
1893e517
...
@@ -13,7 +13,7 @@ real u = drudeParams.x*r;
...
@@ -13,7 +13,7 @@ real u = drudeParams.x*r;
real
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
real
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
real
pairEnergy
=
drudeParams.y*screening*rInv
;
real
pairEnergy
=
drudeParams.y*screening*rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
real4
f
=
delta*
(
pairEnergy*rInv*rInv
)
;
real4
f
=
delta*
(
drudeParams.y*rInv*rInv
)
*
(
screening*rInv-0.5f*
(
1+u
)
*EXP
(
-u
)
*drudeParams.x
)
;
force1
+=
f
;
force1
+=
f
;
force3
-=
f
;
force3
-=
f
;
...
@@ -26,7 +26,7 @@ u = drudeParams.x*r;
...
@@ -26,7 +26,7 @@ u = drudeParams.x*r;
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
pairEnergy
=
-drudeParams.y*screening*rInv
;
pairEnergy
=
-drudeParams.y*screening*rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
f
=
delta*
(
pairEnergy*rInv*rInv
)
;
f
=
delta*
(
-drudeParams.y*rInv*rInv
)
*
(
screening*rInv-0.5f*
(
1+u
)
*EXP
(
-u
)
*drudeParams.x
)
;
force1
+=
f
;
force1
+=
f
;
force4
-=
f
;
force4
-=
f
;
...
@@ -39,7 +39,7 @@ u = drudeParams.x*r;
...
@@ -39,7 +39,7 @@ u = drudeParams.x*r;
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
pairEnergy
=
-drudeParams.y*screening*rInv
;
pairEnergy
=
-drudeParams.y*screening*rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
f
=
delta*
(
pairEnergy*rInv*rInv
)
;
f
=
delta*
(
-drudeParams.y*rInv*rInv
)
*
(
screening*rInv-0.5f*
(
1+u
)
*EXP
(
-u
)
*drudeParams.x
)
;
force2
+=
f
;
force2
+=
f
;
force3
-=
f
;
force3
-=
f
;
...
@@ -52,6 +52,6 @@ u = drudeParams.x*r;
...
@@ -52,6 +52,6 @@ u = drudeParams.x*r;
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
screening
=
1-
(
1+0.5f*u
)
*EXP
(
-u
)
;
pairEnergy
=
drudeParams.y*screening*rInv
;
pairEnergy
=
drudeParams.y*screening*rInv
;
energy
+=
pairEnergy
;
energy
+=
pairEnergy
;
f
=
delta*
(
pairEnergy*rInv*rInv
)
;
f
=
delta*
(
drudeParams.y*rInv*rInv
)
*
(
screening*rInv-0.5f*
(
1+u
)
*EXP
(
-u
)
*drudeParams.x
)
;
force2
+=
f
;
force2
+=
f
;
force4
-=
f
;
force4
-=
f
;
plugins/drude/platforms/reference/src/ReferenceDrudeKernels.cpp
View file @
1893e517
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* *
* Portions copyright (c) 2011-201
3
Stanford University and the Authors. *
* Portions copyright (c) 2011-201
4
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -188,6 +188,7 @@ double ReferenceCalcDrudeForceKernel::execute(ContextImpl& context, bool include
...
@@ -188,6 +188,7 @@ double ReferenceCalcDrudeForceKernel::execute(ContextImpl& context, bool include
int
dipole2
=
pair2
[
i
];
int
dipole2
=
pair2
[
i
];
int
dipole1Particles
[]
=
{
particle
[
dipole1
],
particle1
[
dipole1
]};
int
dipole1Particles
[]
=
{
particle
[
dipole1
],
particle1
[
dipole1
]};
int
dipole2Particles
[]
=
{
particle
[
dipole2
],
particle1
[
dipole2
]};
int
dipole2Particles
[]
=
{
particle
[
dipole2
],
particle1
[
dipole2
]};
RealOpenMM
uscale
=
pairThole
[
i
]
/
pow
(
polarizability
[
dipole1
]
*
polarizability
[
dipole2
],
1.0
/
6.0
);
for
(
int
j
=
0
;
j
<
2
;
j
++
)
for
(
int
j
=
0
;
j
<
2
;
j
++
)
for
(
int
k
=
0
;
k
<
2
;
k
++
)
{
for
(
int
k
=
0
;
k
<
2
;
k
++
)
{
int
p1
=
dipole1Particles
[
j
];
int
p1
=
dipole1Particles
[
j
];
...
@@ -195,10 +196,10 @@ double ReferenceCalcDrudeForceKernel::execute(ContextImpl& context, bool include
...
@@ -195,10 +196,10 @@ double ReferenceCalcDrudeForceKernel::execute(ContextImpl& context, bool include
RealOpenMM
chargeProduct
=
charge
[
dipole1
]
*
charge
[
dipole2
]
*
(
j
==
k
?
1
:
-
1
);
RealOpenMM
chargeProduct
=
charge
[
dipole1
]
*
charge
[
dipole2
]
*
(
j
==
k
?
1
:
-
1
);
RealVec
delta
=
pos
[
p1
]
-
pos
[
p2
];
RealVec
delta
=
pos
[
p1
]
-
pos
[
p2
];
RealOpenMM
r
=
sqrt
(
delta
.
dot
(
delta
));
RealOpenMM
r
=
sqrt
(
delta
.
dot
(
delta
));
RealOpenMM
u
=
r
*
pairThole
[
i
]
/
pow
(
polarizability
[
dipole1
]
*
polarizability
[
dipole2
],
1.0
/
6.0
)
;
RealOpenMM
u
=
r
*
uscale
;
RealOpenMM
screening
=
1.0
-
(
1.0
+
0.5
*
u
)
*
exp
(
-
u
);
RealOpenMM
screening
=
1.0
-
(
1.0
+
0.5
*
u
)
*
exp
(
-
u
);
energy
+=
ONE_4PI_EPS0
*
chargeProduct
*
screening
/
r
;
energy
+=
ONE_4PI_EPS0
*
chargeProduct
*
screening
/
r
;
RealVec
f
=
delta
*
(
ONE_4PI_EPS0
*
chargeProduct
*
screening
/
(
r
*
r
*
r
)
);
RealVec
f
=
delta
*
(
ONE_4PI_EPS0
*
chargeProduct
/
(
r
*
r
))
*
(
screening
/
r
-
0.5
*
(
1
+
u
)
*
exp
(
-
u
)
*
uscale
);
force
[
p1
]
+=
f
;
force
[
p1
]
+=
f
;
force
[
p2
]
-=
f
;
force
[
p2
]
-=
f
;
}
}
...
@@ -461,4 +462,4 @@ void ReferenceIntegrateDrudeSCFStepKernel::minimize(ContextImpl& context, double
...
@@ -461,4 +462,4 @@ void ReferenceIntegrateDrudeSCFStepKernel::minimize(ContextImpl& context, double
lbfgsfloatval_t
fx
;
lbfgsfloatval_t
fx
;
MinimizerData
data
(
context
,
drudeParticles
);
MinimizerData
data
(
context
,
drudeParticles
);
lbfgs
(
numDrudeParticles
*
3
,
minimizerPos
,
&
fx
,
evaluate
,
NULL
,
&
data
,
&
minimizerParams
);
lbfgs
(
numDrudeParticles
*
3
,
minimizerPos
,
&
fx
,
evaluate
,
NULL
,
&
data
,
&
minimizerParams
);
}
}
\ No newline at end of file
plugins/drude/platforms/reference/tests/TestReferenceDrudeForce.cpp
View file @
1893e517
...
@@ -71,7 +71,7 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
...
@@ -71,7 +71,7 @@ void validateForce(System& system, vector<Vec3>& positions, double expectedEnerg
offsetPos
[
i
][
j
]
=
positions
[
i
][
j
]
+
offset
;
offsetPos
[
i
][
j
]
=
positions
[
i
][
j
]
+
offset
;
context
.
setPositions
(
offsetPos
);
context
.
setPositions
(
offsetPos
);
double
e2
=
context
.
getState
(
State
::
Energy
|
State
::
Forces
).
getPotentialEnergy
();
double
e2
=
context
.
getState
(
State
::
Energy
|
State
::
Forces
).
getPotentialEnergy
();
ASSERT_EQUAL_TOL
(
state
.
getForces
()[
i
][
j
],
(
e1
-
e2
)
/
(
2
*
offset
),
1e-
3
);
ASSERT_EQUAL_TOL
(
state
.
getForces
()[
i
][
j
],
(
e1
-
e2
)
/
(
2
*
offset
),
1e-
5
);
}
}
}
}
...
...
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