pyscf_step package#

Subpackages#

Submodules#

pyscf_step.basis module#

Basis sets and ECPs from the Basis Set Exchange, in PySCF’s internal format.

This runs in the SEAMM environment (which has basis_set_exchange) and needs no PySCF: the task’s input then carries the basis and the ECP, with its spin-orbit part, so the PySCF side reads no library. The spin-orbit terms are rebuilt and checked by pyscf_step.engine.ecp_so.

exception pyscf_step.basis.BasisError[source]#

Bases: Exception

pyscf_step.basis.P_SHELL = {'Al': 1, 'At': 5, 'B': 1, 'Br': 5, 'Cl': 5, 'F': 5, 'Ga': 1, 'I': 5, 'In': 1, 'Tl': 1}#

Valence p electrons of the neutral atoms whose aoc atom we can do (p1, p5).

pyscf_step.basis.basis_and_ecp(symbols, basis, other_basis, uncontract=True, spin_orbit=True)[source]#

The basis and ECPs for a set of elements, as the driver takes them.

Each element uses basis if the BSE has it there, else other_basis. An element with an ECP gets the ECP’s spin-orbit part, checked against the published data; an element with an ECP but no such data is refused when spin_orbit is true.

Returns (basis {symbol: shells}, ecp {symbol: ecp}, info {symbol: {…}}).

pyscf_step.basis.electron_basis(name, symbol, uncontract=False)[source]#

The element’s basis as PySCF’s list [[l, [exp, c…], …], …].

pyscf_step.basis.has_element(name, symbol)[source]#

Whether the BSE basis name covers the element.

pyscf_step.basis.scalar_ecp(name, symbol)[source]#

The element’s ECP as PySCF’s [nelec, [[l, by_r], …]], or None.

The local part (stored by the BSE with the highest angular momentum, one above the others) becomes PySCF’s l = -1. Only scalar potentials are accepted: the spin-orbit part is rebuilt separately and checked.

pyscf_step.installer module#

Installer for the PySCF plug-in.

PySCF runs in its own conda environment, seamm-pyscf by default, which this installer creates and registers in pyscf.ini. The environment holds Python 3.12 from conda-forge and PySCF from PyPI (wheels for Linux x86_64 and macOS arm64), for the CPU. GPU4PySCF, for scalar HF/DFT on NVIDIA GPUs, is added only when gpu = yes is set in pyscf.ini (or --gpu is given); the relativistic calculations always run on the CPU.

pyscf_step.installer.GPU_PACKAGES = ('gpu4pyscf-cuda12x>=1.9.1', 'cupy-cuda12x[ctk]', 'cutensor-cu12')#

The optional GPU packages (CUDA 12 build, as the Interaction EDA step uses).

class pyscf_step.installer.Installer(logger=<Logger pyscf_step.installer (WARNING)>)[source]#

Bases: InstallerBase

Handle the installation of PySCF for the PySCF step.

  1. install creates the conda environment seamm-pyscf (Python 3.12), installs PySCF in it (and GPU4PySCF if asked), checks it and writes pyscf.ini.

  2. update upgrades PySCF (within the validated series) in that environment.

  3. check and show say what is installed and whether it works.

An environment named in pyscf.ini that SEAMM did not create, or an installation = local Python, is never changed.

check()[source]#

Check that pyscf.ini points at a working PySCF.

exe_version(config)[source]#

The version of PySCF in its environment.

install()[source]#

Create the environment and install PySCF.

setup_parser()[source]#

Parse the command line into the options.

update()[source]#

Upgrade PySCF in the environment.

pyscf_step.installer.PROBE = '\nimport json\nout = {}\ntry:\n    import pyscf\n    from pyscf import gto, scf\n    out["pyscf"] = pyscf.__version__\n    out["ghf_soc"] = hasattr(scf.ghf.GHF, "with_soc")\n    out["ecpso"] = "ECPso" in gto.moleintor._INTOR_FUNCTIONS\nexcept Exception as e:\n    out["import_error"] = f"{type(e).__name__}: {e}"\ntry:\n    import gpu4pyscf\n    out["gpu4pyscf"] = gpu4pyscf.__version__\nexcept Exception:\n    pass\nprint("PROBE" + json.dumps(out))\n'#

Imports PySCF and checks the pieces the step uses; no calculation.

pyscf_step.installer.PYSCF = 'pyscf==2.15.0'#

The PySCF the step was validated with (SEAMM 5876/5877/5879, 2026-11-20). Pinned: 2.15.1 has no macOS arm64 wheel.

pyscf_step.installer.assess(probe)[source]#

(usable, [lines]) for a probe of the environment.

pyscf_step.installer.parse(output, tag)[source]#

The JSON after tag in a script’s output, or None.

pyscf_step.metadata module#

This file contains metadata describing the results from Pyscf

pyscf_step.metadata.metadata = {'results': {'E_SO atoms': {'calculation': ['spin orbit'], 'description': "The sum of the atoms' E_SO(J-average) used in the correction", 'dimensionality': 'scalar', 'type': 'float', 'units': 'kJ/mol'}, 'E_SO molecule': {'calculation': ['spin orbit'], 'description': 'E(two-component) - E(scalar) of the molecule', 'dimensionality': 'scalar', 'type': 'float', 'units': 'kJ/mol'}, 'atomic spin-orbit': {'calculation': ['spin orbit'], 'description': 'Per element: the computed J splitting (cm^-1) and E_SO of the ground J level and of the J average (kJ/mol)', 'dimensionality': '{element: {term: value}}', 'type': 'json', 'units': ''}, 'scalar energy': {'calculation': ['spin orbit'], 'description': 'The scalar SCF energy of the molecule', 'dimensionality': 'scalar', 'type': 'float', 'units': 'E_h'}, 'spin-orbit correction': {'calculation': ['spin orbit'], 'description': "The molecular (second-order) spin-orbit correction to the atomization energy, delta_SO = -E_SO(molecule) + sum of the atoms' E_SO(J-average)", 'dimensionality': 'scalar', 'property': 'spin-orbit correction#PySCF#{model}', 'type': 'float', 'units': 'kJ/mol'}, 'two-component energy': {'calculation': ['spin orbit'], 'description': 'The two-component (spin-orbit) SCF energy of the molecule', 'dimensionality': 'scalar', 'type': 'float', 'units': 'E_h'}}}#

Description of the computational models for Pyscf.

Hamiltonians, approximations, and basis set or parameterizations, only if appropriate for this code. For example:

metadata["computational models"] = {
    "Hartree-Fock": {
        "models": {
            "PM7": {
                "parameterizations": {
                    "PM7": {
                        "elements": "1-60,62-83",
                        "periodic": True,
                        "reactions": True,
                        "optimization": True,
                        "code": "mopac",
                    },
                    "PM7-TS": {
                        "elements": "1-60,62-83",
                        "periodic": True,
                        "reactions": True,
                        "optimization": False,
                        "code": "mopac",
                    },
                },
            },
        },
    },
}

pyscf_step.pyscf module#

Non-graphical part of the PySCF step in a SEAMM flowchart

class pyscf_step.pyscf.Pyscf(flowchart=None, title='PySCF', namespace='org.molssi.seamm.pyscf', extension=None, logger=<Logger pyscf_step.pyscf (WARNING)>)[source]#

Bases: Node

The non-graphical part of a PySCF step in a flowchart.

parser#

The parser object.

Type:

configargparse.ArgParser

options#

It contains a two item tuple containing the populated namespace and the list of remaining argument strings.

Type:

tuple

subflowchart#

A SEAMM Flowchart object that represents a subflowchart, if needed.

Type:

seamm.Flowchart

parameters#

The control parameters for PySCF.

Type:

PyscfParameters

See also

TkPyscf, Pyscf, PyscfParameters

analyze(indent='', **kwargs)[source]#

Do any analysis of the output from this step.

Also print important results to the local step.out file using “printer”.

Parameters:

indent (str) – An extra indentation for the output

description_text(P=None)[source]#

Create the text description of what this step will do. The dictionary of control values is passed in as P so that the code can test values, etc.

Parameters:

P (dict) – An optional dictionary of the current values of the control parameters.

Returns:

A description of the current step.

Return type:

str

property git_revision#

The git version of this module.

run()[source]#

Run a PySCF step.

Parameters:

None

Returns:

The next node object in the flowchart.

Return type:

seamm.Node

set_id(node_id)[source]#

Set the id for node to a given tuple

property version#

The semantic version of this module.

pyscf_step.pyscf_step module#

class pyscf_step.pyscf_step.PyscfStep(flowchart=None, gui=None)[source]#

Bases: object

Helper class needed for the stevedore integration.

This must provide a description() method that returns a dict containing a description of this node, and create_node() and create_tk_node() methods for creating the graphical and non-graphical nodes.

The dictionary for the description is the class variable just below these comments. The felds are as follows:

my_description{str, str}

A human-readable description of this step. It can be several lines long, and needs to be clear to non-expert users. It contains the following keys: description, group, name.

my_description[“description”]tuple

A description of the PySCF step. It must be clear to non-experts.

my_description[“group”]str

Which group in the menus to put this step. If the group does not exist it will be created. Common groups are “Building”, “Control”, “Custom”, “Data”, and “Simulations”.

my_description[“name”]str

The name of this step, to be displayed in the menus.

create_node(flowchart=None, **kwargs)[source]#

Create and return the new node object.

Parameters:
  • flowchart (seamm.Node) – A non-graphical SEAMM node

  • **kwargs (keyword arguments) – Various keyword arguments such as title, namespace or extension representing the title displayed in the flowchart, the namespace for the plugins of a subflowchart and the extension, respectively.

Return type:

Pyscf

create_tk_node(canvas=None, **kwargs)[source]#

Create and return the graphical Tk node object.

Parameters:
  • canvas (tk.Canvas) – The Tk Canvas widget

  • **kwargs (keyword arguments) – Various keyword arguments such as tk_flowchart, node, x, y, w, h representing a graphical flowchart object, a non-graphical node for a step, and dimensions of the graphical node.

Return type:

TkPyscf

description()[source]#

Return a description of what this step does.

Returns:

description

Return type:

dict(str, str)

my_description = {'description': 'An interface for PySCF', 'group': 'Simulations', 'name': 'PySCF'}#

pyscf_step.spin_orbit module#

Non-graphical part of the Spin Orbit step in a PySCF flowchart

pyscf_step.spin_orbit.ECP_BIBTEX = {'peterson2003b': '@article{peterson2003b,\n  author = {Peterson, Kirk A. and Figgen, Detlev and Goll, Erich and Stoll, Hermann\n    and Dolg, Michael},\n  title = {Systematically convergent basis sets with relativistic pseudopotentials.\n    {II}. Small-core pseudopotentials and correlation consistent basis sets for the\n    post-d group 16-18 elements},\n  journal = {J. Chem. Phys.},\n  volume = {119},\n  pages = {11113--11123},\n  year = {2003},\n  doi = {10.1063/1.1622924}\n}', 'peterson2006a': '@article{peterson2006a,\n  author = {Peterson, Kirk A. and Shepler, Benjamin C. and Figgen, Detlev and\n    Stoll, Hermann},\n  title = {On the Spectroscopic and Thermochemical Properties of {ClO}, {BrO}, {IO},\n    and Their Anions},\n  journal = {J. Phys. Chem. A},\n  volume = {110},\n  pages = {13877--13883},\n  year = {2006},\n  doi = {10.1021/jp065887l}\n}'}#

The pseudopotential papers, as the Basis Set Exchange cites them.

pyscf_step.spin_orbit.ECP_PAPERS = {'Br': ('peterson2003b',), 'I': ('peterson2003b', 'peterson2006a')}#

The papers for each element’s pseudopotential.

class pyscf_step.spin_orbit.SpinOrbit(flowchart=None, title='Spin Orbit', extension=None, logger=<Logger pyscf_step.spin_orbit (WARNING)>)[source]#

Bases: Substep

The non-graphical part of a Spin Orbit step in a flowchart.

parser#

The parser object.

Type:

configargparse.ArgParser

options#

It contains a two item tuple containing the populated namespace and the list of remaining argument strings.

Type:

tuple

subflowchart#

A SEAMM Flowchart object that represents a subflowchart, if needed.

Type:

seamm.Flowchart

parameters#

The control parameters for Spin Orbit.

Type:

SpinOrbitParameters

See also

TkSpinOrbit, SpinOrbit, SpinOrbitParameters

analyze(indent='', data=None, info=None, counts=None, mol=None, **kwargs)[source]#

Print the results.

description_text(P=None)[source]#

A text description of what this step will do.

property git_revision#

The git version of this module.

property header#

A printable header for this section of output

run()[source]#

Run the Spin Orbit step: the atoms, then the molecule, then delta_SO.

property version#

The semantic version of this module.

pyscf_step.spin_orbit.n_functions(shells)[source]#

The number of spherical functions in a PySCF basis list.

pyscf_step.spin_orbit_parameters module#

Control parameters for the Spin Orbit step in a SEAMM flowchart

class pyscf_step.spin_orbit_parameters.SpinOrbitParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for the Spin Orbit sub-step.

See also

SpinOrbit, TkSpinOrbit

parameters = {'basis': {'default': 'cc-pVTZ-PP', 'default_units': '', 'description': 'Basis set:', 'enumeration': ('cc-pVTZ-PP', 'aug-cc-pVTZ-PP', 'cc-pVQZ-PP'), 'format_string': 's', 'help_text': 'The basis set, from the Basis Set Exchange, for the elements it covers; its pseudopotentials must have published spin-orbit data.', 'kind': 'string'}, 'method': {'default': 'HF', 'default_units': '', 'description': 'Method:', 'enumeration': ('HF',), 'format_string': 's', 'help_text': 'The SCF method. HF is the level Bross et al. recommend.', 'kind': 'enum'}, 'other basis': {'default': 'cc-pVTZ', 'default_units': '', 'description': 'Basis set for other elements:', 'enumeration': ('cc-pVTZ', 'aug-cc-pVTZ', 'cc-pVQZ'), 'format_string': 's', 'help_text': 'The basis set for the elements the first one does not cover.', 'kind': 'string'}, 'results': {'default': {}, 'default_units': '', 'description': 'results', 'enumeration': (), 'format_string': '', 'help_text': 'The results to save to variables or in tables.', 'kind': 'dictionary'}, 'route': {'default': 'SO-ECP', 'default_units': '', 'description': 'Relativistic route:', 'enumeration': ('SO-ECP',), 'format_string': 's', 'help_text': 'SO-ECP: two-component SCF with the spin-orbit part of the energy-consistent pseudopotentials, minus the same scalar calculation (Bross et al., J. Phys. Chem. A 127, 704 (2023)).', 'kind': 'enum'}, 'uncontract': {'default': 'yes', 'default_units': '', 'description': 'Uncontract the basis sets:', 'enumeration': ('yes', 'no'), 'format_string': 's', 'help_text': 'Use the basis sets fully uncontracted, as Bross and Peterson recommend for the spin-orbit term.', 'kind': 'boolean'}}#

pyscf_step.spin_orbit_step module#

class pyscf_step.spin_orbit_step.SpinOrbitStep(flowchart=None, gui=None)[source]#

Bases: object

Helper class needed for the stevedore integration.

This must provide a description() method that returns a dict containing a description of this node, and create_node() and create_tk_node() methods for creating the graphical and non-graphical nodes.

The dictionary for the description is the class variable just below these comments. The felds are as follows:

my_description{str, str}

A human-readable description of this step. It can be several lines long, and needs to be clear to non-expert users. It contains the following keys: description, group, name.

my_description[“description”]tuple

A description of the Spin Orbit step. It must be clear to non-experts.

my_description[“group”]str

Which group in the menus to put this step. If the group does not exist it will be created. Common groups are “Building”, “Control”, “Custom”, “Data”, and “Simulations”.

my_description[“name”]str

The name of this step, to be displayed in the menus.

create_node(flowchart=None, **kwargs)[source]#

Create and return the new node object.

Parameters:
  • flowchart (seamm.Node) – A non-graphical SEAMM node

  • **kwargs (keyword arguments) – Various keyword arguments such as title, namespace or extension representing the title displayed in the flowchart, the namespace for the plugins of a subflowchart and the extension, respectively.

Return type:

SpinOrbit

create_tk_node(canvas=None, **kwargs)[source]#

Create and return the graphical Tk node object.

Parameters:
  • canvas (tk.Canvas) – The Tk Canvas widget

  • **kwargs (keyword arguments) – Various keyword arguments such as tk_flowchart, node, x, y, w, h representing a graphical flowchart object, a non-graphical node for a step, and dimensions of the graphical node.

Return type:

TkSpinOrbit

description()[source]#

Return a description of what this step does.

Returns:

description

Return type:

dict(str, str)

my_description = {'description': 'An interface for Spin Orbit', 'group': 'Calculations', 'name': 'Spin Orbit'}#

pyscf_step.substep module#

Base class for substeps in the PySCF step.

class pyscf_step.substep.Substep(flowchart=None, title='no title', extension=None, logger=<Logger pyscf_step.substep (WARNING)>, module=None)[source]#

Bases: Node

A base class for substeps in the PySCF subflowchart.

The top-level Pyscf step iterates over the substeps of its subflowchart and calls each substep’s run() method. Each substep is responsible for preparing its own input, invoking PySCF, analyzing its output, and storing its results.

This base class provides:

  • is_runable - whether the top-level loop should call run() on this substep. Override to return False for substeps that only contribute input (e.g., an Initialization step) rather than invoking the code.

  • input_only - a flag for “write input but don’t run” mode, useful for debugging and testing.

  • options / global_options - delegated to the parent step so that command-line options reach substeps uniformly.

  • header - a printable header for this section of step.out.

  • version / git_revision - delegated to the plug-in package so that every substep reports the plug-in’s version, not seamm.Node’s.

property git_revision#

The git revision of the pyscf_step package.

property global_options#

The global SEAMM options, delegated to the parent step.

property header#

A printable header for this section of output.

property input_only#

Whether to write the input only, not run PySCF.

property is_runable#

Whether this substep should be run by the top-level loop.

Override to return False for substeps that only contribute input (e.g., an Initialization step) rather than invoking PySCF themselves.

property options#

The PySCF options, delegated to the parent step.

property version#

The semantic version of the pyscf_step package.

pyscf_step.tk_pyscf module#

The graphical part of a PySCF step

class pyscf_step.tk_pyscf.TkPyscf(tk_flowchart=None, node=None, namespace='org.molssi.seamm.pyscf.tk', canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a PySCF step in a flowchart.

tk_flowchart#

The flowchart that we belong to.

Type:

TkFlowchart = None

node#

The corresponding node of the non-graphical flowchart

Type:

Node = None

canvas#

The Tk Canvas to draw on

Type:

tkCanvas = None

dialog#

The Pmw dialog object

Type:

Dialog

x#

The x-coordinate of the center of the picture of the node

Type:

int = None

y#

The y-coordinate of the center of the picture of the node

Type:

int = None

w#

The width in pixels of the picture of the node

Type:

int = 200

h#

The height in pixels of the picture of the node

Type:

int = 50

self[widget]#

A dictionary of tk widgets built using the information contained in PySCF_parameters.py

Type:

dict

See also

Pyscf, TkPyscf, PyscfParameters

create_dialog()[source]#

Create the dialog. A set of widgets will be chosen by default based on what is specified in the PySCF_parameters module.

Parameters:

None

Return type:

None

See also

TkPyscf.reset_dialog

right_click(event)[source]#

Handles the right click event on the node.

Parameters:

event (Tk Event)

Return type:

None

See also

TkPyscf.edit

pyscf_step.tk_spin_orbit module#

The graphical part of a Spin Orbit step

class pyscf_step.tk_spin_orbit.TkSpinOrbit(tk_flowchart=None, node=None, canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a Spin Orbit step in a flowchart.

tk_flowchart#

The flowchart that we belong to.

Type:

TkFlowchart = None

node#

The corresponding node of the non-graphical flowchart

Type:

Node = None

canvas#

The Tk Canvas to draw on

Type:

tkCanvas = None

dialog#

The Pmw dialog object

Type:

Dialog

x#

The x-coordinate of the center of the picture of the node

Type:

int = None

y#

The y-coordinate of the center of the picture of the node

Type:

int = None

w#

The width in pixels of the picture of the node

Type:

int = 200

h#

The height in pixels of the picture of the node

Type:

int = 50

self[widget]#

A dictionary of tk widgets built using the information contained in Spin Orbit_parameters.py

Type:

dict

See also

SpinOrbit, TkSpinOrbit, SpinOrbitParameters

create_dialog()[source]#

Create the dialog. A set of widgets will be chosen by default based on what is specified in the Spin Orbit_parameters module.

Parameters:

None

Return type:

None

reset_dialog(widget=None)[source]#

Layout the widgets in the dialog.

The widgets are chosen by default from the information in Spin Orbit_parameter.

This function simply lays them out row by row with aligned labels. You may wish a more complicated layout that is controlled by values of some of the control parameters. If so, edit or override this method

Parameters:

widget (Tk Widget = None)

Return type:

None

right_click(event)[source]#

Handles the right click event on the node.

Parameters:

event (Tk Event)

Return type:

None

See also

TkSpinOrbit.edit

Module contents#

pyscf_step A SEAMM plug-in for PySCF