-
Notifications
You must be signed in to change notification settings - Fork 52
How 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:
-
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.
-
Copy all the files in
InterfaceToLammps
folder tolammps-1Feb14/src
(you can also create a soft link for each file). -
Copy all the files in
InterfaceToLammps/MAKE
folder tolammps-1Feb14/src/MAKE
(you can also create soft link of the files). -
Change to the
lammps-1Feb14/src
folder. Use commandmake yes-granular
to install thegranular
package of LAMMPS. Addkspace
,manybody
,molecule
,fld
,rigid
,misc
as well in a similar way. -
Go back to the
lammps-1Feb14/src
folder. Use commandmake shanghailinux
to generate an executable file namedlmp_shanghailinux
in this folder. It may take 10 to 30 minutes. -
Stay at
lammps-1Feb14/src
folder. Use commandmake makeshlib
to generate a newMakefile.shlib
file. -
Stay at
lammps-1Feb14/src
folder. Use commandmake -f Makefile.shlib shanghailinux
to compile LAMMPS to a dynamic library. After this step, you will see a file namedliblammps_shanghailinux.so
in the working directory. -
Change to
$FOAM_USER_LIBBIN
and make a soft link ofliblammps_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 thelmp_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. -
(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. -
Change to
lammpsFoam
folder. Use commandwmake libso dragModels
to compile the drag models. Use commandwmake libso chPressureGrad
to compile the pressure gradient for channel flow. Use commandwmake libso lammpsFoamTurbulenceModels
to compile the turbulent models for lammpsFoam. -
Change to
lammpsFoam/Make
folder. Choose the file namedoptions-*-openmpi
(* is the name of the operating system (OS)) according to your own OS and rename it as the file namedoptions
. (For example, if your OS is Ubuntu, rename the fileoptions-ubuntu-openmpi
asoptions
) Then, you should modify the first line which represents the path oflammps/src
directory in theoptions
file. The default path isLAMMPS_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. -
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.