Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lmps_str = task_type + '-reprod-k%.2f' % (kspacing)
vasp_path = os.path.join(task_path, vasp_str)
lmps_path = os.path.join(task_path, lmps_str)
os.makedirs(lmps_path, exist_ok = True)
copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
struct_widecard = os.path.join(vasp_path, 'struct-%s-%s-*' % (insert_ele,copy_str))
vasp_struct = glob.glob(struct_widecard)
assert len(vasp_struct)>0 ,"Please compute the interstitial defect using vasp first"
vasp_struct.sort()
cwd=os.getcwd()
# make lammps.in
if task_type =='deepmd':
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_deepmd,
model_name)
elif task_type =='meam':
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_meam,
model_param)
f_lammps_in = os.path.join(lmps_path, 'lammps.in')
with open(f_lammps_in, 'w') as fp :
fp.write(fc)
for vs in vasp_struct :
# get vasp energy
outcar = os.path.join(vs, 'OUTCAR')
energies = vasp.get_energies(outcar)
if task_type == 'static' \
or (task_type == 'surface' and static):
fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_eam_alloy, model_param)
if task_type == 'elastic':
fc = lammps.make_lammps_elastic('conf.lmp', ntypes, lammps.inter_eam_alloy, model_param,
etol, ftol, maxiter, maxeval)
if task_type == 'vacancy' \
or (task_type == 'eos' and change_box) \
or (task_type == 'interstitial' and not reprod_opt):
fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale2equi, lammps.inter_eam_alloy,
model_param, B0, bp, etol, ftol, maxiter, maxeval)
if reprod_opt:
fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_eam_alloy, model_param)
with open(os.path.join(output_dir, 'in.lammps'), 'w') as fp:
fp.write(fc)
model_name = list(map(os.path.basename,self.model))
model_param = {'model_name': model_name,
'param_type': self.type_map}
fc = ''
if task_type == 'relaxation' \
or (task_type == 'eos' and not change_box) \
or (task_type == 'surface' and not static):
fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_meam, model_param,
etol, ftol, maxiter, maxeval, change_box)
if task_type == 'static' \
or (task_type == 'surface' and static):
fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_meam, model_param)
if task_type == 'elastic':
fc = lammps.make_lammps_elastic('conf.lmp', ntypes, lammps.inter_meam, model_param,
etol, ftol, maxiter, maxeval)
if task_type == 'vacancy' \
or (task_type == 'eos' and change_box) \
or (task_type == 'interstitial'):
fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale2equi, lammps.inter_meam,
model_param, B0, bp, etol, ftol, maxiter, maxeval)
if reprod_opt:
fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_meam, model_param)
with open(os.path.join(output_dir, 'in.lammps'), 'w') as fp:
fp.write(fc)
deepmd_version = self.inter.get("deepmd_version", "0.12")
model_param = {'model_name': [model_name],
'param_type': self.type_map,
'deepmd_version': deepmd_version}
fc = ''
if task_type == 'relaxation' \
or (task_type == 'eos' and not change_box) \
or (task_type == 'surface' and not static):
fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_deepmd, model_param,
etol, ftol, maxiter, maxeval, change_box)
if task_type == 'static' \
or (task_type == 'surface' and static):
fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_deepmd, model_param)
if task_type == 'elastic':
fc = lammps.make_lammps_elastic('conf.lmp', ntypes, lammps.inter_deepmd, model_param,
etol, ftol, maxiter, maxeval)
if task_type == 'vacancy' \
or (task_type == 'eos' and change_box) \
or (task_type == 'interstitial'):
fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale2equi, lammps.inter_deepmd,
model_param, B0, bp, etol, ftol, maxiter, maxeval)
if reprod_opt:
fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_deepmd, model_param)
with open(os.path.join(output_dir, 'in.lammps'), 'w') as fp:
fp.write(fc)
os.makedirs(lmps_path, exist_ok = True)
copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
struct_widecard = os.path.join(vasp_path, 'struct-%s-%s-*' % (insert_ele,copy_str))
vasp_struct = glob.glob(struct_widecard)
assert len(vasp_struct)>0 ,"Please compute the interstitial defect using vasp first"
vasp_struct.sort()
cwd=os.getcwd()
# make lammps.in
if task_type =='deepmd':
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_deepmd,
model_name)
elif task_type =='meam':
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_meam,
model_param)
f_lammps_in = os.path.join(lmps_path, 'lammps.in')
with open(f_lammps_in, 'w') as fp :
fp.write(fc)
for vs in vasp_struct :
# get vasp energy
outcar = os.path.join(vs, 'OUTCAR')
energies = vasp.get_energies(outcar)
# get xdat
xdatcar = os.path.join(vs, 'XDATCAR')
struct_basename = os.path.basename(vs)
ls = os.path.join(lmps_path, struct_basename)
print(ls)
os.makedirs(task_path, exist_ok=True)
cwd = os.getcwd()
os.chdir(task_path)
if os.path.isfile('POSCAR') :
os.remove('POSCAR')
os.symlink(os.path.relpath(equi_contcar), 'POSCAR')
os.chdir(cwd)
task_poscar = os.path.join(task_path, 'POSCAR')
# gen strcture
ss = Structure.from_file(task_poscar)
# gen slabs
all_slabs = generate_all_slabs(ss, max_miller, min_slab_size, min_vacuum_size)
# make lammps.in
if task_type =='deepmd':
if static :
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_deepmd,
model_name)
else :
fc = lammps.make_lammps_equi('conf.lmp',
ntypes,
lammps.inter_deepmd,
model_name,
change_box = relax_box)
elif task_type =='meam':
if static :
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_meam,
model_param)
else :
# make lammps.in
if task_type =='deepmd':
if static :
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_deepmd,
model_name)
else :
fc = lammps.make_lammps_equi('conf.lmp',
ntypes,
lammps.inter_deepmd,
model_name,
change_box = relax_box)
elif task_type =='meam':
if static :
fc = lammps.make_lammps_eval('conf.lmp',
ntypes,
lammps.inter_meam,
model_param)
else :
fc = lammps.make_lammps_equi('conf.lmp',
ntypes,
lammps.inter_meam,
model_param,
change_box = relax_box)
f_lammps_in = os.path.join(task_path, 'lammps.in')
with open(f_lammps_in, 'w') as fp :
fp.write(fc)
cwd = os.getcwd()
os.chdir(task_path)
for ii in model_name :