Skip to content

Commit

Permalink
Merge branch 'devel' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz authored Feb 29, 2024
2 parents 360709b + a01acaa commit 18d3d1d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
5 changes: 4 additions & 1 deletion dpgen/data/surf.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ def poscar_scale(poscar_in, poscar_out, scale):
except AttributeError:
poscar = Poscar.from_str("".join(lines))
with open(poscar_out, "w") as fout:
fout.write(poscar.get_string(direct=False))
try:
fout.write(poscar.get_string(direct=False))
except AttributeError:
fout.write(poscar.get_str(direct=False))


def make_scale(jdata):
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/bcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.0:.16f} {0.0:.16f} {0.0:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/diamond.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.12500000000000:.16f} {0.12500000000000:.16f} {0.12500000000000:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/fcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.0:.16f} {0.0:.16f} {0.0:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/hcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0:.16f} {0:.16f} {0:.16f}\n"
Expand Down
2 changes: 1 addition & 1 deletion dpgen/data/tools/sc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def poscar_unit(latt):
ret += f"{box[0][0]:.16f} {box[0][1]:.16f} {box[0][2]:.16f}\n"
ret += f"{box[1][0]:.16f} {box[1][1]:.16f} {box[1][2]:.16f}\n"
ret += f"{box[2][0]:.16f} {box[2][1]:.16f} {box[2][2]:.16f}\n"
ret += "Type\n"
ret += "X\n"
ret += "%d\n" % numb_atoms()
ret += "Direct\n"
ret += f"{0.0:.16f} {0.0:.16f} {0.0:.16f}\n"
Expand Down
24 changes: 18 additions & 6 deletions tests/generator/test_make_fp.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@ def _check_kpoints(testCase, idx):
ret = make_kspacing_kpoints(
os.path.join(os.path.join(ii, "POSCAR")), kspacing, gamma
)
kpoints_ref = Kpoints.from_string(ret)
try:
kpoints_ref = Kpoints.from_string(ret)
except AttributeError:
kpoints_ref = Kpoints.from_str(ret)
testCase.assertEqual(repr(kpoints), repr(kpoints_ref))


Expand Down Expand Up @@ -496,12 +499,21 @@ def _check_incar_ele_temp(testCase, idx, ele_temp):
tidx = int(bname.split(".")[2])
with open("INCAR") as fp:
incar = fp.read()
incar0 = Incar.from_string(incar)
try:
incar0 = Incar.from_string(incar)
except AttributeError:
incar0 = Incar.from_str(incar)
# make_fake_md: the frames in a system shares the same ele_temp
incar1 = Incar.from_string(
vasp_incar_ele_temp_ref
% (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt)
)
try:
incar1 = Incar.from_string(
vasp_incar_ele_temp_ref
% (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt)
)
except AttributeError:
incar1 = Incar.from_str(
vasp_incar_ele_temp_ref
% (ele_temp[sidx][0] * pc.Boltzmann / pc.electron_volt)
)
for ii in incar0.keys():
# skip checking nbands...
if ii == "NBANDS":
Expand Down

0 comments on commit 18d3d1d

Please sign in to comment.