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
7d4b549d
Commit
7d4b549d
authored
Mar 22, 2011
by
Peter Eastman
Browse files
Trying to use an Integrator for multiple Contexts produces an exception
parent
2b475dd3
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
75 additions
and
42 deletions
+75
-42
openmmapi/include/openmm/BrownianIntegrator.h
openmmapi/include/openmm/BrownianIntegrator.h
+1
-0
openmmapi/include/openmm/LangevinIntegrator.h
openmmapi/include/openmm/LangevinIntegrator.h
+1
-0
openmmapi/include/openmm/VariableLangevinIntegrator.h
openmmapi/include/openmm/VariableLangevinIntegrator.h
+1
-0
openmmapi/include/openmm/VariableVerletIntegrator.h
openmmapi/include/openmm/VariableVerletIntegrator.h
+1
-0
openmmapi/include/openmm/VerletIntegrator.h
openmmapi/include/openmm/VerletIntegrator.h
+1
-0
openmmapi/src/BrownianIntegrator.cpp
openmmapi/src/BrownianIntegrator.cpp
+5
-1
openmmapi/src/LangevinIntegrator.cpp
openmmapi/src/LangevinIntegrator.cpp
+5
-1
openmmapi/src/VariableLangevinIntegrator.cpp
openmmapi/src/VariableLangevinIntegrator.cpp
+5
-1
openmmapi/src/VariableVerletIntegrator.cpp
openmmapi/src/VariableVerletIntegrator.cpp
+5
-1
openmmapi/src/VerletIntegrator.cpp
openmmapi/src/VerletIntegrator.cpp
+5
-1
platforms/cuda/tests/TestCudaCustomAngleForce.cpp
platforms/cuda/tests/TestCudaCustomAngleForce.cpp
+4
-5
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
+4
-4
platforms/cuda/tests/TestCudaEwald.cpp
platforms/cuda/tests/TestCudaEwald.cpp
+4
-3
platforms/cuda/tests/TestCudaGBSAOBCForce.cpp
platforms/cuda/tests/TestCudaGBSAOBCForce.cpp
+4
-3
platforms/cuda/tests/TestCudaNonbondedForce.cpp
platforms/cuda/tests/TestCudaNonbondedForce.cpp
+6
-4
platforms/opencl/tests/TestOpenCLCustomAngleForce.cpp
platforms/opencl/tests/TestOpenCLCustomAngleForce.cpp
+2
-3
platforms/opencl/tests/TestOpenCLCustomHbondForce.cpp
platforms/opencl/tests/TestOpenCLCustomHbondForce.cpp
+2
-2
platforms/opencl/tests/TestOpenCLEwald.cpp
platforms/opencl/tests/TestOpenCLEwald.cpp
+8
-5
platforms/opencl/tests/TestOpenCLGBSAOBCForce.cpp
platforms/opencl/tests/TestOpenCLGBSAOBCForce.cpp
+4
-3
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
+7
-5
No files found.
openmmapi/include/openmm/BrownianIntegrator.h
View file @
7d4b549d
...
@@ -124,6 +124,7 @@ private:
...
@@ -124,6 +124,7 @@ private:
double
temperature
,
friction
;
double
temperature
,
friction
;
int
randomNumberSeed
;
int
randomNumberSeed
;
ContextImpl
*
context
;
ContextImpl
*
context
;
Context
*
owner
;
Kernel
kernel
;
Kernel
kernel
;
};
};
...
...
openmmapi/include/openmm/LangevinIntegrator.h
View file @
7d4b549d
...
@@ -124,6 +124,7 @@ private:
...
@@ -124,6 +124,7 @@ private:
double
temperature
,
friction
;
double
temperature
,
friction
;
int
randomNumberSeed
;
int
randomNumberSeed
;
ContextImpl
*
context
;
ContextImpl
*
context
;
Context
*
owner
;
Kernel
kernel
;
Kernel
kernel
;
};
};
...
...
openmmapi/include/openmm/VariableLangevinIntegrator.h
View file @
7d4b549d
...
@@ -155,6 +155,7 @@ private:
...
@@ -155,6 +155,7 @@ private:
double
temperature
,
friction
,
errorTol
;
double
temperature
,
friction
,
errorTol
;
int
randomNumberSeed
;
int
randomNumberSeed
;
ContextImpl
*
context
;
ContextImpl
*
context
;
Context
*
owner
;
Kernel
kernel
;
Kernel
kernel
;
};
};
...
...
openmmapi/include/openmm/VariableVerletIntegrator.h
View file @
7d4b549d
...
@@ -107,6 +107,7 @@ protected:
...
@@ -107,6 +107,7 @@ protected:
private:
private:
double
errorTol
;
double
errorTol
;
ContextImpl
*
context
;
ContextImpl
*
context
;
Context
*
owner
;
Kernel
kernel
;
Kernel
kernel
;
};
};
...
...
openmmapi/include/openmm/VerletIntegrator.h
View file @
7d4b549d
...
@@ -69,6 +69,7 @@ protected:
...
@@ -69,6 +69,7 @@ protected:
std
::
vector
<
std
::
string
>
getKernelNames
();
std
::
vector
<
std
::
string
>
getKernelNames
();
private:
private:
ContextImpl
*
context
;
ContextImpl
*
context
;
Context
*
owner
;
Kernel
kernel
;
Kernel
kernel
;
};
};
...
...
openmmapi/src/BrownianIntegrator.cpp
View file @
7d4b549d
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "openmm/BrownianIntegrator.h"
#include "openmm/BrownianIntegrator.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <ctime>
#include <ctime>
...
@@ -40,7 +41,7 @@ using namespace OpenMM;
...
@@ -40,7 +41,7 @@ using namespace OpenMM;
using
std
::
string
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
vector
;
BrownianIntegrator
::
BrownianIntegrator
(
double
temperature
,
double
frictionCoeff
,
double
stepSize
)
{
BrownianIntegrator
::
BrownianIntegrator
(
double
temperature
,
double
frictionCoeff
,
double
stepSize
)
:
owner
(
NULL
)
{
setTemperature
(
temperature
);
setTemperature
(
temperature
);
setFriction
(
frictionCoeff
);
setFriction
(
frictionCoeff
);
setStepSize
(
stepSize
);
setStepSize
(
stepSize
);
...
@@ -49,7 +50,10 @@ BrownianIntegrator::BrownianIntegrator(double temperature, double frictionCoeff,
...
@@ -49,7 +50,10 @@ BrownianIntegrator::BrownianIntegrator(double temperature, double frictionCoeff,
}
}
void
BrownianIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
void
BrownianIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
context
=
&
contextRef
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateBrownianStepKernel
::
Name
(),
contextRef
);
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateBrownianStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateBrownianStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
dynamic_cast
<
IntegrateBrownianStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
}
...
...
openmmapi/src/LangevinIntegrator.cpp
View file @
7d4b549d
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "openmm/LangevinIntegrator.h"
#include "openmm/LangevinIntegrator.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <ctime>
#include <ctime>
...
@@ -40,7 +41,7 @@ using namespace OpenMM;
...
@@ -40,7 +41,7 @@ using namespace OpenMM;
using
std
::
string
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
vector
;
LangevinIntegrator
::
LangevinIntegrator
(
double
temperature
,
double
frictionCoeff
,
double
stepSize
)
{
LangevinIntegrator
::
LangevinIntegrator
(
double
temperature
,
double
frictionCoeff
,
double
stepSize
)
:
owner
(
NULL
)
{
setTemperature
(
temperature
);
setTemperature
(
temperature
);
setFriction
(
frictionCoeff
);
setFriction
(
frictionCoeff
);
setStepSize
(
stepSize
);
setStepSize
(
stepSize
);
...
@@ -49,7 +50,10 @@ LangevinIntegrator::LangevinIntegrator(double temperature, double frictionCoeff,
...
@@ -49,7 +50,10 @@ LangevinIntegrator::LangevinIntegrator(double temperature, double frictionCoeff,
}
}
void
LangevinIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
void
LangevinIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
context
=
&
contextRef
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateLangevinStepKernel
::
Name
(),
contextRef
);
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateLangevinStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateLangevinStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
dynamic_cast
<
IntegrateLangevinStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
}
...
...
openmmapi/src/VariableLangevinIntegrator.cpp
View file @
7d4b549d
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/VariableLangevinIntegrator.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <limits>
#include <limits>
...
@@ -41,7 +42,7 @@ using namespace OpenMM;
...
@@ -41,7 +42,7 @@ using namespace OpenMM;
using
std
::
string
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
vector
;
VariableLangevinIntegrator
::
VariableLangevinIntegrator
(
double
temperature
,
double
frictionCoeff
,
double
errorTol
)
{
VariableLangevinIntegrator
::
VariableLangevinIntegrator
(
double
temperature
,
double
frictionCoeff
,
double
errorTol
)
:
owner
(
NULL
)
{
setTemperature
(
temperature
);
setTemperature
(
temperature
);
setFriction
(
frictionCoeff
);
setFriction
(
frictionCoeff
);
setErrorTolerance
(
errorTol
);
setErrorTolerance
(
errorTol
);
...
@@ -50,7 +51,10 @@ VariableLangevinIntegrator::VariableLangevinIntegrator(double temperature, doubl
...
@@ -50,7 +51,10 @@ VariableLangevinIntegrator::VariableLangevinIntegrator(double temperature, doubl
}
}
void
VariableLangevinIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
void
VariableLangevinIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
context
=
&
contextRef
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateVariableLangevinStepKernel
::
Name
(),
contextRef
);
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateVariableLangevinStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateVariableLangevinStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
dynamic_cast
<
IntegrateVariableLangevinStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
}
...
...
openmmapi/src/VariableVerletIntegrator.cpp
View file @
7d4b549d
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "openmm/VariableVerletIntegrator.h"
#include "openmm/VariableVerletIntegrator.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <limits>
#include <limits>
...
@@ -40,12 +41,15 @@ using namespace OpenMM;
...
@@ -40,12 +41,15 @@ using namespace OpenMM;
using
std
::
string
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
vector
;
VariableVerletIntegrator
::
VariableVerletIntegrator
(
double
errorTol
)
:
errorTol
(
errorTol
)
{
VariableVerletIntegrator
::
VariableVerletIntegrator
(
double
errorTol
)
:
errorTol
(
errorTol
)
,
owner
(
NULL
)
{
setConstraintTolerance
(
1e-4
);
setConstraintTolerance
(
1e-4
);
}
}
void
VariableVerletIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
void
VariableVerletIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
context
=
&
contextRef
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateVariableVerletStepKernel
::
Name
(),
contextRef
);
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateVariableVerletStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateVariableVerletStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
dynamic_cast
<
IntegrateVariableVerletStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
}
...
...
openmmapi/src/VerletIntegrator.cpp
View file @
7d4b549d
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "openmm/VerletIntegrator.h"
#include "openmm/VerletIntegrator.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include <string>
#include <string>
...
@@ -39,13 +40,16 @@ using namespace OpenMM;
...
@@ -39,13 +40,16 @@ using namespace OpenMM;
using
std
::
string
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
vector
;
VerletIntegrator
::
VerletIntegrator
(
double
stepSize
)
{
VerletIntegrator
::
VerletIntegrator
(
double
stepSize
)
:
owner
(
NULL
)
{
setStepSize
(
stepSize
);
setStepSize
(
stepSize
);
setConstraintTolerance
(
1e-4
);
setConstraintTolerance
(
1e-4
);
}
}
void
VerletIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
void
VerletIntegrator
::
initialize
(
ContextImpl
&
contextRef
)
{
if
(
owner
!=
NULL
&&
&
contextRef
.
getOwner
()
!=
owner
)
throw
OpenMMException
(
"This Integrator is already bound to a context"
);
context
=
&
contextRef
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateVerletStepKernel
::
Name
(),
contextRef
);
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateVerletStepKernel
::
Name
(),
contextRef
);
dynamic_cast
<
IntegrateVerletStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
dynamic_cast
<
IntegrateVerletStepKernel
&>
(
kernel
.
getImpl
()).
initialize
(
contextRef
.
getSystem
(),
*
this
);
}
}
...
...
platforms/cuda/tests/TestCudaCustomAngleForce.cpp
View file @
7d4b549d
...
@@ -79,7 +79,6 @@ void testAngles() {
...
@@ -79,7 +79,6 @@ void testAngles() {
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
HarmonicAngleForce
*
harmonic
=
new
HarmonicAngleForce
();
HarmonicAngleForce
*
harmonic
=
new
HarmonicAngleForce
();
harmonic
->
addAngle
(
0
,
1
,
2
,
1.5
,
0.8
);
harmonic
->
addAngle
(
0
,
1
,
2
,
1.5
,
0.8
);
harmonic
->
addAngle
(
1
,
2
,
3
,
2.0
,
0.5
);
harmonic
->
addAngle
(
1
,
2
,
3
,
2.0
,
0.5
);
...
@@ -91,22 +90,22 @@ void testAngles() {
...
@@ -91,22 +90,22 @@ void testAngles() {
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
4
);
vector
<
Vec3
>
positions
(
4
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
positions
[
j
]
=
Vec3
(
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
));
positions
[
j
]
=
Vec3
(
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
));
double
energy1
,
energy2
;
double
energy1
,
energy2
;
vector
<
Vec3
>
forces1
,
forces2
;
vector
<
Vec3
>
forces1
,
forces2
;
{
{
Context
c
(
customSystem
,
integrator1
,
platform
);
VerletIntegrator
integrator
(
0.01
);
Context
c
(
customSystem
,
integrator
,
platform
);
c
.
setPositions
(
positions
);
c
.
setPositions
(
positions
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
energy1
=
s
.
getPotentialEnergy
();
energy1
=
s
.
getPotentialEnergy
();
forces1
=
s
.
getForces
();
forces1
=
s
.
getForces
();
}
}
{
{
Context
c
(
harmonicSystem
,
integrator1
,
platform
);
VerletIntegrator
integrator
(
0.01
);
Context
c
(
harmonicSystem
,
integrator
,
platform
);
c
.
setPositions
(
positions
);
c
.
setPositions
(
positions
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
energy2
=
s
.
getPotentialEnergy
();
energy2
=
s
.
getPotentialEnergy
();
...
...
platforms/cuda/tests/TestCudaCustomTorsionForce.cpp
View file @
7d4b549d
...
@@ -96,22 +96,22 @@ void testTorsions() {
...
@@ -96,22 +96,22 @@ void testTorsions() {
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
5
);
vector
<
Vec3
>
positions
(
5
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
positions
[
j
]
=
Vec3
(
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
));
positions
[
j
]
=
Vec3
(
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
),
5.0
*
genrand_real2
(
sfmt
));
double
energy1
,
energy2
;
double
energy1
,
energy2
;
vector
<
Vec3
>
forces1
,
forces2
;
vector
<
Vec3
>
forces1
,
forces2
;
{
{
Context
c
(
customSystem
,
integrator1
,
platform
);
VerletIntegrator
integrator
(
0.01
);
Context
c
(
customSystem
,
integrator
,
platform
);
c
.
setPositions
(
positions
);
c
.
setPositions
(
positions
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
energy1
=
s
.
getPotentialEnergy
();
energy1
=
s
.
getPotentialEnergy
();
forces1
=
s
.
getForces
();
forces1
=
s
.
getForces
();
}
}
{
{
Context
c
(
harmonicSystem
,
integrator1
,
platform
);
VerletIntegrator
integrator
(
0.01
);
Context
c
(
harmonicSystem
,
integrator
,
platform
);
c
.
setPositions
(
positions
);
c
.
setPositions
(
positions
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s
=
c
.
getState
(
State
::
Forces
|
State
::
Energy
);
energy2
=
s
.
getPotentialEnergy
();
energy2
=
s
.
getPotentialEnergy
();
...
...
platforms/cuda/tests/TestCudaEwald.cpp
View file @
7d4b549d
...
@@ -65,7 +65,6 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -65,7 +65,6 @@ void testEwaldPME(bool includeExceptions) {
CudaPlatform
cuda
;
CudaPlatform
cuda
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
Ewald
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
Ewald
);
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
...
@@ -96,8 +95,10 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -96,8 +95,10 @@ void testEwaldPME(bool includeExceptions) {
// (1) Check whether the Reference and Cuda platforms agree when using Ewald Method
// (1) Check whether the Reference and Cuda platforms agree when using Ewald Method
Context
cudaContext
(
system
,
integrator
,
cuda
);
VerletIntegrator
integrator1
(
0.01
);
Context
referenceContext
(
system
,
integrator
,
reference
);
VerletIntegrator
integrator2
(
0.01
);
Context
cudaContext
(
system
,
integrator1
,
cuda
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
cudaContext
.
setPositions
(
positions
);
cudaContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
State
cudaState
=
cudaContext
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
cudaState
=
cudaContext
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
...
platforms/cuda/tests/TestCudaGBSAOBCForce.cpp
View file @
7d4b549d
...
@@ -136,7 +136,6 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
...
@@ -136,7 +136,6 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
CudaPlatform
cuda
;
CudaPlatform
cuda
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
();
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
...
@@ -156,8 +155,10 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
...
@@ -156,8 +155,10 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
}
}
system
.
addForce
(
gbsa
);
system
.
addForce
(
gbsa
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
Context
context
(
system
,
integrator
,
cuda
);
LangevinIntegrator
integrator1
(
0
,
0.1
,
0.01
);
Context
refContext
(
system
,
integrator
,
reference
);
LangevinIntegrator
integrator2
(
0
,
0.1
,
0.01
);
Context
context
(
system
,
integrator1
,
cuda
);
Context
refContext
(
system
,
integrator2
,
reference
);
// Set random (but uniformly distributed) positions for all the particles.
// Set random (but uniformly distributed) positions for all the particles.
...
...
platforms/cuda/tests/TestCudaNonbondedForce.cpp
View file @
7d4b549d
...
@@ -105,7 +105,6 @@ void testLJ() {
...
@@ -105,7 +105,6 @@ void testLJ() {
void
testExclusionsAnd14
()
{
void
testExclusionsAnd14
()
{
CudaPlatform
platform
;
CudaPlatform
platform
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -146,6 +145,7 @@ void testExclusionsAnd14() {
...
@@ -146,6 +145,7 @@ void testExclusionsAnd14() {
// The following is in its own block, because CUDA can't deal with multiple Contexts
// The following is in its own block, because CUDA can't deal with multiple Contexts
// existing on the same thread at the same time.
// existing on the same thread at the same time.
{
{
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -174,6 +174,7 @@ void testExclusionsAnd14() {
...
@@ -174,6 +174,7 @@ void testExclusionsAnd14() {
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -375,7 +376,6 @@ void testLargeSystem() {
...
@@ -375,7 +376,6 @@ void testLargeSystem() {
System
system
;
System
system
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
@@ -407,8 +407,10 @@ void testLargeSystem() {
...
@@ -407,8 +407,10 @@ void testLargeSystem() {
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
bonds
);
system
.
addForce
(
bonds
);
Context
cudaContext
(
system
,
integrator
,
cuda
);
VerletIntegrator
integrator1
(
0.01
);
Context
referenceContext
(
system
,
integrator
,
reference
);
VerletIntegrator
integrator2
(
0.01
);
Context
cudaContext
(
system
,
integrator1
,
cuda
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
cudaContext
.
setPositions
(
positions
);
cudaContext
.
setPositions
(
positions
);
cudaContext
.
setVelocities
(
velocities
);
cudaContext
.
setVelocities
(
velocities
);
referenceContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
...
...
platforms/opencl/tests/TestOpenCLCustomAngleForce.cpp
View file @
7d4b549d
...
@@ -79,7 +79,6 @@ void testAngles() {
...
@@ -79,7 +79,6 @@ void testAngles() {
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
harmonicSystem
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
HarmonicAngleForce
*
harmonic
=
new
HarmonicAngleForce
();
HarmonicAngleForce
*
harmonic
=
new
HarmonicAngleForce
();
harmonic
->
addAngle
(
0
,
1
,
2
,
1.5
,
0.8
);
harmonic
->
addAngle
(
0
,
1
,
2
,
1.5
,
0.8
);
harmonic
->
addAngle
(
1
,
2
,
3
,
2.0
,
0.5
);
harmonic
->
addAngle
(
1
,
2
,
3
,
2.0
,
0.5
);
...
@@ -91,9 +90,9 @@ void testAngles() {
...
@@ -91,9 +90,9 @@ void testAngles() {
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
4
);
vector
<
Vec3
>
positions
(
4
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c2
(
harmonicSystem
,
integrator2
,
platform
);
Context
c2
(
harmonicSystem
,
integrator2
,
platform
);
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
...
...
platforms/opencl/tests/TestOpenCLCustomHbondForce.cpp
View file @
7d4b549d
...
@@ -109,9 +109,9 @@ void testHbond() {
...
@@ -109,9 +109,9 @@ void testHbond() {
init_gen_rand
(
0
,
sfmt
);
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
5
);
vector
<
Vec3
>
positions
(
5
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c1
(
customSystem
,
integrator1
,
platform
);
Context
c2
(
standardSystem
,
integrator2
,
platform
);
Context
c2
(
standardSystem
,
integrator2
,
platform
);
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
for
(
int
j
=
0
;
j
<
(
int
)
positions
.
size
();
j
++
)
...
...
platforms/opencl/tests/TestOpenCLEwald.cpp
View file @
7d4b549d
...
@@ -64,7 +64,6 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -64,7 +64,6 @@ void testEwaldPME(bool includeExceptions) {
OpenCLPlatform
cl
;
OpenCLPlatform
cl
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
Ewald
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
Ewald
);
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
...
@@ -95,8 +94,10 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -95,8 +94,10 @@ void testEwaldPME(bool includeExceptions) {
// (1) Check whether the Reference and OpenCL platforms agree when using Ewald Method
// (1) Check whether the Reference and OpenCL platforms agree when using Ewald Method
Context
clContext
(
system
,
integrator
,
cl
);
VerletIntegrator
integrator1
(
0.01
);
Context
referenceContext
(
system
,
integrator
,
reference
);
VerletIntegrator
integrator2
(
0.01
);
Context
clContext
(
system
,
integrator1
,
cl
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
clContext
.
setPositions
(
positions
);
clContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
State
clState
=
clContext
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
clState
=
clContext
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -124,7 +125,8 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -124,7 +125,8 @@ void testEwaldPME(bool includeExceptions) {
Vec3
f
=
clState
.
getForces
()[
i
];
Vec3
f
=
clState
.
getForces
()[
i
];
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
}
}
Context
clContext2
(
system
,
integrator
,
cl
);
VerletIntegrator
integrator3
(
0.01
);
Context
clContext2
(
system
,
integrator3
,
cl
);
clContext2
.
setPositions
(
positions
);
clContext2
.
setPositions
(
positions
);
tol
=
1e-2
;
tol
=
1e-2
;
...
@@ -162,7 +164,8 @@ void testEwaldPME(bool includeExceptions) {
...
@@ -162,7 +164,8 @@ void testEwaldPME(bool includeExceptions) {
Vec3
f
=
clState
.
getForces
()[
i
];
Vec3
f
=
clState
.
getForces
()[
i
];
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
positions
[
i
]
=
Vec3
(
p
[
0
]
-
f
[
0
]
*
step
,
p
[
1
]
-
f
[
1
]
*
step
,
p
[
2
]
-
f
[
2
]
*
step
);
}
}
Context
clContext3
(
system
,
integrator
,
cl
);
VerletIntegrator
integrator4
(
0.01
);
Context
clContext3
(
system
,
integrator4
,
cl
);
clContext3
.
setPositions
(
positions
);
clContext3
.
setPositions
(
positions
);
tol
=
1e-2
;
tol
=
1e-2
;
...
...
platforms/opencl/tests/TestOpenCLGBSAOBCForce.cpp
View file @
7d4b549d
...
@@ -136,7 +136,6 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
...
@@ -136,7 +136,6 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
OpenCLPlatform
cl
;
OpenCLPlatform
cl
;
ReferencePlatform
reference
;
ReferencePlatform
reference
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
0
,
0.1
,
0.01
);
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
();
GBSAOBCForce
*
gbsa
=
new
GBSAOBCForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
{
...
@@ -156,8 +155,10 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
...
@@ -156,8 +155,10 @@ void testForce(int numParticles, NonbondedForce::NonbondedMethod method, GBSAOBC
}
}
system
.
addForce
(
gbsa
);
system
.
addForce
(
gbsa
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
Context
context
(
system
,
integrator
,
cl
);
LangevinIntegrator
integrator1
(
0
,
0.1
,
0.01
);
Context
refContext
(
system
,
integrator
,
reference
);
LangevinIntegrator
integrator2
(
0
,
0.1
,
0.01
);
Context
context
(
system
,
integrator1
,
cl
);
Context
refContext
(
system
,
integrator2
,
reference
);
// Set random (but uniformly distributed) positions for all the particles.
// Set random (but uniformly distributed) positions for all the particles.
...
...
platforms/opencl/tests/TestOpenCLNonbondedForce.cpp
View file @
7d4b549d
...
@@ -106,7 +106,6 @@ void testLJ() {
...
@@ -106,7 +106,6 @@ void testLJ() {
void
testExclusionsAnd14
()
{
void
testExclusionsAnd14
()
{
OpenCLPlatform
platform
;
OpenCLPlatform
platform
;
System
system
;
System
system
;
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
...
@@ -144,6 +143,7 @@ void testExclusionsAnd14() {
...
@@ -144,6 +143,7 @@ void testExclusionsAnd14() {
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
0
,
1.5
,
i
==
3
?
0.5
:
0.0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0.0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
positions
[
i
]
=
Vec3
(
r
,
0
,
0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
Context
context
(
system
,
integrator
,
platform
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
setPositions
(
positions
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
...
@@ -170,7 +170,8 @@ void testExclusionsAnd14() {
...
@@ -170,7 +170,8 @@ void testExclusionsAnd14() {
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setParticleParameters
(
i
,
2
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
first14
,
0
,
3
,
i
==
3
?
4
/
1.2
:
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
nonbonded
->
setExceptionParameters
(
second14
,
1
,
4
,
0
,
1.5
,
0
);
Context
context2
(
system
,
integrator
,
platform
);
LangevinIntegrator
integrator2
(
0.0
,
0.1
,
0.01
);
Context
context2
(
system
,
integrator2
,
platform
);
context2
.
setPositions
(
positions
);
context2
.
setPositions
(
positions
);
state
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
state
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces2
=
state
.
getForces
();
const
vector
<
Vec3
>&
forces2
=
state
.
getForces
();
...
@@ -370,7 +371,6 @@ void testLargeSystem() {
...
@@ -370,7 +371,6 @@ void testLargeSystem() {
System
system
;
System
system
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
0.01
);
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
vector
<
Vec3
>
positions
(
numParticles
);
vector
<
Vec3
>
positions
(
numParticles
);
...
@@ -402,8 +402,10 @@ void testLargeSystem() {
...
@@ -402,8 +402,10 @@ void testLargeSystem() {
nonbonded
->
setCutoffDistance
(
cutoff
);
nonbonded
->
setCutoffDistance
(
cutoff
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
nonbonded
);
system
.
addForce
(
bonds
);
system
.
addForce
(
bonds
);
Context
clContext
(
system
,
integrator
,
cl
);
VerletIntegrator
integrator1
(
0.01
);
Context
referenceContext
(
system
,
integrator
,
reference
);
VerletIntegrator
integrator2
(
0.01
);
Context
clContext
(
system
,
integrator1
,
cl
);
Context
referenceContext
(
system
,
integrator2
,
reference
);
clContext
.
setPositions
(
positions
);
clContext
.
setPositions
(
positions
);
clContext
.
setVelocities
(
velocities
);
clContext
.
setVelocities
(
velocities
);
referenceContext
.
setPositions
(
positions
);
referenceContext
.
setPositions
(
positions
);
...
...
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