interpolation_type=params['interpolation_type'],
    inv_power=params['inv_power'],
    energy_thresh=params['energy_thresh'],
    scaling_property='test_charge')

  print "With C"
  universe.setForceField(ForceField)

  universe.atom1.setPosition(Vector(x[0],0.5,1.5))

#  print 'Energy Terms:'
#  print universe.energyTerms()
#  e, g = universe.energyAndGradients()

  print 'Gradient Test'
  gradientTest(universe)

  import time
  start_time = time.time()
  
  for n in range(steps):
    universe.atom1.setPosition(Vector(x[n],0.5,1.5))
    e, g = universe.energyAndGradients()
  print 'Time to do %d energy and gradient evaluations: %f s'%(\
    steps, time.time()-start_time)

  print "Without C"
  ForceField.use_C = False

  universe.setForceField(ForceField)
Beispiel #2
0
universe = InfiniteUniverse()

universe.atom1 = Atom('C', position=Vector(1.02, 0.512, 1.513))
universe.atom1.test_charge = 1.
universe.atom2 = Atom('C', position=Vector(1.553, 1.724, 1.464))
universe.atom2.test_charge = -0.2

ForceField = TrilinearThreshGrid.TrilinearThreshGridForceField(
    '../../../Example/grids/LJa.nc', 1.0, 'test_charge', Ethresh=100.)

universe.setForceField(ForceField)

print 'Energy Terms:'
print universe.energyTerms()
e, g = universe.energyAndGradients()
print 'Gradient on Atom 1'
print g[universe.atom1]
print 'Gradient on Atom 2'
print g[universe.atom2]

print 'Gradient Test'
gradientTest(universe)

import time
start_time = time.time()
for t in range(100000):
    e, g = universe.energyAndGradients()
print 'Time to do 100000 energy and gradient evaluations'
print time.time() - start_time
Beispiel #3
0
import AlGDock

from MMTK import *
from Cylinder import CylinderForceField
from MMTK.ForceFields.ForceFieldTest import gradientTest, forceConstantTest

import numpy as N

try:
  from Scientific._vector import Vector
except:
  from Scientific.Geometry.VectorModule import Vector

universe = InfiniteUniverse()
universe.atom1 = Atom('C', position=Vector((2, 4.1, 2.1)))

ff1 = CylinderForceField(\
  origin=N.array((2., 2., 1.)), \
  direction=N.array((0,0,1.0)), \
  max_Z=2., max_R=2.)
universe.setForceField(ff1)

e, g = universe.energyAndGradients()
print universe.energyTerms()
print e

gradientTest(universe, delta=0.001)
#forceConstantTest(universe)