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
803faa81
Commit
803faa81
authored
Oct 01, 2013
by
peastman
Browse files
Ignore constraints that connect two massless particles (feature request 1915)
parent
578e25f9
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
16 deletions
+84
-16
platforms/reference/tests/TestReferenceVariableVerletIntegrator.cpp
...reference/tests/TestReferenceVariableVerletIntegrator.cpp
+33
-0
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
+33
-0
plugins/drude/platforms/reference/src/ReferenceDrudeKernels.cpp
...s/drude/platforms/reference/src/ReferenceDrudeKernels.cpp
+18
-16
No files found.
platforms/reference/tests/TestReferenceVariableVerletIntegrator.cpp
View file @
803faa81
...
@@ -210,6 +210,38 @@ void testConstrainedClusters() {
...
@@ -210,6 +210,38 @@ void testConstrainedClusters() {
ASSERT
(
context
.
getState
(
State
::
Positions
).
getTime
()
>
0.1
);
ASSERT
(
context
.
getState
(
State
::
Positions
).
getTime
()
>
0.1
);
}
}
void
testConstrainedMasslessParticles
()
{
ReferencePlatform
platform
;
System
system
;
system
.
addParticle
(
0.0
);
system
.
addParticle
(
1.0
);
system
.
addConstraint
(
0
,
1
,
1.5
);
vector
<
Vec3
>
positions
(
2
);
positions
[
0
]
=
Vec3
(
-
1
,
0
,
0
);
positions
[
1
]
=
Vec3
(
1
,
0
,
0
);
VariableVerletIntegrator
integrator
(
0.01
);
bool
failed
=
false
;
try
{
// This should throw an exception.
Context
context
(
system
,
integrator
,
platform
);
}
catch
(
exception
&
ex
)
{
failed
=
true
;
}
ASSERT
(
failed
);
// Now make both particles massless, which should work.
system
.
setParticleMass
(
1
,
0.0
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
300.0
);
integrator
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Velocities
|
State
::
Positions
);
ASSERT_EQUAL
(
0.0
,
state
.
getVelocities
()[
0
][
0
]);
}
void
testArgonBox
()
{
void
testArgonBox
()
{
const
int
gridSize
=
8
;
const
int
gridSize
=
8
;
const
double
mass
=
40.0
;
// Ar atomic mass
const
double
mass
=
40.0
;
// Ar atomic mass
...
@@ -272,6 +304,7 @@ int main() {
...
@@ -272,6 +304,7 @@ int main() {
testSingleBond
();
testSingleBond
();
testConstraints
();
testConstraints
();
testConstrainedClusters
();
testConstrainedClusters
();
testConstrainedMasslessParticles
();
testArgonBox
();
testArgonBox
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
...
...
platforms/reference/tests/TestReferenceVerletIntegrator.cpp
View file @
803faa81
...
@@ -200,11 +200,44 @@ void testConstrainedClusters() {
...
@@ -200,11 +200,44 @@ void testConstrainedClusters() {
}
}
}
}
void
testConstrainedMasslessParticles
()
{
ReferencePlatform
platform
;
System
system
;
system
.
addParticle
(
0.0
);
system
.
addParticle
(
1.0
);
system
.
addConstraint
(
0
,
1
,
1.5
);
vector
<
Vec3
>
positions
(
2
);
positions
[
0
]
=
Vec3
(
-
1
,
0
,
0
);
positions
[
1
]
=
Vec3
(
1
,
0
,
0
);
VerletIntegrator
integrator
(
0.01
);
bool
failed
=
false
;
try
{
// This should throw an exception.
Context
context
(
system
,
integrator
,
platform
);
}
catch
(
exception
&
ex
)
{
failed
=
true
;
}
ASSERT
(
failed
);
// Now make both particles massless, which should work.
system
.
setParticleMass
(
1
,
0.0
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setVelocitiesToTemperature
(
300.0
);
integrator
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Velocities
|
State
::
Positions
);
ASSERT_EQUAL
(
0.0
,
state
.
getVelocities
()[
0
][
0
]);
}
int
main
()
{
int
main
()
{
try
{
try
{
testSingleBond
();
testSingleBond
();
testConstraints
();
testConstraints
();
testConstrainedClusters
();
testConstrainedClusters
();
testConstrainedMasslessParticles
();
}
}
catch
(
const
exception
&
e
)
{
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
...
...
plugins/drude/platforms/reference/src/ReferenceDrudeKernels.cpp
View file @
803faa81
...
@@ -271,18 +271,19 @@ void ReferenceIntegrateDrudeLangevinStepKernel::initialize(const System& system,
...
@@ -271,18 +271,19 @@ void ReferenceIntegrateDrudeLangevinStepKernel::initialize(const System& system,
// Prepare constraints.
// Prepare constraints.
int
numConstraints
=
system
.
getNumConstraints
();
if
(
system
.
getNumConstraints
()
>
0
)
{
if
(
numConstraints
>
0
)
{
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
pair
<
int
,
int
>
>
constraintIndices
(
numConstraints
);
vector
<
RealOpenMM
>
constraintDistances
;
vector
<
RealOpenMM
>
constraintDistances
(
numConstraints
);
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
for
(
int
i
=
0
;
i
<
numConstraints
;
++
i
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
distance
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
constraintIndices
[
i
].
first
=
particle1
;
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
[
i
].
second
=
particle2
;
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
[
i
]
=
static_cast
<
RealOpenMM
>
(
distance
);
constraintDistances
.
push_back
(
distance
);
}
}
}
int
numConstraints
=
constraintIndices
.
size
();
vector
<
ReferenceCCMAAlgorithm
::
AngleInfo
>
angles
;
vector
<
ReferenceCCMAAlgorithm
::
AngleInfo
>
angles
;
findAnglesForCCMA
(
system
,
angles
);
findAnglesForCCMA
(
system
,
angles
);
constraints
=
new
ReferenceCCMAAlgorithm
(
system
.
getNumParticles
(),
numConstraints
,
constraintIndices
,
constraintDistances
,
particleMass
,
angles
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
constraints
=
new
ReferenceCCMAAlgorithm
(
system
.
getNumParticles
(),
numConstraints
,
constraintIndices
,
constraintDistances
,
particleMass
,
angles
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
...
@@ -395,18 +396,19 @@ void ReferenceIntegrateDrudeSCFStepKernel::initialize(const System& system, cons
...
@@ -395,18 +396,19 @@ void ReferenceIntegrateDrudeSCFStepKernel::initialize(const System& system, cons
// Prepare constraints.
// Prepare constraints.
int
numConstraints
=
system
.
getNumConstraints
();
if
(
system
.
getNumConstraints
()
>
0
)
{
if
(
numConstraints
>
0
)
{
vector
<
pair
<
int
,
int
>
>
constraintIndices
;
vector
<
pair
<
int
,
int
>
>
constraintIndices
(
numConstraints
);
vector
<
RealOpenMM
>
constraintDistances
;
vector
<
RealOpenMM
>
constraintDistances
(
numConstraints
);
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
++
i
)
{
for
(
int
i
=
0
;
i
<
numConstraints
;
++
i
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
distance
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
constraintIndices
[
i
].
first
=
particle1
;
if
(
system
.
getParticleMass
(
particle1
)
!=
0
||
system
.
getParticleMass
(
particle2
)
!=
0
)
{
constraintIndices
[
i
].
second
=
particle2
;
constraintIndices
.
push_back
(
make_pair
(
particle1
,
particle2
));
constraintDistances
[
i
]
=
static_cast
<
RealOpenMM
>
(
distance
);
constraintDistances
.
push_back
(
distance
);
}
}
}
int
numConstraints
=
constraintIndices
.
size
();
vector
<
ReferenceCCMAAlgorithm
::
AngleInfo
>
angles
;
vector
<
ReferenceCCMAAlgorithm
::
AngleInfo
>
angles
;
findAnglesForCCMA
(
system
,
angles
);
findAnglesForCCMA
(
system
,
angles
);
constraints
=
new
ReferenceCCMAAlgorithm
(
system
.
getNumParticles
(),
numConstraints
,
constraintIndices
,
constraintDistances
,
particleMass
,
angles
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
constraints
=
new
ReferenceCCMAAlgorithm
(
system
.
getNumParticles
(),
numConstraints
,
constraintIndices
,
constraintDistances
,
particleMass
,
angles
,
(
RealOpenMM
)
integrator
.
getConstraintTolerance
());
...
...
Prev
1
2
Next
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