Data Structures in GMSO

Following data structures are available within GMSO.

Core Classes

Topology

class gmso.Topology(name='Topology', box=None)[source]

A topology.

A topology represents a chemical structure wherein lie the collection of sites which together form a chemical structure containing connections (gmso.Bond, gmso.Angle and gmso.Dihedral (along with their associated types). A topology is the fundamental data structure in GMSO, from which we can gather various information about the chemical structure and apply a forcefield before converting the structure into a format familiar to various simulation engines.

Parameters:
  • name (str, optional, default=’Topology’) – A name for the Topology.
  • box (gmso.Box, optional, default=None) – A gmso.Box object bounding the topology
Variables:
  • typed (bool) – True if the topology is typed
  • combining_rule (str, ['lorentz', 'geometric']) – The combining rule for the topology, can be either ‘lorentz’ or ‘geometric’
  • n_sites (int) – Number of sites in the topology
  • n_connections (int) – Number of connections in the topology (Bonds, Angles, Dihedrals, Impropers)
  • n_bonds (int) – Number of bonds in the topology
  • n_angles (int) – Number of angles in the topology
  • n_dihedrals (int) – Number of dihedrals in the topology
  • n_impropers (int) – Number of impropers in the topology
  • n_subtops (int) – Number of subtopolgies in the topology
  • connections (tuple of gmso.Connection objects) – A collection of bonds, angles, dihedrals, and impropers in the topology
  • bonds (tuple of gmso.Bond objects) – A collection of bonds in the topology
  • angles (tuple of gmso.Angle objects) – A collection of angles in the topology
  • dihedrals (tuple of gmso.Dihedral objects) – A collection of dihedrals in the topology
  • impropers (tuple of gmso.Improper objects) – A collection of impropers in the topology
  • connection_types (tuple of gmso.Potential objects) – A collection of BondTypes, AngleTypes, DihedralTypes, and ImproperTypes in the topology
  • atom_types (tuple of gmso.AtomType objects) – A collection of AtomTypes in the topology
  • bond_types (tuple of gmso.BondType objects) – A collection of BondTypes in the topology
  • angle_types (tuple of gmso.AngleType objects) – A collection go AngleTypes in the topology
  • dihedral_types (tuple of gmso.DihedralType objects) – A collection of DihedralTypes in the topology
  • improper_types (tuple of gmso.ImproperType objects) – A collection of ImproperTypes in the topology
  • atom_type_expressions (list of gmso.AtomType.expression objects) – A collection of all the expressions for the AtomTypes in topology
  • connection_type_expressions (list of gmso.Potential.expression objects) – A collection of all the expressions for the Potential objects in the topology that represent a connection type
  • bond_type_expressions (list of gmso.BondType.expression objects) – A collection of all the expressions for the BondTypes in topology
  • angle_type_expressions (list of gmso.AngleType.expression objects) – A collection of all the expressions for the AngleTypes in topology
  • dihedral_type_expressions (list of gmso.DihedralType.expression objects) – A collection of all the expression for the DihedralTypes in the topology
  • improper_type_expressions (list of gmso.ImproperType.expression objects) – A collection of all the expression for the ImproperTypes in the topology

See also

gmso.SubTopology
A topology within a topology
add_connection(connection, update_types=True)[source]

Add a gmso.Connection object to the topology.

This method will add a gmso.Connection object to the topology, it can be used to generically include any Connection object i.e. Bond or Angle or Dihedral to the topology. According to the type of object added, the equivalent collection in the topology is updated. For example- If you add a Bond, this method will update topology.connections and topology.bonds object. Additionally, if update_types is True (default behavior), it will also update any Potential objects associated with the connection.

Parameters:
  • connection (one of gmso.Connection, gmso.Bond, gmso.Angle, gmso.Dihedral, or gmso.Improper object)
  • update_types (bool, default=True) – If True also add any Potential object associated with connection to the topology.
add_site(site, update_types=True)[source]

Add a site to the topology

This method will add a site to the existing topology, since sites are stored in an indexed set, adding redundant site will have no effect. If the update_types parameter is set to true (default behavior), this method will also check if there is an gmso.AtomType associated with the site and it to the topology’s AtomTypes collection.

Parameters:
  • site (gmso.core.Site) – Site to be added to this topology
  • update_types ((bool), default=True) – If true, add this site’s atom type to the topology’s set of AtomTypes
add_subtopology(subtop)[source]

Add a sub-topology to this topology

This methods adds a gmso.Core.SubTopology object to the topology All the sites in this sub-topology are added to the collection of current sites in this topology.

Parameters:subtop (gmso.SubTopology) – The sub-topology object to be added.

See also

gmso.SubTopology()
A topology within a topology
get_index(member)[source]

Get index of a member in the topology

Parameters:member (gmso Topology objects) – The member to for which to return index for. member can be of type gmso.Site, gmso.Bond, gmso.Angle, gmso.Dihedral, gmso.Improper, gmso.AtomType, gmso.BondType, gmso.AngleType, gmso.DihedralType or gmso.ImproperType.
Returns:The index of the member in the topology’s collection objects
Return type:int
update_angle_types()[source]

Uses gmso.Topology.update_connection_types to update AngleTypes in the topology.

This method is an alias for gmso.Topology.update_connection_types.

See also

gmso.Topology.update_connection_types()
Update the connection types based on the connection collection in the topology.
update_angles(update_types=False)[source]

Uses gmso.Topology.update_connections to update angles in the topology.

This method is an alias for gmso.Topology.update_connections.

See also

gmso.Topology.update_connections()
Update all the Bonds, Angles, Dihedrals, and Impropers in the topology.
update_atom_types()[source]

Update atom types in the topology

This method checks all the sites in the topology which have an associated AtomType and if that AtomType is not in the topology’s AtomTypes collection, it will add it there.

gmso.Topology.update_connection_types :
Update the connection types based on the connection collection in the topology
update_bond_types()[source]

Uses gmso.Topology.update_connection_types to update BondTypes in the topology.

This method is an alias for gmso.Topology.update_connection_types.

See also

gmso.Topology.update_connection_types()
Update the connection types based on the connection collection in the topology.
update_bonds(update_types=False)[source]

Uses gmso.Topology.update_connections to update bonds in the topology.

This method is an alias for gmso.Topology.update_connections.

See also

gmso.Topology.update_connections()
Update all the Bonds, Angles, Dihedrals, and Impropers in the topology.
update_connection_types()[source]

Update the connection types based on the connection collection in the topology.

This method looks into all the connection objects (Bonds, Angles, Dihedrals, Impropers) to check if any Potential object (BondType, AngleType, DihedralType, ImproperType) is not in the topology’s respective collection and will add those objects there.

See also

gmso.Topology.update_atom_types()
Update atom types in the topology.
update_connections(update_types=False)[source]

Update the topology’s connections(bonds, angles, dihedrals, impropers) from its sites.

This method takes all the sites in the current topology and if any connection (Bond, Angle, Dihedral) is present in the site but not in the topology’s connection collection, this method will add to that collection. If update_types is True (default behavior is False), this method will also add the Potential objects(AtomType, BondType, AngleType, DihedralType) to the topology’s respective collection.

Parameters:update_types (bool, default=False)

See also

gmso.Topology.update_sites()
Update the sites in the topology to reflect any added connection’s sites
gmso.Topology.add_connection()
Add a Bond, an Angle or a Dihedral to the topology.
gmso.Topology.add_site()
Add a site to the topology.
gmso.Topology.update_connection_types()
Update the connection types based on the connection collection in the topology.
gmso.Topology.update_topology()
Update the entire topology.
update_dihedral_types()[source]

Uses gmso.Topology.update_connection_types to update DihedralTypes in the topology.

This method is an alias for gmso.Topology.update_connection_types.

See also

gmso.Topology.update_connection_types()
Update the connection types based on the connection collection in the topology.
update_dihedrals(update_types=False)[source]

Uses gmso.Topology.update_connections to update dihedrals in the topology.

This method is an alias for gmso.Topology.update_connections.

See also

gmso.Topology.update_connections()
Update all the Bonds, Angles, Dihedrals, and Impropers in the topology.
update_improper_types()[source]

Uses gmso.Topology.update_connection_types to update ImproperTypes in the topology.

This method is an alias for gmso.Topology.update_connection_types.

See also

gmso.Topology.update_connection_types()
Update the connection types based on the connection collection in the topology.
update_impropers(update_types=False)[source]

Uses gmso.Topology.update_connections to update impropers in the topology.

This method is an alias for gmso.Topology.update_connections.

See also

gmso.Topology.update_connections()
Update all the Bonds, Angles, Dihedrals, and Impropers in the topology.
update_sites()[source]

Update the sites of the topology.

This method will update the sites in the topology based on the connection members, For example- if you add a bond to a topology, without adding the constituent sites, this method can be called to add the sites which are the connection members of the bond as shown below.

>>> import gmso
>>> site1 = gmso.Site(name='MySite1')
>>> site2 = gmso.Site(name='MySite2')
>>> bond1 = gmso.Bond(name='site1-site2', connection_members=[site1, site2])
>>> this_topology = gmso.Topology('TwoSitesTopology')
>>> this_topology.add_connection(bond1)
>>> this_topology.update_sites()

See also

gmso.Topology.update_connections()
Update the connections in the topology to reflect any added sites connections
gmso.Topology.add_site()
Add a site to the topology.
gmso.Topology.add_connection()
Add a Bond, an Angle or a Dihedral to the topology.
gmso.Topology.update_topology()
Update the entire topology.
update_topology()[source]

Update the entire topology

SubTopology

class gmso.SubTopology(name='Sub-Topology', parent=None)[source]

A sub-topology i.e. topology within a topology

This class provides a hierarchical topological representation to the topology as it imperative with many chemical structures to have separation of layers/ boundaries. A sub-topology can be added to a gmso.Topology object which will be the parent of the sub-topology.

Parameters:
  • name (str, optional, default=’Sub-Topology’) – Name of the sub-topology
  • parent (gmso.Topology, optional, default=None) – The parent topology of this SubTopology
Variables:
  • sites (IndexedSet of gmso.Site objects) – Collection of sites within this sub-topology
  • n_sites (int) – Number of sites withing this sub-topology
add_site(site)[source]

Add a site to this sub-topology

This method adds a site to the sub-topology. If the sub-topology has a parent, the site will also be added to the parent topology.

Parameters:site (gmso.Site) – The site to be added to this sub-topology
Raises:TypeError – If the parameter site is not of type topology.Site

Site

class gmso.Site(name='Site', position=None, charge=None, mass=None, element=None, atom_type=None)[source]

An interaction site object in the topology hierarchy.

Site is the object that represents any general interaction site in a molecular simulation. Sites have been designed to be as general as possible, making no assumptions about representing atoms or beads, or having mass or charge. That is, a Site can represent an atom in an atomistic system, a bead in a coarse-grained system, and much more.

Parameters:
  • name (str, optional, default=’Site’) – Name of the site
  • position (unyt array or numpy array or list, optional, default=None) – The position of the site in Cartesian space. If a unyt array is not passed, units are assumed to be in ‘nm’.
  • charge (unyt quantity or float, optional, default=None) – The charge of the site. Unyt quantities are converted to units of elementary charge, float values are assumed to be in units of elementary charge. If no value is passed, site attempts to grab a charge from site.atom_type.
  • mass (unyt quantity or float, optional, default=None) – The mass of the site. Unyt quantities are converted to units of g/mol, float values are assumed to be in units of g/mol. If no value is passed, site attempts to grab a mass from site.atom_type.
  • element (‘Element’ object, optional, default=None) – The element of the site represented by the Element object. See element.py for more information.
  • atom_type (‘AtomType’ object, optional, default=None) – The atom type of the site containing functional forms, interaction parameters, and other properties such as mass and charge. See atom_type.py for more information.
Variables:
  • connections (IndexedSet) – Set that contains connection information for the site
  • n_connections (int) – Number of connections for the site

Bond

class gmso.Bond(connection_members=None, connection_type=None, name='Bond')[source]

A 2-partner connection between sites.

This is a subclass of the gmso.Connection superclass. This class has strictly 2 members in its connection_members. The connection_type in this class corresponds to gmso.BondType.

Parameters:
  • connection_members (list of gmso.Site) – 2 sites of a bond.
  • connection_type (gmso.BondType, optional, default=None) – BondType of this bond.
  • name (str, optional, default=”Bond”) – Name of the bond.

Notes

Inherits some methods from Connection:
__eq__, __repr__, _validate methods.

Additional _validate methods are presented.

Angle

class gmso.Angle(connection_members=[], connection_type=None, name='Angle')[source]

A 3-partner connection between sites.

This is a subclass of the gmso.Connection superclass. This class has strictly 3 members in its connection members. The connection_type in this class corresponds to gmso.AngleType.

Parameters:
  • connection_members (list of gmso.Site) – 3 sites of an angle.
  • connection_type (gmso.AngleType, optional, default=None) – AngleType of this angle.
  • name (str, optional, default=”Angle”) – Name of the angle.

Notes

Inherits some methods from Connection:
__eq__, __repr__, _validate methods

Additional _validate methods are presented

Dihedral

class gmso.Dihedral(connection_members=[], connection_type=None, name='Dihedral')[source]

A 4-partner connection between sites.

This is a subclass of the gmso.Connection superclass. This class has strictly 4 members in its connection_members. The connection_type in this class corresponds to gmso.DihedralType. The connectivity of a dihedral is:

m1–m2–m3–m4

where m1, m2, m3, and m4 are connection members 1-4, respectively.

Parameters:
  • connection_members (list of gmso.Site) – 4 sites of a dihedral.
  • connection_type (gmso.DihedralType, optional, default=None) – DihedralType of this dihedral.
  • name (str, optional, default=Dihedral) – Name of the dihedral.

Notes

Inherits some methods from Connection:
__eq__, __repr__, _validate methods

Additional _validate methods are presented

Potential Classes

class gmso.Potential(name='Potential', expression='a*x+b', parameters=None, independent_variables=None, template=False, topology=None)[source]

An abstract potential class.

Potential stores a general interaction between components of a chemical topology that can be specified by a mathematical expression. The functional form of the potential is stored as a sympy expression and the parameters are stored explicitly. This class is agnostic to the instantiation of the potential, which can be e.g. a non-bonded potential, a bonded potential, an angle potential, a dihedral potential, etc. and is designed to be inherited by classes that represent these potentials.

Parameters:
  • name (str, default=”Potential”) – The name of the potential.
  • expression (str or sympy.Expr, default=’a*x+b’) – The mathematical expression describing the functional form of the potential.
  • parameters (dict {str: unyt.unyt_quantity},) – default={‘a’: 1.0*u.dimensionless, ‘b’: 1.0*u.dimensionless} The parameters of the potential and their values, as unyt quantities. The keys are names of the variables included in expression and values are the numerical values of these parameters recorded as instances of unyt.unyt_quantity, which combine both value and unit information.
  • independent_variables (str or sympy.Symbol or list or set thereof) – The independent variables in the expression of the potential.
  • topology (gmso.core.Topology, the topology of which this potential is a part of, default=None)
  • set_ref ((str), the string name of the bookkeeping set in topology class.)
classmethod from_template(potential_template, parameters, topology=None)[source]

Create a potential object from the potential_template

Parameters:
  • potential_template (gmso.lib.potential_templates.PotentialTemplate,) – The potential template object
  • parameters (dict,) – The parameters of the potential object to create
  • topology (gmso.Topology, default=None) – The topology to which the created potential object belongs to
Returns:

The potential object created

Return type:

gmso.Potential

Raises:

GMSOError – If potential_template is not of instance PotentialTemplate

set_expression(expression=None, parameters=None, independent_variables=None)[source]

Set the expression, parameters, and independent variables for this potential.

Parameters:
  • expression (sympy.Expression or string) – The mathematical expression corresponding to the potential If None, the expression remains unchanged
  • parameters (dict) – {parameter: value} in the expression If None, the parameters remain unchanged

Notes

Be aware of the symbols used in the expression and parameters. If unnecessary parameters are supplied, an error is thrown. If only a subset of the parameters are supplied, they are updated while the non-passed parameters default to the existing values

AtomType

class gmso.AtomType(name='AtomType', mass=unyt_quantity(0., 'g/mol'), charge=unyt_quantity(0., 'C'), expression='4*epsilon*((sigma/r)**12 - (sigma/r)**6)', parameters=None, independent_variables=None, atomclass='', doi='', overrides=None, definition='', description='', topology=None)[source]

A description of non-bonded interacitons between sites.

This is a subclass of the gmso.core.Potential superclass.

AtomType represents an atom type and includes the functional form describing its interactions and, optionally, other properties such as mass and charge. This class inhereits from Potential, which stores the non-bonded interaction between atoms or sites. The functional form of the potential is stored as a sympy expression and the parameters, with units, are stored explicitly.

Parameters:
  • name (str, default=”AtomType”) – The name of the potential.
  • mass (unyt.unyt_quantity, optional, default=0.0 * unyt.g / u.mol) – The mass of the atom type.
  • charge (unyt.unyt_quantity, optional, default=0.0 * unyt.elementary_charge) – The charge of the atom type.
  • expression (str or sympy.Expr,) – default=‘4*epsilon*((sigma/r)**12 - (sigma/r)**6)’, The mathematical expression describing the functional form of the potential describing this atom type, i.e. a Lennard-Jones potential. The default value is a 12-6 Lennard-Jones potential.
  • parameters (dict of str : unyt.unyt_quantity pairs,) – default={‘sigma’: 0.3 * u.nm, ‘epsilon’: 0.3 * u.Unit(‘kJ’)}, The parameters of the potential describing this atom type and their values, as unyt quantities.
  • independent_variables (str, sympy.Symbol, or list-like of str, sympy.Symbol) – The independent variables of the functional form previously described.
  • atomclass (str, default=’‘) – The class of the atomtype
  • doi (str) – Digital Object Identifier of publication where this atom type was specified
  • desc (str) – Simple description of the atom type
  • overrides (set of str) – Set of other atom types that this atom type overrides
  • definition (str) – SMARTS string defining this atom type
  • topology (gmso.core.Topology, default=None) – The topology of which this atom_type is a part of, default=None
  • set_ref (str) – The string name of the bookkeeping set in gmso class.
classmethod from_template(potential_template, parameters, topology=None)

Create a potential object from the potential_template

Parameters:
  • potential_template (gmso.lib.potential_templates.PotentialTemplate,) – The potential template object
  • parameters (dict,) – The parameters of the potential object to create
  • topology (gmso.Topology, default=None) – The topology to which the created potential object belongs to
Returns:

The potential object created

Return type:

gmso.Potential

Raises:

GMSOError – If potential_template is not of instance PotentialTemplate

set_expression(expression=None, parameters=None, independent_variables=None)

Set the expression, parameters, and independent variables for this potential.

Parameters:
  • expression (sympy.Expression or string) – The mathematical expression corresponding to the potential If None, the expression remains unchanged
  • parameters (dict) – {parameter: value} in the expression If None, the parameters remain unchanged

Notes

Be aware of the symbols used in the expression and parameters. If unnecessary parameters are supplied, an error is thrown. If only a subset of the parameters are supplied, they are updated while the non-passed parameters default to the existing values

BondType

class gmso.BondType(name='BondType', expression='0.5 * k * (r-r_eq)**2', parameters=None, independent_variables=None, member_types=None, topology=None, set_ref='bond_type_set')[source]

A descripton of the interaction between 2 bonded partners.

This is a subclass of the gmso.core.Potential superclass.

BondType represents a bond type and includes the functional form describing its interactions. The functional form of the potential is stored as a sympy expression and the parameters, with units, are stored explicitly. The AtomTypes that are used to define the bond type are stored as member_types.

Parameters:
  • name (str) – The name of the potential.
  • expression (str or sympy.Expression) – See Potential documentation for more information
  • parameters (dict {str, unyt.unyt_quantity}) – See Potential documentation for more information
  • independent vars (set of str) – see Potential documentation for more information
  • member_types (list-like of str) – List-like of of gmso.AtomType.name defining the members of this bond type

Notes

Inherits many functions from gmso.Potential:
__eq__, _validate functions
classmethod from_template(potential_template, parameters, topology=None)

Create a potential object from the potential_template

Parameters:
  • potential_template (gmso.lib.potential_templates.PotentialTemplate,) – The potential template object
  • parameters (dict,) – The parameters of the potential object to create
  • topology (gmso.Topology, default=None) – The topology to which the created potential object belongs to
Returns:

The potential object created

Return type:

gmso.Potential

Raises:

GMSOError – If potential_template is not of instance PotentialTemplate

set_expression(expression=None, parameters=None, independent_variables=None)

Set the expression, parameters, and independent variables for this potential.

Parameters:
  • expression (sympy.Expression or string) – The mathematical expression corresponding to the potential If None, the expression remains unchanged
  • parameters (dict) – {parameter: value} in the expression If None, the parameters remain unchanged

Notes

Be aware of the symbols used in the expression and parameters. If unnecessary parameters are supplied, an error is thrown. If only a subset of the parameters are supplied, they are updated while the non-passed parameters default to the existing values

AngleType

class gmso.AngleType(name='AngleType', expression='0.5 * k * (theta-theta_eq)**2', parameters=None, independent_variables=None, member_types=None, topology=None)[source]

A descripton of the interaction between 3 bonded partners.

This is a subclass of the gmso.core.Potential superclass.

AngleType represents an angle type and includes the functional form describing its interactions. The functional form of the potential is stored as a sympy expression and the parameters, with units, are stored explicitly. The AtomTypes that are used to define the angle type are stored as member_types.

Parameters:
  • name (str, optional) – A name uniquely representing the angle type
  • expression (str or sympy.Expression) – See Potential documentation for more information
  • parameters (dict {str, unyt.unyt_quantity}) – See Potential documentation for more information
  • independent vars (set of str) – See Potential documentation for more information
  • member_types (list-like of str) – List-like of of gmso.AtomType.name defining the members of this angle type
  • gmso (gmso.core.Topology, default=None) – The Topology of which this angle_type is a part of
  • set_ref (str) – The string name of the bookkeeping set in gmso class.

Notes

Inherits many functions from gmso.Potential:
__eq__, _validate functions
classmethod from_template(potential_template, parameters, topology=None)

Create a potential object from the potential_template

Parameters:
  • potential_template (gmso.lib.potential_templates.PotentialTemplate,) – The potential template object
  • parameters (dict,) – The parameters of the potential object to create
  • topology (gmso.Topology, default=None) – The topology to which the created potential object belongs to
Returns:

The potential object created

Return type:

gmso.Potential

Raises:

GMSOError – If potential_template is not of instance PotentialTemplate

set_expression(expression=None, parameters=None, independent_variables=None)

Set the expression, parameters, and independent variables for this potential.

Parameters:
  • expression (sympy.Expression or string) – The mathematical expression corresponding to the potential If None, the expression remains unchanged
  • parameters (dict) – {parameter: value} in the expression If None, the parameters remain unchanged

Notes

Be aware of the symbols used in the expression and parameters. If unnecessary parameters are supplied, an error is thrown. If only a subset of the parameters are supplied, they are updated while the non-passed parameters default to the existing values

DihedralType

class gmso.DihedralType(name='DihedralType', expression='k * (1 + cos(n * phi - phi_eq))**2', parameters=None, independent_variables=None, member_types=None, topology=None, set_ref='dihedral_type_set')[source]

A descripton of the interaction between 4 bonded partners.

This is a subclass of the gmso.core.Potential superclass.

DihedralType represents a dihedral type and includes the functional form describing its interactions. The functional form of the potential is stored as a sympy expression and the parameters, with units, are stored explicitly. The AtomTypes that are used to define the dihedral type are stored as member_types.

The connectivity of a dihedral is:

m1–m2–m3–m4

where m1, m2, m3, and m4 are connection members 1-4, respectively.

Parameters:
  • name (str)
  • expression (str or sympy.Expression) – See Potential documentation for more information
  • parameters (dict {str, unyt.unyt_quantity}) – See Potential documentation for more information
  • independent vars (set of str) – See Potential documentation for more information
  • member_types (list-like of str) – List-like of of gmso.AtomType.name defining the members of this dihedral type
  • topology (gmso.core.Topology, default=None) – The topology of which this dihedral type is a part of
  • set_ref (str) – The string name of the bookkeeping set in topology class.

Notes

Inherits many functions from gmso.Potential:
__eq__, _validate functions
classmethod from_template(potential_template, parameters, topology=None)

Create a potential object from the potential_template

Parameters:
  • potential_template (gmso.lib.potential_templates.PotentialTemplate,) – The potential template object
  • parameters (dict,) – The parameters of the potential object to create
  • topology (gmso.Topology, default=None) – The topology to which the created potential object belongs to
Returns:

The potential object created

Return type:

gmso.Potential

Raises:

GMSOError – If potential_template is not of instance PotentialTemplate

set_expression(expression=None, parameters=None, independent_variables=None)

Set the expression, parameters, and independent variables for this potential.

Parameters:
  • expression (sympy.Expression or string) – The mathematical expression corresponding to the potential If None, the expression remains unchanged
  • parameters (dict) – {parameter: value} in the expression If None, the parameters remain unchanged

Notes

Be aware of the symbols used in the expression and parameters. If unnecessary parameters are supplied, an error is thrown. If only a subset of the parameters are supplied, they are updated while the non-passed parameters default to the existing values

ForceField

class gmso.ForceField(xml_loc=None)[source]

A generic implementation of the forcefield class.

The ForceField class is one of the core data structures in gmso, which is used to hold a collection of gmso.core.Potential subclass objects along with some metadata to represent a forcefield. The forcefield object can be applied to any gmso.Topology which has effects on its Sites, Bonds, Angles and Dihedrals.

Parameters:
  • name (str) – Name of the forcefield, default ‘ForceField’
  • version (str) – a cannonical semantic version of the forcefield, default 1.0.0
Variables:
  • name (str) – Name of the forcefield
  • version (str) – Version of the forcefield
  • atom_types (dict) – A collection of atom types in the forcefield
  • bond_types (dict) – A collection of bond types in the forcefield
  • angle_types (dict) – A collection of angle types in the forcefield
  • dihedral_types (dict) – A collection of dihedral types in the forcefield
  • units (dict) – A collection of unyt.Unit objects used in the forcefield
  • scaling_factors (dict) – A collection of scaling factors used in the forcefield

See also

gmso.ForceField.from_xml
A class method to create forcefield object from XML files
atom_class_groups

Return a dictionary of atomClasses in the Forcefield

classmethod from_xml(xml_locs)[source]

Create a gmso.Forcefield object from XML File(s)

This class method creates a ForceFiled object from the reference XML file. This method takes in a single or collection of XML files with information about gmso.AtomTypes, gmso.BondTypes, gmso.AngleTypes and gmso.DihedralTypes to create the ForceField object.

Parameters:xml_locs (str or iterable of str) – string or iterable of strings containing the forcefield XML locations
Returns:forcefield – A gmso.Forcefield object with a collection of Potential objects created using the information in the XML file
Return type:gmso.ForceField