def test_scf_cell():
    filename = 'files/pw.vc_relax_coords_fixed.out'
    common.system('gunzip %s.gz' %filename)
    
    pp = parse.PwSCFOutputFile(filename, use_alat=False)
    cell_2d_red = pp.get_cell()
    assert np.allclose(cell_2d_red, cell_2d_red_ref, atol=1e-15, rtol=0)
    
    pp = parse.PwSCFOutputFile(filename, use_alat=True)
    assert np.allclose(pp.get_cell(), 
                       cell_2d_red*pp.get_alat(), 
                       atol=1e-15,
                       rtol=0)
    
    st = io.read_pw_scf(filename)
    tr = io.read_pw_md(filename)

    # tr is from a vc-relax w/ fixed fractional coords, check that
    assert np.allclose(np.zeros((tr.nstep,tr.natoms,3)), 
                       tr.coords_frac - tr.coords_frac[0,...].copy(),
                       rtol=0, atol=1e-15)

    # check if scf parser gets the same coords_frac as the trajectory parser
    # Note: this and the next test have the same max error of
    # 4.33868466709e-08 (b/c of limited accuracy in printed numbers in
    # pwscf output)
    assert np.allclose(st.coords_frac,tr.coords_frac[0,...], atol=1e-7, rtol=0)
    
    # same test, plus test of concatenate() works
    trcat = crys.concatenate((st,tr))
    assert np.allclose(np.zeros((trcat.nstep,trcat.natoms,3)), 
                       trcat.coords_frac - trcat.coords_frac[0,...].copy(),
                       rtol=0, atol=1e-7)
Beispiel #2
0
def test_scf_cell():
    filename = 'files/pw.vc_relax_coords_fixed.out'
    common.system('gunzip %s.gz' % filename)

    pp = parse.PwSCFOutputFile(filename, use_alat=False)
    cell_2d_red = pp.get_cell()
    assert np.allclose(cell_2d_red, cell_2d_red_ref, atol=1e-15, rtol=0)

    pp = parse.PwSCFOutputFile(filename, use_alat=True)
    assert np.allclose(pp.get_cell(),
                       cell_2d_red * pp.get_alat(),
                       atol=1e-15,
                       rtol=0)

    st = io.read_pw_scf(filename)
    tr = io.read_pw_md(filename)

    # tr is from a vc-relax w/ fixed fractional coords, check that
    assert np.allclose(np.zeros((tr.nstep, tr.natoms, 3)),
                       tr.coords_frac - tr.coords_frac[0, ...].copy(),
                       rtol=0,
                       atol=1e-15)

    # check if scf parser gets the same coords_frac as the trajectory parser
    # Note: this and the next test have the same max error of
    # 4.33868466709e-08 (b/c of limited accuracy in printed numbers in
    # pwscf output)
    assert np.allclose(st.coords_frac,
                       tr.coords_frac[0, ...],
                       atol=1e-7,
                       rtol=0)

    # same test, plus test of concatenate() works
    trcat = crys.concatenate((st, tr))
    assert np.allclose(np.zeros((trcat.nstep, trcat.natoms, 3)),
                       trcat.coords_frac - trcat.coords_frac[0, ...].copy(),
                       rtol=0,
                       atol=1e-7)
Beispiel #3
0
import os
import numpy as np
from matplotlib import pyplot as plt
from pwtools import parse, crys, constants, common, io

pj = os.path.join

if __name__ == '__main__':
    
    tmpdir = '/tmp/rpdf_vmd_test/'
    if not os.path.exists(tmpdir):
        os.makedirs(tmpdir)
    dct = {}
    
    common.system("gunzip pw.out.gz")
    traj = io.read_pw_md('pw.out')
    common.system("gzip pw.out")
    symbols = np.array(traj.symbols)
    
    # O_Ca
    msk1 = symbols=='O'
    msk2 = symbols=='Ca'
    amask = [msk1, msk2]
    tmask = np.s_[-1]
    dct['O:Ca:-1:-1'] = {'amask': amask, 'tmask': tmask}
    tmask = np.s_[0:]
    dct['O:Ca:0:-1'] = {'amask': amask, 'tmask': tmask}
    
    # Ca_O
    msk1 = symbols=='Ca'
    msk2 = symbols=='O'
Beispiel #4
0
import os
import numpy as np
from matplotlib import pyplot as plt
from pwtools import parse, crys, constants, common, io

pj = os.path.join

if __name__ == '__main__':

    tmpdir = '/tmp/rpdf_vmd_test/'
    if not os.path.exists(tmpdir):
        os.makedirs(tmpdir)
    dct = {}

    common.system("gunzip pw.out.gz")
    traj = io.read_pw_md('pw.out')
    common.system("gzip pw.out")
    symbols = np.array(traj.symbols)

    # O_Ca
    msk1 = symbols == 'O'
    msk2 = symbols == 'Ca'
    amask = [msk1, msk2]
    tmask = np.s_[-1]
    dct['O:Ca:-1:-1'] = {'amask': amask, 'tmask': tmask}
    tmask = np.s_[0:]
    dct['O:Ca:0:-1'] = {'amask': amask, 'tmask': tmask}

    # Ca_O
    msk1 = symbols == 'Ca'
    msk2 = symbols == 'O'