Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/optional_modules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
set(INTEGRATION_TESTING FALSE)
set(BUILD_TAMM_SCF TRUE)
12 changes: 11 additions & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
- master

jobs:
Common-Pull-Request:
default_build:
uses: NWChemEx/.github/.github/workflows/common_pull_request.yaml@master
with:
config_file: '.github/.licenserc.yaml'
Expand All @@ -30,3 +30,13 @@ jobs:
doc_target: 'scf_cxx_api'
build_fail_on_warning: false
secrets: inherit
optional_modules:
uses: NWChemEx/.github/.github/workflows/common_pull_request.yaml@master
with:
config_file: '.github/.licenserc.yaml'
source_dir: ''
compilers: '["gcc-11"]'
doc_target: 'scf_cxx_api'
build_fail_on_warning: false
repo_toolchain: '.github/optional_modules.cmake'
secrets: inherit
174 changes: 59 additions & 115 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,86 +13,41 @@
# limitations under the License.

cmake_minimum_required(VERSION 3.14)
set(VERSION 1.0.0) #TODO: get from git
project(scf VERSION "${VERSION}" LANGUAGES CXX)

include(FetchContent)
enable_language(C)
FetchContent_Declare(
nwx_cmake
GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake
)
FetchContent_MakeAvailable(nwx_cmake)
list(APPEND CMAKE_MODULE_PATH "${nwx_cmake_SOURCE_DIR}/cmake")

set(
CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${PROJECT_SOURCE_DIR}/cmake"
CACHE STRING "" FORCE
)
# Downloads common CMake modules used throughout NWChemEx

#Sets the version to whatever git thinks it is
#include(get_version_from_git)
#get_version_from_git(scf_version "${CMAKE_CURRENT_LIST_DIR}")
project(scf VERSION "1.0.0" LANGUAGES CXX)
include(cmake/get_nwx_cmake.cmake)
include(nwx_versions)
include(get_cmaize)
include(nwx_cxx_api_docs)

set(SCF_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(SCF_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
nwx_cxx_api_docs("${SCF_SOURCE_DIR}" "${SCF_INCLUDE_DIR}")
set(SCF_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")

set(DEPENDENCIES "")
nwx_cxx_api_docs("${SCF_SOURCE_DIR}" "${SCF_INCLUDE_DIR}")

### Options ###
cmaize_option_list(
BUILD_TESTING OFF "Should we build the tests?"
BUILD_PYBIND11_PYBINDINGS ON "Build pybind11 python3 bindings?"
ENABLE_EXPERIMENTAL_FEATURES OFF "Build features which are not 1.0-ed yet?"
)

cmaize_find_or_build_dependency(
simde
URL github.com/NWChemEx/SimDE
BUILD_TARGET simde
FIND_TARGET nwx::simde
CMAKE_ARGS BUILD_TESTING=OFF
BUILD_PYBIND11_PYBINDINGS=${BUILD_PYBIND11_PYBINDINGS}
BUILD_PYBIND11_PYBINDINGS ON "Build Python bindings with pybind11?"
BUILD_TAMM_SCF OFF "Should we build modules that rely on TAMM/Exachem?"
INTEGRATION_TESTING OFF "Should we build the integration tests?"
)
list(APPEND DEPENDENCIES simde)

cmaize_find_or_build_dependency(
gauxc
URL github.com/wavefunction91/GauXC
BUILD_TARGET gauxc
FIND_TARGET gauxc::gauxc
CMAKE_ARGS BUILD_TESTING=OFF GAUXC_ENABLE_HDF5=OFF
)
list(APPEND DEPENDENCIES gauxc)

cmaize_find_or_build_dependency(
tamm
URL github.com/NWChemEx-Project/TAMM
VERSION main
BUILD_TARGET tamm
FIND_TARGET tamm::tamm
CMAKE_ARGS MODULES="DFT"
)
list(APPEND DEPENDENCIES tamm)

cmaize_find_or_build_dependency(
exachem
URL github.com/ExaChem/exachem
VERSION main
BUILD_TARGET exachem
FIND_TARGET exachem::exachem
CMAKE_ARGS MODULES="DFT"
)
list(APPEND DEPENDENCIES exachem)
if("${BUILD_TAMM_SCF}")
set(DEPENDENCIES simde gauxc tamm exachem chemcache)
include(get_libint2)
else()
set(DEPENDENCIES simde gauxc)
endif()

cmaize_find_or_build_dependency(
Libint2
URL github.com/evaleev/libint
VERSION 2.7.2
BUILD_TARGET int2
FIND_TARGET Libint2::int2
)
list(APPEND DEPENDENCIES Libint2)
foreach(dependency_i ${DEPENDENCIES})
include(get_${dependency_i})
endforeach()

cmaize_add_library(
scf
Expand All @@ -101,66 +56,55 @@ cmaize_add_library(
DEPENDS "${DEPENDENCIES}"
)

if("${BUILD_TAMM_SCF}")
target_compile_definitions(scf PRIVATE BUILD_TAMM_SCF)
cmaize_add_executable(
scf_driver
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/examples/driver"
DEPENDS scf Libint2
)
endif()

include(nwx_pybind11)
nwx_add_pybind11_module(
${PROJECT_NAME}
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/src/python"
DEPENDS "${PROJECT_NAME}"
)

cmaize_find_or_build_dependency(
chemcache
URL github.com/NWChemEx/ChemCache
BUILD_TARGET chemcache
FIND_TARGET nwx::chemcache
CMAKE_ARGS BUILD_TESTING=OFF
BUILD_PYBIND11_PYBINDINGS=${BUILD_PYBIND11_PYBINDINGS}
)

cmaize_add_executable(
scf_driver
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/examples/driver"
DEPENDS scf chemcache
)

if("${BUILD_TESTING}")
include(CTest)
set(PYTHON_TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/tests/python")
set(CXX_TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/tests/cxx")

# Need to call with MPI, so we have to deconstruct the cmaize_add_test and
# nwx_pybind11_tests methods
cmaize_find_or_build_dependency(
Catch2
URL github.com/catchorg/Catch2
BUILD_TARGET Catch2
FIND_TARGET Catch2::Catch2
VERSION v3.6.0
)
cmaize_add_executable(
test_scf
SOURCE_DIR "${CXX_TEST_DIR}"
set(PYTHON_TEST_DIR "${SCF_TESTS_DIR}/python")
set(CXX_TEST_DIR "${SCF_TESTS_DIR}/cxx")

include(get_catch2)
include(cmake/mpi_test.cmake)
cxx_mpi_test(
unit_test_scf
SOURCE_DIR "${CXX_TEST_DIR}/unit_tests"
INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/scf"
DEPENDS Catch2 scf chemcache
DEPENDS Catch2 scf
)
add_test(
NAME "test_scf"
COMMAND "${MPIEXEC_EXECUTABLE}" "${MPIEXEC_NUMPROC_FLAG}" "2"
"${CMAKE_BINARY_DIR}/test_scf"
python_mpi_test(
unit_test_scf
"${PYTHON_TEST_DIR}/unit_tests/run_unit_tests.py"
SUBMODULES simde chemist pluginplay parallelzone
)

add_test(
NAME py_test_unit_${PROJECT_NAME}
COMMAND "${MPIEXEC_EXECUTABLE}" "${MPIEXEC_NUMPROC_FLAG}" "2"
"${Python_EXECUTABLE}"
"${PYTHON_TEST_DIR}/unit_tests/test_scf.py"
)
nwx_python_path(
TEST_PYTHONPATH
SUBMODULES chemcache simde chemist pluginplay parallelzone
)
set_tests_properties(
py_test_unit_${PROJECT_NAME}
PROPERTIES ENVIRONMENT "${TEST_PYTHONPATH}"
)
if("${INTEGRATION_TESTING}")
include(get_nwchemex)
cxx_mpi_test(
integration_test_scf
SOURCE_DIR "${CXX_TEST_DIR}/integration_tests"
INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/scf"
DEPENDS Catch2 nwchemex scf
)

python_mpi_test(
integration_test_scf
"${PYTHON_TEST_DIR}/integration_tests/run_integration_tests.py"
SUBMODULES nwchemex chemcache simde chemist pluginplay parallelzone
friendzone
)
endif()
endif()
31 changes: 31 additions & 0 deletions cmake/get_nwx_cmake.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include_guard()

macro(get_nwx_cmake)
include(FetchContent)
FetchContent_Declare(
nwx_cmake
GIT_REPOSITORY https://github.com/NWChemEx/NWXCMake
)
FetchContent_MakeAvailable(nwx_cmake)
set(
CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${nwx_cmake_SOURCE_DIR}/cmake"
CACHE STRING ""
FORCE
)
endmacro()

get_nwx_cmake()
38 changes: 38 additions & 0 deletions cmake/mpi_test.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

macro(cxx_mpi_test test_name)
# Need to call with MPI, so we have to deconstruct the cmaize_add_test and
# nwx_pybind11_tests methods
cmaize_add_executable("${test_name}" ${ARGN})
add_test(
NAME "${test_name}"
COMMAND "${MPIEXEC_EXECUTABLE}" "${MPIEXEC_NUMPROC_FLAG}" "2"
"${CMAKE_BINARY_DIR}/${test_name}"
)
endmacro()

macro(python_mpi_test test_name test_script)
add_test(
NAME "py_${test_name}"
COMMAND "${MPIEXEC_EXECUTABLE}" "${MPIEXEC_NUMPROC_FLAG}" "2"
"${Python_EXECUTABLE}"
"${test_script}"
)
nwx_python_path(TEST_PYTHONPATH ${ARGN})
set_tests_properties(
"py_${test_name}"
PROPERTIES ENVIRONMENT "${TEST_PYTHONPATH}"
)
endmacro()
21 changes: 20 additions & 1 deletion include/scf/scf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
*/

#pragma once
#include "scf/scf_mm.hpp"
#include <scf/scf_mm.hpp>
#include <simde/simde.hpp>
#ifdef BUILD_TAMM_SCF
#include <tamm/tamm.hpp>
#endif

namespace scf {

inline auto initialize(int argc, char *argv[]) {
#ifdef BUILD_TAMM_SCF
tamm::initialize(argc, argv);
#endif
return parallelzone::runtime::RuntimeView(argc, argv);
}

inline auto finalize() {
#ifdef BUILD_TAMM_SCF
tamm::finalize();
#endif
}

} // namespace scf
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is a hack to get CI/CD to work. These packages are needed by
# FriendZone NOT this repo.
pydantic>=1.10.13
qcengine
networkx
ase
28 changes: 13 additions & 15 deletions src/python/export_fastscf.cpp → src/python/export_scf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,27 @@
* limitations under the License.
*/

#include <scf/scf.hpp>
#include <pluginplay/plugin/plugin.hpp>
#include <pybind11/pybind11.h>
#include <tamm/tamm.hpp>
#include <scf/scf.hpp>

namespace scf {

EXPORT_PLUGIN(scf, m) {
m.def("tamm_initialize", [](pybind11::list py_args) {
std::vector<std::string> args;
for (const auto& arg : py_args)
args.push_back(arg.cast<std::string>());
pybind11::module::import("parallelzone");
m.def("initialize", [](pybind11::list py_args) {
std::vector<std::string> args;
for (const auto &arg : py_args)
args.push_back(arg.cast<std::string>());

std::vector<char*> argv;
for (const auto& arg : args)
argv.push_back(const_cast<char*>(arg.c_str()));
std::vector<char *> argv;
for (const auto &arg : args)
argv.push_back(const_cast<char *>(arg.c_str()));

int argc = static_cast<int>(argv.size());
tamm::initialize(argc, argv.data());
});
m.def("tamm_finalize", []() {
tamm::finalize();
});
int argc = static_cast<int>(argv.size());
return scf::initialize(argc, argv.data());
});
m.def("finalize", []() { scf::finalize(); });
}

} // namespace scf
Loading