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
0fa56f2e
Commit
0fa56f2e
authored
Apr 13, 2016
by
peastman
Browse files
Merge pull request #1461 from peastman/periodic
Allow periodic boundary conditions for bonded forces
parents
4bd2f9d2
b458028f
Changes
69
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
344 additions
and
109 deletions
+344
-109
platforms/reference/include/ReferenceCustomCentroidBondIxn.h
platforms/reference/include/ReferenceCustomCentroidBondIxn.h
+13
-1
platforms/reference/include/ReferenceCustomCompoundBondIxn.h
platforms/reference/include/ReferenceCustomCompoundBondIxn.h
+13
-1
platforms/reference/include/ReferenceCustomTorsionIxn.h
platforms/reference/include/ReferenceCustomTorsionIxn.h
+13
-1
platforms/reference/include/ReferenceHarmonicBondIxn.h
platforms/reference/include/ReferenceHarmonicBondIxn.h
+14
-1
platforms/reference/include/ReferenceKernels.h
platforms/reference/include/ReferenceKernels.h
+11
-1
platforms/reference/include/ReferenceProperDihedralBond.h
platforms/reference/include/ReferenceProperDihedralBond.h
+14
-1
platforms/reference/include/ReferenceRbDihedralBond.h
platforms/reference/include/ReferenceRbDihedralBond.h
+14
-1
platforms/reference/src/ReferenceKernels.cpp
platforms/reference/src/ReferenceKernels.cpp
+32
-2
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
...ms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
+16
-3
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
.../reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
+25
-8
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
.../reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
+16
-10
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
...s/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
+12
-9
platforms/reference/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
+13
-3
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
...nce/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
+13
-3
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
...eference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
+18
-11
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
...reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
+12
-16
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
...erence/src/SimTKReference/ReferenceProperDihedralBond.cpp
+18
-18
platforms/reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
.../reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
+18
-18
plugins/amoeba/platforms/cuda/src/AmoebaCudaKernels.cpp
plugins/amoeba/platforms/cuda/src/AmoebaCudaKernels.cpp
+2
-0
tests/TestCMAPTorsionForce.h
tests/TestCMAPTorsionForce.h
+57
-1
No files found.
platforms/reference/include/ReferenceCustomCentroidBondIxn.h
View file @
0fa56f2e
/* Portions copyright (c) 2009-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -50,6 +50,8 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
std
::
vector
<
DistanceTermInfo
>
distanceTerms
;
std
::
vector
<
AngleTermInfo
>
angleTerms
;
std
::
vector
<
DihedralTermInfo
>
dihedralTerms
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
...
...
@@ -94,6 +96,16 @@ class ReferenceCustomCentroidBondIxn : public ReferenceBondIxn {
~
ReferenceCustomCentroidBondIxn
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Get the list of groups in each bond.
...
...
platforms/reference/include/ReferenceCustomCompoundBondIxn.h
View file @
0fa56f2e
/* Portions copyright (c) 2009-201
2
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -48,6 +48,8 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
std
::
vector
<
DistanceTermInfo
>
distanceTerms
;
std
::
vector
<
AngleTermInfo
>
angleTerms
;
std
::
vector
<
DihedralTermInfo
>
dihedralTerms
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
...
...
@@ -91,6 +93,16 @@ class ReferenceCustomCompoundBondIxn : public ReferenceBondIxn {
~
ReferenceCustomCompoundBondIxn
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Get the list atoms in each bond.
...
...
platforms/reference/include/ReferenceCustomTorsionIxn.h
View file @
0fa56f2e
/* Portions copyright (c) 2010-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2010-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -39,6 +39,8 @@ class ReferenceCustomTorsionIxn : public ReferenceBondIxn {
double
*
energyTheta
;
double
*
forceTheta
;
int
numParameters
;
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
public:
...
...
@@ -59,6 +61,16 @@ class ReferenceCustomTorsionIxn : public ReferenceBondIxn {
~
ReferenceCustomTorsionIxn
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Custom Torsion Ixn
...
...
platforms/reference/include/ReferenceHarmonicBondIxn.h
View file @
0fa56f2e
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -33,6 +33,9 @@ class ReferenceHarmonicBondIxn : public ReferenceBondIxn {
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
public:
/**---------------------------------------------------------------------------------------
...
...
@@ -51,6 +54,16 @@ class ReferenceHarmonicBondIxn : public ReferenceBondIxn {
~
ReferenceHarmonicBondIxn
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Harmonic Bond Ixn
...
...
platforms/reference/include/ReferenceKernels.h
View file @
0fa56f2e
...
...
@@ -9,7 +9,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2008-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -280,6 +280,7 @@ private:
int
numBonds
;
int
**
bondIndexArray
;
RealOpenMM
**
bondParamArray
;
bool
usePeriodic
;
};
/**
...
...
@@ -319,6 +320,7 @@ private:
RealOpenMM
**
bondParamArray
;
Lepton
::
CompiledExpression
energyExpression
,
forceExpression
;
std
::
vector
<
std
::
string
>
parameterNames
,
globalParameterNames
;
bool
usePeriodic
;
};
/**
...
...
@@ -356,6 +358,7 @@ private:
int
numAngles
;
int
**
angleIndexArray
;
RealOpenMM
**
angleParamArray
;
bool
usePeriodic
;
};
/**
...
...
@@ -395,6 +398,7 @@ private:
RealOpenMM
**
angleParamArray
;
Lepton
::
CompiledExpression
energyExpression
,
forceExpression
;
std
::
vector
<
std
::
string
>
parameterNames
,
globalParameterNames
;
bool
usePeriodic
;
};
/**
...
...
@@ -432,6 +436,7 @@ private:
int
numTorsions
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
bool
usePeriodic
;
};
/**
...
...
@@ -469,6 +474,7 @@ private:
int
numTorsions
;
int
**
torsionIndexArray
;
RealOpenMM
**
torsionParamArray
;
bool
usePeriodic
;
};
/**
...
...
@@ -505,6 +511,7 @@ private:
std
::
vector
<
std
::
vector
<
std
::
vector
<
RealOpenMM
>
>
>
coeff
;
std
::
vector
<
int
>
torsionMaps
;
std
::
vector
<
std
::
vector
<
int
>
>
torsionIndices
;
bool
usePeriodic
;
};
/**
...
...
@@ -544,6 +551,7 @@ private:
RealOpenMM
**
torsionParamArray
;
Lepton
::
CompiledExpression
energyExpression
,
forceExpression
;
std
::
vector
<
std
::
string
>
parameterNames
,
globalParameterNames
;
bool
usePeriodic
;
};
/**
...
...
@@ -860,6 +868,7 @@ private:
RealOpenMM
**
bondParamArray
;
ReferenceCustomCentroidBondIxn
*
ixn
;
std
::
vector
<
std
::
string
>
globalParameterNames
;
bool
usePeriodic
;
};
/**
...
...
@@ -898,6 +907,7 @@ private:
RealOpenMM
**
bondParamArray
;
ReferenceCustomCompoundBondIxn
*
ixn
;
std
::
vector
<
std
::
string
>
globalParameterNames
;
bool
usePeriodic
;
};
/**
...
...
platforms/reference/include/ReferenceProperDihedralBond.h
View file @
0fa56f2e
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -33,6 +33,9 @@ class OPENMM_EXPORT ReferenceProperDihedralBond : public ReferenceBondIxn {
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
public:
/**---------------------------------------------------------------------------------------
...
...
@@ -51,6 +54,16 @@ class OPENMM_EXPORT ReferenceProperDihedralBond : public ReferenceBondIxn {
~
ReferenceProperDihedralBond
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate proper dihedral bond ixn
...
...
platforms/reference/include/ReferenceRbDihedralBond.h
View file @
0fa56f2e
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -33,6 +33,9 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn {
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
public:
/**---------------------------------------------------------------------------------------
...
...
@@ -51,6 +54,16 @@ class OPENMM_EXPORT ReferenceRbDihedralBond : public ReferenceBondIxn {
~
ReferenceRbDihedralBond
();
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Ryckaert-Bellemans bond ixn
...
...
platforms/reference/src/ReferenceKernels.cpp
View file @
0fa56f2e
...
...
@@ -370,6 +370,7 @@ void ReferenceCalcHarmonicBondForceKernel::initialize(const System& system, cons
bondParamArray
[
i
][
0
]
=
(
RealOpenMM
)
length
;
bondParamArray
[
i
][
1
]
=
(
RealOpenMM
)
k
;
}
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
double
ReferenceCalcHarmonicBondForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
...
@@ -378,6 +379,8 @@ double ReferenceCalcHarmonicBondForceKernel::execute(ContextImpl& context, bool
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceHarmonicBondIxn
harmonicBond
;
if
(
usePeriodic
)
harmonicBond
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
harmonicBond
);
return
energy
;
}
...
...
@@ -409,6 +412,7 @@ ReferenceCalcCustomBondForceKernel::~ReferenceCalcCustomBondForceKernel() {
void
ReferenceCalcCustomBondForceKernel
::
initialize
(
const
System
&
system
,
const
CustomBondForce
&
force
)
{
numBonds
=
force
.
getNumBonds
();
int
numParameters
=
force
.
getNumPerBondParameters
();
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
// Build the arrays.
...
...
@@ -448,8 +452,10 @@ double ReferenceCalcCustomBondForceKernel::execute(ContextImpl& context, bool in
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceCustomBondIxn
harmonicBond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
harmonicBond
);
ReferenceCustomBondIxn
bond
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
if
(
usePeriodic
)
bond
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numBonds
,
bondIndexArray
,
posData
,
bondParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
bond
);
return
energy
;
}
...
...
@@ -490,6 +496,7 @@ void ReferenceCalcHarmonicAngleForceKernel::initialize(const System& system, con
angleParamArray
[
i
][
0
]
=
(
RealOpenMM
)
angle
;
angleParamArray
[
i
][
1
]
=
(
RealOpenMM
)
k
;
}
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
double
ReferenceCalcHarmonicAngleForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
...
@@ -498,6 +505,8 @@ double ReferenceCalcHarmonicAngleForceKernel::execute(ContextImpl& context, bool
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceAngleBondIxn
angleBond
;
if
(
usePeriodic
)
angleBond
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
angleBond
);
return
energy
;
}
...
...
@@ -527,6 +536,7 @@ ReferenceCalcCustomAngleForceKernel::~ReferenceCalcCustomAngleForceKernel() {
void
ReferenceCalcCustomAngleForceKernel
::
initialize
(
const
System
&
system
,
const
CustomAngleForce
&
force
)
{
numAngles
=
force
.
getNumAngles
();
int
numParameters
=
force
.
getNumPerAngleParameters
();
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
// Build the arrays.
...
...
@@ -568,6 +578,8 @@ double ReferenceCalcCustomAngleForceKernel::execute(ContextImpl& context, bool i
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceCustomAngleIxn
customAngle
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
if
(
usePeriodic
)
customAngle
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numAngles
,
angleIndexArray
,
posData
,
angleParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
customAngle
);
return
energy
;
}
...
...
@@ -611,6 +623,7 @@ void ReferenceCalcPeriodicTorsionForceKernel::initialize(const System& system, c
torsionParamArray
[
i
][
1
]
=
(
RealOpenMM
)
phase
;
torsionParamArray
[
i
][
2
]
=
(
RealOpenMM
)
periodicity
;
}
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
double
ReferenceCalcPeriodicTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
...
@@ -619,6 +632,8 @@ double ReferenceCalcPeriodicTorsionForceKernel::execute(ContextImpl& context, bo
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceProperDihedralBond
periodicTorsionBond
;
if
(
usePeriodic
)
periodicTorsionBond
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
periodicTorsionBond
);
return
energy
;
}
...
...
@@ -665,6 +680,7 @@ void ReferenceCalcRBTorsionForceKernel::initialize(const System& system, const R
torsionParamArray
[
i
][
4
]
=
(
RealOpenMM
)
c4
;
torsionParamArray
[
i
][
5
]
=
(
RealOpenMM
)
c5
;
}
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
double
ReferenceCalcRBTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
...
@@ -673,6 +689,8 @@ double ReferenceCalcRBTorsionForceKernel::execute(ContextImpl& context, bool inc
RealOpenMM
energy
=
0
;
ReferenceBondForce
refBondForce
;
ReferenceRbDihedralBond
rbTorsionBond
;
if
(
usePeriodic
)
rbTorsionBond
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
rbTorsionBond
);
return
energy
;
}
...
...
@@ -722,6 +740,7 @@ void ReferenceCalcCMAPTorsionForceKernel::initialize(const System& system, const
force
.
getTorsionParameters
(
i
,
torsionMaps
[
i
],
torsionIndices
[
i
][
0
],
torsionIndices
[
i
][
1
],
torsionIndices
[
i
][
2
],
torsionIndices
[
i
][
3
],
torsionIndices
[
i
][
4
],
torsionIndices
[
i
][
5
],
torsionIndices
[
i
][
6
],
torsionIndices
[
i
][
7
]);
}
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
}
double
ReferenceCalcCMAPTorsionForceKernel
::
execute
(
ContextImpl
&
context
,
bool
includeForces
,
bool
includeEnergy
)
{
...
...
@@ -729,6 +748,8 @@ double ReferenceCalcCMAPTorsionForceKernel::execute(ContextImpl& context, bool i
vector
<
RealVec
>&
forceData
=
extractForces
(
context
);
RealOpenMM
totalEnergy
=
0
;
ReferenceCMAPTorsionIxn
torsion
(
coeff
,
torsionMaps
,
torsionIndices
);
if
(
usePeriodic
)
torsion
.
setPeriodic
(
extractBoxVectors
(
context
));
torsion
.
calculateIxn
(
posData
,
forceData
,
&
totalEnergy
);
return
totalEnergy
;
}
...
...
@@ -775,6 +796,7 @@ ReferenceCalcCustomTorsionForceKernel::~ReferenceCalcCustomTorsionForceKernel()
void
ReferenceCalcCustomTorsionForceKernel
::
initialize
(
const
System
&
system
,
const
CustomTorsionForce
&
force
)
{
numTorsions
=
force
.
getNumTorsions
();
int
numParameters
=
force
.
getNumPerTorsionParameters
();
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
// Build the arrays.
...
...
@@ -817,6 +839,8 @@ double ReferenceCalcCustomTorsionForceKernel::execute(ContextImpl& context, bool
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
ReferenceBondForce
refBondForce
;
ReferenceCustomTorsionIxn
customTorsion
(
energyExpression
,
forceExpression
,
parameterNames
,
globalParameters
);
if
(
usePeriodic
)
customTorsion
.
setPeriodic
(
extractBoxVectors
(
context
));
refBondForce
.
calculateForce
(
numTorsions
,
torsionIndexArray
,
posData
,
torsionParamArray
,
forceData
,
includeEnergy
?
&
energy
:
NULL
,
customTorsion
);
return
energy
;
}
...
...
@@ -1644,6 +1668,7 @@ ReferenceCalcCustomCentroidBondForceKernel::~ReferenceCalcCustomCentroidBondForc
}
void
ReferenceCalcCustomCentroidBondForceKernel
::
initialize
(
const
System
&
system
,
const
CustomCentroidBondForce
&
force
)
{
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
// Build the arrays.
...
...
@@ -1697,6 +1722,8 @@ double ReferenceCalcCustomCentroidBondForceKernel::execute(ContextImpl& context,
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
if
(
usePeriodic
)
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
ixn
->
calculatePairIxn
(
posData
,
bondParamArray
,
globalParameters
,
forceData
,
includeEnergy
?
&
energy
:
NULL
);
return
energy
;
}
...
...
@@ -1728,6 +1755,7 @@ ReferenceCalcCustomCompoundBondForceKernel::~ReferenceCalcCustomCompoundBondForc
}
void
ReferenceCalcCustomCompoundBondForceKernel
::
initialize
(
const
System
&
system
,
const
CustomCompoundBondForce
&
force
)
{
usePeriodic
=
force
.
usesPeriodicBoundaryConditions
();
// Build the arrays.
...
...
@@ -1774,6 +1802,8 @@ double ReferenceCalcCustomCompoundBondForceKernel::execute(ContextImpl& context,
map
<
string
,
double
>
globalParameters
;
for
(
int
i
=
0
;
i
<
(
int
)
globalParameterNames
.
size
();
i
++
)
globalParameters
[
globalParameterNames
[
i
]]
=
context
.
getParameter
(
globalParameterNames
[
i
]);
if
(
usePeriodic
)
ixn
->
setPeriodic
(
extractBoxVectors
(
context
));
ixn
->
calculatePairIxn
(
posData
,
bondParamArray
,
globalParameters
,
forceData
,
includeEnergy
?
&
energy
:
NULL
);
return
energy
;
}
...
...
platforms/reference/src/SimTKReference/ReferenceAngleBondIxn.cpp
View file @
0fa56f2e
...
...
@@ -38,7 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceAngleBondIxn
::
ReferenceAngleBondIxn
()
{
ReferenceAngleBondIxn
::
ReferenceAngleBondIxn
()
:
usePeriodic
(
false
)
{
// ---------------------------------------------------------------------------------------
...
...
@@ -64,6 +64,13 @@ ReferenceAngleBondIxn::~ReferenceAngleBondIxn() {
}
void
ReferenceAngleBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
Get dEdR and energy term for angle bond
...
...
@@ -145,8 +152,14 @@ void ReferenceAngleBondIxn::calculateBondIxn(int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
[
1
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
1
]);
}
RealOpenMM
pVector
[
threeI
];
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
deltaR
[
1
],
pVector
);
...
...
platforms/reference/src/SimTKReference/ReferenceCMAPTorsionIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2010 Stanford University and Simbios.
/* Portions copyright (c) 2010
-2016
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -36,7 +36,14 @@ using namespace OpenMM;
ReferenceCMAPTorsionIxn
::
ReferenceCMAPTorsionIxn
(
const
vector
<
vector
<
vector
<
RealOpenMM
>
>
>&
coeff
,
const
vector
<
int
>&
torsionMaps
,
const
vector
<
vector
<
int
>
>&
torsionIndices
)
:
coeff
(
coeff
),
torsionMaps
(
torsionMaps
),
torsionIndices
(
torsionIndices
)
{
coeff
(
coeff
),
torsionMaps
(
torsionMaps
),
torsionIndices
(
torsionIndices
),
usePeriodic
(
false
)
{
}
void
ReferenceCMAPTorsionIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -83,13 +90,23 @@ void ReferenceCMAPTorsionIxn::calculateOneIxn(int index, vector<RealVec>& atomCo
// Compute deltas between the various atoms involved.
RealOpenMM
deltaA
[
3
][
ReferenceForce
::
LastDeltaRIndex
];
RealOpenMM
deltaB
[
3
][
ReferenceForce
::
LastDeltaRIndex
];
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
a2
],
atomCoordinates
[
a1
],
boxVectors
,
deltaA
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
a2
],
atomCoordinates
[
a3
],
boxVectors
,
deltaA
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
a4
],
atomCoordinates
[
a3
],
boxVectors
,
deltaA
[
2
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
b2
],
atomCoordinates
[
b1
],
boxVectors
,
deltaB
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
b2
],
atomCoordinates
[
b3
],
boxVectors
,
deltaB
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
b4
],
atomCoordinates
[
b3
],
boxVectors
,
deltaB
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
a2
],
atomCoordinates
[
a1
],
deltaA
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
a2
],
atomCoordinates
[
a3
],
deltaA
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
a4
],
atomCoordinates
[
a3
],
deltaA
[
2
]);
RealOpenMM
deltaB
[
3
][
ReferenceForce
::
LastDeltaRIndex
];
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
b2
],
atomCoordinates
[
b1
],
deltaB
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
b2
],
atomCoordinates
[
b3
],
deltaB
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
b4
],
atomCoordinates
[
b3
],
deltaB
[
2
]);
}
// Visual Studio complains if crossProduct declared as 'crossProduct[2][3]'
...
...
platforms/reference/src/SimTKReference/ReferenceCustomAngleIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2010-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2010-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -39,7 +39,7 @@ using namespace std;
ReferenceCustomAngleIxn
::
ReferenceCustomAngleIxn
(
const
Lepton
::
CompiledExpression
&
energyExpression
,
const
Lepton
::
CompiledExpression
&
forceExpression
,
const
vector
<
string
>&
parameterNames
,
map
<
string
,
double
>
globalParameters
)
:
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
{
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
,
usePeriodic
(
false
)
{
energyTheta
=
ReferenceForce
::
getVariablePointer
(
this
->
energyExpression
,
"theta"
);
forceTheta
=
ReferenceForce
::
getVariablePointer
(
this
->
forceExpression
,
"theta"
);
...
...
@@ -61,13 +61,13 @@ ReferenceCustomAngleIxn::ReferenceCustomAngleIxn(const Lepton::CompiledExpressio
--------------------------------------------------------------------------------------- */
ReferenceCustomAngleIxn
::~
ReferenceCustomAngleIxn
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomAngleIxn::~ReferenceCustomAngleIxn";
// ---------------------------------------------------------------------------------------
void
ReferenceCustomAngleIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -106,8 +106,14 @@ void ReferenceCustomAngleIxn::calculateBondIxn(int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
[
1
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomCIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
[
1
]);
}
RealOpenMM
pVector
[
3
];
SimTKOpenMMUtilities
::
crossProductVector3
(
deltaR
[
0
],
deltaR
[
1
],
pVector
);
RealOpenMM
rp
=
SQRT
(
DOT3
(
pVector
,
pVector
));
...
...
platforms/reference/src/SimTKReference/ReferenceCustomBondIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2009-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -40,7 +40,7 @@ using namespace OpenMM;
ReferenceCustomBondIxn
::
ReferenceCustomBondIxn
(
const
Lepton
::
CompiledExpression
&
energyExpression
,
const
Lepton
::
CompiledExpression
&
forceExpression
,
const
vector
<
string
>&
parameterNames
,
map
<
string
,
double
>
globalParameters
)
:
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
{
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
,
usePeriodic
(
false
)
{
energyR
=
ReferenceForce
::
getVariablePointer
(
this
->
energyExpression
,
"r"
);
forceR
=
ReferenceForce
::
getVariablePointer
(
this
->
forceExpression
,
"r"
);
numParameters
=
parameterNames
.
size
();
...
...
@@ -61,13 +61,13 @@ ReferenceCustomBondIxn::ReferenceCustomBondIxn(const Lepton::CompiledExpression&
--------------------------------------------------------------------------------------- */
ReferenceCustomBondIxn
::~
ReferenceCustomBondIxn
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomBondIxn::~ReferenceCustomBondIxn";
// ---------------------------------------------------------------------------------------
void
ReferenceCustomBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -108,6 +108,9 @@ void ReferenceCustomBondIxn::calculateBondIxn(int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
);
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
ReferenceForce
::
setVariable
(
energyR
,
deltaR
[
ReferenceForce
::
RIndex
]);
...
...
platforms/reference/src/SimTKReference/ReferenceCustomCentroidBondIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2009-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -41,7 +41,7 @@ ReferenceCustomCentroidBondIxn::ReferenceCustomCentroidBondIxn(int numGroupsPerB
const
vector
<
vector
<
double
>
>&
normalizedWeights
,
const
vector
<
vector
<
int
>
>&
bondGroups
,
const
Lepton
::
ParsedExpression
&
energyExpression
,
const
vector
<
string
>&
bondParameterNames
,
const
map
<
string
,
vector
<
int
>
>&
distances
,
const
map
<
string
,
vector
<
int
>
>&
angles
,
const
map
<
string
,
vector
<
int
>
>&
dihedrals
)
:
groupAtoms
(
groupAtoms
),
normalizedWeights
(
normalizedWeights
),
bondGroups
(
bondGroups
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
{
groupAtoms
(
groupAtoms
),
normalizedWeights
(
normalizedWeights
),
bondGroups
(
bondGroups
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
,
usePeriodic
(
false
)
{
for
(
int
i
=
0
;
i
<
numGroupsPerBond
;
i
++
)
{
stringstream
xname
,
yname
,
zname
;
xname
<<
'x'
<<
(
i
+
1
);
...
...
@@ -62,6 +62,13 @@ ReferenceCustomCentroidBondIxn::ReferenceCustomCentroidBondIxn(int numGroupsPerB
ReferenceCustomCentroidBondIxn
::~
ReferenceCustomCentroidBondIxn
()
{
}
void
ReferenceCustomCentroidBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
void
ReferenceCustomCentroidBondIxn
::
calculatePairIxn
(
vector
<
RealVec
>&
atomCoordinates
,
RealOpenMM
**
bondParameters
,
const
map
<
string
,
double
>&
globalParameters
,
vector
<
RealVec
>&
forces
,
RealOpenMM
*
totalEnergy
)
const
{
...
...
@@ -215,6 +222,9 @@ void ReferenceCustomCentroidBondIxn::calculateOneIxn(int bond, vector<RealVec>&
}
void
ReferenceCustomCentroidBondIxn
::
computeDelta
(
int
group1
,
int
group2
,
RealOpenMM
*
delta
,
vector
<
RealVec
>&
groupCenters
)
const
{
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
groupCenters
[
group1
],
groupCenters
[
group2
],
boxVectors
,
delta
);
else
ReferenceForce
::
getDeltaR
(
groupCenters
[
group1
],
groupCenters
[
group2
],
delta
);
}
...
...
platforms/reference/src/SimTKReference/ReferenceCustomCompoundBondIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2009-201
5
Stanford University and Simbios.
/* Portions copyright (c) 2009-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -46,7 +46,7 @@ using namespace OpenMM;
ReferenceCustomCompoundBondIxn
::
ReferenceCustomCompoundBondIxn
(
int
numParticlesPerBond
,
const
vector
<
vector
<
int
>
>&
bondAtoms
,
const
Lepton
::
ParsedExpression
&
energyExpression
,
const
vector
<
string
>&
bondParameterNames
,
const
map
<
string
,
vector
<
int
>
>&
distances
,
const
map
<
string
,
vector
<
int
>
>&
angles
,
const
map
<
string
,
vector
<
int
>
>&
dihedrals
)
:
bondAtoms
(
bondAtoms
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
{
bondAtoms
(
bondAtoms
),
energyExpression
(
energyExpression
.
createProgram
()),
bondParamNames
(
bondParameterNames
)
,
usePeriodic
(
false
)
{
for
(
int
i
=
0
;
i
<
numParticlesPerBond
;
i
++
)
{
stringstream
xname
,
yname
,
zname
;
xname
<<
'x'
<<
(
i
+
1
);
...
...
@@ -73,6 +73,13 @@ ReferenceCustomCompoundBondIxn::ReferenceCustomCompoundBondIxn(int numParticlesP
ReferenceCustomCompoundBondIxn
::~
ReferenceCustomCompoundBondIxn
()
{
}
void
ReferenceCustomCompoundBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
Calculate custom hbond interaction
...
...
@@ -232,6 +239,9 @@ void ReferenceCustomCompoundBondIxn::calculateOneIxn(int bond, vector<RealVec>&
}
void
ReferenceCustomCompoundBondIxn
::
computeDelta
(
int
atom1
,
int
atom2
,
RealOpenMM
*
delta
,
vector
<
RealVec
>&
atomCoordinates
)
const
{
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atom1
],
atomCoordinates
[
atom2
],
boxVectors
,
delta
);
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atom1
],
atomCoordinates
[
atom2
],
delta
);
}
...
...
platforms/reference/src/SimTKReference/ReferenceCustomTorsionIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2010-201
3
Stanford University and Simbios.
/* Portions copyright (c) 2010-201
6
Stanford University and Simbios.
* Contributors: Peter Eastman
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -39,7 +39,7 @@ using namespace OpenMM;
ReferenceCustomTorsionIxn
::
ReferenceCustomTorsionIxn
(
const
Lepton
::
CompiledExpression
&
energyExpression
,
const
Lepton
::
CompiledExpression
&
forceExpression
,
const
vector
<
string
>&
parameterNames
,
map
<
string
,
double
>
globalParameters
)
:
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
{
energyExpression
(
energyExpression
),
forceExpression
(
forceExpression
)
,
usePeriodic
(
false
)
{
energyTheta
=
ReferenceForce
::
getVariablePointer
(
this
->
energyExpression
,
"theta"
);
forceTheta
=
ReferenceForce
::
getVariablePointer
(
this
->
forceExpression
,
"theta"
);
...
...
@@ -61,13 +61,13 @@ ReferenceCustomTorsionIxn::ReferenceCustomTorsionIxn(const Lepton::CompiledExpre
--------------------------------------------------------------------------------------- */
ReferenceCustomTorsionIxn
::~
ReferenceCustomTorsionIxn
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceCustomTorsionIxn::~ReferenceCustomTorsionIxn";
// ---------------------------------------------------------------------------------------
void
ReferenceCustomTorsionIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -107,9 +107,16 @@ void ReferenceCustomTorsionIxn::calculateBondIxn(int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
}
// Visual Studio complains if crossProduct declared as 'crossProduct[2][3]'
...
...
platforms/reference/src/SimTKReference/ReferenceHarmonicBondIxn.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -38,14 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
()
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
ReferenceHarmonicBondIxn
::
ReferenceHarmonicBondIxn
()
:
usePeriodic
(
false
)
{
}
/**---------------------------------------------------------------------------------------
...
...
@@ -55,13 +48,13 @@ ReferenceHarmonicBondIxn::ReferenceHarmonicBondIxn() {
--------------------------------------------------------------------------------------- */
ReferenceHarmonicBondIxn
::~
ReferenceHarmonicBondIxn
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceHarmonicBondIxn::~ReferenceHarmonicBondIxn";
// ---------------------------------------------------------------------------------------
void
ReferenceHarmonicBondIxn
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -99,6 +92,9 @@ void ReferenceHarmonicBondIxn::calculateBondIxn(int* atomIndices,
int
atomAIndex
=
atomIndices
[
0
];
int
atomBIndex
=
atomIndices
[
1
];
if
(
usePeriodic
)
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
boxVectors
,
deltaR
);
else
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomAIndex
],
atomCoordinates
[
atomBIndex
],
deltaR
);
// deltaIdeal = r - r_0
...
...
platforms/reference/src/SimTKReference/ReferenceProperDihedralBond.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -38,14 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceProperDihedralBond
::
ReferenceProperDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceProperDihedralBond::ReferenceProperDihedralBond";
// ---------------------------------------------------------------------------------------
ReferenceProperDihedralBond
::
ReferenceProperDihedralBond
()
:
usePeriodic
(
false
)
{
}
/**---------------------------------------------------------------------------------------
...
...
@@ -55,13 +48,13 @@ ReferenceProperDihedralBond::ReferenceProperDihedralBond() {
--------------------------------------------------------------------------------------- */
ReferenceProperDihedralBond
::~
ReferenceProperDihedralBond
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceProperDihedralBond::~ReferenceProperDihedralBond";
// ---------------------------------------------------------------------------------------
void
ReferenceProperDihedralBond
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -110,9 +103,16 @@ void ReferenceProperDihedralBond::calculateBondIxn(int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
}
RealOpenMM
dotDihedral
;
RealOpenMM
signOfAngle
;
...
...
platforms/reference/src/SimTKReference/ReferenceRbDihedralBond.cpp
View file @
0fa56f2e
/* Portions copyright (c) 2006 Stanford University and Simbios.
/* Portions copyright (c) 2006
-2016
Stanford University and Simbios.
* Contributors: Pande Group
*
* Permission is hereby granted, free of charge, to any person obtaining
...
...
@@ -38,14 +38,7 @@ using namespace OpenMM;
--------------------------------------------------------------------------------------- */
ReferenceRbDihedralBond
::
ReferenceRbDihedralBond
()
{
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceRbDihedralBond::ReferenceRbDihedralBond";
// ---------------------------------------------------------------------------------------
ReferenceRbDihedralBond
::
ReferenceRbDihedralBond
()
:
usePeriodic
(
false
)
{
}
/**---------------------------------------------------------------------------------------
...
...
@@ -55,13 +48,13 @@ ReferenceRbDihedralBond::ReferenceRbDihedralBond() {
--------------------------------------------------------------------------------------- */
ReferenceRbDihedralBond
::~
ReferenceRbDihedralBond
()
{
}
// ---------------------------------------------------------------------------------------
// static const char* methodName = "\nReferenceRbDihedralBond::~ReferenceRbDihedralBond";
// ---------------------------------------------------------------------------------------
void
ReferenceRbDihedralBond
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
...
...
@@ -112,9 +105,16 @@ void ReferenceRbDihedralBond::calculateBondIxn(int* atomIndices,
int
atomBIndex
=
atomIndices
[
1
];
int
atomCIndex
=
atomIndices
[
2
];
int
atomDIndex
=
atomIndices
[
3
];
if
(
usePeriodic
)
{
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
boxVectors
,
deltaR
[
0
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
1
]);
ReferenceForce
::
getDeltaRPeriodic
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
boxVectors
,
deltaR
[
2
]);
}
else
{
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomAIndex
],
deltaR
[
0
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomBIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
1
]);
ReferenceForce
::
getDeltaR
(
atomCoordinates
[
atomDIndex
],
atomCoordinates
[
atomCIndex
],
deltaR
[
2
]);
}
RealOpenMM
cosPhi
;
RealOpenMM
signOfAngle
;
...
...
plugins/amoeba/platforms/cuda/src/AmoebaCudaKernels.cpp
View file @
0fa56f2e
...
...
@@ -117,6 +117,7 @@ void CudaCalcAmoebaBondForceKernel::initialize(const System& system, const Amoeb
}
params
->
upload
(
paramVector
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
"0"
;
replacements
[
"COMPUTE_FORCE"
]
=
CudaAmoebaKernelSources
::
amoebaBondForce
;
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float2"
);
replacements
[
"CUBIC_K"
]
=
cu
.
doubleToString
(
force
.
getAmoebaGlobalBondCubic
());
...
...
@@ -214,6 +215,7 @@ void CudaCalcAmoebaAngleForceKernel::initialize(const System& system, const Amoe
}
params
->
upload
(
paramVector
);
map
<
string
,
string
>
replacements
;
replacements
[
"APPLY_PERIODIC"
]
=
"0"
;
replacements
[
"COMPUTE_FORCE"
]
=
CudaAmoebaKernelSources
::
amoebaAngleForce
;
replacements
[
"PARAMS"
]
=
cu
.
getBondedUtilities
().
addArgument
(
params
->
getDevicePointer
(),
"float2"
);
replacements
[
"CUBIC_K"
]
=
cu
.
doubleToString
(
force
.
getAmoebaGlobalAngleCubic
());
...
...
tests/TestCMAPTorsionForce.h
View file @
0fa56f2e
...
...
@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-201
5
Stanford University and the Authors. *
* Portions copyright (c) 2010-201
6
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -158,6 +158,61 @@ void testChangingParameters() {
ASSERT_EQUAL_TOL
(
2
-
20
*
sin
(
M_PI
/
4
),
energy
,
1e-5
);
}
void
testPeriodic
()
{
const
int
mapSize
=
36
;
// Create two systems that use periodic boundary conditions: one with a pair
// of periodic torsions, and one with a CMAP torsion that approximates the same force.
System
system1
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
system1
.
addParticle
(
1.0
);
PeriodicTorsionForce
*
periodic
=
new
PeriodicTorsionForce
();
periodic
->
addTorsion
(
0
,
1
,
2
,
3
,
2
,
M_PI
/
4
,
1.5
);
periodic
->
addTorsion
(
1
,
2
,
3
,
4
,
3
,
M_PI
/
3
,
2.0
);
periodic
->
setUsesPeriodicBoundaryConditions
(
true
);
system1
.
addForce
(
periodic
);
System
system2
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
system2
.
addParticle
(
1.0
);
CMAPTorsionForce
*
cmap
=
new
CMAPTorsionForce
();
vector
<
double
>
mapEnergy
(
mapSize
*
mapSize
);
for
(
int
i
=
0
;
i
<
mapSize
;
i
++
)
{
double
angle1
=
i
*
2
*
M_PI
/
mapSize
;
double
energy1
=
1.5
*
(
1
+
cos
(
2
*
angle1
-
M_PI
/
4
));
for
(
int
j
=
0
;
j
<
mapSize
;
j
++
)
{
double
angle2
=
j
*
2
*
M_PI
/
mapSize
;
double
energy2
=
2.0
*
(
1
+
cos
(
3
*
angle2
-
M_PI
/
3
));
mapEnergy
[
i
+
j
*
mapSize
]
=
energy1
+
energy2
;
}
}
cmap
->
addMap
(
mapSize
,
mapEnergy
);
cmap
->
addTorsion
(
0
,
0
,
1
,
2
,
3
,
1
,
2
,
3
,
4
);
cmap
->
setUsesPeriodicBoundaryConditions
(
true
);
system2
.
addForce
(
cmap
);
// Set the atoms in various positions, and verify that both systems give equal forces and energy.
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
5
);
VerletIntegrator
integrator1
(
0.01
);
VerletIntegrator
integrator2
(
0.01
);
Context
c1
(
system1
,
integrator1
,
platform
);
Context
c2
(
system2
,
integrator2
,
platform
);
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
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
));
c1
.
setPositions
(
positions
);
c2
.
setPositions
(
positions
);
State
s1
=
c1
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
s2
=
c2
.
getState
(
State
::
Forces
|
State
::
Energy
);
for
(
int
i
=
0
;
i
<
system1
.
getNumParticles
();
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
0.05
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-3
);
}
}
void
runPlatformTests
();
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -165,6 +220,7 @@ int main(int argc, char* argv[]) {
initializeTests
(
argc
,
argv
);
testCMAPTorsions
();
testChangingParameters
();
testPeriodic
();
runPlatformTests
();
}
catch
(
const
exception
&
e
)
{
...
...
Prev
1
2
3
4
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