An atomistic molecular dynamics simulation method is proposed for the computation of Frank elastic constants of nematic liquid crystals. The method uses spatially modulated aligning forces that cause distortion in the spatial distribution of the nematic director. Test calculations on the 5CB molecule indicate very good agreement between the simulation and experiment.