diffusivity_step package#

Submodules#

diffusivity_step.diffusivity module#

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

The self-diffusion coefficients of the species in a fluid, from the mean square displacement (MSD) of the molecules’ centres of mass, from their single-molecule Helfand moments (the square of the integral of the velocity), or from both, with the Yeh-Hummer correction for the size of the periodic cell.

The MD is run before this step – in a Loop for independent runs – or read from files; the step analyzes it.

diffusivity_step.diffusivity.A2_PER_PS = 1e-08#

Ų/ps in m²/s

diffusivity_step.diffusivity.CHUNK = 100#

The number of frames read at a time when computing centres of mass

diffusivity_step.diffusivity.DIRECTIONS = ('x', 'y', 'z')#

The directions

class diffusivity_step.diffusivity.Diffusivity(flowchart=None, title='Diffusivity', extension=None, logger=<Logger diffusivity_step.diffusivity (WARNING)>)[source]#

Bases: Node

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

parameters#

The control parameters for Diffusivity.

Type:

DiffusivityParameters

paths#

The md.h5md file of each run analyzed.

Type:

[pathlib.Path]

See also

TkDiffusivity, DiffusivityParameters

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

Analyze, print, plot and store the diffusion coefficients.

Parameters:
  • indent (str) – An extra indentation for the output.

  • P (dict) – The values of the parameters.

  • configuration (molsystem._Configuration) – The structure that was simulated.

check_configuration(configuration)[source]#

Called by an MD step before it runs MD that this step will analyze.

Returns:

Warnings about the structure, e.g. that it is small.

Return type:

[str]

Raises:

RuntimeError – If the system is not periodic.

check_flowchart(preceding)[source]#

Check, before the job runs, that the MD will sample what is needed and is set up for the analysis.

Parameters:

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

Returns:

A description of each problem; empty if none.

Return type:

[str]

create_parser()[source]#

Setup the command-line / config file parser

description_text(P=None, short=False)[source]#

Create the text description of what this step will do.

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

  • short (bool) – Not used: the description is always short.

Returns:

A description of the current step.

Return type:

str

property git_revision#

The git version of this module.

md_requirements(P=None)[source]#

What the analysis needs from the MD.

Parameters:

P (dict = None) – The parameters, as values; by default the current ones.

Return type:

seamm_md_analysis.Requirements

run()[source]#

Run the diffusivity step.

Returns:

The next node object in the flowchart.

Return type:

seamm.Node

static species(configuration)[source]#

The molecules of each species.

Returns:

{str – The molecules (0-based) of each species, by canonical SMILES, in the order of find_molecules.

Return type:

[int]}

property version#

The semantic version of this module.

diffusivity_step.diffusivity.METHODS = {'HM': 'Helfand moments', 'MSD': 'MSD', 'both': 'Combined'}#

The name of each method in the output

diffusivity_step.diffusivity.MIN_FRAMES = 10#

The fewest frames of a block of a single run

diffusivity_step.diffusivity.SUFFIX = {'HM': ' (HM)', 'MSD': ' (MSD)', 'both': ''}#

The suffix of each method’s results; the best estimate has none

diffusivity_step.diffusivity.power_of_ten(exponent)[source]#

10 to an integer power, as text, e.g. “10⁻⁹”.

diffusivity_step.diffusivity_parameters module#

Control parameters for the Diffusivity step in a SEAMM flowchart

class diffusivity_step.diffusivity_parameters.DiffusivityParameters(defaults={}, data=None)[source]#

Bases: Parameters

The control parameters for Diffusivity.

The MD to analyze is run earlier in the flowchart – in a Loop for independent runs – or in other jobs (see seamm_md_analysis.step_support.source_parameters). 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

Diffusivity, TkDiffusivity, Diffusivity, DiffusivityStep

parameters = {'approach': {'default': 'both', 'default_units': '', 'description': 'Approach:', 'enumeration': ('both', 'Helfand moments', 'Mean Square Displacement (MSD)'), 'format_string': '', 'help_text': 'The approach or method for determining the diffusivity.', 'kind': 'enum'}, 'helfand_fit_end': {'applies_when': {'approach': ('both', 'Helfand moments')}, 'default': '1.00', 'default_units': '', 'description': 'End point of Helfand fit (0.0..1.0):', 'enumeration': (), 'format_string': '', 'help_text': 'End point of Helfand fit this far into the data.', 'kind': 'float'}, 'helfand_fit_start': {'applies_when': {'approach': ('both', 'Helfand moments')}, 'default': '0.35', 'default_units': '', 'description': 'Start point of Helfand fit (0.0..1.0):', 'enumeration': (), 'format_string': '', 'help_text': 'Starting point of Helfand fit this far into the data.', 'kind': 'float'}, 'hydrodynamic correction': {'default': 'yes', 'description': 'Correction for cell size:', 'enumeration': ('no', 'yes'), 'format_string': 's', 'help_text': 'Apply the Yeh-Hummer hydrodynamic correction for the cell size, which needs the viscosity.', 'kind': 'boolean'}, 'maximum Helfand Integral length': {'applies_when': {'approach': ('both', 'Helfand moments')}, 'default': 1000, 'default_units': '', 'description': 'Maximum Helfand Integral length:', 'enumeration': (), 'format_string': '', 'help_text': 'Maximum length of the Integral used in the Helfand moments.', 'kind': 'integer'}, 'md files': {'applies_when': {'md source': 'files'}, 'default': '', 'default_units': '', 'description': 'H5MD files:', 'enumeration': (), 'format_string': 's', 'help_text': 'The md.h5md files to analyze, separated by spaces or commas. Each is an independent run. A relative path is in this job; job://<n>/<path> is in job n.', 'kind': 'string'}, 'md source': {'default': 'the last MD run of each loop iteration', 'default_units': '', 'description': 'MD to analyze:', 'enumeration': ('the last MD run', 'the last MD run of each loop iteration', 'files'), 'format_string': 's', 'help_text': "Where the MD for the diffusivity comes from: the last MD run of each iteration of the loop around the MD, as independent runs (or the one run, without a loop); the last MD run earlier in the flowchart; or the H5MD files (md.h5md) of earlier runs, including other jobs' (job://<n>/<path>).", 'kind': 'enum'}, 'msd_fit_end': {'applies_when': {'approach': ('both', 'Mean Square Displacement (MSD)')}, 'default': '0.6', 'default_units': '', 'description': 'End point of MSD fit (0.0..1.0):', 'enumeration': (), 'format_string': '', 'help_text': 'End point of fit the MSD this far into the data.', 'kind': 'float'}, 'msd_fit_start': {'applies_when': {'approach': ('both', 'Mean Square Displacement (MSD)')}, 'default': '0.1', 'default_units': '', 'description': 'Start point of MSD fit (0.0..1.0):', 'enumeration': (), 'format_string': '', 'help_text': 'Starting point of fit the MSD this far into the data.', 'kind': 'float'}, 'number of blocks': {'default': 5, 'default_units': '', 'description': 'Blocks for errors from one run:', 'enumeration': (), 'format_string': 'd', 'help_text': 'When a single MD run is analyzed, it is divided into this many consecutive blocks, which are analyzed separately to estimate the errors. Each block must be much longer than the correlation time.', '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'}, 'viscosity': {'applies_when': {'viscosity source': 'given value'}, 'default': '0.0', 'default_units': 'cP', 'description': 'Viscosity:', 'enumeration': (), 'format_string': '', 'help_text': 'The viscosity for the Yeh-Hummer cell size correction.', 'kind': 'float'}, 'viscosity source': {'applies_when': {'hydrodynamic correction': 'yes'}, 'default': 'the preceding Viscosity step', 'default_units': '', 'description': 'Viscosity from:', 'enumeration': ('the preceding Viscosity step', 'given value'), 'format_string': 's', 'help_text': 'Where the viscosity for the Yeh-Hummer correction comes from: the last Viscosity step run before this one, or a value given here. If there is no Viscosity step, the correction is skipped with a note.', 'kind': 'enum'}}#
retired = ('nruns', 'errors')#

an older flowchart that stores them can still be read, and they are ignored. Any other unknown parameter is an error. A plug-in’s Parameters class sets this.

Type:

Parameters the step had once and has dropped

diffusivity_step.diffusivity_step module#

class diffusivity_step.diffusivity_step.DiffusivityStep(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 Diffusivity 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 or extension, representing the title displayed in the flowchart and the extension, respectively.

Return type:

Diffusivity

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:

TkDiffusivity

description()[source]#

Return a description of what this step does.

Returns:

description

Return type:

dict(str, str)

my_description = {'description': 'An interface for Diffusivity', 'group': 'Properties', 'name': 'Diffusivity'}#

diffusivity_step.metadata module#

This file contains metadata describing the results from Diffusivity

diffusivity_step.metadata.metadata = {'results': {'1/L': {'description': '1/length of cell in the diffusion calculation', 'dimensionality': 'scalar', 'type': 'float', 'units': '1/Å'}, '1/L,stderr': {'description': 'Standard error if 1/length of cell in the diffusion calculation', 'dimensionality': 'scalar', 'type': 'float', 'units': '1/Å'}, 'D (box) {key}': {'description': 'The total diffusion coefficient in the periodic cell, without the correction for its size', 'dimensionality': '{species: value}', 'property': 'D (box)#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D (box) {key},stderr': {'description': 'The standard error of the total diffusion coefficient in the periodic cell', 'dimensionality': '{species: value}', 'property': 'D (box),stderr#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D {key}': {'description': 'The total diffusion coefficient, corrected for the size of the cell if the correction is applied', 'dimensionality': '{species: value}', 'property': 'D#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D {key} (HM)': {'description': 'The total diffusion coefficient from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'D#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D {key} (HM),stderr': {'description': 'The standard error of the total diffusion coefficient from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'D,stderr#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D {key} (MSD)': {'description': 'The total diffusion coefficient from MSD', 'dimensionality': '{species: value}', 'property': 'D#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D {key} (MSD),stderr': {'description': 'The standard error of the total diffusion coefficient from MSD', 'dimensionality': '{species: value}', 'property': 'D,stderr#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'D {key},stderr': {'description': 'The standard error of the total diffusion coefficient', 'dimensionality': '{species: value}', 'property': 'D,stderr#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dx {key}': {'description': 'The diffusion coefficient in x', 'dimensionality': '{species: value}', 'property': 'Dx#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dx {key} (HM)': {'description': 'The diffusion coefficient in x from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'Dx#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dx {key} (HM),stderr': {'description': 'The standard error of the diffusion coefficient in x from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'Dx,stderr#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dx {key} (MSD)': {'description': 'The diffusion coefficient in x from MSD', 'dimensionality': '{species: value}', 'property': 'Dx#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dx {key} (MSD),stderr': {'description': 'The standard error of the diffusion coefficient in x from MSD', 'dimensionality': '{species: value}', 'property': 'Dx,stderr#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dx {key},stderr': {'description': 'The standard error of the diffusion coefficient in x', 'dimensionality': '{species: value}', 'property': 'Dx,stderr#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dy {key}': {'description': 'The diffusion coefficient in y', 'dimensionality': '{species: value}', 'property': 'Dy#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dy {key} (HM)': {'description': 'The diffusion coefficient in y from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'Dy#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dy {key} (HM),stderr': {'description': 'The standard error of the diffusion coefficient in y from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'Dy,stderr#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dy {key} (MSD)': {'description': 'The diffusion coefficient in y from MSD', 'dimensionality': '{species: value}', 'property': 'Dy#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dy {key} (MSD),stderr': {'description': 'The standard error of the diffusion coefficient in y from MSD', 'dimensionality': '{species: value}', 'property': 'Dy,stderr#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dy {key},stderr': {'description': 'The standard error of the diffusion coefficient in y', 'dimensionality': '{species: value}', 'property': 'Dy,stderr#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dz {key}': {'description': 'The diffusion coefficient in z', 'dimensionality': '{species: value}', 'property': 'Dz#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dz {key} (HM)': {'description': 'The diffusion coefficient in z from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'Dz#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dz {key} (HM),stderr': {'description': 'The standard error of the diffusion coefficient in z from Helfand Moments', 'dimensionality': '{species: value}', 'property': 'Dz,stderr#Helfand Moments#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dz {key} (MSD)': {'description': 'The diffusion coefficient in z from MSD', 'dimensionality': '{species: value}', 'property': 'Dz#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dz {key} (MSD),stderr': {'description': 'The standard error of the diffusion coefficient in z from MSD', 'dimensionality': '{species: value}', 'property': 'Dz,stderr#MSD#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Dz {key},stderr': {'description': 'The standard error of the diffusion coefficient in z', 'dimensionality': '{species: value}', 'property': 'Dz,stderr#{model}', 'type': 'json', 'units': 'm^2/s'}, 'Helfand integral length': {'description': 'The length of the Helfand numerical integration', 'dimensionality': 'scalar', 'type': 'integer'}, 'P': {'description': 'The mean pressure', 'dimensionality': 'scalar', 'type': 'float', 'units': 'atm'}, 'P,stderr': {'description': 'The standard error of the pressure', 'dimensionality': 'scalar', 'type': 'float', 'units': 'atm'}, 'T': {'description': 'The mean temperature', 'dimensionality': 'scalar', 'type': 'float', 'units': 'K'}, 'T,stderr': {'description': 'The standard error of the temperature', 'dimensionality': 'scalar', 'type': 'float', 'units': 'K'}, 'V': {'description': 'The mean volume', 'dimensionality': 'scalar', 'type': 'float', 'units': 'Å^3'}, 'Yeh-Hummer correction': {'description': 'The Yeh-Hummer correction for the size of the cell, added to the diffusion coefficients', 'dimensionality': 'scalar', 'type': 'float', 'units': 'm^2/s'}, 'Yeh-Hummer correction,stderr': {'description': 'The standard error of the Yeh-Hummer correction, from that of the viscosity', 'dimensionality': 'scalar', 'type': 'float', 'units': 'm^2/s'}, 'approach': {'description': 'Algorithm for diffusion calculation', 'dimensionality': 'scalar', 'type': 'string'}, 'bulk modulus': {'description': 'The bulk modulus used for the equilibrium density, from an NPT run', 'dimensionality': 'scalar', 'type': 'float', 'units': 'atm'}, 'density': {'description': 'The mean density', 'dimensionality': 'scalar', 'type': 'float', 'units': 'g/mL'}, 'density,stderr': {'description': 'The standard error of the density', 'dimensionality': 'scalar', 'type': 'float', 'units': 'g/mL'}, 'equilibrium density': {'description': 'The estimated density at the target pressure of runs at constant volume', 'dimensionality': 'scalar', 'type': 'float', 'units': 'g/mL'}, 'equilibrium density,stderr': {'description': 'The standard error of the estimated equilibrium density', 'dimensionality': 'scalar', 'type': 'float', 'units': 'g/mL'}, 'helfand_fit_end': {'description': 'Where to end the fit of the Helfand moments curve', 'dimensionality': 'scalar', 'type': 'float'}, 'helfand_fit_start': {'description': 'Where to start the fit of the Helfand moments curve', 'dimensionality': 'scalar', 'type': 'float'}, 'msd samples': {'description': 'Number of samples to take for the MSD calculation', 'dimensionality': 'scalar', 'type': 'float'}, 'msd_fit_end': {'description': 'Where to end the fit of the MSD curve', 'dimensionality': 'scalar', 'type': 'float'}, 'msd_fit_start': {'description': 'Where to start the fit of the MSD curve', 'dimensionality': 'scalar', 'type': 'float'}, 'nruns': {'description': 'The number of MD runs analyzed', 'dimensionality': 'scalar', 'type': 'integer'}, 't_hm': {'description': 'The time taken in the Helfand moments analysis', 'dimensionality': 'scalar', 'type': 'float', 'units': 's'}, 't_msd': {'description': 'The time taken in the MSD analysis', 'dimensionality': 'scalar', 'type': 'float', 'units': 's'}, 'viscosity for correction': {'description': 'The viscosity used in the Yeh-Hummer correction', 'dimensionality': 'scalar', 'type': 'float', 'units': 'mPa*s'}}}#

Description of the computational models for Diffusivity.

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

diffusivity_step.tk_diffusivity module#

The graphical part of a Diffusivity step

class diffusivity_step.tk_diffusivity.TkDiffusivity(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 Diffusivity 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

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 Diffusivity_parameters.py

Type:

dict

See also

Diffusivity, TkDiffusivity, DiffusivityParameters

create_dialog()[source]#

Create the dialog, with the widgets for the parameters.

reset_dialog(widget=None)[source]#

Lay out the widgets that apply, given the choices made.

Parameters:

widget (Tk Widget = None)

right_click(event)[source]#

Handles the right click event on the node.

Parameters:

event (Tk Event)

Return type:

None

See also

TkDiffusivity.edit

Module contents#

diffusivity_step A SEAMM plug-in for Diffusivity