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
047934e2
Commit
047934e2
authored
Mar 01, 2017
by
Rafal P. Wiewiora
Browse files
Merge remote-tracking branch 'upstream/master'
parents
ce3a5dc0
d12c9bd1
Changes
351
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
125 additions
and
69 deletions
+125
-69
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+21
-3
openmmapi/src/CustomAngleForceImpl.cpp
openmmapi/src/CustomAngleForceImpl.cpp
+1
-0
openmmapi/src/CustomBondForceImpl.cpp
openmmapi/src/CustomBondForceImpl.cpp
+1
-0
openmmapi/src/CustomCentroidBondForceImpl.cpp
openmmapi/src/CustomCentroidBondForceImpl.cpp
+1
-0
openmmapi/src/CustomCompoundBondForceImpl.cpp
openmmapi/src/CustomCompoundBondForceImpl.cpp
+1
-0
openmmapi/src/CustomExternalForceImpl.cpp
openmmapi/src/CustomExternalForceImpl.cpp
+1
-0
openmmapi/src/CustomGBForceImpl.cpp
openmmapi/src/CustomGBForceImpl.cpp
+1
-0
openmmapi/src/CustomHbondForceImpl.cpp
openmmapi/src/CustomHbondForceImpl.cpp
+1
-0
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+10
-1
openmmapi/src/CustomManyParticleForceImpl.cpp
openmmapi/src/CustomManyParticleForceImpl.cpp
+1
-0
openmmapi/src/CustomNonbondedForceImpl.cpp
openmmapi/src/CustomNonbondedForceImpl.cpp
+1
-0
openmmapi/src/CustomTorsionForceImpl.cpp
openmmapi/src/CustomTorsionForceImpl.cpp
+1
-0
openmmapi/src/GBSAOBCForceImpl.cpp
openmmapi/src/GBSAOBCForceImpl.cpp
+1
-0
openmmapi/src/GayBerneForceImpl.cpp
openmmapi/src/GayBerneForceImpl.cpp
+1
-0
openmmapi/src/HarmonicAngleForceImpl.cpp
openmmapi/src/HarmonicAngleForceImpl.cpp
+1
-0
openmmapi/src/HarmonicBondForceImpl.cpp
openmmapi/src/HarmonicBondForceImpl.cpp
+1
-0
openmmapi/src/LocalEnergyMinimizer.cpp
openmmapi/src/LocalEnergyMinimizer.cpp
+70
-64
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
+3
-0
openmmapi/src/MonteCarloBarostatImpl.cpp
openmmapi/src/MonteCarloBarostatImpl.cpp
+4
-1
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
+3
-0
No files found.
openmmapi/src/ContextImpl.cpp
View file @
047934e2
...
@@ -56,12 +56,13 @@ const static char CHECKPOINT_MAGIC_BYTES[] = "OpenMM Binary Checkpoint\n";
...
@@ -56,12 +56,13 @@ const static char CHECKPOINT_MAGIC_BYTES[] = "OpenMM Binary Checkpoint\n";
ContextImpl
::
ContextImpl
(
Context
&
owner
,
const
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
ContextImpl
::
ContextImpl
(
Context
&
owner
,
const
System
&
system
,
Integrator
&
integrator
,
Platform
*
platform
,
const
map
<
string
,
string
>&
properties
)
:
owner
(
owner
),
system
(
system
),
integrator
(
integrator
),
hasInitializedForces
(
false
),
hasSetPositions
(
false
),
integratorIsDeleted
(
false
),
owner
(
owner
),
system
(
system
),
integrator
(
integrator
),
hasInitializedForces
(
false
),
hasSetPositions
(
false
),
integratorIsDeleted
(
false
),
lastForceGroups
(
-
1
),
platform
(
platform
),
platformData
(
NULL
)
{
lastForceGroups
(
-
1
),
platform
(
platform
),
platformData
(
NULL
)
{
if
(
system
.
getNumParticles
()
==
0
)
int
numParticles
=
system
.
getNumParticles
();
if
(
numParticles
==
0
)
throw
OpenMMException
(
"Cannot create a Context for a System with no particles"
);
throw
OpenMMException
(
"Cannot create a Context for a System with no particles"
);
// Check for errors in virtual sites and massless particles.
// Check for errors in virtual sites and massless particles.
for
(
int
i
=
0
;
i
<
system
.
getN
umParticles
()
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
umParticles
;
i
++
)
{
if
(
system
.
isVirtualSite
(
i
))
{
if
(
system
.
isVirtualSite
(
i
))
{
if
(
system
.
getParticleMass
(
i
)
!=
0.0
)
if
(
system
.
getParticleMass
(
i
)
!=
0.0
)
throw
OpenMMException
(
"Virtual site has nonzero mass"
);
throw
OpenMMException
(
"Virtual site has nonzero mass"
);
...
@@ -71,14 +72,23 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
...
@@ -71,14 +72,23 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
throw
OpenMMException
(
"A virtual site cannot depend on another virtual site"
);
throw
OpenMMException
(
"A virtual site cannot depend on another virtual site"
);
}
}
}
}
set
<
pair
<
int
,
int
>
>
constraintAtoms
;
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
i
++
)
{
for
(
int
i
=
0
;
i
<
system
.
getNumConstraints
();
i
++
)
{
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
distance
;
double
distance
;
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
if
(
particle1
==
particle2
)
throw
OpenMMException
(
"A constraint cannot connect a particle to itself"
);
if
(
particle1
<
0
||
particle2
<
0
||
particle1
>=
numParticles
||
particle2
>=
numParticles
)
throw
OpenMMException
(
"Illegal particle index in constraint"
);
double
mass1
=
system
.
getParticleMass
(
particle1
);
double
mass1
=
system
.
getParticleMass
(
particle1
);
double
mass2
=
system
.
getParticleMass
(
particle2
);
double
mass2
=
system
.
getParticleMass
(
particle2
);
if
((
mass1
==
0.0
&&
mass2
!=
0.0
)
||
(
mass2
==
0.0
&&
mass1
!=
0.0
))
if
((
mass1
==
0.0
&&
mass2
!=
0.0
)
||
(
mass2
==
0.0
&&
mass1
!=
0.0
))
throw
OpenMMException
(
"A constraint cannot involve a massless particle"
);
throw
OpenMMException
(
"A constraint cannot involve a massless particle"
);
pair
<
int
,
int
>
atoms
=
make_pair
(
min
(
particle1
,
particle2
),
max
(
particle1
,
particle2
));
if
(
constraintAtoms
.
find
(
atoms
)
!=
constraintAtoms
.
end
())
throw
OpenMMException
(
"The System has two constraints between the same atoms. This will produce a singular constraint matrix."
);
constraintAtoms
.
insert
(
atoms
);
}
}
// Validate the list of properties.
// Validate the list of properties.
...
@@ -170,7 +180,7 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
...
@@ -170,7 +180,7 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
for
(
size_t
i
=
0
;
i
<
forceImpls
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
forceImpls
.
size
();
++
i
)
forceImpls
[
i
]
->
initialize
(
*
this
);
forceImpls
[
i
]
->
initialize
(
*
this
);
integrator
.
initialize
(
*
this
);
integrator
.
initialize
(
*
this
);
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
setVelocities
(
*
this
,
vector
<
Vec3
>
(
system
.
getN
umParticles
()
));
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
setVelocities
(
*
this
,
vector
<
Vec3
>
(
n
umParticles
));
}
}
ContextImpl
::~
ContextImpl
()
{
ContextImpl
::~
ContextImpl
()
{
...
@@ -259,10 +269,14 @@ void ContextImpl::setPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3
...
@@ -259,10 +269,14 @@ void ContextImpl::setPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3
}
}
void
ContextImpl
::
applyConstraints
(
double
tol
)
{
void
ContextImpl
::
applyConstraints
(
double
tol
)
{
if
(
!
hasSetPositions
)
throw
OpenMMException
(
"Particle positions have not been set"
);
applyConstraintsKernel
.
getAs
<
ApplyConstraintsKernel
>
().
apply
(
*
this
,
tol
);
applyConstraintsKernel
.
getAs
<
ApplyConstraintsKernel
>
().
apply
(
*
this
,
tol
);
}
}
void
ContextImpl
::
applyVelocityConstraints
(
double
tol
)
{
void
ContextImpl
::
applyVelocityConstraints
(
double
tol
)
{
if
(
!
hasSetPositions
)
throw
OpenMMException
(
"Particle positions have not been set"
);
applyConstraintsKernel
.
getAs
<
ApplyConstraintsKernel
>
().
applyToVelocities
(
*
this
,
tol
);
applyConstraintsKernel
.
getAs
<
ApplyConstraintsKernel
>
().
applyToVelocities
(
*
this
,
tol
);
}
}
...
@@ -460,3 +474,7 @@ void ContextImpl::loadCheckpoint(istream& stream) {
...
@@ -460,3 +474,7 @@ void ContextImpl::loadCheckpoint(istream& stream) {
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
loadCheckpoint
(
*
this
,
stream
);
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
loadCheckpoint
(
*
this
,
stream
);
hasSetPositions
=
true
;
hasSetPositions
=
true
;
}
}
void
ContextImpl
::
systemChanged
()
{
integrator
.
stateChanged
(
State
::
Energy
);
}
openmmapi/src/CustomAngleForceImpl.cpp
View file @
047934e2
...
@@ -108,4 +108,5 @@ map<string, double> CustomAngleForceImpl::getDefaultParameters() {
...
@@ -108,4 +108,5 @@ map<string, double> CustomAngleForceImpl::getDefaultParameters() {
void
CustomAngleForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomAngleForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomAngleForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomAngleForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/CustomBondForceImpl.cpp
View file @
047934e2
...
@@ -113,4 +113,5 @@ vector<pair<int, int> > CustomBondForceImpl::getBondedParticles() const {
...
@@ -113,4 +113,5 @@ vector<pair<int, int> > CustomBondForceImpl::getBondedParticles() const {
void
CustomBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/CustomCentroidBondForceImpl.cpp
View file @
047934e2
...
@@ -246,6 +246,7 @@ void CustomCentroidBondForceImpl::addBondsBetweenGroups(int group1, int group2,
...
@@ -246,6 +246,7 @@ void CustomCentroidBondForceImpl::addBondsBetweenGroups(int group1, int group2,
void
CustomCentroidBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomCentroidBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomCentroidBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomCentroidBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
void
CustomCentroidBondForceImpl
::
computeNormalizedWeights
(
const
CustomCentroidBondForce
&
force
,
const
System
&
system
,
vector
<
vector
<
double
>
>&
weights
)
{
void
CustomCentroidBondForceImpl
::
computeNormalizedWeights
(
const
CustomCentroidBondForce
&
force
,
const
System
&
system
,
vector
<
vector
<
double
>
>&
weights
)
{
...
...
openmmapi/src/CustomCompoundBondForceImpl.cpp
View file @
047934e2
...
@@ -208,4 +208,5 @@ ExpressionTreeNode CustomCompoundBondForceImpl::replaceFunctions(const Expressio
...
@@ -208,4 +208,5 @@ ExpressionTreeNode CustomCompoundBondForceImpl::replaceFunctions(const Expressio
void
CustomCompoundBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomCompoundBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomCompoundBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomCompoundBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/CustomExternalForceImpl.cpp
View file @
047934e2
...
@@ -97,4 +97,5 @@ map<string, double> CustomExternalForceImpl::getDefaultParameters() {
...
@@ -97,4 +97,5 @@ map<string, double> CustomExternalForceImpl::getDefaultParameters() {
void
CustomExternalForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomExternalForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomExternalForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomExternalForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/CustomGBForceImpl.cpp
View file @
047934e2
...
@@ -126,4 +126,5 @@ map<string, double> CustomGBForceImpl::getDefaultParameters() {
...
@@ -126,4 +126,5 @@ map<string, double> CustomGBForceImpl::getDefaultParameters() {
void
CustomGBForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomGBForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomGBForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomGBForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/CustomHbondForceImpl.cpp
View file @
047934e2
...
@@ -278,4 +278,5 @@ ExpressionTreeNode CustomHbondForceImpl::replaceFunctions(const ExpressionTreeNo
...
@@ -278,4 +278,5 @@ ExpressionTreeNode CustomHbondForceImpl::replaceFunctions(const ExpressionTreeNo
void
CustomHbondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomHbondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomHbondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomHbondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/CustomIntegrator.cpp
View file @
047934e2
...
@@ -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
4
Stanford University and the Authors. *
* Portions copyright (c) 2011-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -63,6 +63,15 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -63,6 +63,15 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
if
(
contextRef
.
getParameters
().
find
(
name
)
!=
contextRef
.
getParameters
().
end
())
if
(
contextRef
.
getParameters
().
find
(
name
)
!=
contextRef
.
getParameters
().
end
())
throw
OpenMMException
(
"The Integrator defines a variable with the same name as a Context parameter: "
+
name
);
throw
OpenMMException
(
"The Integrator defines a variable with the same name as a Context parameter: "
+
name
);
}
}
set
<
std
::
string
>
globalTargets
;
globalTargets
.
insert
(
globalNames
.
begin
(),
globalNames
.
end
());
globalTargets
.
insert
(
"dt"
);
for
(
map
<
string
,
double
>::
const_iterator
iter
=
contextRef
.
getParameters
().
begin
();
iter
!=
contextRef
.
getParameters
().
end
();
++
iter
)
globalTargets
.
insert
(
iter
->
first
);
for
(
int
i
=
0
;
i
<
computations
.
size
();
i
++
)
{
if
(
computations
[
i
].
type
==
ComputeGlobal
&&
globalTargets
.
find
(
computations
[
i
].
variable
)
==
globalTargets
.
end
())
throw
OpenMMException
(
"Unknown global variable: "
+
computations
[
i
].
variable
);
}
context
=
&
contextRef
;
context
=
&
contextRef
;
owner
=
&
contextRef
.
getOwner
();
owner
=
&
contextRef
.
getOwner
();
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateCustomStepKernel
::
Name
(),
contextRef
);
kernel
=
context
->
getPlatform
().
createKernel
(
IntegrateCustomStepKernel
::
Name
(),
contextRef
);
...
...
openmmapi/src/CustomManyParticleForceImpl.cpp
View file @
047934e2
...
@@ -240,6 +240,7 @@ ExpressionTreeNode CustomManyParticleForceImpl::replaceFunctions(const Expressio
...
@@ -240,6 +240,7 @@ ExpressionTreeNode CustomManyParticleForceImpl::replaceFunctions(const Expressio
void
CustomManyParticleForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomManyParticleForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomManyParticleForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomManyParticleForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
void
CustomManyParticleForceImpl
::
buildFilterArrays
(
const
CustomManyParticleForce
&
force
,
int
&
numTypes
,
vector
<
int
>&
particleTypes
,
vector
<
int
>&
orderIndex
,
vector
<
vector
<
int
>
>&
particleOrder
)
{
void
CustomManyParticleForceImpl
::
buildFilterArrays
(
const
CustomManyParticleForce
&
force
,
int
&
numTypes
,
vector
<
int
>&
particleTypes
,
vector
<
int
>&
orderIndex
,
vector
<
vector
<
int
>
>&
particleOrder
)
{
...
...
openmmapi/src/CustomNonbondedForceImpl.cpp
View file @
047934e2
...
@@ -155,6 +155,7 @@ map<string, double> CustomNonbondedForceImpl::getDefaultParameters() {
...
@@ -155,6 +155,7 @@ map<string, double> CustomNonbondedForceImpl::getDefaultParameters() {
void
CustomNonbondedForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomNonbondedForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomNonbondedForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomNonbondedForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
void
CustomNonbondedForceImpl
::
calcLongRangeCorrection
(
const
CustomNonbondedForce
&
force
,
const
Context
&
context
,
double
&
coefficient
,
vector
<
double
>&
derivatives
)
{
void
CustomNonbondedForceImpl
::
calcLongRangeCorrection
(
const
CustomNonbondedForce
&
force
,
const
Context
&
context
,
double
&
coefficient
,
vector
<
double
>&
derivatives
)
{
...
...
openmmapi/src/CustomTorsionForceImpl.cpp
View file @
047934e2
...
@@ -115,4 +115,5 @@ map<string, double> CustomTorsionForceImpl::getDefaultParameters() {
...
@@ -115,4 +115,5 @@ map<string, double> CustomTorsionForceImpl::getDefaultParameters() {
void
CustomTorsionForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
CustomTorsionForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcCustomTorsionForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcCustomTorsionForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/GBSAOBCForceImpl.cpp
View file @
047934e2
...
@@ -69,4 +69,5 @@ std::vector<std::string> GBSAOBCForceImpl::getKernelNames() {
...
@@ -69,4 +69,5 @@ std::vector<std::string> GBSAOBCForceImpl::getKernelNames() {
void
GBSAOBCForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
GBSAOBCForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcGBSAOBCForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcGBSAOBCForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/GayBerneForceImpl.cpp
View file @
047934e2
...
@@ -126,4 +126,5 @@ std::vector<std::string> GayBerneForceImpl::getKernelNames() {
...
@@ -126,4 +126,5 @@ std::vector<std::string> GayBerneForceImpl::getKernelNames() {
void
GayBerneForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
GayBerneForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcGayBerneForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcGayBerneForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/HarmonicAngleForceImpl.cpp
View file @
047934e2
...
@@ -63,4 +63,5 @@ std::vector<std::string> HarmonicAngleForceImpl::getKernelNames() {
...
@@ -63,4 +63,5 @@ std::vector<std::string> HarmonicAngleForceImpl::getKernelNames() {
void
HarmonicAngleForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
HarmonicAngleForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcHarmonicAngleForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcHarmonicAngleForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/HarmonicBondForceImpl.cpp
View file @
047934e2
...
@@ -73,4 +73,5 @@ vector<pair<int, int> > HarmonicBondForceImpl::getBondedParticles() const {
...
@@ -73,4 +73,5 @@ vector<pair<int, int> > HarmonicBondForceImpl::getBondedParticles() const {
void
HarmonicBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
void
HarmonicBondForceImpl
::
updateParametersInContext
(
ContextImpl
&
context
)
{
kernel
.
getAs
<
CalcHarmonicBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
kernel
.
getAs
<
CalcHarmonicBondForceKernel
>
().
copyParametersToContext
(
context
,
owner
);
context
.
systemChanged
();
}
}
openmmapi/src/LocalEnergyMinimizer.cpp
View file @
047934e2
...
@@ -105,12 +105,13 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
...
@@ -105,12 +105,13 @@ static lbfgsfloatval_t evaluate(void *instance, const lbfgsfloatval_t *x, lbfgsf
void
LocalEnergyMinimizer
::
minimize
(
Context
&
context
,
double
tolerance
,
int
maxIterations
)
{
void
LocalEnergyMinimizer
::
minimize
(
Context
&
context
,
double
tolerance
,
int
maxIterations
)
{
const
System
&
system
=
context
.
getSystem
();
const
System
&
system
=
context
.
getSystem
();
int
numParticles
=
system
.
getNumParticles
();
int
numParticles
=
system
.
getNumParticles
();
lbfgsfloatval_t
*
x
=
lbfgs_malloc
(
numParticles
*
3
);
if
(
x
==
NULL
)
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
constraintTol
=
context
.
getIntegrator
().
getConstraintTolerance
();
double
workingConstraintTol
=
std
::
max
(
1e-4
,
constraintTol
);
double
workingConstraintTol
=
std
::
max
(
1e-4
,
constraintTol
);
double
k
=
tolerance
/
workingConstraintTol
;
double
k
=
tolerance
/
workingConstraintTol
;
lbfgsfloatval_t
*
x
=
lbfgs_malloc
(
numParticles
*
3
);
if
(
x
==
NULL
)
throw
OpenMMException
(
"LocalEnergyMinimizer: Failed to allocate memory"
);
try
{
// Initialize the minimizer.
// Initialize the minimizer.
...
@@ -182,6 +183,11 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
...
@@ -182,6 +183,11 @@ void LocalEnergyMinimizer::minimize(Context& context, double tolerance, int maxI
}
}
}
}
}
}
}
catch
(...)
{
lbfgs_free
(
x
);
throw
;
}
lbfgs_free
(
x
);
lbfgs_free
(
x
);
// If necessary, do a final constraint projection to make sure they are satisfied
// If necessary, do a final constraint projection to make sure they are satisfied
...
...
openmmapi/src/MonteCarloAnisotropicBarostatImpl.cpp
View file @
047934e2
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "openmm/internal/OSRngSeed.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include "openmm/OpenMMException.h"
#include <cmath>
#include <cmath>
#include <vector>
#include <vector>
#include <algorithm>
#include <algorithm>
...
@@ -51,6 +52,8 @@ MonteCarloAnisotropicBarostatImpl::MonteCarloAnisotropicBarostatImpl(const Monte
...
@@ -51,6 +52,8 @@ MonteCarloAnisotropicBarostatImpl::MonteCarloAnisotropicBarostatImpl(const Monte
}
}
void
MonteCarloAnisotropicBarostatImpl
::
initialize
(
ContextImpl
&
context
)
{
void
MonteCarloAnisotropicBarostatImpl
::
initialize
(
ContextImpl
&
context
)
{
if
(
!
context
.
getSystem
().
usesPeriodicBoundaryConditions
())
throw
OpenMMException
(
"A barostat cannot be used with a non-periodic system"
);
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyMonteCarloBarostatKernel
::
Name
(),
context
);
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyMonteCarloBarostatKernel
::
Name
(),
context
);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
Vec3
box
[
3
];
Vec3
box
[
3
];
...
...
openmmapi/src/MonteCarloBarostatImpl.cpp
View file @
047934e2
...
@@ -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) 2010 Stanford University and the Authors.
*
* Portions copyright (c) 2010
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Authors: Peter Eastman *
* Contributors: *
* Contributors: *
* *
* *
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "openmm/internal/OSRngSeed.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include "openmm/OpenMMException.h"
#include <cmath>
#include <cmath>
#include <vector>
#include <vector>
#include <algorithm>
#include <algorithm>
...
@@ -51,6 +52,8 @@ MonteCarloBarostatImpl::MonteCarloBarostatImpl(const MonteCarloBarostat& owner)
...
@@ -51,6 +52,8 @@ MonteCarloBarostatImpl::MonteCarloBarostatImpl(const MonteCarloBarostat& owner)
}
}
void
MonteCarloBarostatImpl
::
initialize
(
ContextImpl
&
context
)
{
void
MonteCarloBarostatImpl
::
initialize
(
ContextImpl
&
context
)
{
if
(
!
context
.
getSystem
().
usesPeriodicBoundaryConditions
())
throw
OpenMMException
(
"A barostat cannot be used with a non-periodic system"
);
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyMonteCarloBarostatKernel
::
Name
(),
context
);
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyMonteCarloBarostatKernel
::
Name
(),
context
);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
Vec3
box
[
3
];
Vec3
box
[
3
];
...
...
openmmapi/src/MonteCarloMembraneBarostatImpl.cpp
View file @
047934e2
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
#include "openmm/internal/OSRngSeed.h"
#include "openmm/internal/OSRngSeed.h"
#include "openmm/Context.h"
#include "openmm/Context.h"
#include "openmm/kernels.h"
#include "openmm/kernels.h"
#include "openmm/OpenMMException.h"
#include <cmath>
#include <cmath>
#include <vector>
#include <vector>
#include <algorithm>
#include <algorithm>
...
@@ -51,6 +52,8 @@ MonteCarloMembraneBarostatImpl::MonteCarloMembraneBarostatImpl(const MonteCarloM
...
@@ -51,6 +52,8 @@ MonteCarloMembraneBarostatImpl::MonteCarloMembraneBarostatImpl(const MonteCarloM
}
}
void
MonteCarloMembraneBarostatImpl
::
initialize
(
ContextImpl
&
context
)
{
void
MonteCarloMembraneBarostatImpl
::
initialize
(
ContextImpl
&
context
)
{
if
(
!
context
.
getSystem
().
usesPeriodicBoundaryConditions
())
throw
OpenMMException
(
"A barostat cannot be used with a non-periodic system"
);
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyMonteCarloBarostatKernel
::
Name
(),
context
);
kernel
=
context
.
getPlatform
().
createKernel
(
ApplyMonteCarloBarostatKernel
::
Name
(),
context
);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
kernel
.
getAs
<
ApplyMonteCarloBarostatKernel
>
().
initialize
(
context
.
getSystem
(),
owner
);
Vec3
box
[
3
];
Vec3
box
[
3
];
...
...
Prev
1
2
3
4
5
6
7
…
18
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