2018-08-08 05:40:23 +01:00
|
|
|
{ lib
|
|
|
|
, bash
|
|
|
|
, stdenv
|
|
|
|
, writeText
|
|
|
|
, fetchFromGitHub
|
|
|
|
, libpng
|
|
|
|
, gzip
|
|
|
|
, fftw
|
|
|
|
, openblas
|
|
|
|
, mpiSupport ? false, mpi ? null
|
2016-04-01 21:10:06 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert mpiSupport -> mpi != null;
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
# LAMMPS has weird versioning converted to ISO 8601 format
|
2018-08-08 05:40:23 +01:00
|
|
|
version = "patch_2Aug2018";
|
2016-04-01 21:10:06 +01:00
|
|
|
name = "lammps-${version}";
|
|
|
|
|
2018-08-08 05:40:23 +01:00
|
|
|
lammps_packages = "asphere body class2 colloid compress coreshell dipole granular kspace manybody mc misc molecule opt peri qeq replica rigid shock snap srd user-reaxc";
|
|
|
|
lammps_includes = "-DLAMMPS_EXCEPTIONS -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "lammps";
|
|
|
|
repo = "lammps";
|
|
|
|
rev = "${version}";
|
|
|
|
sha256 = "1ph9pr7s11wgmspmnhxa55bh1pq2cyl8iimfi62lbpbpl9pr1ilc";
|
2016-04-01 21:10:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit mpi;
|
|
|
|
};
|
|
|
|
|
2018-08-08 05:40:23 +01:00
|
|
|
buildInputs = [ fftw libpng openblas gzip bash ]
|
2016-04-01 21:10:06 +01:00
|
|
|
++ (stdenv.lib.optionals mpiSupport [ mpi ]);
|
|
|
|
|
|
|
|
# Must do manual build due to LAMMPS requiring a seperate build for
|
|
|
|
# the libraries and executable
|
|
|
|
builder = writeText "builder.sh" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
2018-08-08 05:40:23 +01:00
|
|
|
mkdir lammps
|
|
|
|
cp -r $src/lib $src/src lammps
|
|
|
|
chmod -R 755 lammps/src/
|
|
|
|
cd lammps/src
|
|
|
|
for pack in ${lammps_packages}; do make "yes-$pack" SHELL=$SHELL; done
|
|
|
|
make mode=exe ${if mpiSupport then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
|
|
|
|
make mode=shlib ${if mpiSupport then "mpi" else "serial"} SHELL=$SHELL LMP_INC="${lammps_includes}" FFT_PATH=-DFFT_FFTW3 FFT_LIB=-lfftw3 JPG_LIB=-lpng
|
2016-04-01 21:10:06 +01:00
|
|
|
|
|
|
|
mkdir -p $out/bin
|
2018-08-08 05:40:23 +01:00
|
|
|
cp -v lmp_* $out/bin/
|
|
|
|
|
|
|
|
mkdir -p $out/include
|
|
|
|
cp -v *.h $out/include/
|
2016-04-01 21:10:06 +01:00
|
|
|
|
|
|
|
mkdir -p $out/lib
|
|
|
|
cp -v liblammps* $out/lib/
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Classical Molecular Dynamics simulation code";
|
|
|
|
longDescription = ''
|
|
|
|
LAMMPS is a classical molecular dynamics simulation code designed to
|
|
|
|
run efficiently on parallel computers. It was developed at Sandia
|
|
|
|
National Laboratories, a US Department of Energy facility, with
|
|
|
|
funding from the DOE. It is an open-source code, distributed freely
|
|
|
|
under the terms of the GNU Public License (GPL).
|
|
|
|
'';
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = http://lammps.sandia.gov;
|
2016-04-01 21:10:06 +01:00
|
|
|
license = stdenv.lib.licenses.gpl2;
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
2018-08-08 05:40:23 +01:00
|
|
|
maintainers = with lib.maintainers; [ costrouc ];
|
2016-04-01 21:10:06 +01:00
|
|
|
};
|
|
|
|
}
|