structure_step package#

Submodules#

structure_step.energy_source module#

Where the Structure step’s energies and gradients come from.

Either the step’s own sub-steps (a subflowchart, e.g. MOPAC with an Energy sub-step, run at each geometry and read back from its Results.json) or the flowchart’s Model Chemistry (the _model_chemistry variable published by a Model Chemistry step upstream). The Model Chemistry is driven as a warm MDI engine when the program has one here, otherwise as one separate calculation (task) per geometry through seamm_exec.Evaluator. Every optimizer – geomeTRIC, ASE and SEAMM – sees the same engine interface (set_coordinates, energy, forces) in an seamm_exec.hessian.EngineSession.

class structure_step.energy_source.EvaluatorEngine(driver, evaluator, configuration, prefix='opt')[source]#

Bases: object

The interface of an MDI engine over separate calculations: each new geometry is one task of a seamm_exec.Evaluator, for a Model Chemistry with no MDI engine here (or whose program runs only where the job’s tasks run).

The energy and forces of a geometry come from the same task, computed once. A task’s key carries a hash of its coordinates, so a job that is run again reuses only the calculations of the same geometries.

Parameters:
  • driver (seamm_exec.hessian.HessianDriver) – Its evaluate runs the tasks.

  • evaluator (seamm_exec.Evaluator)

  • configuration (molsystem._Configuration) – For the elements, charge and multiplicity.

energy(units='kJ/mol')[source]#
forces(units='hartree/bohr')[source]#
set_coordinates(xyz, units='Å')[source]#
supports(command)[source]#

No MDI commands, so no analytic Hessian.

structure_step.energy_source.NEEDS_MODEL_CHEMISTRY = 'There is no Model Chemistry step before this step: add one, or get the energy and gradients from the subflowchart.'#

What the dialog says is missing for the chosen source

structure_step.energy_source.NO_SOURCE = 'The Structure step has no way to calculate the energy and gradients: add a Model Chemistry step before it, or put the calculation (e.g. MOPAC or ORCA with an Energy sub-step) in its subflowchart.'#

The message when a Structure step has no way to get energies and gradients

structure_step.energy_source.SEAMM_NEEDS_MODEL_CHEMISTRY = "The SEAMM optimizer gets the energy and gradients from the flowchart's Model Chemistry, and there is none: add a Model Chemistry step before the Structure step, or choose another optimizer (e.g. geomeTRIC) to use its sub-steps."#

… and for the SEAMM optimizer, which uses only the Model Chemistry

structure_step.energy_source.USING_SUBFLOWCHART = 'There is no Model Chemistry before this step, so the subflowchart is used for the energies and gradients.'#

Notes when the chosen source is missing and the other is used instead

structure_step.energy_source.choose_engine(engine, optimizer, have_model_chemistry, have_substeps)[source]#

Where an optimization’s energies and gradients come from.

The choice (‘Energies and gradients from:’) is followed when it can be; when the chosen source is missing and the other is there, the other is used, with a note (as the Thermochemistry step does). The SEAMM optimizer uses only the Model Chemistry.

Parameters:
  • engine (str) – “Model Chemistry” or “subflowchart”.

  • optimizer (str) – E.g. “geomeTRIC/geomeTRIC”.

  • have_model_chemistry (bool) – Whether there is a Model Chemistry before the step, and sub-steps.

  • have_substeps (bool) – Whether there is a Model Chemistry before the step, and sub-steps.

Returns:

“Model Chemistry” or “subflowchart”, and the note when the choice could not be followed.

Return type:

(str, str or None)

Raises:

RuntimeError – When neither is there, naming what is missing.

structure_step.energy_source.has_substeps(flowchart)[source]#

Whether a subflowchart has any step after its start node.

structure_step.energy_source.is_model_chemistry_step(node)[source]#

Whether a node is a Model Chemistry step (without importing that plug-in).

structure_step.energy_source.make_driver(node, print_to=None)[source]#

The driver of the Model Chemistry for an optimization: a warm MDI engine whenever the program has one here, otherwise separate calculations.

Return type:

seamm_exec.hessian.HessianDriver

structure_step.energy_source.model_chemistry_session(node, configuration, driver=None, print_to=None)[source]#

An seamm_exec.hessian.EngineSession over the flowchart’s Model Chemistry for the configuration: a warm MDI engine, or separate calculations.

Parameters:
  • node (seamm.Node) – The Structure step.

  • configuration (molsystem._Configuration) – The structure to optimize.

  • driver (seamm_exec.hessian.HessianDriver, optional) – Default: make_driver().

  • print_to (printer, optional) – Where the notes for the user go.

Yields:

seamm_exec.hessian.EngineSession

structure_step.energy_source.uses_model_chemistry_only(optimizer)[source]#

Whether the optimizer works only from the Model Chemistry (SEAMM).

structure_step.metadata module#

This file contains metadata describing the results from Structure

structure_step.structure module#

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

class structure_step.structure.Structure(flowchart=None, title='Structure', namespace='org.molssi.seamm', extension=None, logger=<Logger structure_step.structure (WARNING)>)[source]#

Bases: Node, ASE_mixin, geomeTRIC_mixin

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

Type:

StructureParameters

See also

TkStructure, Structure, StructureParameters

SEAMM_COORDINATES = {'Cart': 'cartesian', 'DLC': 'DLC', 'HDLC': 'HDLC', 'TRIC': 'TRIC', 'TRIC-p': 'primitive'}#

the SEAMM optimizer’s names for the coordinate systems

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

apply_convergence_preset(P)[source]#

Set the convergence formula and criteria from the preset convergence.

The dialog does this when a preset (anything but “custom”) is chosen, but a flowchart made without it – by seamm-flowchart or the MCP server – has only the preset’s name: the formula was left empty, failing with KeyError ‘’, and the criteria were the defaults rather than the preset’s.

Parameters:

P (dict) – The values of the parameters, changed in place.

Returns:

P

Return type:

dict

ase_calculator(calculator, properties=['energy'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]#

The energy and forces for an ASE optimizer: from the Model Chemistry’s engine when it is the source, else the sub-steps (the ASE connector’s own method).

check_flowchart(preceding)[source]#

Check, before the job runs, that an optimization can get its energy and gradients: from sub-steps, or from a Model Chemistry step before this one (the SEAMM optimizer only from the Model Chemistry).

Called by SEAMM’s flowchart checks (the editor’s Run, seamm-flowchart validate and the MCP server), so such a flowchart is stopped before it is queued rather than failing at its first gradient.

Parameters:

preceding ([seamm.Node]) – The steps that run before this one.

Returns:

The problems found; empty if none.

Return type:

[str]

create_parser()[source]#

Setup the command-line / config file parser

describe_seamm_optimizer(P)[source]#

The description of the SEAMM optimizer (seamm_optimizer).

description_text(P=None, short=False, natoms=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.

  • short (bool) – If True, return a short description of the step.

  • natoms (int) – The number of atoms in the structure.

Returns:

A description of the current step.

Return type:

str

energy_engine(P)[source]#

For the geomeTRIC and ASE optimizers: while open, their energies and gradients come from the Model Chemistry’s engine (self._mc_session) when that is the source, else from the sub-steps.

energy_source(P)[source]#

Where the optimization’s energies and gradients come from: the ‘Energies and gradients from:’ choice, or the other source, with a note, when the chosen one is missing (see energy_source.choose_engine).

Parameters:

P (dict) – The values of the parameters.

Returns:

“Model Chemistry” or “subflowchart”

Return type:

str

Raises:

RuntimeError – When there is neither, naming what is missing.

generate_stereoisomers(P)[source]#

Generate the stereoisomers.

Parameters:

P (dict(str, value)) – The control parameters

geometric_calculate_gradients(coordinates)[source]#

The energy (E_h) and gradients (E_h/bohr) for geomeTRIC: from the Model Chemistry’s engine when it is the source, else the sub-steps (the geomeTRIC connector’s own method).

property git_revision#

The git version of this module.

static minimum_check_results(last)[source]#

The results of the SEAMM optimizer’s minimum check, from seamm_exec’s record of the optimization (last_optimization): whether the end point is a minimum, its lowest frequency, the saddle escapes and the cheap-level modes confirmed, when the check ran (a cheap level and “check minimum”); and the number of cheap-level Hessians.

model_chemistry_energy_and_gradients(coordinates)[source]#

The energy (kJ/mol) and gradients (kJ/mol/Å, (n, 3)) at the coordinates (Å) from the Model Chemistry’s engine; also sets the working configuration’s coordinates and records the step for the convergence table and graph.

optimize(P, PP)[source]#

Optimize the structure to a minimum or transition state

Parameters:
  • P (dict(str, value)) – The control parameters

  • PP (dict(str, value)) – The printable control parameters

plot(E_units='', F_units='')[source]#

Generate a plot of the convergence of the geometry optimization.

run()[source]#

Run a Structure step.

Parameters:

None

Returns:

The next node object in the flowchart.

Return type:

seamm.Node

run_seamm_optimizer(P, PP)[source]#

Optimize with seamm_optimizer over the flowchart’s Model Chemistry (a warm MDI engine), with a model or cheap-level Hessian.

set_id(node_id=())[source]#

Sequentially number the subnodes

set_subids(node_id=())[source]#

Set the ids of the nodes in the subflowchart

property version#

The semantic version of this module.

structure_step.structure_parameters module#

Control parameters for the Structure step in a SEAMM flowchart

class structure_step.structure_parameters.StructureParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for Structure.

You need to replace the “time” entry in dictionary below these comments with the definitions of parameters to control this step. The keys are parameters for the current plugin,the values are dictionaries as outlined below.

Examples

parameters = {
    "time": {
        "default": 100.0,
        "kind": "float",
        "default_units": "ps",
        "enumeration": tuple(),
        "format_string": ".1f",
        "description": "Simulation time:",
        "help_text": ("The time to simulate in the dynamics run.")
    },
}
parameters{str: {str: str}}

A dictionary containing the parameters for the current step. Each key of the dictionary is a dictionary that contains the the following keys:

parameters[“default”] :

The default value of the parameter, used to reset it.

parameters[“kind”]enum()

Specifies the kind of a variable. One of “integer”, “float”, “string”, “boolean”, or “enum”

While the “kind” of a variable might be a numeric value, it may still have enumerated custom values meaningful to the user. For instance, if the parameter is a convergence criterion for an optimizer, custom values like “normal”, “precise”, etc, might be adequate. In addition, any parameter can be set to a variable of expression, indicated by having “$” as the first character in the field. For example, $OPTIMIZER_CONV.

parameters[“default_units”]str

The default units, used for resetting the value.

parameters[“enumeration”]tuple

A tuple of enumerated values.

parameters[“format_string”]str

A format string for “pretty” output.

parameters[“description”]str

A short string used as a prompt in the GUI.

parameters[“help_text”]str

A longer string to display as help for the user.

See also

Structure, TkStructure, Structure, StructureStep

parameters = {'Energy change criterion': {'default': 1e-06, 'default_units': 'E_h', 'description': 'Energy:', 'enumeration': (), 'format_string': '.g', 'help_text': 'The criterion for the change of the energy between steps.', 'kind': 'float'}, 'Maximum atomic gradient criterion': {'default': 0.00045, 'default_units': 'E_h/a_0', 'description': 'Maximum atomic gradient:', 'enumeration': (), 'format_string': '.g', 'help_text': 'The criterion for the maximum gradient of an atom.', 'kind': 'float'}, 'Maximum atomic step criterion': {'default': 0.00045, 'default_units': 'Å', 'description': 'Maximum atomic step:', 'enumeration': (), 'format_string': '.g', 'help_text': 'The criterion for the maximum displacement of an atom between steps.', 'kind': 'float'}, 'RMS gradient criterion': {'default': 0.0003, 'default_units': 'E_h/a_0', 'description': 'RMS gradient:', 'enumeration': (), 'format_string': '.g', 'help_text': 'The criterion for the RMS gradient.', 'kind': 'float'}, 'RMS step criterion': {'default': 0.0003, 'default_units': 'Å', 'description': 'RMS step:', 'enumeration': (), 'format_string': '.g', 'help_text': 'The criterion for the RMS displacement between steps.', 'kind': 'float'}, 'approach': {'default': 'Optimization', 'default_units': '', 'description': 'Approach:', 'enumeration': ('Optimization',), 'format_string': '', 'help_text': 'The approach or method for determining the structure.', 'kind': 'enum'}, 'calculate hessian': {'default': 'never', 'default_units': '', 'description': 'Recalculate Hessian:', 'enumeration': ('never', 'first', 'each', 'first+last'), 'format_string': '', 'help_text': 'How often to recalculate the Hessian.', 'kind': 'enum'}, 'cheap level': {'default': 'none', 'default_units': '', 'description': 'Cheap level for Hessians:', 'enumeration': ('none', 'xTB:SQM@GFN2-xTB', 'MOPAC:SQM@PM7'), 'format_string': '', 'help_text': "The SEAMM optimizer: a cheap model chemistry whose Hessian starts the optimization, is recomputed when the model keeps failing, and checks that the end point is a minimum. 'none' uses a model Hessian instead.", 'kind': 'string'}, 'check minimum': {'default': 'yes', 'default_units': '', 'description': 'Check the minimum:', 'enumeration': ('yes', 'no'), 'format_string': '', 'help_text': "The SEAMM optimizer: with a cheap level, check the end point's Hessian and, at a saddle point, displace along the imaginary mode both ways and optimize again.", 'kind': 'boolean'}, 'continue if not converged': {'default': 'no', 'default_units': '', 'description': 'Continue if not converged:', 'enumeration': ('yes', 'no'), 'format_string': '', 'help_text': 'Whether to stop if the optimizer does not converge.', 'kind': 'boolean'}, 'convergence': {'default': 'Gaussian', 'default_units': '', 'description': 'Convergence criterion:', 'enumeration': ('custom', 'ASE', 'Gaussian (loose)', 'Gaussian', 'Gaussian (tight)', 'Gaussian (very tight)', 'Inter-fragment (tight)', 'MolPro', 'NWChem (loose)', 'NWChem', 'NWChem (tight)', 'QChem', 'Turbomole'), 'format_string': 's', 'help_text': 'The criterion for convergence of the optimizer.', 'kind': 'enum'}, 'convergence formula': {'default': '', 'default_units': '', 'description': 'Convergence formula:', 'enumeration': (), 'format_string': 's', 'help_text': 'The formula of the criteria for convergence.', 'kind': 'enum'}, 'coordinate system': {'default': 'TRIC: translation-rotation internal coordinates', 'default_units': '', 'description': 'The coordinate system to use:', 'enumeration': ('TRIC: translation-rotation internal coordinates', 'TRIC-p: primitive (redundant) TRIC', 'Cart: Cartesian coordinates', 'DLC: delocalized internal coordinates', 'HDLC: hybrid delocalized internal coordinates'), 'format_string': '', 'help_text': 'The coordinates system to use in the calculation.', 'kind': 'integer'}, 'engine': {'default': 'Model Chemistry', 'default_units': '', 'description': 'Energies and gradients from:', 'enumeration': ('Model Chemistry', 'subflowchart'), 'format_string': '', 'help_text': "The flowchart's Model Chemistry, run as a warm engine over MDI (or as a separate calculation per step when the program has no engine here), or this step's subflowchart, run once per step. The SEAMM optimizer always uses the Model Chemistry.", 'kind': 'enum'}, 'max steps': {'default': '12 * natoms', 'default_units': '', 'description': 'Maximum # of steps:', 'enumeration': ('6 * natoms', '12 * natoms', '18 * natoms'), 'format_string': '', 'help_text': 'The maximum number of steps to take.', 'kind': 'integer'}, 'max stereoisomers': {'default': 1024, 'default_units': '', 'description': 'Maximum # of stereoisomers:', 'enumeration': (), 'format_string': '', 'help_text': 'The maximum number of stereoisomers to keep.', 'kind': 'integer'}, 'model hessian': {'default': 'Lindh', 'default_units': '', 'description': 'Model Hessian:', 'enumeration': ('Lindh', 'geomeTRIC guess'), 'format_string': '', 'help_text': "The SEAMM optimizer's starting Hessian when there is no cheap level: Lindh's model (1995) or geomeTRIC's guess.", 'kind': 'enumeration'}, 'on error': {'default': 'keep all subdirectories', 'default_units': '', 'description': 'On error:', 'enumeration': ('keep last subdirectory', 'keep all subdirectories', 'delete all subdirectories'), 'format_string': '', 'help_text': 'Which subdirectories to keep if there is an error.', 'kind': 'enum'}, 'on success': {'default': 'keep last subdirectory', 'default_units': '', 'description': 'On success:', 'enumeration': ('keep last subdirectory', 'keep all subdirectories', 'delete all subdirectories'), 'format_string': '', 'help_text': 'Which subdirectories to keep.', 'kind': 'enum'}, 'optimizer': {'default': 'geomeTRIC/geomeTRIC', 'default_units': '', 'description': 'Method:', 'enumeration': (), 'format_string': '', 'help_text': 'The optimizer to use.', 'kind': 'enum'}, 'results': {'default': {}, 'default_units': None, 'description': 'results', 'enumeration': (), 'format_string': '', 'help_text': 'The results to save to variables or in tables.', 'kind': 'dictionary'}, 'target': {'default': 'minimum', 'default_units': '', 'description': 'Target:', 'enumeration': ('minimum', 'transition state', 'stereoisomers'), 'format_string': '', 'help_text': 'The type of structure that is the target.', 'kind': 'enum'}}#

structure_step.structure_step module#

class structure_step.structure_step.StructureStep(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 Structure 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:

Structure

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:

TkStructure

description()[source]#

Return a description of what this step does.

Returns:

description

Return type:

dict(str, str)

my_description = {'description': 'An interface for predicting structures', 'group': 'Properties', 'name': 'Structure'}#

structure_step.tk_structure module#

The graphical part of a Structure step

class structure_step.tk_structure.TkStructure(tk_flowchart=None, node=None, namespace='org.molssi.seamm.tk', canvas=None, x=None, y=None, w=200, h=50)[source]#

Bases: TkNode

The graphical part of a Structure 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 Structure_parameters.py

Type:

dict

See also

Structure, TkStructure, StructureParameters

create_dialog()[source]#

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

Parameters:

None

Return type:

None

energy_source_text()[source]#

Where the optimization’s energy and gradients come from, as chosen (‘Energies and gradients from:’), and what is missing.

Returns:

The text for the dialog (”” when there is nothing to say), whether it works as chosen, whether the subflowchart (the Flowchart tab) is used, and whether the choice applies (not for the SEAMM optimizer, which uses only the Model Chemistry, nor when nothing is optimized).

Return type:

(str, bool, bool, bool)

reset_dialog(widget=None)[source]#

Layout the widgets in the dialog.

The widgets are chosen by default from the information in Diffusivity parameters.

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

See also

TkDiffusivity.create_dialog

reset_structure_frame(widget=None)[source]#

Layout the widgets in the structure frame as needed for the current state

reset_structure_handling_frame(widget=None)[source]#

Layout the widgets in the structure hadnling frame as needed for the current state

right_click(event)[source]#

Handles the right click event on the node.

Parameters:

event (Tk Event)

Return type:

None

See also

TkStructure.edit

Module contents#

structure_step A SEAMM plug-in for energy optimized structures