API reference¶
Signatures, documented defaults, and expandable source below are generated from this checkout on every build. Start with the linked tutorials for worked examples, interpretation, and known limitations. Public methods lacking original docstrings are included so they are discoverable.
Private modules beginning with _ are implementation details. Names accidentally re-exported by wildcard imports (for example NumPy or imported helpers) are not a supported matmalib API. Import the classes and functions below explicitly.
Molecular objects¶
Tutorial: Molecules and geometry. Compatibility notes: Core behavior.
matmalib.core.Atom(coord: list = None, type: str = None, valence: int = None, index: int = None)
¶
Source code in matmalib/core.py
matmalib.core.Fragment()
¶
matmalib.core.State(**kwargs)
¶
xyz
property
¶
Mass
property
¶
mass
property
¶
from_file(path, software)
classmethod
¶
element_symbol(A)
staticmethod
¶
add_atoms(atom)
¶
remove_atoms(atom)
¶
measure_internal(atom_list)
¶
set_internal(atom_list, val)
¶
Source code in matmalib/core.py
connectivity_matrix(distXX=1.65, distXH=1.15)
¶
Creates a connectivity matrix of the molecule. A connectivity matrix holds the information of which atoms are bonded and to what.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distXX
|
The max distance between two atoms (not hydrogen) to be considered a bond |
1.65
|
|
distXH
|
The max distance between any atom and a hydrogen atom to be considered a bond |
1.15
|
Source code in matmalib/core.py
system_split()
¶
Source code in matmalib/core.py
show(width=600, height=600)
¶
Source code in matmalib/core.py
matmalib.core.Data(**kwargs)
¶
Source code in matmalib/core.py
matmalib.core.Space(states: list = None, theory: dict = None, input_path: str = None, output_path: str = None)
¶
Source code in matmalib/core.py
states = [] if states is None else states
instance-attribute
¶
theory = theory
instance-attribute
¶
input_path = input_path
instance-attribute
¶
output_path = output_path
instance-attribute
¶
energies
property
¶
free_energies
property
¶
enthalpies
property
¶
from_xyz(path, *, glycans=False)
classmethod
¶
Read every XYZ frame into a State (or a Glycan when glycans=True).
Source code in matmalib/core.py
rmsd_matrix(**kwargs)
¶
cluster(threshold=1.0, **kwargs)
¶
Return a ClusterResult with memberships and representative conformers.
remove_duplicates(threshold=0.1, **kwargs)
¶
Return a new Space of complete-linkage representatives; keep self intact.
Every pair within a duplicate group is at most threshold apart. Other options match cluster(), except the linkage method is fixed.
Source code in matmalib/core.py
to_file(software: str = 'gaussian')
¶
sum(states: list, quant: str = 'E')
¶
Source code in matmalib/core.py
from_dir(path, software='gaussian')
classmethod
¶
Source code in matmalib/core.py
diff(states=None, quant: str = 'E')
¶
Source code in matmalib/core.py
add(state)
¶
remove(state)
¶
Source code in matmalib/core.py
sort(val: str = 'E')
¶
table(sort='E')
¶
Source code in matmalib/core.py
Geometry and file builders¶
Tutorials: Geometry editing, File I/O, and Ensemble energies. InputBuilder may be imported explicitly from matmalib.calc.
matmalib.util.StateEditor(state)
¶
state = state
instance-attribute
¶
get_distance(atom_list, state=None)
staticmethod
¶
Finds the distance between two atoms
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom_list
|
Two Atom objects or two zero-based atom positions. |
required | |
state
|
State used to resolve integer atom positions. |
None
|
Returns:
| Type | Description |
|---|---|
|
(float) the distance between 2 atoms |
Source code in matmalib/util.py
adjacent_atoms(conn_mat, at)
staticmethod
¶
returns all adjacent atoms to a specific atom in a conformation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn_mat
|
the connectivity matrix |
required | |
at
|
index of the selected atom |
required |
Returns:
| Type | Description |
|---|---|
|
indices of all atoms adjacent to the selected atom |
Source code in matmalib/util.py
get_angle(atom_list, state=None)
staticmethod
¶
Calculate an angle between three atoms: angle = acos(dot(X,Y)/(norm(X)*norm(Y)))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom_list
|
Three Atom objects or three zero-based atom positions. |
required | |
state
|
State used to resolve integer atom positions. |
None
|
Returns:
| Type | Description |
|---|---|
|
A tuple of angle in degrees and rotation-axis vector. |
Source code in matmalib/util.py
get_dihedral(atom_list, state=None, ax: bool = False)
staticmethod
¶
Measure the signed torsion of four ordered atoms, in degrees.
Uses the same atan2 convention as glycan torsions: a positive right-handed rotation of the fourth atom about the second-to-third atom direction increases the angle. Values lie in [-180, 180]. This corrects the opposite sign and translation-dependent sign bug in the legacy implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom_list
|
Four Atom objects or four zero-based atom positions. |
required | |
state
|
State used to resolve integer atom positions. |
None
|
|
ax
|
bool
|
Also return the unnormalized cross product of the two plane normals, retained for compatibility. It is zero for exactly planar torsions; it is not a stable rotation axis. |
False
|
Returns:
| Type | Description |
|---|---|
|
Signed degrees, or (degrees, plane-normal cross product). |
Raises:
| Type | Description |
|---|---|
ValueError
|
For invalid selections, nonfinite coordinates, coincident central atoms, or collinear triples. |
Source code in matmalib/util.py
measure(atom_list, state=None)
staticmethod
¶
Source code in matmalib/util.py
determine_carried_atoms(state, atom_list)
staticmethod
¶
Source code in matmalib/util.py
connect_atoms(state, at1: int, at2: int)
staticmethod
¶
Connects two atoms in the conn_mat
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
State with an associated conn_mat. |
required | |
at1
|
int
|
First zero-based matrix index. |
required |
at2
|
int
|
Second zero-based matrix index. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in matmalib/util.py
disconnect_atoms(state, at1: int, at2: int)
staticmethod
¶
Disconnects two atoms in the conn_mat
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
State with an associated conn_mat. |
required | |
at1
|
int
|
First zero-based matrix index. |
required |
at2
|
int
|
Second zero-based matrix index. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in matmalib/util.py
set_distance(atom_list, new_distance)
¶
Set a new distance between two atoms
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom_list
|
Two zero-based atom positions. |
required | |
new_distance
|
value of bond distance to be set |
required |
Source code in matmalib/util.py
set_angle(atom_list, new_ang)
¶
Set a new angle between three atoms
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom_list
|
Three zero-based atom positions. |
required | |
new_ang
|
Bond angle in degrees to be set. |
required |
Source code in matmalib/util.py
set_dihedral(atom_list, new_dih, incr=False, axis_pos='bond', threshold=0.1)
¶
Rotate the moving fragment using the signed dihedral convention.
In bond mode, rotate the component on the third atom's side of the central bond about the second-to-third atom direction. The first atom must remain fixed and the fourth must belong to that component. Cutting the bond must separate its endpoints; rings are rejected. Connectivity is never modified. Exact planar targets are supported.
The legacy terminal mode rotates only atoms beyond the fourth atom about a parallel axis through that atom. It leaves the defining quartet fixed, so it does not set that quartet's measured torsion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
atom_list
|
Four zero-based atom positions. |
required | |
new_dih
|
Finite target angle in degrees, or an increment. |
required | |
incr
|
Treat new_dih as an increment to the current dihedral. |
False
|
|
axis_pos
|
Use the central bond ('bond') or terminal pivot ('term'). |
'bond'
|
|
threshold
|
Finite nonnegative tolerance in degrees for a no-op. |
0.1
|
Returns:
| Type | Description |
|---|---|
|
None; modifies the State's atom coordinates in place. |
Raises:
| Type | Description |
|---|---|
ValueError
|
For invalid inputs, degenerate geometry, or a bond that does not separate the required fixed and moving atoms. |
Source code in matmalib/util.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
matmalib.util.StateBuilder(path, software)
¶
Source code in matmalib/util.py
path = path
instance-attribute
¶
software = software
instance-attribute
¶
element_symbol(A)
staticmethod
¶
gaussian()
¶
Parses log files from Gaussian 16 and appends information inside the log file to the mol object.
Source code in matmalib/util.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
cp2k_geom()
¶
Parses information from CP2K. Right now only works for AIMD Trajectories, plan to implement opt compatability later.
Source code in matmalib/util.py
orca()
¶
Parses information from ORCA input.log file
Source code in matmalib/util.py
build()
¶
Source code in matmalib/util.py
matmalib.util.DataBuilder(path, software, **kwargs)
¶
Source code in matmalib/util.py
path = path
instance-attribute
¶
software = software
instance-attribute
¶
cp2k_md(colvar=None, timestep=None)
¶
Source code in matmalib/util.py
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 | |
gromacs()
¶
Parses information from gromacs *.xvg file
Source code in matmalib/util.py
csv(skiprows=0, dtype=float, delimiter: str = ',')
¶
Parse the CSV file at this builder's path into its data attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skiprows
|
(int) Number of rows to skip |
0
|
|
dtype
|
(type) Data type |
float
|
|
delimiter
|
str
|
(str) Delimiter |
','
|
Source code in matmalib/util.py
build()
¶
Source code in matmalib/util.py
matmalib.calc.InputBuilder(path: str = None, theory: dict = None, software: str = 'gaussian', space=None)
¶
Source code in matmalib/calc.py
path = path
instance-attribute
¶
theory = theory
instance-attribute
¶
software = software
instance-attribute
¶
space = space
instance-attribute
¶
element_number(A)
staticmethod
¶
gaussian()
¶
Source code in matmalib/calc.py
fhiaims()
¶
Source code in matmalib/calc.py
xyz()
¶
Source code in matmalib/calc.py
build(space, theory, software, path, names: list = None)
¶
Source code in matmalib/calc.py
Carbohydrates and trajectories¶
Tutorials: Glycans, Ring puckering, and Trajectories. Glycan inherits the State methods above.
matmalib.glycan.Glycan(atoms, *, rings=None, monomers=None, distXX=1.65, distXH=1.15, **kwargs)
¶
Bases: State
A carbohydrate State whose monomers are Fragment objects.
rings and monomers are parallel sequences of zero-based positions
in atoms (not Atom.id values). Each ring must be in cyclic order;
each monomer lists all atoms assigned to that sugar. Assign bridging
atoms to only one monomer. Unassigned atoms remain in the State and are
available through unassigned_atoms (for example solvent or counterions).
With no assignments, detect sugars using CarPpy's connectivity-based
approach. Supplied conn_mat or graph uses atom-list positions;
otherwise bonds are inferred with distXX=1.65 and distXH=1.15
(angstrom defaults). Automatic rings start at O, followed by the anomeric
carbon and the remaining ring carbons. Ketoses start at C2, aldoses at C1.
Supply both rings and monomers to bypass detection for unusual chemistry.
Source code in matmalib/glycan.py
atoms = list(atoms)
instance-attribute
¶
NAtoms = len(self.atoms)
instance-attribute
¶
graph = graph
instance-attribute
¶
Nmols = nx.number_connected_components(graph)
instance-attribute
¶
rings = _rings(rings, self.NAtoms)
instance-attribute
¶
monomers = fragments
instance-attribute
¶
fragments = fragments
instance-attribute
¶
unassigned_atoms = [atom for i, atom in enumerate(self.atoms) if i not in assigned]
instance-attribute
¶
glycosidic_bonds = links
instance-attribute
¶
from_state(state, *, rings=None, monomers=None, **kwargs)
classmethod
¶
Wrap a State, retaining its metadata and sharing its Atom objects.
Source code in matmalib/glycan.py
from_file(path, software='xyz', *, rings=None, monomers=None, **kwargs)
classmethod
¶
Read a system and detect sugars; XYZ/CP2K uses the last saved frame.
Source code in matmalib/glycan.py
cremer_pople(*, degrees=True)
¶
Return one puckering dictionary per monomer for the current geometry.
identify_ring_puckers(**kwargs)
¶
Return CP coordinates, canonical pucker labels, and distances per ring.
Six-membered labels follow CarPpy's positional convention: 1–5 are the ring carbons after O, and 6 is O. For ketoses these positions are not the chemical carbon numbers. Five-membered labels use 0–4 in ring order. See classify_ring_pucker for tolerances and conventions.
Source code in matmalib/glycan.py
identify_sugars()
¶
Return base-residue names, D/L configuration and alpha/beta anomer.
Common aldohexopyranoses and their C2 amino/N-acetyl, C6 deoxy and uronic-acid variants are supported. Other chemistry remains Unknown.
Source code in matmalib/glycan.py
glycosidic_torsions(*, degrees=True)
¶
Return phi/psi/omega and their atom quadruplets for each linkage.
backbone_torsions(*, degrees=True)
¶
Return hydroxymethyl omega and its atom quadruplet per monomer.
snfg(**kwargs)
¶
cremer_pople_trajectory(frames, **kwargs)
¶
Analyze frames using this Glycan's fixed atom assignments.
Accepts a Space, an iterable of States, or coordinate arrays with shape
(n_frames, n_atoms, 3). Every frame must use this State's atom order.
See :func:cremer_pople_trajectory for output and time conventions.
Source code in matmalib/glycan.py
matmalib.glycan.cremer_pople_trajectory(frames, rings=None, *, timestep=1.0, times=None, time_unit='fs', degrees=True, path='', software=None, elements=None, conn_mat=None, distXX=1.65, distXH=1.15, classify=False)
¶
Analyze ordered rings in a trajectory and return a plotting-ready Data.
frames is a Space, an iterable of States, or an iterable of full
coordinate arrays. Without rings, detect sugars on the first State
(or supply elements for coordinate arrays). conn_mat can provide
reference connectivity; otherwise CarPpy distance cutoffs infer bonds.
rings lists zero-based atom positions in cyclic order, held fixed for
every frame. Frames must have identical atom order
and whole, unwrapped rings; no periodic-boundary correction is performed.
data[:, 0] contains explicit times or arange(n_frames)*timestep.
columns names every column: time, then monomer_0.Q, monomer_0.theta,
monomer_0.phi, monomer_0.q2, monomer_0.q3, and so on. Five-membered rings
omit theta and q3. Angles default to degrees; lengths retain input units.
Frames are consumed once, without storing the full coordinate trajectory.
With classify=True, also attach pucker_labels, pucker_families,
and pucker_distances arrays of shape (n_frames, n_rings), following
classify_ring_pucker's positional naming and degree-distance conventions.
The numeric data columns are unchanged.
Source code in matmalib/glycan.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
matmalib.puckering.cremer_pople(coordinates, *, degrees=True)
¶
Calculate ring puckering for one geometry or a batch of geometries.
coordinates has shape (..., ring_size, 3) with atoms in cyclic
order. All rings in a batch must have the same size (five or six).
Coordinates must describe whole, unwrapped rings. Amplitudes retain the
input length unit; angles are degrees by default, or radians when
degrees=False.
The returned dictionary contains Q, q2, and phi. Six-membered
rings also have the signed amplitude q3 and polar angle theta.
phi lies in [0, 360) and theta in [0, 180] (or [0, 2*pi) and
[0, pi]). Undefined angles are NaN: phi for planar rings and pure chairs,
and theta for planar rings. A degenerate mean plane raises ValueError.
Uses the original Cremer–Pople convention (JACS 97, 1354–1358, 1975, https://doi.org/10.1021/ja00839a011): the mean-plane normal is R' x R'', with sine-weighted R' and cosine-weighted R''. The phase is defined by q2cos(phi) = sqrt(2/N)sum(zcos(4pij/N)) and q2sin(phi) = -sqrt(2/N)sum(zsin(4pij/N)), for j starting at zero. Changing the starting atom or traversal direction changes the angles.
Source code in matmalib/puckering.py
matmalib.puckering.ring_dihedrals(coordinates)
¶
CarPpy's three ring-puckering angles, in degrees (not CP theta).
Input shape is (..., 6, 3), in O, C1, C2, C3, C4, C5 order. These are the transformed diagonal dihedrals used by CarPpy's ring_canon routine.
Source code in matmalib/puckering.py
matmalib.puckering.classify_ring_pucker(coordinates, *, degrees=True, planar_tolerance=1e-06, max_distance=None)
¶
Return CP coordinates plus a nearest canonical pucker and its distance.
Six-membered rings use CarPpy's 38 canonical three-angle references; names
use C1–C5 and 6 for O, with O first in the input. carppy_theta is the
measured three-angle vector and distance is its Euclidean distance
from the reference, in degrees. It is distinct from the CP polar theta.
Five-membered rings use 20 ideal envelope/twist phases with indices 0–4
in input order. 0E raises atom 0; 0T1 raises 0 and lowers 1 relative
to the CP normal. Distance is the wrapped phase difference in degrees.
Angles in the returned CP coordinates follow degrees.
planar_tolerance uses the coordinate length unit. Planar rings are
labelled planar. max_distance can reject a remote nearest reference
with label unassigned; nearest_label still records the nearest candidate.
These assignments describe proximity to ideal conformations, not exact
conformational identities.
Source code in matmalib/puckering.py
matmalib.snfg.draw_snfg(glycan, *, labels=None, ax=None, positions=None, show_linkages=True, show_names=False, symbol_size=0.32, symbol_linewidth=2.0, linkage_linewidth=2.0, bond_length=1.2, diagonal_bond_scale=1.2)
¶
Draw a Glycan as SNFG symbols; return (figure, axes).
Common aldohexopyranoses are named from connectivity and stereochemistry.
Unsupported chemistry uses the white Unknown hexagon. labels may be
a sequence (one standard SNFG abbreviation per monomer) or an index/name
mapping overriding selected names, e.g. {0: 'Fru'}. Explicit unknown
abbreviations raise ValueError. Names describe base residues; protecting
groups and all modifications are not inventoried by automatic naming.
Reducing ends appear at the right. Automatic linkages extend from each
acceptor towards its donor according to the acceptor carbon position:
2 down (270 degrees), 3 lower left (225), 4 left (180), 6 upper left
(135), and 8 up (90), independent of branching. bond_length sets the
horizontal and vertical center-to-center distance in drawing coordinates
(default 1.2). diagonal_bond_scale multiplies this length for diagonal
links (default 1.2, or 20 percent longer); use 1 for equal lengths.
Alpha linkages are dashed;
beta and unknown linkages are solid. symbol_linewidth and linkage_linewidth set
stroke widths in points. positions optionally maps every
monomer index to (x, y); it is required for non-tree topologies. The
lines between explicit positions are drawn straight without snapping or
rescaling. Unknown or other acceptor positions and overlapping fixed-length
layouts also require explicit positions.
Linkage annotations give alpha/beta and donor–acceptor carbon positions. Anomers
that cannot be determined are shown as ?. Nondefault D/L configurations
and furanose rings are annotated. Figures support normal Matplotlib export.
Source code in matmalib/snfg.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
Conformer analysis¶
Tutorial: Conformers and clustering.
matmalib.conformers.rmsd(first, second, *, atom_indices=None, heavy_only=False, align=True)
¶
Return RMSD in input length units, using a proper rotation when aligned.
Inputs are States or coordinate arrays. Atom correspondence is positional; this does not perform symmetry-based atom permutation or mirror reflection. Neither input is modified.
Source code in matmalib/conformers.py
matmalib.conformers.rmsd_matrix(states, *, atom_indices=None, heavy_only=True, align=True)
¶
Symmetric pairwise RMSD matrix for a Space or iterable of States.
Source code in matmalib/conformers.py
matmalib.conformers.cluster_conformers(states, threshold=1.0, *, method='single', heavy_only=True, atom_indices=None, energy='E', energy_window=None, energy_unit='hartree')
¶
Cluster aligned RMSDs with single, complete, average, or weighted linkage.
threshold uses coordinate length units. An optional energy_window
is in kcal/mol above the minimum; energy_unit describes stored energies
(hartree, kcal/mol, or kJ/mol). Complete finite energies are required for
filtering. Representatives are lowest-energy members when all energies
are available, otherwise medoids (minimum sum of within-cluster RMSDs).
Set energy=None to select medoids even when energies are present.
Source code in matmalib/conformers.py
matmalib.conformers.ClusterResult(labels: np.ndarray, members: tuple, representative_indices: tuple, representatives: object, distances: np.ndarray, linkage: np.ndarray, included_indices: np.ndarray, threshold: float, method: str)
dataclass
¶
Cluster labels/members use original indices; excluded labels are -1.
distances covers all input states. Rows of linkage refer to
included_indices. representatives is a new Space sharing the
selected State objects; no input conformer is reordered or modified.
labels: np.ndarray
instance-attribute
¶
members: tuple
instance-attribute
¶
representative_indices: tuple
instance-attribute
¶
representatives: object
instance-attribute
¶
distances: np.ndarray
instance-attribute
¶
linkage: np.ndarray
instance-attribute
¶
included_indices: np.ndarray
instance-attribute
¶
threshold: float
instance-attribute
¶
method: str
instance-attribute
¶
Plotting¶
Tutorials: Plotting and styling, Free-energy surfaces, and IR spectra.
matmalib.viz.Plot()
¶
A class that creates plots from a numpy array. It can make reaction coordinate diagrams, RMSD and RMSF trajectory plots, Free energy plots, Scatter Plots, and SNFG Figures.
Construct a plot object with default configuration and colors.
Source code in matmalib/viz.py
config = config
instance-attribute
¶
config_dict = config_dict
instance-attribute
¶
colors = ['#4856d1', '#f3a667', '#e31a1c', '#1f78b4', '#53546c']
instance-attribute
¶
Config(xrange: list = None, yrange: list = None, xtick: list = None, ytick: list = None, xlabel: str = None, ylabel: str = None, title: str = None, font: str = None, xextend: float = None, yextend: float = None, title_fontsize: float = None, axis_fontsize: float = None, tick_fontsize: float = None, headers: list = None)
dataclass
¶
xrange: list = None
class-attribute
instance-attribute
¶
yrange: list = None
class-attribute
instance-attribute
¶
xtick: list = None
class-attribute
instance-attribute
¶
ytick: list = None
class-attribute
instance-attribute
¶
xlabel: str = None
class-attribute
instance-attribute
¶
ylabel: str = None
class-attribute
instance-attribute
¶
title: str = None
class-attribute
instance-attribute
¶
font: str = None
class-attribute
instance-attribute
¶
xextend: float = None
class-attribute
instance-attribute
¶
yextend: float = None
class-attribute
instance-attribute
¶
title_fontsize: float = None
class-attribute
instance-attribute
¶
axis_fontsize: float = None
class-attribute
instance-attribute
¶
tick_fontsize: float = None
class-attribute
instance-attribute
¶
headers: list = None
class-attribute
instance-attribute
¶
snfg(glycan, **kwargs)
¶
Draw SNFG symbols; return (figure, axes) and retain them on this Plot.
cluster_dendrogram(clusters, *, labels=None, ax=None, **kwargs)
¶
Plot a ClusterResult's linkage tree in RMSD units.
Optional labels cover all original conformers; energy-excluded states are omitted from the tree. Remaining options go to SciPy dendrogram.
Source code in matmalib/viz.py
cmap(color_num: int = None, offset: float = 0, map: str = 'ice', reverse: bool = False)
¶
Generates and processes a colormap with optional offsetting logic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color_num
|
int
|
(int) Number of discrete colors. |
None
|
offset
|
float
|
(float) Fractional offset to shift the colormap. |
0
|
map
|
str
|
(str) Name of the colormap from the colormaps library. Also configures the palette for cremer_pople_sphere and updates an already-drawn sphere and its colorbar. An explicit cmap argument when drawing a new sphere overrides this palette for that call only. |
'ice'
|
Source code in matmalib/viz.py
savefig(filename='fig', format: str = 'png')
¶
set_colors(colors: list = None)
¶
set_config(conf: dict)
¶
set_axes(ax: matplotlib.pyplot.axes)
¶
Source code in matmalib/viz.py
trajectory(data_list, var_name='colvar', col=1, average=None, title=None, hist=True, alpha=None, calc_qa=False, overlap=False, headers=None, *, projection=None, monomer=0, pucker_labels=False, cmap=None, bins=(72, 36), num_levels=8, quantity='free_energy', temp=300, energy_unit='kcal/mol')
¶
Plots MD trajectory with histogram. Takes in data for CP2K or Gromacs via Mol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_list
|
(Mol / List) Either a Data object, or a list of Data objs if you want to overlay data. |
required | |
var_name
|
(list) Name of the collective variable you are plotting on your y-axis. |
'colvar'
|
|
col
|
(int) Index of the column containing your colvar data, in the case that you have multiple. For a Cremer–Pople free-energy map, use cremer_pople_sphere.
|
1
|
Source code in matmalib/viz.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | |
cremer_pople_sphere(data_list, *, monomer=0, cmap=None, title=None, alpha=None, headers=None, pucker_labels=False, figsize=(8, 4), bins=(72, 36), num_levels=8, quantity='free_energy', temp=300, energy_unit='kcal/mol')
¶
Plot relative free energy on a Mollweide Cremer–Pople sphere.
Accept a Data or list of Data returned by cremer_pople_trajectory.
Select a zero-based six-membered monomer (default 0). Named theta
and phi columns are required; angle_unit is degrees or radians. Each
valid row contributes one conformer, irrespective of time or order.
Multiple datasets are pooled into one histogram. bins is a positive
integer or a (phi, theta) pair of bin counts; the default (72, 36) gives
5-degree cells. By default, each occupied bin has free energy
-R * temp * log(N / Nmax), using R = 8.314 J/(mol K) and
temp=300 kelvin, matching Plot.fes. energy_unit defaults to
"kcal/mol"; "kJ/mol" is also supported (1 kcal = 4.184 kJ).
The most populated bin is
zero; empty bins are masked. This uses counts per angular cell, with
no spherical-area correction or reweighting. quantity="counts"
restores the population map.
Filled contours interpolate between sampled bin centers using
num_levels color bands (default 8). In free-energy mode, a finer
drawing grid interpolates energies using occupied neighbors and rounds
the boundary at half occupancy. Isolated samples remain visible and
empty bin centers stay white. This changes only the rendering, not the
stored populations or energies. A light dashed grid marks CP angles.
Use the palette configured by Plot.cmap() or Plot.set_colors(), or a
pastel green palette by default. An explicit cmap Matplotlib name
or object overrides it for this plot. The vertical colorbar on the
right shows free energy in the selected unit, or Number of conformers
in count mode.
Longitude is 180-phi degrees and latitude is 90-theta; tick labels show CP angles in degrees. Phi wraps at 0/360 degrees. Pure chairs are counted at the poles using phi=180, where phase is arbitrary; planar frames and other undefined angles are omitted. Set pucker_labels=True to annotate the 38 ideal puckers. Labels assume O, C1, ..., C5 ring order, with O denoting position 6 in classification results.
figsize defaults to (8, 4) inches and alpha to 1. Alpha must be
common to all pooled datasets. Headers are joined into a default title.
Supports title and label/font configuration; configured axis limits
are unsupported. Return (figure, axes), also stored as fig and ax on
this Plot; heatmap and colorbar hold the filled contours and Colorbar.
conformer_counts holds the exact integer histogram in displayed
(latitude, longitude) order, with latitude_edges and longitude_edges
in radians. In free-energy mode, free_energy holds the masked energy
grid in the same order and in the selected energy_unit.
Source code in matmalib/viz.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
fes_1d(data, *, smooth_window=None, show_raw=True, show_basins=True, energy_unit='kJ/mol', ax=None, color='#235789', label=None)
¶
Plot the 1D FES returned by mlmd.analyze_metadynamics.
Uses the analysis script's local cubic smoothing, basin shading and
projected-barrier marker. Smoothing preserves unsampled gaps and does
not modify the raw profile or its thermodynamics. Set smooth_window=0
to disable it. Return (figure, axes), also retained on this Plot.
Plot.fes continues to handle two-dimensional population plots.
Source code in matmalib/viz.py
fes(data, cols=[1, 2], temp=300, num_levels=8)
¶
Plots MD FES. Takes in data for CP2K or Gromacs via Mol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(Data) Class Data. |
required | |
cols
|
(int) Index of the 2 columns containing your colvar data, in the case that you have more than 2. |
[1, 2]
|
Source code in matmalib/viz.py
contour(xpm_data_list, limit=16)
¶
Plots contour maps for a provided list of moles from xpm files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpm_data_list
|
Data object or list of Data objects read from XPM files. |
required | |
limit
|
(Int) The upper limit on your energy scale |
16
|
Source code in matmalib/viz.py
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | |
foo_plot(data, SCR=None, w=0.5)
¶
Not a bar plot. Mostly used for SCR stuff
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
(Data) Data objects generated from csv files. |
required | |
SCR
|
(list) Specifies specific SCRs to plot from your data. Otherwise, default is to plot them all. |
None
|
|
w
|
(float) Width of the lines in the foo plot. |
0.5
|
Source code in matmalib/viz.py
scatter(data=None, headers=None, format: str = '.', figsize=(6, 6))
¶
Generates a scatter plot from data
Source code in matmalib/viz.py
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 | |
gaussian_broadening(state, broaden=1, resolution=1)
¶
Performs gaussian broadening on IR spectrum generates attribute self.IR - np.array with dimmension 4000/resolution consisting gaussian-boraden spectrum
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
broaden
|
(float) gaussian broadening in wn-1 |
1
|
|
resolution
|
(float) resolution of the spectrum (number of points for 1 wn) defaults is 1, needs to be fixed in plotting |
1
|
Source code in matmalib/viz.py
ir(state, xmin=900, xmax=1700, normal_modes: bool = False)
¶
Plots the IR spectrum in xmin -- xmax range, x-axis is multiplied by scaling factor, everything is normalized to 1. If exp_data is specified, then the top panel is getting plotted too. Need to add output directory. Default name is self._id
Source code in matmalib/viz.py
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 | |
space(list_of_spaces, names=None, quant: str = 'E')
¶
Source code in matmalib/viz.py
Machine-learning molecular dynamics¶
The mlmd interface provides geometry minimization, equilibration, production dynamics, checkpoint restart, periodic solvation, and one-dimensional metadynamics analysis. Its configuration classes are nested under mlmd; simulation dependencies load only when required.
Tutorials: run a simulation, solvate a system, metadynamics, restart, and analyze free energy. The configuration reference explains every configuration class with source-derived defaults; the script feature map records the integration's scope.
matmalib.mlmd.mlmd(model_path=None, *, device=None, compile_model=False, calculator=None, model_kwargs=None)
¶
Simulation interface accepting XYZ/PDB paths or matmalib State objects.
model_path accepts one AIMNet inference file, or a sequence of files
whose predictions are averaged. With no path, all four AIMNet2-2025
B97-3c/D3 members are used. Registry downloads are managed by AIMNet.
Other MLIPs can be used by passing an ASE calculator instance.
Input systems are copied; no trajectory is accumulated in memory.
Source code in matmalib/mlmd.py
model_path = model_path
instance-attribute
¶
device = device
instance-attribute
¶
compile_model = compile_model
instance-attribute
¶
calculator = calculator
instance-attribute
¶
model_kwargs = dict(model_kwargs or {})
instance-attribute
¶
data = Data()
instance-attribute
¶
SystemConfig(cell: Any = None, pbc: bool | tuple[bool, bool, bool] | None = None, charge: float | None = None, multiplicity: int | None = None, min_distance: float = 0.5, fixed_atoms: tuple[int, ...] = (), fix_com: bool = False, shake_hydrogens: bool = False, shake_cutoff: float = 1.3, shake_tolerance: float = 1e-06)
dataclass
¶
cell: Any = None
class-attribute
instance-attribute
¶
pbc: bool | tuple[bool, bool, bool] | None = None
class-attribute
instance-attribute
¶
charge: float | None = None
class-attribute
instance-attribute
¶
multiplicity: int | None = None
class-attribute
instance-attribute
¶
min_distance: float = 0.5
class-attribute
instance-attribute
¶
fixed_atoms: tuple[int, ...] = ()
class-attribute
instance-attribute
¶
fix_com: bool = False
class-attribute
instance-attribute
¶
shake_hydrogens: bool = False
class-attribute
instance-attribute
¶
shake_cutoff: float = 1.3
class-attribute
instance-attribute
¶
shake_tolerance: float = 1e-06
class-attribute
instance-attribute
¶
MinimizationConfig(cell: Any = None, pbc: bool | tuple[bool, bool, bool] | None = None, charge: float | None = None, multiplicity: int | None = None, min_distance: float = 0.5, fixed_atoms: tuple[int, ...] = (), fix_com: bool = False, shake_hydrogens: bool = False, shake_cutoff: float = 1.3, shake_tolerance: float = 1e-06, optimizer: str = 'FIRE', fmax: float = 0.05, steps: int = 10000, maxstep: float = 0.1, optimizer_kwargs: dict[str, Any] = dict(), require_convergence: bool = True, trajectory: str | PathLike | None = None, trajectory_interval: int = 1, log_file: str | PathLike | None = None, overwrite: bool = False)
dataclass
¶
Bases: SystemConfig
optimizer: str = 'FIRE'
class-attribute
instance-attribute
¶
fmax: float = 0.05
class-attribute
instance-attribute
¶
steps: int = 10000
class-attribute
instance-attribute
¶
maxstep: float = 0.1
class-attribute
instance-attribute
¶
optimizer_kwargs: dict[str, Any] = field(default_factory=dict)
class-attribute
instance-attribute
¶
require_convergence: bool = True
class-attribute
instance-attribute
¶
trajectory: str | PathLike | None = None
class-attribute
instance-attribute
¶
trajectory_interval: int = 1
class-attribute
instance-attribute
¶
log_file: str | PathLike | None = None
class-attribute
instance-attribute
¶
overwrite: bool = False
class-attribute
instance-attribute
¶
MetadynamicsConfig(plumed_file: str | PathLike | None = None, input_lines: tuple[str, ...] | None = None, save_input: str | PathLike | None = None, cv: str = 'DISTANCE', cv_label: str = 'cv', atoms: tuple[int, ...] = (1, 2), metad_label: str = 'metad', metad_arg: str | None = None, sigma: float = 0.02, height_kj_mol: float = 2.0, pace: int = 300, biasfactor: float = 10.0, temperature_K: float | None = None, hills_file: str | PathLike = 'HILLS', colvar_file: str | PathLike = 'COLVAR', colvar_stride: int = 10, colvar_arg: str | None = None, wall_type: str | None = None, wall_label: str = 'wall', wall_arg: str | None = None, wall_at: float = 0.35, wall_kappa: float = 150000.0, wall_exp: int = 2, wall_eps: float = 1.0, wall_offset: float = 0.0, calc_rct: bool | None = None, grid_auto: bool | None = None, grid_min: float = 0.0, grid_max: float | None = None, grid_bins: int | None = None, grid_spacing: float = 0.002, log_file: str | PathLike | None = None)
dataclass
¶
plumed_file: str | PathLike | None = None
class-attribute
instance-attribute
¶
input_lines: tuple[str, ...] | None = None
class-attribute
instance-attribute
¶
save_input: str | PathLike | None = None
class-attribute
instance-attribute
¶
cv: str = 'DISTANCE'
class-attribute
instance-attribute
¶
cv_label: str = 'cv'
class-attribute
instance-attribute
¶
atoms: tuple[int, ...] = (1, 2)
class-attribute
instance-attribute
¶
metad_label: str = 'metad'
class-attribute
instance-attribute
¶
metad_arg: str | None = None
class-attribute
instance-attribute
¶
sigma: float = 0.02
class-attribute
instance-attribute
¶
height_kj_mol: float = 2.0
class-attribute
instance-attribute
¶
pace: int = 300
class-attribute
instance-attribute
¶
biasfactor: float = 10.0
class-attribute
instance-attribute
¶
temperature_K: float | None = None
class-attribute
instance-attribute
¶
hills_file: str | PathLike = 'HILLS'
class-attribute
instance-attribute
¶
colvar_file: str | PathLike = 'COLVAR'
class-attribute
instance-attribute
¶
colvar_stride: int = 10
class-attribute
instance-attribute
¶
colvar_arg: str | None = None
class-attribute
instance-attribute
¶
wall_type: str | None = None
class-attribute
instance-attribute
¶
wall_label: str = 'wall'
class-attribute
instance-attribute
¶
wall_arg: str | None = None
class-attribute
instance-attribute
¶
wall_at: float = 0.35
class-attribute
instance-attribute
¶
wall_kappa: float = 150000.0
class-attribute
instance-attribute
¶
wall_exp: int = 2
class-attribute
instance-attribute
¶
wall_eps: float = 1.0
class-attribute
instance-attribute
¶
wall_offset: float = 0.0
class-attribute
instance-attribute
¶
calc_rct: bool | None = None
class-attribute
instance-attribute
¶
grid_auto: bool | None = None
class-attribute
instance-attribute
¶
grid_min: float = 0.0
class-attribute
instance-attribute
¶
grid_max: float | None = None
class-attribute
instance-attribute
¶
grid_bins: int | None = None
class-attribute
instance-attribute
¶
grid_spacing: float = 0.002
class-attribute
instance-attribute
¶
log_file: str | PathLike | None = None
class-attribute
instance-attribute
¶
MDConfig(cell: Any = None, pbc: bool | tuple[bool, bool, bool] | None = None, charge: float | None = None, multiplicity: int | None = None, min_distance: float = 0.5, fixed_atoms: tuple[int, ...] = (), fix_com: bool = False, shake_hydrogens: bool = False, shake_cutoff: float = 1.3, shake_tolerance: float = 1e-06, steps: int = 10000, timestep_fs: float = 0.5, temperature_K: float = 300.0, ensemble: str = 'NVT', thermostat: str = 'langevin', barostat: str = 'mtk', thermostat_time_fs: float = 100.0, barostat_time_fs: float = 1000.0, pressure_bar: float = 1.0, compressibility_per_bar: float = 4.57e-05, thermostat_chain: int = 3, barostat_chain: int = 3, seed: int | None = None, initialize_velocities: bool | None = None, remove_com_motion: bool = True, hydrogen_mass: float | None = None, heavy_mass_multiplier: float = 1.0, max_velocity_angstrom_fs: float | None = None, max_force_eV_A: float | None = 150.0, trajectory: str | PathLike = 'trajectory.xyz', trajectory_interval: int = 10, wrap_output: bool = False, log_file: str | PathLike | None = 'md.log', log_interval: int = 10, checkpoint_interval: int = 1000, checkpoint_file: str | PathLike | None = 'auto', mode: str = 'md', metadynamics: mlmd.MetadynamicsConfig | None = None, minimization: mlmd.MinimizationConfig | None = None, equilibration: mlmd.EquilibrationConfig | None = None, continue_equilibration_bias: bool = False, overwrite: bool = False)
dataclass
¶
Bases: SystemConfig
steps: int = 10000
class-attribute
instance-attribute
¶
timestep_fs: float = 0.5
class-attribute
instance-attribute
¶
temperature_K: float = 300.0
class-attribute
instance-attribute
¶
ensemble: str = 'NVT'
class-attribute
instance-attribute
¶
thermostat: str = 'langevin'
class-attribute
instance-attribute
¶
barostat: str = 'mtk'
class-attribute
instance-attribute
¶
thermostat_time_fs: float = 100.0
class-attribute
instance-attribute
¶
barostat_time_fs: float = 1000.0
class-attribute
instance-attribute
¶
pressure_bar: float = 1.0
class-attribute
instance-attribute
¶
compressibility_per_bar: float = 4.57e-05
class-attribute
instance-attribute
¶
thermostat_chain: int = 3
class-attribute
instance-attribute
¶
barostat_chain: int = 3
class-attribute
instance-attribute
¶
seed: int | None = None
class-attribute
instance-attribute
¶
initialize_velocities: bool | None = None
class-attribute
instance-attribute
¶
remove_com_motion: bool = True
class-attribute
instance-attribute
¶
hydrogen_mass: float | None = None
class-attribute
instance-attribute
¶
heavy_mass_multiplier: float = 1.0
class-attribute
instance-attribute
¶
max_velocity_angstrom_fs: float | None = None
class-attribute
instance-attribute
¶
max_force_eV_A: float | None = 150.0
class-attribute
instance-attribute
¶
trajectory: str | PathLike = 'trajectory.xyz'
class-attribute
instance-attribute
¶
trajectory_interval: int = 10
class-attribute
instance-attribute
¶
wrap_output: bool = False
class-attribute
instance-attribute
¶
log_file: str | PathLike | None = 'md.log'
class-attribute
instance-attribute
¶
log_interval: int = 10
class-attribute
instance-attribute
¶
checkpoint_interval: int = 1000
class-attribute
instance-attribute
¶
checkpoint_file: str | PathLike | None = 'auto'
class-attribute
instance-attribute
¶
mode: str = 'md'
class-attribute
instance-attribute
¶
metadynamics: mlmd.MetadynamicsConfig | None = None
class-attribute
instance-attribute
¶
minimization: mlmd.MinimizationConfig | None = None
class-attribute
instance-attribute
¶
equilibration: mlmd.EquilibrationConfig | None = None
class-attribute
instance-attribute
¶
continue_equilibration_bias: bool = False
class-attribute
instance-attribute
¶
overwrite: bool = False
class-attribute
instance-attribute
¶
EquilibrationConfig(cell: Any = None, pbc: bool | tuple[bool, bool, bool] | None = None, charge: float | None = None, multiplicity: int | None = None, min_distance: float = 0.5, fixed_atoms: tuple[int, ...] = (), fix_com: bool = False, shake_hydrogens: bool = False, shake_cutoff: float = 1.3, shake_tolerance: float = 1e-06, steps: int = 2000, timestep_fs: float = 0.5, temperature_K: float = 300.0, ensemble: str = 'NVT', thermostat: str = 'langevin', barostat: str = 'mtk', thermostat_time_fs: float = 10.0, barostat_time_fs: float = 1000.0, pressure_bar: float = 1.0, compressibility_per_bar: float = 4.57e-05, thermostat_chain: int = 3, barostat_chain: int = 3, seed: int | None = None, initialize_velocities: bool | None = None, remove_com_motion: bool = True, hydrogen_mass: float | None = None, heavy_mass_multiplier: float = 1.0, max_velocity_angstrom_fs: float | None = None, max_force_eV_A: float | None = None, trajectory: str | PathLike | None = None, trajectory_interval: int = 10, wrap_output: bool = False, log_file: str | PathLike | None = 'equilibration.log', log_interval: int = 10, checkpoint_interval: int = 1000, checkpoint_file: str | PathLike | None = 'auto', mode: str = 'md', metadynamics: mlmd.MetadynamicsConfig | None = None, minimization: mlmd.MinimizationConfig | None = None, equilibration: mlmd.EquilibrationConfig | None = None, continue_equilibration_bias: bool = False, overwrite: bool = False)
dataclass
¶
Bases: MDConfig
steps: int = 2000
class-attribute
instance-attribute
¶
thermostat_time_fs: float = 10.0
class-attribute
instance-attribute
¶
max_force_eV_A: float | None = None
class-attribute
instance-attribute
¶
trajectory: str | PathLike | None = None
class-attribute
instance-attribute
¶
log_file: str | PathLike | None = 'equilibration.log'
class-attribute
instance-attribute
¶
SolvationConfig(cell: float | tuple[float, float, float] = 30.0, density_g_ml: float = 1.0, counterion: Any = None, counterion_gap: float = 0.5, packmol: str | PathLike = 'packmol', tolerance: float = 2.0, nloop: int = 1000, timeout: float = 600.0, seed: int = 12345, volume_samples: int = 200000, vdw_radii: dict[str, float] = dict(), work_dir: str | PathLike | None = None, dry_run: bool = False, charge: float | None = None, multiplicity: int = 1, overwrite: bool = False)
dataclass
¶
cell: float | tuple[float, float, float] = 30.0
class-attribute
instance-attribute
¶
density_g_ml: float = 1.0
class-attribute
instance-attribute
¶
counterion: Any = None
class-attribute
instance-attribute
¶
counterion_gap: float = 0.5
class-attribute
instance-attribute
¶
packmol: str | PathLike = 'packmol'
class-attribute
instance-attribute
¶
tolerance: float = 2.0
class-attribute
instance-attribute
¶
nloop: int = 1000
class-attribute
instance-attribute
¶
timeout: float = 600.0
class-attribute
instance-attribute
¶
seed: int = 12345
class-attribute
instance-attribute
¶
volume_samples: int = 200000
class-attribute
instance-attribute
¶
vdw_radii: dict[str, float] = field(default_factory=dict)
class-attribute
instance-attribute
¶
work_dir: str | PathLike | None = None
class-attribute
instance-attribute
¶
dry_run: bool = False
class-attribute
instance-attribute
¶
charge: float | None = None
class-attribute
instance-attribute
¶
multiplicity: int = 1
class-attribute
instance-attribute
¶
overwrite: bool = False
class-attribute
instance-attribute
¶
AnalysisConfig(colvar: Any = None, hills: str | PathLike | None = None, fes_file: str | PathLike | None = None, plumed_input: str | PathLike | None = None, plumed: str | PathLike | None = None, cv: str | None = None, temperature: float | None = None, energy_unit: str | None = None, time_unit: str | None = None, cv_unit: str | None = None, bins: int = 100, grid_range: tuple[float, float] | None = None, energy_column: str = 'file.free', rbias_column: str | None = None, bias_column: str | None = None, rct_column: str | None = None, additional_bias: tuple[str, ...] | None = None, start_time: float | None = None, end_time: float | None = None, upper_wall: tuple[float, float] | None = None, keep_wall: bool = False, reactant: tuple[float, float] | None = None, product: tuple[float, float] | None = None, kappa: float = 1.0, infrequent: bool = False, acceleration_column: str | None = None, smooth_window: int = 11, plot: bool = False, output_dir: str | PathLike | None = None, overwrite: bool = False)
dataclass
¶
colvar: Any = None
class-attribute
instance-attribute
¶
hills: str | PathLike | None = None
class-attribute
instance-attribute
¶
fes_file: str | PathLike | None = None
class-attribute
instance-attribute
¶
plumed_input: str | PathLike | None = None
class-attribute
instance-attribute
¶
plumed: str | PathLike | None = None
class-attribute
instance-attribute
¶
cv: str | None = None
class-attribute
instance-attribute
¶
temperature: float | None = None
class-attribute
instance-attribute
¶
energy_unit: str | None = None
class-attribute
instance-attribute
¶
time_unit: str | None = None
class-attribute
instance-attribute
¶
cv_unit: str | None = None
class-attribute
instance-attribute
¶
bins: int = 100
class-attribute
instance-attribute
¶
grid_range: tuple[float, float] | None = None
class-attribute
instance-attribute
¶
energy_column: str = 'file.free'
class-attribute
instance-attribute
¶
rbias_column: str | None = None
class-attribute
instance-attribute
¶
bias_column: str | None = None
class-attribute
instance-attribute
¶
rct_column: str | None = None
class-attribute
instance-attribute
¶
additional_bias: tuple[str, ...] | None = None
class-attribute
instance-attribute
¶
start_time: float | None = None
class-attribute
instance-attribute
¶
end_time: float | None = None
class-attribute
instance-attribute
¶
upper_wall: tuple[float, float] | None = None
class-attribute
instance-attribute
¶
keep_wall: bool = False
class-attribute
instance-attribute
¶
reactant: tuple[float, float] | None = None
class-attribute
instance-attribute
¶
product: tuple[float, float] | None = None
class-attribute
instance-attribute
¶
kappa: float = 1.0
class-attribute
instance-attribute
¶
infrequent: bool = False
class-attribute
instance-attribute
¶
acceleration_column: str | None = None
class-attribute
instance-attribute
¶
smooth_window: int = 11
class-attribute
instance-attribute
¶
plot: bool = False
class-attribute
instance-attribute
¶
output_dir: str | PathLike | None = None
class-attribute
instance-attribute
¶
overwrite: bool = False
class-attribute
instance-attribute
¶
minimize(system, config=None, *, output=None, output_format=None)
¶
Relax geometry; return a State, or a Path when output is supplied.
output_format='state' returns a State even when writing an XYZ.
output_format='xyz' requires an output path. Nonconvergence raises
unless require_convergence=False; the result records convergence.
Source code in matmalib/mlmd.py
equilibrate(system, config=None, *, output=None, output_format=None)
¶
Run equilibration and return its final State or XYZ path.
Final masses and momenta are retained for a subsequent production run. An optional equilibration trajectory is streamed to its configured path. Checkpoints save positions and velocities every 1,000 steps and at completion by default, with or without PLUMED.
Source code in matmalib/mlmd.py
run_md(system, config=None, *, trajectory=None) -> Path
¶
Run normal or biased dynamics; return the streamed XYZ trajectory path.
All ensembles save positions/velocities checkpoints every 1,000 steps and at completion by default. This includes ordinary MD and generated or custom PLUMED input; PLUMED is not needed for ordinary MD checkpointing.
Source code in matmalib/mlmd.py
restart_md(checkpoint, *, steps, trajectory=None, log_file=None, checkpoint_file='auto') -> Path
¶
Continue a checkpoint for steps additional integration steps.
Restore velocities, RNG and thermostat/barostat state. Output is a new XYZ segment with continuous step/time labels. Use the same calculator and model files as the original run. Generated metadynamics input also restores its saved HILLS/COLVAR history into a new directory.
Source code in matmalib/mlmd.py
solvate(solute, solvent, config=None, *, output=None, output_format=None)
¶
Pack a periodic solvent box; inputs accept XYZ, PDB, or State.
Density is total mass / box volume. The final State contains a
solvation_report with counts, actual density and packing diagnostics.
dry_run=True requires work_dir and returns Data with reusable
packing inputs and the report; omit output/output_format for a dry run.
Source code in matmalib/mlmd.py
analyze_metadynamics(config=None, *, output_format='data')
¶
Analyze a 1D FES and optional infrequent kinetics from PLUMED files.
Return a matmalib Data object accepted by Plot.fes_1d. It is also
stored as self.data. With output_format='files', require
config.output_dir and return that directory after writing CSV/JSON.
Source code in matmalib/mlmd.py
Element mappings¶
matmalib.elements.ELEMENT_SYMBOLS maps string atomic numbers "1"–"118" to element symbols. ELEMENT_NUMBERS maps those symbols back to integer atomic numbers. State.element_symbol, StateBuilder.element_symbol, and InputBuilder.element_number wrap these mappings; they do not supply atomic masses. See element utilities.