PackageWrapper
A module which adds the PackageWrapper
class.
The herein implemented class serves as a wrapper around the qmflows
Package
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:
No generic keywords are implemented for such jobs.
Specialized warning message will not be available.
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 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
|
A |
|
Initialize this instance. |
|
(scheduled) If possible, call |
|
Run the job and pass the resulting |
Method not implemented. |
|
|
The matching |
Placeholder docstring for sphinx. |
API
- class qmflows.packages.PackageWrapper(job_type, name=None)[source]
A
Package
subclass for processing arbitraryplams.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 import ResultWrapper, 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 appropiatePackage
instance upon callingPackageWrapper.__call__()
. If not, default to the more bare-bones implementation within this class and the matchingResultWrapper
instance.- Type:
See also
JOB_MAP
A dictionary 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 executedplams.Job
type. Will be automatically translated, when possible, into to the appropiatePackage
instance upon callingPackageWrapper.__call__()
. If not, default to the more bare-bones implementation within this class and the matchingResultWrapper
instance. See alsoPackageWrapper.job_type
.
- PackageWrapper.__call__(settings, mol, job_name='', **kwargs)[source]
(scheduled) If possible, call
__call__()
of the Package instance appropiate toPackageWrapper.job_type
.If not, default to the base
__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 toResultWrapper
.
- static PackageWrapper.handle_special_keywords(settings, key, value, mol)[source]
Method not implemented.
- class qmflows.packages.ResultWrapper(settings, molecule, job_name, dill_path=None, plams_dir=None, work_dir=None, status='successful', warnings=None)[source]
The matching
Result
subclass forPackageWrapper
.
- qmflows.packages.JOB_MAP : dict[type[plams.Job], Package]
A dictionary mapping PLAMS
Job
types to appropiate QMFlowsPackage
instance.>>> from __future__ import annotations >>> 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 ... }