Skip to content
iurnus edited this page May 16, 2018 · 26 revisions

Instructions to compile#

The CFD-DEM solver lammpsFoam would be successfully installed on a machine with OpenFOAM and LAMMPS. Here are the steps to compile it on your linux machine:

  1. The current version of lammpsFoam is supported by OpenFOAM 2.3.0, 2.3.x, 2.4.0, 3.0 and 4.0. The version of the LAMMPS is lamps-1Feb14.

  2. Copy all the files in InterfaceToLammps folder to lammps-1Feb14/src (you can also create a soft link for each file).

  3. Copy all the files in InterfaceToLammps/MAKE folder to lammps-1Feb14/src/MAKE (you can also create soft link of the files).

  4. Change to the lammps-1Feb14/src folder. Use command make yes-granular to install the granular package of LAMMPS. Add kspace, manybody, molecule, fld, rigid, misc as well in a similar way.

  5. Go back to the lammps-1Feb14/src folder. Use command make shanghailinux to generate an executable file named lmp_shanghailinux in this folder. It may take 10 to 30 minutes.

  6. Stay at lammps-1Feb14/src folder. Use command make makeshlib to generate a new Makefile.shlib file.

  7. Stay at lammps-1Feb14/src folder. Use command make -f Makefile.shlib shanghailinux to compile LAMMPS to a dynamic library. After this step, you will see a file named liblammps_shanghailinux.so in the working directory.

  8. Change to $FOAM_USER_LIBBIN and make a soft link of liblammps_shanghailinux.so generated in the previous step. The command is: ln -s PREVIOUS_DIRECTORY/liblammps_shanghailinux.so ., replace PREVIOUS_DIRECTORY with the FULL directory of the lmp_shanghailinux.so. Usually, the $FOAM_USER_LIBBIN is ~/home/username-2.3.0/platforms/linux64GccOpt/lib, but it may vary due to the system compiling options.

  9. (WARNING: Only for OpenFOAM 3.0 and 4.0) Change to the lammpsfoam_of400_patch folder. Use command ./AllUpdate.sh to run the script to add the patch for OpenFOAM 4.0. If your OpenFOAM version is 2.3.0 or 2.4.0, please do not use this command.

  10. Change to lammpsFoam folder. Use command wmake libso dragModels to compile the drag models. Use command wmake libso chPressureGrad to compile the pressure gradient for channel flow. Use command wmake libso lammpsFoamTurbulenceModels to compile the turbulent models for lammpsFoam.

  11. Change to lammpsFoam/Make folder. Choose the file named options-*-openmpi (* is the name of the operating system (OS)) according to your own OS and rename it as the file named options. (For example, if your OS is Ubuntu, rename the file options-ubuntu-openmpi as options) Then, you should modify the first line which represents the path of lammps/src directory in the options file. The default path is LAMMPS_DIR = ../lammps-1Feb14/src, you should replace ../lammps-1Feb14 with the path where you installed your own lammps package and the correct version name of your lammps package.

  12. Stay at the same directory. Use command wmake to compile the lammpsFoam solver.

The following comments may be useful for some common errors (need some tests):

Step 4: Note: packages of kspace and fld might not be found in the newer version of lammps. Use command 'make no-USER-QUIP' if error message "*** Environment variable QUIP_ROOT must be set.. Stop." occurs.

Step 5: In the case of error "No target to make Makefile.lammps", change Makefile.package.settings to your system. This should have been done by some automatic script. For some reason, my lammps didn't do it. For error "../compute_smd_tlsph_defgrad.cpp:39:23: fatal error: Eigen/Eigen: No such file or directory #include <Eigen/Eigen>",

Step 6: If error, try command "make shanghailinux mode=shlib" instead.

Step 7: After step 6, you can skip this step. (Rui: I think you can skip this step ONLY if you try "make shanghailinux mode=shlib" command in the previous step.)

Step 8: Alternatively, use "ln -s PREVIOUS_DIRECTORY/liblammps_shanghailinux.so liblammps.so". This may solve the problem of "lammpsFoam: error while loading shared libraries: liblammps.so: cannot open shared object file: No such file or directory".

If more errors occur, please consult the webpage at http://lammps.sandia.gov/doc/Section_start.html#making-lammps-with-optional-packages and related pages. Usually the problem comes from the updates of LAMMPS.