예제 #1
0
파일: oxdna.py 프로젝트: yfyh2013/PyGMIN
import numpy as np
import oxdnagmin_ as GMIN
from pygmin.potentials.gminpotential import GMINPotential
import pygmin.basinhopping as bh
from pygmin.takestep import displace
from pygmin.storage.database import Database

# initialize GMIN
GMIN.initialize()
# create a potential which calls GMIN
potential = GMINPotential(GMIN)
# get the initial coorinates
coords = potential.getCoords()
coords = np.random.random(coords.shape)
# create takestep routine
step = displace.RandomDisplacement(stepsize=1.)

# store all minima in a database
db = Database(db="storage.sqlite", accuracy=1e-2)

# create Basinhopping object
opt = bh.BasinHopping(coords, potential, step, db.minimum_adder())

# run for 100 steps
opt.run(1000)

# now dump all the minima
i = 0
for m in db.minima():
    i += 1
    GMIN.userpot_dump("lowest_%03d.dat" % (i), m.coords)
예제 #2
0
            for i in xrange(index, ca.nrigid):
                a = np.dot(rotations.aa2mx(ca.rotRigid[i]), np.array([1., 0., 0.]))
                ca.rotRigid[i] = rotations.rotate_aa(p, ca.rotRigid[i])
                x = ca.posRigid[i] - 0.4*a
                ca.posRigid[i] = np.dot(mx, x - center) + center
                a = np.dot(rotations.aa2mx(ca.rotRigid[i]), np.array([1., 0., 0.]))
                ca.posRigid[i]+=0.4*a
            
# this is necessary for adaptive step taking
    def scale(self, factor):
        self.stepsize *= factor
        
# initialize GMIN
GMIN.initialize()
# create a potential which calls GMIN
potential = GMINPotential(GMIN)
# get the initial coorinates
coords=potential.getCoords()
# create takestep routine

step = OXDNAScrewTakestep()
#os.system(TO_PDB%"before.dat")
out = open("traj.xyz", "w")
export_xyz(out, coords)
for i in xrange(1,10):
    step.takeStep(coords)
    coords_opt, E, rms, fcalls = lbfgs_py(coords, potential.getEnergyGradient)
    print E, fcalls
    export_xyz(out, coords)
    coords = coords_opt
    export_xyz(out, coords)
예제 #3
0
parser.add_option("--maxstep",
                  dest="maxstep",
                  type=float,
                  default=0.1,
                  help="maximum stepsize for minimizer")
parser.add_option("-o",
                  dest="outfile",
                  default="results.txt",
                  help="outfile for results")

(options, args) = parser.parse_args()

configurations = pickle.load(open("quench_benchmark.dat"))

GMIN.initialize()
pot = GMINPotential(GMIN)

#fl = open("quenched.xyz", "w")
res = open("results.txt", "w")

t0 = time.time()
print "# energy nsteps rms"
res.write("# energy nsteps rms\n")
for coords in configurations[0:5]:
    ret = mylbfgs(coords,
                  pot.getEnergyGradient,
                  tol=options.tol,
                  M=options.M,
                  maxstep=options.maxstep,
                  maxErise=options.maxErise)
    energy = ret[1]
예제 #4
0
파일: dmagmin.py 프로젝트: wwwtyro/PyGMIN
 def getEnergyGradient(self, coords):        
     E, g = GMINPotential.getEnergyGradient(self, coords)
     if self.freeze_lattice:
         g[-6:]=0.
     g*=self.energy_unit
     return self.energy_unit * E, g
예제 #5
0
파일: dmagmin.py 프로젝트: wwwtyro/PyGMIN
 def getEnergy(self, coords):
     return self.energy_unit * GMINPotential.getEnergy(self, coords)
예제 #6
0
파일: dmagmin.py 프로젝트: wwwtyro/PyGMIN
 def __init__(self):
     GMINPotential.__init__(self, GMIN)
     self.energy_unit = self.ENERGY_IN_KJMOL
     self.freeze_lattice = False