summaryrefslogtreecommitdiff
path: root/lammps.spec
blob: 842d45e2690b78a9dded72ca50d0d556cb4e938f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
%global blaslib openblas
%global blasvar o
%global cmake_blas_flags -DBLAS_LIBRARIES=%{_libdir}/lib%{blaslib}%{blasvar}.so -DLAPACK_LIBRARIES=%{_libdir}/lib%{blaslib}%{blasvar}.so

Name:           lammps
Version:        20241119
Release:        1%{?dist}
Summary:        Molecular Dynamics Simulator
License:        GPL-2.0-only
Url:            https://www.lammps.org/
Source0:        lammps-patch_19Nov2024.tar.gz
Source1:        googletest-1.12.1.tar.gz
Source2:        yaml-0.2.5.tar.gz
Source3:        opencl-loader-2024.05.09.tar.gz
Source4:        spglib-1.11.2.1.tar.gz
Source5:        heffte-2.4.0.tar.gz

Patch0:         0-lammps-change-cmake-download.patch

BuildRequires:  environment-modules
BuildRequires:  fftw-devel
BuildRequires:  gcc-c++
BuildRequires:  gcc-fortran
BuildRequires:  libpng-devel
BuildRequires:  libjpeg-devel
%ifnarch %ix86
BuildRequires:  openmpi-devel
BuildRequires:  python3-mpi4py-openmpi
BuildRequires:  python3-mpi4py-mpich
%endif
BuildRequires:  mpich-devel
BuildRequires:  python3-devel
BuildRequires:  python3-numpy
BuildRequires:  fftw3-devel
BuildRequires:  zlib-devel
BuildRequires:  gsl-devel
BuildRequires:  voro++-devel
BuildRequires:  %{blaslib}-devel
BuildRequires:  hdf5-devel
BuildRequires:  kim-api-devel
BuildRequires:  kim-api-examples
BuildRequires:  cmake3 >= 3.16
BuildRequires:  ocl-icd-devel
BuildRequires:  opencl-headers
BuildRequires:  tbb-devel
BuildRequires:  readline-devel

Requires:       %{name}-data

%global lammps_desc \
LAMMPS is a classical molecular dynamics code, and an acronym for Large-scale \
Atomic/Molecular Massively Parallel Simulator.\
\
LAMMPS has potentials for soft materials (biomolecules, polymers) and \
solid-state materials (metals, semiconductors) and coarse-grained or \
mesoscopic systems. It can be used to model atoms or, more generically, as a \
parallel particle simulator at the atomic, meso, or continuum scale. \
\
LAMMPS runs on single processors or in parallel using message-passing \
techniques and a spatial-decomposition of the simulation domain. The code is \
designed to be easy to modify or extend with new functionality.


%description
%{lammps_desc}

%ifnarch %ix86
%global with_openmpi 1
%package openmpi
Summary:        LAMMPS Open MPI binaries and libraries
Requires:       openmpi
Requires:       %{name}-data

%description openmpi
%{lammps_desc}

This package contains LAMMPS Open MPI binaries and libraries
%endif

%package mpich
Summary:        LAMMPS MPICH binaries and libraries
Requires:       mpich
Requires:       %{name}-data

%description mpich
%{lammps_desc}

This package contains LAMMPS MPICH binaries and libraries

%package -n python3-%{name}
Summary:        LAMMPS Python interface
Requires:       python3
Requires:       python3-numpy
Requires:       %{name}%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python3-%{name}}

%description -n python3-%{name}
%{lammps_desc}

This package contains LAMMPS Python interface

%package headers
Summary:        Development headers for LAMMPS

%description headers
%{lammps_desc}

This package contains development headers for LAMMPS.

%package devel
Summary:        Development libraries for LAMMPS
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       %{name}-headers%{?_isa} = %{version}-%{release}

%description devel
%{lammps_desc}

This package contains development libraries for serial LAMMPS.

%package mpich-devel
Summary:        Development libraries for MPICH LAMMPS
Requires:       %{name}-mpich%{?_isa} = %{version}-%{release}
Requires:       %{name}-headers%{?_isa} = %{version}-%{release}

%description mpich-devel
%{lammps_desc}

This package contains development headers and libraries for MPICH LAMMPS.

%ifnarch %ix86
%package openmpi-devel
Summary:        Development libraries for Open MPI LAMMPS
Requires:       %{name}-openmpi%{?_isa} = %{version}-%{release}
Requires:       %{name}-headers%{?_isa} = %{version}-%{release}

%description openmpi-devel
%{lammps_desc}

This package contains development libraries for Open MPI LAMMPS.
%endif

%package data
Summary:        Data files for LAMMPS
BuildArch:      noarch

%description data
%{lammps_desc}

This package contains data files for LAMMPS.

BuildRequires:  python3-setuptools >= 42
BuildRequires:  python3-wheel
BuildRequires:  python3-build

%prep
%autosetup -p1 -n lammps-patch_19Nov2024
cp %{SOURCE5} cmake/

%build
set +e
. /etc/profile.d/modules.sh
set -e

for mpi in '' mpich %{?with_openmpi:openmpi} ; do
  test -n "${mpi}" && module load mpi/${mpi}-%{_arch}
  if [ -z "$mpi" ]; then
    mkdir build && cd build
  else
    mkdir build-${mpi} && cd build-${mpi}
  fi
  #python wrapper isn't mpi specific
  %{cmake3} ../cmake \
  -C ../cmake/presets/all_on.cmake \
  -C ../cmake/presets/nolib.cmake \
  %{cmake_blas_flags} \
  -DCMAKE_TUNE_FLAGS='' \
  -DCMAKE_CUSTOM_LINKER="default" \
  -DPKG_PYTHON=ON \
  -DPKG_VORONOI=ON \
  -DPKG_ATC=ON \
  -DPKG_H5MD=ON \
  -DPKG_KIM=ON \
  -DENABLE_TESTING=ON \
  -DGTEST_URL=file://%{S:1} \
  -DYAML_URL=file://%{S:2} \
  -DOPENCL_LOADER_URL=file://%{S:3} \
  -DSPGLIB_URL=file://%{S:4} \
  -DDOWNLOAD_POTENTIALS=OFF \
  -DPYTHON_INSTDIR=%{python3_sitelib} \
  -DCMAKE_INSTALL_SYSCONFDIR=/etc \
  -DPKG_GPU=ON -DGPU_API=OpenCL \
  -DBUILD_OMP=ON \
  -DFFT=FFTW3 \
%ifnarch x86_64 %x86
  -DPKG_INTEL=OFF \
%endif
    -DCMAKE_INSTALL_BINDIR=${MPI_BIN:-%{_bindir}} -DCMAKE_INSTALL_LIBDIR=${MPI_LIB:-%{_libdir}} -DLAMMPS_MACHINE="${MPI_SUFFIX#_}" -DLAMMPS_LIB_SUFFIX="${MPI_SUFFIX#_}" -DCMAKE_INSTALL_MANDIR=${MPI_MAN:-%{_mandir}} \
    ${mpi:+-DBUILD_MPI=ON -DFFT_USE_HEFFTE=ON -DCMAKE_EXE_LINKER_FLAGS="%{__global_ldflags} -Wl,-rpath -Wl,${MPI_LIB} -Wl,--enable-new-dtags" -DCMAKE_SHARED_LINKER_FLAGS="%{__global_ldflags} -Wl,-rpath -Wl,${MPI_LIB} -Wl,--enable-new-dtags" $(test "$mpi" != openmpi || echo "-DMPIEXEC_PREFLAGS=--oversubscribe") } \
    $(test -z "${mpi}" && echo -DBUILD_MPI=OFF -DBUILD_LAMMPS_SHELL=ON -DBUILD_TOOLS=ON)
    cmake --build . -j8
  test -n "${mpi}" && module unload mpi/${mpi}-%{_arch}
  cd ..
done

cd python
%py3_build

%install
set +e
. /etc/profile.d/modules.sh
set -e

for mpi in '' mpich %{?with_openmpi:openmpi} ; do
  if [ -z "$mpi" ]; then
    %make_install -C build
  else
    %make_install -C build-${mpi}
  fi
done

cd python
%py3_install

%check
 
%global testargs --label-exclude unstable --exclude-regex '\(SimpleCommands\|Variables\|ComputeGlobal\|MolPairStyle:coul_slater_long\|AtomicPairStyle:meam_spline\|FixTimestep:.*\|.*tip4p.*\)'
 
%ifnarch %ix86
%global testargs --label-exclude unstable --exclude-regex '\(SimpleCommands\|Variables\|ComputeGlobal\|MolPairStyle:coul_slater_long\|AtomicPairStyle:meam_spline\|FixTimestep:.*\|.*tip4p.*\|Groups\|AtomicPairStyle:lj_cut_sphere\|AtomicPairStyle:lj_expand_sphere\|AtomicPairStyle:meam_ms\|AtomicPairStyle:pedone\|DihedralStyle:cosine_squared_restricted\|BondStyle:harmonic_restrain\)'
%endif
 
%ifarch s390x
%global testargs --label-exclude unstable --exclude-regex '\(SimpleCommands\|Variables\|ComputeGlobal\|MolPairStyle:coul_slater_long\|AtomicPairStyle:meam_spline\|FixTimestep:.*\|.*tip4p.*\|LibraryMPI\|MPILoadBalancing\|FileOperations\|Groups\|SetProperty\|AtomicPairStyle:lj_cut_sphere\|AtomicPairStyle:lj_expand_sphere\|AtomicPairStyle:meam_ms\|AtomicPairStyle:pedone\|DihedralStyle:cosine_squared_restricted\|BondStyle:harmonic_restrain\|TestPairList\)'
%endif
 
set +e
. /etc/profile.d/modules.sh
set -e
 
for mpi in '' mpich %{?with_openmpi:openmpi}; do
  old_PYTHONPATH="${PYTHONPATH}"
  test -n "${mpi}" && module load mpi/${mpi}-%{_arch} && export PYTHONPATH="${MPI_PYTHON3_SITEARCH}:${PYTHONPATH}"
  if [ -z "$mpi" ]; then
    cd build
    ctest %{?testargs} || true
  else
    cd build-${mpi}
    ctest %{?testargs} || true
  fi
  cd ..
  test -n "${mpi}" && module unload mpi/${mpi}-%{_arch} && export PYTHONPATH="${old_PYTHONPATH}"
done

%ldconfig_scriptlets

%files
%doc README
%license LICENSE
%{_bindir}/lmp
%{_mandir}/man1/lmp.*
%{_libdir}/liblammps.so.*
%{_bindir}/msi2lmp
%{_mandir}/man1/msi2lmp.*
%{_bindir}/binary2txt
%{_bindir}/chain.x
%{_bindir}/micelle2d.x
%{_bindir}/stl_bin2txt
%{_bindir}/phana

%exclude %{_builddir}/lammps-patch_19Nov2024/build/phana_build/spglib_build_ext/include/spglib.h
%exclude %{_builddir}/lammps-patch_19Nov2024/build/phana_build/spglib_build_ext/lib/libsymspg.a
 
%files devel
%{_libdir}/liblammps.so
%{_libdir}/pkgconfig/liblammps.pc
%{_libdir}/cmake/LAMMPS
 
%ifnarch %ix86
%files openmpi-devel
%{_libdir}/openmpi*/lib/liblammps_openmpi.so
%{_libdir}/openmpi*/lib/pkgconfig/liblammps_openmpi.pc
%{_libdir}/openmpi*/lib/cmake/LAMMPS
%endif
 
%files mpich-devel
%{_libdir}/mpich*/lib/liblammps_mpich.so
%{_libdir}/mpich*/lib/pkgconfig/liblammps_mpich.pc
%{_libdir}/mpich*/lib/cmake/LAMMPS
 
%files -n python3-%{name}
%{python3_sitelib}/lammps
%{python3_sitelib}/lammps-*.egg-info
 
%files headers
%license LICENSE
%{_includedir}/%{name}/
 
%ifnarch %ix86
%files openmpi
%license LICENSE
%{_libdir}/openmpi*/bin/lmp_openmpi
%{_mandir}/openmpi*/man1/lmp_openmpi.*
%{_libdir}/openmpi*/lib/liblammps_openmpi.so.*
%endif
 
%files mpich
%license LICENSE
%{_libdir}/mpich*/bin/lmp_mpich
%{_mandir}/mpich*/man1/lmp_mpich.*
%{_libdir}/mpich*/lib/liblammps_mpich.so.*
 
%files data
%license LICENSE
%{_datadir}/%{name}
%config %{_sysconfdir}/profile.d/lammps.*

%changelog
* Tue Dec 26 2024 zhtianyu <zhangtianyu@iscas.ac.cn> - 20241119-1
- Package init