training_structures_step package#

Submodules#

training_structures_step.export module#

The labelled training points of one molecule: relative energies, the filters, the extended-XYZ file and the coverage counts, as plain functions (no flowchart state) so that they can be tested on their own.

Energies are in kJ/mol and gradients in kJ/mol/Å, as the Energy step stores them, unless a name says otherwise.

training_structures_step.export.FRAME_KEYS = (('type', 'config_type'), ('name', 'point'), ('target energy', 'target_energy_kJmol'), ('harmonic energy', 'harmonic_energy_kJmol'), ('prescreen energy', 'prescreen_energy_kJmol'), ('scan angle', 'scan_angle'), ('bond class', 'bond_class'), ('bond change', 'bond_change'), ('S**2', 'S2'))#

point keys copied into each frame’s comment line, with their file key

training_structures_step.export.UNITS = {'E_h': (2625.4996394799, 'E_h/Å'), 'eV': (96.48533212331002, 'eV/Å'), 'kJ/mol': (1.0, 'kJ/mol/Å')}#

name -> (kJ/mol per unit, force units)

Type:

the energy and force units of the file

training_structures_step.export.add_coverage(coverage, symbols, bonds, xyz_list)[source]#

Count one molecule’s kept points: every point counts for every element and every bonded element pair of the molecule (the E2a census rule), and each pair’s sampled bond lengths are tracked.

coverage : {“elements”: {el: [molecules, points]}, “pairs”: {pair: [molecules, points, r_min, r_max]}}, updated in place.

training_structures_step.export.coverage_table(coverage, element_minimum=(30, 500), pair_minimum=(10, 100))[source]#

Rows (kind, name, molecules, points, r_min, r_max, passes) of a coverage record, against the minimum (molecules, points) for elements and pairs.

training_structures_step.export.dumps(record)[source]#
training_structures_step.export.extxyz_frame(symbols, xyz, info, gradients=None, units='eV')[source]#

One extended-XYZ frame: species, positions (full precision) and, with gradients (kJ/mol/Å), the forces in the file’s units as REF_forces.

info gives the comment-line keys; numbers already in the file’s units. The energy goes in as REF_energy (not ‘energy’, which ASE would turn into a calculator result), and there is no ‘charge’ column (ASE reads that as a calculator result too).

training_structures_step.export.filter_points(points, window=None, spin_tolerance=None)[source]#

Relative energies and the filters, for one molecule’s labelled points.

Parameters:
  • points ([dict]) – One per configuration, in order, each with “name”, “type” (the Training Structures point type), “energy” (kJ/mol or None when unlabelled), “gradients”, “fingerprint” (the settings fingerprint or None) and “S**2” (or None). Exactly one has type “minimum”.

  • window (float or None) – Drop a point more than this (kJ/mol) above the minimum.

  • spin_tolerance (float or None) – For an open shell, drop a point whose <S**2> differs from the minimum’s by more than this.

Returns:

kept: the points with “delta energy” added, the minimum first; dropped: (name, type, reason); problem: None, or why the molecule as a whole cannot be exported (no labelled minimum, mixed settings).

Return type:

(kept, dropped, problem)

training_structures_step.export.merge_redraw(points, redraw_points, same_model=True, tolerance=0.01)[source]#

A molecule’s points with a redraw’s samples in place of the first pass’s.

The first pass’s samples are kept in the list, marked “replaced” (so the caller can mark their configurations); the redraw’s minimum is a duplicate of the first pass’s and is left out. Both minima must agree in energy (within tolerance kJ/mol) and settings: the redraw must start from the same structure at the same level.

Return type:

(points, problem)

training_structures_step.export.molecule_file(symbols, kept, molecule, units='eV', charge=0, multiplicity=1)[source]#

The extended-XYZ text of one molecule’s kept points (the minimum first).

training_structures_step.export.provenance(molecule, model, fingerprint, record, hessian, seed, kept, dropped)[source]#

The sidecar record of one molecule’s export (JSON-ready).

training_structures_step.export.sample_drop_fraction(points, dropped)[source]#

The fraction of the normal-mode samples dropped by the window or the spin check (the recipe redraws a molecule’s samples when it exceeds 15 %).

training_structures_step.export_training_set module#

Non-graphical part of the Export Training Set step in a SEAMM flowchart

class training_structures_step.export_training_set.ExportTrainingSet(flowchart=None, title='Export Training Set', extension=None, logger=<Logger training_structures_step.export_training_set (WARNING)>)[source]#

Bases: Node

The non-graphical part of a Export Training Set 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 Export Training Set.

Type:

ExportTrainingSetParameters

See also

TkExportTrainingSet, ExportTrainingSet, ExportTrainingSetParameters

analyze(data=None, summary=(), refused=(), redraw=(), below=(), rows=(), threshold=0.15, **kwargs)[source]#

Summarize the export.

description_text(P=None)[source]#

Create the text description of what this step will do.

property git_revision#

The git version of this module.

run()[source]#

Export the training points.

property version#

The semantic version of this module.

training_structures_step.export_training_set_parameters module#

Control parameters for the Export Training Set step in a SEAMM flowchart

class training_structures_step.export_training_set_parameters.ExportTrainingSetParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for Export Training Set.

The step reads the systems made by Training Structures after an Energy step has labelled them, works out each point’s energy above its molecule’s minimum, drops points outside the energy window or with a changed <S**2>, and writes one extended-XYZ file per molecule, with a record of how it was made, and a coverage table of the elements and bonded pairs.

parameters = {'directory': {'default': 'training_set', 'default_units': '', 'description': 'Directory:', 'enumeration': (), 'format_string': '', 'help_text': "Where the files go, relative to the job's directory unless absolute: <molecule>.extxyz and <molecule>.json per molecule, and coverage.csv.", 'kind': 'string'}, 'element minimum molecules': {'default': 30, 'default_units': '', 'description': 'Elements need at least:', 'enumeration': (), 'format_string': '', 'help_text': 'molecules ...', 'kind': 'integer'}, 'element minimum points': {'default': 500, 'default_units': '', 'description': 'and points:', 'enumeration': (), 'format_string': '', 'help_text': 'points.', 'kind': 'integer'}, 'energy units': {'default': 'eV', 'default_units': '', 'description': 'Units in the file:', 'enumeration': ('eV', 'kJ/mol', 'E_h'), 'format_string': '', 'help_text': 'The units of REF_energy and delta_energy (forces in the same per Å).', 'kind': 'enum'}, 'energy window': {'default': 10.0, 'default_units': 'kcal/mol', 'description': 'Energy window:', 'enumeration': ('none',), 'format_string': '.2f', 'help_text': "Drop a point more than this above its molecule's minimum. 'none' keeps every labelled point.", 'kind': 'float'}, 'model chemistry': {'default': 'from the labels', 'default_units': '', 'description': 'Labels from:', 'enumeration': ('from the labels',), 'format_string': '', 'help_text': "The model chemistry whose energies and gradients are the labels: 'from the labels' when the points carry only one, else its level (e.g. 'ORCA:DFT@r2SCAN-3c').", 'kind': 'string'}, 'pair minimum molecules': {'default': 10, 'default_units': '', 'description': 'Bonded pairs need at least:', 'enumeration': (), 'format_string': '', 'help_text': 'molecules ...', 'kind': 'integer'}, 'pair minimum points': {'default': 100, 'default_units': '', 'description': 'and points:', 'enumeration': (), 'format_string': '', 'help_text': 'points.', 'kind': 'integer'}, 'redraw threshold': {'default': 15.0, 'default_units': '', 'description': 'Report a redraw above (%):', 'enumeration': (), 'format_string': '.1f', 'help_text': 'A molecule that lost more than this share of its samples to the window or the spin check is reported for new samples with a lower maximum target energy.', 'kind': 'float'}, 'results': {'default': {}, 'default_units': None, 'description': 'results', 'enumeration': (), 'format_string': '', 'help_text': 'The results to save to variables or in tables.', 'kind': 'dictionary'}, 'spin tolerance': {'default': 0.05, 'default_units': '', 'description': 'Allowed change of <S**2>:', 'enumeration': ('none',), 'format_string': '.3f', 'help_text': "For an open-shell molecule, drop a point whose <S**2> differs from the minimum's by more than this (a different electronic state or more spin contamination). 'none' skips the check.", 'kind': 'float'}, 'systems': {'default': 'all training systems', 'default_units': '', 'description': 'Systems:', 'enumeration': ('all training systems', 'current'), 'format_string': '', 'help_text': "Which systems to export: 'all training systems' (every system whose configurations were made by Training Structures), 'current', or a pattern for the system names (e.g. '* training').", 'kind': 'string'}}#

training_structures_step.export_training_set_step module#

class training_structures_step.export_training_set_step.ExportTrainingSetStep(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 Export Training Set 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:

ExportTrainingSet

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:

TkExportTrainingSet

description()[source]#

Return a description of what this step does.

Returns:

description

Return type:

dict(str, str)

my_description = {'description': 'Write labelled training structures as extended-XYZ files, one per molecule, with relative energies, filters and a coverage table', 'group': 'Data', 'name': 'Export Training Set'}#

training_structures_step.generate module#

The geometry generators and filters of the Training Structures step, as plain functions of coordinates, bonds and Hessians (no flowchart state), so that they can be tested on their own.

Units: coordinates in Å, Hessians in E_h/bohr², gradients in E_h/bohr, energies in E_h unless a name says otherwise.

training_structures_step.generate.bond_classes(symbols, xyz, bonds, pairs=None)[source]#

{“C-H”: (i, j), …}: for each bonded element pair, the bond of median length (the lower of the two middle ones; ties to the lower indices). pairs limits it to those classes (e.g. {“C-H”, “C-C”}; order of the elements does not matter).

training_structures_step.generate.check_hessian(hessian, gradient, xyz, masses_amu, rng, n_displacements=3, rms=0.005, tolerance=0.02, max_frequency=5000.0)[source]#

Test a Hessian against central differences of the gradient.

For each of n_displacements random displacements δ with an RMS of rms Å, e = ‖Hδ − [g(x₀+δ) − g(x₀−δ)]/2‖ / ‖Hδ‖ (2 gradients each). The Hessian is refused if any e exceeds tolerance or any frequency magnitude exceeds max_frequency cm⁻¹.

Parameters:

gradient (callable) – gradient(xyz (N, 3) Å) -> (3N,) E_h/bohr.

Returns:

“errors”: [e], “max frequency”: the largest frequency magnitude, “refused”: bool and “reason”: text or None.

Return type:

dict

training_structures_step.generate.connectivity(symbols, xyz, factor=1.3, radii=None)[source]#

The bonds (i < j) of a structure: atoms closer than factor times the sum of their covalent radii.

training_structures_step.generate.connectivity_change(reference_bonds, symbols, xyz, factor=1.3, radii=None, exempt=None)[source]#

None if the structure has exactly the reference bonds, else the bonds broken and formed, as text (e.g. ‘-C1-H5 +H5-O3’). exempt is a bond (i, j) not judged: a bond stretched on purpose.

training_structures_step.generate.covalent_radii(symbols)[source]#

RDKit’s covalent radii (Å) of the elements.

training_structures_step.generate.diatomic_grid(hessian, xyz, energy, n_points)[source]#

Bond-length changes (Å) for a diatomic’s 1-D stretch grid: n_points equally spaced from -a to +a, a the displacement whose harmonic energy is energy (E_h); r_e itself (the minimum, already a point) is left out if it falls on the grid.

training_structures_step.generate.dihedral(x, a, b, c, d)[source]#

The dihedral a-b-c-d (degrees, -180..180).

training_structures_step.generate.find_rotors(symbols, bonds, orders=None, conjugated=None, max_rotors=None)[source]#

The heavy rotors of a molecule, most heavy atoms moved first.

A heavy rotor is an acyclic single bond i-j, not conjugated, where i and j each have another heavy-atom neighbour (so methyl, OH and NH2 rotations are not rotors). Rotating about it moves the smaller side; rotors are ranked by the number of heavy atoms that moves, ties going to the lower atom indices.

Parameters:
  • symbols ([str])

  • bonds ([(int, int)]) – 0-based.

  • orders ({(i, j): int} or None) – Bond orders (i < j); a bond without one counts as single.

  • conjugated (set of (i, j) or None) – The conjugated bonds (i < j), e.g. from RDKit’s GetIsConjugated.

  • max_rotors (int or None)

Returns:

Each with “bond” (i, j), “dihedral” (a, i, j, b), “moving” (the atoms that rotate, a sorted list) and “heavy moved”.

Return type:

[dict]

training_structures_step.generate.frequencies(hessian, masses_amu)[source]#

Signed harmonic frequencies (cm⁻¹) of a Cartesian Hessian (E_h/bohr²), without projecting translations and rotations (for the frequency guard).

training_structures_step.generate.rotate_about_bond(xyz, i, j, moving, degrees)[source]#

A copy of xyz with the atoms moving turned by degrees about the i-j axis (right-handed about i -> j).

training_structures_step.generate.scan_angles(start, step=15.0)[source]#

The scan’s dihedral targets: start + k*step, k = 1 … 360/step - 1 (the start itself is the minimum and is not repeated), wrapped to -180..180.

training_structures_step.generate.set_dihedral(xyz, rotor, target)[source]#

A copy of xyz with the rotor’s dihedral set to target degrees by turning its moving side.

training_structures_step.generate.stretch(xyz, i, j, a)[source]#

A copy of xyz with bond i-j lengthened by a (Å; negative shortens), each atom moving a/2.

training_structures_step.generate.stretch_amplitude(hessian, xyz, i, j, energy, maximum=None)[source]#

The bond-length change a (Å) whose harmonic energy along the stretch is energy (E_h): 1/2 a² vᵀHv = energy, exact for this two-atom displacement; capped at maximum (Å).

training_structures_step.generate.stretch_vector(xyz, i, j)[source]#

The unit-free stretch direction (3N): -u/2 on i, +u/2 on j, u the unit vector i -> j; a displacement a times it lengthens the bond by a.

training_structures_step.generate.wrap(delta)[source]#

The magnitude of an angle difference, wrapped to 0..180 degrees.

training_structures_step.metadata module#

This file contains metadata describing the results from TrainingStructures

training_structures_step.metadata.export_metadata = {'results': {'directory': {'description': 'Where the files were written', 'dimensionality': 'scalar', 'type': 'string'}, 'molecules below their minimum': {'description': 'Molecules with points more than 1 kJ/mol below the minimum', 'dimensionality': 'scalar', 'type': 'json'}, 'molecules to redraw': {'description': 'Molecules that lost too many samples to the filters', 'dimensionality': 'scalar', 'type': 'json'}, 'number of dropped points': {'description': 'The number of points dropped by the filters', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of molecules': {'description': 'The number of molecules exported', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of points': {'description': 'The number of points kept and exported', 'dimensionality': 'scalar', 'type': 'integer'}, 'redraw regexp': {'description': 'A regular expression matching the training systems to redraw, for a Loop over systems', 'dimensionality': 'scalar', 'type': 'string'}, 'refused molecules': {'description': 'Molecules not exported, with the reasons', 'dimensionality': 'scalar', 'type': 'json'}}}#

The results of the Export Training Set step

training_structures_step.metadata.metadata = {'results': {'dropped points': {'description': 'The points refused, by kind, with the reasons', 'dimensionality': 'scalar', 'type': 'json'}, 'hessian': {'description': 'How the Hessian was made and checked', 'dimensionality': 'scalar', 'type': 'json'}, 'number of dropped points': {'description': 'The number of points refused by the checks', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of grid points': {'description': "The number of a diatomic's stretch-grid points", 'dimensionality': 'scalar', 'type': 'integer'}, 'number of points': {'description': 'The number of structures made, the minimum included', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of rotors': {'description': 'The number of heavy rotors scanned', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of sample points': {'description': 'The number of normal-mode samples', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of scan points': {'description': 'The number of torsion-scan points', 'dimensionality': 'scalar', 'type': 'integer'}, 'number of stretch points': {'description': 'The number of bond-stretch points', 'dimensionality': 'scalar', 'type': 'integer'}, 'random seed': {'description': 'The seed of the random numbers, to reproduce the points', 'dimensionality': 'scalar', 'type': 'integer'}, 'system name': {'description': 'The name of the system holding the structures', 'dimensionality': 'scalar', 'type': 'string'}}}#

Description of the computational models for TrainingStructures.

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",
                    },
                },
            },
        },
    },
}

training_structures_step.substep module#

Base class for substeps in the Training Structures step.

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

Bases: Node

A base class for substeps in the Training Structures subflowchart.

The top-level TrainingStructures 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 Training Structures, 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 training_structures_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 Training Structures.

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 Training Structures themselves.

property options#

The Training Structures options, delegated to the parent step.

property version#

The semantic version of the training_structures_step package.

training_structures_step.tk_export_training_set module#

The graphical part of a Export Training Set step

class training_structures_step.tk_export_training_set.TkExportTrainingSet(tk_flowchart=None, node=None, canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a Export Training Set 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

namespace#

The namespace of the current step.

Type:

str

tk_subflowchart#

A graphical Flowchart representing a subflowchart

Type:

TkFlowchart

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 Export Training Set_parameters.py

Type:

dict

See also

ExportTrainingSet, TkExportTrainingSet, ExportTrainingSetParameters

create_dialog()[source]#

Create the dialog. A set of widgets will be chosen by default based on what is specified in the Export Training Set_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 Export Training Set_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

TkExportTrainingSet.edit

training_structures_step.tk_training_structures module#

The graphical part of a Training Structures step

class training_structures_step.tk_training_structures.TkTrainingStructures(tk_flowchart=None, node=None, canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a Training Structures 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

namespace#

The namespace of the current step.

Type:

str

tk_subflowchart#

A graphical Flowchart representing a subflowchart

Type:

TkFlowchart

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 Training Structures_parameters.py

Type:

dict

See also

TrainingStructures, TkTrainingStructures, TrainingStructuresParameters

DRIVERS = ('number of samples', 'number of rotors', 'bond stretches', 'connectivity check', 'prescreen energy', 'check the hessian')#

the parameters whose value changes the layout

GROUPS = {'Bond stretches': ('bond stretches', 'bond pairs', 'stretch energy', 'maximum stretch', 'diatomic grid points', 'diatomic grid energy'), 'Checks': ('generator level', 'connectivity check', 'connectivity factor', 'prescreen energy'), 'Hessian': ('check the hessian', 'closed-shell check fraction', 'hessian tolerance', 'check displacement', 'maximum frequency'), 'Output': ('random seed', 'system name'), 'Samples': ('number of samples', 'samples per mode', 'minimum number of samples', 'maximum number of samples', 'minimum target energy', 'maximum target energy', 'amplitude cap', 'lowest frequency', 'maximum atom displacement', 'maximum bond change', 'maximum angle change', 'maximum draws'), 'Torsion scans': ('number of rotors', 'scan step', 'relaxation convergence', 'relaxation max steps')}#

the dialog’s frames and the parameters in each, in order

create_dialog()[source]#

Create the dialog: the parameters in labelled frames.

reset_dialog(widget=None)[source]#

Lay out the frames, showing each parameter only when it applies.

right_click(event)[source]#

Handles the right click event on the node.

Parameters:

event (Tk Event)

Return type:

None

See also

TkTrainingStructures.edit

training_structures_step.training_structures module#

Non-graphical part of the Training Structures step in a SEAMM flowchart

class training_structures_step.training_structures.TrainingStructures(flowchart=None, title='Training Structures', extension=None, logger=<Logger training_structures_step.training_structures (WARNING)>)[source]#

Bases: Node

The non-graphical part of a Training Structures 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 Training Structures.

Type:

TrainingStructuresParameters

See also

TkTrainingStructures, TrainingStructures, TrainingStructuresParameters

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

Summarize the points made.

description_text(P=None)[source]#

Create the text description of what this step will do.

property git_revision#

The git version of this module.

run()[source]#

Make the training structures of the current molecule.

property version#

The semantic version of this module.

training_structures_step.training_structures_parameters module#

Control parameters for the Training Structures step in a SEAMM flowchart

class training_structures_step.training_structures_parameters.TrainingStructuresParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for Training Structures.

The step makes distorted structures of one molecule (the current configuration, which should be a minimum of the flowchart’s Model Chemistry) for training a machine-learned potential: normal-mode samples at targeted energies, relaxed torsion scans of the heavy rotors, and bond stretches. The Hessian comes from the Model Chemistry; the scans and the pre-screen use a second, cheap level.

parameters = {'amplitude cap': {'default': 3.0, 'default_units': '', 'description': 'Amplitude cap (in sigma):', 'enumeration': ('none',), 'format_string': '.1f', 'help_text': "Clamp each normal coordinate of the shape to this many standard deviations before scaling. 'none' leaves the tails uncapped.", 'kind': 'float'}, 'bond pairs': {'default': 'all', 'default_units': '', 'description': 'Element pairs:', 'enumeration': ('all',), 'format_string': '', 'help_text': "'all', or the pairs to stretch, e.g. 'C-H, C-C, C-O'.", 'kind': 'string'}, 'bond stretches': {'default': 'yes', 'default_units': '', 'description': 'Bond stretches:', 'enumeration': ('yes', 'no'), 'format_string': '', 'help_text': 'Stretch and compress the median bond of each bonded element pair by the amplitude below (two points per pair).', 'kind': 'enum'}, 'check displacement': {'default': 0.005, 'default_units': 'Å', 'description': 'Check displacement (RMS):', 'enumeration': (), 'format_string': '.4f', 'help_text': 'The size of each random displacement.', 'kind': 'float'}, 'check the hessian': {'default': 'open shells', 'default_units': '', 'description': 'Check the Hessian:', 'enumeration': ('open shells', 'always', 'never'), 'format_string': '', 'help_text': "Test the Hessian against central differences of the gradient along random displacements; a refused one is replaced by finite differences of the gradient. 'open shells' checks every open-shell molecule and the fraction below of closed-shell ones.", 'kind': 'enum'}, 'closed-shell check fraction': {'default': 0.05, 'default_units': '', 'description': 'and closed shells at random:', 'enumeration': (), 'format_string': '.2f', 'help_text': 'The fraction of closed-shell molecules checked, as a watch.', 'kind': 'float'}, 'connectivity check': {'default': 'yes', 'default_units': '', 'description': 'Keep the bonds:', 'enumeration': ('yes', 'no'), 'format_string': '', 'help_text': "Refuse a point whose bonds (atoms closer than the factor below times the sum of their covalent radii) differ from the minimum's.", 'kind': 'enum'}, 'connectivity factor': {'default': 1.3, 'default_units': '', 'description': 'Bond factor:', 'enumeration': (), 'format_string': '.2f', 'help_text': 'Covalent-radius factor.', 'kind': 'float'}, 'diatomic grid energy': {'default': 9.5, 'default_units': 'kcal/mol', 'description': 'out to a harmonic energy of:', 'enumeration': (), 'format_string': '.2f', 'help_text': "The ends of a diatomic's grid.", 'kind': 'float'}, 'diatomic grid points': {'default': 100, 'default_units': '', 'description': 'Diatomic stretch grid:', 'enumeration': (), 'format_string': '', 'help_text': 'A diatomic gets this many points evenly spaced along its stretch, in place of samples and stretches.', 'kind': 'integer'}, 'generator level': {'default': 'xTB:SQM@GFN2-xTB', 'default_units': '', 'description': 'Level for scans and pre-screen:', 'enumeration': ('xTB:SQM@GFN2-xTB', 'MOPAC:SQM@PM7'), 'format_string': '', 'help_text': 'The cheap model chemistry that relaxes the scan points at fixed torsion and pre-screens every point. It only makes geometries: no energy of it is a label.', 'kind': 'string'}, 'hessian tolerance': {'default': 0.02, 'default_units': '', 'description': 'Relative error allowed:', 'enumeration': (), 'format_string': '.3f', 'help_text': 'e = |Hδ - Δg/2| / |Hδ| above this, or any |ν| above the maximum frequency, refuses the Hessian.', 'kind': 'float'}, 'lowest frequency': {'default': 100.0, 'default_units': '1/cm', 'description': 'Skip modes below:', 'enumeration': ('none',), 'format_string': '.1f', 'help_text': "Do not sample along modes softer than this: soft torsions are covered by the scans. 'none' samples every mode.", 'kind': 'float'}, 'maximum angle change': {'default': 15.0, 'default_units': 'degree', 'description': 'Largest bond-angle change:', 'enumeration': ('none',), 'format_string': '.1f', 'help_text': 'Redraw a sample in which a bond angle changes by more than this.', 'kind': 'float'}, 'maximum atom displacement': {'default': 0.3, 'default_units': 'Å', 'description': 'Largest atom displacement:', 'enumeration': ('none',), 'format_string': '.3f', 'help_text': "Redraw a sample in which an atom moves farther than this. 'none' sets no limit.", 'kind': 'float'}, 'maximum bond change': {'default': 0.2, 'default_units': 'Å', 'description': 'Largest bond-length change:', 'enumeration': ('none',), 'format_string': '.3f', 'help_text': 'Redraw a sample in which a bond length changes by more than this.', 'kind': 'float'}, 'maximum draws': {'default': 5, 'default_units': '', 'description': 'Draws per sample:', 'enumeration': (), 'format_string': '', 'help_text': 'How many times a sample is drawn (keeping its target energy) before it is dropped, when it fails the limits, the connectivity check or the pre-screen.', 'kind': 'integer'}, 'maximum frequency': {'default': 5000.0, 'default_units': '1/cm', 'description': 'Maximum frequency:', 'enumeration': (), 'format_string': '.0f', 'help_text': 'A frequency above this means the Hessian is broken.', 'kind': 'float'}, 'maximum number of samples': {'default': 40, 'default_units': '', 'description': 'At most:', 'enumeration': (), 'format_string': '', 'help_text': 'The most samples.', 'kind': 'integer'}, 'maximum stretch': {'default': 0.1, 'default_units': 'Å', 'description': 'but by at most:', 'enumeration': (), 'format_string': '.3f', 'help_text': 'The largest bond-length change of a stretch point.', 'kind': 'float'}, 'maximum target energy': {'default': 9.0, 'default_units': 'kcal/mol', 'description': 'to:', 'enumeration': (), 'format_string': '.2f', 'help_text': 'The highest target energy.', 'kind': 'float'}, 'minimum number of samples': {'default': 10, 'default_units': '', 'description': 'At least:', 'enumeration': (), 'format_string': '', 'help_text': 'The fewest samples.', 'kind': 'integer'}, 'minimum target energy': {'default': 0.5, 'default_units': 'kcal/mol', 'description': 'Target energies from:', 'enumeration': (), 'format_string': '.2f', 'help_text': 'Each sample is the equipartition shape scaled to a harmonic energy drawn uniformly between this and the maximum.', 'kind': 'float'}, 'number of rotors': {'default': 2, 'default_units': '', 'description': 'Rotors to scan:', 'enumeration': (), 'format_string': '', 'help_text': 'Scan up to this many heavy rotors (acyclic, non-conjugated single bonds with a heavy atom beyond each end), those that move the most heavy atoms first. 0 makes no scans.', 'kind': 'integer'}, 'number of samples': {'default': 'in proportion to the modes', 'default_units': '', 'description': 'Number of samples:', 'enumeration': ('in proportion to the modes',), 'format_string': '', 'help_text': "How many normal-mode samples to draw: a number, or 'in proportion to the modes' for the number of sampled modes times 'samples per mode', kept between the minimum and maximum below. 0 makes no samples.", 'kind': 'integer'}, 'prescreen energy': {'default': 15.0, 'default_units': 'kcal/mol', 'description': 'Pre-screen energy:', 'enumeration': ('none',), 'format_string': '.1f', 'help_text': "Refuse a point whose energy at the generator level is more than this above the minimum's. 'none' skips the pre-screen.", 'kind': 'float'}, 'random seed': {'default': 'random', 'default_units': '', 'description': 'Random seed:', 'enumeration': ('random',), 'format_string': '', 'help_text': "An integer for reproducible points, or 'random' (the seed used is recorded).", 'kind': 'string'}, 'relaxation convergence': {'default': 0.01, 'default_units': 'eV/Å', 'description': 'Relax scan points to:', 'enumeration': (), 'format_string': '.3f', 'help_text': "The largest force on an atom (the torsion held fixed) at which a scan point's relaxation stops.", 'kind': 'float'}, 'relaxation max steps': {'default': 200, 'default_units': '', 'description': 'At most:', 'enumeration': (), 'format_string': '', 'help_text': "Steps of each scan point's relaxation.", 'kind': 'integer'}, 'results': {'default': {}, 'default_units': None, 'description': 'results', 'enumeration': (), 'format_string': '', 'help_text': 'The results to save to variables or in tables.', 'kind': 'dictionary'}, 'samples per mode': {'default': 0.5, 'default_units': '', 'description': 'Samples per mode:', 'enumeration': (), 'format_string': '.2f', 'help_text': 'Samples per sampled mode.', 'kind': 'float'}, 'scan step': {'default': 15.0, 'default_units': 'degree', 'description': 'Scan step:', 'enumeration': (), 'format_string': '.1f', 'help_text': "The step of each torsion scan; the minimum's own angle is not repeated.", 'kind': 'float'}, 'stretch energy': {'default': 8.0, 'default_units': 'kcal/mol', 'description': 'Stretch to an energy of:', 'enumeration': (), 'format_string': '.2f', 'help_text': 'The amplitude a solves 1/2 a² vᵀHv = this, with the full Hessian.', 'kind': 'float'}, 'system name': {'default': 'from structure', 'default_units': '', 'description': 'Name of the new system:', 'enumeration': ('from structure', 'for a redraw'), 'format_string': '', 'help_text': "The system holding the points: 'from structure' adds ' training' to the molecule's name; 'for a redraw' adds ' redraw', for a second pass of samples that Export Training Set merges with the first. Other text is used as given, with {structure} replaced by the molecule's name.", 'kind': 'string'}}#

training_structures_step.training_structures_step module#

class training_structures_step.training_structures_step.TrainingStructuresStep(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 Training Structures 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:

TrainingStructures

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:

TkTrainingStructures

description()[source]#

Return a description of what this step does.

Returns:

description

Return type:

dict(str, str)

my_description = {'description': 'Distorted structures of a molecule for training a machine-learned potential: energy-targeted normal-mode samples, relaxed torsion scans and bond stretches', 'group': 'Building', 'name': 'Training Structures'}#

Module contents#

training_structures_step A SEAMM plug-in for Training Structures