Beispiel #1
0
def test_glosim_molecules():
    is_pass = True

    # check if the same molecules give global similarity of around 1
    from ase.collections import g2
    myAlphas, myBetas = soaplite.genBasis.getBasisFunc(10.0, 5)
    for molname in g2.names:
        atoms = molecule(molname)
        local_a = soaplite.get_soap_structure(atoms,
                                              myAlphas,
                                              myBetas,
                                              rCut=10.0,
                                              NradBas=5,
                                              Lmax=5,
                                              crossOver=True)

        envkernel = compute_envkernel(local_a, local_a)
        glosim = rematch_entry(envkernel, gamma=0.01)

        if (0.99 < glosim < 1.01):
            pass
        else:
            is_pass = False

    # check randomly a few combinations of molecules, just for no errors
    all_atomtypes = [1, 6, 7, 8]
    for molname1 in g2.names:
        for molname2 in g2.names:
            if np.random.rand(1, 1) < 0.99:
                continue
            atoms1 = molecule(molname1)
            atoms2 = molecule(molname2)

            local_a = soaplite.get_soap_structure(atoms1,
                                                  myAlphas,
                                                  myBetas,
                                                  rCut=10.0,
                                                  NradBas=5,
                                                  Lmax=5,
                                                  crossOver=True,
                                                  all_atomtypes=all_atomtypes)
            local_b = soaplite.get_soap_structure(atoms2,
                                                  myAlphas,
                                                  myBetas,
                                                  rCut=10.0,
                                                  NradBas=5,
                                                  Lmax=5,
                                                  crossOver=True,
                                                  all_atomtypes=all_atomtypes)

            envkernel = compute_envkernel(local_a, local_b)
            glosim = rematch_entry(envkernel, gamma=0.01)
            #print(glosim)

    return is_pass
Beispiel #2
0
from soaplite import get_soap_structure
from soaplite import getBasisFunc
from ase.build import molecule

atoms = molecule('CO2')

a,b = getBasisFunc(5.0, 10)
x = get_soap_structure(atoms, a, b)


print(x.shape)
print(x)
start = time.time()
x = soaplite.get_soap_locals(atoms,
                             Hpos,
                             myAlphas,
                             myBetas,
                             rCut=10.0,
                             NradBas=5,
                             Lmax=5,
                             crossOver=True)
endTime = time.time()
totalTime = endTime - start
print("Soap ran in seconds:", totalTime)
np.savetxt('au40cu40H.txt', x)

#-------------- run local chemical environments on each atom ----------------
start = time.time()
y = soaplite.get_soap_structure(atoms,
                                myAlphas,
                                myBetas,
                                rCut=10.0,
                                NradBas=5,
                                Lmax=5,
                                crossOver=True)
endTime = time.time()
totalTime = endTime - start

print("Soap ran in seconds:", totalTime)
np.savetxt('structure_test.txt', y)
#------------ Check Results in *txt files --------------------------------
#------------ Make sure that rCut and N_max are the same across all calculations
Beispiel #4
0
                   0.95 * (1 + math.cos(76 / 180 * math.pi)),
                   0.95 * math.sin(76 / 180 * math.pi), 0.0
               ]],
    symbols=["H", "O", "H"],
)

# Test the GTO basis

myAlphas, myBetas = genBasis.getBasisFunc(10.0, 5)

atoms = orig_atoms.copy()

features = soaplite.get_soap_structure(atoms,
                                       myAlphas,
                                       myBetas,
                                       rCut=10.0,
                                       nMax=5,
                                       Lmax=9,
                                       crossOver=True)

for rotation in ['x', 'y', 'z']:

    # print("rotating in", rotation)

    atoms.rotate(45, rotation)

    rot_features = soaplite.get_soap_structure(atoms,
                                               myAlphas,
                                               myBetas,
                                               rCut=10.0,
                                               nMax=5,
                             rCut=10.0,
                             nMax=5,
                             Lmax=6,
                             crossOver=True,
                             eta=1.5)
endTime = time.time()
totalTime = endTime - start
print("Soap ran in seconds:", totalTime)
np.savetxt('au40cu40H.txt', x)

#-------------- run local chemical environments on each atom ----------------
start = time.time()
y = soaplite.get_soap_structure(atoms,
                                myAlphas,
                                myBetas,
                                rCut=10.0,
                                nMax=5,
                                Lmax=6,
                                crossOver=True,
                                eta=1.5)
endTime = time.time()
totalTime = endTime - start

print("Soap ran in seconds:", totalTime)
np.savetxt('structure_test.txt', y)
#-------------- one point----------------
Hpos = [[0, 0, 0]]
atoms = ase.io.read("onePoint.xyz")
start = time.time()
y = soaplite.get_soap_locals(atoms,
                             Hpos,
                             myAlphas,
Beispiel #6
0
import soaplite
import datetime
import ase
import numpy as np
from soaplite import genBasis
from numpy import genfromtxt
import time
x = []
#-------------- Define Structure ------------------------------------
for i in range(2,13):
  myAlphas, myBetas = genBasis.getBasisFunc(5.0, i) # input:(rCut, NradBas)
  atoms1 = ase.io.read("Structs/h2o.xyz")
  atoms2 = ase.io.read('Structs/h2oDiff.xyz')

#-------------- set Basis Function (rCut--soft, N_max) Environment ----------------

#-------------- run local chemical environments on each atom ----------------
#start = time.time()
  y1 = soaplite.get_soap_structure(atoms1, myAlphas, myBetas, rCut=5.0, NradBas=i, Lmax=9,crossOver=True) 
  y2 = soaplite.get_soap_structure(atoms2, myAlphas, myBetas, rCut=5.0, NradBas=i, Lmax=9,crossOver=True) 
#endTime = time.time()
#totalTime = endTime - start
  print(np.sum((y1 - y2)**2, axis=1)[2]) 
#print("Soap ran in seconds:", totalTime)
#np.savetxt('structure_test.txt',y)
#------------ Check Results in *txt files --------------------------------
#------------ Make sure that rCut and N_max are the same across all calculations 
Beispiel #7
0
my_alphas, my_betas = getBasisFunc(r_cut, n_max)

#--------- Get local chemical environments for each defined position -----------
x = get_soap_locals(atoms,
                    hpos,
                    my_alphas,
                    my_betas,
                    rCut=r_cut,
                    NradBas=n_max,
                    Lmax=l_max,
                    crossOver=True)

xs = get_soap_structure(atoms,
                        my_alphas,
                        my_betas,
                        rCut=r_cut,
                        NradBas=n_max,
                        Lmax=l_max,
                        crossOver=True)
# xps = get_periodic_soap_structure(atoms,
#
#     my_alphas,
#     my_betas,
#     rCut=r_cut,
#     NradBas=n_max,
#     Lmax=l_max,
#     crossOver=True)
# xp = get_periodic_soap_locals(atoms,
#     hpos,
#     my_alphas,
#     my_betas,
Beispiel #8
0
            #print(glosim)

    return is_pass


if __name__ == "__main__":
    print("Start")
    myAlphas, myBetas = soaplite.genBasis.getBasisFunc(
        10.0, 5)  # input:(rCut, NradBas)

    A = molecule('H2O')
    B = molecule('H2O2')
    local_a = soaplite.get_soap_structure(A,
                                          myAlphas,
                                          myBetas,
                                          rCut=10.0,
                                          NradBas=5,
                                          Lmax=5,
                                          crossOver=True)
    local_b = soaplite.get_soap_structure(B,
                                          myAlphas,
                                          myBetas,
                                          rCut=10.0,
                                          NradBas=5,
                                          Lmax=5,
                                          crossOver=True)

    envkernel = compute_envkernel(local_a, local_b)

    glosim = rematch_entry(envkernel, gamma=0.01)
Beispiel #9
0
atoms = ase.io.read("Structs/au40cu40.xyz")

#-------------- Define Position of Local Environment ----------------
#Hpos = [[1.0,2.0,3.0],[4.0,5.0,6.0],[7.0,8.0,9.0],[10.0,11.0,12.0]]
#Hpos = genfromtxt('Structs/mos2H.xyz').tolist()
Hpos = genfromtxt('Structs/au40cu40H.dat').tolist()

#-------------- set Basis Function (rCut--soft, N_max) Environment ----------------
myAlphas, myBetas = genBasis.getBasisFunc(10.0, 5)
print("hello")

#-------------- run local chemical environments on each atom ----------------
features = soaplite.get_soap_structure(atoms,
                                       myAlphas,
                                       myBetas,
                                       rCut=10.0,
                                       NradBas=5,
                                       Lmax=9,
                                       crossOver=True)
orig_atoms = atoms.copy()
# rotation check
for rotation in ['x', 'y', 'z']:
    print("rotating in", rotation)
    atoms.rotate(45, rotation)
    rot_features = soaplite.get_soap_structure(atoms,
                                               myAlphas,
                                               myBetas,
                                               rCut=10.0,
                                               NradBas=5,
                                               Lmax=9,
                                               crossOver=True)