Calculation of the interaction energy of one molecule with its whole surrounding. I. Method and application to pure nonpolar compounds