diff --git a/castep_outputs/parsers/castep_file_parser.py b/castep_outputs/parsers/castep_file_parser.py index 9eeffd5..f886c2f 100644 --- a/castep_outputs/parsers/castep_file_parser.py +++ b/castep_outputs/parsers/castep_file_parser.py @@ -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: diff --git a/castep_outputs/test/test_castep_parser.py b/castep_outputs/test/test_castep_parser.py index 8497a81..b3b6551 100644 --- a/castep_outputs/test/test_castep_parser.py +++ b/castep_outputs/test/test_castep_parser.py @@ -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("""