diff --git a/.clangd b/.clangd new file mode 100644 index 000000000..c7c821813 --- /dev/null +++ b/.clangd @@ -0,0 +1,3 @@ +CompileFlags: # Tweak the parse settings, example directory given to show format + Add: + - "-I./include" diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 94621c9ca..a42cf57c5 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -6,6 +6,7 @@ on: pull_request: branches: ["main"] tags: "v*" + workflow_dispatch: env: BUILD_TYPE: Release CPM_SOURCE_CACHE: ${{github.workspace}}/cache/cpm diff --git a/.gitignore b/.gitignore index 57b9e1e6e..f909ee667 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ coverage/ *.cube *.pgrid *.ply +.direnv +.envrc diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index f8f7a9bb1..5d1093751 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,5 +1,6 @@ set(CMAKE_UNITY_BUILD OFF) +if (NOT NIX_BUILD) CPMAddPackage( NAME fmt GITHUB_REPOSITORY "fmtlib/fmt" @@ -14,6 +15,8 @@ CPMAddPackage( VERSION "1.x" ) +endif () + if(NOT "${USE_SYSTEM_TBB}") set(TBB_OPTIONS "") @@ -30,7 +33,7 @@ endif() if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") list(APPEND TBB_OPTIONS "CMAKE_CXX_FLAGS=-O2 -fno-stack-clash-protection -fno-fcf-protection") endif() - +if (NOT NIX_BUILD) CPMAddPackage( NAME oneTBB GITHUB_REPOSITORY "uxlfoundation/oneTBB" @@ -38,7 +41,9 @@ CPMAddPackage( OPTIONS ${TBB_OPTIONS} ) endif() +endif() +if (NOT NIX_BUILD) CPMAddPackage( NAME unordered_dense GITHUB_REPOSITORY "martinus/unordered_dense" @@ -59,6 +64,7 @@ CPMAddPackage( VERSION "2.4.2" ) +endif() if("${USE_MLX}") CPMAddPackage( NAME mlx @@ -66,12 +72,13 @@ CPMAddPackage( VERSION "0.6.0" ) else() +if (NOT NIX_BUILD) CPMAddPackage( NAME "nlohmann_json" GITHUB_REPOSITORY "nlohmann/json" VERSION "3.11.3" ) - +endif() endif() if(NOT "${USE_SYSTEM_EIGEN}") @@ -88,7 +95,7 @@ if("${eigen3_ADDED}") endif() endif() - +if (NOT NIX_BUILD) CPMAddPackage( NAME gemmi GITHUB_REPOSITORY project-gemmi/gemmi @@ -122,7 +129,7 @@ if("${LBFGSpp_ADDED}") add_library(LBFGSpp::LBFGSpp INTERFACE IMPORTED GLOBAL) target_include_directories(LBFGSpp::LBFGSpp INTERFACE "${LBFGSpp_SOURCE_DIR}/include") endif() - +endif() if("${USE_QCINT}") set(LIBCINT_REPOSITORY "sunqm/qcint") else() @@ -135,7 +142,7 @@ endif () # Add compiler flags to fix the implicit function declaration error set(LIBCINT_C_FLAGS "-Wno-implicit-function-declaration -Wno-deprecated-non-prototype -D_GNU_SOURCE") - +if (NOT NIX_BUILD) CPMAddPackage( NAME libcint GITHUB_REPOSITORY "${LIBCINT_REPOSITORY}" @@ -152,7 +159,7 @@ CPMAddPackage( ${LIBCINT_BUILD_TYPE} VERSION "6.1.2" ) - +endif() # Apply the flags to the target after it's created if(TARGET cint) target_compile_options(cint PRIVATE @@ -160,7 +167,7 @@ if(TARGET cint) -Wno-deprecated-non-prototype ) endif() - +if (NOT NIX_BUILD) add_library(libcint::libcint INTERFACE IMPORTED GLOBAL) target_link_libraries(libcint::libcint INTERFACE cint) target_include_directories( @@ -169,7 +176,7 @@ target_include_directories( "${libcint_SOURCE_DIR}/src" "${libcint_BINARY_DIR}/include" ) - +endif() if(NOT "${USE_SYSTEM_LIBXC}") CPMAddPackage( NAME Libxc @@ -188,11 +195,10 @@ target_include_directories( "${Libxc_BINARY_DIR}/src" "${Libxc_BINARY_DIR}" ) - endif() -if("${WITH_PYTHON_BINDINGS}") +if("${WITH_PYTHON_BINDINGS}" AND NOT NIX_BUILD) CPMAddPackage( NAME nanobind GITHUB_REPOSITORY "wjakob/nanobind" diff --git a/3rdparty/nix/dftd4.nix b/3rdparty/nix/dftd4.nix new file mode 100644 index 000000000..4944c11ef --- /dev/null +++ b/3rdparty/nix/dftd4.nix @@ -0,0 +1,89 @@ +{ + stdenv, + lib, + fetchFromGitHub, + buildType ? "cmake", + pkgs, + src, + version, +}: + +assert !pkgs.blas.isILP64 && !pkgs.lapack.isILP64; +assert ( + builtins.elem buildType [ + "meson" + "cmake" + ] +); + +stdenv.mkDerivation { + pname = "dftd4"; + inherit version; + inherit src; + + nativeBuildInputs = + with pkgs; + [ + gfortran + pkg-config + python3 + ] + ++ lib.optionals (buildType == "meson") [ + meson + ninja + ] + ++ lib.optional (buildType == "cmake") cmake; + + buildInputs = with pkgs; [ + blas + lapack + eigen + ]; + + propagatedBuildInputs = with pkgs; [ + mctc-lib + mstore + multicharge + ]; + + cmakeFlags = [ + (lib.strings.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic)) + "-DDFTD4_USE_EIGEN=ON" + "-DBUILD_SHARED_LIBS=OFF" + ]; + + doCheck = true; + + postPatch = '' + patchShebangs --build \ + config/install-mod.py \ + app/tester.py + ''; + + preCheck = '' + export OMP_NUM_THREADS=2 + ''; + postInstall = '' + TARGET_DIR="$out/lib/cmake/dftd4" + mkdir -p "$TARGET_DIR" + + cat > "$TARGET_DIR/dftd4Config.cmake" < "$TARGET_DIR/gemmiConfig.cmake" < $out/lib/cmake/libcint/libcintConfig.cmake <()) .def("symmetry_unique_molecules", &Crystal::symmetry_unique_molecules) .def("symmetry_unique_dimers", &Crystal::symmetry_unique_dimers) + .def("symmetry_operations", &Crystal::symmetry_operations) .def("unit_cell", &Crystal::unit_cell) .def("unit_cell_molecules", &Crystal::unit_cell_molecules) .def("unit_cell_atoms", &Crystal::unit_cell_atoms)