SCM-NV / PLAMS

Python Library for Automating Molecular Simulations
https://www.scm.com/doc/plams
Other
65 stars 24 forks source link

Add UCS Support Into AMSResults #142

Closed dormrod closed 1 month ago

dormrod commented 1 month ago

Description

The principal aim of this PR is to allow the SCM ChemicalSystem support within PLAMS to be extended. Currently, it is supported for a ChemicalSystem can be passed into an AMSJob in place of a Molecule and have the job run successfully. In addition, a ChemicalSystem can now be retrieved from the AMSResults class via analogous methods to retrieving a Molecule.

In addition to facilitate this, unit test coverage has been added for the ams job and results classes, along with additional type-hinting and small bug fixes, detailed below.

Changes

Unit Tests

AMSJob

Unit tests added based off the output rkf files of a water geometry optimisation job. The small ams.rkf and dftb.rkf files have been added. A set of tests is then run for each of the following scenarios:

AMSResults

Unit tests added based again on the output rkf files of the water geometry optimisation. This allows testing of a fair number of the result getter methods.

Note these tests can only be run with an AMS installation - not on the CI on GitHub.

AMSResults

In AMSResults missing type hints have been added. In addition, the following methods have been added to get UCS out:

def get_system(self, section: str, file: str = "ams") -> "ChemicalSystem":
def get_main_system(self) -> "ChemicalSystem":
def get_input_system(self) -> "ChemicalSystem":

this is in analogy with the methods to retrieve Molecule/ASE Atoms. All these methods will raise an error if scm libbase is not available. There are additional methods (such as for retrieving history), but these are the simplest starting set.

Fixes

ChemicalSystem is now added to the type hint on AMSJob. In addition, the passed molecule is deep copied when passed into the job. This mirrors the behaviour of a Molecule and is generally assumed behaviour. A few small unhappy paths have also been patched in the AMSResults methods.

In addition, a change has been made to the InputParserFacade. A bug has been fixed in the non-scm version of the input parser and an efficiency improvement for the scm libbase version of the parser, which caches the instance so that the json definitions do not need to be constantly reloaded.