def getvasprun(self, files): m = self.m maindir = pwd() if m.engine == "vasp": calculator = self.getVaspRun_vasp elif m.engine == "lammps": calculator = self.getVaspRun_lammps self.jm = jobManager() for file in files: print(file) dir = "dirs/dir_" + file mkdir(dir) mv(file, dir + '/POSCAR') cd(dir) calculator() cd(maindir) self.jm.run() if m.th: mkdir(m.pbsname) self.thcode(files, m.pbsname) cp("dirs", m.pbsname) passthru("tar zcf %s.tar.gz %s" % (m.pbsname, m.pbsname)) print('start check') self.jm.check() if m.engine == "lammps1": from multiprocessing.dummy import Pool pool = Pool() pool.map_async(lammpsvasprun, files) pool.close() pool.join()
def creatmini(self): print('creatmini') tl.mkdir('minimize') tl.cd('minimize') minimize_input(self.m) tl.write(time.strftime('%Y-%m-%d %H:%M:%S'), 'done') tl.cd('..')
def generate(self): m = self.m coordination = self.phontsAtoms() content0 = "species %d\n" % (len(m.elements)) + m.phontsmasses + """ D3_cutoff %f kpoints %s 1 delta 0.005 numerical_2der T numerical_3der T iter_steps 3 pdos 0. 70. 200 10. temp 60. 400. 10 AbInitio T F FP_interface LAMMPS #phonons_only T Lattice 1.0 %s end """ % (m.shengcut, m.toString(m.kpoints), coordination) tl.write(content0, 'phonons_input.dat') tl.passthru(config.phonts) # generate many displacement files tl.mkdir('lammps') tl.cd('lammps') content = "units %s\n" % m.units content += """atom_style charge dimension 3 boundary p p p read_data GENERIC %s %s neighbor 1.1 bin neigh_modify every 1 delay 1 check yes dump 1 all custom 1 *.dump id fx fy fz dump_modify 1 format "%%d %%30.20f %%30.20f %%30.20f" dump_modify 1 sort id run 0 """ % (m.masses, m.potential) tl.shell_exec("mv ../*.str .") strs = tl.shell_exec("ls *.str").split("\n") for str in strs: dir = str.replace("str", "dir") tl.mkdir(dir) tl.write(content.replace("GENERIC", str), dir + "/in") tl.mv(str, "%s/%s" % (dir, str)) tl.cd(dir) tl.passthru(config.lammps + " <in >out.dat") tl.cd('..') dirs = tl.shell_exec("ls |grep dir").split("\n") for dir in dirs: print(dir) tl.cp(dir + "/0.dump", "../" + dir.replace("dir", "out")) tl.cp("1.0000.dir/out.dat", "../1.0000.out") tl.cd('..') content0 = content0.replace('AbInitio T F', 'AbInitio F T') tl.write(content0, 'phonons_input.dat') tl.passthru(config.phonts)
def lifenmaq(self, filename="qpoints/qpoints.yaml", k=[0, 0, 0], correlation_supercell=[10, 10, 1], test=False): self.test = test self.pfactor = self.getpfactor(correlation_supercell) pya = phononyaml(filename) self.pya = pya self.testk = k if not tl.exists('NMA'): tl.mkdir('NMA') self.specialk(pya, map(float, k))
def getV(self): if not exists('groupv'): mkdir('groupv') cd('groupv') cp('../FORCE_CONSTANTS', '.') cp('../POSCAR', '.') cp('../disp.yaml', '.') self.generate_vconf() passthru(config.phonopy + "--tolerance=1e-4 v.conf") self.drawV() cd('..')
def ineq(m): now = tl.pwd() species = m.species if not (species in ["CN-small"]): return 0.0 tl.cd('minimize') tl.mkdir('nonequ') tl.cd('nonequ') ie = inequality() nonequ5 = ie.run() tl.cd(now) return nonequ5
def runSPOSCAR(self): m = self.m maindir = pwd() file = "SPOSCAR" dir = "dir_" + file mkdir(dir) cp(file, dir + '/POSCAR') cd(dir) if m.engine == "vasp": self.getVaspRun_vasp() if m.engine == "lammps": self.getVaspRun_lammps() cd(maindir)
def creatmini(self, m): print('creatmini') m.home = pwd() assert m.home != '' mkdir('minimize') cd('minimize') minimize_input(m) write(time.strftime('%Y-%m-%d %H:%M:%S'), 'done') cd('..') if m.engine == "lammps": return m.dump2POSCAR(m.home + '/minimize/range') else: return io.read(m.home + '/minimize/CONTCAR')
def collect(self): tl.mkdir('save') nqpt = len(tl.ls("diam.dyn*")) - 1 for iqpt in np.arange(1, nqpt + 1): label = str(iqpt) tl.shell_exec('cp diam.dyn' + str(iqpt) + ' save/diam.dyn_q' + label) if (iqpt == 1): tl.shell_exec('cp _ph0/diam.dvscf1 save/diam.dvscf_q' + label) tl.shell_exec('cp -r _ph0/diam.phsave save/') else: tl.shell_exec('cp _ph0/diam.q_' + str(iqpt) + '/diam.dvscf1 save/diam.dvscf_q' + label) tl.shell_exec('rm _ph0/diam.q_' + str(iqpt) + '/*wfc*')
def generate(self): # m = self.m self.minimizePOSCAR() # cp('minimize/POSCAR','.') mkdir('secondorder') cd('secondorder') self.pSecond() self.fc2() cd('..') self.third() self.vasprun3() self.force_constant3() cd('..') self.pSheng() self.runsheng()
def sed_band(self, correlation_supercell=[10, 10, 1]): self.pfactor = self.getpfactor(correlation_supercell) data = tl.parseyaml('band.yaml') natom_unitcell = int(data['natom']) if not tl.exists('SEDBAND'): tl.mkdir('SEDBAND') sed = [] db = h5py.File('sed.h5') def u(phonon): qp = phonon['q-position'] qps = str(qp) print(qps) if qps not in db: db[qps] = self.calculateSED(map(float, qp), natom_unitcell) s = db[qps][:] sed.append(s) map(u, data['phonon']) totalStep = self.totalStep x = np.linspace(0, 1, totalStep / 2 + 1) * 1 / 2.0 / self.timestep np.save('wtick.npy', x) np.save('sed.npy', sed)
def third(self): mkdir('thirdorder') cd('thirdorder') cp('../POSCAR', '.') self.generate_supercells3()
def pSheng(self): mkdir('SHENG') cd('SHENG') cp('../secondorder/FORCE_CONSTANTS', 'FORCE_CONSTANTS_2ND') cp('../thirdorder/FORCE_CONSTANTS_3RD', '.') self.getControl()
def creatmini(self, dir): cur = tl.pwd() tl.mkdir(dir) tl.cd(dir) minimize_input(self.m) tl.cd(cur)