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 = tip4p.water() system = RBTopology() system.add_sites([deepcopy(water) for i in xrange(nrigid)]) self.potential = pot self.nrigid = nrigid self.render_scale = 0.3 self.atom_types = system.get_atomtypes() self.draw_bonds = [] for i in xrange(nrigid): self.draw_bonds.append((3 * i, 3 * i + 1)) self.draw_bonds.append((3 * i, 3 * 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
def __init__(self): BaseSystem.__init__(self) neb_params = BaseParameters() self.params["neb"]=neb_params neb_params["nimages"] = 15 neb_params["k"] = 10. neb_params["aadist"] = True defaults.NEBquenchParams["nsteps"] = 200 defaults.NEBquenchParams["iprint"] = 1 defaults.NEBquenchParams["maxstep"] = 0.1 #defaults.NEBquenchParams["maxErise"] = 0.1 defaults.NEBquenchParams["tol"] = 1e-6 defaults.NEBquenchRoutine = fire GMIN.initialize() pot = GMINPotential(GMIN) coords = pot.getCoords() nrigid = coords.size / 6 print "I have %d water molecules in the system"%nrigid water = tip4p.water() system = RBSystem() system.add_sites([deepcopy(water) for i in xrange(nrigid)]) self.aasystem = system self.potential = pot self.nrigid = nrigid
def create_basinhopping(self): potential = GMINPotential(GMIN) coords = potential.getCoords() # genearte a random configuration OXDNAReseed().takeStep(coords) opt = bh.BasinHopping(coords,potential, temperature=0.1, takeStep=self.create_takestep(), outstream = None) return opt
class OTPSystem(RBSystem): def __init__(self, nmol, boxl=None): # super(OTPSystem, self) self.nmol = nmol if boxl is None: self.periodic = False self.boxl = 1e100 else: self.periodic = True self.boxl = boxl super(OTPSystem, self).__init__() self.setup_params(self.params) def get_rigid_fragment(self): return RigidFragment() def make_otp(self): otp = self.get_rigid_fragment() otp.add_atom("O", np.array([0.0, -2. / 3 * np.sin(7. * pi / 24.), 0.0]), 1.) otp.add_atom( "O", np.array([cos(7. * pi / 24.), 1. / 3. * sin(7. * pi / 24.), 0.0]), 1.) otp.add_atom( "O", np.array([-cos(7. * pi / 24.), 1. / 3. * sin(7. * pi / 24), 0.0]), 1.) otp.finalize_setup() return otp def setup_params(self, params): params.gui["basinhopping_nsteps"] = 1000 nebparams = params.double_ended_connect.local_connect_params.NEBparams nebparams.max_images = 50 nebparams.image_density = 5 nebparams.iter_density = 10. nebparams.k = 5. nebparams.reinterpolate = 50 nebparams.NEBquenchParams["iprint"] = 10 tssearch = params.double_ended_connect.local_connect_params.tsSearchParams tssearch.nsteps_tangent1 = 10 tssearch.nsteps_tangent2 = 30 tssearch.lowestEigenvectorQuenchParams["nsteps"] = 50 tssearch.iprint = 1 tssearch.nfail_max = 100 def get_random_coordinates(self): coords = np.zeros([self.nmol * 2, 3]) coords[:self.nmol, :] = np.random.uniform( -1, 1, [self.nmol, 3]) * (self.nmol * 3)**(-1. / 3) * 1.5 from pygmin.utils.rotations import random_aa for i in range(self.nmol, self.nmol * 2): coords[i, :] = random_aa() return coords.flatten() def write_coords_data(self): coords = self.get_random_coordinates() coords = coords.reshape(-1, 3) with open("coords", "w") as fout: for xyz in coords: fout.write("%f %f %f\n" % tuple(xyz)) data = "LWOTP 2.614\n" if self.periodic: data += "periodic %f %f %f\n" % (self.boxl, self.boxl, self.boxl) with open("data", "w") as fout: fout.write(data) def setup_aatopology(self): self.write_coords_data() GMIN.initialize() self.pot = GMINPotential(GMIN) coords = self.pot.getCoords() self.nrigid = coords.size / 6 assert (self.nrigid == self.nmol) #self.nrigid = self.nmol otp = self.make_otp() topology = RBTopology() topology.add_sites([deepcopy(otp) for i in xrange(self.nrigid)]) self.render_scale = 0.2 self.atom_types = topology.get_atomtypes() self.draw_bonds = [] for i in xrange(self.nrigid): self.draw_bonds.append((3 * i, 3 * i + 1)) self.draw_bonds.append((3 * i, 3 * i + 2)) self.params.double_ended_connect.local_connect_params.tsSearchParams.iprint = 10 return topology def get_potential(self): #return OTPPotential(self.aasystem) return self.pot def __call__(self): return self def load_coords_pymol(self, coordslist, oname, index=1): import pymol super(OTPSystem, self).load_coords_pymol(coordslist, oname, index=index) pymol.cmd.set("sphere_scale", value=0.2, selection=oname)
class OTPSystem(RBSystem): def __init__(self, nmol, boxl=None): # super(OTPSystem, self) self.nmol = nmol if boxl is None: self.periodic = False self.boxl = 1e100 else: self.periodic = True self.boxl = boxl super(OTPSystem, self).__init__() self.setup_params(self.params) def get_rigid_fragment(self): return RigidFragment() def make_otp(self): otp = self.get_rigid_fragment() otp.add_atom("O", np.array([0.0, -2./3 * np.sin( 7.*pi/24.), 0.0]), 1.) otp.add_atom("O", np.array([cos( 7.*pi/24.), 1./3. * sin( 7.* pi/24.), 0.0]), 1.) otp.add_atom("O", np.array([-cos( 7.* pi/24.), 1./3. * sin( 7.*pi/24), 0.0]), 1.) otp.finalize_setup() return otp def setup_params(self, params): params.gui["basinhopping_nsteps"] = 1000 nebparams = params.double_ended_connect.local_connect_params.NEBparams nebparams.max_images = 50 nebparams.image_density = 5 nebparams.iter_density = 10. nebparams.k = 5. nebparams.reinterpolate = 50 nebparams.NEBquenchParams["iprint"] = 10 tssearch = params.double_ended_connect.local_connect_params.tsSearchParams tssearch.nsteps_tangent1 = 10 tssearch.nsteps_tangent2 = 30 tssearch.lowestEigenvectorQuenchParams["nsteps"] = 50 tssearch.iprint=1 tssearch.nfail_max = 100 def get_random_coordinates(self): coords = np.zeros([self.nmol*2, 3]) coords[:self.nmol,:] = np.random.uniform(-1,1,[self.nmol,3]) * (self.nmol*3)**(-1./3) * 1.5 from pygmin.utils.rotations import random_aa for i in range(self.nmol, self.nmol*2): coords[i,:] = random_aa() return coords.flatten() def write_coords_data(self): coords = self.get_random_coordinates() coords = coords.reshape(-1,3) with open("coords", "w") as fout: for xyz in coords: fout.write( "%f %f %f\n" % tuple(xyz) ) data = "LWOTP 2.614\n" if self.periodic: data += "periodic %f %f %f\n" % (self.boxl, self.boxl, self.boxl) with open("data", "w") as fout: fout.write(data) def setup_aatopology(self): self.write_coords_data() GMIN.initialize() self.pot = GMINPotential(GMIN) coords = self.pot.getCoords() self.nrigid = coords.size/6 assert(self.nrigid == self.nmol) #self.nrigid = self.nmol otp = self.make_otp() topology = RBTopology() topology.add_sites([deepcopy(otp) for i in xrange(self.nrigid)]) self.render_scale = 0.2 self.atom_types = topology.get_atomtypes() self.draw_bonds = [] for i in xrange(self.nrigid): self.draw_bonds.append((3*i, 3*i+1)) self.draw_bonds.append((3*i, 3*i+2)) self.params.double_ended_connect.local_connect_params.tsSearchParams.iprint = 10 return topology def get_potential(self): #return OTPPotential(self.aasystem) return self.pot def __call__(self): return self def load_coords_pymol(self, coordslist, oname, index=1): import pymol super(OTPSystem, self).load_coords_pymol(coordslist, oname, index=index) pymol.cmd.set("sphere_scale", value=0.2, selection=oname)
fl = open("stat.dat", "a") print "#found minimum" t1= time.clock() timespent= t1 - t0 fl.write("#quenches, functioncalls, time\n") fl.write("%d %d %f\n"%(opt.stepnum , potential.ncalls , timespent)) fl.close() exit() # 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 # we combine a normal step taking group = takestep.BlockMoves() step1 = takestep.AdaptiveStepsize(OXDNATakestep(displace=parameters.displace, rotate=0.), frequency=50) step2 = takestep.AdaptiveStepsize(OXDNATakestep(displace=0., rotate=parameters.rotate), frequency=50) group.addBlock(100, step1) group.addBlock(100, step2) # with a generate random configuration genrandom = OXDNAReseed() # in a reseeding takestep procedure reseed = takestep.Reseeding(group, genrandom, maxnoimprove=parameters.reseed)
import gmin_ as GMIN from pygmin.utils import rotations from pygmin.takestep import buildingblocks from pygmin.transition_states import NEB from pygmin import defaults import pylab as pl from copy import deepcopy, copy from pygmin.optimize import mylbfgs, fire from pygmin.angleaxis import RigidFragment, RBSystem import tip4p from tip4p import dump_path # initialize GMIN and potential GMIN.initialize() pot = GMINPotential(GMIN) coords = pot.getCoords() nrigid = coords.size / 6 print "I have %d water molecules in the system"%nrigid water = tip4p.water() #water.S = np.identity(3, dtype="float64") #water.S*=10. # define the whole water system system = RBSystem() system.add_sites([deepcopy(water) for i in xrange(nrigid)]) # this is an easy access wrapper for coordinates array ca = system.coords_adapter(coords)
fl = open("stat.dat", "a") print "#found minimum" t1 = time.clock() timespent = t1 - t0 fl.write("#quenches, functioncalls, time\n") fl.write("%d %d %f\n" % (opt.stepnum, potential.ncalls, timespent)) fl.close() exit() # 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 # we combine a normal step taking group = takestep.BlockMoves() step1 = takestep.AdaptiveStepsize(OXDNATakestep(displace=parameters.displace, rotate=0.), frequency=50) step2 = takestep.AdaptiveStepsize(OXDNATakestep(displace=0., rotate=parameters.rotate), frequency=50) group.addBlock(100, step1) group.addBlock(100, step2) # with a generate random configuration
from pygmin.potentials import GMINPotential import gmin_ as GMIN from pygmin.utils import rotations from pygmin.takestep import buildingblocks from pygmin.transition_states import NEB import pylab as pl from copy import deepcopy, copy from pygmin.optimize import mylbfgs from pygmin.angleaxis import RigidFragment, RBSystem import tip4p from tip4p import dump_path # initialize GMIN and potential GMIN.initialize() pot = GMINPotential(GMIN) coords = pot.getCoords() nrigid = coords.size / 6 print "I have %d water molecules in the system" % nrigid water = tip4p.water() #water.S = np.identity(3, dtype="float64") #water.S*=10. # define the whole water system system = RBSystem() system.add_sites([deepcopy(water) for i in xrange(nrigid)]) # this is an easy access wrapper for coordinates array ca = system.coords_adapter(coords)