Exemplo n.º 1
0
def test(X1, X2, lj, atomtypes=["LA"], fname = "lj.xyz",
         minPermDist=MinPermDistCluster()):
    import copy
    natoms = len(X1) / 3
        
    X1i = copy.copy(X1)
    X2i = copy.copy(X2)
    
    printlist = []
    printlist.append((X2.copy(), "X2 initial"))
    printlist.append((X1.copy(), "X1 initial"))


    distinit = np.linalg.norm(X1-X2)
    print "distinit", distinit

    (dist, X1, X2) = minPermDist(X1,X2)
    distfinal = np.linalg.norm(X1-X2)
    print "dist returned    ", dist
    print "dist from coords ", distfinal
    print "initial energies (post quench)", lj.getEnergy(X1i), lj.getEnergy(X2i)
    print "final energies                ", lj.getEnergy(X1), lj.getEnergy(X2)

    printlist.append((X1.copy(), "X1 final"))
    printlist.append((X2.copy(), "X2 final"))


    import pygmin.printing.print_atoms_xyz as printxyz
    with open(fname, "w") as fout:
        for xyz, line2 in printlist:
            printxyz.printAtomsXYZ(fout, xyz, line2=line2 +" "+ str(lj.getEnergy(xyz)))
Exemplo n.º 2
0
def test(coords1, coords2, mysys, permlist):
    printlist = []
    printlist.append((coords1.copy(), "after quench"))
    printlist.append((coords2.copy(), "after quench"))
    coords2in = coords2.copy()
    coords1in = coords1.copy()


    distinit = getDistaa(coords1, coords2, mysys)
    print "distinit", distinit

    (dist, coords1, coords2) = minPermDistRBMol(coords1,coords2, mysys, permlist=permlist)
    distfinal = getDistaa(coords1, coords2, mysys)
    print "dist returned    ", dist
    print "dist from coords ", distfinal
    print "coords2 initial energy", mysys.getEnergy(coords2in)
    print "coords2 final energy  ", mysys.getEnergy(coords2)
    print "coords1 initial energy", mysys.getEnergy(coords1in)
    print "coords1 final energy  ", mysys.getEnergy(coords1)


    printlist.append((coords1.copy(), "coords1 after mindist"))
    printlist.append((coords2.copy(), "coords2 after mindist"))
    import pygmin.printing.print_atoms_xyz as printxyz
    with open("otp.xyz", "w") as fout:
        for coords, line2 in printlist:
            xyz = mysys.getxyz(coords)
            printxyz.printAtomsXYZ(fout, xyz, line2=line2, atom_type = ["N", "O", "O"])
    
    
    return dist, coords1, coords2
Exemplo n.º 3
0
def main():
    natoms = 5
    X1 = np.random.uniform(-1, 1, [natoms * 3]) * (float(natoms)) ** (1.0 / 3)
    X2 = np.random.uniform(-1, 1, [natoms * 3]) * (float(natoms)) ** (1.0 / 3)

    # X1 = np.array( [ 0., 0., 0., 1., 0., 0., 0., 0., 1.,] )
    # X2 = np.array( [ 0., 0., 0., 1., 0., 0., 0., 1., 0.,] )
    import copy

    X1i = copy.copy(X1)
    X2i = copy.copy(X2)

    distinit = np.linalg.norm(X1 - X2)
    print "distinit", distinit

    dist, X1, X2 = minDist(X1, X2)
    distfinal = np.linalg.norm(X1 - X2)
    print "dist from eigenvalue", dist
    print "distfinal", distfinal

    import pygmin.printing.print_atoms_xyz as printxyz

    with open("out.xyz", "w") as fout:
        CoMToOrigin(X1i)
        CoMToOrigin(X2i)
        printxyz.printAtomsXYZ(fout, X1i)
        printxyz.printAtomsXYZ(fout, X2i)
        printxyz.printAtomsXYZ(fout, X1)
        printxyz.printAtomsXYZ(fout, X2)
Exemplo n.º 4
0
def main():
    natoms = 9
    X1 = np.random.uniform(-1,1,[natoms*3])*(float(natoms))**(1./3)
    X2 = np.random.uniform(-1,1,[natoms*3])*(float(natoms))**(1./3)

    #X1 = np.array( [ 0., 0., 0., 1., 0., 0., 0., 0., 1.,] )
    #X2 = np.array( [ 0., 0., 0., 1., 0., 0., 0., 1., 0.,] )
    import copy
    X1i = copy.copy(X1)
    X2i = copy.copy(X2)

    distinit = np.linalg.norm(X1-X2)
    print "distinit", distinit

    (dist, X1, X2) = minPermDistLong(X1,X2)
    distfinal = np.linalg.norm(X1-X2)
    print "dist returned    ", dist
    print "dist from coords ", distfinal

    import pygmin.printing.print_atoms_xyz as printxyz
    with open("out.xyz", "w") as fout:
        CoMToOrigin(X1i)
        CoMToOrigin(X2i)
        printxyz.printAtomsXYZ(fout, X1i )
        printxyz.printAtomsXYZ(fout, X2i )
        printxyz.printAtomsXYZ(fout, X1 )
        printxyz.printAtomsXYZ(fout, X2 )
Exemplo n.º 5
0
import ambgmin_ as GMIN
import pygmin.potentials.gminpotential as gminpot
import numpy as np
import pygmin.basinhopping as bh
from pygmin.optimize import _quench as quench
from pygmin.takestep import displace

# export PYTHONPATH=/home/ss2029/svn/GMIN/bin:$PWD/../..

GMIN.initialize()   
pot = gminpot.GMINPotental(GMIN)

coords = pot.getCoords()

step = displace.RandomDisplacement(stepsize=0.7)

opt = bh.BasinHopping(coords, pot, takeStep=step, quenchRoutine=quench.lbfgs_py)
opt.quenchParameters['tol'] = 1e-4
opt.run(3)

# some visualization
try: 
    import pygmin.utils.pymolwrapper as pym
    pym.start()
    pym.draw_spheres(opt.coords, "A", 1)
except:
    print "Could not draw using pymol, skipping this step"
import pygmin.printing.print_atoms_xyz as pr
pr.printAtomsXYZ(open("final.xyz", "w"), opt.coords)