Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions auto_test/cmpt_02_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def cmpt_deepmd_lammps(jdata, conf_dir, task_name) :
lst_strain = []
lst_stress = []
for ii in lst_dfm_path :
# print(ii)
strain = np.loadtxt(os.path.join(ii, 'strain.out'))
stress = lammps.get_stress(os.path.join(ii, 'log.lammps'))
# convert from pressure to stress
Expand All @@ -83,7 +82,7 @@ def cmpt_deepmd_lammps(jdata, conf_dir, task_name) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="cmpt 02.elastic")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
2 changes: 1 addition & 1 deletion auto_test/cmpt_03_vacancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def cmpt_deepmd_lammps(jdata, conf_dir, supercell, task_name) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="cmpt 03.vacancy")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
2 changes: 1 addition & 1 deletion auto_test/cmpt_04_interstitial.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _cmpt_deepmd_lammps(jdata, conf_dir, supercell, insert_ele, task_name) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="cmpt 04.interstitial")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
2 changes: 1 addition & 1 deletion auto_test/cmpt_05_surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def cmpt_deepmd_lammps(jdata, conf_dir, task_name, static = False) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="cmpt 05.surf")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
99 changes: 99 additions & 0 deletions auto_test/cmpt_06_phonon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python3

import os, re, argparse, filecmp, json, glob
import subprocess as sp
import numpy as np
import lib.vasp as vasp
import lib.lammps as lammps
from phonopy import Phonopy
from phonopy.structure.atoms import PhonopyAtoms
import yaml
import phonopy
#from phonolammps import Phonolammps



global_equi_name = '00.equi'
global_task_name = '06.phonon'

'''
link poscar
link potcar
make incar
'''
def cmpt_vasp(jdata, conf_dir,opt) :
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']
supercell_matrix=jdata['supercell_matrix']

conf_path = os.path.abspath(conf_dir)
task_path = re.sub('confs', global_task_name, conf_path)
task_path = os.path.join(task_path, 'vasp-k%.2f' % kspacing)
cwd = os.getcwd()
os.chdir(task_path)
if os.path.isfile('vasprun.xml'):
os.system('phonopy --fc vasprun.xml')
os.system('phonopy --dim="%d %d %d" -c POSCAR-unitcell band.conf'%(supercell_matrix[0],supercell_matrix[1],supercell_matrix[2]))
else:
print('vasprun.xml No such file')
if opt=='Y':
ph = phonopy.load(supercell_matrix=supercell_matrix,primitive_matrix='auto',unitcell_filename="POSCAR-unitcell",force_constants_filename='FORCE_CONSTANTS')
ph.auto_band_structure(plot=True).show()


def cmpt_deepmd_lammps(jdata, conf_dir,opt) :
deepmd_model_dir = jdata['deepmd_model_dir']
deepmd_type_map = jdata['deepmd_type_map']
ntypes = len(deepmd_type_map)
deepmd_model_dir = os.path.abspath(deepmd_model_dir)
deepmd_models = glob.glob(os.path.join(deepmd_model_dir, '*pb'))
supercell_matrix=jdata['supercell_matrix']

conf_path = os.path.abspath(conf_dir)
task_path = re.sub('confs', global_task_name, conf_path)
task_path = os.path.join(task_path, 'deepmd')

os.chdir(task_path)
if os.path.isfile('FORCE_CONSTANTS'):
os.system('phonopy --dim="%d %d %d" -c POSCAR-unitcell band.conf'%(supercell_matrix[0],supercell_matrix[1],supercell_matrix[2]))
else:
print('FORCE_CONSTANTS No such file')
if opt=='Y':
ph = phonopy.load(supercell_matrix=supercell_matrix,primitive_matrix='auto',unitcell_filename="POSCAR-unitcell",force_constants_filename='FORCE_CONSTANTS')
ph.auto_band_structure(plot=True).show()


def _main() :
parser = argparse.ArgumentParser(
description="cmpt 06.phonon")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
help='json parameter file')
parser.add_argument('CONF', type=str,
help='the path to conf')
parser.add_argument('OPT', type=str,
help='show the band structue or not [Y/N]')
args = parser.parse_args()

with open (args.PARAM, 'r') as fp :
jdata = json.load (fp)

# print('generate %s task with conf %s' % (args.TASK, args.CONF))
if args.TASK == 'vasp':
cmpt_vasp(jdata, args.CONF,args.OPT)
elif args.TASK == 'deepmd' :
cmpt_deepmd_lammps(jdata, args.CONF,args.OPT)
elif args.TASK == 'meam' :
cmpt_meam_lammps(jdata, args.CONF)
else :
raise RuntimeError("unknow task ", args.TASK)

if __name__ == '__main__' :
_main()

8 changes: 4 additions & 4 deletions auto_test/gen_01_eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def make_deepmd_lammps (jdata, conf_dir) :
print('# generate %s' % (vol_path))
os.makedirs(vol_path, exist_ok = True)
os.chdir(vol_path)
print(vol_path)
#print(vol_path)
for ii in ['conf.lmp', 'conf.lmp'] + deepmd_models_name :
if os.path.exists(ii) :
os.remove(ii)
Expand All @@ -159,7 +159,7 @@ def make_deepmd_lammps (jdata, conf_dir) :
os.symlink(os.path.relpath(ii), jj)
# make lammps input
scale = (vol / vpa) ** (1./3.)
fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale, deepmd_models_name)
fc = lammps.make_lammps_press_relax('conf.lmp', ntypes, scale,lammps.inter_deepmd, deepmd_models_name)
with open(os.path.join(vol_path, 'lammps.in'), 'w') as fp :
fp.write(fc)
os.chdir(cwd)
Expand Down Expand Up @@ -314,12 +314,12 @@ def _main() :
if args.TASK == 'vasp':
make_vasp(jdata, args.CONF)
elif args.TASK == 'deepmd' :
if args.fix_shape is not None :
if args.fix_shape :
make_deepmd_lammps_fixv(jdata, args.CONF)
else :
make_deepmd_lammps(jdata, args.CONF)
elif args.TASK == 'meam' :
if args.fix_shape is not None :
if args.fix_shape:
make_meam_lammps_fixv(jdata, args.CONF)
else :
raise RuntimeError("not implemented ", args.TASK)
Expand Down
2 changes: 1 addition & 1 deletion auto_test/gen_02_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def make_meam_lammps(jdata, conf_dir) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="gen 02.elastic")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
2 changes: 1 addition & 1 deletion auto_test/gen_03_vacancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def make_meam_lammps(jdata, conf_dir, supercell) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="gen 03.vacancy")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
2 changes: 1 addition & 1 deletion auto_test/gen_04_interstitial.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def _make_meam_lammps(jdata, conf_dir, supercell, insert_ele, task_name) :

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="gen 04.interstitial")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
2 changes: 1 addition & 1 deletion auto_test/gen_05_surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def make_meam_lammps(jdata, conf_dir, max_miller = 2, static = False, relax_box

def _main() :
parser = argparse.ArgumentParser(
description="gen 01.eos")
description="gen 05.surf")
parser.add_argument('TASK', type=str,
help='the task of generation, vasp or lammps')
parser.add_argument('PARAM', type=str,
Expand Down
Loading