To prevent the optimised ligand from going outside the input box, a penalty is added to the binding energy estimate obtained by trilinear interpolation at neighbouring grid nodes during the optimisation. The value of penalty is proportional to the size of the portion of the ligand that was out of the box. The penalty slope equal to 10 6 will be added to the corresponding components of the gradient ∇f . For example, if a ligand molecule exceeds the box boundary on the X axis, the penatly added to the gradient value is slope multiplied by the excess. Similarly for the Y and Z axes.