http://www.ime.unicamp.br/~martinez/packmolby clicking on the Download link. By following this link you will download the file packmol.tar.gz which contains the whole source code of Packmol.
tar xvzf packmol.tar.gzThis will create a directory called packmol inside which you can find the source code. You can build the executable by:
cd packmol makeThat's it, if no error was reported the packmol executable was built.
1.  fixed 
Usage: fixed x y z a b g This options holds the molecule fixed in the position specified by the parameters. x, y, z, a, b, g, which are six real numbers. The first three determine the translation of the molecule relative to its position in the coordinate file. The former three parameters are rotation angles (in radians). For this option it is required that only one molecule is set. It may be accompanied by the keyword center. If this keyword is present the first three numbers are the position of the baricenter (not really the center of mass, because we suppose that all atoms have the same mass). Therefore this keyword must be used in the following context: structure molecule.pdb number 1 center fixed 0. 0. 0. 0. 0. 0. end structure In this example, the molecule will be fixed with its center the origin and no rotation.  
2.  inside cube 
Usage: inside cube x_{min} y_{min} z_{min} d x_{min} , y_{min} , z_{min} and d are four real numbers. The coordinates (x,y,z) of the atoms restrained by this option will satisfy, at the solution: x_{min} < x < x_{min} + d y_{min} < y < y_{min} + d z_{min} < z < z_{min} + d  
3.  outside cube 
Usage: outside cube x_{min} y_{min} z_{min} d x_{min} , y_{min} , z_{min} and d are four real numbers. The coordinates (x,y,z) of the atoms restrained by this option will satisfy, at the solution: x < x_{min} or x > x_{min} + d y < y_{min} or y > y_{min} + d z < z_{min} or z > z_{min} + d  
4.  inside box 
Usage: inside box
x_{min}
y_{min}
z_{min}
x_{max}
y_{max}
z_{max} x_{min} , y_{min} , z_{min} , x_{max} , y_{max} and z_{max} are six real numbers. The coordinates (x,y,z) of the atoms restrained by this option will satisfy, at the solution: y_{min} < y < y_{max} z_{min} < z < z_{max}  
5.  outside box 
Usage: outside box
x_{min}
y_{min}
z_{min}
x_{max}
y_{max}
z_{max} x_{min} , y_{min} , z_{min} , x_{max} , y_{max} and z_{max} are six real numbers. The coordinates (x,y,z) of the atoms restrained by this option will satisfy, at the solution: y < y_{min} or y > y_{max} z < z_{min} or z > z_{max}  
6.  inside (or outside) sphere 
Spheres are defined by equations of the general form and, therefore, you must provide four real parameters a, b, c and d in order to define it. The input syntax is, for example, inside sphere 2.30 3.40 4.50 8.0 and therefore the coordinates of the atoms will satisfy the equation Other input alternative would be: outside sphere 2.30 3.40 4.50 8.0 The outside parameter is similar to the inside parameter, but the equation above uses instead of and, therefore, the atoms will be placed outside the defined sphere.  
7.  inside (or outside) ellipsoid 
Ellipsoids are defined by the general equation
The parameters must be given as in the sphere example, but now they are 7, and must be entered in the following order: inside ellipsoid a_{1} b_{1} c_{1} a_{2} b_{2} c_{2} d The coordinates (a_{1},b_{1},c_{1}) will define the center of the ellipsoid, the coordinates (a_{2},b_{2},c_{2}) will define the relative size of the axes and d will define the volume of the ellipsoid. Of course, the commands outside ellipsoid a_{1} b_{1} c_{1} a_{2} b_{2} c_{2} d can also be used in the same manner as the parameters for spheres. Note that the case a_{2} = b_{2} = c_{2} = 1.0 provides the exactly the same as the sphere parameter. The parameters for the ellipsoid are not normalized. Therefore, if a_{2}, b_{2} and c_{2} are large, the ellipsoid will be large, even for a small d.  
8.  over (or below) plane 
The planes are defined by the general equation
And it is possible to restrict atoms to be over or below the plane. The syntax is over plane 2.5 3.2 1.2 6.2 below plane 2.5 3.2 1.2 6.2 where the over keyword will make the atoms satisfy the condition the below keyword will make the atoms satisfy  
9.  inside (or outside) cylinder 
In order to define a cylinder, it is necessary first to define a
line oriented in space. This line is defined in Packmol by the
parametric equation
where t is the independent parameter. The vector (a_{2} , b_{2} , c_{2}) defines the direction of the line. The cylinder is therefore defined by the distance to this line, d, and a length l. Therefore, the usage must be: inside cylinder a_{1} b_{1} c_{1} a_{2} b_{2} c_{2} d l outside cylinder a_{1} b_{1} c_{1} a_{2} b_{2} c_{2} d l Here, the first three parameters define the point where the cylinder starts, and l defines the length of the cylinder. d defines de radius of the cylinder. The simpler example is a cylinder oriented in the x axis and starting at the origin, such as inside cylinder 0. 0. 0. 1. 0. 0. 10. 20. This cylinder is specified by the points that have a distance of 10. to the x axis (the cylinder has a radius of 10.). Furthermore, it starts at the origin, therefore no atom restricted by this cylinder will have an x coordinate less than 0. Furthermore, it has a length of 20. and, as such, no atom will have an x coordinate greater than 20. The orientation of the cylinder, parallel to the x axis is defined by the director vector (1,0,0), the fourth, fifth and sixth parameters. Cylinders can be oriented in space in anyway.  
10.  Constrain rotations 
It is possible to constrain rotations of all molecules of each type, so
that they have some average orientation in space.
The keywords to be used are, within a structure...end structure section: constrain_rotation x 180. 20. constrain_rotation y 180. 20. constrain_rotation z 180. 20. Each of these keywords restricts the possible rotation angles around each axis to be within 180±20 degrees (or any other value). For a technical reason the rotation around the z axis will, alone, be identical to the rotation around the y axis (we hope to fix this some day). Constraining the three rotations will constrain completely the rotations. Note that to have your molecules oriented parallel to an axis, you need to constrain the rotations relative to the other two. For example, to constrain the rotation of your molecule along the z axis, use something like: constrain_rotation x 0. 20. constrain_rotation y 0. 20. Note that these rotations are defined relative to the molecule in the orientation which was provided by the user, in the input PDB file. Therefore, it is a good idea to orient the molecule in a reasonable way in order to understand the rotations. For example, if the molecule is elongated in one direction, a good idea is to provide the molecule with the larger dimension oriented along the z axis. 
tolerance
parameter. In this
case it is possible to think that the radius of every atom is half the
distance tolerance. A tolerance of 2.0 Angs is usually fine for
simulation of molecular systems using allatom models.
radius
" keyword within the
structure ... end structure
section of a molecule type, or
within atoms ... end atoms
section of an atom selection.
tolerance 2.0
structure water.pdb
number 500
inside box 0. 0. 0. 30. 30. 30.
radius 1.5
end structure
the radius of the atoms of the water molecules will be 1.5. Note that
this implies a distance tolerance of 3.0 within water molecules.
tolerance 2.0
structure water.pdb
number 500
inside box 0. 0. 0. 30. 30. 30.
atoms 1 2
radius 1.5
end atoms
end structure
only atoms 1 and 2 of the water molecule (as listed in the water.pdb
file) will have a radius of 1.5, while atom 3 will have a radius of 1.0,
as defined by the tolerance of 2.0
solvate.tcl
script,
which is used to solvate large molecules, usually proteins, with water
and ions (Na^{+} and Cl^{}). Given the PDB file of the
biomolecule, just run the script with:
solvate.tcl PROTEIN.pdb
packmol_input.inp
. With this file, run Packmol with
solvate.tcl structure.pdb shell 15. charge +5 density 1.0 i pack.inp
o solvated.pdb
Where: 
structure.pdb is the pdb file to be solvated (usually a protein)
" 15. " is the size of the solvation shell. This
is an optional parameter. If not set, 15. will be used.
+5 is the total charge of the system, to be neutralized.
This is also and optional parameter, if not used, the package
considers histidine residues as neutral, Arg and Lys as +1
and Glu and Asp as 1. The Na+ and Cl concentrations are set
the closest possible to 0.16M, approximately the physiological
concentration.
Alternatively, use the noions to not add any ions, just water.
1.0 is the desired density. Optional. If not set, the density
will be set to 1.0 g/ml.
solvated.pdb : is the (optional) name for the solvated system
output file. If this argument is not provided, it will be the default
solvated.pdb file.
pack.inp : is the (optional) name for the packmol input file that
will be generated. If not provided, packmol_input.inp will be used.

structure peptide.pdb number 10 resnumbers 1 inside box 0. 0. 0. 20. 20. 20. end structureDefault: The default behavior is to use 0 for structures with only one residue and 1 for structures with more than one residue.
changechains
structure...end structure
section of a type of molecule, the chains will alternate between
two values ("A" and "B" for example). This might be useful if the
molecules are peptides, and topology builders sometimes think
that the peptides of the same chain must be join by covalent bonds.
This is avoided by alternating the chain from molecule to molecule.
chain D
structure water.pdb number 1000 inside cube 0. 0. 0. 40. restart_to water1.pack end structureThis will generate a restart file for the water molecules only.
structure water.pdb number 1000 inside cube 0. 0. 0. 40. restart_from water1.pack end structureThe new input file might contain other molecules, as a regular Packmol input file, and these water molecules will be packed together with the new molecules, but starting from the previous runs. This can be used, for example, to build solvated bilayers by parts. For instance, the bilayers could be built and, later, different solvents can be added to the bilayer, without having to restart the whole system construction from scratch every time. This could also be used to add some molecule to the bilayer.
• Look at the best solution obtained, many times it is good enough to be used.  
• Simulate the same problem with only a few molecules of each type. For example, instead of using 20 thousand water molecules, put 300, and see if they are in the correct regions.  
• If you have large molecules, try running the program twice, one to pack these molecules, and then use the solution as fixed molecule for the next packing, in which solvation is included. This may be particularly useful for building solvated membranes. Build the membrane first and then use it as a fixed molecule for a solvation run.  
• You can change some options of the packing procedure to try
improve the optimization:
