Path A - Module 40: PBC Geometry & Conventions#
To run a simulation, you need a “World”. In Computational Biology, this world is usually a box that repeats itself infinitely in space: the Periodic Boundary Conditions (PBC).
In this module, you will learn to master the geometry of your simulation box using MolSysMT.
import molsysmt as msm
from molsysmt import systems
# Load a solvated fibril complex (it already has a box)
fibril = msm.convert('pdb:2BEG', to_form='molsysmt.MolSys')
solvated_molsys = msm.build.solvate(fibril, box_shape='cubic', clearance='1.0 nm')
1. Checking for PBC#
Not every molecular system has a box. Before simulating, you must verify that the Periodic Boundary Conditions are defined.
has_box = msm.pbc.has_pbc(solvated_molsys)
print(f"Does the system have a simulation box? {has_box}")
2. Box Dimensions and Shape#
Simulation boxes can be cubes, rhombic dodecahedrons, or general triclinic shapes. MolSysMT can tell you the shape and the volume.
# Get the box matrix
box = msm.get(solvated_molsys, element='system', box=True)
# Identify the shape
shape = msm.pbc.get_shape_from_box(box)
# Calculate the volume
volume = msm.pbc.get_volume_from_box(box)
print(f"Box Shape: {shape}")
print(f"Box Volume: {volume}")
3. Lengths and Angles#
If you prefer to work with lengths (a, b, c) in nanometers and angles (alpha, beta, gamma) instead of a 3x3 matrix, MolSysMT provides converters and computes the volume directly from these parameters.
lengths, angles = msm.pbc.get_lengths_and_angles_from_box(box)
volume_from_parameters = msm.pbc.get_volume_from_lengths_and_angles(lengths, angles)
print(f"Lengths (nm): {lengths}")
print(f"Angles: {angles}")
print(f"Volume from lengths and angles: {volume_from_parameters}")
🏆 Path A Challenge: The Box Designer#
Take the Villin trajectory from the database.
Measure the Box Volume for all frames. Does it change during the simulation? (This indicates a simulation in the NPT ensemble).
Use
msm.pbc.get_box_from_lengths_and_angles()to create a custom triclinic box with \(a=b=c=5\) nm and \(\alpha=60, \beta=60, \gamma=60\) degrees.Check the volume of your custom box.
Understanding the world’s boundaries is the first step of physics. In Module 41, we will learn how to handle the “teleportation” of atoms across these boundaries: Wrapping & Unwrapping.