示例#1
0
def run(tgz, skip=[], atol_map={}):
    tgz_path = os.path.dirname(tgz)
    unpack_path = tgz.replace('.tgz', '')
    common.system("tar -C {0} -xzf {1}".format(tgz_path, tgz))
    tr1 = io.read_lammps_md_txt("{0}/log.lammps".format(unpack_path))
    tr2 = io.read_lammps_md_dcd("{0}/log.lammps".format(unpack_path))
    for name in tr1.attr_lst:
        if name in skip:
            continue
        elif name in atol_map:
            set_atol(atol_map[name])
        else:
            set_atol()
        x1 = getattr(tr1, name)
        x2 = getattr(tr2, name)
        print(name)
        tools.assert_all_types_almost_equal(x1, x2)
    # stress
    assert (tr1.stress[:, 0, 1] == tr1.stress[:, 1, 0]).all()
    assert (tr1.stress[:, 0, 2] == tr1.stress[:, 2, 0]).all()
    assert (tr1.stress[:, 1, 2] == tr1.stress[:, 2, 1]).all()
示例#2
0
def run(tgz, skip=[], atol_map={}):
    tgz_path = os.path.dirname(tgz)
    unpack_path = tgz.replace('.tgz','')
    common.system("tar -C {0} -xzf {1}".format(tgz_path,tgz))
    tr1 = io.read_lammps_md_txt("{0}/log.lammps".format(unpack_path))
    tr2 = io.read_lammps_md_dcd("{0}/log.lammps".format(unpack_path))
    for name in tr1.attr_lst:
        if name in skip:
            continue
        elif atol_map.has_key(name):
            set_atol(atol_map[name])
        else:
            set_atol()
        x1 = getattr(tr1, name)
        x2 = getattr(tr2, name)
        print name
        tools.assert_all_types_almost_equal(x1, x2) 
    # stress
    assert (tr1.stress[:,0,1] == tr1.stress[:,1,0]).all()
    assert (tr1.stress[:,0,2] == tr1.stress[:,2,0]).all()
    assert (tr1.stress[:,1,2] == tr1.stress[:,2,1]).all()
示例#3
0
文件: run.py 项目: elcorto/pwtools
# create structure file
st = crys.Structure(coords_frac=np.array([[0.0]*3, [.5]*3]),
                    cryst_const=np.array([2.85]*3 + [60]*3),
                    symbols=['Al','N'])
io.write_lammps('lmp.struct', crys.scell(st,(3,3,3)))

# write lmp.in for nvt or npt
common.file_write('lmp.in', lmp_in_templ.format(ensemble=ens_txt))

# run lammps
common.system("mpirun -np 2 lammps < lmp.in", wait=True)

# read trajectory
trtxt_orig = io.read_lammps_md_txt('log.lammps')
trdcd = io.read_lammps_md_dcd('log.lammps')

# plotting
plots = mpl.prepare_plots(['coords', 'coords_frac', 'velocity', 
                           'cryst_const', 'cell'])
for name,pl in plots.iteritems():
    trtxt = trtxt_orig.copy()
    print name
    xtxt = getattr(trtxt, name)
    setattr(trtxt, name, None)
    xcalc = eval('trtxt.get_%s()' %name)
    if name == 'cell':
        sl = np.s_[Ellipsis]
        func = lambda x: np.reshape(x, (x.shape[0], 9))
    elif name in trtxt.attrs_nstep_3d:
        # coords_frac and coords: only x-coord (index=0)
示例#4
0
# create structure file
st = crys.Structure(coords_frac=np.array([[0.0]*3, [.5]*3]),
                    cryst_const=np.array([2.85]*3 + [60]*3),
                    symbols=['Al','N'])
io.write_lammps('lmp.struct', crys.scell(st,(3,3,3)))

# write lmp.in for nvt or npt
common.file_write('lmp.in', lmp_in_templ.format(ensemble=ens_txt))

# run lammps
common.system("mpirun -np 2 lammps < lmp.in", wait=True)

# read trajectory
trtxt_orig = io.read_lammps_md_txt('log.lammps')
trdcd = io.read_lammps_md_dcd('log.lammps')

# plotting
plots = mpl.prepare_plots(['coords', 'coords_frac', 'velocity', 
                           'cryst_const', 'cell'])
for name,pl in plots.items():
    trtxt = trtxt_orig.copy()
    print(name)
    xtxt = getattr(trtxt, name)
    setattr(trtxt, name, None)
    xcalc = eval('trtxt.get_%s()' %name)
    if name == 'cell':
        sl = np.s_[Ellipsis]
        func = lambda x: np.reshape(x, (x.shape[0], 9))
    elif name in trtxt.attrs_nstep_3d:
        # coords_frac and coords: only x-coord (index=0)