The following script may help you, which applies a force in Z-direction. You have to select a list of atoms to which you have to apply it. This script can be copied straight to the configuration NAMD script that you call from namd.
tclForces on
tclForcesScript {
set cellLengthZ $ZLength ;# The length in the z-direction (=cellBasisVector3)