Abstract Base Classes
The gmso.abc module defines the abstract base classes that underpin all data structures in
GMSO. These classes are not meant to be instantiated directly; instead, they provide a shared
interface and common behaviour that concrete classes (e.g., gmso.Atom,
gmso.Bond) build upon.
GMSOBase
GMSOBase is the root Pydantic BaseModel that every GMSO
object derives from. It enforces strict validation, forbids extra fields, and provides
JSON-serialisation helpers.
Site
Site is the abstract base for all interaction sites
(atoms, virtual sites, coarse-grained beads, etc.). It stores a 3-D Cartesian position,
an optional name, and optional molecule/residue labels.
- class gmso.abc.abstract_site.Site(**data)[source]
Bases:
GMSOBase- position_: Sequence[float] | ndarray | unyt_array
- property position: unyt_array
Return the 3D Cartesian coordinates of the site.
Molecule
A lightweight label that groups sites into named, numbered molecules.
Residue
A lightweight label that groups sites into named, numbered residues.
AbstractPotential
AbstractPotential is the abstract base for all
potential-energy functions. It stores the functional form as a sympy expression and
the parameters—with physical units—as a dictionary.
- class gmso.abc.abstract_potential.AbstractPotential(name='Potential', expression='a*x+b', independent_variables=None, potential_expression=None, *, tags={})[source]
Bases:
GMSOBase- potential_expression_: PotentialExpression
- property independent_variables: Set
The independent variables in the potential’s expression.
Returns the set of
sympysymbols that are not parameters — typically the interparticle distanceror an angletheta.
- property expression
The mathematical expression of the potential as a
sympy.Expr.
- property potential_expression: PotentialExpression
The
PotentialExpressionfor this potential.Bundles the sympy expression, the independent variables, and the parameter dictionary into a single validated object.
- add_tag(tag, value, overwrite=True)[source]
Add or update a metadata tag on this potential.
- Parameters:
tag (
str) – Name of the tag to add.value (
Any) – Value to associate with the tag.overwrite (
bool) – IfFalse, raiseValueErrorwhen tag already exists.
- Return type:
Connection
Connection is the abstract base for all topological
connections between sites (bonds, angles, dihedrals, impropers).
- class gmso.abc.abstract_connection.Connection(**data)[source]
Bases:
GMSOBase- property connection_members: Sequence[Site] | None
Return the ordered sequence of sites that form this connection.
- property member_types: List[str] | None
Return the atom-type name of each connection member.
Returns the names from the connection’s
connection_typewhen available, otherwise falls back to the individual members’ atom types. ReturnsNonewhen no type information is present.