diff options
author | markuskowa <markus.kowalewski@gmail.com> | 2023-08-04 10:55:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-04 10:55:44 +0200 |
commit | 394beeefa6133b9645baa5a202f8c52a7b6577cc (patch) | |
tree | ac348df5da7c8d7d7cf3bb8fd582f38b08782f2a /pkgs/applications | |
parent | 3e36ea62d7302c0da62960534d99069868a6b2f0 (diff) | |
parent | eacf49d19ecfd2e121d523f83bf449ba368e3c33 (diff) |
Merge pull request #246983 from sheepforce/molcas-qcmaquis
openmolcas: enable dmrg and nevpt2 support
Diffstat (limited to 'pkgs/applications')
-rw-r--r-- | pkgs/applications/science/chemistry/openmolcas/default.nix | 74 | ||||
-rw-r--r-- | pkgs/applications/science/chemistry/openmolcas/qcmaquis.patch | 46 |
2 files changed, 108 insertions, 12 deletions
diff --git a/pkgs/applications/science/chemistry/openmolcas/default.nix b/pkgs/applications/science/chemistry/openmolcas/default.nix index c99c5da06f372..695d5502b5eb1 100644 --- a/pkgs/applications/science/chemistry/openmolcas/default.nix +++ b/pkgs/applications/science/chemistry/openmolcas/default.nix @@ -1,19 +1,47 @@ -{ lib, stdenv, fetchFromGitLab, cmake, gfortran, perl -, blas-ilp64, hdf5-cpp, python3, texlive -, armadillo, libxc, makeWrapper -# Note that the CASPT2 module is broken with MPI -# See https://gitlab.com/Molcas/OpenMolcas/-/issues/169 +{ lib +, stdenv +, fetchFromGitLab +, fetchFromGitHub +, cmake +, gfortran +, perl +, blas-ilp64 +, hdf5-cpp +, python3 +, texlive +, armadillo +, libxc +, makeWrapper +, gsl +, boost175 +, autoPatchelfHook + # Note that the CASPT2 module is broken with MPI + # See https://gitlab.com/Molcas/OpenMolcas/-/issues/169 , enableMpi ? false -, mpi, globalarrays -} : +, mpi +, globalarrays +}: assert blas-ilp64.isILP64; assert lib.elem blas-ilp64.passthru.implementation [ "openblas" "mkl" ]; let - python = python3.withPackages (ps : with ps; [ six pyparsing numpy h5py ]); + python = python3.withPackages (ps: with ps; [ six pyparsing numpy h5py ]); + qcmaquisSrc = fetchFromGitHub { + owner = "qcscine"; + repo = "qcmaquis"; + rev = "release-3.1.1"; # Must match tag in cmake/custom/qcmaquis.cmake + hash = "sha256-diLDWj/Om6EHrVp+Hd24jsN6R9vV2vRl0y9gqyRWhkI="; + }; + nevtp2Src = fetchFromGitHub { + owner = "qcscine"; + repo = "nevpt2"; + rev = "e1484fd"; # Must match tag in cmake/custom/nevpt2.cmake + hash = "sha256-Vl+FhwhJBbD/7U2CwsYE9BClSQYLJ8DKXV9EXxQUmz0="; + }; -in stdenv.mkDerivation { +in +stdenv.mkDerivation { pname = "openmolcas"; version = "23.06"; @@ -28,12 +56,22 @@ in stdenv.mkDerivation { patches = [ # Required to handle openblas multiple outputs ./openblasPath.patch + + # Required for a local QCMaquis build + ./qcmaquis.patch ]; postPatch = '' # Using env fails in the sandbox substituteInPlace Tools/pymolcas/export.py --replace \ "/usr/bin/env','python3" "python3" + + # Pointing CMake to local QCMaquis and NEVPT2 archives + substituteInPlace cmake/custom/qcmaquis.cmake \ + --subst-var-by "qcmaquis_src_url" "file://${qcmaquisSrc}" + + substituteInPlace cmake/custom/nevpt2.cmake \ + --subst-var-by "nevpt2_src_url" "file://${nevtp2Src}" ''; nativeBuildInputs = [ @@ -42,6 +80,7 @@ in stdenv.mkDerivation { cmake texlive.combined.scheme-minimal makeWrapper + autoPatchelfHook ]; buildInputs = [ @@ -50,6 +89,8 @@ in stdenv.mkDerivation { python armadillo libxc + gsl.dev + boost175 ] ++ lib.optionals enableMpi [ mpi globalarrays @@ -64,10 +105,15 @@ in stdenv.mkDerivation { "-DHDF5=ON" "-DFDE=ON" "-DEXTERNAL_LIBXC=${libxc}" + "-DDMRG=ON" + "-DNEVPT2=ON" + "-DCMAKE_SKIP_BUILD_RPATH=ON" ] ++ lib.optionals (blas-ilp64.passthru.implementation == "openblas") [ - "-DOPENBLASROOT=${blas-ilp64.passthru.provider.dev}" "-DLINALG=OpenBLAS" + "-DOPENBLASROOT=${blas-ilp64.passthru.provider.dev}" + "-DLINALG=OpenBLAS" ] ++ lib.optionals (blas-ilp64.passthru.implementation == "mkl") [ - "-DMKLROOT=${blas-ilp64.passthru.provider}" "-DLINALG=MKL" + "-DMKLROOT=${blas-ilp64.passthru.provider}" + "-DLINALG=MKL" ] ++ lib.optionals enableMpi [ "-DGA=ON" "-DMPI=ON" @@ -89,6 +135,10 @@ in stdenv.mkDerivation { rm -r $out/Tools ''; + # DMRG executables contain references to /build, however, they are properly + # removed by autopatchelf + noAuditTmpdir = true; + postFixup = '' # Wrong store path in shebang (no Python pkgs), force re-patching sed -i "1s:/.*:/usr/bin/env python:" $out/bin/pymolcas @@ -101,7 +151,7 @@ in stdenv.mkDerivation { description = "Advanced quantum chemistry software package"; homepage = "https://gitlab.com/Molcas/OpenMolcas"; maintainers = [ maintainers.markuskowa ]; - license = licenses.lgpl21Only; + license = with licenses; [ lgpl21Only bsd3 ]; platforms = [ "x86_64-linux" ]; mainProgram = "pymolcas"; }; diff --git a/pkgs/applications/science/chemistry/openmolcas/qcmaquis.patch b/pkgs/applications/science/chemistry/openmolcas/qcmaquis.patch new file mode 100644 index 0000000000000..ca276bb3fb584 --- /dev/null +++ b/pkgs/applications/science/chemistry/openmolcas/qcmaquis.patch @@ -0,0 +1,46 @@ +diff --git a/cmake/custom/nevpt2.cmake b/cmake/custom/nevpt2.cmake +index 789739ec8..6c86a7b8c 100644 +--- a/cmake/custom/nevpt2.cmake ++++ b/cmake/custom/nevpt2.cmake +@@ -67,6 +67,7 @@ list(APPEND NEVPT2CMakeArgs + "-DMOLCAS_BUILD_DIR=${PROJECT_BINARY_DIR}" + "-DCMAKE_Fortran_MODULE_DIRECTORY=${mod_dir}" + "-DDMRG_INCLUDE=${HDF5_QCM_INCLUDE}" ++ "-DCMAKE_SKIP_BUILD_RPATH=ON" + ) + + if(HDF5_ROOT) +@@ -118,9 +119,7 @@ endif () + + ExternalProject_Add(${EP_PROJECT} + PREFIX ${CUSTOM_NEVPT2_LOCATION} +- GIT_REPOSITORY ${reference_git_repo} +- GIT_TAG ${reference_git_commit} +- UPDATE_DISCONNECTED ${EP_SkipUpdate} ++ URL @nevpt2_src_url@ + CMAKE_ARGS "${NEVPT2CMakeArgs}" + INSTALL_DIR "${PROJECT_BINARY_DIR}/qcmaquis" + ) +diff --git a/cmake/custom/qcmaquis.cmake b/cmake/custom/qcmaquis.cmake +index 176d02761..e160b7bc8 100644 +--- a/cmake/custom/qcmaquis.cmake ++++ b/cmake/custom/qcmaquis.cmake +@@ -78,6 +78,7 @@ list(APPEND QCMaquisCMakeArgs + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS=${QCM_CMake_CXX_FLAGS} + -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> ++ -DCMAKE_SKIP_BUILD_RPATH=ON + ) + if(HDF5_ROOT) + list(APPEND QCMaquisCMakeArgs +@@ -278,9 +279,7 @@ set (CMAKE_DISABLE_SOURCE_CHANGES OFF) + + ExternalProject_Add(${EP_PROJECT} + PREFIX ${extprojpath} +- GIT_REPOSITORY ${reference_git_repo} +- GIT_TAG ${reference_git_commit} +- UPDATE_DISCONNECTED ${EP_SkipUpdate} ++ URL @qcmaquis_src_url@ + + SOURCE_SUBDIR dmrg + CMAKE_ARGS ${EP_CMAKE_ARGS} |