setParameter leads to AttributeError
Posted: Sun Sep 20, 2020 7:20 am
Hi, all,
I am experiencing a problem with OpenMM, version -7.4.2-py37_cuda101_rc1. I tested the platforms CPU and CUDA, both have the same issue: I want to update a global parameter with context.setParamter() which fails with the following error:
Traceback (most recent call last):
File "openmm_run.py", line 106, in <module>
simulation.context.setParamter('ref', 4.0)
File "xxx/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 18255, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, Context, name)
File "xxx/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "xxx/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 69, in _swig_getattr_nondynamic
return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'
My python input is given below. Any ideas would be great!! Thanks!
Best,
Martin
***
# Build system
system = psf.createSystem(params, nonbondedMethod=inputs.coulomb,
nonbondedCutoff=inputs.r_off*nanometers,
constraints=inputs.cons,
ewaldErrorTolerance=inputs.ewald_Tol)
# Add custom force
xpos = 5.0
ypos = 0.0
zpos = 4.6
r6 = CustomExternalForce('1000*(sqrt((x-x0)^2+(y-y0)^2+(z-z0)^2)-ref)^2')
r6.addGlobalParameter('ref', 4.0)
r6.addPerParticleParameter('x0')
r6.addPerParticleParameter('y0')
r6.addPerParticleParameter('z0')
atom2 = 4000
r6.addParticle(atom2, [xpos, ypos, zpos])
system.addForce(r6)
# Set platform
platform = Platform.getPlatformByName('CUDA')
prop = dict(CudaPrecision='single')
# Build simulation context
integrator = LangevinIntegrator(inputs.temp*kelvin, inputs.fric_coeff/picosecond, inputs.dt*picoseconds)
simulation = Simulation(psf.topology, system, integrator, platform, prop)
simulation.context.setPositions(crd.positions)
simulation.context.setParamter('ref', 0.0)
stop
I am experiencing a problem with OpenMM, version -7.4.2-py37_cuda101_rc1. I tested the platforms CPU and CUDA, both have the same issue: I want to update a global parameter with context.setParamter() which fails with the following error:
Traceback (most recent call last):
File "openmm_run.py", line 106, in <module>
simulation.context.setParamter('ref', 4.0)
File "xxx/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 18255, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, Context, name)
File "xxx/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "xxx/lib/python3.7/site-packages/simtk/openmm/openmm.py", line 69, in _swig_getattr_nondynamic
return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'
My python input is given below. Any ideas would be great!! Thanks!
Best,
Martin
***
# Build system
system = psf.createSystem(params, nonbondedMethod=inputs.coulomb,
nonbondedCutoff=inputs.r_off*nanometers,
constraints=inputs.cons,
ewaldErrorTolerance=inputs.ewald_Tol)
# Add custom force
xpos = 5.0
ypos = 0.0
zpos = 4.6
r6 = CustomExternalForce('1000*(sqrt((x-x0)^2+(y-y0)^2+(z-z0)^2)-ref)^2')
r6.addGlobalParameter('ref', 4.0)
r6.addPerParticleParameter('x0')
r6.addPerParticleParameter('y0')
r6.addPerParticleParameter('z0')
atom2 = 4000
r6.addParticle(atom2, [xpos, ypos, zpos])
system.addForce(r6)
# Set platform
platform = Platform.getPlatformByName('CUDA')
prop = dict(CudaPrecision='single')
# Build simulation context
integrator = LangevinIntegrator(inputs.temp*kelvin, inputs.fric_coeff/picosecond, inputs.dt*picoseconds)
simulation = Simulation(psf.topology, system, integrator, platform, prop)
simulation.context.setPositions(crd.positions)
simulation.context.setParamter('ref', 0.0)
stop