def make_lammps(jdata, conf_dir, task_type): fp_params = jdata['lammps_params'] model_dir = fp_params['model_dir'] type_map = fp_params['type_map'] model_dir = os.path.abspath(model_dir) model_name = fp_params['model_name'] deepmd_version = fp_params.get("deepmd_version", "0.12") if not model_name and task_type == 'deepmd': models = glob.glob(os.path.join(model_dir, '*pb')) model_name = [os.path.basename(ii) for ii in models] assert len(model_name) > 0, "No deepmd model in the model_dir" else: models = [os.path.join(model_dir, ii) for ii in model_name] model_param = { 'model_name': model_name, 'param_type': fp_params['model_param_type'], 'deepmd_version': deepmd_version } ntypes = len(type_map) conf_path = os.path.abspath(conf_dir) equi_path = re.sub('confs', global_task_name, conf_path) os.makedirs(equi_path, exist_ok=True) cwd = os.getcwd() from_poscar = os.path.join(conf_path, 'POSCAR') to_poscar = os.path.join(equi_path, 'POSCAR') if os.path.exists(to_poscar): assert (filecmp.cmp(from_poscar, to_poscar)) else: os.chdir(equi_path) os.symlink(os.path.relpath(from_poscar), 'POSCAR') os.chdir(cwd) # lmp path lmp_path = os.path.join(equi_path, task_type) os.makedirs(lmp_path, exist_ok=True) print(lmp_path) # lmp conf conf_file = os.path.join(lmp_path, 'conf.lmp') lammps.cvt_lammps_conf(to_poscar, os.path.relpath(conf_file)) ptypes = vasp.get_poscar_types(to_poscar) lammps.apply_type_map(conf_file, type_map, ptypes) # lmp input if task_type == 'deepmd': fc = lammps.make_lammps_equi(os.path.basename(conf_file), ntypes, lammps.inter_deepmd, model_param) elif task_type == 'meam': fc = lammps.make_lammps_equi(os.path.basename(conf_file), ntypes, lammps.inter_meam, model_param) with open(os.path.join(lmp_path, 'lammps.in'), 'w') as fp: fp.write(fc) # link models os.chdir(lmp_path) for ii in model_name: if os.path.exists(ii): os.remove(ii) for (ii, jj) in zip(models, model_name): os.symlink(os.path.relpath(ii), jj) os.chdir(cwd)
def make_meam_lammps(jdata, conf_dir): meam_potfile_dir = jdata['meam_potfile_dir'] meam_potfile_dir = os.path.abspath(meam_potfile_dir) meam_potfile = jdata['meam_potfile'] meam_potfile = [os.path.join(meam_potfile_dir, ii) for ii in meam_potfile] meam_potfile_name = jdata['meam_potfile'] type_map = jdata['meam_type_map'] ntypes = len(type_map) meam_param = { 'meam_potfile': jdata['meam_potfile'], 'meam_type': jdata['meam_param_type'] } conf_path = os.path.abspath(conf_dir) equi_path = re.sub('confs', global_task_name, conf_path) os.makedirs(equi_path, exist_ok=True) cwd = os.getcwd() from_poscar = os.path.join(conf_path, 'POSCAR') to_poscar = os.path.join(equi_path, 'POSCAR') if os.path.exists(to_poscar): assert (filecmp.cmp(from_poscar, to_poscar)) else: os.chdir(equi_path) os.symlink(os.path.relpath(from_poscar), 'POSCAR') os.chdir(cwd) # lmp path lmp_path = os.path.join(equi_path, 'meam') os.makedirs(lmp_path, exist_ok=True) print(lmp_path) # lmp conf conf_file = os.path.join(lmp_path, 'conf.lmp') lammps.cvt_lammps_conf(to_poscar, os.path.relpath(conf_file)) ptypes = vasp.get_poscar_types(to_poscar) lammps.apply_type_map(conf_file, type_map, ptypes) # lmp input fc = lammps.make_lammps_equi(os.path.basename(conf_file), ntypes, lammps.inter_meam, meam_param) with open(os.path.join(lmp_path, 'lammps.in'), 'w') as fp: fp.write(fc) # link models os.chdir(lmp_path) for ii in meam_potfile_name: if os.path.exists(ii): os.remove(ii) for (ii, jj) in zip(meam_potfile, meam_potfile_name): os.symlink(os.path.relpath(ii), jj) os.chdir(cwd)
def make_deepmd_lammps(jdata, conf_dir): 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')) deepmd_models_name = [os.path.basename(ii) for ii in deepmd_models] conf_path = os.path.abspath(conf_dir) equi_path = re.sub('confs', global_task_name, conf_path) os.makedirs(equi_path, exist_ok=True) cwd = os.getcwd() from_poscar = os.path.join(conf_path, 'POSCAR') to_poscar = os.path.join(equi_path, 'POSCAR') if os.path.exists(to_poscar): assert (filecmp.cmp(from_poscar, to_poscar)) else: os.chdir(equi_path) os.symlink(os.path.relpath(from_poscar), 'POSCAR') os.chdir(cwd) # lmp path lmp_path = os.path.join(equi_path, 'deepmd') os.makedirs(lmp_path, exist_ok=True) print(lmp_path) # lmp conf conf_file = os.path.join(lmp_path, 'conf.lmp') lammps.cvt_lammps_conf(to_poscar, os.path.relpath(conf_file)) ptypes = vasp.get_poscar_types(to_poscar) lammps.apply_type_map(conf_file, deepmd_type_map, ptypes) # lmp input fc = lammps.make_lammps_equi(os.path.basename(conf_file), ntypes, lammps.inter_deepmd, deepmd_models_name) with open(os.path.join(lmp_path, 'lammps.in'), 'w') as fp: fp.write(fc) # link models os.chdir(lmp_path) for ii in deepmd_models_name: if os.path.exists(ii): os.remove(ii) for (ii, jj) in zip(deepmd_models, deepmd_models_name): os.symlink(os.path.relpath(ii), jj) os.chdir(cwd)
def make_meam_lammps_fixv (jdata, conf_dir) : meam_potfile_dir = jdata['meam_potfile_dir'] meam_potfile_dir = os.path.abspath(meam_potfile_dir) meam_potfile = jdata['meam_potfile'] meam_potfile = [os.path.join(meam_potfile_dir,ii) for ii in meam_potfile] meam_potfile_name = jdata['meam_potfile'] type_map = jdata['meam_type_map'] ntypes = len(type_map) meam_param = {'meam_potfile' : jdata['meam_potfile'], 'meam_type': jdata['meam_param_type']} vol_start = jdata['vol_start'] vol_end = jdata['vol_end'] vol_step = jdata['vol_step'] # get equi props equi_path = re.sub('confs', global_equi_name, conf_dir) task_path = re.sub('confs', global_task_name, conf_dir) equi_path = os.path.join(equi_path, 'meam') task_path = os.path.join(task_path, 'meam') equi_path = os.path.abspath(equi_path) task_path = os.path.abspath(task_path) equi_log = os.path.join(equi_path, 'log.lammps') equi_dump = os.path.join(equi_path, 'dump.relax') os.makedirs(task_path, exist_ok = True) task_poscar = os.path.join(task_path, 'POSCAR') lammps.poscar_from_last_dump(equi_dump, task_poscar, type_map) cwd = os.getcwd() volume = vasp.poscar_vol(task_poscar) natoms = vasp.poscar_natoms(task_poscar) vpa = volume / natoms # structrure ss = Structure.from_file(task_poscar) # make lammps.in fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_meam, meam_param, change_box = False) f_lammps_in = os.path.join(task_path, 'lammps.in') with open(f_lammps_in, 'w') as fp : fp.write(fc) # make vols for vol in np.arange(vol_start, vol_end, vol_step) : vol_path = os.path.join(task_path, 'vol-%.2f' % vol) print('# generate %s' % (vol_path)) os.makedirs(vol_path, exist_ok = True) os.chdir(vol_path) for ii in ['conf.lmp', 'conf.lmp', 'lammps.in'] + meam_potfile_name : if os.path.exists(ii) : os.remove(ii) # make conf scale_ss = ss.copy() scale_ss.scale_lattice(vol * natoms) scale_ss.to('POSCAR', 'POSCAR') lammps.cvt_lammps_conf('POSCAR', 'conf.lmp') ptypes = vasp.get_poscar_types('POSCAR') lammps.apply_type_map('conf.lmp', type_map, ptypes) # link lammps.in os.symlink(os.path.relpath(f_lammps_in), 'lammps.in') # link models for (ii,jj) in zip(meam_potfile, meam_potfile_name) : os.symlink(os.path.relpath(ii), jj) # make lammps input os.chdir(cwd)
def make_lammps(jdata, conf_dir, max_miller=2, static=False, relax_box=False, task_type='wrong-task'): kspacing = jdata['vasp_params']['kspacing'] fp_params = jdata['lammps_params'] model_dir = fp_params['model_dir'] type_map = fp_params['type_map'] model_dir = os.path.abspath(model_dir) model_name = fp_params['model_name'] if not model_name and task_type == 'deepmd': models = glob.glob(os.path.join(model_dir, '*pb')) model_name = [os.path.basename(ii) for ii in models] assert len(model_name) > 0, "No deepmd model in the model_dir" else: models = [os.path.join(model_dir, ii) for ii in model_name] model_param = { 'model_name': fp_params['model_name'], 'param_type': fp_params['model_param_type'] } ntypes = len(type_map) min_slab_size = jdata['min_slab_size'] min_vacuum_size = jdata['min_vacuum_size'] # get equi poscar # conf_path = os.path.abspath(conf_dir) # conf_poscar = os.path.join(conf_path, 'POSCAR') equi_path = re.sub('confs', global_equi_name, conf_dir) equi_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing) equi_path = os.path.abspath(equi_path) equi_contcar = os.path.join(equi_path, 'CONTCAR') assert os.path.exists( equi_contcar), "Please compute the equilibrium state using vasp first" task_path = re.sub('confs', global_task_name, conf_dir) task_path = os.path.abspath(task_path) if static: task_path = os.path.join(task_path, task_type + '-static') else: task_path = os.path.join(task_path, task_type) 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: 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() if task_type == 'deepmd': os.chdir(task_path) for ii in model_name: if os.path.exists(ii): os.remove(ii) for (ii, jj) in zip(models, model_name): os.symlink(os.path.relpath(ii), jj) share_models = glob.glob(os.path.join(task_path, '*pb')) else: share_models = models for ii in range(len(all_slabs)): slab = all_slabs[ii] miller_str = "m%d.%d.%dm" % ( slab.miller_index[0], slab.miller_index[1], slab.miller_index[2]) # make dir struct_path = os.path.join(task_path, 'struct-%03d-%s' % (ii, miller_str)) os.makedirs(struct_path, exist_ok=True) os.chdir(struct_path) for jj in ['conf.lmp', 'lammps.in'] + model_name: if os.path.isfile(jj): os.remove(jj) print("# %03d generate " % ii, struct_path, " \t %d atoms" % len(slab.sites)) # make conf slab.to('POSCAR', 'POSCAR') vasp.regulate_poscar('POSCAR', 'POSCAR') lammps.cvt_lammps_conf('POSCAR', 'conf.lmp') ptypes = vasp.get_poscar_types('POSCAR') lammps.apply_type_map('conf.lmp', type_map, ptypes) # record miller np.savetxt('miller.out', slab.miller_index, fmt='%d') # link lammps.in os.symlink(os.path.relpath(f_lammps_in), 'lammps.in') # link models for (ii, jj) in zip(share_models, model_name): os.symlink(os.path.relpath(ii), jj) cwd = os.getcwd()
def make_input_file(self, output_dir, task_type, task_param): lammps.cvt_lammps_conf(os.path.join(output_dir, 'POSCAR'), 'conf.lmp') with open(os.path.join(output_dir, 'task.json'), 'w') as fp: json.dump(task_param, fp, indent=4) # lines in lammps.in related to model # line_model = "pair_style meam \n" # line_model += "pair_coeff * * %s " % (os.path.basename(self.model[0])) # for ii in self.type_map: # line_model += ii + ' ' # line_model += "%s " % (os.path.basename(self.model[1])) # for ii in self.type_map: # line_model += ii + ' ' # line_model += '\n' etol = 1e-12 ftol = 1e-6 maxiter = 5000 maxeval = 500000 change_box = True B0 = 70 bp = 0 scale2equi = 1 ntypes = len(self.type_map) reprod_opt = False static = False if 'etol' in task_param: etol = task_param['etol'] if 'ftol' in task_param: ftol = task_param['ftol'] if 'maxiter' in task_param: maxiter = task_param['maxiter'] if 'maxeval' in task_param: maxeval = task_param['maxeval'] if 'change_box' in task_param: change_box = task_param['change_box'] if 'scale2equi' in task_param: scale2equi = task_param['scale2equi'] if 'reprod_opt' in task_param: reprod_opt = task_param['reprod_opt'] if 'static-opt' in task_param: static = task_param['static-opt'] 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)
def make_lammps_fixv (jdata, conf_dir,task_type) : fp_params = jdata['lammps_params'] model_dir = fp_params['model_dir'] type_map = fp_params['type_map'] model_dir = os.path.abspath(model_dir) model_name =fp_params['model_name'] deepmd_version = fp_params.get("deepmd_version", "0.12") if not model_name and task_type =='deepmd': models = glob.glob(os.path.join(model_dir, '*pb')) model_name = [os.path.basename(ii) for ii in models] else: models = [os.path.join(model_dir,ii) for ii in model_name] model_param = {'model_name' : model_name, 'param_type': fp_params['model_param_type'], 'deepmd_version' : deepmd_version} ntypes = len(type_map) vol_start = jdata['vol_start'] vol_end = jdata['vol_end'] vol_step = jdata['vol_step'] # get equi props equi_path = re.sub('confs', global_equi_name, conf_dir) task_path = re.sub('confs', global_task_name, conf_dir) equi_path = os.path.join(equi_path, task_type) task_path = os.path.join(task_path, task_type) equi_path = os.path.abspath(equi_path) task_path = os.path.abspath(task_path) equi_dump = os.path.join(equi_path, 'dump.relax') os.makedirs(task_path, exist_ok = True) task_poscar = os.path.join(task_path, 'POSCAR') lammps.poscar_from_last_dump(equi_dump, task_poscar, type_map) cwd = os.getcwd() volume = vasp.poscar_vol(task_poscar) natoms = vasp.poscar_natoms(task_poscar) vpa = volume / natoms # structrure ss = Structure.from_file(task_poscar) # make lammps.in if task_type=='deepmd': fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_deepmd, model_param, change_box = False) elif task_type=='meam': fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_meam, model_param, change_box = False) f_lammps_in = os.path.join(task_path, 'lammps.in') with open(f_lammps_in, 'w') as fp : fp.write(fc) os.chdir(task_path) for ii in model_name : if os.path.exists(ii) : os.remove(ii) for (ii,jj) in zip(models, model_name) : os.symlink(os.path.relpath(ii), jj) share_models = [os.path.join(task_path,ii) for ii in model_name] # make vols for vol in np.arange(vol_start, vol_end, vol_step) : vol_path = os.path.join(task_path, 'vol-%.2f' % vol) print('# generate %s' % (vol_path)) os.makedirs(vol_path, exist_ok = True) os.chdir(vol_path) for ii in ['conf.lmp', 'conf.lmp', 'lammps.in'] + model_name : if os.path.exists(ii) : os.remove(ii) # make conf scale_ss = ss.copy() scale_ss.scale_lattice(vol * natoms) scale_ss.to('POSCAR', 'POSCAR') lammps.cvt_lammps_conf('POSCAR', 'conf.lmp') ptypes = vasp.get_poscar_types('POSCAR') lammps.apply_type_map('conf.lmp', type_map, ptypes) # link lammps.in os.symlink(os.path.relpath(f_lammps_in), 'lammps.in') # link models for (ii,jj) in zip(share_models,model_name) : os.symlink(os.path.relpath(ii), jj) # make lammps input os.chdir(cwd)
def make_meam_lammps(jdata, conf_dir, max_miller=2, static=False, relax_box=False, task_name='wrong-task'): fp_params = jdata['vasp_params'] kspacing = fp_params['kspacing'] meam_potfile_dir = jdata['meam_potfile_dir'] meam_potfile_dir = os.path.abspath(meam_potfile_dir) meam_potfile = jdata['meam_potfile'] meam_potfile = [os.path.join(meam_potfile_dir, ii) for ii in meam_potfile] meam_potfile_name = jdata['meam_potfile'] type_map = jdata['meam_type_map'] ntypes = len(type_map) meam_param = { 'meam_potfile': jdata['meam_potfile'], 'meam_type': jdata['meam_param_type'] } min_slab_size = jdata['min_slab_size'] min_vacuum_size = jdata['min_vacuum_size'] # get equi poscar # conf_path = os.path.abspath(conf_dir) # conf_poscar = os.path.join(conf_path, 'POSCAR') equi_path = re.sub('confs', global_equi_name, conf_dir) equi_path = os.path.join(equi_path, 'vasp-k%.2f' % kspacing) equi_path = os.path.abspath(equi_path) equi_contcar = os.path.join(equi_path, 'CONTCAR') task_path = re.sub('confs', global_task_name, conf_dir) task_path = os.path.abspath(task_path) task_path = os.path.join(task_path, task_name) 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 static: fc = lammps.make_lammps_eval('conf.lmp', ntypes, lammps.inter_meam, meam_param) else: fc = lammps.make_lammps_equi('conf.lmp', ntypes, lammps.inter_meam, meam_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() for ii in range(len(all_slabs)): slab = all_slabs[ii] miller_str = "m%d.%d.%dm" % ( slab.miller_index[0], slab.miller_index[1], slab.miller_index[2]) # make dir struct_path = os.path.join(task_path, 'struct-%03d-%s' % (ii, miller_str)) os.makedirs(struct_path, exist_ok=True) os.chdir(struct_path) for jj in ['conf.lmp', 'lammps.in'] + meam_potfile_name: if os.path.isfile(jj): os.remove(jj) print("# %03d generate " % ii, struct_path, " \t %d atoms" % len(slab.sites)) # make conf slab.to('POSCAR', 'POSCAR') vasp.regulate_poscar('POSCAR', 'POSCAR') lammps.cvt_lammps_conf('POSCAR', 'conf.lmp') ptypes = vasp.get_poscar_types('POSCAR') lammps.apply_type_map('conf.lmp', type_map, ptypes) # record miller np.savetxt('miller.out', slab.miller_index, fmt='%d') # link lammps.in os.symlink(os.path.relpath(f_lammps_in), 'lammps.in') # link models for (ii, jj) in zip(meam_potfile, meam_potfile_name): os.symlink(os.path.relpath(ii), jj) cwd = os.getcwd()
def make_input_file(self, output_dir, task_type, task_param): lammps.cvt_lammps_conf(os.path.join(output_dir, 'POSCAR'), os.path.join(output_dir, 'conf.lmp'), lammps.element_list(self.type_map)) # dumpfn(task_param, os.path.join(output_dir, 'task.json'), indent=4) etol = 1e-12 ftol = 1e-6 maxiter = 5000 maxeval = 500000 B0 = 70 bp = 0 ntypes = len(self.type_map) cal_type = task_param['cal_type'] cal_setting = task_param['cal_setting'] self.set_model_param() # deal with user input in.lammps for relaxation if os.path.isfile(self.in_lammps) and task_type == 'relaxation': with open(self.in_lammps, 'r') as fin: fc = fin.read() # user input in.lammps for property calculation if 'input_prop' in cal_setting and os.path.isfile(cal_setting['input_prop']): with open(os.path.abspath(cal_setting['input_prop']), 'r') as fin: fc = fin.read() else: if 'etol' in cal_setting: dlog.info("%s setting etol to %s" % (self.make_input_file.__name__, cal_setting['etol'])) etol = cal_setting['etol'] if 'ftol' in cal_setting: dlog.info("%s setting ftol to %s" % (self.make_input_file.__name__, cal_setting['ftol'])) ftol = cal_setting['ftol'] if 'maxiter' in cal_setting: dlog.info("%s setting maxiter to %s" % (self.make_input_file.__name__, cal_setting['maxiter'])) maxiter = cal_setting['maxiter'] if 'maxeval' in cal_setting: dlog.info("%s setting maxeval to %s" % (self.make_input_file.__name__, cal_setting['maxeval'])) maxeval = cal_setting['maxeval'] if cal_type == 'relaxation': relax_pos = cal_setting['relax_pos'] relax_shape = cal_setting['relax_shape'] relax_vol = cal_setting['relax_vol'] if [relax_pos, relax_shape, relax_vol] == [True, False, False]: fc = lammps.make_lammps_equi('conf.lmp', self.type_map, self.inter_func, self.model_param, etol, ftol, maxiter, maxeval, False) elif [relax_pos, relax_shape, relax_vol] == [True, True, True]: fc = lammps.make_lammps_equi('conf.lmp', self.type_map, self.inter_func, self.model_param, etol, ftol, maxiter, maxeval, True) elif [relax_pos, relax_shape, relax_vol] == [True, True, False] and not task_type == 'eos': if 'scale2equi' in task_param: scale2equi = task_param['scale2equi'] fc = lammps.make_lammps_press_relax('conf.lmp', self.type_map, scale2equi[int(output_dir[-6:])], self.inter_func, self.model_param, B0, bp, etol, ftol, maxiter, maxeval) else: fc = lammps.make_lammps_equi('conf.lmp', self.type_map, self.inter_func, self.model_param, etol, ftol, maxiter, maxeval, True) elif [relax_pos, relax_shape, relax_vol] == [True, True, False] and task_type == 'eos': task_param['cal_setting']['relax_shape'] = False fc = lammps.make_lammps_equi('conf.lmp', self.type_map, self.inter_func, self.model_param, etol, ftol, maxiter, maxeval, False) elif [relax_pos, relax_shape, relax_vol] == [False, False, False]: fc = lammps.make_lammps_eval('conf.lmp', self.type_map, self.inter_func, self.model_param) else: raise RuntimeError("not supported calculation setting for LAMMPS") elif cal_type == 'static': fc = lammps.make_lammps_eval('conf.lmp', self.type_map, self.inter_func, self.model_param) else: raise RuntimeError("not supported calculation type for LAMMPS") dumpfn(task_param, os.path.join(output_dir, 'task.json'), indent=4) in_lammps_not_link_list = ['eos'] if task_type not in in_lammps_not_link_list: with open(os.path.join(output_dir, '../in.lammps'), 'w') as fp: fp.write(fc) cwd = os.getcwd() os.chdir(output_dir) if not (os.path.islink('in.lammps') or os.path.isfile('in.lammps')): os.symlink('../in.lammps', 'in.lammps') else: os.remove('in.lammps') os.symlink('../in.lammps', 'in.lammps') os.chdir(cwd) else: with open(os.path.join(output_dir, 'in.lammps'), 'w') as fp: fp.write(fc)