Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update {Elastic,run,surf,Vasp,vasp}.py: To be compatible with Pymatgen #1302

Merged
merged 30 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
03c93ee
Update run.py
ZhouXY-PKU Aug 4, 2023
1d6578b
Update run.py: To be compatible with new and old versions of Pymatgen
ZhouXY-PKU Aug 5, 2023
b5004ea
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2023
f8b5b9b
Update surf.py
ZhouXY-PKU Aug 5, 2023
5a10743
Update Elastic.py
ZhouXY-PKU Aug 5, 2023
cd9e401
Update VASP.py
ZhouXY-PKU Aug 5, 2023
c61e470
Update run.py
ZhouXY-PKU Aug 5, 2023
d2efd4c
Update vasp.py
ZhouXY-PKU Aug 5, 2023
44a1650
Update Elastic.py
ZhouXY-PKU Aug 5, 2023
5972106
Update VASP.py
ZhouXY-PKU Aug 5, 2023
d06bf02
Merge branch 'devel' into master
ZhouXY-PKU Aug 5, 2023
b67b4bf
Update VASP.py
ZhouXY-PKU Aug 6, 2023
7561d43
Update Elastic.py
ZhouXY-PKU Aug 6, 2023
275855a
Update VASP.py
ZhouXY-PKU Aug 6, 2023
d7f1787
Update Elastic.py
ZhouXY-PKU Aug 6, 2023
b23d09a
Update vasp.py
ZhouXY-PKU Aug 6, 2023
91c21b6
Update surf.py
ZhouXY-PKU Aug 6, 2023
ceb8794
Update run.py
ZhouXY-PKU Aug 6, 2023
9aaafcd
Update VASP.py
ZhouXY-PKU Aug 7, 2023
49e93b6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2023
bb7d24d
Update Elastic.py
ZhouXY-PKU Aug 7, 2023
d66b580
Update vasp.py
ZhouXY-PKU Aug 7, 2023
3925bec
Update run.py
ZhouXY-PKU Aug 7, 2023
97e63fc
Update surf.py
ZhouXY-PKU Aug 7, 2023
84db5cc
Update Elastic.py
ZhouXY-PKU Aug 10, 2023
c2939a4
Update VASP.py
ZhouXY-PKU Aug 10, 2023
5b2c6af
Update vasp.py
ZhouXY-PKU Aug 10, 2023
9f6a307
Update surf.py
ZhouXY-PKU Aug 10, 2023
94d9f84
Update run.py
ZhouXY-PKU Aug 10, 2023
b86bedc
Merge branch 'devel' into master
ZhouXY-PKU Aug 10, 2023
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
7 changes: 6 additions & 1 deletion dpgen/auto_test/Elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ def post_process(self, task_list):
kspacing = incar.get("KSPACING")
kgamma = incar.get("KGAMMA", False)
ret = vasp.make_kspacing_kpoints(poscar_start, kspacing, kgamma)
kp = Kpoints.from_string(ret)
pymgv = "old"
try:
kp = Kpoints.from_string(ret)
except AttributeError:
kp = Kpoints.from_str(ret)
pymgv = "new"
if os.path.isfile("KPOINTS"):
os.remove("KPOINTS")
kp.write_file("KPOINTS")
Expand Down
7 changes: 6 additions & 1 deletion dpgen/auto_test/VASP.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ def make_input_file(self, output_dir, task_type, task_param):
os.symlink("../INCAR", "INCAR")
os.chdir(cwd)
ret = vasp.make_kspacing_kpoints(self.path_to_poscar, kspacing, kgamma)
kp = Kpoints.from_string(ret)
pymgv = "old"
try:
kp = Kpoints.from_string(ret)
except AttributeError:
kp = Kpoints.from_str(ret)
pymgv = "new"
kp.write_file(os.path.join(output_dir, "KPOINTS"))

def compute(self, output_dir):
Expand Down
12 changes: 10 additions & 2 deletions dpgen/auto_test/lib/vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,12 @@ def make_vasp_kpoints_from_incar(work_dir, jdata):
assert os.path.exists("INCAR")
with open("INCAR") as fp:
incar = fp.read()
standard_incar = incar_upper(Incar.from_string(incar))
pymgv = "old"
try:
standard_incar = incar_upper(Incar.from_string(incar))
except AttributeError:
standard_incar = incar_upper(Incar.from_str(incar))
pymgv = "new"
if fp_aniso_kspacing is None:
try:
kspacing = standard_incar["KSPACING"]
Expand All @@ -533,6 +538,9 @@ def make_vasp_kpoints_from_incar(work_dir, jdata):
assert os.path.exists("POSCAR")
# make kpoints
ret = make_kspacing_kpoints("POSCAR", kspacing, gamma)
kp = Kpoints.from_string(ret)
if pymgv == "new":
kp = Kpoints.from_str(ret)
elif pymgv == "old":
kp = Kpoints.from_string(ret)
kp.write_file("KPOINTS")
os.chdir(cwd)
7 changes: 6 additions & 1 deletion dpgen/data/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,12 @@ def poscar_scale(poscar_in, poscar_out, scale):
else:
raise RuntimeError("Unknow poscar style at line 7: %s" % lines[7])

poscar = Poscar.from_string("".join(lines))
pymgv = "old"
try:
poscar = Poscar.from_string("".join(lines))
except AttributeError:
poscar = Poscar.from_str("".join(lines))
pymgv = "new"
with open(poscar_out, "w") as fout:
fout.write(poscar.get_string(direct=False))

Expand Down
24 changes: 20 additions & 4 deletions dpgen/generator/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2859,14 +2859,22 @@ def make_pwmat_input(jdata, filename):
def make_vasp_incar_ele_temp(jdata, filename, ele_temp, nbands_esti=None):
with open(filename) as fp:
incar = fp.read()
incar = incar_upper(Incar.from_string(incar))
pymgv = "old"
try:
incar = incar_upper(Incar.from_string(incar))
except AttributeError:
incar = incar_upper(Incar.from_str(incar))
pymgv = "new"
incar["ISMEAR"] = -1
incar["SIGMA"] = ele_temp * pc.Boltzmann / pc.electron_volt
incar.write_file("INCAR")
if nbands_esti is not None:
nbands = nbands_esti.predict(".")
with open(filename) as fp:
incar = Incar.from_string(fp.read())
if pymgv == "new":
incar = Incar.from_str(fp.read())
elif pymgv == "old":
incar = Incar.from_string(fp.read())
incar["NBANDS"] = nbands
incar.write_file("INCAR")

Expand Down Expand Up @@ -2943,7 +2951,12 @@ def make_fp_vasp_kp(iter_index, jdata):
assert os.path.exists("INCAR")
with open("INCAR") as fp:
incar = fp.read()
standard_incar = incar_upper(Incar.from_string(incar))
pymgv = "old"
try:
standard_incar = incar_upper(Incar.from_string(incar))
except AttributeError:
standard_incar = incar_upper(Incar.from_str(incar))
pymgv = "new"
if fp_aniso_kspacing is None:
try:
kspacing = standard_incar["KSPACING"]
Expand All @@ -2966,7 +2979,10 @@ def make_fp_vasp_kp(iter_index, jdata):
assert os.path.exists("POSCAR")
# make kpoints
ret = make_kspacing_kpoints("POSCAR", kspacing, gamma)
kp = Kpoints.from_string(ret)
if pymgv == "new":
kp = Kpoints.from_str(ret)
elif pymgv == "old":
kp = Kpoints.from_string(ret)
kp.write_file("KPOINTS")
os.chdir(cwd)

Expand Down