mirror of
https://github.com/triqs/dft_tools
synced 2025-01-03 10:05:49 +01:00
helper script to write inmdftpr file
This commit is contained in:
parent
b8b1b6b77d
commit
27f642b11d
86
bin/init_dmftpr
Executable file
86
bin/init_dmftpr
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import glob, sys, os
|
||||||
|
import itertools
|
||||||
|
from numpy import array
|
||||||
|
|
||||||
|
def write_indmftpr():
|
||||||
|
orbitals = {"s" : [1, 0, 0, 0],
|
||||||
|
"p" : [0, 1, 0, 0],
|
||||||
|
"d" : [0, 0, 1, 0],
|
||||||
|
"f" : [0, 0, 0, 1]}
|
||||||
|
corr_orbitals = {"s" : [2, 0, 0, 0],
|
||||||
|
"p" : [0, 2, 0, 0],
|
||||||
|
"d" : [0, 0, 2, 0],
|
||||||
|
"f" : [0, 0, 0, 2]}
|
||||||
|
dirname = os.getcwd().rpartition('/')[2]
|
||||||
|
if os.path.isfile(dirname + ".indmftpr"):
|
||||||
|
found = input("Previous {}.indmftpr detected! Continue? (y/n)\n".format(dirname))
|
||||||
|
if found == "n":
|
||||||
|
sys.exit(0)
|
||||||
|
with open(dirname + ".indmftpr", "w") as out:
|
||||||
|
print("Preparing dmftproj input file : {}\n".format(dirname + ".indmftpr"))
|
||||||
|
struct = open(glob.glob("*.struct")[0], "r").readlines()
|
||||||
|
species = [line.split()[0] for line in struct if "NPT" in line]
|
||||||
|
num_atoms = len(species)
|
||||||
|
out.write(str(num_atoms)+"\n")
|
||||||
|
mult = [line.split("=")[1].split()[0] for line in struct if "MULT" in line ]
|
||||||
|
out.write(" ".join(mult)+"\n")
|
||||||
|
out.write("3\n")
|
||||||
|
for atom in range(num_atoms):
|
||||||
|
while True: # input choice of spherical harmonics for atom
|
||||||
|
sph_harm=input("What flavor of spherical harmonics do you want to use for ATOM {} ({})? (cubic/complex)\n".format(atom+1, species[atom]))
|
||||||
|
if sph_harm in ["cubic", "complex"]:
|
||||||
|
out.write(sph_harm+"\n")
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("Did not recognize that input. Try again.")
|
||||||
|
corr=input("Do you want to treat ATOM {} ({}) as correlated (y/n)?\n".format(atom+1, species[atom]))
|
||||||
|
if corr == "y":
|
||||||
|
proj=input("Specify the correlated orbital? (d,f)\n")
|
||||||
|
non_corr=input("projectors for non-correlated orbitals?\n")
|
||||||
|
projectors=array([0, 0, 0, 0])
|
||||||
|
projectors += array(corr_orbitals[proj])
|
||||||
|
if len(non_corr) > 0:
|
||||||
|
for p in non_corr:
|
||||||
|
projectors += array(orbitals[p])
|
||||||
|
out.write(" ".join(list(map(str, projectors)))+"\n")
|
||||||
|
if proj == "d":
|
||||||
|
irrep=input("Split this orbital into it's irreps? (t2g/eg/n)\n")
|
||||||
|
if irrep == "t2g":
|
||||||
|
out.write("0 0 2 0\n")
|
||||||
|
out.write("01\n")
|
||||||
|
elif irrep == "t2g":
|
||||||
|
out.write("0 0 2 0\n")
|
||||||
|
out.write("10\n")
|
||||||
|
else:
|
||||||
|
out.write("0 0 0 0\n")
|
||||||
|
soc=input("Do you want to include soc? (y/n)\n")
|
||||||
|
if soc == "y":
|
||||||
|
out.write("1\n")
|
||||||
|
else:
|
||||||
|
out.write("0\n")
|
||||||
|
else: # still identify the projectors
|
||||||
|
while True:
|
||||||
|
proj=input("Specify the projectors that you would like to include? (type h for help)\n")
|
||||||
|
if proj == "h":
|
||||||
|
print("indicate orbital projectors using (s, p, d, or f). For multiple, combine them (sp, pd, spd, etc.)")
|
||||||
|
else:
|
||||||
|
projectors = array([0, 0, 0, 0], dtype=int)
|
||||||
|
for p in proj: projectors += array(orbitals[p], dtype=int)
|
||||||
|
out.write(" ".join(list(map(str, projectors)))+"\n")
|
||||||
|
out.write("0 0 0 0\n")
|
||||||
|
break
|
||||||
|
while True:
|
||||||
|
window=input("Specify the projection window around eF (in Ry)\n")
|
||||||
|
if float(window.split()[0]) < 0 and float(window.split()[1]) > 0:
|
||||||
|
out.write(window)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print("The energy window ({}) does not contain the Fermi energy!".format(window))
|
||||||
|
|
||||||
|
print("initialize {} file ok!".format(dirname + ".indmftpr"))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
write_indmftpr()
|
Loading…
Reference in New Issue
Block a user