Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated tolerance for position comparison and eps parameter in wrap. … #58

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions sparc/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def resort(self):
else:
return self.sparc_bundle.sorting["resort"]

def check_state(self, atoms, tol=1e-9):
def check_state(self, atoms, tol=1e-8):
"""Updated check_state method.
By default self.atoms (cached from output files) contains the initial_magmoms,
so we add a zero magmoms to the atoms for comparison if it does not exist.
Expand All @@ -421,11 +421,10 @@ def check_state(self, atoms, tol=1e-9):
]
* len(atoms_copy)
)

system_changes = FileIOCalculator.check_state(self, atoms_copy, tol=tol)
# A few hard-written rules. Wrapping should only affect the position
if "positions" in system_changes:
atoms_copy.wrap()
atoms_copy.wrap(eps=tol)
new_system_changes = FileIOCalculator.check_state(self, atoms_copy, tol=tol)
if "positions" not in new_system_changes:
system_changes.remove("positions")
Expand Down Expand Up @@ -635,9 +634,12 @@ def _calculate_with_socket(
assert np.isclose(
ret["energy"], self.results["energy"]
), "Energy values from socket communication and output file are different! Please contact the developers."
assert np.isclose(
ret["forces"][self.resort], self.results["forces"]
).all(), "Force values from socket communication and output file are different! Please contact the developers."
try:
assert np.isclose(
ret["forces"][self.resort], self.results["forces"]
).all(), "Force values from socket communication and output file are different! Please contact the developers."
except KeyError:
print("Force values cannot be accessed via the results dictionary. They may not be available in the output file. Ensure PRINT_FORCES: 1\nResults:\n",self.results)
# For stress information, we make sure that the stress is always present
if "stress" not in self.results:
virial_from_socket = ret.get("virial", np.zeros(6))
Expand Down
Loading