pymolpro package

Module contents

class pymolpro.ASEMolpro(name='ASEMolpro', method='hf', basis='cc-pVDZ', project_location=None, **kwargs)

Bases: BaseCalculator

ASE calculator interface to Molpro. Implemented using pysjef and pymolpro, which use project bundles to contain input, output and other files, as described at https://github.com/molpro/sjef and https://github.com/molpro/pymolpro.

__init__(name='ASEMolpro', method='hf', basis='cc-pVDZ', project_location=None, **kwargs)
Parameters:
  • name (str) – The file name for the Molpro project

  • method (str) – Molpro input fragment that specifies the method

  • basis (str) – Basis set specification in the form of arguments to Molpro basis directive

  • project_location (str) – Directory where the project bundle will be placed. Defaults to a unique temporary directory

  • kwargs (dict) – Any additional arguments to pass through to pymolpro.Project()

calculate(atoms, properties, system_changes)
clean()

Remove all Molpro projects from file system

implemented_properties: List[str] = ['energy', 'forces']

Properties calculator can handle (energy, forces, …)

class pymolpro.Database(molecules: dict[str, str] = {}, reactions: dict[str, dict[str, int]] = {}, description: str = None, project_directory: str = None)

Bases: object

Database of molecular structures and reactions. The class contains and supports the following data.

  • Descriptions of molecules: geometry, charge, spin state.

  • Descriptions of reactions between the molecules: stochiometric factors.

  • Optionally, computed data: energies of molecules and/or reactions,s the parameters used to obtain them, and references to persistent data that can be used to further query or restart.

  • Description and external URLs that serve to further define the provenance of the data.

  • Specification of recommended subsets of the reactions

__init__(molecules: dict[str, str] = {}, reactions: dict[str, dict[str, int]] = {}, description: str = None, project_directory: str = None)
Parameters:
  • molecules – Initial molecules to be added with default options to add_molecule().

  • reactions – Initial reactions to be added with default options to add_reaction().

  • description – Text describing the database

  • project_directory – The path of the directory where support files that were generated in calculating energies can be found.

add_molecule(name, geometry, energy=None, description=None, InChI=None, SMILES=None, spin=None, charge=None, preamble=None)

Add a molecule to the database. The minimal information that is stored is the geometry, but information from each of the optional arguments, if given, is also stored in the molecules dictionary.

Parameters:
  • name (str) – The key for the molecule in molecules.

  • geometry (str) – The geometry. Any format recognised by Molpro can be used. This includes xyz, with or without the two header lines, or Z matrix, and lines can be separated either with newline or ;. The geometry can be specified either as a string, or a filename or url reference, in which case the contents of the reference are resolved now.

  • energy (float) – The reference value for the energy of the molecule in Hartree units

  • description (str) – Descriptive text

  • InChI (str) – InChI string describing the molecule

  • SMILES (str) – SMILES string describing the molecule

  • spin (int) – The spin multiplicity minus one

  • charge (int) – Electrical charge of molecule

  • preamble (str) – Additional Molpro input to be added before geometry

Returns:

The added molecule

Return type:

dict

add_reaction(name, stoichiometry, energy=None, description=None)

Add a reaction to the database. The minimal information that is stored is the stoichiometry, which references existing molecules in the database, but information from each of the optional arguments, if given, is also stored in the reactions dictionary.

Parameters:
  • name – The key for the reaction in reactions.

  • stoichiometry – A dictionary describing the stoichiometry of the reaction. Each key should be a key in molecules, and the value is an integer giving the number of equivalents of the molecule in the reaction, with the sign convention of positive for products, negative for reactants.

  • energy – The reference value for the energy change of the reaction in Hartree units. If not given, and if all molecules in the reaction have an energy, it will be computed.

  • description – Descriptive text

Returns:

The added reaction

Return type:

dict

add_reference(key, url)
add_subset(subset_name, subset)
basis

A string specifying the orbital basis-set used to compute the energies.

calculate_reaction_energies(check=False)
copy()
description

Text describing the database

dump(filename=None)

Dump the database in json format.

Parameters:

filename (str) – If specified, the destination of the result

Returns:

If filename is not specified, the json is returned as a string

Return type:

str

failed

Subset of projects corresponding to jobs that did not complete successfully.

input_specification

A string containing JSON describing the Molpro input used to construct the energies

load(source)

Load the database from a json dump in either the library, a file or a string

Parameters:

source (str) – Source of dump

Returns:

The database

Return type:

Database

method

A string specifying the ansatz used to compute the energies.

molecule_energies

A dictionary with molecule keys giving the molecular energy/Hartree reference values associated with the Database. The dictionary could be empty or only partly filled.

molecules

Dictionary of molecules

preamble

any Molpro commands that should be executed before geometry specification. Typically angstrom could be specified if the geometry specification is in Z-matrix format with numerical values that would, by default, be interpreted as Bohr.

project_directory

A string giving the path of the directory where support files generated in calculating energies can be found.

projects

A dictionary with molecule handles pointing to filesystem project bundles for each Molpro job that has been run.

reaction_energies

A dictionary with reaction keys giving the reaction energy/Hartree reference values associated with the Database. The dictionary could be empty or only partly filled. A database might have either, both or none of molecule_energies or reaction_energies.

reactions

Dictionary of reactions involving the molecules together with stoichiometric factors

references

A dictionary of external references to the data. The keys should be a short-form string that you want printed, eg author, year, and the values URLs that lead to the resource.

subset(subset=None, open_shell=True, max_atoms=None, max_electrons=None)

Extract a subset of this database as a new database

Parameters:
  • subset – Either a key in the subsets or a list of keys in reactions. If not given, all the reactions in the database

  • open_shell – Whether to include reactions involving open-shell molecules, or prune to closed-shell only

  • max_atoms – Exclude reactions with one or more molecules with more than this number of atoms

  • max_electrons – Exclude reactions with one or more molecules with more than this number of electrons

Returns:

The subset

Return type:

Database

subsets

A dictionary defining named subsets of the database reactions

class pymolpro.Orbital(node, directory=None)

Bases: object

Container for an orbital (usually molecular).

property ID
__init__(node, directory=None)

Initialise from a node on a Molpro output xml tree

Parameters:
  • node – lxml.etree.Element holding a single orbital

  • directory – the directory in which the xml file, and its sidecar, live

attribute(key)
property axes

The coordinate system for the orbital. The \(z\) axis is the normalised vector \(\vec e_{z}\) that is the eigenvector of the second-moment tensor of largest eigenvalue, similarly for \(\vec e_y, \vec e_x\). The phase of each axis is chosen such that the largest of the coefficients specifying the axis in the global coordinate system is positive.

Returns:

The axes, with the first index labelling the component in the base coordinate system, and the second index specifying which orbital axis.

Return type:

np.array(3,3)

centroid

Centroid of the orbital

energy

energy of the orbital

evaluate(points, values=False)

Evaluate orbital on a grid of points

Parameters:
  • points – List of geometries specified as 3-list of values in bohr

  • values

Returns:

array of dictionaries giving the occupation and values on the grid, or if ID is specified, a single dictionary, or if values==True, a numpy array

grid(npt, method='erfinv', scale=1.0, grid_parameters=[], spherical_average=False)

Generate a grid centred on the orbital.

Parameters:
  • npt – Number of desired points in each coordinate.

  • method – Algorithm for grid generation.

  • scale – Scale the grid by this factor.

Returns:

points and weights (numpy array [npt,4])

property kinetic_energy

Kinetic energy expectation value for the orbital.

property local_second_moments
occupation

Occupation of the orbital

second_moment_eigenvalues

Eigenvalues of the orbital second-moment tensor (origin at centre of charge) in ascending order

class pymolpro.Pair(node)

Bases: Tuple

Container for a pair of orbitals

property axes

The coordinate system for the pair of orbitals. The \(z\) axis is the vector \(\vec e_{z,10}=(\vec r_1-\vec r_0)/|\vec r_1-\vec r_0|\) from orbital 0 to orbital 1. The \(x\) axis is the along the vector \(\vec e_{x,10} = \vec e_{z,10} \times \vec e_z\) (or \(\vec e_y\) if necessary), normalised. Then \(\vec e_{y,10}=\vec e_{z,10}\times\vec e_{x,10}\). If \(|\vec r_1-\vec r_0|\) is small, the global coordinate axes are adopted.

Returns:

The axes, with the first index labelling the component in the base coordinate system, and the second index specifying which pair axis.

Return type:

np.array(3,3)

property local_orbital_axes

The coordinate axes of the orbitals expressed in the basis of the pair coordinate system.

Returns:

Return type:

list(np.array(3,3))

class pymolpro.Project(name: str = None, input: str | dict | None = None, specification: str | dict | None = None, ansatz: str | None = None, files: list[str] | None = None, **kwargs)

Bases: Project

A Project holds all the data associated with a single Molpro job. This includes input, output, any auxiliary files, and information about the state of the job. Project acts as a reference to a sjef Project with some added functionality. All of the data is stored in the project bundle on the file system, with the consequence that it is safe to construct and recreate multiple Project objects all mapping the same underlying project.

The underlying functionality of sjef includes job submission and monitoring on local or remote machines, and structured searching of Molpro’s xml output stream. This class provides additional convenience operations:

  • Preparation of simple Molpro input from provided geometry, method, basis set and other options.

  • Molpro-specific error checking.

  • Computed properties, energies and geometries.

  • Computed orbitals, including their evaluation on a grid.

  • Values of Molpro variables.

__init__(name: str = None, input: str | dict | None = None, specification: str | dict | None = None, ansatz: str | None = None, files: list[str] | None = None, **kwargs)
Parameters:
  • name – The base filename of the filesystem bundle carrying the project. If the bundle does not yet exist, it is created.

  • input – General specification of the input. If it looks like JSON or is a dictionary, it is treated as if it had been passed as the specification parameter. If it has the form method/basis or method/basis//geometry_method/geometry_basis, it is treated as if it had been passed as the ansatz parameter. Otherwise, it is treated as the desired contents of the Molpro input file. If input is specified, all other arguments are ignored.

  • specification – Either a dictionary or a JSON string conforming to the JSON schema https://www.molpro.net/schema/molpro_input.json

  • ansatz – A string of the form method/basis//geometry_method/geometry_basis or method/basis which is parsed to give the same effect as the method and basis parameters. If geometry_method/geometry_basis is specified, the calculation will be preceded by a geometry optimisation at that level of theory.

  • files – External files to be copied into the project directory. If one of these is a molpro-output xml file, it is used to construct the input file.

  • kwargs – Any of the top-level keywords in the JSON schema https://www.molpro.net/schema/molpro_input.json, or any of the arguments accepted by the parent sjef.Project class constructor.

property ansatz
basis_registry()

Get the basis registry from the Molpro pointed to in the local backend

Returns:

Return type:

dict

builtins = <module 'builtins' (built-in)>
commandify_method(method)
energies(*args, **kwargs)

Wrapper for properties() that restricts to energy values

Parameters:
  • args

  • kwargs

Returns:

energy(*args, **kwargs)

Wrapper for energies() that returns a single value as a scalar. An exception is thrown if more than one value is found.

Parameters:
  • args

  • kwargs

Returns:

errors(ignore_warning=True)

Return all error nodes

Returns:

list of error nodes

Return type:

lxml.etree

evaluateOrbitals(points, instance=-1, minocc=1e-10, ID=None, values=False)

Evaluate molecular orbitals on a grid of points

Parameters:
  • points – List of geometries specified as 3-list of values in bohr, or numpy [:,3] array

  • instance – Which set of orbitals

  • minocc – Only orbitals with at least this occupation will be returned

  • ID – Only the orbital whose ID attribute matches this will be selected

  • values

Returns:

array of dictionaries giving the occupation and values on the grid, or if ID is specified, a single dictionary, or if values==True, a numpy array

geometries(preamble='//', parent_node=None)

Obtain all geometries from the job output

Parameters:

preamble – Prepend this to the xpath search expression to locate the geometry

Returns:

list of dictionaries holding the geometry. Coordinates are in bohr

geometry(preamble='//', instance=-1)

Obtain the geometry from the job output

Parameters:
  • preamble – Prepend this to the xpath search expression to locate the geometry

  • instance – In the case of multiple geometries in the output stream, which occurence

Returns:

dictionary holding the geometry. Coordinates are in bohr

gradient(instance=-1)
input(input: str | dict = None, specification: str | dict = None, ansatz: str = None, **kwargs)

Defines the input for running Molpro.

:param input:General specification of the input. If it looks like JSON or is a dictionary, it is treated as if it had been passed as the specification parameter. If it has the form method/basis or method/basis//geometry_method/geometry_basis, it is treated as if it had been passed as the ansatz parameter. Otherwise, it is treated as the desired contents of the Molpro input file. If input is specified, all other arguments are ignored. :param specification: Either a dictionary or a JSON string conforming to the JSON schema https://www.molpro.net/schema/molpro_input.json :param ansatz: A string of the form method/basis//geometry_method/geometry_basis or method/basis which is parsed to give the same effect as the method and basis parameters. If geometry_method/geometry_basis is specified, the calculation will be preceded by a geometry optimisation at that level of theory. :param kwargs: Any of the top-level keywords in the JSON schema https://www.molpro.net/schema/molpro_input.json

input_from_output(instance=-1)

Return a list of all defined input in the output stream

Parameters:

instance – index of occurence of input node in output

Returns:

property local_molpro_root

Get the directory of the Molpro installation in the local backend

Returns:

directory

Return type:

pathlib.Path

molecule(instance=-1)

Obtain a molecule in the job output

Parameters:

instance – Which molecule object to get

Returns:

a dictionary containing all the information available

orbitals(instance=-1, minocc=1.0, ID=None, orbital_instance=-1)

Obtain some or all of the orbitals in the job output

Parameters:
  • instance – Which molecule object to get orbitals for

  • minocc – Only orbitals with at least this occupation will be returned

  • ID – Only the orbital whose ID attribute matches this will be selected

  • orbital_instance – Which set of orbitals

Returns:

a list of Orbital objects

orbitals_old(instance=-1, minocc=1.0, ID=None, orbital_instance=-1)

Obtain some or all of the orbitals in the job output

Parameters:
  • instance – Which molecule object to get orbitals for

  • minocc – Only orbitals with at least this occupation will be returned

  • ID – Only the orbital whose ID attribute matches this will be selected

  • orbital_instance – Which set of orbitals

Returns:

a list of Orbital objects

orbitals_to_molden(filename=None, instance=-1, minocc=1.0, ID=None)
orbitals_to_trexio(filename=None, instance=-1, overwrite=True)

Create a TrexIO dump containing the geometry and orbitals.

Parameters:
  • filename (str) – Name of the Trexio file to be placed in the run directory

  • instance (int) – Which instance of the molecule node in the xml file

  • overwrite (bool) – Overwrite existing TrexIO file

Returns:

file, label

Return type:

str, str

pairs(instance=-1)

Obtain some or all of the correlation pairs in the job output

Parameters:

instance – Which set of pairs

Returns:

a list of Pair objects

parse_ansatz(ansatz)
procedures_registry()

Get the procedures registry from the Molpro pointed to in the local backend

Returns:

Return type:

dict

properties(*args, **kwargs)

Obtain selected properties from the job output

Parameters:
  • args – any trailing XPath qualifier, for example '[@StateSymmetry = "1" or @StateSymmetry = "4"]'. For restrictions that should be combined with and, it’s simpler to instead use a kwarg argument, eg StateSymmetry=1

  • kwargs – any attribute selectors for the select function, including the following

  • name – name of property

  • principal – restrict to principal property

  • preamble – XPath expression to prepend the search for the property node

  • command – restrict to properties contained in a jobstep with this command

  • dict – return property value, scalar float or list of floats as appropriate, if False or omitted. Otherwise, a dictionary containing all the data in the property node is returned

Returns:

list of properties

properties_old(name='Energy', principal=True, *, value=False, **kwargs)

Obtain selected properties from the job output

Parameters:
  • name – name of property

  • principal – principal property

  • value – return by value

  • kwargs – any other attribute selectors for the select function

Returns:

list of properties

Shorthand for p.select(‘//properties[name= {}, principal ={}, … ]’)

property(*args, **kwargs)

Wrapper for properties() that returns a single value as a scalar. An exception is thrown if more than one value is found.

Parameters:
  • args

  • kwargs

Returns:

registry(set=None)

Access the registry belonging to Molpro in the local backend.

Parameters:

set – If present, obtain as a dictionary the specified registry set. If absent, obtain a list of all sets

Returns:

run_local_molpro(options: list)
singles(instance=-1)

Obtain some or all of the correlation singles in the job output

Parameters:

instance – Which set of singles

Returns:

a list of Single objects

variable(name, instance=-1, list=False, dict=False)

Return the value of a variable in the output xml stream

Parameters:
  • name – The name of the variable

  • instance – index of occurence in output

  • list – Whether to force returning a list. If true, a list is always returned; otherwise if the result is a scalar, a scalar is returned, and if no match is found, None is returned

  • dict – return property value, scalar float or list of floats as appropriate, if False or omitted. Otherwise, a dictionary containing all the data in the property node is returned

Returns:

variables(instance=-1)

Return a list of all defined variables

Parameters:

instance – index of occurence of variables node in output

Returns:

property vibrations

Give information on normal vibrational modes

Parameters:

instance (int)

Returns:

Mass-weighted normal coordinates, vibrational wavenumbers, atomic masses, force constant matrix

Return type:

dict

xyz(preamble='//', instance=-1, title='')

Obtain a geometry in xyz file format

Parameters:
  • instance – In the case of multiple geometries in the output stream, which occurence

  • preamble – Prepend this to the xpath search expression to locate the geometry

  • title – A title to be injected into the second line

Returns:

A string containing the xyz representation of the geometry

xyzs(preamble='//', title='')

Obtain a set of geometries in xyz file format

Parameters:
  • preamble – Prepend this to the xpath search expression to locate the geometry

  • title – A title to be injected into the second line

Returns:

A list of strings containing the xyz representation of the geometry

class pymolpro.Single(node)

Bases: Tuple

Container for a single orbital

class pymolpro.Tuple(node)

Bases: object

Container for a tuple of orbitals

Parameters:

node (lxml.etree.Element) – Node holding a correlation single or pair descriptor

__init__(node)

Initialise from a node on a Molpro output xml tree

energy

Correlation energy contribution from a Single or Pair

orbitals

Orbital objects forming the tuple

spins

1(alpha) or -1(beta) for each orbital

pymolpro.element_to_dict(node, attributes=True)

Convert an lxml.etree node tree into a dict.

Parameters:
  • node (lxml.etree.ElementTree) – A node in an lxml tree

  • attributes (bool, optional) – whether to include attributes in the result

Returns:

A dictionary representing the tree

Return type:

dict

pymolpro.no_errors(projects, ignore_warning=True)

Checks that none of the projects have any errors. Projects can by running.

Parameters:
  • projects – list of projects to check for errors

  • ignore_warning – Whether to count warnings as well as errors.

Returns:

True/False whether any projects have errors

pymolpro.xyz_to_zmat(xyz: str, algorithm='chemcoord')

Converts from xyz to z-matrix coordinates.

Parameters:
  • xyz – xyz-file

  • algorithm – algorithm to choose, default is the chemcoord algorithm

Returns:

The Z matrix as a string, or None in case of unknown algorithm,

Return type:

str

Submodules

pymolpro.molpro_input module

class pymolpro.molpro_input.InputSpecification(input: str = None, allowed_methods: list[str] = [], debug: bool = False, specification: dict = None, directory: str = None)

Bases: UserDict

A declarative specification of a Molpro input. Almost any simple input - no loops or logic - that requests a single quantum-mechanical method, possibly with geometry optimisation using a different method, can be represented. The class can be instantiated from a procedural Molpro input, or from a JSON string or dictionary. If both an input and a specification are provided, the specification is ignored.

The class is a dictionary with some extra methods, with all the data contained in the dictionary, which is constrained to conform with the molpro_input JSON schema, https://www.molpro.net/schema/molpro_input.json .

__init__(input: str = None, allowed_methods: list[str] = [], debug: bool = False, specification: dict = None, directory: str = None)
Parameters:
  • input – Either a text string or a file name containing Molpro procedural input.

  • allowed_methods – A list of allowed methods to be appended to the defaults.

  • specification – Initial data to be included in the specification.

  • directory – The directory where any auxiliary files are located. If not specified, the current working directory will be used.

property ansatz: str

A string of the form method/basis, or method/basis//geometry_method/geometry_basis summarising the ansatz where possible, otherwise an empty string.

property basis_hamiltonian: str

The hamiltonian for which the orbital basis set is designed

property basis_quality: int

The cardinal number of the basis set used in the job. If not a correlation-consistent basis set, returns 0.

clear() None.  Remove all items from D.
copy()
classmethod default_instance() InputSpecification

Factory method for creating a default instance generated from the schema.

property density_functional: str

For a Kohn-Sham calculation, the name of the density functional used

classmethod fromkeys(iterable, value=None)
get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
property job_steps: list[JobStep]

Returns the job steps in this input

keys() a set-like object providing a view on D's keys
property method: str

The single method implemented by the job, represented as the Molpro input command name that implements it.

property method_options: str

The options for a single-method job

molpro_input() str

Create the procedural Molpro input from the declarative specification

property open_shell_electrons: int

The number of open-shell electrons in the molecule’s normal state. This will typically be 0 or 1, but for some special cases (eg atoms) might be higher.

parse(input: str, debug=False) InputSpecification

Take a procedural molpro input, and logically parse it. If it is impossible to do so, an empty specification is returned.

Parameters:

input – Either text that is the input, or a file name containing it.

polish()

Ensure that the job specification is valid and complete

pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

set_job_step(job_step: JobStep, index: int)
set_job_type(new_job_type)
setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

validate()

Validate the specification according to the schema.

values() an object providing a view on D's values
property with_defaults: InputSpecification

A copy of this specification with all defaults filled in from the schema.

property without_defaults: InputSpecification

A copy of this specification with any values equal to the schema default removed.

class pymolpro.molpro_input.JobStep(card: 'str')

Bases: object

__init__(card: str)
command: str
directives: list
dump(braces=True)
load(card: str)
options: list
pymolpro.molpro_input.canonicalise(input)
pymolpro.molpro_input.equivalent(input1, input2, debug=False)
pymolpro.molpro_input.hamiltonians() dict[str, dict[str, str]]

Returns a dictionary containing the supported hamiltonians.

pymolpro.molpro_input.job_types() dict

Return the supported job types.

pymolpro.molpro_input.local_orbital_types() dict[str, dict[str, str]]

Return a dictionary containing the supported local orbital types.

pymolpro.molpro_input.orientation_options()
pymolpro.molpro_input.procedures_registry() dict

Returns a dictionary with procedure names as keys and procedures as values.

pymolpro.molpro_input.supported_methods()

Returns a list of supported methods.

pymolpro.molpro_input.symmetry_commands()

pymolpro.database module

class pymolpro.database.Database(molecules: dict[str, str] = {}, reactions: dict[str, dict[str, int]] = {}, description: str = None, project_directory: str = None)

Bases: object

Database of molecular structures and reactions. The class contains and supports the following data.

  • Descriptions of molecules: geometry, charge, spin state.

  • Descriptions of reactions between the molecules: stochiometric factors.

  • Optionally, computed data: energies of molecules and/or reactions,s the parameters used to obtain them, and references to persistent data that can be used to further query or restart.

  • Description and external URLs that serve to further define the provenance of the data.

  • Specification of recommended subsets of the reactions

__init__(molecules: dict[str, str] = {}, reactions: dict[str, dict[str, int]] = {}, description: str = None, project_directory: str = None)
Parameters:
  • molecules – Initial molecules to be added with default options to add_molecule().

  • reactions – Initial reactions to be added with default options to add_reaction().

  • description – Text describing the database

  • project_directory – The path of the directory where support files that were generated in calculating energies can be found.

add_molecule(name, geometry, energy=None, description=None, InChI=None, SMILES=None, spin=None, charge=None, preamble=None)

Add a molecule to the database. The minimal information that is stored is the geometry, but information from each of the optional arguments, if given, is also stored in the molecules dictionary.

Parameters:
  • name (str) – The key for the molecule in molecules.

  • geometry (str) – The geometry. Any format recognised by Molpro can be used. This includes xyz, with or without the two header lines, or Z matrix, and lines can be separated either with newline or ;. The geometry can be specified either as a string, or a filename or url reference, in which case the contents of the reference are resolved now.

  • energy (float) – The reference value for the energy of the molecule in Hartree units

  • description (str) – Descriptive text

  • InChI (str) –

    InChI string describing the molecule

  • SMILES (str) –

    SMILES string describing the molecule

  • spin (int) – The spin multiplicity minus one

  • charge (int) – Electrical charge of molecule

  • preamble (str) – Additional Molpro input to be added before geometry

Returns:

The added molecule

Return type:

dict

add_reaction(name, stoichiometry, energy=None, description=None)

Add a reaction to the database. The minimal information that is stored is the stoichiometry, which references existing molecules in the database, but information from each of the optional arguments, if given, is also stored in the reactions dictionary.

Parameters:
  • name – The key for the reaction in reactions.

  • stoichiometry – A dictionary describing the stoichiometry of the reaction. Each key should be a key in molecules, and the value is an integer giving the number of equivalents of the molecule in the reaction, with the sign convention of positive for products, negative for reactants.

  • energy – The reference value for the energy change of the reaction in Hartree units. If not given, and if all molecules in the reaction have an energy, it will be computed.

  • description – Descriptive text

Returns:

The added reaction

Return type:

dict

add_reference(key, url)
add_subset(subset_name, subset)
basis

A string specifying the orbital basis-set used to compute the energies.

calculate_reaction_energies(check=False)
copy()
description

Text describing the database

dump(filename=None)

Dump the database in json format.

Parameters:

filename (str) – If specified, the destination of the result

Returns:

If filename is not specified, the json is returned as a string

Return type:

str

failed

Subset of projects corresponding to jobs that did not complete successfully.

input_specification

A string containing JSON describing the Molpro input used to construct the energies

load(source)

Load the database from a json dump in either the library, a file or a string

Parameters:

source (str) – Source of dump

Returns:

The database

Return type:

Database

method

A string specifying the ansatz used to compute the energies.

molecule_energies

A dictionary with molecule keys giving the molecular energy/Hartree reference values associated with the Database. The dictionary could be empty or only partly filled.

molecules

Dictionary of molecules

preamble

any Molpro commands that should be executed before geometry specification. Typically angstrom could be specified if the geometry specification is in Z-matrix format with numerical values that would, by default, be interpreted as Bohr.

project_directory

A string giving the path of the directory where support files generated in calculating energies can be found.

projects

A dictionary with molecule handles pointing to filesystem project bundles for each Molpro job that has been run.

reaction_energies

A dictionary with reaction keys giving the reaction energy/Hartree reference values associated with the Database. The dictionary could be empty or only partly filled. A database might have either, both or none of molecule_energies or reaction_energies.

reactions

Dictionary of reactions involving the molecules together with stoichiometric factors

references

A dictionary of external references to the data. The keys should be a short-form string that you want printed, eg author, year, and the values URLs that lead to the resource.

subset(subset=None, open_shell=True, max_atoms=None, max_electrons=None)

Extract a subset of this database as a new database

Parameters:
  • subset – Either a key in the subsets or a list of keys in reactions. If not given, all the reactions in the database

  • open_shell – Whether to include reactions involving open-shell molecules, or prune to closed-shell only

  • max_atoms – Exclude reactions with one or more molecules with more than this number of atoms

  • max_electrons – Exclude reactions with one or more molecules with more than this number of electrons

Returns:

The subset

Return type:

Database

subsets

A dictionary defining named subsets of the database reactions

pymolpro.database.analyse(databases, reference_database=None, unit=None, **kwargs)

Analyse and format the results in one or more databases

Parameters:
  • databases (list(Database)|Database)

  • reference_database (Database)

  • unit – Either a string or a float specifying desired units for the output. In the case of a string, it should match (case insensitive) one of the keys of units; if an explicit value is given, it should be the value of the desired units in atomic units, ie the results will be divided by the value.

Returns:

A dictionary with keys, where possible,

  • molecule energies

  • molecule energy deviations

  • molecule statistics

  • molecule violin

  • reaction energies

  • reaction energy deviations

  • reaction statistics

  • reaction violin

The energy deviations are, for each molecule or reaction, the difference between the energies in each element of databases and the value in reference_database. The values are pandas Dataframe objects, whose columns correspond to the elements of databases. In the case of the molecule or reaction energies or energy deviations, the rows correspond to the individual molecule or reaction. In the case of statistics, the rows are

  • MSD: the mean of the deviations

  • STDEVD: the standard deviation of the deviations

  • MAD: the mean of the absolute value of the deviations

  • MAXD: the maximum absolute value of the deviations

  • RMSD: the root mean square deviation

Return type:

dict

pymolpro.database.basis_extrapolate(results, hf_results, x=None)
pymolpro.database.load(source)

Construct a Database from a json dump in either the library, a file or a string

Parameters:

source (str) – Source of dump

Returns:

The database

Return type:

Database

pymolpro.database.run(db, ansatz=None, specification=None, location='.', parallel=None, backend='local', clean=False, check=False, check_energy=True, **kwargs)

Construct and run a Molpro job for each molecule in a Database, and compute reaction energies.

Parameters:
  • db (Database) – The database that defines molecules and reactions.

  • method (str) – The computational method for constructed input. Anything accepted as Molpro input, including parameters and directives, can be given. If the method needs a preceding Hartree-Fock calculation, this is prepended automatically.

  • basis (str) – The orbital basis set for constructed input. Anything that can appear after basis= in Molpro input is accepted.

  • ansatz (str) – String of the form method/basis//geometry_method/geometry_basis or method/basis which is parsed to give the same effect as the method and basis parameters. If geometry_method/geometry_basis is specified, the calculation will be preceded by a geometry optimisation at that level of theory.

  • specification – A JSON string, or a dict, giving the method used to compute the energies in the database, conforming to the JSON schema https://www.molpro.net/schema/molpro_input.json.

  • func (str) –

    This should be one of

    • energy for a single geometry

    • opt for a geometry optimisation

  • extrapolate (str) – If specified, carry out basis-set extrapolation. Anything that can appear after extrapolate,basis= in Molpro input is accepted.

  • location (str) – The filesystem directory in which projects will be constructed.

  • parallel (int) – The number of simultaneous jobs to be launched. The default is the number of cores on the local machine.

  • backend (str) – The sjef backend to be used for running jobs.

  • clean (bool) – Whether to destroy the project bundles on successful completion. This should not normally be done, since later invocations of run() will use cached results when possible. If there are errors, this parameter is ignored.

  • check (bool) – Whether to check for status of jobs instead of running them.

  • check_energy (bool) – Whether to throw an exception if any job did not set the Molpro ENERGY variable

  • kwargs – Any other options to pass to project.Project(), including any top-level keywords from the JSON schema https://www.molpro.net/schema/molpro_input.json.

Returns:

A new database which is a copy of db but with the new results overwriting any old ones

Return type:

Database

pymolpro.database.units = <pymolpro.database.Units object>

dictionary of units, giving their values in atomic units

pymolpro.grid module

pymolpro.grid.cubical_grid(points1d, weights1d)

Take a one-dimensional grid, and construct a 3-dimensional outer-product cubical grid

Parameters:
  • points1d

  • weights1d

Returns:

points and weights (numpy array [npt,4])

pymolpro.grid.evaluateBasis(molecule, points)

Evaluate the orbital basis set on a grid

Parameters:
  • molecule – lxml.etree.Element holding the molecule

  • points – numpy :,3 array

Returns:

numpy :,: array, first index basis function, second index brid point

pymolpro.grid.evaluateOrbitals(molecule, points, minocc=1e-10, ID=None, values=False, directory=None)

Evaluate the molecular orbitals on a grid

Parameters:
  • molecule – lxml.etree.Element holding the molecule

  • points – numpy :,3 array

  • minocc – Only orbitals with at least this occupation will be returned

  • ID – Only the orbital whose ID attribute matches this will be selected

  • values

Returns:

array of dictionaries giving the occupation and values on the grid, or if ID is specified, a single dictionary, or if values==True, a numpy array

pymolpro.grid.spherical_grid(radial_points, radial_weights, l: int)

Take a one-dimensional grid, and use it for radial integration, together with a Lebedev grid of specified order, to generate a 3-dimensional grid (cartesian coordinates, weights) for quadrature.

Parameters:
  • radial_points

  • radial_weights

  • l – Largest rank of spherical harmonic for which exact quadrature is wanted.

Returns:

points and weights (numpy array [npt,4])

pymolpro.node_xml module

class pymolpro.node_xml.AxesXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:axes Children: [list of doubles]

class pymolpro.node_xml.BasisSetXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:basisSet - Container for a basis set Children: basisGroup, association Attributes: str id, str type, str angular, int groups, str primitives, int length, int cartesianLength

class pymolpro.node_xml.CmlAtomXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

cml:atom - Output about a single atom

class pymolpro.node_xml.CmlMoleculeXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

cml:molecule - Output about a single molecule Children: cml:atomarry, cml:symmetry

class pymolpro.node_xml.CubeXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:cube - Metadata for a cube dataset Children: field, dimensions, origin, axes, step Attributes: str method

class pymolpro.node_xml.DateXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:date - The time of the calculation. Children: [string datetime] Attributes: int year, int month, int day, int hour, int minute, int second

class pymolpro.node_xml.DiagnosticsXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:diagnostics - Diagnostic info from the job Attributes: int warnings

class pymolpro.node_xml.DimensionsXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:dimensions Children: [list of doubles]

class pymolpro.node_xml.FieldXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:field Attributes: str quantity, str type, str number, str symmetry, double occupancy, double energy, str file

class pymolpro.node_xml.InputXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:input - Molpro input dataset Children: p, include

class pymolpro.node_xml.JobstepXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:jobstep - Output from a single job step Children: error, gradient, opt, property, cube, time, storage, vibrations, jobstep, cml:molecule, variables, instanton Attributes: str command, str commandset, bool displaced

class pymolpro.node_xml.LicenceXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:licence Attributes: str id

class pymolpro.node_xml.MachineXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:machine Attributes: str hostname

class pymolpro.node_xml.MoleculeXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:molecule - Summary output about the job Children: cml:molecule, basisSet, vibrations, orbitals, stm:metadataList, platform Attributes: str id, str index, str InChI, str InChIKey, str SMILES, str title, str method, str basis, str geometryMethod, str geometryBasis, double energy

class pymolpro.node_xml.NormalCoordinateXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:normalCoordinate - A normal vibrational coordinate Children: [list of doubles] Attributes: double wavenumber, str units, double IRintensity, str IRintensityunits, str symmetry, str real_zero_imag

class pymolpro.node_xml.OrbitalXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:orbital - A Molpro molecular orbital Children: [string] Attributes: str symmetryID, double energy, double occupation

class pymolpro.node_xml.OrbitalsXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:orbitals - Container for Molpro internal orbitals Children: orbital Attributes: str basis, str angular, str spin, str method

class pymolpro.node_xml.OriginXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:origin Children: [list of doubles]

class pymolpro.node_xml.ParallelXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:parallel Attributes: int processes, int nodes, int all_processes, int openmp

class pymolpro.node_xml.PlatformXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:platform - Container for metadata about the platform Children: version, licence, parallel, machine, dimensions

class pymolpro.node_xml.PlotXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:plot - Metadata for plot from a Molpro table Attributes: str table, str plot, str type Also attributes from http://www.w3.org/1999/xlink

class pymolpro.node_xml.PropertyXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:property - Output about a single property of a single molecule Attributes: str name, any value

class pymolpro.node_xml.StepXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:step Children: [list of doubles]

class pymolpro.node_xml.VariableXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

TODO Doc

class pymolpro.node_xml.VariablesXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:variables - Container for Molpro internal variables Children: variable

class pymolpro.node_xml.VersionXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:version Children: [string], date Attributes: int major, int minor, str SHA, int integer_bits, str parallelism

class pymolpro.node_xml.VibrationsXml(filename=None, xml=None, parent=None, suffix=None, **options)

Bases: RootXml

molpro-output:vibrations - Container for info on molecular vibrations Children: normalCoordinate Attributes: str name, str type, str units, int length

pymolpro.node_xml.tag_to_name(tag)

Takes XML tag with namespace, outputs raw node name.