PackageWrapper

A module which adds the PackageWrapper class.

The herein implemented class serves as a wrapper around the qmflows Result class, taking a single plams.Job type as argument and, upon calling pkg = PackageWrapper(...); pkg() an appropiate instance of Package subclas instance is called.

For example, passing plams.ADFJob will automatically call adf, plams.Cp2kJob will call cp2k, etc.

When no appropiate Package is found, let’s say after passing the MyFancyJob type, the PackageWrapper class will still run the job as usual and return the matching ResultWrapper object.

There are however three caveats:

  1. No generic keywords are implemented for such jobs.
  2. Specialized warning message will not be available.
  3. The availability of property-extraction methods is limited.

The therein embedded results can be still extracted by calling the plams.Results methods appropiate to the passed job type, e.g. plams.AMSResults.

For example:

>>> from scm.plams import AMSJob, Molecule, Settings

>>> from qmflows import run, PackageWrapper
>>> from qmflows.packages.package_wrapper import ResultWrapper

>>> mol = Molecule(...)  
>>> settings = Settings(...)  

>>> pkg = PackageWrapper(AMSJob)
>>> job = pkg(settings, mol, name='amsjob')
>>> result: ResultWrapper = run(job)

>>> energy = result.get_energy()  
>>> mol = result.get_molecule()  
>>> freq = result.get_frequencies()  

Index

PackageWrapper(job_type[, name]) A Package subclass for processing arbitrary plams.Job types.
PackageWrapper.__init__(job_type[, name]) Initialize this instance.
PackageWrapper.__call__(settings, mol[, …]) (scheduled) If possible, call __call__() of the Package instance appropiate to PackageWrapper.job_type.
PackageWrapper.run_job(settings, mol[, …]) Run the job and pass the resulting plams.Results object to ResultWrapper.
PackageWrapper.handle_special_keywords(…) Method not implemented.
ResultWrapper(settings, molecule, job_name) The matching Result subclass for PackageWrapper.
JOB_MAP A dict mapping PLAMS Job types to appropiate QMFlows Package instance

API

class qmflows.packages.package_wrapper.PackageWrapper(job_type, name=None)[source]

A Package subclass for processing arbitrary plams.Job types.

Will automatically convert the passed Job type into the appropiate Package instance upon calling PackageWrapper.__call__().

Examples

>>> from scm.plams import ADFJob, AMSJob

>>> from qmflows import PackageWrapper, run
>>> from qmflows.packages.package_wrapper import ResultWrapper
>>> from qmflows.packages.SCM import ADF_Result

# Start of with two PackageWrapper instances
>>> pkg_adf = PackageWrapper(ADFJob)
>>> pkg_ams = PackageWrapper(AMSJob)

# End up with two different Result instances
>>> result_adf: ADF_Result = run(pkg_adf(...), ...)  
>>> result_ams: ResultWrapper = run(pkg_ams(...), ...)  
job_type

The to-be executed plams.Job type. Will be automatically translated, when possible, into to the appropiate Package instance upon calling PackageWrapper.__call__(). If not, default to the more bare-bones implementation within this class and the matching ResultWrapper instance.

Type:type [plams.Job]

See also

JOB_MAP
dict [type [plams.Job], Package]
A
class:dict mapping PLAMS Job types to appropiate QMFlows Package instances.
PackageWrapper.__init__(job_type, name=None)[source]

Initialize this instance.

Parameters:job_type (type [plams.Job]) – The to-be executed plams.Job type. Will be automatically translated, when possible, into to the appropiate Package instance upon calling PackageWrapper.__call__(). If not, default to the more bare-bones implementation within this class and the matching ResultWrapper instance. See also PackageWrapper.job_type.
PackageWrapper.__call__(settings, mol, job_name='', **kwargs)[source]

(scheduled) If possible, call __call__() of the Package instance appropiate to PackageWrapper.job_type.

If not, default to the base Package.__call__() method.

PackageWrapper.run_job(settings, mol, job_name='job', work_dir=None, validate_output=True, **kwargs)[source]

Run the job and pass the resulting plams.Results object to ResultWrapper.

static PackageWrapper.handle_special_keywords(settings, key, value, mol)[source]

Method not implemented.

class qmflows.packages.package_wrapper.ResultWrapper(settings, molecule, job_name, dill_path=None, plams_dir=None, work_dir=None, status='done', warnings=None)[source]

The matching Result subclass for PackageWrapper.

qmflows.packages.package_wrapper.JOB_MAP : dict [type [plams.Job], Package]

A dict mapping PLAMS Job types to appropiate QMFlows Package instance

.

>>> from typing import Dict, Type

>>> from qmflows.packages import Package, cp2k, adf, dftb, orca
>>> from scm import plams

>>> plams.Job = plams.core.basejob.Job
>>> plams.ORCAJob = plams.interfaces.thirdparty.orca.ORCAJob

>>> JOB_MAP: Dict[Type[plams.Job], Package] = {
...     plams.Cp2kJob: cp2k,
...     plams.ADFJob: adf,
...     plams.DFTBJob: dftb,
...     plams.ORCAJob: orca
... }