Constraints

This page documents the constraint syntax, shared between input files and the Julia API. It follows the keywords of Fortran Packmol, and adds new constraints.

A constraint restricts where the atoms of a structure are allowed to be. In an input file, each one is declared as a line inside a structure ... end structure block, and takes the form:

<placement> <shape> <parameters...>

Multiple constraints can be given for the same structure — a molecule must then satisfy all of them simultaneously (e.g. inside box ... together with outside sphere ... carves a box with a spherical hole in it). By default a constraint applies to every atom of the structure; in an input file, wrapping a subset of lines in an atoms <indices> ... end block restricts a constraint to just those atoms (see Structure blocks in Input files).

In Julia code, a region can also be defined by any function of the position of the atoms, with CustomConstraint (see Custom constraints).

Note

Constraints are independent of, but interact with, periodic boundary conditions: setting pbc/unitcell changes how every constraint below is evaluated (atoms are wrapped to the periodic image nearest the cell center first), and bounds the centers of mass of the molecules to the cell. See Periodic boundary conditions for the pbc/unitcell keywords themselves and the full relationship between the two.