Example #1
0
def size_scaling_smallest_eig(natoms):
    from pygmin.systems import LJCluster
    import time, sys
    system = LJCluster(natoms)
    pot = system.get_potential()
    quencher = system.get_minimizer(tol=10.)

    time1 = 0.
    time2 = 0.
    time3 = 0.
    time4 = 0.
    for i in range(100):
        coords = system.get_random_configuration()
        #        print "len(coords)", len(coords)
        coords = quencher(coords)[0]
        e, g, h = pot.getEnergyGradientHessian(coords)

        t0 = time.time()
        w1, v1 = get_smallest_eig(h)
        t1 = time.time()
        w, v = get_smallest_eig_arpack(h)
        t2 = time.time()
        w2, v2 = get_smallest_eig_sparse(h)
        t3 = time.time()
        w3, v3 = get_smallest_eig_nohess(coords, system, tol=1e-3)
        t4 = time.time()

        time1 += t1 - t0
        time2 += t2 - t1
        time3 += t3 - t2
        time4 += t4 - t3

        wdiff = np.abs(w - w1) / np.max(np.abs([w, w1]))
        if wdiff > 5e-3:
            sys.stderr.write(
                "eigenvalues for dense  are different %g %g normalized diff %g\n"
                % (w1, w, wdiff))
        wdiff = np.abs(w - w2) / np.max(np.abs([w, w2]))
        if wdiff > 5e-2:
            sys.stderr.write(
                "eigenvalues for sparse are different %g %g normalized diff %g\n"
                % (w2, w, wdiff))
        wdiff = np.abs(w - w3) / np.max(np.abs([w, w3]))
        if wdiff > 5e-2:
            sys.stderr.write(
                "eigenvalues for nohess are different %g %g normalized diff %g\n"
                % (w3, w, wdiff))


#    print "times", n, t1-t0, t2-t1, w1, w
    print "times", n, time1, time2, time3, time4
    sys.stdout.flush()
Example #2
0
def size_scaling_smallest_eig(natoms):
    from pygmin.systems import LJCluster
    import time, sys
    system = LJCluster(natoms)
    pot = system.get_potential()
    quencher = system.get_minimizer(tol=10.)
    
    time1 = 0.
    time2 = 0.
    time3 = 0.
    time4 = 0.
    for i in range(100):
        coords = system.get_random_configuration()
#        print "len(coords)", len(coords)
        coords = quencher(coords)[0]
        e, g, h = pot.getEnergyGradientHessian(coords)
        
        t0 = time.time()
        w1, v1 = get_smallest_eig(h)
        t1 = time.time()
        w, v = get_smallest_eig_arpack(h)
        t2 = time.time()
        w2, v2 = get_smallest_eig_sparse(h)
        t3 = time.time()
        w3, v3 = get_smallest_eig_nohess(coords, system, tol=1e-3)
        t4 = time.time()
        
        time1 += t1-t0
        time2 += t2-t1
        time3 += t3-t2
        time4 += t4-t3
        
        wdiff = np.abs(w-w1) / np.max(np.abs([w,w1]))
        if wdiff > 5e-3:
            sys.stderr.write("eigenvalues for dense  are different %g %g normalized diff %g\n" % (w1, w, wdiff))
        wdiff = np.abs(w-w2) / np.max(np.abs([w,w2]))
        if wdiff > 5e-2:
            sys.stderr.write("eigenvalues for sparse are different %g %g normalized diff %g\n" % (w2, w, wdiff))
        wdiff = np.abs(w-w3) / np.max(np.abs([w,w3]))
        if wdiff > 5e-2:
            sys.stderr.write("eigenvalues for nohess are different %g %g normalized diff %g\n" % (w3, w, wdiff))
#    print "times", n, t1-t0, t2-t1, w1, w
    print "times", n, time1, time2, time3, time4
    sys.stdout.flush()
Example #3
0
    pl.show()


if __name__ == "__main__":
    from pygmin.systems import LJCluster
    natoms = 30
    system = LJCluster(natoms)
    pot = system.get_potential()
    coords = system.get_random_configuration()

    xmin = system.get_random_minimized_configuration()[0]
    e, g, h = pot.getEnergyGradientHessian(xmin)
    evals = get_eigvals(h)
    print evals

    quencher = system.get_minimizer(tol=10.)
    coords = quencher(coords)[0]
    e, g, h = pot.getEnergyGradientHessian(coords)
    w1, v1 = get_smallest_eig(h)
    print w1
    w, v = get_smallest_eig_arpack(h)
    print w
    w2, v2 = get_smallest_eig_sparse(h)
    print w2, w2 / w1
    w3, v3 = get_smallest_eig_nohess(coords, system)
    print w3, w3 / w1
    #    plot_hist(h)
    #    exit()

    if False:
        n = 10
from pygmin.utils.disconnectivity_graph import DisconnectivityGraph, database2graph

# initialize the system class
natoms = 13
system = LJCluster(natoms)

# make a random configuration
coords = system.get_random_configuration()

# compute the energy of that configuration
potential = system.get_potential()
energy = potential.getEnergy(coords)
print "the energy of the random configuration is", energy

# minimize that configuration
quencher = system.get_minimizer()
ret = quencher(coords)
newcoords = ret[0]
newenergy = ret[1]
print "after quenching, the energy is", newenergy

# create a database to store the minimum in
db = system.create_database()
# note: this creates a database in memory, if you want to save the results
# you would use
# db = system.create_database("lj.sqlite")
minimum1 = db.addMinimum(newenergy, newcoords)

# get a second random minimized configuration and add it to the database
ret = system.get_random_minimized_configuration()
print "a second minimum has energy", ret[1]
Example #5
0
    pl.hist(np.log10(np.abs(hess.reshape(-1))))
    pl.show()

if __name__ == "__main__":
    from pygmin.systems import LJCluster
    natoms = 30
    system = LJCluster(natoms)
    pot = system.get_potential()
    coords = system.get_random_configuration()
    
    xmin = system.get_random_minimized_configuration()[0]
    e, g, h = pot.getEnergyGradientHessian(xmin)
    evals = get_eigvals(h)
    print evals

    quencher = system.get_minimizer(tol=10.)
    coords = quencher(coords)[0]
    e, g, h = pot.getEnergyGradientHessian(coords)
    w1, v1 = get_smallest_eig(h)
    print w1
    w, v = get_smallest_eig_arpack(h)
    print w
    w2, v2 = get_smallest_eig_sparse(h)
    print w2, w2/w1
    w3, v3 = get_smallest_eig_nohess(coords, system)
    print w3, w3/w1
#    plot_hist(h)
#    exit()
    
    if False:
        n = 10
Example #6
0
See the class LJCluster for what the default parameters are for this system
"""
import numpy as np

from pygmin.systems import LJCluster

natoms = 38
system = LJCluster(natoms)

# load the coordinates from disk
coords1 = np.genfromtxt("coords.A").flatten()
coords2 = np.genfromtxt("coords.B").flatten()

# minimize them
quencher = system.get_minimizer()
ret1 = quencher(coords1)
ret2 = quencher(coords2)

# make a database and add the minima
db = system.create_database()
coords, E = ret1[:2]
min1 = db.addMinimum(E, coords)
coords, E = ret2[:2]
min2 = db.addMinimum(E, coords)


#
# here is where we modify the parameters
#
"""