dwsideriusNIST / LAMMPS_Examples

Examples LAMMPS simulations to generate thermodynamic properties of simple molecular models
80 stars 25 forks source link

Add docker support #5

Open ianhbell opened 4 years ago

ianhbell commented 4 years ago

I don't know how you want to handle updates to the repo, but I have put together some encapsulated docker environments that run the simple example. I struggled a bit to get the right combination of packages to run the examples, but this should basically work I think.

Docker is a very powerful, industry standard, approach for process encapsulation, and is very well suited to reproducbility.

## Use "docker-compose up --build" to build and run

FROM centos:7.3.1611

RUN yum install -y --setopt=skip_missing_names_on_install=False cmake git zip gcc make openmpi openmpi-devel gcc-c++ numpy

# This ADD block forces a build (invalidates the cache) if the git repo contents have changed, otherwise leaves it untouched.
# See https://stackoverflow.com/a/39278224
ADD https://api.github.com/repos/dwsideriusNIST/LAMMPS_Examples/git/refs/heads/master examples-version.json
RUN git clone --recursive https://github.com/dwsideriusNIST/LAMMPS_Examples.git
ADD https://api.github.com/repos/lammps/lammps/git/refs/heads/master examples-version.json
RUN git clone --recursive https://github.com/lammps/lammps.git

# Add necessary paths
ENV PATH="/lammps/src:/usr/lib64/openmpi/bin:${PATH}"

# Build the LAMMPS executable
WORKDIR /lammps/src
RUN git checkout r15061 && \
    make package-update && \
    make yes-user-misc && \
    make yes-opt && \
    make -j8 mpi

# Link the initial states into the working folder
WORKDIR /LAMMPS_Examples/LJ_example
RUN ln -s ../LJ_initial_cfgs/in.nvt.dens_*.* ./

# The task to run
CMD mpirun -np 12 --allow-run-as-root lmp_mpi -sf opt -in NVT.startfromrestart -var rho 0.4000 -var temp 1.5 && \
    ls -al && \
    ../analysis/block_analysis.py -f ave.dens_0.4000.out -b 5 -m 100000