htmd.builder.solvate module#

htmd.builder.solvate.solvate(mol, pad=None, minmax=None, centersel=None, boxsize=None, negx=0, posx=0, negy=0, posy=0, negz=0, posz=0, buffer=2.4, watsize=65.4195, prefix='W', rotate=False, spdb=None)#

Solvate a molecular system in a water box.

Places water molecules around the input molecule by tiling a pre-built water box and removing waters that clash with existing atoms or fall outside the specified box boundaries.

Parameters:
  • mol (Molecule) – The molecule to solvate.

  • pad (float | None) – Uniform padding in Angstroms to add around the molecule in all six directions. Overrides negx, posx, negy, posy, negz, posz.

  • minmax (list | ndarray | None) – Explicit box boundaries as a 2D array of the form [[minx, miny, minz], [maxx, maxy, maxz]]. If None, derived from the molecule’s own coordinates.

  • centersel (str | ndarray | None) – An atom selection string, a boolean mask, or an integer index array (see Molecule.atomselect) defining the center of the solvation box. The geometric center of the selected atoms is used. Must be combined with boxsize.

  • boxsize (float | list | ndarray | None) – Dimensions of the solvation box. A single float creates a cubic box; a 3-element list [sx, sy, sz] creates an axis-aligned box. Must be combined with centersel.

  • negx (float) – Padding in Angstroms in the -x direction.

  • posx (float) – Padding in Angstroms in the +x direction.

  • negy (float) – Padding in Angstroms in the -y direction.

  • posy (float) – Padding in Angstroms in the +y direction.

  • negz (float) – Padding in Angstroms in the -z direction.

  • posz (float) – Padding in Angstroms in the +z direction.

  • buffer (float) – Minimum distance in Angstroms between water molecules and other atoms.

  • watsize (float) – Edge length in Angstroms of the pre-built water box tile.

  • prefix (str) – Prefix string used for water segment names.

  • rotate (bool) – If True, rotate the molecule to minimize box volume (not yet implemented).

  • spdb (str | None) – Path to a custom water PDB file. If None, uses the built-in water box.

Returns:

mol – A copy of the input molecule with water molecules added.

Return type:

Molecule

Examples

>>> smol = solvate(mol, pad=10)
>>> smol = solvate(mol, minmax=[[-20, -20, -20],[20, 20, 20]])
>>> smol = solvate(mol, centersel="protein", boxsize=100)
>>> smol = solvate(mol, centersel="protein", boxsize=[80, 80, 120])