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
08e8b206
Commit
08e8b206
authored
Mar 31, 2017
by
peastman
Committed by
GitHub
Mar 31, 2017
Browse files
Merge pull request #1769 from peastman/loops
Use C++11 style loops
parents
55ee0b9f
083bc501
Changes
96
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
145 additions
and
156 deletions
+145
-156
olla/src/Platform.cpp
olla/src/Platform.cpp
+19
-19
openmmapi/src/AndersenThermostatImpl.cpp
openmmapi/src/AndersenThermostatImpl.cpp
+3
-3
openmmapi/src/CompiledExpressionSet.cpp
openmmapi/src/CompiledExpressionSet.cpp
+5
-5
openmmapi/src/Context.cpp
openmmapi/src/Context.cpp
+10
-12
openmmapi/src/ContextImpl.cpp
openmmapi/src/ContextImpl.cpp
+20
-20
openmmapi/src/CustomCentroidBondForce.cpp
openmmapi/src/CustomCentroidBondForce.cpp
+2
-2
openmmapi/src/CustomCentroidBondForceImpl.cpp
openmmapi/src/CustomCentroidBondForceImpl.cpp
+8
-8
openmmapi/src/CustomCompoundBondForce.cpp
openmmapi/src/CustomCompoundBondForce.cpp
+2
-2
openmmapi/src/CustomCompoundBondForceImpl.cpp
openmmapi/src/CustomCompoundBondForceImpl.cpp
+5
-5
openmmapi/src/CustomGBForce.cpp
openmmapi/src/CustomGBForce.cpp
+2
-2
openmmapi/src/CustomHbondForce.cpp
openmmapi/src/CustomHbondForce.cpp
+2
-2
openmmapi/src/CustomHbondForceImpl.cpp
openmmapi/src/CustomHbondForceImpl.cpp
+2
-2
openmmapi/src/CustomIntegrator.cpp
openmmapi/src/CustomIntegrator.cpp
+3
-4
openmmapi/src/CustomIntegratorUtilities.cpp
openmmapi/src/CustomIntegratorUtilities.cpp
+7
-12
openmmapi/src/CustomManyParticleForce.cpp
openmmapi/src/CustomManyParticleForce.cpp
+11
-12
openmmapi/src/CustomManyParticleForceImpl.cpp
openmmapi/src/CustomManyParticleForceImpl.cpp
+5
-5
openmmapi/src/CustomNonbondedForce.cpp
openmmapi/src/CustomNonbondedForce.cpp
+13
-14
openmmapi/src/Force.cpp
openmmapi/src/Force.cpp
+6
-8
openmmapi/src/NonbondedForce.cpp
openmmapi/src/NonbondedForce.cpp
+16
-15
openmmapi/src/System.cpp
openmmapi/src/System.cpp
+4
-4
No files found.
olla/src/Platform.cpp
View file @
08e8b206
...
@@ -70,10 +70,10 @@ static int platformInitializer = registerPlatforms();
...
@@ -70,10 +70,10 @@ static int platformInitializer = registerPlatforms();
Platform
::~
Platform
()
{
Platform
::~
Platform
()
{
set
<
KernelFactory
*>
uniqueKernelFactories
;
set
<
KernelFactory
*>
uniqueKernelFactories
;
for
(
map
<
string
,
KernelFactory
*>::
const_iterator
iter
=
kernelFactories
.
begin
();
iter
!=
kernelFactories
.
end
();
++
iter
)
for
(
auto
&
factory
:
kernelFactories
)
uniqueKernelFactories
.
insert
(
iter
->
second
);
uniqueKernelFactories
.
insert
(
factory
.
second
);
for
(
set
<
KernelFactory
*>::
const_iterator
iter
=
uniqueKernelFactories
.
begin
();
iter
!=
uniqueKernelFactories
.
end
();
++
iter
)
for
(
auto
factory
:
uniqueKernelFactories
)
delete
*
iter
;
delete
factory
;
}
}
const
vector
<
string
>&
Platform
::
getPropertyNames
()
const
{
const
vector
<
string
>&
Platform
::
getPropertyNames
()
const
{
...
@@ -102,8 +102,8 @@ void Platform::setPropertyDefaultValue(const string& property, const string& val
...
@@ -102,8 +102,8 @@ void Platform::setPropertyDefaultValue(const string& property, const string& val
string
propertyName
=
property
;
string
propertyName
=
property
;
if
(
deprecatedPropertyReplacements
.
find
(
property
)
!=
deprecatedPropertyReplacements
.
end
())
if
(
deprecatedPropertyReplacements
.
find
(
property
)
!=
deprecatedPropertyReplacements
.
end
())
propertyName
=
deprecatedPropertyReplacements
.
find
(
property
)
->
second
;
propertyName
=
deprecatedPropertyReplacements
.
find
(
property
)
->
second
;
for
(
int
i
=
0
;
i
<
(
int
)
platformProperties
.
size
();
i
++
)
for
(
auto
&
prop
:
platformProperties
)
if
(
p
latformProperties
[
i
]
==
propertyName
)
{
if
(
p
rop
==
propertyName
)
{
defaultProperties
[
propertyName
]
=
value
;
defaultProperties
[
propertyName
]
=
value
;
return
;
return
;
}
}
...
@@ -121,8 +121,8 @@ void Platform::registerKernelFactory(const string& name, KernelFactory* factory)
...
@@ -121,8 +121,8 @@ void Platform::registerKernelFactory(const string& name, KernelFactory* factory)
}
}
bool
Platform
::
supportsKernels
(
const
vector
<
string
>&
kernelNames
)
const
{
bool
Platform
::
supportsKernels
(
const
vector
<
string
>&
kernelNames
)
const
{
for
(
int
i
=
0
;
i
<
(
int
)
kernelNames
.
size
();
++
i
)
for
(
auto
&
name
:
kernelNames
)
if
(
kernelFactories
.
find
(
kernelNames
[
i
]
)
==
kernelFactories
.
end
())
if
(
kernelFactories
.
find
(
name
)
==
kernelFactories
.
end
())
return
false
;
return
false
;
return
true
;
return
true
;
}
}
...
@@ -167,9 +167,9 @@ Platform& Platform::findPlatform(const vector<string>& kernelNames) {
...
@@ -167,9 +167,9 @@ Platform& Platform::findPlatform(const vector<string>& kernelNames) {
Platform
*
best
=
0
;
Platform
*
best
=
0
;
vector
<
Platform
*>&
platforms
=
getPlatforms
();
vector
<
Platform
*>&
platforms
=
getPlatforms
();
double
speed
=
0.0
;
double
speed
=
0.0
;
for
(
int
i
=
0
;
i
<
(
int
)
platforms
.
size
();
++
i
)
{
for
(
auto
platform
:
platforms
)
{
if
(
platform
s
[
i
]
->
supportsKernels
(
kernelNames
)
&&
platform
s
[
i
]
->
getSpeed
()
>
speed
)
{
if
(
platform
->
supportsKernels
(
kernelNames
)
&&
platform
->
getSpeed
()
>
speed
)
{
best
=
platform
s
[
i
]
;
best
=
platform
;
speed
=
best
->
getSpeed
();
speed
=
best
->
getSpeed
();
}
}
}
}
...
@@ -193,15 +193,15 @@ static HMODULE loadOneLibrary(const string& file) {
...
@@ -193,15 +193,15 @@ static HMODULE loadOneLibrary(const string& file) {
}
}
static
void
initializePlugins
(
vector
<
HMODULE
>&
plugins
)
{
static
void
initializePlugins
(
vector
<
HMODULE
>&
plugins
)
{
for
(
int
i
=
0
;
i
<
(
int
)
plugins
.
size
();
i
++
)
{
for
(
auto
plugin
:
plugins
)
{
void
(
*
init
)();
void
(
*
init
)();
*
(
void
**
)(
&
init
)
=
(
void
*
)
GetProcAddress
(
plugin
s
[
i
]
,
"registerPlatforms"
);
*
(
void
**
)(
&
init
)
=
(
void
*
)
GetProcAddress
(
plugin
,
"registerPlatforms"
);
if
(
init
!=
NULL
)
if
(
init
!=
NULL
)
(
*
init
)();
(
*
init
)();
}
}
for
(
int
i
=
0
;
i
<
(
int
)
plugins
.
size
();
i
++
)
{
for
(
auto
plugin
:
plugins
)
{
void
(
*
init
)();
void
(
*
init
)();
*
(
void
**
)(
&
init
)
=
(
void
*
)
GetProcAddress
(
plugin
s
[
i
]
,
"registerKernelFactories"
);
*
(
void
**
)(
&
init
)
=
(
void
*
)
GetProcAddress
(
plugin
,
"registerKernelFactories"
);
if
(
init
!=
NULL
)
if
(
init
!=
NULL
)
(
*
init
)();
(
*
init
)();
}
}
...
@@ -221,15 +221,15 @@ static void* loadOneLibrary(const string& file) {
...
@@ -221,15 +221,15 @@ static void* loadOneLibrary(const string& file) {
static
void
initializePlugins
(
vector
<
void
*>&
plugins
)
{
static
void
initializePlugins
(
vector
<
void
*>&
plugins
)
{
#ifndef __PNACL__
#ifndef __PNACL__
for
(
int
i
=
0
;
i
<
(
int
)
plugins
.
size
();
i
++
)
{
for
(
auto
plugin
:
plugins
)
{
void
(
*
init
)();
void
(
*
init
)();
*
(
void
**
)(
&
init
)
=
dlsym
(
plugin
s
[
i
]
,
"registerPlatforms"
);
*
(
void
**
)(
&
init
)
=
dlsym
(
plugin
,
"registerPlatforms"
);
if
(
init
!=
NULL
)
if
(
init
!=
NULL
)
(
*
init
)();
(
*
init
)();
}
}
for
(
int
i
=
0
;
i
<
(
int
)
plugins
.
size
();
i
++
)
{
for
(
auto
plugin
:
plugins
)
{
void
(
*
init
)();
void
(
*
init
)();
*
(
void
**
)(
&
init
)
=
dlsym
(
plugin
s
[
i
]
,
"registerKernelFactories"
);
*
(
void
**
)(
&
init
)
=
dlsym
(
plugin
,
"registerKernelFactories"
);
if
(
init
!=
NULL
)
if
(
init
!=
NULL
)
(
*
init
)();
(
*
init
)();
}
}
...
...
openmmapi/src/AndersenThermostatImpl.cpp
View file @
08e8b206
...
@@ -94,7 +94,7 @@ void AndersenThermostatImpl::tagParticlesInGroup(int particle, int group, vector
...
@@ -94,7 +94,7 @@ void AndersenThermostatImpl::tagParticlesInGroup(int particle, int group, vector
// Recursively tag particles as belonging to a particular group.
// Recursively tag particles as belonging to a particular group.
particleGroup
[
particle
]
=
group
;
particleGroup
[
particle
]
=
group
;
for
(
int
i
=
0
;
i
<
(
int
)
particleConstraints
[
particle
]
.
size
();
i
++
)
for
(
int
constrained
:
particleConstraints
[
particle
])
if
(
particleGroup
[
particleConstraints
[
particle
][
i
]
]
==
-
1
)
if
(
particleGroup
[
constrained
]
==
-
1
)
tagParticlesInGroup
(
particleConstraints
[
particle
][
i
]
,
group
,
particleGroup
,
particleConstraints
);
tagParticlesInGroup
(
constrained
,
group
,
particleGroup
,
particleConstraints
);
}
}
openmmapi/src/CompiledExpressionSet.cpp
View file @
08e8b206
...
@@ -44,15 +44,15 @@ int CompiledExpressionSet::getVariableIndex(const std::string& name) {
...
@@ -44,15 +44,15 @@ int CompiledExpressionSet::getVariableIndex(const std::string& name) {
int
index
=
variables
.
size
();
int
index
=
variables
.
size
();
variables
.
push_back
(
name
);
variables
.
push_back
(
name
);
variableReferences
.
push_back
(
vector
<
double
*>
());
variableReferences
.
push_back
(
vector
<
double
*>
());
for
(
int
i
=
0
;
i
<
(
int
)
expressions
.
size
();
i
++
)
for
(
auto
expression
:
expressions
)
if
(
expression
s
[
i
]
->
getVariables
().
find
(
name
)
!=
expression
s
[
i
]
->
getVariables
().
end
())
if
(
expression
->
getVariables
().
find
(
name
)
!=
expression
->
getVariables
().
end
())
variableReferences
[
index
].
push_back
(
&
expression
s
[
i
]
->
getVariableReference
(
name
));
variableReferences
[
index
].
push_back
(
&
expression
->
getVariableReference
(
name
));
return
index
;
return
index
;
}
}
void
CompiledExpressionSet
::
setVariable
(
int
index
,
double
value
)
{
void
CompiledExpressionSet
::
setVariable
(
int
index
,
double
value
)
{
for
(
int
i
=
0
;
i
<
(
int
)
variableReferences
[
index
]
.
size
();
i
++
)
for
(
auto
ref
:
variableReferences
[
index
])
*
variableReferences
[
index
][
i
]
=
value
;
*
ref
=
value
;
}
}
int
CompiledExpressionSet
::
getNumVariables
()
const
{
int
CompiledExpressionSet
::
getNumVariables
()
const
{
...
...
openmmapi/src/Context.cpp
View file @
08e8b206
...
@@ -97,8 +97,8 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
...
@@ -97,8 +97,8 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
}
}
if
(
types
&
State
::
Parameters
)
{
if
(
types
&
State
::
Parameters
)
{
map
<
string
,
double
>
params
;
map
<
string
,
double
>
params
;
for
(
map
<
string
,
double
>::
const_iterator
iter
=
impl
->
parameters
.
begin
();
iter
!=
impl
->
parameters
.
end
();
iter
++
)
for
(
auto
&
param
:
impl
->
parameters
)
params
[
iter
->
first
]
=
iter
->
second
;
params
[
param
.
first
]
=
param
.
second
;
builder
.
setParameters
(
params
);
builder
.
setParameters
(
params
);
}
}
if
(
types
&
State
::
ParameterDerivatives
)
{
if
(
types
&
State
::
ParameterDerivatives
)
{
...
@@ -111,13 +111,13 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
...
@@ -111,13 +111,13 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
impl
->
getPositions
(
positions
);
impl
->
getPositions
(
positions
);
if
(
enforcePeriodicBox
)
{
if
(
enforcePeriodicBox
)
{
const
vector
<
vector
<
int
>
>&
molecules
=
impl
->
getMolecules
();
const
vector
<
vector
<
int
>
>&
molecules
=
impl
->
getMolecules
();
for
(
int
i
=
0
;
i
<
(
int
)
molecules
.
size
();
i
++
)
{
for
(
auto
&
mol
:
molecules
)
{
// Find the molecule center.
// Find the molecule center.
Vec3
center
;
Vec3
center
;
for
(
int
j
=
0
;
j
<
(
int
)
molecules
[
i
].
size
();
j
++
)
for
(
int
j
:
mol
)
center
+=
positions
[
molecules
[
i
][
j
]
];
center
+=
positions
[
j
];
center
*=
1.0
/
mol
ecules
[
i
]
.
size
();
center
*=
1.0
/
mol
.
size
();
// Find the displacement to move it into the first periodic box.
// Find the displacement to move it into the first periodic box.
Vec3
diff
;
Vec3
diff
;
...
@@ -126,10 +126,8 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
...
@@ -126,10 +126,8 @@ State Context::getState(int types, bool enforcePeriodicBox, int groups) const {
diff
+=
periodicBoxSize
[
0
]
*
floor
((
center
[
0
]
-
diff
[
0
])
/
periodicBoxSize
[
0
][
0
]);
diff
+=
periodicBoxSize
[
0
]
*
floor
((
center
[
0
]
-
diff
[
0
])
/
periodicBoxSize
[
0
][
0
]);
// Translate all the particles in the molecule.
// Translate all the particles in the molecule.
for
(
int
j
=
0
;
j
<
(
int
)
molecules
[
i
].
size
();
j
++
)
{
for
(
int
j
:
mol
)
Vec3
&
pos
=
positions
[
molecules
[
i
][
j
]];
positions
[
j
]
-=
diff
;
pos
-=
diff
;
}
}
}
}
}
builder
.
setPositions
(
positions
);
builder
.
setPositions
(
positions
);
...
@@ -152,8 +150,8 @@ void Context::setState(const State& state) {
...
@@ -152,8 +150,8 @@ void Context::setState(const State& state) {
if
((
state
.
getDataTypes
()
&
State
::
Velocities
)
!=
0
)
if
((
state
.
getDataTypes
()
&
State
::
Velocities
)
!=
0
)
setVelocities
(
state
.
getVelocities
());
setVelocities
(
state
.
getVelocities
());
if
((
state
.
getDataTypes
()
&
State
::
Parameters
)
!=
0
)
if
((
state
.
getDataTypes
()
&
State
::
Parameters
)
!=
0
)
for
(
map
<
string
,
double
>::
const_iterator
iter
=
state
.
getParameters
().
begin
();
iter
!=
state
.
getParameters
()
.
end
();
++
iter
)
for
(
auto
&
param
:
state
.
getParameters
())
setParameter
(
iter
->
first
,
iter
->
second
);
setParameter
(
param
.
first
,
param
.
second
);
}
}
void
Context
::
setTime
(
double
time
)
{
void
Context
::
setTime
(
double
time
)
{
...
...
openmmapi/src/ContextImpl.cpp
View file @
08e8b206
...
@@ -95,19 +95,19 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
...
@@ -95,19 +95,19 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
const
vector
<
string
>&
platformProperties
=
platform
->
getPropertyNames
();
const
vector
<
string
>&
platformProperties
=
platform
->
getPropertyNames
();
map
<
string
,
string
>
validatedProperties
;
map
<
string
,
string
>
validatedProperties
;
for
(
map
<
string
,
string
>::
const_iterator
iter
=
properties
.
begin
();
iter
!=
properties
.
end
();
++
iter
)
{
for
(
auto
&
prop
:
properties
)
{
string
property
=
iter
->
first
;
string
property
=
prop
.
first
;
if
(
platform
->
deprecatedPropertyReplacements
.
find
(
property
)
!=
platform
->
deprecatedPropertyReplacements
.
end
())
if
(
platform
->
deprecatedPropertyReplacements
.
find
(
property
)
!=
platform
->
deprecatedPropertyReplacements
.
end
())
property
=
platform
->
deprecatedPropertyReplacements
[
property
];
property
=
platform
->
deprecatedPropertyReplacements
[
property
];
bool
valid
=
false
;
bool
valid
=
false
;
for
(
int
i
=
0
;
i
<
(
int
)
platformProperties
.
size
();
i
++
)
for
(
auto
&
p
:
platformProperties
)
if
(
p
latformProperties
[
i
]
==
property
)
{
if
(
p
==
property
)
{
valid
=
true
;
valid
=
true
;
break
;
break
;
}
}
if
(
!
valid
)
if
(
!
valid
)
throw
OpenMMException
(
"Illegal property name: "
+
iter
->
first
);
throw
OpenMMException
(
"Illegal property name: "
+
prop
.
first
);
validatedProperties
[
property
]
=
iter
->
second
;
validatedProperties
[
property
]
=
prop
.
second
;
}
}
// Find the list of kernels required.
// Find the list of kernels required.
...
@@ -184,8 +184,8 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
...
@@ -184,8 +184,8 @@ ContextImpl::ContextImpl(Context& owner, const System& system, Integrator& integ
}
}
ContextImpl
::~
ContextImpl
()
{
ContextImpl
::~
ContextImpl
()
{
for
(
int
i
=
0
;
i
<
(
int
)
forceImpls
.
size
();
++
i
)
for
(
auto
force
:
forceImpls
)
delete
force
Impls
[
i
]
;
delete
force
;
// Make sure all kernels get properly deleted before contextDestroyed() is called.
// Make sure all kernels get properly deleted before contextDestroyed() is called.
...
@@ -292,8 +292,8 @@ double ContextImpl::calcForcesAndEnergy(bool includeForces, bool includeEnergy,
...
@@ -292,8 +292,8 @@ double ContextImpl::calcForcesAndEnergy(bool includeForces, bool includeEnergy,
while
(
true
)
{
while
(
true
)
{
double
energy
=
0.0
;
double
energy
=
0.0
;
kernel
.
beginComputation
(
*
this
,
includeForces
,
includeEnergy
,
groups
);
kernel
.
beginComputation
(
*
this
,
includeForces
,
includeEnergy
,
groups
);
for
(
int
i
=
0
;
i
<
(
int
)
forceImpls
.
size
();
++
i
)
for
(
auto
force
:
forceImpls
)
energy
+=
force
Impls
[
i
]
->
calcForcesAndEnergy
(
*
this
,
includeForces
,
includeEnergy
,
groups
);
energy
+=
force
->
calcForcesAndEnergy
(
*
this
,
includeForces
,
includeEnergy
,
groups
);
bool
valid
=
true
;
bool
valid
=
true
;
energy
+=
kernel
.
finishComputation
(
*
this
,
includeForces
,
includeEnergy
,
groups
,
valid
);
energy
+=
kernel
.
finishComputation
(
*
this
,
includeForces
,
includeEnergy
,
groups
,
valid
);
if
(
valid
)
if
(
valid
)
...
@@ -310,8 +310,8 @@ double ContextImpl::calcKineticEnergy() {
...
@@ -310,8 +310,8 @@ double ContextImpl::calcKineticEnergy() {
}
}
void
ContextImpl
::
updateContextState
()
{
void
ContextImpl
::
updateContextState
()
{
for
(
int
i
=
0
;
i
<
(
int
)
forceImpls
.
size
();
++
i
)
for
(
auto
force
:
forceImpls
)
force
Impls
[
i
]
->
updateContextState
(
*
this
);
force
->
updateContextState
(
*
this
);
}
}
const
vector
<
ForceImpl
*>&
ContextImpl
::
getForceImpls
()
const
{
const
vector
<
ForceImpl
*>&
ContextImpl
::
getForceImpls
()
const
{
...
@@ -349,8 +349,8 @@ const vector<vector<int> >& ContextImpl::getMolecules() const {
...
@@ -349,8 +349,8 @@ const vector<vector<int> >& ContextImpl::getMolecules() const {
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
system
.
getConstraintParameters
(
i
,
particle1
,
particle2
,
distance
);
bonds
.
push_back
(
std
::
make_pair
(
particle1
,
particle2
));
bonds
.
push_back
(
std
::
make_pair
(
particle1
,
particle2
));
}
}
for
(
int
i
=
0
;
i
<
(
int
)
forceImpls
.
size
();
i
++
)
{
for
(
auto
force
:
forceImpls
)
{
vector
<
pair
<
int
,
int
>
>
forceBonds
=
force
Impls
[
i
]
->
getBondedParticles
();
vector
<
pair
<
int
,
int
>
>
forceBonds
=
force
->
getBondedParticles
();
bonds
.
insert
(
bonds
.
end
(),
forceBonds
.
begin
(),
forceBonds
.
end
());
bonds
.
insert
(
bonds
.
end
(),
forceBonds
.
begin
(),
forceBonds
.
end
());
}
}
for
(
int
i
=
0
;
i
<
system
.
getNumParticles
();
i
++
)
{
for
(
int
i
=
0
;
i
<
system
.
getNumParticles
();
i
++
)
{
...
@@ -365,9 +365,9 @@ const vector<vector<int> >& ContextImpl::getMolecules() const {
...
@@ -365,9 +365,9 @@ const vector<vector<int> >& ContextImpl::getMolecules() const {
int
numParticles
=
system
.
getNumParticles
();
int
numParticles
=
system
.
getNumParticles
();
vector
<
vector
<
int
>
>
particleBonds
(
numParticles
);
vector
<
vector
<
int
>
>
particleBonds
(
numParticles
);
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
i
++
)
{
for
(
auto
&
bond
:
bonds
)
{
particleBonds
[
bond
s
[
i
]
.
first
].
push_back
(
bond
s
[
i
]
.
second
);
particleBonds
[
bond
.
first
].
push_back
(
bond
.
second
);
particleBonds
[
bond
s
[
i
]
.
second
].
push_back
(
bond
s
[
i
]
.
first
);
particleBonds
[
bond
.
second
].
push_back
(
bond
.
first
);
}
}
// Now identify particles by which molecule they belong to.
// Now identify particles by which molecule they belong to.
...
@@ -441,9 +441,9 @@ void ContextImpl::createCheckpoint(ostream& stream) {
...
@@ -441,9 +441,9 @@ void ContextImpl::createCheckpoint(ostream& stream) {
stream
.
write
((
char
*
)
&
numParticles
,
sizeof
(
int
));
stream
.
write
((
char
*
)
&
numParticles
,
sizeof
(
int
));
int
numParameters
=
parameters
.
size
();
int
numParameters
=
parameters
.
size
();
stream
.
write
((
char
*
)
&
numParameters
,
sizeof
(
int
));
stream
.
write
((
char
*
)
&
numParameters
,
sizeof
(
int
));
for
(
map
<
string
,
double
>::
const_iterator
iter
=
parameters
.
begin
();
iter
!=
parameters
.
end
();
++
iter
)
{
for
(
auto
&
param
:
parameters
)
{
writeString
(
stream
,
iter
->
first
);
writeString
(
stream
,
param
.
first
);
stream
.
write
((
char
*
)
&
iter
->
second
,
sizeof
(
double
));
stream
.
write
((
char
*
)
&
param
.
second
,
sizeof
(
double
));
}
}
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
createCheckpoint
(
*
this
,
stream
);
updateStateDataKernel
.
getAs
<
UpdateStateDataKernel
>
().
createCheckpoint
(
*
this
,
stream
);
stream
.
flush
();
stream
.
flush
();
...
...
openmmapi/src/CustomCentroidBondForce.cpp
View file @
08e8b206
...
@@ -52,8 +52,8 @@ CustomCentroidBondForce::CustomCentroidBondForce(int numGroups, const string& en
...
@@ -52,8 +52,8 @@ CustomCentroidBondForce::CustomCentroidBondForce(int numGroups, const string& en
}
}
CustomCentroidBondForce
::~
CustomCentroidBondForce
()
{
CustomCentroidBondForce
::~
CustomCentroidBondForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
const
string
&
CustomCentroidBondForce
::
getEnergyFunction
()
const
{
const
string
&
CustomCentroidBondForce
::
getEnergyFunction
()
const
{
...
...
openmmapi/src/CustomCentroidBondForceImpl.cpp
View file @
08e8b206
...
@@ -83,11 +83,11 @@ void CustomCentroidBondForceImpl::initialize(ContextImpl& context) {
...
@@ -83,11 +83,11 @@ void CustomCentroidBondForceImpl::initialize(ContextImpl& context) {
vector
<
double
>
weights
;
vector
<
double
>
weights
;
for
(
int
i
=
0
;
i
<
owner
.
getNumGroups
();
i
++
)
{
for
(
int
i
=
0
;
i
<
owner
.
getNumGroups
();
i
++
)
{
owner
.
getGroupParameters
(
i
,
particles
,
weights
);
owner
.
getGroupParameters
(
i
,
particles
,
weights
);
for
(
int
j
=
0
;
j
<
(
int
)
particles
.
size
();
j
++
)
for
(
int
particle
:
particles
)
if
(
particle
s
[
j
]
<
0
||
particle
s
[
j
]
>=
system
.
getNumParticles
())
{
if
(
particle
<
0
||
particle
>=
system
.
getNumParticles
())
{
stringstream
msg
;
stringstream
msg
;
msg
<<
"CustomCentroidBondForce: Illegal particle index for a group: "
;
msg
<<
"CustomCentroidBondForce: Illegal particle index for a group: "
;
msg
<<
particle
s
[
j
]
;
msg
<<
particle
;
throw
OpenMMException
(
msg
.
str
());
throw
OpenMMException
(
msg
.
str
());
}
}
if
(
weights
.
size
()
!=
particles
.
size
()
&&
weights
.
size
()
>
0
)
{
if
(
weights
.
size
()
!=
particles
.
size
()
&&
weights
.
size
()
>
0
)
{
...
@@ -102,11 +102,11 @@ void CustomCentroidBondForceImpl::initialize(ContextImpl& context) {
...
@@ -102,11 +102,11 @@ void CustomCentroidBondForceImpl::initialize(ContextImpl& context) {
int
numBondParameters
=
owner
.
getNumPerBondParameters
();
int
numBondParameters
=
owner
.
getNumPerBondParameters
();
for
(
int
i
=
0
;
i
<
owner
.
getNumBonds
();
i
++
)
{
for
(
int
i
=
0
;
i
<
owner
.
getNumBonds
();
i
++
)
{
owner
.
getBondParameters
(
i
,
groups
,
parameters
);
owner
.
getBondParameters
(
i
,
groups
,
parameters
);
for
(
int
j
=
0
;
j
<
(
int
)
groups
.
size
();
j
++
)
for
(
int
group
:
groups
)
if
(
group
s
[
j
]
<
0
||
group
s
[
j
]
>=
owner
.
getNumGroups
())
{
if
(
group
<
0
||
group
>=
owner
.
getNumGroups
())
{
stringstream
msg
;
stringstream
msg
;
msg
<<
"CustomCentroidBondForce: Illegal group index for a bond: "
;
msg
<<
"CustomCentroidBondForce: Illegal group index for a bond: "
;
msg
<<
group
s
[
j
]
;
msg
<<
group
;
throw
OpenMMException
(
msg
.
str
());
throw
OpenMMException
(
msg
.
str
());
}
}
if
(
parameters
.
size
()
!=
numBondParameters
)
{
if
(
parameters
.
size
()
!=
numBondParameters
)
{
...
@@ -179,8 +179,8 @@ ExpressionTreeNode CustomCentroidBondForceImpl::replaceFunctions(const Expressio
...
@@ -179,8 +179,8 @@ ExpressionTreeNode CustomCentroidBondForceImpl::replaceFunctions(const Expressio
// This is not an angle or dihedral, so process its children.
// This is not an angle or dihedral, so process its children.
vector
<
ExpressionTreeNode
>
children
;
vector
<
ExpressionTreeNode
>
children
;
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
children
.
push_back
(
replaceFunctions
(
node
.
getChildren
()[
i
]
,
groups
,
distances
,
angles
,
dihedrals
,
variables
));
children
.
push_back
(
replaceFunctions
(
child
,
groups
,
distances
,
angles
,
dihedrals
,
variables
));
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
}
}
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
...
...
openmmapi/src/CustomCompoundBondForce.cpp
View file @
08e8b206
...
@@ -53,8 +53,8 @@ CustomCompoundBondForce::CustomCompoundBondForce(int numParticles, const string&
...
@@ -53,8 +53,8 @@ CustomCompoundBondForce::CustomCompoundBondForce(int numParticles, const string&
CustomCompoundBondForce
::~
CustomCompoundBondForce
()
{
CustomCompoundBondForce
::~
CustomCompoundBondForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
const
string
&
CustomCompoundBondForce
::
getEnergyFunction
()
const
{
const
string
&
CustomCompoundBondForce
::
getEnergyFunction
()
const
{
...
...
openmmapi/src/CustomCompoundBondForceImpl.cpp
View file @
08e8b206
...
@@ -88,11 +88,11 @@ void CustomCompoundBondForceImpl::initialize(ContextImpl& context) {
...
@@ -88,11 +88,11 @@ void CustomCompoundBondForceImpl::initialize(ContextImpl& context) {
int
numBondParameters
=
owner
.
getNumPerBondParameters
();
int
numBondParameters
=
owner
.
getNumPerBondParameters
();
for
(
int
i
=
0
;
i
<
owner
.
getNumBonds
();
i
++
)
{
for
(
int
i
=
0
;
i
<
owner
.
getNumBonds
();
i
++
)
{
owner
.
getBondParameters
(
i
,
particles
,
parameters
);
owner
.
getBondParameters
(
i
,
particles
,
parameters
);
for
(
int
j
=
0
;
j
<
(
int
)
particles
.
size
();
j
++
)
for
(
int
particle
:
particles
)
if
(
particle
s
[
j
]
<
0
||
particle
s
[
j
]
>=
system
.
getNumParticles
())
{
if
(
particle
<
0
||
particle
>=
system
.
getNumParticles
())
{
stringstream
msg
;
stringstream
msg
;
msg
<<
"CustomCompoundBondForce: Illegal particle index for a bond: "
;
msg
<<
"CustomCompoundBondForce: Illegal particle index for a bond: "
;
msg
<<
particle
s
[
j
]
;
msg
<<
particle
;
throw
OpenMMException
(
msg
.
str
());
throw
OpenMMException
(
msg
.
str
());
}
}
if
(
parameters
.
size
()
!=
numBondParameters
)
{
if
(
parameters
.
size
()
!=
numBondParameters
)
{
...
@@ -165,8 +165,8 @@ ExpressionTreeNode CustomCompoundBondForceImpl::replaceFunctions(const Expressio
...
@@ -165,8 +165,8 @@ ExpressionTreeNode CustomCompoundBondForceImpl::replaceFunctions(const Expressio
// This is not an angle or dihedral, so process its children.
// This is not an angle or dihedral, so process its children.
vector
<
ExpressionTreeNode
>
children
;
vector
<
ExpressionTreeNode
>
children
;
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
children
.
push_back
(
replaceFunctions
(
node
.
getChildren
()[
i
]
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
children
.
push_back
(
replaceFunctions
(
child
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
}
}
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
...
...
openmmapi/src/CustomGBForce.cpp
View file @
08e8b206
...
@@ -51,8 +51,8 @@ CustomGBForce::CustomGBForce() : nonbondedMethod(NoCutoff), cutoffDistance(1.0)
...
@@ -51,8 +51,8 @@ CustomGBForce::CustomGBForce() : nonbondedMethod(NoCutoff), cutoffDistance(1.0)
}
}
CustomGBForce
::~
CustomGBForce
()
{
CustomGBForce
::~
CustomGBForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
CustomGBForce
::
NonbondedMethod
CustomGBForce
::
getNonbondedMethod
()
const
{
CustomGBForce
::
NonbondedMethod
CustomGBForce
::
getNonbondedMethod
()
const
{
...
...
openmmapi/src/CustomHbondForce.cpp
View file @
08e8b206
...
@@ -52,8 +52,8 @@ CustomHbondForce::CustomHbondForce(const string& energy) : energyExpression(ener
...
@@ -52,8 +52,8 @@ CustomHbondForce::CustomHbondForce(const string& energy) : energyExpression(ener
CustomHbondForce
::~
CustomHbondForce
()
{
CustomHbondForce
::~
CustomHbondForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
const
string
&
CustomHbondForce
::
getEnergyFunction
()
const
{
const
string
&
CustomHbondForce
::
getEnergyFunction
()
const
{
...
...
openmmapi/src/CustomHbondForceImpl.cpp
View file @
08e8b206
...
@@ -235,8 +235,8 @@ ExpressionTreeNode CustomHbondForceImpl::replaceFunctions(const ExpressionTreeNo
...
@@ -235,8 +235,8 @@ ExpressionTreeNode CustomHbondForceImpl::replaceFunctions(const ExpressionTreeNo
// This is not an angle or dihedral, so process its children.
// This is not an angle or dihedral, so process its children.
vector
<
ExpressionTreeNode
>
children
;
vector
<
ExpressionTreeNode
>
children
;
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
children
.
push_back
(
replaceFunctions
(
node
.
getChildren
()[
i
]
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
children
.
push_back
(
replaceFunctions
(
child
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
}
}
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
...
...
openmmapi/src/CustomIntegrator.cpp
View file @
08e8b206
...
@@ -55,8 +55,7 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -55,8 +55,7 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
set
<
std
::
string
>
variableSet
;
set
<
std
::
string
>
variableSet
;
variableList
.
insert
(
variableList
.
end
(),
globalNames
.
begin
(),
globalNames
.
end
());
variableList
.
insert
(
variableList
.
end
(),
globalNames
.
begin
(),
globalNames
.
end
());
variableList
.
insert
(
variableList
.
end
(),
perDofNames
.
begin
(),
perDofNames
.
end
());
variableList
.
insert
(
variableList
.
end
(),
perDofNames
.
begin
(),
perDofNames
.
end
());
for
(
int
i
=
0
;
i
<
(
int
)
variableList
.
size
();
i
++
)
{
for
(
auto
&
name
:
variableList
)
{
string
&
name
=
variableList
[
i
];
if
(
variableSet
.
find
(
name
)
!=
variableSet
.
end
())
if
(
variableSet
.
find
(
name
)
!=
variableSet
.
end
())
throw
OpenMMException
(
"The Integrator defines two variables with the same name: "
+
name
);
throw
OpenMMException
(
"The Integrator defines two variables with the same name: "
+
name
);
variableSet
.
insert
(
name
);
variableSet
.
insert
(
name
);
...
@@ -66,8 +65,8 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
...
@@ -66,8 +65,8 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
set
<
std
::
string
>
globalTargets
;
set
<
std
::
string
>
globalTargets
;
globalTargets
.
insert
(
globalNames
.
begin
(),
globalNames
.
end
());
globalTargets
.
insert
(
globalNames
.
begin
(),
globalNames
.
end
());
globalTargets
.
insert
(
"dt"
);
globalTargets
.
insert
(
"dt"
);
for
(
map
<
string
,
double
>::
const_iterator
iter
=
contextRef
.
getParameters
().
begin
();
iter
!=
contextRef
.
getParameters
()
.
end
();
++
iter
)
for
(
auto
&
param
:
contextRef
.
getParameters
())
globalTargets
.
insert
(
iter
->
first
);
globalTargets
.
insert
(
param
.
first
);
for
(
int
i
=
0
;
i
<
computations
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
computations
.
size
();
i
++
)
{
if
(
computations
[
i
].
type
==
ComputeGlobal
&&
globalTargets
.
find
(
computations
[
i
].
variable
)
==
globalTargets
.
end
())
if
(
computations
[
i
].
type
==
ComputeGlobal
&&
globalTargets
.
find
(
computations
[
i
].
variable
)
==
globalTargets
.
end
())
throw
OpenMMException
(
"Unknown global variable: "
+
computations
[
i
].
variable
);
throw
OpenMMException
(
"Unknown global variable: "
+
computations
[
i
].
variable
);
...
...
openmmapi/src/CustomIntegratorUtilities.cpp
View file @
08e8b206
...
@@ -59,8 +59,8 @@ bool CustomIntegratorUtilities::usesVariable(const Lepton::ExpressionTreeNode& n
...
@@ -59,8 +59,8 @@ bool CustomIntegratorUtilities::usesVariable(const Lepton::ExpressionTreeNode& n
const
Lepton
::
Operation
&
op
=
node
.
getOperation
();
const
Lepton
::
Operation
&
op
=
node
.
getOperation
();
if
(
op
.
getId
()
==
Lepton
::
Operation
::
VARIABLE
&&
op
.
getName
()
==
variable
)
if
(
op
.
getId
()
==
Lepton
::
Operation
::
VARIABLE
&&
op
.
getName
()
==
variable
)
return
true
;
return
true
;
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
if
(
usesVariable
(
node
.
getChildren
()[
i
]
,
variable
))
if
(
usesVariable
(
child
,
variable
))
return
true
;
return
true
;
return
false
;
return
false
;
}
}
...
@@ -107,11 +107,9 @@ void CustomIntegratorUtilities::analyzeComputations(const ContextImpl& context,
...
@@ -107,11 +107,9 @@ void CustomIntegratorUtilities::analyzeComputations(const ContextImpl& context,
set
<
string
>
affectsForce
;
set
<
string
>
affectsForce
;
affectsForce
.
insert
(
"x"
);
affectsForce
.
insert
(
"x"
);
for
(
vector
<
ForceImpl
*>::
const_iterator
iter
=
context
.
getForceImpls
().
begin
();
iter
!=
context
.
getForceImpls
().
end
();
++
iter
)
{
for
(
auto
force
:
context
.
getForceImpls
())
const
map
<
string
,
double
>
params
=
(
*
iter
)
->
getDefaultParameters
();
for
(
auto
&
param
:
force
->
getDefaultParameters
())
for
(
map
<
string
,
double
>::
const_iterator
param
=
params
.
begin
();
param
!=
params
.
end
();
++
param
)
affectsForce
.
insert
(
param
.
first
);
affectsForce
.
insert
(
param
->
first
);
}
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
for
(
int
i
=
0
;
i
<
numSteps
;
i
++
)
invalidatesForces
[
i
]
=
(
stepType
[
i
]
==
CustomIntegrator
::
ConstrainPositions
||
affectsForce
.
find
(
stepVariable
[
i
])
!=
affectsForce
.
end
());
invalidatesForces
[
i
]
=
(
stepType
[
i
]
==
CustomIntegrator
::
ConstrainPositions
||
affectsForce
.
find
(
stepVariable
[
i
])
!=
affectsForce
.
end
());
...
@@ -253,8 +251,7 @@ void CustomIntegratorUtilities::analyzeForceComputationsForPath(vector<int>& ste
...
@@ -253,8 +251,7 @@ void CustomIntegratorUtilities::analyzeForceComputationsForPath(vector<int>& ste
const
vector
<
bool
>&
invalidatesForces
,
const
vector
<
int
>&
forceGroup
,
vector
<
bool
>&
computeBoth
)
{
const
vector
<
bool
>&
invalidatesForces
,
const
vector
<
int
>&
forceGroup
,
vector
<
bool
>&
computeBoth
)
{
vector
<
int
>
candidatePoints
;
vector
<
int
>
candidatePoints
;
int
currentGroup
=
-
1
;
int
currentGroup
=
-
1
;
for
(
int
i
=
0
;
i
<
(
int
)
steps
.
size
();
i
++
)
{
for
(
int
step
:
steps
)
{
int
step
=
steps
[
i
];
if
(
invalidatesForces
[
step
]
||
((
needsForces
[
step
]
||
needsEnergy
[
step
])
&&
forceGroup
[
step
]
!=
currentGroup
))
{
if
(
invalidatesForces
[
step
]
||
((
needsForces
[
step
]
||
needsEnergy
[
step
])
&&
forceGroup
[
step
]
!=
currentGroup
))
{
// Forces and energies are invalidated at this step, or it changes to a different force group,
// Forces and energies are invalidated at this step, or it changes to a different force group,
// so anything from this point on won't affect what we do at earlier steps.
// so anything from this point on won't affect what we do at earlier steps.
...
@@ -264,11 +261,9 @@ void CustomIntegratorUtilities::analyzeForceComputationsForPath(vector<int>& ste
...
@@ -264,11 +261,9 @@ void CustomIntegratorUtilities::analyzeForceComputationsForPath(vector<int>& ste
if
(
needsForces
[
step
]
||
needsEnergy
[
step
])
{
if
(
needsForces
[
step
]
||
needsEnergy
[
step
])
{
// See if this step affects what we do at earlier points.
// See if this step affects what we do at earlier points.
for
(
int
j
=
0
;
j
<
(
int
)
candidatePoints
.
size
();
j
++
)
{
for
(
int
candidate
:
candidatePoints
)
int
candidate
=
candidatePoints
[
j
];
if
((
needsForces
[
candidate
]
&&
needsEnergy
[
step
])
||
(
needsEnergy
[
candidate
]
&&
needsForces
[
step
]))
if
((
needsForces
[
candidate
]
&&
needsEnergy
[
step
])
||
(
needsEnergy
[
candidate
]
&&
needsForces
[
step
]))
computeBoth
[
candidate
]
=
true
;
computeBoth
[
candidate
]
=
true
;
}
// Add this to the list of candidates that might be affected by later steps.
// Add this to the list of candidates that might be affected by later steps.
...
...
openmmapi/src/CustomManyParticleForce.cpp
View file @
08e8b206
...
@@ -48,8 +48,8 @@ CustomManyParticleForce::CustomManyParticleForce(int particlesPerSet, const stri
...
@@ -48,8 +48,8 @@ CustomManyParticleForce::CustomManyParticleForce(int particlesPerSet, const stri
}
}
CustomManyParticleForce
::~
CustomManyParticleForce
()
{
CustomManyParticleForce
::~
CustomManyParticleForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
const
string
&
CustomManyParticleForce
::
getEnergyFunction
()
const
{
const
string
&
CustomManyParticleForce
::
getEnergyFunction
()
const
{
...
@@ -162,9 +162,9 @@ void CustomManyParticleForce::createExclusionsFromBonds(const vector<pair<int, i
...
@@ -162,9 +162,9 @@ void CustomManyParticleForce::createExclusionsFromBonds(const vector<pair<int, i
return
;
return
;
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
{
for
(
auto
&
bond
:
bonds
)
{
int
p1
=
bond
s
[
i
]
.
first
;
int
p1
=
bond
.
first
;
int
p2
=
bond
s
[
i
]
.
second
;
int
p2
=
bond
.
second
;
exclusions
[
p1
].
insert
(
p2
);
exclusions
[
p1
].
insert
(
p2
);
exclusions
[
p2
].
insert
(
p1
);
exclusions
[
p2
].
insert
(
p1
);
bonded12
[
p1
].
insert
(
p2
);
bonded12
[
p1
].
insert
(
p2
);
...
@@ -172,15 +172,14 @@ void CustomManyParticleForce::createExclusionsFromBonds(const vector<pair<int, i
...
@@ -172,15 +172,14 @@ void CustomManyParticleForce::createExclusionsFromBonds(const vector<pair<int, i
}
}
for
(
int
level
=
0
;
level
<
bondCutoff
-
1
;
level
++
)
{
for
(
int
level
=
0
;
level
<
bondCutoff
-
1
;
level
++
)
{
vector
<
set
<
int
>
>
currentExclusions
=
exclusions
;
vector
<
set
<
int
>
>
currentExclusions
=
exclusions
;
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
size
();
i
++
)
for
(
set
<
int
>::
const_iterator
iter
=
currentExclusions
[
i
].
begin
();
iter
!=
currentExclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
currentExclusions
[
i
])
exclusions
[
*
iter
].
insert
(
bonded12
[
i
].
begin
(),
bonded12
[
i
].
end
());
exclusions
[
j
].
insert
(
bonded12
[
i
].
begin
(),
bonded12
[
i
].
end
());
}
}
}
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
exclusions
[
i
]
)
if
(
*
iter
<
i
)
if
(
j
<
i
)
addExclusion
(
*
iter
,
i
);
addExclusion
(
j
,
i
);
}
}
void
CustomManyParticleForce
::
getTypeFilter
(
int
index
,
set
<
int
>&
types
)
const
{
void
CustomManyParticleForce
::
getTypeFilter
(
int
index
,
set
<
int
>&
types
)
const
{
...
...
openmmapi/src/CustomManyParticleForceImpl.cpp
View file @
08e8b206
...
@@ -197,8 +197,8 @@ ExpressionTreeNode CustomManyParticleForceImpl::replaceFunctions(const Expressio
...
@@ -197,8 +197,8 @@ ExpressionTreeNode CustomManyParticleForceImpl::replaceFunctions(const Expressio
// This is not an angle or dihedral, so process its children.
// This is not an angle or dihedral, so process its children.
vector
<
ExpressionTreeNode
>
children
;
vector
<
ExpressionTreeNode
>
children
;
for
(
int
i
=
0
;
i
<
(
int
)
node
.
getChildren
()
.
size
();
i
++
)
for
(
auto
&
child
:
node
.
getChildren
())
children
.
push_back
(
replaceFunctions
(
node
.
getChildren
()[
i
]
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
children
.
push_back
(
replaceFunctions
(
child
,
atoms
,
distances
,
angles
,
dihedrals
,
variables
));
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
return
ExpressionTreeNode
(
op
.
clone
(),
children
);
}
}
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
const
Operation
::
Custom
&
custom
=
static_cast
<
const
Operation
::
Custom
&>
(
op
);
...
@@ -280,9 +280,9 @@ void CustomManyParticleForceImpl::buildFilterArrays(const CustomManyParticleForc
...
@@ -280,9 +280,9 @@ void CustomManyParticleForceImpl::buildFilterArrays(const CustomManyParticleForc
for
(
int
j
=
0
;
j
<
numTypes
;
j
++
)
for
(
int
j
=
0
;
j
<
numTypes
;
j
++
)
allowedTypes
[
i
].
insert
(
j
);
allowedTypes
[
i
].
insert
(
j
);
else
{
else
{
for
(
set
<
int
>::
const_iterator
iter
=
types
.
begin
();
iter
!=
types
.
end
();
++
iter
)
for
(
int
type
:
types
)
if
(
typeMap
.
find
(
*
iter
)
!=
typeMap
.
end
())
if
(
typeMap
.
find
(
type
)
!=
typeMap
.
end
())
allowedTypes
[
i
].
insert
(
typeMap
[
*
iter
]);
allowedTypes
[
i
].
insert
(
typeMap
[
type
]);
if
(
allowedTypes
[
i
].
size
()
<
numTypes
)
if
(
allowedTypes
[
i
].
size
()
<
numTypes
)
anyFilters
=
true
;
anyFilters
=
true
;
}
}
...
...
openmmapi/src/CustomNonbondedForce.cpp
View file @
08e8b206
...
@@ -70,8 +70,8 @@ CustomNonbondedForce::CustomNonbondedForce(const CustomNonbondedForce& rhs) {
...
@@ -70,8 +70,8 @@ CustomNonbondedForce::CustomNonbondedForce(const CustomNonbondedForce& rhs) {
}
}
CustomNonbondedForce
::~
CustomNonbondedForce
()
{
CustomNonbondedForce
::~
CustomNonbondedForce
()
{
for
(
int
i
=
0
;
i
<
(
int
)
functions
.
size
();
i
++
)
for
(
auto
function
:
functions
)
delete
function
s
[
i
]
.
function
;
delete
function
.
function
;
}
}
const
string
&
CustomNonbondedForce
::
getEnergyFunction
()
const
{
const
string
&
CustomNonbondedForce
::
getEnergyFunction
()
const
{
...
@@ -210,14 +210,14 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
...
@@ -210,14 +210,14 @@ void CustomNonbondedForce::setExclusionParticles(int index, int particle1, int p
void
CustomNonbondedForce
::
createExclusionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
int
bondCutoff
)
{
void
CustomNonbondedForce
::
createExclusionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
int
bondCutoff
)
{
if
(
bondCutoff
<
1
)
if
(
bondCutoff
<
1
)
return
;
return
;
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
for
(
auto
&
bond
:
bonds
)
if
(
bond
s
[
i
]
.
first
<
0
||
bond
s
[
i
]
.
second
<
0
||
bond
s
[
i
]
.
first
>=
particles
.
size
()
||
bond
s
[
i
]
.
second
>=
particles
.
size
())
if
(
bond
.
first
<
0
||
bond
.
second
<
0
||
bond
.
first
>=
particles
.
size
()
||
bond
.
second
>=
particles
.
size
())
throw
OpenMMException
(
"createExclusionsFromBonds: Illegal particle index in list of bonds"
);
throw
OpenMMException
(
"createExclusionsFromBonds: Illegal particle index in list of bonds"
);
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
{
for
(
auto
&
bond
:
bonds
)
{
int
p1
=
bond
s
[
i
]
.
first
;
int
p1
=
bond
.
first
;
int
p2
=
bond
s
[
i
]
.
second
;
int
p2
=
bond
.
second
;
exclusions
[
p1
].
insert
(
p2
);
exclusions
[
p1
].
insert
(
p2
);
exclusions
[
p2
].
insert
(
p1
);
exclusions
[
p2
].
insert
(
p1
);
bonded12
[
p1
].
insert
(
p2
);
bonded12
[
p1
].
insert
(
p2
);
...
@@ -225,15 +225,14 @@ void CustomNonbondedForce::createExclusionsFromBonds(const vector<pair<int, int>
...
@@ -225,15 +225,14 @@ void CustomNonbondedForce::createExclusionsFromBonds(const vector<pair<int, int>
}
}
for
(
int
level
=
0
;
level
<
bondCutoff
-
1
;
level
++
)
{
for
(
int
level
=
0
;
level
<
bondCutoff
-
1
;
level
++
)
{
vector
<
set
<
int
>
>
currentExclusions
=
exclusions
;
vector
<
set
<
int
>
>
currentExclusions
=
exclusions
;
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
(
int
)
particles
.
size
();
i
++
)
for
(
set
<
int
>::
const_iterator
iter
=
currentExclusions
[
i
].
begin
();
iter
!=
currentExclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
currentExclusions
[
i
])
exclusions
[
*
iter
].
insert
(
bonded12
[
i
].
begin
(),
bonded12
[
i
].
end
());
exclusions
[
j
].
insert
(
bonded12
[
i
].
begin
(),
bonded12
[
i
].
end
());
}
}
}
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
exclusions
[
i
]
)
if
(
*
iter
<
i
)
if
(
j
<
i
)
addExclusion
(
*
iter
,
i
);
addExclusion
(
j
,
i
);
}
}
int
CustomNonbondedForce
::
addTabulatedFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
int
CustomNonbondedForce
::
addTabulatedFunction
(
const
std
::
string
&
name
,
TabulatedFunction
*
function
)
{
...
...
openmmapi/src/Force.cpp
View file @
08e8b206
...
@@ -54,18 +54,16 @@ bool Force::usesPeriodicBoundaryConditions() const {
...
@@ -54,18 +54,16 @@ bool Force::usesPeriodicBoundaryConditions() const {
}
}
ForceImpl
&
Force
::
getImplInContext
(
Context
&
context
)
{
ForceImpl
&
Force
::
getImplInContext
(
Context
&
context
)
{
const
vector
<
ForceImpl
*>&
impls
=
context
.
getImpl
().
getForceImpls
();
for
(
auto
impl
:
context
.
getImpl
().
getForceImpls
())
for
(
int
i
=
0
;
i
<
(
int
)
impls
.
size
();
i
++
)
if
(
&
impl
->
getOwner
()
==
this
)
if
(
&
impls
[
i
]
->
getOwner
()
==
this
)
return
*
impl
;
return
*
impls
[
i
];
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
}
}
const
ForceImpl
&
Force
::
getImplInContext
(
const
Context
&
context
)
const
{
const
ForceImpl
&
Force
::
getImplInContext
(
const
Context
&
context
)
const
{
const
vector
<
ForceImpl
*>&
impls
=
context
.
getImpl
().
getForceImpls
();
for
(
auto
impl
:
context
.
getImpl
().
getForceImpls
())
for
(
int
i
=
0
;
i
<
(
int
)
impls
.
size
();
i
++
)
if
(
&
impl
->
getOwner
()
==
this
)
if
(
&
impls
[
i
]
->
getOwner
()
==
this
)
return
*
impl
;
return
*
impls
[
i
];
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
throw
OpenMMException
(
"getImplInContext: This Force is not present in the Context"
);
}
}
...
...
openmmapi/src/NonbondedForce.cpp
View file @
08e8b206
...
@@ -203,17 +203,17 @@ ForceImpl* NonbondedForce::createImpl() const {
...
@@ -203,17 +203,17 @@ ForceImpl* NonbondedForce::createImpl() const {
}
}
void
NonbondedForce
::
createExceptionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
double
coulomb14Scale
,
double
lj14Scale
)
{
void
NonbondedForce
::
createExceptionsFromBonds
(
const
vector
<
pair
<
int
,
int
>
>&
bonds
,
double
coulomb14Scale
,
double
lj14Scale
)
{
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
for
(
auto
&
bond
:
bonds
)
if
(
bond
s
[
i
]
.
first
<
0
||
bond
s
[
i
]
.
second
<
0
||
bond
s
[
i
]
.
first
>=
particles
.
size
()
||
bond
s
[
i
]
.
second
>=
particles
.
size
())
if
(
bond
.
first
<
0
||
bond
.
second
<
0
||
bond
.
first
>=
particles
.
size
()
||
bond
.
second
>=
particles
.
size
())
throw
OpenMMException
(
"createExceptionsFromBonds: Illegal particle index in list of bonds"
);
throw
OpenMMException
(
"createExceptionsFromBonds: Illegal particle index in list of bonds"
);
// Find particles separated by 1, 2, or 3 bonds.
// Find particles separated by 1, 2, or 3 bonds.
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
exclusions
(
particles
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
vector
<
set
<
int
>
>
bonded12
(
exclusions
.
size
());
for
(
int
i
=
0
;
i
<
(
int
)
bonds
.
size
();
++
i
)
{
for
(
auto
&
bond
:
bonds
)
{
bonded12
[
bond
s
[
i
]
.
first
].
insert
(
bond
s
[
i
]
.
second
);
bonded12
[
bond
.
first
].
insert
(
bond
.
second
);
bonded12
[
bond
s
[
i
]
.
second
].
insert
(
bond
s
[
i
]
.
first
);
bonded12
[
bond
.
second
].
insert
(
bond
.
first
);
}
}
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
addExclusionsToSet
(
bonded12
,
exclusions
[
i
],
i
,
i
,
2
);
addExclusionsToSet
(
bonded12
,
exclusions
[
i
],
i
,
i
,
2
);
...
@@ -223,33 +223,34 @@ void NonbondedForce::createExceptionsFromBonds(const vector<pair<int, int> >& bo
...
@@ -223,33 +223,34 @@ void NonbondedForce::createExceptionsFromBonds(const vector<pair<int, int> >& bo
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
(
int
)
exclusions
.
size
();
++
i
)
{
set
<
int
>
bonded13
;
set
<
int
>
bonded13
;
addExclusionsToSet
(
bonded12
,
bonded13
,
i
,
i
,
1
);
addExclusionsToSet
(
bonded12
,
bonded13
,
i
,
i
,
1
);
for
(
set
<
int
>::
const_iterator
iter
=
exclusions
[
i
].
begin
();
iter
!=
exclusions
[
i
].
end
();
++
iter
)
for
(
int
j
:
exclusions
[
i
])
{
if
(
*
iter
<
i
)
{
if
(
j
<
i
)
{
if
(
bonded13
.
find
(
*
iter
)
==
bonded13
.
end
())
{
if
(
bonded13
.
find
(
j
)
==
bonded13
.
end
())
{
// This is a 1-4 interaction.
// This is a 1-4 interaction.
const
ParticleInfo
&
particle1
=
particles
[
*
iter
];
const
ParticleInfo
&
particle1
=
particles
[
j
];
const
ParticleInfo
&
particle2
=
particles
[
i
];
const
ParticleInfo
&
particle2
=
particles
[
i
];
const
double
chargeProd
=
coulomb14Scale
*
particle1
.
charge
*
particle2
.
charge
;
const
double
chargeProd
=
coulomb14Scale
*
particle1
.
charge
*
particle2
.
charge
;
const
double
sigma
=
0.5
*
(
particle1
.
sigma
+
particle2
.
sigma
);
const
double
sigma
=
0.5
*
(
particle1
.
sigma
+
particle2
.
sigma
);
const
double
epsilon
=
lj14Scale
*
std
::
sqrt
(
particle1
.
epsilon
*
particle2
.
epsilon
);
const
double
epsilon
=
lj14Scale
*
std
::
sqrt
(
particle1
.
epsilon
*
particle2
.
epsilon
);
addException
(
*
iter
,
i
,
chargeProd
,
sigma
,
epsilon
);
addException
(
j
,
i
,
chargeProd
,
sigma
,
epsilon
);
}
}
else
{
else
{
// This interaction should be completely excluded.
// This interaction should be completely excluded.
addException
(
*
iter
,
i
,
0.0
,
1.0
,
0.0
);
addException
(
j
,
i
,
0.0
,
1.0
,
0.0
);
}
}
}
}
}
}
}
}
}
void
NonbondedForce
::
addExclusionsToSet
(
const
vector
<
set
<
int
>
>&
bonded12
,
set
<
int
>&
exclusions
,
int
baseParticle
,
int
fromParticle
,
int
currentLevel
)
const
{
void
NonbondedForce
::
addExclusionsToSet
(
const
vector
<
set
<
int
>
>&
bonded12
,
set
<
int
>&
exclusions
,
int
baseParticle
,
int
fromParticle
,
int
currentLevel
)
const
{
for
(
set
<
int
>::
const_iterator
iter
=
bonded12
[
fromParticle
].
begin
();
iter
!=
bonded12
[
fromParticle
]
.
end
();
++
iter
)
{
for
(
int
i
:
bonded12
[
fromParticle
])
{
if
(
*
iter
!=
baseParticle
)
if
(
i
!=
baseParticle
)
exclusions
.
insert
(
*
iter
);
exclusions
.
insert
(
i
);
if
(
currentLevel
>
0
)
if
(
currentLevel
>
0
)
addExclusionsToSet
(
bonded12
,
exclusions
,
baseParticle
,
*
iter
,
currentLevel
-
1
);
addExclusionsToSet
(
bonded12
,
exclusions
,
baseParticle
,
i
,
currentLevel
-
1
);
}
}
}
}
...
...
openmmapi/src/System.cpp
View file @
08e8b206
...
@@ -45,10 +45,10 @@ System::System() {
...
@@ -45,10 +45,10 @@ System::System() {
}
}
System
::~
System
()
{
System
::~
System
()
{
for
(
int
i
=
0
;
i
<
(
int
)
forces
.
size
();
++
i
)
for
(
auto
force
:
forces
)
delete
force
s
[
i
]
;
delete
force
;
for
(
int
i
=
0
;
i
<
(
int
)
virtualSites
.
size
();
++
i
)
for
(
auto
site
:
virtualSites
)
delete
virtualSites
[
i
]
;
delete
site
;
}
}
double
System
::
getParticleMass
(
int
index
)
const
{
double
System
::
getParticleMass
(
int
index
)
const
{
...
...
Prev
1
2
3
4
5
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