LAMMPS software installation tutorial for Linux

Table of contents

1. Preparation before installation

2. Download and install four compilation tools

3. Download FFTW, MPICH and LAMMPS installation packages

4. Install FFTW and MPICH

5. Install LAMMPS

6. Test the software and set the path


1. Preparation before installation

The previous article "VMware Virtual Machine Ubuntu System Installation Tutorial" has shared how to install a virtual machine and Linux system. This article will install the LAMMPS software on this basis. The specific process can be divided into the following steps:

  1. Install the four necessary compilation tools (used to compile the software into computer-recognizable executable programs)
  2. Install FFTW (mathematical assembly for Fourier transforms) and MPICH (assembly for parallel computing)
  3. Install LAMMPS software

2. Download and install four compilation tools

sudo su    #进入管理员模式,需输入密码并回车确认
apt-get install gcc    #安装gcc编译器
apt-get install g++    #安装g++编译器
apt-get install gfortran    #安装gfortran编译器
apt-get install make    #安装make编译器

3. Download FFTW, MPICH and LAMMPS installation packages

To avoid online installation failure, my personal suggestion is to download the installation packages of the three software first, and then transfer them to the Linux system for offline installation.

Personally, it is recommended to decompress and install the downloaded FFTW, MPICH and LAMMPS compressed packages in the same "lammps" folder for easier management. Taking the author as an example, the three installation packages are named "fftw-3.3.10.tar.gz", "mpich-4.1.2.tar.gz" and "lammps-stable.tar.gz", all of which are stored in " /home/lc/software/lammps ” (=" ~/software/lammps ") path. The instructions to decompress the three compressed packages are:

tar -zxvf fftw-3.3.10.tar.gz
tar -zxvf mpich-4.1.2.tar.gz
tar -zxvf lammps-stable.tar.gz

After decompression, there are three more folders "fftw-3.3.10", "mpich-4.1.2" and "lammps-23Jun2022" in the "lammps" folder.

4. Install FFTW and MPICH

The default FFTW and MPICH calling paths of LAMMPS software are " /usr/local " (you can open the "Makefile.fftw" file and "Makefile" under the " ~/software/lammps/lammps-23Jun2022/src/MAKE/OPTIONS " path .g++_mpich_link" file, the former's FFT_INC, FFT_PATH and the latter's MPI_INC, MPI_PATH all contain the " /usr/local " field). Therefore, for the convenience of subsequent compilation of LAMMPS, both FFTW and MPI are installed in this path.

(1) Install FFTW:

cd ~/software/lammps/fftw-3.3.10    #进入“fftw-3.3.10”文件夹
./configure --prefix=/usr/local --enable-float    #配置FFTW安装路径
sudo make    #编译FFTW源文件
sudo make install    #将编译好的FFTW程序安装至系统中

(2) Install MPICH:

cd ~/software/lammps/mpich-4.1.2    #进入“mpich-4.1.2”文件夹
./configure --prefix=/usr/local    #配置MPICH安装路径
sudo make    #编译MPICH源文件
sudo make install    #将编译好的MPICH程序安装至系统中

Among them, the "./configure" instruction is used to execute the "configure" script in the current directory and generate a "Makefile" file, which specifies information such as compiler type and parameters. Then use the "make" command to compile according to the "Makefile" file.

5. Install LAMMPS

Before compiling the LAMMPS software, you can first check the dependency package status of each functional module:

cd ~/software/lammps/lammps-23Jun2022/src    #进入安装文件夹
make package-status    #查看依赖包状态

At this time, you will find that each module is in the "NO" status. To install some of the modules, you need to set it to "YES". The command is:

make yes-MANYBODY
make yes-KSPACE
make yes-MOLECULE
make yes-MISC    #准备安装MANYBODY等四个模块

Then compile the parallel computing version of the executable program (serial computing has almost no usage scenarios, so there is no need to compile):

sudo make mpi    #编译“并行计算”的可执行程序

If the compilation is successful, an executable program file named "lmp_mpi" will be generated.

If you want to install other modules in the future, you can enter the folder again, set the dependency package availability of the required modules to "YES", and then recompile the program.

6. Test the software and set the path

After compilation, you can enter the test folder to test whether the software is successfully installed and configured:

cd ~/software/lammps/lammps-23Jun2022/examples/deposit    #进入测试文件夹
/usr/local/bin/mpirun -n 2 ~/software/lammps/lammps-23Jun2022Mar/src/lmp_mpi < in.deposit.atom    #运行程序,计算测试案例

If there is no problem, you can write the program path into the terminal settings, so that when you call the program in the future, you don't need to enter such a long string of text. The online tutorials for this step all use the vi or vim program to edit files, which is troublesome for novices who are not familiar with Linux. In fact, you can edit it here through the Xftp program and Notepad. First, set Xftp to display hidden folders and enter the " /home/lc " (= " ~ ") path; then use Notepad to open the ".bashrc" file, paste the following content at the end of the document, and save it (note that you need to modify it Change the path to your own folder and do not change other content):

# lammps
export PATH=/usr/local/bin:/usr/local/lib:/usr/local/include:/home/lc/software/lammps/lammps-23Jun2022/src:$PATH
# lammps end

The file can be reloaded through the " source ~/.bashrc " command to make the content effective. You can also close the terminal directly, and this part of the content will be automatically loaded the next time you open the terminal (ctrl+alt+T).

After making the changes, you can test again whether the setting is successful:

cd ~/software/lammps/lammps-23Jun2022/examples/deposit
mpirun -n 2 lmp_mpi < in.deposit.atom

If successful, the settings are correct.

Guess you like

Origin blog.csdn.net/u011618064/article/details/131955141