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
11a1982a
Unverified
Commit
11a1982a
authored
Apr 15, 2022
by
Peter Eastman
Committed by
GitHub
Apr 15, 2022
Browse files
Fixed inconsistency in computing kinetic energy (#3574)
parent
c8981916
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
platforms/cpu/src/CpuKernels.cpp
platforms/cpu/src/CpuKernels.cpp
+8
-6
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+3
-2
No files found.
platforms/cpu/src/CpuKernels.cpp
View file @
11a1982a
...
@@ -113,7 +113,7 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
...
@@ -113,7 +113,7 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
int
numParticles
=
context
.
getSystem
().
getNumParticles
();
int
numParticles
=
context
.
getSystem
().
getNumParticles
();
// Compute the shifted velocities.
// Compute the shifted velocities.
vector
<
Vec3
>
shiftedVel
(
numParticles
);
vector
<
Vec3
>
shiftedVel
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
if
(
masses
[
i
]
>
0
)
if
(
masses
[
i
]
>
0
)
...
@@ -123,11 +123,13 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
...
@@ -123,11 +123,13 @@ static double computeShiftedKineticEnergy(ContextImpl& context, vector<double>&
}
}
// Apply constraints to them.
// Apply constraints to them.
vector
<
double
>
inverseMasses
(
numParticles
);
if
(
timeShift
!=
0
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
vector
<
double
>
inverseMasses
(
numParticles
);
inverseMasses
[
i
]
=
(
masses
[
i
]
==
0
?
0
:
1
/
masses
[
i
]);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
extractConstraints
(
context
).
applyToVelocities
(
posData
,
shiftedVel
,
inverseMasses
,
1e-4
);
inverseMasses
[
i
]
=
(
masses
[
i
]
==
0
?
0
:
1
/
masses
[
i
]);
extractConstraints
(
context
).
applyToVelocities
(
posData
,
shiftedVel
,
inverseMasses
,
1e-4
);
}
// Compute the kinetic energy.
// Compute the kinetic energy.
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
11a1982a
...
@@ -262,8 +262,9 @@ void ReferenceUpdateStateDataKernel::computeShiftedVelocities(ContextImpl& conte
...
@@ -262,8 +262,9 @@ void ReferenceUpdateStateDataKernel::computeShiftedVelocities(ContextImpl& conte
}
}
// Apply constraints to them.
// Apply constraints to them.
extractConstraints
(
context
).
applyToVelocities
(
posData
,
velocities
,
inverseMasses
,
1e-4
);
if
(
timeShift
!=
0
)
extractConstraints
(
context
).
applyToVelocities
(
posData
,
velocities
,
inverseMasses
,
1e-4
);
}
}
void
ReferenceUpdateStateDataKernel
::
getForces
(
ContextImpl
&
context
,
std
::
vector
<
Vec3
>&
forces
)
{
void
ReferenceUpdateStateDataKernel
::
getForces
(
ContextImpl
&
context
,
std
::
vector
<
Vec3
>&
forces
)
{
...
...
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