diff --git a/dpdata/abacus/scf.py b/dpdata/abacus/scf.py index 47ac6de43..424e39fa3 100644 --- a/dpdata/abacus/scf.py +++ b/dpdata/abacus/scf.py @@ -182,15 +182,19 @@ 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 @@ -198,15 +202,19 @@ def parse_stru_pos(pos_line): 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 @@ -214,16 +222,17 @@ def parse_stru_pos(pos_line): 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")