Commit 7bfb75c7 authored by Lee-Ping Wang's avatar Lee-Ping Wang
Browse files

Merge branch 'master' of github.com:SimTk/openmm

parents a85d163b 49cb91c5
......@@ -34,10 +34,10 @@
using namespace OpenMM;
extern "C" void registerPlatforms() {
extern "C" OPENMM_EXPORT void registerPlatforms() {
}
extern "C" void registerKernelFactories() {
extern "C" OPENMM_EXPORT void registerKernelFactories() {
try {
Platform& platform = Platform::getPlatformByName("OpenCL");
OpenCLDrudeKernelFactory* factory = new OpenCLDrudeKernelFactory();
......
......@@ -34,10 +34,10 @@
using namespace OpenMM;
extern "C" void registerPlatforms() {
extern "C" OPENMM_EXPORT void registerPlatforms() {
}
extern "C" void registerKernelFactories() {
extern "C" OPENMM_EXPORT void registerKernelFactories() {
try {
Platform& platform = Platform::getPlatformByName("CUDA");
CudaRpmdKernelFactory* factory = new CudaRpmdKernelFactory();
......
......@@ -296,12 +296,25 @@ void CudaIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& pos
throw OpenMMException("RPMDIntegrator: Cannot set positions before the integrator is added to a Context");
if (pos.size() != numParticles)
throw OpenMMException("RPMDIntegrator: wrong number of values passed to setPositions()");
// Adjust the positions based on the current cell offsets.
const vector<int>& order = cu.getAtomIndex();
double4 periodicBoxSize = cu.getPeriodicBoxSize();
vector<Vec3> offsetPos(numParticles);
for (int i = 0; i < numParticles; ++i) {
int4 offset = cu.getPosCellOffsets()[i];
offsetPos[order[i]] = pos[order[i]] + Vec3(offset.x*periodicBoxSize.x, offset.y*periodicBoxSize.y, offset.z*periodicBoxSize.z);
}
// Record the positions.
CUresult result;
if (cu.getUseDoublePrecision()) {
vector<double4> posq(cu.getPaddedNumAtoms());
cu.getPosq().download(posq);
for (int i = 0; i < numParticles; i++)
posq[i] = make_double4(pos[i][0], pos[i][1], pos[i][2], posq[i].w);
posq[i] = make_double4(offsetPos[i][0], offsetPos[i][1], offsetPos[i][2], posq[i].w);
result = cuMemcpyHtoD(positions->getDevicePointer()+copy*cu.getPaddedNumAtoms()*sizeof(double4), &posq[0], numParticles*sizeof(double4));
}
else if (cu.getUseMixedPrecision()) {
......@@ -309,14 +322,14 @@ void CudaIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& pos
cu.getPosq().download(posqf);
vector<double4> posq(cu.getPaddedNumAtoms());
for (int i = 0; i < numParticles; i++)
posq[i] = make_double4(pos[i][0], pos[i][1], pos[i][2], posqf[i].w);
posq[i] = make_double4(offsetPos[i][0], offsetPos[i][1], offsetPos[i][2], posqf[i].w);
result = cuMemcpyHtoD(positions->getDevicePointer()+copy*cu.getPaddedNumAtoms()*sizeof(double4), &posq[0], numParticles*sizeof(double4));
}
else {
vector<float4> posq(cu.getPaddedNumAtoms());
cu.getPosq().download(posq);
for (int i = 0; i < numParticles; i++)
posq[i] = make_float4((float) pos[i][0], (float) pos[i][1], (float) pos[i][2], posq[i].w);
posq[i] = make_float4((float) offsetPos[i][0], (float) offsetPos[i][1], (float) offsetPos[i][2], posq[i].w);
result = cuMemcpyHtoD(positions->getDevicePointer()+copy*cu.getPaddedNumAtoms()*sizeof(float4), &posq[0], numParticles*sizeof(float4));
}
if (result != CUDA_SUCCESS) {
......
......@@ -28,16 +28,16 @@
#include "OpenCLRpmdKernelFactory.h"
#include "OpenCLRpmdKernels.h"
#include "openmm/internal/windowsExport.h"
#include "openmm/internal/windowsExportRpmd.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/OpenMMException.h"
using namespace OpenMM;
extern "C" void registerPlatforms() {
extern "C" OPENMM_EXPORT void registerPlatforms() {
}
extern "C" void registerKernelFactories() {
extern "C" OPENMM_EXPORT void registerKernelFactories() {
try {
Platform& platform = Platform::getPlatformByName("OpenCL");
OpenCLRpmdKernelFactory* factory = new OpenCLRpmdKernelFactory();
......
......@@ -312,11 +312,24 @@ void OpenCLIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& p
throw OpenMMException("RPMDIntegrator: Cannot set positions before the integrator is added to a Context");
if (pos.size() != numParticles)
throw OpenMMException("RPMDIntegrator: wrong number of values passed to setPositions()");
// Adjust the positions based on the current cell offsets.
const vector<int>& order = cl.getAtomIndex();
mm_double4 periodicBoxSize = cl.getPeriodicBoxSizeDouble();
vector<Vec3> offsetPos(numParticles);
for (int i = 0; i < numParticles; ++i) {
mm_int4 offset = cl.getPosCellOffsets()[i];
offsetPos[order[i]] = pos[order[i]] + Vec3(offset.x*periodicBoxSize.x, offset.y*periodicBoxSize.y, offset.z*periodicBoxSize.z);
}
// Record the positions.
if (cl.getUseDoublePrecision()) {
vector<mm_double4> posq(cl.getPaddedNumAtoms());
cl.getPosq().download(posq);
for (int i = 0; i < numParticles; i++)
posq[i] = mm_double4(pos[i][0], pos[i][1], pos[i][2], posq[i].w);
posq[i] = mm_double4(offsetPos[i][0], offsetPos[i][1], offsetPos[i][2], posq[i].w);
cl.getQueue().enqueueWriteBuffer(positions->getDeviceBuffer(), CL_TRUE, copy*cl.getPaddedNumAtoms()*sizeof(mm_double4), numParticles*sizeof(mm_double4), &posq[0]);
}
else if (cl.getUseMixedPrecision()) {
......@@ -324,14 +337,14 @@ void OpenCLIntegrateRPMDStepKernel::setPositions(int copy, const vector<Vec3>& p
cl.getPosq().download(posqf);
vector<mm_double4> posq(cl.getPaddedNumAtoms());
for (int i = 0; i < numParticles; i++)
posq[i] = mm_double4(pos[i][0], pos[i][1], pos[i][2], posqf[i].w);
posq[i] = mm_double4(offsetPos[i][0], offsetPos[i][1], offsetPos[i][2], posqf[i].w);
cl.getQueue().enqueueWriteBuffer(positions->getDeviceBuffer(), CL_TRUE, copy*cl.getPaddedNumAtoms()*sizeof(mm_double4), numParticles*sizeof(mm_double4), &posq[0]);
}
else {
vector<mm_float4> posq(cl.getPaddedNumAtoms());
cl.getPosq().download(posq);
for (int i = 0; i < numParticles; i++)
posq[i] = mm_float4((cl_float) pos[i][0], (cl_float) pos[i][1], (cl_float) pos[i][2], posq[i].w);
posq[i] = mm_float4((cl_float) offsetPos[i][0], (cl_float) offsetPos[i][1], (cl_float) offsetPos[i][2], posq[i].w);
cl.getQueue().enqueueWriteBuffer(positions->getDeviceBuffer(), CL_TRUE, copy*cl.getPaddedNumAtoms()*sizeof(mm_float4), numParticles*sizeof(mm_float4), &posq[0]);
}
}
......
......@@ -41,10 +41,25 @@ import simtk.openmm as mm
# Enumerated values for implicit solvent model
HCT = object()
OBC1 = object()
OBC2 = object()
GBn = object()
class HCT(object):
def __repr__(self):
return 'HCT'
HCT = HCT()
class OBC1(object):
def __repr__(self):
return 'OBC1'
OBC1 = OBC1()
class OBC2(object):
def __repr__(self):
return 'OBC2'
OBC2 = OBC2()
class GBn(object):
def __repr__(self):
return 'GBn'
GBn = GBn()
class AmberPrmtopFile(object):
"""AmberPrmtopFile parses an AMBER prmtop file and constructs a Topology and (optionally) an OpenMM System from it."""
......
......@@ -42,17 +42,47 @@ from simtk.openmm.app import Topology
# Enumerated values for nonbonded method
NoCutoff = object()
CutoffNonPeriodic = object()
CutoffPeriodic = object()
Ewald = object()
PME = object()
class NoCutoff(object):
def __repr__(self):
return 'NoCutoff'
NoCutoff = NoCutoff()
class CutoffNonPeriodic(object):
def __repr__(self):
return 'CutoffNonPeriodic'
CutoffNonPeriodic = CutoffNonPeriodic()
class CutoffPeriodic(object):
def __repr__(self):
return 'CutoffPeriodic'
CutoffPeriodic = CutoffPeriodic()
class Ewald(object):
def __repr__(self):
return 'Ewald'
Ewald = Ewald()
class PME(object):
def __repr__(self):
return 'PME'
PME = PME()
# Enumerated values for constraint type
HBonds = object()
AllBonds = object()
HAngles = object()
class HBonds(object):
def __repr__(self):
return 'HBonds'
HBonds = HBonds()
class AllBonds(object):
def __repr__(self):
return 'AllBonds'
AllBonds = AllBonds()
class HAngles(object):
def __repr__(self):
return 'HAngles'
HAngles = HAngles()
# A map of functions to parse elements of the XML file.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment