Skip to content

Commit

Permalink
Add parsing for CoM removal
Browse files Browse the repository at this point in the history
  • Loading branch information
oerc0122 committed Oct 3, 2024
1 parent 5899c35 commit 52e821c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 17 additions & 0 deletions castep_outputs/parsers/castep_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,23 @@ def parse_castep_file(castep_file_in: TextIO,

curr_run["forces"][key].append(val)

elif block := Block.from_re(line, castep_file,
"firstd_calculate: removing force on centre of mass",
r"^\s*$"):

if Filters.FORCE not in to_parse:
continue

if "forces" not in curr_run:
curr_run["forces"] = defaultdict(list)

key = "com_force_removal"
val = to_type([get_numbers(line)[0] for line in block if line.startswith(" dF")], float)

logger("Found %s forces", key)

curr_run["forces"][key].append(val)

# Stress tensor block
elif block := Block.from_re(line, castep_file, REs.STRESSES_BLOCK_RE, r"^\s*\*+$"):
if Filters.STRESS not in to_parse:
Expand Down
9 changes: 6 additions & 3 deletions castep_outputs/test/test_castep_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,14 @@ def test_get_verbose_com_remove(self):
dFx: -1.0633987424376136E-008 eV/A
dFy: 4.9260774814424966E-008 eV/A
dFz: -9.5379737861699631E-004 eV/A
""")
self.skipTest("Not implemented yet")

test_dict = parse_castep_file(test_text)[0]
pprint.pprint(test_dict)
self.assertEqual(test_dict, {})

self.assertEqual(test_dict, {'forces': {'com_force_removal': [(-1.0633987424376136e-08,
4.9260774814424966e-08,
-0.0009537973786169963)]}})

def test_get_k_pts(self):
test_text = io.StringIO("""
Expand Down

0 comments on commit 52e821c

Please sign in to comment.