Water and urea
A periodic box of 1000 water molecules and 400 urea molecules: the simplest kind of system, a homogeneous liquid, in which every molecule can be anywhere in the cell.
Water (sticks) and urea (balls and sticks), with the edges of the periodic box (drag to rotate, scroll to zoom).
Files: water.pdb, urea.pdb and the input file mixture.inp.
The periodic box
The input file:
#
# A mixture of water and urea
#
# All the atoms from different molecules will be separated at least 2.0
# Angstroms in the solution.
tolerance 2.0
# The file type of the input and output files is PDB
filetype pdb
# The name of the output file
output mixture.pdb
# To write only the initial placement of the molecules to the output file,
# without packing them (to check the constraints), uncomment the line below.
# check_initial_placement
# The periodic box: from the origin to x, y and z = 40. 40. 40., a cube of
# side 40. The molecules are packed in it, and they are kept 2.0 Angstroms
# apart also from the periodic images of the other molecules.
pbc 40. 40. 40.
# 1000 water molecules and 400 urea molecules. The periodic box confines
# them: no constraint is needed.
structure water.pdb
number 1000
end structure
structure urea.pdb
number 400
end structure
pbc 40. 40. 40. sets a periodic box from the origin to (40, 40, 40) (see Orthorhombic box). The box confines the molecules, so they need no constraint, and the distances between them are computed across its faces: the molecules near a face are kept tolerance away from those near the opposite face, and the box can be used in a simulation with periodic boundary conditions as it is, with no gaps or overlaps at the faces. The output file has the CRYST1 record of the box.
Run it with:
packmol mixture.inpThe packed system is written to mixture.pdb. A system this simple needs no check of the initial placement, but the input has the check_initial_placement line, commented, as all the tutorials (see Checking the initial placement).
Julia script
Each structure ... end structure block is a structure_type, and the global keywords (tolerance, output, pbc) are keyword arguments of PackmolSystem:
using Packmolwater = structure_type("water.pdb"; number = 1000)urea = structure_type("urea.pdb"; number = 400)system = PackmolSystem([water, urea]; output = "mixture.pdb", tolerance = 2.0, unitcell = [40. 0. 0.; 0. 40. 0.; 0. 0. 40.], # centered at the origin # check_initial_placement = true, # uncomment to only place the molecules)packmol(system)unitcell is the matrix of the cell vectors (as columns); the cell is centered at the origin, unless unitcell_center is given (unitcell_center = [20., 20., 20.] is the box of pbc 40. 40. 40.). The output format follows the extension of the output file, so filetype is not needed.
The packed coordinates are also available without reading the output file: get_atoms(system) returns them as a vector of atoms.