How to use the pyscal.traj_process.write_structure function in pyscal

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_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

    ptp.write_structure(sys2, "tests/bcc2.dump")

    #now merge the two dump files
    os.system("cat tests/bcc1.dump tests/bcc2.dump > tests/bcc3.dat")
github srmnitc / pyscal / tests / test_traj_process.py View on Github external
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

    ptp.write_structure(sys2, "tests/bcc2.dump")

    #now merge the two dump files
    os.system("cat tests/bcc1.dump tests/bcc2.dump > tests/bcc3.dat")
    #os.remove("tests/bcc1.dump")
    #os.remove("tests/bcc2.dump")

    #now this file should have info of both - read it in
    sys3 = pc.System()
    sys3.read_inputfile("tests/bcc3.dat", frame=1)
    atoms = sys3.atoms
    assert len(atoms) == 432
    assert atoms[0].pos == [0.01,0,0]

    #now this file should have info of both - read it in
    sys4 = pc.System()
    sys4.read_inputfile("tests/bcc3.dat", frame=0)