I have been looking for the same code. It is not exactly trivial. I found some code in the following book
"The Molecular Dynamics of Liquid Crystals,by G. R. Luckhurst, C. A. Veracini"
I have been looking for a DJVU copy of this book but haven't found one.