Monday, May 3, 2010

Install LAMMPS on UBUNTU

1. lammps install with makefile.serial no makefile.linux
From: http://ubuntuforums.org/showthread.php?t=1038282&highlight=LAMMPS&page=2

Download it from lammps.sandia.gov


In the terminal write the following:

gunzip lammps*.tar.gz
tar xvf lammps*.tar


This will create a file named: ''lammps-21Nov09'' (The date may change depending of the updates in the website).


It will contain the following files: bench, doc, examples, lib, potentials, src, tools.


christian@christian-laptop:~/lammps/lammps-21Nov09$ cd src
christian@christian-laptop:~/lammps/lammps-21Nov09$ cd MAKE


Before keep going it is necessary to solve some dependencies: build-essential (to compile in C), MPIch (to work in parallel) , FFTW ( to compute long-range interactions), libxaw7 (to compute the movies). In one line code you choose


sudo apt-get install build-essential mpich-bin libmpich1.0-dev fftw2 fftw-dev libxaw7-dev


If you are working in your personal computer you just need


sudo apt-get install build-essential
sudo apt-get install libxaw7-dev


To avoid future problems it will be better installing with the first line code
Now in the MAKE file you will see a lot of makefiles.xxx. Most users think Makefile.linux is the one they should use because they use ''linux.'' If you open the Makefile.linux you will see that it requires MPICH and FFTW. Things that we actually don't need (especially if we are starting the use of lammps). What a Beginner needs to install is Makefile.serial. If you open this file you will see in the first line that it says: no MPICH, no FFTW.


If you read carefully the Makefile.serial, in one line it says:
# MPI library, can be src/STUBS dummy lib.
If you go to STUBS you will find a Makefile, this will create a dummy lib for MPI in accordance to the Makefile.serial. So in the STUBS file you type:


christian@christian-laptop:~/lammps/lammps-21Nov09/src/STUBS$ make clean
christian@christian-laptop:~/lammps/lammps-21Nov09/src/STUBS$ make


Then you go back to src and compile lammps


christian@christian-laptop:~/lammps/lammps-21Nov09/src$ make clean-all
christian@christian-laptop:~/lammps/lammps-21Nov09/src$ make serial

It will work correctly, to verify your installation we will run some examples. First type


christian@christian-laptop:~/lammps/lammps-21Nov09/src$ ./lmp_serial
You should get:


LAMMPS (7 Jul 2009)


This means you are ok in the installation process, ctrl-C to get out and let's go to the examples file (cd ../examples), Choose any, and get deep in learning the meaning of the codes. Each example has one or more lammps input files.
For instance I will choose ''flow'' (cd flow). It has two in.flow.xxx files. (input files). I will run one of them by typing:


christian@christian-laptop:~/lammps/lammps-21Nov09/examples/flow$ ../../src/lmp_serial < in.flow.couette


Where is the data stored? Check the in.flow.couette file to see where it is. Almost at the end it says:


dump 1 all atom 50 dump.flow


So the data is stored in dump.flow
To finish this test let's visualize the data in a movie. First let's install xmovie
For this


christian@christian-laptop:~/lammps/lammps-21Nov09/examples/flow$ cd ../../tools/
christian@christian-laptop:~/lammps/lammps-21Nov09/tools$ cd xmovie
christian@christian-laptop:~/lammps/lammps-21Nov09/tools/xmovie$ make
christian@christian-laptop:~/lammps/lammps-21Nov09/tools/xmovie$ ./xmovie


Now you will be able to visualize your data using xmovie just by typing in the flow directory


christian@christian-laptop:~/lammps/lammps-21Nov09/examples/flow$ ../../tools/xmovie/xmovie -scale dump.flow


This will open the program, maybe your screen will appear black, change the color of your particles and click in Start to watch it.

http://ubuntuforums.org/attachment.php?attachmentid=140676&d=1261350130



2. 1. lammps install with makefile for parallel
From : http://ubuntuforums.org/showthread.php?t=1390490

I will tell you how to compile a serial and parallel version of LAMMPS (24Jan10) on Ubuntu 9.10. I don't expect to be making many return trips to this post, since as far as I can tell, everything works smoothly.

A couple disclaimers:
  • Nearly everything can be figured out by thoroughly reading the LAMMPS documentation (link). That includes this entire guide!
  • Don't forget the mailing list (link). Someone may have already asked your question so be sure to search it (link).
  • I am going to assume you are comfortable issuing commands in the terminal.
  • I will not deal with the instructions for older versions of LAMMPS or Ubuntu, since they are outdated and correspondingly more complicated.
  • I am not responsible if you cannot get LAMMPS to compile.
  • These instructions have been only tested to work on 25 January 2010 on a fresh Ubuntu 9.10 (Karmic) installation.
  • It is your job to manage multiple MPI implementations if that is an issue on your machine. I assume there is no MPI infrastructure installed and install mpich2.
  • The version of LAMMPS changes very rapidly, so just replace lammps-24Jan10 with lammps-(whatever your package release date is) and everything should still work.
  • Finally, LAMMPS will probably never be available through apt-get because of very quick release of patches and updates as well as the inability to modify/extend LAMMPS if it were installed by apt-get. That means LAMMPS never gets "installed", and when you call it, the path to the binary must be explicitly given or be found within the $PATH.

Let's start making LAMMPS!
  1. Enable Universe Repository, if not enabled (link)
  2. Install required packages to build LAMMPS
    You will need superuser privileges to successfully issue:
    Code:
    sudo apt-get install build-essential fftw-dev tcsh mpich2 gfortran
    • build-essential is non-negotiable, and you may already have it installed.
    • fftw-dev installs developer files for FFTW2 (not FFTW3, which won't work!) at standard locations that ubuntu knows about. It's possible to configure a LAMMPS compilation without any FFT tables, but I won't cover that here.
    • tcsh is required so the LAMMPS Makefile system works. Substituting this with the "csh" package probably won't make any difference. (EDIT: As of the 30 Jan 2010 patch, this package is no longer needed).
    • mpich2 will install MPICH-2, which can perform compilation of MPI programs linking to native MPI libraries. If only want a serial binary, you may safely leave this package off the list. While there are many other MPI implementations, I am not going to cover them here, though the idea is still the same. MPICH is kind of odd in that it requires a little bit more configuration to make it work, see below for the additional instructions.
    • gfortran is required to compile and link against the Fortran libraries MEAM and REAX. If you use a different Fortran compiler, or will not be linking these libraries, it is safe to leave this item off the package list.
  3. Get LAMMPS
    You can do this by going to the LAMMPS WWW site (link) or by issuing the following command in terminal
    Code:
    wget -m -nd http://lammps.sandia.gov/tars/lammps.tar.gz
  4. Unpack LAMMPS
    Code:
    tar xvzf lammps.tar.gz
  5. Copy Makefile to lammps-24Jan10/src/MAKE/Makefile.ubuntu
    I have attached two files, one for serial and parallel builds. Due to the restrictions of the ubuntuforums.org, I had to give these with a ".txt" extension. When copying the makefile, I highly recommend removing everything from the underscore to the end off the filename (especially including the .txt!).
  6. Compile LAMMPS
    Make sure you are sitting in lammps-24Jan10/src (not the MAKE directory!). You'll need the STUBS library if you're making a serial binary
    Code:
    # for parallel binaries
    
    make ubuntu
    # for serial, make STUBS, then LAMMPS
    cd STUBS ; make ; cd ..
    make ubuntu
  7. Try an example to verify it works
    While sitting in the src directory, the first command should run the "crack" example in serial mode. If your computer supports it, the second command should utilize 2 cores and run faster. Remember, even if you compile using the parallel makefile, the first invocation will still work, and is the reason you don't need a separate binary for serial runs.
    Code:
    # change to the examples/crack directory
    
    cd ../examples/crack
    # for serial or parallel builds
    ../../lmp_ubuntu < in.crack
    # for parallel builds only
    mpiexec -np 2 ../../lmp_ubuntu <>

Finally, I note that if you want to build lammps again after a new release or when patches of merged with the trunk, You can simply begin at step 3 and follow to the end. That "wget" command should always give you the latest package as long as the LAMMPS people keep their website they way they have it now.

--------

Finishing the configuration of MPICH2
To finish your MPICH2 installation, you need to make a file at ~/.mpd.conf. The MPICH2 documentation tells you:
Code:
A file named .mpd.conf file must be present in the user's home

directory (/etc/mpd.conf if root) with read and write access
only for the user, and must contain at least a line with:
MPD_SECRETWORD=
One way to safely create this file is to do the following:
cd $HOME
touch .mpd.conf
chmod 600 .mpd.conf
and then use an editor to insert a line like
MPD_SECRETWORD=mr45-j9z
into the file. (Of course use some other secret word than mr45-j9z.)
The secret word isn't the utmost secret there is to be had--it's more just a mechanism that MPICH2 uses to make sure users don't step on each others toes. So just type in a jumble of letters and get on with running stuff.
Attached Files
File Type: txt Makefile.ubuntu_serial.txt (649 Bytes, 96 views)
File Type: txt Makefile.ubuntu_parallel.txt (649 Bytes, 115 views)

Last edited by Yoshis88; February 1st, 2010 at 02:02 PM..


12 comments:

  1. This post is very helpful for me, thank you so much!

    ReplyDelete
  2. This post helps very much. However remember to copy the in.crack to the src directory. Or copy the lmp_ubuntu executable to the working directory containing your input file.

    ReplyDelete
  3. Thank your for your effort to prepare this document. It is really useful for beginners like me.

    ReplyDelete
  4. Thanks for your kind post, I finally could install LAMMPS thanks to this post. However I found that after obtaining the lmp_serial file I still could not run LAMMPS, just after I installed openmpi-1.5 then I could run my input script. Perhaps installing openmpi-1.5 is obvious I just want to notice this fact to beginners like myself.

    Thanks again.

    ReplyDelete
  5. Dear Katter,

    I got a simple question, I installed LAMMPS following your instructions. My machine is a workstation with 4 physical processors and 4 logical. When I run my scripts I input on the shell something like: mpirun -np 4 or mpirun -np 8. However, when I monitor my system I only see 2 CPU's working. Should I install LAMMPS in parallel or should I input something different in the command line?

    Thanks!

    ReplyDelete
  6. This post was amazing, it really helped me! Just a quick question: are all the standard packages (http://lammps.sandia.gov/doc/Section_packages.html#pkg_1) included when following this procedure? Because I'm gonna work with class2 force field, and I don't know if I should install any other complementary packages.

    Thanks!

    ReplyDelete
  7. nice instructions. It really helped a lot.

    ReplyDelete
  8. very nice. This was useful to a lammps newbie even in 2015. Thank you.

    ReplyDelete
  9. well, the xmovie installation will often not work simply like this because X11 development packages are not installed in the right place. See the discussion here: http://dft-blog.natanzon.eu/2012/05/installing-xmovie-tool.html

    ReplyDelete
    Replies
    1. hello this like seems not working
      \

      Delete
  10. I couldn't find the folder 'xmovie' after installing LAMMPS in ubuntu. What should I do now?

    ReplyDelete