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
8190f243
Commit
8190f243
authored
Apr 21, 2016
by
peastman
Browse files
Merge pull request #1467 from peastman/amoebaperiodic
Periodic boundary conditions for AMOEBA bonded forces
parents
fd289aae
c54126a0
Changes
68
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
462 additions
and
50 deletions
+462
-50
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.h
...e/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.h
+15
-2
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.cpp
...ence/src/SimTKReference/AmoebaReferencePiTorsionForce.cpp
+21
-7
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.h
...erence/src/SimTKReference/AmoebaReferencePiTorsionForce.h
+15
-2
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.cpp
...ce/src/SimTKReference/AmoebaReferenceStretchBendForce.cpp
+16
-3
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.h
...ence/src/SimTKReference/AmoebaReferenceStretchBendForce.h
+15
-2
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.cpp
...src/SimTKReference/AmoebaReferenceTorsionTorsionForce.cpp
+36
-12
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.h
...e/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.h
+15
-2
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaAngleForce.cpp
...atforms/reference/tests/TestReferenceAmoebaAngleForce.cpp
+54
-2
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaBondForce.cpp
...latforms/reference/tests/TestReferenceAmoebaBondForce.cpp
+46
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaInPlaneAngleForce.cpp
.../reference/tests/TestReferenceAmoebaInPlaneAngleForce.cpp
+46
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaOutOfPlaneBendForce.cpp
...eference/tests/TestReferenceAmoebaOutOfPlaneBendForce.cpp
+39
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaPiTorsionForce.cpp
...rms/reference/tests/TestReferenceAmoebaPiTorsionForce.cpp
+37
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaStretchBendForce.cpp
...s/reference/tests/TestReferenceAmoebaStretchBendForce.cpp
+37
-1
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaTorsionTorsionForce.cpp
...eference/tests/TestReferenceAmoebaTorsionTorsionForce.cpp
+40
-1
plugins/amoeba/serialization/src/AmoebaAngleForceProxy.cpp
plugins/amoeba/serialization/src/AmoebaAngleForceProxy.cpp
+5
-2
plugins/amoeba/serialization/src/AmoebaBondForceProxy.cpp
plugins/amoeba/serialization/src/AmoebaBondForceProxy.cpp
+5
-2
plugins/amoeba/serialization/src/AmoebaInPlaneAngleForceProxy.cpp
...amoeba/serialization/src/AmoebaInPlaneAngleForceProxy.cpp
+5
-2
plugins/amoeba/serialization/src/AmoebaOutOfPlaneBendForceProxy.cpp
...oeba/serialization/src/AmoebaOutOfPlaneBendForceProxy.cpp
+5
-2
plugins/amoeba/serialization/src/AmoebaPiTorsionForceProxy.cpp
...ns/amoeba/serialization/src/AmoebaPiTorsionForceProxy.cpp
+5
-2
plugins/amoeba/serialization/src/AmoebaStretchBendForceProxy.cpp
.../amoeba/serialization/src/AmoebaStretchBendForceProxy.cpp
+5
-2
No files found.
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceOutOfPlaneBendForce.h
View file @
8190f243
/* 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
...
...
@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */
AmoebaReferenceOutOfPlaneBendForce
()
{};
AmoebaReferenceOutOfPlaneBendForce
()
:
usePeriodic
(
false
)
{};
/**---------------------------------------------------------------------------------------
...
...
@@ -50,6 +50,16 @@ public:
~
AmoebaReferenceOutOfPlaneBendForce
()
{};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Amoeba out-of-plane-bend angle (force and energy)
...
...
@@ -86,6 +96,9 @@ public:
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
Calculate Amoeba Out-Of-Plane-Bend ixn (force and energy)
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.cpp
View file @
8190f243
/* 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
...
...
@@ -29,6 +28,13 @@
using
std
::
vector
;
using
namespace
OpenMM
;
void
AmoebaReferencePiTorsionForce
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
Calculate Amoeba pi-torsion ixn (force and energy)
...
...
@@ -66,11 +72,19 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
std
::
vector
<
RealOpenMM
>
deltaR
[
LastDeltaIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
}
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomA
,
deltaR
[
AD
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomB
,
deltaR
[
BD
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomF
,
deltaR
[
FC
]);
}
if
(
usePeriodic
)
{
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomD
,
positionAtomA
,
deltaR
[
AD
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomD
,
positionAtomB
,
deltaR
[
BD
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomF
,
deltaR
[
FC
],
boxVectors
);
}
else
{
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomA
,
deltaR
[
AD
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomB
,
deltaR
[
BD
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomF
,
deltaR
[
FC
]);
}
enum
{
A
,
B
,
C
,
D
,
E
,
F
,
LastAtomIndex
};
std
::
vector
<
RealOpenMM
>
d
[
LastAtomIndex
];
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferencePiTorsionForce.h
View file @
8190f243
/* 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
...
...
@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */
AmoebaReferencePiTorsionForce
()
{};
AmoebaReferencePiTorsionForce
()
:
usePeriodic
(
false
)
{};
/**---------------------------------------------------------------------------------------
...
...
@@ -50,6 +50,16 @@ public:
~
AmoebaReferencePiTorsionForce
()
{};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Amoeba torsion ixns (force and energy)
...
...
@@ -85,6 +95,9 @@ public:
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
Calculate Amoeba pi-torsion ixn (force and energy)
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.cpp
View file @
8190f243
/* 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
...
...
@@ -29,6 +29,13 @@
using
std
::
vector
;
using
namespace
OpenMM
;
void
AmoebaReferenceStretchBendForce
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
Calculate Amoeba stretch bend angle ixn (force and energy)
...
...
@@ -76,8 +83,14 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
for
(
unsigned
int
ii
=
0
;
ii
<
LastDeltaIndex
;
ii
++
)
{
deltaR
[
ii
].
resize
(
3
);
}
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomA
,
deltaR
[
AB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
]);
if
(
usePeriodic
)
{
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomB
,
positionAtomA
,
deltaR
[
AB
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
],
boxVectors
);
}
else
{
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomA
,
deltaR
[
AB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
]);
}
RealOpenMM
rAB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
AB
]);
RealOpenMM
rAB
=
SQRT
(
rAB2
);
RealOpenMM
rCB2
=
AmoebaReferenceForce
::
getNormSquared3
(
deltaR
[
CB
]);
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceStretchBendForce.h
View file @
8190f243
/* 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
...
...
@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */
AmoebaReferenceStretchBendForce
()
{};
AmoebaReferenceStretchBendForce
()
:
usePeriodic
(
false
)
{};
/**---------------------------------------------------------------------------------------
...
...
@@ -50,6 +50,16 @@ public:
~
AmoebaReferenceStretchBendForce
()
{};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Amoeba stretch bend ixns (force and energy)
...
...
@@ -84,6 +94,9 @@ public:
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
Calculate Amoeba stretch bend angle ixn (force and energy)
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.cpp
View file @
8190f243
/* 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
...
...
@@ -28,6 +27,13 @@
using
std
::
vector
;
using
namespace
OpenMM
;
void
AmoebaReferenceTorsionTorsionForce
::
setPeriodic
(
OpenMM
::
RealVec
*
vectors
)
{
usePeriodic
=
true
;
boxVectors
[
0
]
=
vectors
[
0
];
boxVectors
[
1
]
=
vectors
[
1
];
boxVectors
[
2
]
=
vectors
[
2
];
}
/**---------------------------------------------------------------------------------------
Load grid values from rectenclosing angles
...
...
@@ -294,9 +300,16 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
deltaR
[
ii
].
resize
(
3
);
}
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomA
,
deltaR
[
CA
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomB
,
deltaR
[
CB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomD
,
deltaR
[
CD
]);
if
(
usePeriodic
)
{
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomA
,
deltaR
[
CA
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomB
,
deltaR
[
CB
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomD
,
deltaR
[
CD
],
boxVectors
);
}
else
{
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomA
,
deltaR
[
CA
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomB
,
deltaR
[
CB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomD
,
deltaR
[
CD
]);
}
RealOpenMM
volume
=
deltaR
[
CA
][
0
]
*
(
deltaR
[
CB
][
1
]
*
deltaR
[
CD
][
2
]
-
deltaR
[
CB
][
2
]
*
deltaR
[
CD
][
1
])
+
deltaR
[
CB
][
0
]
*
(
deltaR
[
CD
][
1
]
*
deltaR
[
CA
][
2
]
-
deltaR
[
CD
][
2
]
*
deltaR
[
CA
][
1
])
+
...
...
@@ -351,13 +364,24 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
deltaR
[
ii
].
resize
(
3
);
}
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomA
,
positionAtomB
,
deltaR
[
BA
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomD
,
deltaR
[
DC
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomE
,
deltaR
[
ED
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomA
,
positionAtomC
,
deltaR
[
CA
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomD
,
deltaR
[
DB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
]);
if
(
usePeriodic
)
{
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomA
,
positionAtomB
,
deltaR
[
BA
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomD
,
deltaR
[
DC
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomD
,
positionAtomE
,
deltaR
[
ED
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomA
,
positionAtomC
,
deltaR
[
CA
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomB
,
positionAtomD
,
deltaR
[
DB
],
boxVectors
);
AmoebaReferenceForce
::
loadDeltaRPeriodic
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
],
boxVectors
);
}
else
{
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomA
,
positionAtomB
,
deltaR
[
BA
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomC
,
deltaR
[
CB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomD
,
deltaR
[
DC
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomD
,
positionAtomE
,
deltaR
[
ED
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomA
,
positionAtomC
,
deltaR
[
CA
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomB
,
positionAtomD
,
deltaR
[
DB
]);
AmoebaReferenceForce
::
loadDeltaR
(
positionAtomC
,
positionAtomE
,
deltaR
[
EC
]);
}
std
::
vector
<
RealOpenMM
>
d
[
LastAtomIndex
];
for
(
unsigned
int
ii
=
0
;
ii
<
LastAtomIndex
;
ii
++
)
{
...
...
plugins/amoeba/platforms/reference/src/SimTKReference/AmoebaReferenceTorsionTorsionForce.h
View file @
8190f243
/* 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
...
...
@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */
AmoebaReferenceTorsionTorsionForce
()
{};
AmoebaReferenceTorsionTorsionForce
()
:
usePeriodic
(
false
)
{};
/**---------------------------------------------------------------------------------------
...
...
@@ -50,6 +50,16 @@ public:
~
AmoebaReferenceTorsionTorsionForce
()
{};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void
setPeriodic
(
OpenMM
::
RealVec
*
vectors
);
/**---------------------------------------------------------------------------------------
Calculate Amoeba torsion-torsion ixns (force and energy)
...
...
@@ -84,6 +94,9 @@ public:
private:
bool
usePeriodic
;
RealVec
boxVectors
[
3
];
/**---------------------------------------------------------------------------------------
Load grid values from rectangle enclosing angles
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaAngleForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -35,6 +35,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomAngleForce.h"
#include "OpenMMAmoeba.h"
#include "openmm/System.h"
#include "openmm/LangevinIntegrator.h"
...
...
@@ -274,12 +275,63 @@ void testOneAngle() {
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaAngleForce
,
TOL
,
"testOneAngle"
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions, then compare to an identical custom force.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numParticles
=
3
;
for
(
int
ii
=
0
;
ii
<
numParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaAngleForce
*
amoebaAngleForce
=
new
AmoebaAngleForce
();
double
angle
=
100.0
;
double
quadraticK
=
1.0
;
double
cubicK
=
1.0e-01
;
double
quarticK
=
1.0e-02
;
double
penticK
=
1.0e-03
;
double
sexticK
=
1.0e-04
;
amoebaAngleForce
->
addAngle
(
0
,
1
,
2
,
angle
,
quadraticK
);
amoebaAngleForce
->
setAmoebaGlobalAngleCubic
(
cubicK
);
amoebaAngleForce
->
setAmoebaGlobalAngleQuartic
(
quarticK
);
amoebaAngleForce
->
setAmoebaGlobalAnglePentic
(
penticK
);
amoebaAngleForce
->
setAmoebaGlobalAngleSextic
(
sexticK
);
amoebaAngleForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaAngleForce
);
CustomAngleForce
*
customForce
=
new
CustomAngleForce
(
"k2*delta^2 + k3*delta^3 + k4*delta^4 + k5*delta^5 + k6*delta^6; delta=theta-theta0"
);
customForce
->
addGlobalParameter
(
"theta0"
,
angle
*
M_PI
/
180
);
customForce
->
addGlobalParameter
(
"k2"
,
quadraticK
*
pow
(
180
/
M_PI
,
2.0
));
customForce
->
addGlobalParameter
(
"k3"
,
cubicK
*
pow
(
180
/
M_PI
,
3.0
));
customForce
->
addGlobalParameter
(
"k4"
,
quarticK
*
pow
(
180
/
M_PI
,
4.0
));
customForce
->
addGlobalParameter
(
"k5"
,
penticK
*
pow
(
180
/
M_PI
,
5.0
));
customForce
->
addGlobalParameter
(
"k6"
,
sexticK
*
pow
(
180
/
M_PI
,
6.0
));
customForce
->
addAngle
(
0
,
1
,
2
);
customForce
->
setUsesPeriodicBoundaryConditions
(
true
);
customForce
->
setForceGroup
(
1
);
system
.
addForce
(
customForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numParticles
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
0
,
2
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
true
,
1
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
true
,
2
);
ASSERT_EQUAL_TOL
(
s2
.
getPotentialEnergy
(),
s1
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s2
.
getForces
()[
i
],
s1
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
try
{
std
::
cout
<<
"Test
Cuda
AmoebaAngleForce running test..."
<<
std
::
endl
;
std
::
cout
<<
"Test
Reference
AmoebaAngleForce running test..."
<<
std
::
endl
;
registerAmoebaReferenceKernelFactories
();
testOneAngle
();
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaBondForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -35,6 +35,7 @@
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "openmm/CustomBondForce.h"
#include "OpenMMAmoeba.h"
#include "openmm/System.h"
#include "openmm/LangevinIntegrator.h"
...
...
@@ -201,6 +202,49 @@ void testTwoBond() {
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaBondForce
,
TOL
,
"testTwoBond"
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions, then compare to an identical custom force.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numParticles
=
2
;
for
(
int
ii
=
0
;
ii
<
numParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaBondForce
*
amoebaBondForce
=
new
AmoebaBondForce
();
double
bondLength
=
1.5
;
double
quadraticK
=
1.0
;
double
cubicK
=
2.0
;
double
quarticK
=
3.0
;
amoebaBondForce
->
setAmoebaGlobalBondCubic
(
cubicK
);
amoebaBondForce
->
setAmoebaGlobalBondQuartic
(
quarticK
);
amoebaBondForce
->
addBond
(
0
,
1
,
bondLength
,
quadraticK
);
amoebaBondForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaBondForce
);
CustomBondForce
*
customForce
=
new
CustomBondForce
(
"k2*delta^2 + k3*delta^3 + k4*delta^4; delta=r-r0"
);
customForce
->
addGlobalParameter
(
"r0"
,
bondLength
);
customForce
->
addGlobalParameter
(
"k2"
,
quadraticK
);
customForce
->
addGlobalParameter
(
"k3"
,
cubicK
);
customForce
->
addGlobalParameter
(
"k4"
,
quarticK
);
customForce
->
addBond
(
0
,
1
);
customForce
->
setUsesPeriodicBoundaryConditions
(
true
);
customForce
->
setForceGroup
(
1
);
system
.
addForce
(
customForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numParticles
);
positions
[
0
]
=
Vec3
(
0
,
2
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
true
,
1
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
,
true
,
2
);
ASSERT_EQUAL_TOL
(
s2
.
getPotentialEnergy
(),
s1
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s2
.
getForces
()[
i
],
s1
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
try
{
...
...
@@ -208,6 +252,7 @@ int main(int numberOfArguments, char* argv[]) {
registerAmoebaReferenceKernelFactories
();
//testOneBond();
testTwoBond
();
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaInPlaneAngleForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -354,12 +354,57 @@ void testOneAngle() {
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaInPlaneAngleForce
,
TOL
,
"testOneInPlaneAngle"
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numberOfParticles
=
4
;
for
(
int
ii
=
0
;
ii
<
numberOfParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaInPlaneAngleForce
*
amoebaInPlaneAngleForce
=
new
AmoebaInPlaneAngleForce
();
double
angle
=
65.0
;
double
quadraticK
=
1.0
;
double
cubicK
=
0.0e-01
;
double
quarticK
=
0.0e-02
;
double
penticK
=
0.0e-03
;
double
sexticK
=
0.0e-04
;
amoebaInPlaneAngleForce
->
addAngle
(
0
,
1
,
2
,
3
,
angle
,
quadraticK
);
amoebaInPlaneAngleForce
->
setAmoebaGlobalInPlaneAngleCubic
(
cubicK
);
amoebaInPlaneAngleForce
->
setAmoebaGlobalInPlaneAngleQuartic
(
quarticK
);
amoebaInPlaneAngleForce
->
setAmoebaGlobalInPlaneAnglePentic
(
penticK
);
amoebaInPlaneAngleForce
->
setAmoebaGlobalInPlaneAngleSextic
(
sexticK
);
amoebaInPlaneAngleForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaInPlaneAngleForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numberOfParticles
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
0
,
1
);
positions
[
3
]
=
Vec3
(
1
,
1
,
1
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
// Move one atom to a position that should give identical results.
positions
[
2
]
=
Vec3
(
0
,
0
,
-
2
);
context
.
setPositions
(
positions
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
try
{
std
::
cout
<<
"TestReferenceAmoebaInPlaneAngleForce running test..."
<<
std
::
endl
;
registerAmoebaReferenceKernelFactories
();
testOneAngle
();
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaOutOfPlaneBendForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -461,12 +461,50 @@ void testOneOutOfPlaneBend2(int setId) {
}
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numberOfParticles
=
4
;
for
(
int
ii
=
0
;
ii
<
numberOfParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaOutOfPlaneBendForce
*
amoebaOutOfPlaneBendForce
=
new
AmoebaOutOfPlaneBendForce
();
amoebaOutOfPlaneBendForce
->
setAmoebaGlobalOutOfPlaneBendCubic
(
-
0.1400000E-01
);
amoebaOutOfPlaneBendForce
->
setAmoebaGlobalOutOfPlaneBendQuartic
(
0.5600000E-04
);
amoebaOutOfPlaneBendForce
->
setAmoebaGlobalOutOfPlaneBendPentic
(
-
0.7000000E-06
);
amoebaOutOfPlaneBendForce
->
setAmoebaGlobalOutOfPlaneBendSextic
(
0.2200000E-07
);
double
kOutOfPlaneBend
=
0.328682196E-01
;
amoebaOutOfPlaneBendForce
->
addOutOfPlaneBend
(
0
,
1
,
2
,
3
,
kOutOfPlaneBend
);
amoebaOutOfPlaneBendForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaOutOfPlaneBendForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numberOfParticles
);
positions
[
0
]
=
Vec3
(
0
,
0
,
0
);
positions
[
1
]
=
Vec3
(
1
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
1
,
0
);
positions
[
3
]
=
Vec3
(
0
,
0
,
1
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
// Move one atom to a position that should give identical results.
positions
[
3
]
=
Vec3
(
0
,
0
,
-
2
);
context
.
setPositions
(
positions
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
try
{
std
::
cout
<<
"TestReferenceAmoebaOutOfPlaneBendForce running test..."
<<
std
::
endl
;
registerAmoebaReferenceKernelFactories
();
testOneOutOfPlaneBend
();
testPeriodic
();
//testOneOutOfPlaneBend2(atoi(argv[1]));
//for (int ii = 1; ii <= 6; ii++) {
// testOneOutOfPlaneBend2(ii);
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaPiTorsionForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -290,12 +290,48 @@ void testOnePiTorsion() {
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaPiTorsionForce
,
TOL
,
"testOnePiTorsion"
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numberOfParticles
=
6
;
for
(
int
ii
=
0
;
ii
<
numberOfParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaPiTorsionForce
*
amoebaPiTorsionForce
=
new
AmoebaPiTorsionForce
();
double
kTorsion
=
6.85
;
amoebaPiTorsionForce
->
addPiTorsion
(
0
,
1
,
2
,
3
,
4
,
5
,
kTorsion
);
amoebaPiTorsionForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaPiTorsionForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numberOfParticles
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
0
,
0.5
);
positions
[
3
]
=
Vec3
(
0.4
,
0.4
,
0.4
);
positions
[
4
]
=
Vec3
(
1
,
0
,
1
);
positions
[
5
]
=
Vec3
(
1
,
1
,
0
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
// Move one atom to a position that should give identical results.
positions
[
0
]
=
Vec3
(
0
,
-
2
,
0
);
context
.
setPositions
(
positions
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
try
{
std
::
cout
<<
"TestReferenceAmoebaPiTorsionForce running test..."
<<
std
::
endl
;
registerAmoebaReferenceKernelFactories
();
testOnePiTorsion
();
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaStretchBendForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -270,12 +270,48 @@ void testOneStretchBend() {
compareWithExpectedForceAndEnergy
(
context
,
*
amoebaStretchBendForce
,
TOL
,
"testOneStretchBend"
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numberOfParticles
=
3
;
for
(
int
ii
=
0
;
ii
<
numberOfParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaStretchBendForce
*
amoebaStretchBendForce
=
new
AmoebaStretchBendForce
();
double
abLength
=
0.144800000E+01
;
double
cbLength
=
0.101500000E+01
;
double
angleStretchBend
=
0.108500000E+03
*
DegreesToRadians
;
double
kStretchBend
=
1.0
;
amoebaStretchBendForce
->
addStretchBend
(
0
,
1
,
2
,
abLength
,
cbLength
,
angleStretchBend
,
kStretchBend
,
kStretchBend
);
amoebaStretchBendForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaStretchBendForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numberOfParticles
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
0
,
1
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
// Move one atom to a position that should give identical results.
positions
[
2
]
=
Vec3
(
0
,
0
,
-
2
);
context
.
setPositions
(
positions
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
try
{
std
::
cout
<<
"TestReferenceAmoebaStretchBendForce running test..."
<<
std
::
endl
;
registerAmoebaReferenceKernelFactories
();
testOneStretchBend
();
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
plugins/amoeba/platforms/reference/tests/TestReferenceAmoebaTorsionTorsionForce.cpp
View file @
8190f243
...
...
@@ -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) 2008 Stanford University and the Authors.
*
* Portions copyright (c) 2008
-2016
Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
...
...
@@ -2669,6 +2669,44 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
ASSERT_EQUAL_TOL
(
expectedEnergy
,
state
.
getPotentialEnergy
(),
tolerance
);
}
void
testPeriodic
()
{
// Create a force that uses periodic boundary conditions.
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
3
,
0
,
0
),
Vec3
(
0
,
3
,
0
),
Vec3
(
0
,
0
,
3
));
int
numberOfParticles
=
6
;
for
(
int
ii
=
0
;
ii
<
numberOfParticles
;
ii
++
)
system
.
addParticle
(
1.0
);
LangevinIntegrator
integrator
(
0.0
,
0.1
,
0.01
);
AmoebaTorsionTorsionForce
*
amoebaTorsionTorsionForce
=
new
AmoebaTorsionTorsionForce
();
int
chiralCheckAtomIndex
;
int
gridIndex
;
chiralCheckAtomIndex
=
5
;
gridIndex
=
2
;
amoebaTorsionTorsionForce
->
addTorsionTorsion
(
0
,
1
,
2
,
3
,
4
,
chiralCheckAtomIndex
,
0
);
amoebaTorsionTorsionForce
->
setTorsionTorsionGrid
(
0
,
getTorsionGrid
(
gridIndex
,
false
));
amoebaTorsionTorsionForce
->
setUsesPeriodicBoundaryConditions
(
true
);
system
.
addForce
(
amoebaTorsionTorsionForce
);
Context
context
(
system
,
integrator
,
Platform
::
getPlatformByName
(
"Reference"
));
std
::
vector
<
Vec3
>
positions
(
numberOfParticles
);
positions
[
0
]
=
Vec3
(
0
,
1
,
0
);
positions
[
1
]
=
Vec3
(
0
,
0
,
0
);
positions
[
2
]
=
Vec3
(
0
,
0
,
0.5
);
positions
[
3
]
=
Vec3
(
0.4
,
0.4
,
0.4
);
positions
[
4
]
=
Vec3
(
1
,
0
,
1
);
positions
[
5
]
=
Vec3
(
1
,
1
,
0
);
context
.
setPositions
(
positions
);
State
s1
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
// Move one atom to a position that should give identical results.
positions
[
0
]
=
Vec3
(
0
,
-
2
,
0
);
context
.
setPositions
(
positions
);
State
s2
=
context
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
s1
.
getPotentialEnergy
(),
s2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numberOfParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
s1
.
getForces
()[
i
],
s2
.
getForces
()[
i
],
1e-5
);
}
int
main
(
int
numberOfArguments
,
char
*
argv
[])
{
...
...
@@ -2677,6 +2715,7 @@ int main(int numberOfArguments, char* argv[]) {
registerAmoebaReferenceKernelFactories
();
testTorsionTorsion
(
1
,
true
);
testTorsionTorsion
(
1
,
false
);
testPeriodic
();
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"exception: "
<<
e
.
what
()
<<
std
::
endl
;
...
...
plugins/amoeba/serialization/src/AmoebaAngleForceProxy.cpp
View file @
8190f243
...
...
@@ -42,11 +42,12 @@ AmoebaAngleForceProxy::AmoebaAngleForceProxy() : SerializationProxy("AmoebaAngle
}
void
AmoebaAngleForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
AmoebaAngleForce
&
force
=
*
reinterpret_cast
<
const
AmoebaAngleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setDoubleProperty
(
"cubic"
,
force
.
getAmoebaGlobalAngleCubic
());
node
.
setDoubleProperty
(
"quartic"
,
force
.
getAmoebaGlobalAngleQuartic
());
node
.
setDoubleProperty
(
"pentic"
,
force
.
getAmoebaGlobalAnglePentic
());
...
...
@@ -63,12 +64,14 @@ void AmoebaAngleForceProxy::serialize(const void* object, SerializationNode& nod
void
*
AmoebaAngleForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaAngleForce
*
force
=
new
AmoebaAngleForce
();
try
{
if
(
version
>
1
)
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
2
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
force
->
setAmoebaGlobalAngleCubic
(
node
.
getDoubleProperty
(
"cubic"
));
force
->
setAmoebaGlobalAngleQuartic
(
node
.
getDoubleProperty
(
"quartic"
));
force
->
setAmoebaGlobalAnglePentic
(
node
.
getDoubleProperty
(
"pentic"
));
...
...
plugins/amoeba/serialization/src/AmoebaBondForceProxy.cpp
View file @
8190f243
...
...
@@ -42,10 +42,11 @@ AmoebaBondForceProxy::AmoebaBondForceProxy() : SerializationProxy("AmoebaBondFor
}
void
AmoebaBondForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
AmoebaBondForce
&
force
=
*
reinterpret_cast
<
const
AmoebaBondForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setDoubleProperty
(
"cubic"
,
force
.
getAmoebaGlobalBondCubic
());
node
.
setDoubleProperty
(
"quartic"
,
force
.
getAmoebaGlobalBondQuartic
());
...
...
@@ -60,12 +61,14 @@ void AmoebaBondForceProxy::serialize(const void* object, SerializationNode& node
void
*
AmoebaBondForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaBondForce
*
force
=
new
AmoebaBondForce
();
try
{
if
(
version
>
1
)
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
2
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
force
->
setAmoebaGlobalBondCubic
(
node
.
getDoubleProperty
(
"cubic"
));
force
->
setAmoebaGlobalBondQuartic
(
node
.
getDoubleProperty
(
"quartic"
));
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"Bonds"
);
...
...
plugins/amoeba/serialization/src/AmoebaInPlaneAngleForceProxy.cpp
View file @
8190f243
...
...
@@ -43,10 +43,11 @@ AmoebaInPlaneAngleForceProxy::AmoebaInPlaneAngleForceProxy() : SerializationProx
void
AmoebaInPlaneAngleForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
AmoebaInPlaneAngleForce
&
force
=
*
reinterpret_cast
<
const
AmoebaInPlaneAngleForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setDoubleProperty
(
"cubic"
,
force
.
getAmoebaGlobalInPlaneAngleCubic
());
node
.
setDoubleProperty
(
"quartic"
,
force
.
getAmoebaGlobalInPlaneAngleQuartic
());
node
.
setDoubleProperty
(
"pentic"
,
force
.
getAmoebaGlobalInPlaneAnglePentic
());
...
...
@@ -63,12 +64,14 @@ void AmoebaInPlaneAngleForceProxy::serialize(const void* object, SerializationNo
void
*
AmoebaInPlaneAngleForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaInPlaneAngleForce
*
force
=
new
AmoebaInPlaneAngleForce
();
try
{
if
(
version
>
1
)
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
2
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
force
->
setAmoebaGlobalInPlaneAngleCubic
(
node
.
getDoubleProperty
(
"cubic"
));
force
->
setAmoebaGlobalInPlaneAngleQuartic
(
node
.
getDoubleProperty
(
"quartic"
));
force
->
setAmoebaGlobalInPlaneAnglePentic
(
node
.
getDoubleProperty
(
"pentic"
));
...
...
plugins/amoeba/serialization/src/AmoebaOutOfPlaneBendForceProxy.cpp
View file @
8190f243
...
...
@@ -42,9 +42,10 @@ AmoebaOutOfPlaneBendForceProxy::AmoebaOutOfPlaneBendForceProxy() : Serialization
}
void
AmoebaOutOfPlaneBendForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
AmoebaOutOfPlaneBendForce
&
force
=
*
reinterpret_cast
<
const
AmoebaOutOfPlaneBendForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
node
.
setDoubleProperty
(
"cubic"
,
force
.
getAmoebaGlobalOutOfPlaneBendCubic
());
node
.
setDoubleProperty
(
"quartic"
,
force
.
getAmoebaGlobalOutOfPlaneBendQuartic
());
node
.
setDoubleProperty
(
"pentic"
,
force
.
getAmoebaGlobalOutOfPlaneBendPentic
());
...
...
@@ -61,12 +62,14 @@ void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, Serialization
void
*
AmoebaOutOfPlaneBendForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaOutOfPlaneBendForce
*
force
=
new
AmoebaOutOfPlaneBendForce
();
try
{
if
(
version
>
1
)
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
2
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
force
->
setAmoebaGlobalOutOfPlaneBendCubic
(
node
.
getDoubleProperty
(
"cubic"
));
force
->
setAmoebaGlobalOutOfPlaneBendQuartic
(
node
.
getDoubleProperty
(
"quartic"
));
force
->
setAmoebaGlobalOutOfPlaneBendPentic
(
node
.
getDoubleProperty
(
"pentic"
));
...
...
plugins/amoeba/serialization/src/AmoebaPiTorsionForceProxy.cpp
View file @
8190f243
...
...
@@ -42,9 +42,10 @@ AmoebaPiTorsionForceProxy::AmoebaPiTorsionForceProxy() : SerializationProxy("Amo
}
void
AmoebaPiTorsionForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
2
);
node
.
setIntProperty
(
"version"
,
3
);
const
AmoebaPiTorsionForce
&
force
=
*
reinterpret_cast
<
const
AmoebaPiTorsionForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
bonds
=
node
.
createChildNode
(
"PiTorsion"
);
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
force
.
getNumPiTorsions
());
ii
++
)
{
int
particle1
,
particle2
,
particle3
,
particle4
,
particle5
,
particle6
;
...
...
@@ -56,12 +57,14 @@ void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode&
void
*
AmoebaPiTorsionForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
2
)
if
(
version
<
1
||
version
>
3
)
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaPiTorsionForce
*
force
=
new
AmoebaPiTorsionForce
();
try
{
if
(
version
>
1
)
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
2
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"PiTorsion"
);
for
(
unsigned
int
ii
=
0
;
ii
<
bonds
.
getChildren
().
size
();
ii
++
)
{
const
SerializationNode
&
bond
=
bonds
.
getChildren
()[
ii
];
...
...
plugins/amoeba/serialization/src/AmoebaStretchBendForceProxy.cpp
View file @
8190f243
...
...
@@ -42,9 +42,10 @@ AmoebaStretchBendForceProxy::AmoebaStretchBendForceProxy() : SerializationProxy(
}
void
AmoebaStretchBendForceProxy
::
serialize
(
const
void
*
object
,
SerializationNode
&
node
)
const
{
node
.
setIntProperty
(
"version"
,
3
);
node
.
setIntProperty
(
"version"
,
4
);
const
AmoebaStretchBendForce
&
force
=
*
reinterpret_cast
<
const
AmoebaStretchBendForce
*>
(
object
);
node
.
setIntProperty
(
"forceGroup"
,
force
.
getForceGroup
());
node
.
setBoolProperty
(
"usesPeriodic"
,
force
.
usesPeriodicBoundaryConditions
());
SerializationNode
&
bonds
=
node
.
createChildNode
(
"StretchBendAngles"
);
for
(
unsigned
int
ii
=
0
;
ii
<
static_cast
<
unsigned
int
>
(
force
.
getNumStretchBends
());
ii
++
)
{
int
particle1
,
particle2
,
particle3
;
...
...
@@ -57,12 +58,14 @@ void AmoebaStretchBendForceProxy::serialize(const void* object, SerializationNod
void
*
AmoebaStretchBendForceProxy
::
deserialize
(
const
SerializationNode
&
node
)
const
{
int
version
=
node
.
getIntProperty
(
"version"
);
if
(
version
<
1
||
version
>
3
)
if
(
version
<
1
||
version
>
4
)
throw
OpenMMException
(
"Unsupported version number"
);
AmoebaStretchBendForce
*
force
=
new
AmoebaStretchBendForce
();
try
{
if
(
version
>
2
)
force
->
setForceGroup
(
node
.
getIntProperty
(
"forceGroup"
,
0
));
if
(
version
>
3
)
force
->
setUsesPeriodicBoundaryConditions
(
node
.
getBoolProperty
(
"usesPeriodic"
));
const
SerializationNode
&
bonds
=
node
.
getChildNode
(
"StretchBendAngles"
);
for
(
unsigned
int
ii
=
0
;
ii
<
(
int
)
bonds
.
getChildren
().
size
();
ii
++
)
{
const
SerializationNode
&
bond
=
bonds
.
getChildren
()[
ii
];
...
...
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