How to use pyscal - 10 common examples

To help you get started, we’ve selected a few pyscal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github srmnitc / pyscal / tests / test_traj_process.py View on Github external
def test_customvals_dump():
    """
    Test writing customvals
    """
    atoms, boxdims = pcs.make_crystal('bcc', repetitions=[1,1,1])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims


    #test for multiple customvals
    customks = 'one'
    customvs = [1,1]
    ptp.write_structure(sys, "tests/bcc4.dump", customkey=customks, customvals=customvs)

    #now read this file
    lines = []
    for line in open("tests/bcc4.dump", 'r'):
        lines.append(line)

    #now check the atoms
    last1line = lines[-1].strip().split()
    last2line = lines[-2].strip().split()
    last3line = lines[-3].strip().split()

    #now verify
    assert last1line[-1] == '1'
    assert last2line[-1] == '1'
    assert last3line[-1] == 'one'
github srmnitc / pyscal / tests / test_nucsize.py View on Github external
def test_system_nucsize_fraction():
    #create some atoms
    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [2, 2, 2])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims

    #test that atoms are set properly
    assert len(sys.atoms) == 16

    #now calculate nucsize
    sys.find_neighbors(method='cutoff', cutoff=3.63)
    assert 16 == sys.find_solids(bonds=0.8, threshold=0.5, avgthreshold=0.6, cluster=True)
github srmnitc / pyscal / tests / test_nucsize.py View on Github external
def test_complex_system():
    sys = pc.System()
    sys.read_inputfile('examples/cluster.dump')
    sys.find_neighbors(method='cutoff', cutoff=3.63)
    assert 176 == sys.find_solids(bonds=6, threshold=0.5, avgthreshold=0.6, cluster=True)
github srmnitc / pyscal / tests / test_neighbors.py View on Github external
def test_neighbors_system():
    #create some atoms
    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [6, 6, 6])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims

    #test that atoms are set properly
    assert len(sys.atoms) == 432

    #then lets find neighbors
    #cutoff method - first shell only
    sys.find_neighbors(method = 'cutoff', cutoff=0.867)
    #any atom should have 8 neighbors
    atoms = sys.atoms
    assert atoms[0].coordination == 8

    sys.reset_neighbors()

    #cutoff method - second shell
github srmnitc / pyscal / tests / test_traj_process.py View on Github external
def test_create_multislice_dump():
    """
    Create a multitest dump file and test it
    """
    atoms, boxdims = pcs.make_crystal('bcc', repetitions=[6,6,6])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims

    ptp.write_structure(sys, "tests/bcc1.dump")

    atoms2, boxdims2 = pcs.make_crystal('bcc', repetitions=[6,6,6])
    #modify the coordinates of one atom
    x  = atoms2[0].pos
    x[0] += 0.01
    atoms2[0].pos = x
    assert len(atoms2) == 432
    #write it out
    sys2 = pc.System()
    sys2.atoms = atoms2
    sys2.box = boxdims2
github srmnitc / pyscal / tests / test_q2.py View on Github external
def test_q_2():
    #this might take a while, it will find all qs
    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [6, 6, 6])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims
    #sys.read_inputfile("tests/bcc.dat")
    sys.find_neighbors(method = 'voronoi')
    #sys.get_neighbors(method = 'cutoff', cutoff=0.9)

    sys.calculate_q(2)
    q = sys.get_qvals(2)
    assert np.round(np.mean(np.array(q)), decimals=2) == 0.00
github srmnitc / pyscal / tests / test_pickling.py View on Github external
def test_pickle_system():

    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [1, 1, 1])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims
    sys.find_neighbors(method = 'voronoi')

    #test write and read system
    sys.to_pickle('tests/sy.npy')

    #now read the pickled system
    psys = pc.System()
    psys.from_pickle('tests/sy.npy')

    #now get atoms and a random number of atom
    satoms = sys.atoms
    patoms = psys.atoms

    rn = np.random.randint(0, len(satoms)-1)
github srmnitc / pyscal / tests / test_q10.py View on Github external
def test_q_10():
    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [4, 4, 4])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims

    sys.find_neighbors(method = 'voronoi')

    sys.calculate_q(10, averaged=True)
    q = sys.get_qvals(10, averaged=True)
    assert np.round(np.mean(np.array(q)), decimals=2) == 0.41
github srmnitc / pyscal / tests / test_q8.py View on Github external
def test_q_8():
    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [4, 4, 4])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims

    sys.find_neighbors(method = 'voronoi')

    sys.calculate_q(8, averaged=True)
    q = sys.get_qvals(8, averaged=True)
    assert np.round(np.mean(np.array(q)), decimals=2) == 0.33
github srmnitc / pyscal / tests / test_voronoi.py View on Github external
def test_voro_props():
    atoms, boxdims = pcs.make_crystal('bcc', repetitions = [2, 2, 2])
    sys = pc.System()
    sys.atoms = atoms
    sys.box = boxdims


    sys.find_neighbors(method = 'voronoi')
    sys.calculate_vorovector()
    atoms = sys.atoms
    atom = atoms[0]
    v = atom.vorovector
    assert v == [0,6,0,8]