Skip to content

Commit

Permalink
Merge pull request #138 from sheepforce/psi4
Browse files Browse the repository at this point in the history
psi4: external libint + generic blas, dft-d3: replace with free fork
  • Loading branch information
markuskowa authored Jan 20, 2022
2 parents eca4512 + fa9167c commit 816062b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 81 deletions.
13 changes: 0 additions & 13 deletions pkgs/apps/dft-d3/Linking.patch

This file was deleted.

36 changes: 12 additions & 24 deletions pkgs/apps/dft-d3/default.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,29 @@
{ lib, stdenv, fetchurl, gfortran } :
{ lib, stdenv, fetchFromGitHub, gfortran } :

stdenv.mkDerivation rec {
pname = "dft-d3";
version = "3.2rev0";
pname = "dftd3-lib";
version = "0.10"; # Equivalent to 3.2rev0 of the original

nativeBuildInputs = [ gfortran ];

src = fetchurl {
url = "https://www.chemie.uni-bonn.de/pctc/mulliken-center/software/dft-d3/dftd3.tgz";
sha256 = "0n8gi0raz8rik1rkd4ifq43wxs56ykxlhm22hpyq3ak1ixszjz6r";
src = fetchFromGitHub {
owner = "dftbplus";
repo = pname;
rev = version;
hash = "sha256-lda0eEb/QoMG2Sb1/VhJSr+fJcu2wvy1hqw+rVDhe2w=";
};

unpackPhase = ''
tar -xvf $src
'';

# Using gfortran for linking instead of ifort
patches = [
./Linking.patch
];

dontConfigure = true;


installPhase = ''
mkdir -p $out/bin
cp -p dftd3 $out/bin
cp prg/dftd3 $out/bin/.
'';

hardeningDisable = [
"format"
];
hardeningDisable = [ "format" ];

meta = with lib; {
description = "Dispersion correction for DFT";
homepage = "https://www.chemie.uni-bonn.de/pctc/mulliken-center/software/dft-d3/get-the-current-version-of-dft-d3";
homepage = "https://github.com/dftbplus/dftd3-lib";
platforms = platforms.unix;
license = licenses.unfree;
license = licenses.gpl1;
};
}
12 changes: 0 additions & 12 deletions pkgs/apps/psi4/LibintCmake.patch

This file was deleted.

69 changes: 37 additions & 32 deletions pkgs/apps/psi4/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib, buildPythonPackage, buildPackages, makeWrapper, fetchFromGitHub, fetchurl, pkg-config
{ lib, stdenv, buildPythonPackage, buildPackages, makeWrapper, fetchFromGitHub, fetchurl, pkg-config
, writeTextFile, cmake, perl, gfortran, python, pybind11, qcelemental, qcengine, numpy, pylibefp
, deepdiff, mkl, gau2grid, libxc, dkh, dftd3, pcmsolver, libefp, chemps2, hdf5, hdf5-cpp
, deepdiff, blas, lapack, gau2grid, libxc, dkh, dftd3, pcmsolver, libefp, chemps2, hdf5, hdf5-cpp
, pytest, mpfr, gmpxx, eigen, boost
} :

Expand Down Expand Up @@ -36,9 +36,34 @@ let
'';
});

libintSrc = fetchurl {
url = "https://github.com/loriab/libint/releases/download/v0.1/Libint2-export-7-7-4-7-7-5_1.tgz";
sha256 = "16vgnjpspairzm72ffjc8qb1qz0vwbx1cq237mc3c79qvqlw2zmn";
libint = stdenv.mkDerivation rec {
pname = "libint";
version = "0.1";

src = fetchurl {
url = "https://github.com/loriab/${pname}/releases/download/v${version}/Libint2-export-7-7-4-7-7-5_1.tgz";
hash = "sha256-tn7BKd44HTZYPUNgFvriG3wcFkZMOidO/Tmqq6+0b5s=";
};

nativeBuildInputs = [ cmake ];
propagatedBuildInputs = [ eigen boost mpfr ];

preConfigure = ''
ulimit -s 65536
cmakeFlagsArray+=(
${builtins.toString specialInstallCmakeFlags}
-DLIBINT2_SHGAUSS_ORDERING=gaussian
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED=ON
-DBUILD_STATIC=ON
-DMERGE_LIBDERIV_INCLUDEDIR=OFF
-DBUILD_FPIC=ON
-DENABLE_GENERIC=ON
-DCMAKE_CXX_FLAGS=-fPIC
-DENABLE_CXX11API=ON
-DCMAKECONFIG_INSTALL_DIR=$out/share/cmake/Libint2
)
'';
};

testInputs = {
Expand All @@ -65,7 +90,6 @@ let
};
};


in buildPythonPackage rec {
pname = "psi4";
version = "1.5";
Expand All @@ -82,17 +106,16 @@ in buildPythonPackage rec {
buildInputs = [
gau2grid
libxc
mkl
blas
lapack
dkh_
pcmsolver_
libefp
chemps2_
hdf5
hdf5-cpp
eigen
mpfr
gmpxx
boost
libint
];

propagatedBuildInputs = [
Expand All @@ -119,18 +142,6 @@ in buildPythonPackage rec {
sha256 = "sha256-NVpE5fAVWYlkymTrvptZ7xqu68eVy71YJ+dRdBMMU9c=";
};

patches = [ ./LibintCmake.patch ];

# Required for Libint compilation. g++ will otherwise not be able to link the large amount of files.
preConfigure = ''
ulimit -s 65536
'';

# Must be done after configuration unfortunately. Directories are overridden otherwise.
postConfigure = ''
cp ${libintSrc} external/upstream/libint2/libint2_external-prefix/src/Libint2-export-7-7-4-7-7-5_1.tgz
'';

cmakeFlags = [
"-DDCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF"
"-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF"
Expand All @@ -142,11 +153,11 @@ in buildPythonPackage rec {
# gau2grid
"-DCMAKE_INSIST_FIND_PACKAGE_gau2grid=ON"
"-Dgau2grid_DIR=${gau2grid}/share/cmake/gau2grid"
# libint. Force to build within Psi4's own CMake system. It requires that many tunings
# compared to the upstream version, that everything else is just wasting time.
# libint
"-DMAX_AM_ERI=7"
"-DBUILD_SHARED_LIBS=ON"
"-DCMAKE_DISABLE_FIND_PACKAGE_Libint=ON"
"-DCMAKE_INSIST_FIND_PACKAGE_Libint=ON"
"-DLibint2_DIR=${libint}/share/cmake/Libint2"
# libxc
"-DCMAKE_INSIST_FIND_PACKAGE_Libxc=ON"
"-DLibxc_DIR=${libxc}/share/cmake/Libxc"
Expand All @@ -163,7 +174,7 @@ in buildPythonPackage rec {
# CheMPS2
"-DENABLE_CheMPS2=ON"
# Prefix path for all external packages
"-DCMAKE_PREFIX_PATH=\"${gau2grid};${libxc};${qcelemental};${pcmsolver_};${dkh_};${libefp};${chemps2_}\""
"-DCMAKE_PREFIX_PATH=\"${gau2grid};${libxc};${qcelemental};${pcmsolver_};${dkh_};${libefp};${chemps2_};${libint}\""
];

format = "other";
Expand Down Expand Up @@ -198,12 +209,6 @@ in buildPythonPackage rec {
--subst-var out
'';

doCheck = false;
checkPhase = ''
runHook preCheck
ctest -j $NIX_BUILD_CORES
'';

doInstallCheck = true;
installCheckPhase = ''
export OMP_NUM_THREADS=2
Expand Down

0 comments on commit 816062b

Please sign in to comment.