basisopt.wrappers package

Submodules

basisopt.wrappers.dummy module

class basisopt.wrappers.dummy.DummyWrapper

Bases: Wrapper

A Wrapper that can’t actually be used to do computations. It has two purposes: to be a default Wrapper so that the library can be used even when calculations aren’t needed (e.g. if looking at and analysing previously computed results); and to make testing a lot easier, as we don’t have to have e.g. Psi4 installed. As such this has minimal functionality.

convert_molecule(m: Molecule) int

Dummy molecule converter

dipole(mol, tmp='')

Dipole moment, numpy array, a.u.

energy(mol, tmp='')

Energy, Hartree

initialise(m: Molecule, name: str = '', tmp: str = '')

Initialises calc by converting molecule, setting globals and self._basis_value

polarizability(mol, tmp='')

Dipole polarizability, a.u.

quadrupole(mol, tmp='')

Quadrupole moment, numpy array, a.u.

basisopt.wrappers.orca module

class basisopt.wrappers.orca.OrcaWrapper(orca_path: str)

Bases: Wrapper

Wrapper for Orca 5

Private attribute:

pwd (str): the present working directory

convert_molecule(m: Molecule) str

Convert an internal Molecule object to an Orca geometry section

dipole(mol, tmp='', **params)

Dipole moment, numpy array, a.u.

energy(mol, tmp='', **params)

Energy, Hartree

initialise(m: Molecule, name: str = '', tmp: str = '.', **params) str

Initialises Orca and creates input file for calculation. WARNING: moves to the scratch directory, but saves PWD in

self._pwd

Parameters:
  • m (Molecule) – molecule to run calculation on

  • name (str) – name for calculation

  • tmp (str) – path to scratch directory

Returns:

the prefix for the calculation input/output files

jk_error(mol, tmp='', **params)

JK density fitting error, Hartree

polarizability(mol, tmp='', **params)

Dipole polarizability, a.u.

quadrupole(mol, tmp='', **params)

Quadrupole moment, numpy array, a.u.

basisopt.wrappers.psi4 module

basisopt.wrappers.wrapper module

class basisopt.wrappers.wrapper.Wrapper(name: str = 'Empty')

Bases: object

Abstract class to derive all backend wrappers from; see e.g. Psi4.

All new calculation types must be added to this class and marked as unavailable, this means that the library knows what calculation types are possible agnostic to which wrapper is being used.

You only have to implement the calculation types that you want to expose, and decorate them as being available. These functions should have the signature

func(self, mol, tmp=””) where mol is a Molecule object, and tmp is the path to

the scratch directory.

Attributes that should be set in children:

_name (str): identifier, e.g. ‘Psi4’ _method_strings (dict): dictionary of method names and what calculation types can be done with them, e.g. {‘hf’: [‘energy’, ‘dipole’], ‘mp2’: [‘energy’], …}

Attributes used by children:

_values (dict): dictionary where most recent calculated results are stored _globals (dict): dictionary of parameters that should be set every time a calculation is run, e.g. {‘memory’: ‘2gb’, …}. These should be parsed as part of the ‘run’ function in every Child implementation

Attributes that should only be set here:

_methods (dict): dictionary of all possible calculation types, pointing to member funcs

add_global(name: str, value: Any)

Add a global option

all_available() list[str]

Returns a list of all available calculation types

available_methods(prop: str) list[str]

Returns a list of all available methods to calculate a particular property

prop

name of property, e.g. ‘energy’, ‘dipole’

Type:

str

available_properties(name: str) list[str]

Returns a list of all available calculation types for a given method.

name

method name, e.g. ‘rhf’, ‘mp2’

Type:

str

clean()

Cleans up any temporary files

dipole(mol, tmp='', **params)

Dipole moment, numpy array, a.u.

energy(mol, tmp='', **params)

Energy, Hartree

get_value(name: str) Any

Retrieve a data point if it exists

jk_error(mol, tmp='', **params)

JK density fitting error, Hartree

method_is_available(method: str = 'energy') bool

Returns True if a calculation type is available, false otherwise

polarizability(mol, tmp='', **params)

Dipole polarizability, a.u.

quadrupole(mol, tmp='', **params)

Quadrupole moment, numpy array, a.u.

run(evaluate: str, molecule: Molecule, params: dict[str, Any], tmp: str = '') int

Runs a calculation with this backend MUST BE IMPLEMENTED IN ALL WRAPPERS

Parameters:
  • evaluate (str) – the property to evaluate, e.g. ‘energy’

  • molecule – a Molecule object to run a calculation on

  • params (dict) – any parameters for the calculation in addition to _globals

  • tmp (str) – path to scratch directory

Returns:

0 on success, -1 if method isn’t available, -2 otherwise

trans_dipole(mol, tmp='', **params)

Transition dipole moment, numpy array, a.u.

trans_quadrupole(mol, tmp='', **params)

Transition quadrupole moment, numpy array, a.u.

verify_method_string(string: str) bool

Checks whether a method is available with this wrapper

Parameters:
  • string (str) – a string of the form “name.method”, e.g. “rhf.energy”

  • 'rhf' (will check to see if 'energy' can be calculated with) –

Returns:

True if available, False otherwise

Raises:

InvalidMethodString

basisopt.wrappers.wrapper.available(func: Callable[[object, Molecule, str, ...], Any]) Callable[[object, Molecule, str, ...], Any]

Decorator to mark a method as available

basisopt.wrappers.wrapper.unavailable(func: Callable[[object, Molecule, str, ...], Any]) Callable[[object, Molecule, str, ...], Any]

Decorator to mark a method as unavailable

Module contents