forcefield_step package#
Submodules#
forcefield_step.forcefield module#
A node or step for the forcefield in a flowchart
- class forcefield_step.forcefield.Forcefield(flowchart=None, extension=None, logger=<Logger forcefield_step.forcefield (WARNING)>)[source]#
Bases:
Node- assign_forcefield(P=None, configuration=None)[source]#
Assign the forcefield to the structure, i.e. find the atom types and charges.
- Parameters:
P ({str: Any}) – The final values of the parameters.
- Return type:
None
- checkpoint_variable(name, value)[source]#
Save the forcefield in the checkpoint as its file and name.
- description_text(P=None)[source]#
Return a short description of this step.
Return a nicely formatted string describing what this step will do.
- Keyword Arguments:
P – a dictionary of parameter values, which may be variables or final values. If None, then the parameters values will be used as is.
- property files#
The files in the forcefield … (short name & full path)
- forcefield_names(ff_file)[source]#
The forcefields defined in a forcefield file and the files it includes.
- Parameters:
ff_file (str) – The forcefield file, as given in “forcefield_file”, e.g. “oplsaa.frc” or “local:OPLS-AA/my_oplsaa.frc”.
- Returns:
The names in the “#define” lines, in order, or [] if the file cannot be found or is not a forcefield file with definitions, e.g. OpenKIM.
- Return type:
[str]
- property git_revision#
The git version of this module.
- setup_forcefield(P=None)[source]#
Setup the forcefield for later use.
- Parameters:
P ({str: Any}) – The final values of the parameters.
- Return type:
None
- uri_handler(path)[source]#
Return the actual file given a path that may have a uri.
- Parameters:
path (str or pathlib.Path) – The filename or uri for the file.
- Returns:
path – The full path to the file
- Return type:
pathlib.Path
Note
Forcefields can be in one of 3 locations:
In the data directory of this Python package. This is where the standard forcefields are stored.
In the SEAMM installation, under <root>/data/Forcefields, and then in the default installation’s ~/SEAMM/data/Forcefields. This allows a site to add or customize forcefields for all users. The user for the SEAMM installation may not be the same as the user running the code! So ‘~/’ may reference a different directory than the next item.
In the users directory at ~/seamm.d/data/Forcefields. This allows the user to add or override any existing forcefield.
When a forcefield is referenced, if it has no URI it is assumed to be in (1), the default location for forcefields shipped with the release.
If it has a URI, i.e. the path starts with ‘local:’, the code searches for it first in the users local data (3). If it is not found, the search continues in site location (2).
Jobs executed by the JobServer are handled a bit differently, because the site and home directories may not exist or may be different on the machine that the JobServer is running on. When a job is submitted to the Dashboard, the code locates the forcefields on the local machine, as outlined above. It then sends copies to the data/Forcefields directory of the job. The path for the job’s data/ directory is changed to its local data/ directory, so the copies sent with the job are used.
- property version#
The semantic version of this module.
forcefield_step.forcefield_parameters module#
Control parameters for using forcefields
- class forcefield_step.forcefield_parameters.ForcefieldParameters(defaults={}, data=None)[source]#
Bases:
ParametersThe control parameters for forcefields
- parameters = {'elements': {'default': '', 'default_units': None, 'description': 'Elements:', 'enumeration': None, 'format_string': '', 'help_text': 'The elements to include.', 'kind': 'periodic table'}, 'forcefield': {'default': 'default', 'default_units': '', 'description': 'Forcefield:', 'enumeration': ('default',), 'format_string': 's', 'help_text': "The forcefield in the file to use, e.g. oplsaa+ or oplsaa+-spc_e in oplsaa.frc, or 'default' for the first one in the file.", 'kind': 'string'}, 'forcefield_file': {'default': 'oplsaa.frc', 'default_units': '', 'description': 'Forcefield Repository:', 'enumeration': (), 'format_string': 's', 'help_text': 'The forcefield repository or file to use.', 'kind': 'enumeration'}, 'potentials': {'default': '', 'default_units': '', 'description': 'Interatomic Potentials:', 'enumeration': ('will be replaced',), 'format_string': 's', 'help_text': 'The interatomic potentials to use.', 'kind': 'enumeration'}, 'task': {'default': 'setup forcefield', 'default_units': '', 'description': 'What to do:', 'enumeration': ('setup forcefield', 'assign forcefield to structure'), 'format_string': 's', 'help_text': 'What to do with the forcefield.', 'kind': 'enumeration'}}#
forcefield_step.forcefield_step module#
Helper class needed for the stevedore integration. Needs to provide a description() method that returns a dict containing a description of this node, and a factory() method for creating the graphical and non-graphical nodes.
- class forcefield_step.forcefield_step.ForcefieldStep(flowchart=None, gui=None)[source]#
Bases:
object- classmethod forcefield(model_chemistry, node=None)[source]#
The seamm_ff_util forcefield for a model chemistry from
get_model_chemistry_options().
- classmethod get_model_chemistry_options(periodic_only=False, mdi_only=False, data_path=None)[source]#
The forcefields in the .frc files the step can find, as model chemistries;
data_pathis a running flowchart’s data directories. Seeforcefield_step.model_chemistry.get_model_chemistry_options().
- classmethod model_chemistry_data_files(model_chemistry, node, local_only=True)[source]#
The local and personal files a job needs for the model chemistry.
- my_description = {'description': 'An interface for the setup and control of the forcefield', 'group': 'Simulations', 'name': 'Forcefield'}#
forcefield_step.ligpargen module#
- forcefield_step.ligpargen.add_to_ff(ff, configuration, data)[source]#
Adds the data to the forcefield file
This method adds the data from the .key file to the forcefield file.
- Parameters:
ff (list) – The list of strings that make up the forcefield file
configuration (Configuration) – The configuration object
data (dict) – The data read from the .key file
- Returns:
The updated forcefield file
- Return type:
str
- forcefield_step.ligpargen.check_fragment(configuration, data, smarts, match, types)[source]#
Check a fragment’s atom types against the molecule they describe.
A wrong ordering of the types is otherwise silent – it is a permutation, so the charges still sum to the molecular charge and nothing complains until the types are used, if then. These checks catch it at the point it is written.
- Parameters:
configuration (Configuration) – The configuration the .key file was generated for.
data (dict) – The data read from the .key file.
smarts (str) – The SMARTS for the fragment.
match (tuple(int)) – The configuration’s atom for each position of the SMARTS.
types ([str]) – The atom type for each position of the SMARTS.
- Raises:
ValueError – If the types do not describe the molecule.
- forcefield_step.ligpargen.key_atom_types(configuration, data)[source]#
Get the LigParGen atom type of each atom of the configuration.
LigParGen does not keep the order of the atoms it is given: it perceives the molecule afresh and orders it its own way. The
atomrecords of the .key file are therefore not in the configuration’s order, so they cannot simply be zipped together.LigParGen does, however, give every atom its own type, which means the
bondrecords – which are in terms of the types – are the molecular graph of its ordering. Matching that graph to the configuration’s gives the mapping exactly, with no reliance on the two orders agreeing.- Parameters:
configuration (Configuration) – The configuration the .key file was generated for.
data (dict) – The data read from the .key file.
- Returns:
The LigParGen atom type of each atom, in the configuration’s order.
- Return type:
[str]
- forcefield_step.ligpargen.reader(path)[source]#
Reads the .key file and returns the data
This method reads the .key file output by LigParGen and adds the parameters to the local SEAMM forcefield ligpargen.frc file.
- Parameters:
path (str or pathlib.Path) – The path to the .key or .xyz files
Note
The .key file is a text file that contains the forcefield parameters for Tinker. It looks like this:
############################## ## ## ## Force Field Definition ## ## ## ############################## forcefield OPLS-AA vdwindex TYPE vdwtype LENNARD-JONES radiusrule GEOMETRIC radiustype SIGMA radiussize DIAMETER epsilonrule GEOMETRIC torsionunit 1.0 imptorunit 1.0 vdw-14-scale 2.0 chg-14-scale 2.0 electric 332.06 dielectric 1.0 ############################# ## ## ## Atom Type Definitions ## ## ## ############################# atom 800 800 CT "C00" 6 12.011 4 atom 801 801 CZ "C01" 6 12.011 2 atom 802 802 NZ "N02" 7 14.007 1 atom 803 803 F "F03" 9 18.998 1 atom 804 804 HC "H04" 1 1.008 1 atom 805 805 HC "H05" 1 1.008 1 ################################ ## ## ## Van der Waals Parameters ## ## ## ################################ vdw 800 3.5000 0.0660 vdw 801 3.3000 0.0660 vdw 802 3.2000 0.1700 ...
- The interesting keys are:
atom: defines the atom types
vdw: defines the van der Waals parameters
bond: defines the bond parameters
angle: defines the angle parameters
torsion: defines the torsion parameters
imptors: defines the improper torsion parameters
charge: defines the charge parameters
forcefield_step.model_chemistry module#
The forcefields as model chemistries.
Every forcefield defined in a .frc file the step can find – the package’s,
the SEAMM installation’s (local:) and the user’s (personal:) – is offered
as a model chemistry: FF@<name> for a classical forcefield (FF@oplsaa+)
and ReaxFF@<parameter set> for a ReaxFF one, the names being those the
files define. The steps that use a forcefield
(LAMMPS, Packmol) build it from the model chemistry with forcefield().
See lammps_step’s campaign of 2026-10-11 (forcefields as model chemistries).
- forcefield_step.model_chemistry.RESERVED = ':@/|'#
Characters the model-chemistry grammar reserves
- forcefield_step.model_chemistry.TYPES = ('FF', 'ReaxFF')#
The model-chemistry types this package offers
- forcefield_step.model_chemistry.data_files(model_chemistry, node, local_only=True)[source]#
The files a job needs for a forcefield model chemistry, as the Forcefield step’s
list_data_files:[(uri, path)]of thelocal:andpersonal:file and its includes (and the package’s, unlesslocal_only).
- forcefield_step.model_chemistry.defined_forcefields(path)[source]#
The names of the forcefields a
.frcfile defines (#define), in order; the first is the file’s default.
- forcefield_step.model_chemistry.forcefield(model_chemistry, node=None)[source]#
The seamm_ff_util forcefield for a model chemistry, ready to use.
- Parameters:
model_chemistry (dict) – The
_model_chemistrywrapper of anFForReaxFFmodel chemistry offered by this package.node (seamm.Node, optional) – The step using it: its data files (a job’s copies of
local:andpersonal:files) and its references, which get the forcefield’s citations.
- Return type:
seamm_ff_util.Forcefield
- forcefield_step.model_chemistry.forcefield_files(root=None, data_path=None)[source]#
[(spec, path)]of the.frcfiles, the user’s first.specis what the Forcefield step calls the file:personal:<path>orlocal:<path>relative to its directory, or the path within the package’s data directory. Files that another.frcfile includes (#include) are left out: they are parts of that forcefield – e.g.oplsaa.frcincludeslocal:OPLS-AA/ligpargen.frc, whose parameters extendoplsaa+– not forcefields of their own.
- forcefield_step.model_chemistry.get_model_chemistry_options(periodic_only=False, mdi_only=False, root=None, data_path=None)[source]#
The forcefields as model chemistries.
- Parameters:
periodic_only (bool) – Only those that handle periodic systems – all of them.
mdi_only (bool) – Only those launchable as MDI engines – none: LAMMPS evaluates the forcefield itself.
root (str or Path, optional) – The SEAMM installation; the current one by default.
data_path ([Path], optional) – A flowchart’s data directories (
Node.data_path) to search instead of the default ones: in a job, its own copies of the files sent with it.
- Returns:
Keyed by the model chemistry (
FF@oplsaa+). Each entry hasmodel_chemistry,type,description,file(the file as the Forcefield step names it),path,forcefield(the name in the file),source(personal,localorpackage),periodic_native,periodic_mdiandmdi_capable. A user’s forcefield of the same name as a bundled one is offered instead of it.- Return type:
dict
- forcefield_step.model_chemistry.included_files(path)[source]#
What a
.frcfile includes, as(where, relative path):localforlocal:files (the user’s and the installation’s data directories), elsepackage.
- forcefield_step.model_chemistry.package_directory()[source]#
The directory of the forcefields shipped with this package.
- forcefield_step.model_chemistry.source_directories(root=None, data_path=None)[source]#
[(source, directory)]searched for.frcfiles, in order.personalis~/.seamm.d/data/Forcefields;localthe installation’s<root>/data/Forcefieldsand then the default installation’s~/SEAMM/data/Forcefields. Given a flowchart’sdata_path, theForcefieldsdirectory in each of its directories instead – in a job this starts with the job’s own copies of the files sent with it.
forcefield_step.tk_forcefield module#
The graphical part of a Forcefield step
- class forcefield_step.tk_forcefield.TkForcefield(tk_flowchart=None, node=None, canvas=None, x=None, y=None, w=200, h=50)[source]#
Bases:
TkNodeThe graphical part of a forcefield step
Module contents#
forcefield_step A step for choosing the default forcefield.