示例#1
0
 def write_input(self, atoms, properties=None, system_changes=None):
     FileIOCalculator.write_input(self, atoms, properties,
                                  system_changes)
     if self.backup:
         for fn in [self.infile, self.outfile, self.dumpfile,
                    self.structfile, self.logfile]:
             if os.path.exists(fn):
                 common.backup(fn)
     common.file_write(self.infile, self.fill_infile_templ())
     io.write_lammps(self.structfile, 
                     crys.atoms2struct(atoms), 
                     symbolsbasename=os.path.basename(self.structfile) + \
                         '.symbols')
示例#2
0
 def write_input(self, atoms, properties=None, system_changes=None):
     FileIOCalculator.write_input(self, atoms, properties, system_changes)
     if self.backup:
         for fn in [
                 self.infile, self.outfile, self.dumpfile, self.structfile,
                 self.logfile
         ]:
             if os.path.exists(fn):
                 common.backup(fn)
     common.file_write(self.infile, self.fill_infile_templ())
     io.write_lammps(self.structfile,
                     crys.atoms2struct(atoms),
                     symbolsbasename=os.path.basename(self.structfile) + \
                         '.symbols')
示例#3
0
def test_write_lammps():
    st = crys.Structure(coords_frac=rand(20, 3),
                        cell=rand(3, 3),
                        symbols=['Al'] * 10 + ['N'] * 10)
    # align cell to lammps standard [[x,0,0],...]
    st.coords = None
    st.cell = None
    st.set_all()
    st_fn = common.pj(testdir, 'lmp.struct')
    io.write_lammps(st_fn, st)
    symbols = common.file_read(st_fn + '.symbols').split()
    assert st.symbols == symbols
    cmd = r"grep -A22 Atoms %s | grep '^[0-9]'" % st_fn
    arr = parse.arr2d_from_txt(common.backtick(cmd))
    assert arr.shape == (20, 5)
    assert np.allclose(st.coords, arr[:, 2:])
示例#4
0
def test_write_lammps():
    st = crys.Structure(coords_frac=rand(20,3),
                        cell=rand(3,3),
                        symbols=['Al']*10+['N']*10)
    # align cell to lammps standard [[x,0,0],...]
    st.coords = None  
    st.cell = None
    st.set_all()
    st_fn = common.pj(testdir, 'lmp.struct')
    io.write_lammps(st_fn, st)
    symbols = common.file_read(st_fn + '.symbols').split()
    assert st.symbols == symbols
    cmd = r"grep -A22 Atoms %s | grep '^[0-9]'" %st_fn
    arr = parse.arr2d_from_txt(common.backtick(cmd))
    assert arr.shape == (20,5)
    assert np.allclose(st.coords, arr[:,2:])
示例#5
0
文件: run.py 项目: elcorto/pwtools
run 1000
"""

assert len(sys.argv) == 2, "need one input arg: nvt or npt"
if sys.argv[1] == 'npt':
    ens_txt = npt_txt
elif sys.argv[1] == 'nvt':    
    ens_txt = nvt_txt
else:
    raise StandardError("only nvt / npt allowed")

# 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():
示例#6
0
run 1000
"""

assert len(sys.argv) == 2, "need one input arg: nvt or npt"
if sys.argv[1] == 'npt':
    ens_txt = npt_txt
elif sys.argv[1] == 'nvt':    
    ens_txt = nvt_txt
else:
    raise Exception("only nvt / npt allowed")

# 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():
示例#7
0
pair_coeff * * ../AlN.tersoff Al N

### IO
dump dump_txt all custom 1 lmp.out.dump id type xu yu zu fx fy fz &
    vx vy vz xsu ysu zsu 
dump_modify dump_txt sort id 
dump dump_dcd all dcd 1 lmp.out.dcd
dump_modify dump_dcd sort id unwrap yes
thermo_style custom step temp vol cella cellb cellc cellalpha cellbeta cellgamma &
                    ke pe etotal &
                    press pxx pyy pzz pxy pxz pyz cpu press
thermo_modify flush yes
thermo 1

fix 1 all box/relax tri 0.0
minimize 1e-8 1e-8 5000 10000 
"""

st = crys.Structure(coords_frac=np.array([[0.0]*3, [.5]*3]),
                    cryst_const=np.array([2.85]*3 + [60]*3),
                    symbols=['Al','N'])

for dr in ['md-nvt', 'md-npt', 'vc-relax']:
    common.system("rm -rfv {dr}; mkdir -v {dr}".format(dr=dr))
io.write_lammps('vc-relax/lmp.struct', st)
io.write_lammps('md-nvt/lmp.struct', crys.scell(st,(2,2,2)))
io.write_lammps('md-npt/lmp.struct', crys.scell(st,(2,2,2)))

for dr,txt in lmp_in.iteritems():
    common.file_write('%s/lmp.in' %dr, txt)