def setup_aatopology(self): GMIN.initialize() pot = GMINPotential(GMIN) coords = pot.getCoords() nrigid = old_div(coords.size, 6) print("I have %d water molecules in the system"%nrigid) print("The initial energy is", pot.getEnergy(coords)) water = create_base() system = RBTopology() system.add_sites([deepcopy(water) for i in range(nrigid)]) self.potential = pot self.nrigid = nrigid self.render_scale = 0.15 self.atom_types = system.get_atomtypes() self.draw_bonds = [] for i in range(nrigid-1): self.draw_bonds.append((2*i, 2*i+1)) self.draw_bonds.append((2*i, 2*i+2)) return system
def setup_aatopology(self): GMIN.initialize() pot = GMINPotential(GMIN) coords = pot.getCoords() nrigid = coords.size / 6 print "I have %d water molecules in the system"%nrigid print "The initial energy is", pot.getEnergy(coords) water = create_base() system = RBTopology() system.add_sites([deepcopy(water) for i in xrange(nrigid)]) self.potential = pot self.nrigid = nrigid self.render_scale = 0.15 self.atom_types = system.get_atomtypes() self.draw_bonds = [] for i in xrange(nrigid-1): self.draw_bonds.append((2*i, 2*i+1)) self.draw_bonds.append((2*i, 2*i+2)) return system
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)
self.add_option("--block1",type="int", dest="block1", default=100, help="maximum number of steps with no improvement", group="Basinhopping") def create_basinhopping(self, add_minimum=None, potential=None): if(self.target != None): add_minimum = self.check_converged self.opt = AppBasinHopping.create_basinhopping(self, add_minimum=add_minimum) return self.opt def check_converged(self, E, coords): if(E<(self.target+EDIFF)): print "#found minimum" t1= time.clock() timespent= t1 - t0 print "quenches functioncalls timespent" print "%d %d %f"%(self.opt.stepnum, self.potential.ncalls, timespent) exit() if __name__ == "__main__": # let GMIN do some initialization GMIN.initialize() # create a OXDNA application app = AppOXDNA() # and run it app.execute()
def main(): # add some program options parser = OptionParser(usage="usage: %prog [options] storage") parser.add_option( "--write-disconnect", dest="writeDPS", action="store_true", help="generate min.dat and ts.dat to use with disconnectDPS") parser.add_option("-m", dest="writeMinima", action="store_true", help="dump minima to screen") parser.add_option("-t", dest="writeTS", action="store_true", help="dump transition states to screen") parser.add_option("--coords", dest="writeCoords", action="store_true", help="export coordinates files") parser.add_option("--xyz", dest="writeXYZ", action="store_true", help="export xyz files") (options, args) = parser.parse_args() # print help if no input file is given if (len(args) != 1): parser.print_help() exit(-1) db = Database(db=args[0]) if (options.writeMinima): print "List of minima:" print "---------------" for m in db.minima(): print "%f\t\tid %d" % (m.energy, m._id) print "END\n" if (options.writeTS): print "List of transition states:" print "--------------------------" for ts in db.transition_states(): print "%d\t<->\t%d\tid %d\tenergies %f %f %f"%\ (ts.minimum1._id, ts.minimum2._id, ts._id, ts.minimum1.energy, ts.energy, ts.minimum2.energy) print "END\n" if (options.writeDPS): writeDPS(db) if (options.writeCoords): GMIN.initialize() i = 0 for m in db.minima(): i += 1 filename = "lowest/lowest%03d.cif" % (i) print "minimum", i, "energy", m.energy, "to", filename GMIN.userpot_dump(filename, m.coords) if (not TO_PDB is None): os.system(TO_PDB % filename) np.savetxt("lowest/coords_%03d.txt" % (i), m.coords) if (options.writeXYZ): traj = open("lowest/traj.xyz", "w") i = 0 for m in db.minima(): i += 1 filename = "lowest/lowest%03d.xyz" % (i) print "minimum", i, "energy", m.energy, "to", filename export_xyz(open(filename, "w"), m.coords) export_xyz(traj, m.coords) traj.close()
def main(): # add some program options parser = OptionParser(usage = "usage: %prog [options] storage") parser.add_option("--write-disconnect", dest="writeDPS", action="store_true", help="generate min.dat and ts.dat to use with disconnectDPS") parser.add_option("-m", dest="writeMinima", action="store_true", help="dump minima to screen") parser.add_option("-t", dest="writeTS", action="store_true", help="dump transition states to screen") parser.add_option("--coords", dest="writeCoords", action="store_true", help="export coordinates files") parser.add_option("--xyz", dest="writeXYZ", action="store_true", help="export xyz files") (options, args) = parser.parse_args() # print help if no input file is given if(len(args) != 1): parser.print_help() exit(-1) db = Database(db=args[0]) if(options.writeMinima): print "List of minima:" print "---------------" for m in db.minima(): print "%f\t\tid %d"%(m.energy, m._id) print "END\n" if(options.writeTS): print "List of transition states:" print "--------------------------" for ts in db.transition_states(): print "%d\t<->\t%d\tid %d\tenergies %f %f %f"%\ (ts.minimum1._id, ts.minimum2._id, ts._id, ts.minimum1.energy, ts.energy, ts.minimum2.energy) print "END\n" if(options.writeDPS): writeDPS(db) if(options.writeCoords): GMIN.initialize() i=0 for m in db.minima(): i+=1 filename = "lowest/lowest%03d.cif"%(i) print "minimum",i, "energy",m.energy,"to",filename GMIN.userpot_dump(filename, m.coords) if(not TO_PDB is None): os.system(TO_PDB%filename) np.savetxt("lowest/coords_%03d.txt"%(i), m.coords) if(options.writeXYZ): traj=open("lowest/traj.xyz", "w") i=0 for m in db.minima(): i+=1 filename = "lowest/lowest%03d.xyz"%(i) print "minimum",i, "energy",m.energy,"to",filename export_xyz(open(filename, "w"), m.coords) export_xyz(traj, m.coords) traj.close()