def getVaspRun_lammps(m): # generate structure rot = m.POSCAR2data() # generate in content = get_lammps_script(m) tl.write(content, "in") # generate dump.force tl.shell_exec(config.lammps + " < in >log.out") d, p, d1, p1 = rot # generate vasprun.xml f = open('dump.force') for i in range(9): f.next() forces = "" poses = "" for line in f: line = line.split() force = np.array(map(float, line[1:4])) pos = np.array(map(float, line[4:8])) force = RotateVector(force, d1, -p1) force = RotateVector(force, d, -p) forces += "<v> %f %f %f </v>\n" % tuple(force) poses += "<v> %f %f %f </v>\n" % tuple(pos) vasprun = '<root><calculation><varray name="forces" >\n' vasprun += forces vasprun += '</varray>\n<structure><varray name="positions">\n' + poses vasprun += '</varray></structure></calculation></root>\n' tl.write(vasprun, 'vasprun.xml') f.close()
def write(self): self.atoms.write("CN.xyz") write_vasp("POSCAR", self.atoms, sort="True", direct=True, vasp5=True) poscar = open("POSCAR") unit_cell = UnitCell(poscar) unit_cell.num_atom_types = len(self.elements) tools.write(unit_cell.output_lammps(), "structure")
def getTempProfile(self, begin, upP, deta, S, tcfactor, zfactor): fas = fixAveSpace('tempProfile.txt') quants = fas.getConvergence(upP + 1, begin) tools.to_txt(['Temperature(K)', 'Jx'], quants, 'convergenceT.txt') snapStep = fas.snapStep dto = dict(log="step\tkappa\n", plots=[]) coord, aveN, aveQuants = fas.iterate(begin, self.kappaConverge, snapStep, upP, deta, S, tcfactor, zfactor, dto) tools.write(dto['log'], 'convergenceK.txt') series( 'x(Augstrom)', 'temperature(K)', dto['plots'], 'convergenceT.png', linewidth=1, legend=False) filter = aveN[:] > 1 # at least 1 atom in the bin aveC = coord[filter] aveN = aveN[filter] aveTemp = aveQuants[filter, 0] avejx = aveQuants[filter, 1] nbin = len(avejx) data = np.c_[np.arange(nbin) + 1, aveC, aveN, aveTemp, avejx] tools.to_txt(['id', 'Coord', 'Count', 'Temp', 'Jx'], data, 'tempAve.txt') drawTempAve() return (aveC, aveN, aveTemp, avejx)
def prepareet(self): atoms = io.read('POSCAR') from pyspglib import spglib s = spglib.get_spacegroup(atoms) from aces.scanf import sscanf sgN = sscanf(s, '%s (%d)')[1] sg = Spacegroup(sgN) atoms.info = {'spacegroup': sg} nelect = self.getNelect(outcar='band/OUTCAR') # The remaining part takes care of writing the files required by # BoltzTraP. bandstructure = vasp2boltz.get_vasp_bandstructure(pathname='band/') tl.mkcd('et') vasp2boltz.write_bandstructure_boltztrap( bandstructure, filename='et.energy') vasp2boltz.write_structure_boltztrap(atoms, filename='et.struct') vasp2boltz.write_intrans_boltztrap( n_electrons=nelect, filename='et.intrans') s = tl.read('et.energy') s = s.replace('HTE', 'et') tl.write(s, 'et.energy') s = tl.read('et.struct') s = s.replace('HTE', 'et') tl.write(s, 'et.struct') tl.cd('..')
def prepareet(self): fermi = self.get_fermi() nelect = self.get_nelect() tl.mkcd('et') tl.cp('../band/SYMMETRY', '.') tl.cp('../band/EIGENVAL', '.') tl.cp('../band/POSCAR', '.') lpfac = 5 if(self.m.soc): lpfac = 20 s = """VASP 0 1 0 0.0 %f 0.0005 0.40 %f CALC %d BOLTZ .15 800. 50. 0. """ % (fermi, nelect, lpfac) # Format of DOS # iskip (not presently used) idebug setgap shiftgap # Fermilevel (eV, please note), energygrid (Ry),\ # energy span around Fermilevel (Ry), No of electrons # CALC (calculate expansion coeff), NOCALC read from file # lpfac, number of latt-points per k-point # run mode (only BOLTZ is supported) # (efcut) energy range of chemical potential (Ry) # Tmax, temperature grid # energyrange of bands given individual \ # DOS output sig_xxx and dos_xxx (xxx is band number) tl.write(s, "et.intrans") tl.cd('..')
def drawdos(self): from aces.ElectronicDOS.electronicdos import ElectronicDOS doscar = ElectronicDOS() # orbital_dos = doscar.sum_ms_dos() # Create a list of each atom type to sum over. # type_list = [] # n = 0 # for i in range(len(doscar.unit_cell.atom_types)): # type_list.append([]) # for j in range(doscar.unit_cell.atom_types[i]): # type_list[i].append(n) # n += 1 # Sum dos over sets of atoms. # partial_dos = doscar.sum_site_dos(type_list,orbital_dos) dos = doscar.write_dos([doscar.tot_dos]) tl.write(dos, 'dos.txt') dos = np.loadtxt('dos.txt') f = tl.shell_exec("grep fermi OUTCAR|tail -1") from aces.scanf import sscanf f = sscanf(f, "E-fermi : %f XC(G=0):") with fig("dos.png"): pl.xlabel("Energy-Ef (eV)") pl.ylabel("DOS") pl.plot(dos[:, 0] - f, dos[:, 1], lw=2) pl.xlim([-4, 4])
def prepareet(self): atoms = io.read('POSCAR') from pyspglib import spglib s = spglib.get_spacegroup(atoms) from aces.scanf import sscanf sgN = sscanf(s, '%s (%d)')[1] sg = Spacegroup(sgN) atoms.info = {'spacegroup': sg} nelect = self.getNelect(outcar='band/OUTCAR') # The remaining part takes care of writing the files required by # BoltzTraP. bandstructure = vasp2boltz.get_vasp_bandstructure(pathname='band/') tl.mkcd('et') vasp2boltz.write_bandstructure_boltztrap(bandstructure, filename='et.energy') vasp2boltz.write_structure_boltztrap(atoms, filename='et.struct') vasp2boltz.write_intrans_boltztrap(n_electrons=nelect, filename='et.intrans') s = tl.read('et.energy') s = s.replace('HTE', 'et') tl.write(s, 'et.energy') s = tl.read('et.struct') s = s.replace('HTE', 'et') tl.write(s, 'et.struct') tl.cd('..')
def phanados(self): from aces.tools import read m = self.m s = """20 1 1 %s 2 y 1000 y phana.dos.txt 0 """ % tl.toString(m.kpoints) s = s.replace(r'^\s+', '') tl.write(s, 'phana.dos.in') tl.passthru(config.phana + 'phonon.bin.%d <phana.dos.in' % m.Ctime) s = read('pdos.gnuplot') s = s.replace('pdos.eps', 'phana.dos.eps') tl.write(s, 'phana.dos.gnuplot') tl.passthru('rm pdos.gnuplot') tl.passthru('gnuplot phana.dos.gnuplot') tl.passthru('convert -rotate 90 phana.dos.eps phana.dos.png')
def write(self): self.atoms.write("CN.xyz") write_vasp("POSCAR",self.atoms,sort="True",direct=True,vasp5=True) poscar = open("POSCAR") unit_cell = UnitCell(poscar) unit_cell.num_atom_types=len(self.elements) tools.write(unit_cell.output_lammps(),"structure")
def post(self): import pandas as pd df = pd.read_csv("strain_stress.txt", sep=r"[ \t]", engine="python", skiprows=2, header=None) import numpy as np df = np.array(df) strain = df[:, 1] / df[0, 1] - 1 # convert to GPa # metalE/metalV/(siE/siV)=metalE/siE*siV/metalV=1/u.si.E()*u.si.L()**2 tl.cd('minimize') self.m.postMini() tl.cd('..') pxx = -df[:, 2] * 1e5 * 1e-9 * self.m.zfactor from aces.graph import plot plot((strain, 'Strain'), (pxx, 'Stress (GPa)'), 'stress.png', linewidth=2, grid=True) dp = pd.DataFrame() dp['Strain'] = strain dp['Stress_GPa'] = pxx dp.to_csv('cal_stress.txt', sep='\t', index=False, float_format="%f") from scipy import stats slope, intercept, r_value, p_value, std_err = stats.linregress( strain[:50], pxx[:50]) self.YoungsModulus = slope tl.write(slope, 'YoungsModulus.txt')
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 phana(self): from aces.tools import read m = self.m bp = m.bandpath bpp = m.bandpoints v = "" for i in range(len(bp) - 1): v += "%s\n%s\n101\n" % (tl.toString(bpp[bp[i]]), tl.toString(bpp[bp[i + 1]])) s = """20 1 2 phana.band.txt %sq 0 """ % v s = s.replace(r'^\s+', '') tl.write(s, 'phana.in') tl.passthru(config.phana + 'phonon.bin.%d <phana.in' % m.Ctime) s = read('pdisp.gnuplot') s = s.replace('pdisp.eps', 'phana.band.eps') tl.write(s, 'phana.band.gnuplot') tl.passthru('rm pdisp.gnuplot') tl.passthru('gnuplot phana.band.gnuplot') tl.passthru('convert -rotate 90 phana.band.eps phana.band.png')
def getVaspRun_vasp(self): m = self.m if m.isym: sym = "ISYM = 1" else: sym = "ISYM = 0" if m.ispin: spin = "ISPIN =2" else: spin = "" s = """SYSTEM=calculate energy PREC = High IBRION = 8 ENCUT = %f EDIFF = 1.0e-8 ISMEAR = %d; SIGMA = 0.01 IALGO = 38 LREAL = .FALSE. ADDGRID = .TRUE. LWAVE = .FALSE. LCHARG = .FALSE. %s %s """ % (self.m.ecut, m.ismear, sym, spin) s = s.replace(r'^\s+', '') tl.write(s, 'INCAR') m = self.m m.writePOTCAR() s = """A 0 Monkhorst-Pack %s 0 0 0 """ % ' '.join(map(str, m.ekpoints)) s = s.replace(r'^\s+', '') tl.write(s, 'KPOINTS') if 'jm' in self.__dict__: from aces.jobManager import pbs path = tl.pwd() if m.queue == "q3.4": pb = pbs(queue=m.queue, nodes=12, procs=4, disp=m.pbsname, path=path, content=config.mpirun + " 48 " + config.vasp + ' >log.out') else: pb = pbs(queue=m.queue, nodes=4, procs=12, disp=m.pbsname, path=path, content=config.mpirun + " 48 " + config.vasp + ' >log.out') self.jm.reg(pb) else: tl.shell_exec(config.mpirun + " %s " % m.cores + config.vasp + ' >log.out')
def writefc2(fc2, filename='FORCE_CONSTANTS_2ND'): natom = len(fc2) s = "%d\n" % natom for i in range(natom): for j in range(natom): s += "%d\t%d\n" % (i + 1, j + 1) s += matrixFormat(fc2[i, j]) tl.write(s, filename)
def thcode(self, files, put): s = "" for file in files: dir = "dirs/dir_" + file s += "cd %s\n" % (dir) s += "yhbatch -N 1 aces.pbs\n" s += "cd ../../\n" write(s, put + "/runall.sh")
def thcode(self, files, put): s = "" for file in files: dir = "dirs/dir_" + file s += "cd %s\n" % (dir) s += "yhbatch -N 1 aces.pbs\n" s += "cd ../../\n" write(s, put + "/runall.sh")
def writefc2(fc2, filename='FORCE_CONSTANTS_2ND'): natom = len(fc2) s = "%d\n" % natom for i in range(natom): for j in range(natom): s += "%d\t%d\n" % (i + 1, j + 1) s += matrixFormat(fc2[i, j]) tl.write(s, filename)
def get_bandplot(self): tl.write("""diam.freq 0 600 band.plot band.ps 0.0 50.0 0.0""", "plotband.in") tl.shell_exec(config.espresso + "bin/plotband.x < plotband.in >plotband.out")
def getnscfin(self): m = self.m tmpl = self.getscf_template() nscfk = self.getNscfKpoints() aa = '\n'.join([m.toString(a) for a in nscfk]) newskpoints = "K_POINTS crystal\n%d\n%s" % (len(nscfk), aa) s = tmpl.replace('TYPE', 'nscf').replace('CONTROL', '').replace( 'KPOINTS', newskpoints) tl.write(s, "nscf.in")
def get_bandplot(self): tl.write("""diam.freq 0 600 band.plot band.ps 0.0 50.0 0.0""", "plotband.in") tl.shell_exec(config.espresso + "bin/plotband.x < plotband.in >plotband.out")
def writeKPOINTS(kpoints): s = """A 0 Monkhorst-Pack %s 0 0 0 """ % ' '.join(map(str, kpoints)) s = tl.headtrim(s) tl.write(s, 'KPOINTS')
def prepare(self): db=self.db['/particles/main/velocity/'] self.natom=db['value'].shape[1] self.totalStep=db['step'].shape[0] if self.totalStep%2==1:self.totalStep-=1 print "Atom Number=",self.natom print "Total step=",self.totalStep self.timestep=db['time'][1]-db['time'][0] write('%d %d %f'%(self.natom,self.totalStep,self.timestep),'velocity.info')
def writeKPOINTS(kpoints): s = """A 0 Monkhorst-Pack %s 0 0 0 """ % ' '.join(map(str, kpoints)) s = tl.headtrim(s) tl.write(s, 'KPOINTS')
def get_fitin(self): content = tl.read('alm.in').replace('suggest', 'fitting') fitting = """&fitting \tNDATA = %d \tDFILE = disp_all.dat \tFFILE = force_all.dat / """ % self.NDATA fitting = tl.trimhead(fitting) tl.write(content + fitting, 'fit.in')
def setUp(self): content="""# Spatial-averaged data for fix temp_profile and group main # Timestep Number-of-bins # Bin Coord Ncount v_temp v_jx 100000 19 1 14.961 0 0 0 2 17.961 0 0 0 3 20.961 10 291.241 -0.00395033 """ write(content,'tmptestlinemanager.txt')
def setUp(self): content = """# Spatial-averaged data for fix temp_profile and group main # Timestep Number-of-bins # Bin Coord Ncount v_temp v_jx 100000 19 1 14.961 0 0 0 2 17.961 0 0 0 3 20.961 10 291.241 -0.00395033 """ write(content, 'tmptestlinemanager.txt')
def getnscfin(self): m = self.m tmpl = self.getscf_template() nscfk = self.getNscfKpoints() aa = '\n'.join([m.toString(a) for a in nscfk]) newskpoints = "K_POINTS crystal\n%d\n%s" % (len(nscfk), aa) s = tmpl.replace('TYPE', 'nscf').replace('CONTROL', '').replace('KPOINTS', newskpoints) tl.write(s, "nscf.in")
def getpedos(self): tl.write("""&projwfc outdir='./' prefix='diam' filpdos='diam.pedos', Emin=-10.0, Emax=10.0, DeltaE=0.1,degauss=0.0025,ngauss=-99 / """, "pedos.in") projwfc = self.getx('projwfc') tl.shell_exec(projwfc + " < pedos.in >pedos.out")
def get_fitin(self): content = tl.read('alm.in').replace('suggest', 'fitting') fitting = """&fitting \tNDATA = %d \tDFILE = disp_all.dat \tFFILE = force_all.dat / """ % self.NDATA fitting = tl.trimhead(fitting) tl.write(content + fitting, 'fit.in')
def modulation(self): m = self.m conf = """ DIM = %s MODULATION = 1 1 1, 0 0 0 0 1 0 ATOM_NAME = %s FORCE_CONSTANTS = READ """ % (m.dim, ' '.join(m.elements)) write(conf, 'modulation.conf') passthru(config.phonopy + "--tolerance=1e-4 modulation.conf")
def force_constant(self, files): cmd = config.phono3py + "--cf3 " for file in files: dir = "dirs/dir_" + file cmd += dir + '/vasprun.xml ' tl.write(cmd, 'post.sh') # generate FORCE_SETS tl.passthru("sh post.sh") m = self.m print("Create fc2.hdf and fc3.hdf") tl.passthru(config.phono3py + "-c POSCAR --dim='%s'" % (m.dim))
def modulation(self): m = self.m conf = """ DIM = %s MODULATION = 1 1 1, 0 0 0 0 1 0 ATOM_NAME = %s FORCE_CONSTANTS = READ """ % (m.dim, ' '.join(m.elements)) write(conf, 'modulation.conf') passthru(config.phonopy + "--tolerance=1e-4 modulation.conf")
def getpedos(self): tl.write( """&projwfc outdir='./' prefix='diam' filpdos='diam.pedos', Emin=-10.0, Emax=10.0, DeltaE=0.1,degauss=0.0025,ngauss=-99 / """, "pedos.in") projwfc = self.getx('projwfc') tl.shell_exec(projwfc + " < pedos.in >pedos.out")
def getscfin(self): m = self.m tmpl = self.getscf_template() skpoints = "K_POINTS automatic\n%s 1 1 1" % tl.toString(m.ekpoints) a = """tprnfor = .true. tstress = .true. restart_mode = 'from_scratch' """ s = tmpl.replace('TYPE', 'scf').replace('CONTROL', a).replace( 'KPOINTS', skpoints) tl.write(s, 'scf.in')
def getedos(self): fermi = self.getfermi() tl.write("""&DOS outdir='./' prefix='diam' fildos='diam.edos', Emin=%f, Emax=%f, DeltaE=0.01,degauss=0.005,ngauss=1 / """ % (-4.0 + fermi, 4.0 + fermi), "edos.in") dos = self.getx("dos") tl.shell_exec(dos + " < edos.in >edos.out") self.drawedos()
def animate(self): m = self.m conf = """ DIM = %s ANIME = 0 5 20 ANIME_TYPE = xyz ATOM_NAME = %s FORCE_CONSTANTS = READ """ % (m.dim, ' '.join(m.elements)) write(conf, 'animate.conf') passthru(config.phonopy + "--tolerance=1e-4 animate.conf")
def getscfin(self): m = self.m tmpl = self.getscf_template() skpoints = "K_POINTS automatic\n%s 1 1 1" % tl.toString(m.ekpoints) a = """tprnfor = .true. tstress = .true. restart_mode = 'from_scratch' """ s = tmpl.replace('TYPE', 'scf').replace('CONTROL', a).replace('KPOINTS', skpoints) tl.write(s, 'scf.in')
def animate(self): m = self.m conf = """ DIM = %s ANIME = 0 5 20 ANIME_TYPE = xyz ATOM_NAME = %s FORCE_CONSTANTS = READ """ % (m.dim, ' '.join(m.elements)) write(conf, 'animate.conf') passthru(config.phonopy + "--tolerance=1e-4 animate.conf")
def getdispforce(self, files): force = "" disp = "" orig = io.read('POSCAR-supercell').positions for dir0 in files: forcearr = read_forces( 'dirs/dir_%s/vasprun.xml' % dir0) / 25.7110 # in Rd/bohr force += matrixFormat(forcearr) disparr = (io.read('dirs/dir_%s/POSCAR' % dir0).positions - orig ) * 1.889726 # in bohr disp += matrixFormat(disparr) tl.write(disp, "disp_all.dat") tl.write(force, "force_all.dat")
def getdispforce(self, files): force = "" disp = "" orig = io.read('POSCAR-supercell').positions for dir0 in files: forcearr = read_forces( 'dirs/dir_%s/vasprun.xml' % dir0) / 25.7110 # in Rd/bohr force += matrixFormat(forcearr) disparr = (io.read('dirs/dir_%s/POSCAR' % dir0).positions - orig) * 1.889726 # in bohr disp += matrixFormat(disparr) tl.write(disp, "disp_all.dat") tl.write(force, "force_all.dat")
def getedos(self): fermi = self.getfermi() tl.write( """&DOS outdir='./' prefix='diam' fildos='diam.edos', Emin=%f, Emax=%f, DeltaE=0.01,degauss=0.005,ngauss=1 / """ % (-4.0 + fermi, 4.0 + fermi), "edos.in") dos = self.getx("dos") tl.shell_exec(dos + " < edos.in >edos.out") self.drawedos()
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 getphin(self): m = self.m nqs = "nq1=%d,\n nq2= %d,\n nq3= %d," % tuple(m.kpoints) s = """-- &inputph prefix = 'diam' fildyn = 'diam.dyn' fildvscf = 'dvscf' ldisp = .true %s tr2_ph = 1.0d-12 / """ % nqs tl.write(s, 'ph.in')
def getphin(self): m = self.m nqs = "nq1=%d,\n nq2= %d,\n nq3= %d," % tuple(m.kpoints) s = """-- &inputph prefix = 'diam' fildyn = 'diam.dyn' fildvscf = 'dvscf' ldisp = .true %s tr2_ph = 1.0d-12 / """ % nqs tl.write(s, 'ph.in')
def generate_vconf(self): # generate v.conf m = self.m mesh = """DIM = %s ATOM_NAME = %s MP = %s FORCE_CONSTANTS = READ MESH_SYMMETRY = .FALSE. GROUP_VELOCITY=.TRUE. PRIMITIVE_AXIS = %s """ % (m.dim, ' '.join(m.elements), ' '.join(map( str, m.kpoints)), toString(m.premitive.flatten())) mesh = mesh.replace(r'^\s+', '') write(mesh, 'v.conf')
def get_dos(self): m = self.m amass = self.get_amass() nks = "nk1=%d,nk2= %d,nk3= %d" % tuple(m.nqf) tl.write("""&input asr='simple', dos=.true. %s flfrc='diam.fc', fldos='diam.dos', %s /""" % (amass, nks), "phdos.in") matdyn = self.getx("matdyn", pa=False) tl.shell_exec(matdyn + "< phdos.in >phdos.out") self.drawDos()
def drawpr(self): pr() # plot xs = [] ys = [] for line in open('pr.txt'): x, y = map(float, line.split()) xs.append(x) ys.append(y) write("%s" % (sum(ys) / len(ys)), "ave_pr.txt") with fig('Paticipation_ratio.png'): pl.plot(xs, ys, '.', color='red') pl.ylim([0.0, 1.0]) pl.xlabel('Frequency (THz)') pl.ylabel('Paticipation Ratio')
def generate_vconf(self): # generate v.conf m = self.m mesh = """DIM = %s ATOM_NAME = %s MP = %s FORCE_CONSTANTS = READ MESH_SYMMETRY = .FALSE. GROUP_VELOCITY=.TRUE. PRIMITIVE_AXIS = %s """ % (m.dim, ' '.join(m.elements), ' '.join(map(str, m.kpoints)), toString(m.premitive.flatten())) mesh = mesh.replace(r'^\s+', '') write(mesh, 'v.conf')
def drawpr(self): pr() # plot xs = [] ys = [] for line in open('pr.txt'): x, y = map(float, line.split()) xs.append(x) ys.append(y) write("%s" % (sum(ys) / len(ys)), "ave_pr.txt") with fig('Paticipation_ratio.png'): pl.plot(xs, ys, '.', color='red') pl.ylim([0.0, 1.0]) pl.xlabel('Frequency (THz)') pl.ylabel('Paticipation Ratio')
def get_dos(self): m = self.m amass = self.get_amass() nks = "nk1=%d,nk2= %d,nk3= %d" % tuple(m.nqf) tl.write( """&input asr='simple', dos=.true. %s flfrc='diam.fc', fldos='diam.dos', %s /""" % (amass, nks), "phdos.in") matdyn = self.getx("matdyn", pa=False) tl.shell_exec(matdyn + "< phdos.in >phdos.out") self.drawDos()
def get_almin(self): m = self.m m.atoms = io.read('POSCAR') atoms = m.atoms.repeat(m.supercell) general = """&general \tPREFIX = alm \tMODE = suggest \tNAT = %s; NKD = %s \tKD = %s / """ % (len(atoms), len(m.elements), m.toString(m.elements)) interaction = """&interaction \tNORDER = 2 / """ cell = """&cell \t1.889726 \t%s / """ % ('\n '.join([m.toString(atoms.cell[i]) for i in range(3)])) cutoff = """&cutoff \t*-* None %f / """ % (self.m.shengcut * 1.889726) pos = ' \n'.join([ '\t%s ' % (m.elements.index(a.symbol) + 1) + m.toString(atoms.get_scaled_positions()[i]) for i, a in enumerate(atoms) ]) position = """&position %s / """ % pos s = tl.headtrim(general + interaction + cell + cutoff + position) tl.write(s, 'alm.in') write_vasp('POSCAR-supercell', atoms, sort="True", direct=True, vasp5=True)
def generate_bandconf(self): # generate mesh.conf m = self.m bp = m.bandpoints bpath = ' '.join([toString(bp[x]) for x in m.bandpath]) band = """DIM = %s ATOM_NAME = %s BAND = %s BAND_POINTS = 101 FORCE_CONSTANTS = READ PRIMITIVE_AXIS = %s """ % (m.dim, ' '.join(m.elements), bpath, toString(m.premitive.flatten())) band = band.replace(r'^\s+', '') write(band, 'band.conf')
def writeINCAR(self): m = self.m npar = 1 for i in range(1, int(np.sqrt(m.cores)) + 1): if m.cores % i == 0: npar = i if m.ispin: ispin = "ISPIN=2" else: ispin = "" if m.soc: soc = "LSORBIT=T" else: soc = "" if m.isym: sym = "ISYM = 1" else: sym = "ISYM = 0" s = """SYSTEM=calculate energy PREC = High IBRION = -1 ENCUT = %f EDIFF = 1.0e-8 ISMEAR = %d; SIGMA = 0.01 IALGO = 38 LREAL = .FALSE. ADDGRID = .TRUE. LWAVE = .FALSE. LCHARG = .FALSE. NPAR = %d %s %s %s """ % (self.m.ecut, m.ismear, npar, sym, ispin, soc) if m.vdw: s += """\nIVDW = 1 VDW_RADIUS = 50 VDW_S6 = 0.75 VDW_SR = 1.00 VDW_SCALING = 0.75 VDW_D = 20.0 VDW_C6 = 63.540 31.50 VDW_R0 = 1.898 1.892 """ s = s.replace(r'^\s+', '') write(s, 'INCAR')
def generate_bandconf(self): # generate mesh.conf m = self.m bp = m.bandpoints bpath = ' '.join([toString(bp[x]) for x in m.bandpath]) band = """DIM = %s ATOM_NAME = %s BAND = %s BAND_POINTS = 101 FORCE_CONSTANTS = READ PRIMITIVE_AXIS = %s """ % (m.dim, ' '.join( m.elements), bpath, toString(m.premitive.flatten())) band = band.replace(r'^\s+', '') write(band, 'band.conf')
def generate_vqconf(self, q): # generate q.conf m = self.m mesh = """DIM = %s ATOM_NAME = %s FORCE_CONSTANTS = READ GROUP_VELOCITY=.TRUE. QPOINTS=.TRUE. PRIMITIVE_AXIS = %s """ % (m.dim, ' '.join(m.elements), toString(m.premitive.flatten())) mesh = mesh.replace(r'^\s+', '') write(mesh, 'q.conf') s = "%s\n" % len(q) for qq in q: s += "%s\n" % toString(qq) write(s, 'QPOINTS')