Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stress = vasp.get_stress(equi_outcar)
np.savetxt(os.path.join(task_path, 'equi.stress.out'), stress)
# gen strcture
ss = Structure.from_file(task_poscar)
# gen defomations
norm_strains=np.arange(strain_start,strain_end,strain_step)
print('gen with norm '+str(norm_strains))
deformations=[]
for ii in norm_strains:
strain = Strain.from_index_amount(strain_direct, ii)
deformations.append(strain.get_deformation_matrix())
deformed_structures = [defo.apply_to_structure(ss)
for defo in deformations]
n_dfm = len(deformed_structures)
# gen incar
fc = vasp.make_vasp_relax_incar(ecut, ediff, True, False, False, npar=npar, kpar=kpar, kspacing = None, kgamma = None)
with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
fp.write(fc)
# gen potcar
with open(task_poscar,'r') as fp :
lines = fp.read().split('\n')
ele_list = lines[5].split()
potcar_map = jdata['potcar_map']
potcar_list = []
for ii in ele_list :
assert(os.path.exists(potcar_map[ii]))
potcar_list.append(potcar_map[ii])
with open(os.path.join(task_path,'POTCAR'), 'w') as outfile:
for fname in potcar_list:
with open(fname) as infile:
outfile.write(infile.read())
# gen kpoints
if 'relax_incar' in jdata.keys():
relax_incar_path = jdata['relax_incar']
assert(os.path.exists(relax_incar_path))
relax_incar_path = os.path.abspath(relax_incar_path)
fc = open(relax_incar_path).read()
kspacing =float(re.findall((r"KSPACING(.+?)\n"),fc)[0].replace('=',''))
kgamma =('T' in re.findall((r"KGAMMA(.+?)\n"),fc)[0])
else :
fp_params = jdata['vasp_params']
ecut = fp_params['ecut']
ediff = fp_params['ediff']
npar = fp_params['npar']
kpar = fp_params['kpar']
kspacing = fp_params['kspacing']
kgamma = fp_params['kgamma']
fc = vasp.make_vasp_relax_incar(ecut, ediff, True, False, False, npar=npar,kpar=kpar, kspacing = kspacing, kgamma = kgamma)
with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
fp.write(fc)
# gen potcar
with open(task_poscar,'r') as fp :
lines = fp.read().split('\n')
ele_list = lines[5].split()
potcar_map = jdata['potcar_map']
potcar_list = []
for ii in ele_list :
assert os.path.exists(os.path.abspath(potcar_map[ii])),"No POTCAR in the potcar_map of %s"%(ii)
potcar_list.append(os.path.abspath(potcar_map[ii]))
with open(os.path.join(task_path,'POTCAR'), 'w') as outfile:
for fname in potcar_list:
with open(fname) as infile:
outfile.write(infile.read())
dss.append(jj.generate_defect_structure(supercell))
# gen incar
if 'relax_incar' in jdata.keys():
relax_incar_path = jdata['relax_incar']
assert(os.path.exists(relax_incar_path))
relax_incar_path = os.path.abspath(relax_incar_path)
fc = open(relax_incar_path).read()
else :
fp_params = jdata['vasp_params']
ecut = fp_params['ecut']
ediff = fp_params['ediff']
npar = fp_params['npar']
kpar = fp_params['kpar']
kspacing = fp_params['kspacing']
kgamma = fp_params['kgamma']
fc = vasp.make_vasp_relax_incar(ecut, ediff, True, True, True, npar=npar,kpar=kpar, kspacing = kspacing, kgamma = kgamma)
with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
fp.write(fc)
# gen potcar
with open(task_poscar,'r') as fp :
lines = fp.read().split('\n')
ele_list = lines[5].split()
potcar_map = jdata['potcar_map']
potcar_list = []
for ii in ele_list :
assert os.path.exists(os.path.abspath(potcar_map[ii])),"No POTCAR in the potcar_map of %s"%(ii)
potcar_list.append(os.path.abspath(potcar_map[ii]))
with open(os.path.join(task_path,'POTCAR'), 'w') as outfile:
for fname in potcar_list:
with open(fname) as infile:
outfile.write(infile.read())
# gen tasks
fc = vasp.make_vasp_static_incar(ecut, ediff, npar=npar,kpar=kpar, kspacing = kspacing, kgamma = kgamma)
else :
if 'relax_incar' in jdata.keys():
relax_incar_path = jdata['relax_incar']
assert(os.path.exists(relax_incar_path))
relax_incar_path = os.path.abspath(relax_incar_path)
fc = open(relax_incar_path).read()
else :
fp_params = jdata['vasp_params']
ecut = fp_params['ecut']
ediff = fp_params['ediff']
npar = fp_params['npar']
kpar = fp_params['kpar']
kspacing = fp_params['kspacing']
kgamma = fp_params['kgamma']
fc = vasp.make_vasp_relax_incar(ecut, ediff, True, relax_box, False, npar=npar,kpar=kpar, kspacing = kspacing, kgamma = kgamma)
with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
fp.write(fc)
# gen potcar
with open(task_poscar,'r') as fp :
lines = fp.read().split('\n')
ele_list = lines[5].split()
potcar_map = jdata['potcar_map']
potcar_list = []
for ii in ele_list :
assert os.path.exists(os.path.abspath(potcar_map[ii])),"No POTCAR in the potcar_map of %s"%(ii)
potcar_list.append(os.path.abspath(potcar_map[ii]))
with open(os.path.join(task_path,'POTCAR'), 'w') as outfile:
for fname in potcar_list:
with open(fname) as infile:
outfile.write(infile.read())
# gen tasks
# gen incar
if 'relax_incar' in jdata.keys():
relax_incar_path = jdata['relax_incar']
assert(os.path.exists(relax_incar_path))
relax_incar_path = os.path.abspath(relax_incar_path)
fc = open(relax_incar_path).read()
vasp_path = os.path.join(task_path, 'vasp-relax_incar' )
else :
fp_params = jdata['vasp_params']
ecut = fp_params['ecut']
ediff = fp_params['ediff']
npar = fp_params['npar']
kpar = fp_params['kpar']
kspacing = fp_params['kspacing']
kgamma = fp_params['kgamma']
fc = vasp.make_vasp_relax_incar(ecut, ediff, is_alloy, True, False, npar, kpar, kspacing, kgamma)
vasp_path = os.path.join(task_path, 'vasp-k%.2f' % kspacing)
os.makedirs(vasp_path, exist_ok = True)
os.chdir(vasp_path)
print(vasp_path)
with open('INCAR', 'w') as fp :
fp.write(fc)
# gen potcar
with open('POTCAR', 'w') as outfile:
for fname in potcar_list:
with open(fname) as infile:
outfile.write(infile.read())
# loop over volumes
for vol in np.arange(vol_start, vol_end, vol_step) :
vol_path = os.path.join(vasp_path, 'vol-%.2f' % vol)
dss.append(jj.generate_defect_structure(supercell))
# gen incar
if 'relax_incar' in jdata.keys():
relax_incar_path = jdata['relax_incar']
assert(os.path.exists(relax_incar_path))
relax_incar_path = os.path.abspath(relax_incar_path)
fc = open(relax_incar_path).read()
else :
fp_params = jdata['vasp_params']
ecut = fp_params['ecut']
ediff = fp_params['ediff']
npar = fp_params['npar']
kpar = fp_params['kpar']
kspacing = fp_params['kspacing']
kgamma = fp_params['kgamma']
fc = vasp.make_vasp_relax_incar(ecut, ediff, True, True, True, npar=npar,kpar=kpar, kspacing = kspacing, kgamma = kgamma)
with open(os.path.join(task_path, 'INCAR'), 'w') as fp :
fp.write(fc)
# gen tasks
copy_str = "%sx%sx%s" % (supercell[0], supercell[1], supercell[2])
cwd = os.getcwd()
for ii in range(len(dss)) :
struct_path = os.path.join(task_path, 'struct-%s-%s-%03d' % (insert_ele,copy_str,ii))
print('# generate %s' % (struct_path))
os.makedirs(struct_path, exist_ok=True)
os.chdir(struct_path)
for jj in ['POSCAR', 'POTCAR', 'INCAR'] :
if os.path.isfile(jj):
os.remove(jj)
# make conf
dss[ii].to('POSCAR', 'POSCAR')
# gen potcar
# gen incar
if 'relax_incar' in jdata.keys():
relax_incar_path = jdata['relax_incar']
assert(os.path.exists(relax_incar_path))
relax_incar_path = os.path.abspath(relax_incar_path)
fc = open(relax_incar_path).read()
vasp_path = os.path.join(equi_path, 'vasp-relax_incar' )
else :
fp_params = jdata['vasp_params']
ecut = fp_params['ecut']
ediff = fp_params['ediff']
npar = fp_params['npar']
kpar = fp_params['kpar']
kspacing = fp_params['kspacing']
kgamma = fp_params['kgamma']
fc = vasp.make_vasp_relax_incar(ecut, ediff, is_alloy, True, True, npar, kpar, kspacing, kgamma)
vasp_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing)
os.makedirs(vasp_path, exist_ok = True)
os.chdir(vasp_path)
print(vasp_path)
with open('INCAR', 'w') as fp :
fp.write(fc)
# gen poscar
if os.path.exists('POSCAR') :
os.remove('POSCAR')
os.symlink(os.path.relpath(to_poscar), 'POSCAR')
# gen potcar
with open('POTCAR', 'w') as outfile:
for fname in potcar_list:
with open(fname) as infile: