Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 9, 2024
1 parent 6dd5e05 commit d20ed7f
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions dpdata/abacus/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,48 +182,57 @@ def parse_stru_pos(pos_line):
constrain_list.append(bool(int(sline[i])))
elif label == "lambda":
lambda_list.append(float(sline[i]))

if len(move_list) > 0:
assert(len(move_list) == 3), f"should 3 numbers to define if atom can move, but got {len(move_list)}"
assert (
len(move_list) == 3
), f"should 3 numbers to define if atom can move, but got {len(move_list)}"
move = move_list

if len(velocity_list) > 0:
assert(len(velocity_list) == 3), f"should 3 numbers to define velocity, but got {len(velocity_list)}"
assert (
len(velocity_list) == 3
), f"should 3 numbers to define velocity, but got {len(velocity_list)}"
velocity = velocity_list

if len(mag_list) > 0:
if len(mag_list) == 3:
magmom = mag_list
elif len(mag_list) == 1:
magmom = mag_list[0]
else:
raise RuntimeError(f"Invalid magnetic moment {mag_list}")

if len(angle1_list) > 0:
assert(len(angle1_list) == 1), f"should 1 number to define angle1, but got {len(angle1_list)}"
assert (
len(angle1_list) == 1
), f"should 1 number to define angle1, but got {len(angle1_list)}"
angle1 = angle1_list[0]

if len(angle2_list) > 0:
assert(len(angle2_list) == 1), f"should 1 number to define angle2, but got {len(angle2_list)}"
assert (
len(angle2_list) == 1
), f"should 1 number to define angle2, but got {len(angle2_list)}"
angle2 = angle2_list[0]

if len(constrain_list) > 0:
if len(constrain_list) == 3:
constrain = constrain_list
elif len(constrain_list) == 1:
constrain = constrain_list[0]
else:
raise RuntimeError(f"Invalid constrain {constrain_list}")

if len(lambda_list) > 0:
if len(lambda_list) == 3:
lambda1 = lambda_list
elif len(lambda_list) == 1:
lambda1 = lambda_list[0]
else:
raise RuntimeError(f"Invalid lambda {lambda_list}")

return pos,move,velocity,magmom,angle1,angle2,constrain,lambda1
raise RuntimeError(f"Invalid lambda {lambda_list}")

return pos, move, velocity, magmom, angle1, angle2, constrain, lambda1


def get_coords(celldm, cell, geometry_inlines, inlines=None):
coords_lines = get_stru_block(geometry_inlines, "ATOMIC_POSITIONS")
Expand Down

0 comments on commit d20ed7f

Please sign in to comment.