### Install Skala Development Dependencies Source: https://github.com/microsoft/skala/blob/main/docs/installation.rst Installs additional dependencies required for Skala development, including tools for testing and code quality. This is typically used after installing from source. ```bash pip install -e .[dev] ``` -------------------------------- ### Install Gau2Grid from Source Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/py_install.rst Installs Gau2Grid by cloning the repository from GitHub and executing the setup script. This method is useful for developers who want to modify the source code or contribute to the project. ```bash git clone https://github.com/dgasmith/gau2grid.git cd gau2grid python setup.py install ``` -------------------------------- ### Run Skala Tests Source: https://github.com/microsoft/skala/blob/main/docs/installation.rst Executes the test suite for the Skala installation to verify that the package is working correctly. This is a crucial step after installation, especially when installing from source or making modifications. ```bash pytest -v tests/ ``` -------------------------------- ### Clone gau2grid Repository Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_install.rst This snippet demonstrates how to clone the gau2grid repository from GitHub using git. It is the first step in installing from source. After cloning, navigate into the repository directory. ```bash git clone https://github.com/dgasmith/gau2grid.git cd gau2grid ``` -------------------------------- ### Basic CMake Build for gau2grid Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_install.rst This sequence of commands compiles and installs gau2grid from source using CMake. It involves creating a build directory, configuring the build, compiling the code, and finally installing the library. Dependencies like CMake and a C++ compiler are required. ```bash cmake -H. -Bobjdir cd objdir make make install ``` -------------------------------- ### Configure gau2grid Build with CMake Options Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_install.rst This example shows how to customize the gau2grid build process using CMake options. The -D flag is used to pass configuration variables such as installation prefix, maximum angular momentum, and build type. This allows for tailored installations. ```bash cmake -H. -Bobjdir -DCMAKE_INSTALL_PREFIX=~/installs ``` -------------------------------- ### Install Skala from Source Source: https://github.com/microsoft/skala/blob/main/docs/installation.rst Installs Skala from its source code by cloning the repository, creating a Conda environment, and installing in editable mode. This method is useful for developers or users who need to modify the code. ```bash git clone https://github.com/microsoft/skala cd skala mamba env create -n skala -f environment.yml mamba activate skala pip install -e . ``` -------------------------------- ### Install Skala using pip Source: https://github.com/microsoft/skala/blob/main/docs/installation.rst Installs the Skala Python package and its core dependencies using pip. This is the recommended method for most users. ```bash pip install microsoft-skala ``` -------------------------------- ### Install gau2grid using Conda Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_install.rst This command installs the gau2grid library using the conda package manager. Ensure you have conda installed and configured before running this command. It simplifies dependency management. ```bash conda install gau2grid -c psi4 ``` -------------------------------- ### Initialize Pre-commit Hooks Source: https://github.com/microsoft/skala/blob/main/docs/installation.rst Sets up pre-commit hooks for the Skala project. These hooks help maintain code quality by automatically checking code before commits. ```bash pre-commit install ``` -------------------------------- ### Install CPU-only PyTorch Source: https://github.com/microsoft/skala/blob/main/docs/installation.rst Installs the CPU-only version of PyTorch, which is smaller and may be preferred if GPU acceleration is not required for Skala calculations. This should be run before installing Skala if a CPU-only PyTorch is desired. ```bash pip install torch --index-url https://download.pytorch.org/whl/cpu ``` -------------------------------- ### Test Gau2Grid Installation Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/py_install.rst Tests the installed Gau2Grid package using the py.test framework. This ensures that the installation was successful and the package is functioning as expected. ```bash cd gau2grid py.test ``` -------------------------------- ### Install Project Configuration (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/CMakeLists.txt This section handles the installation of the project's CMake configuration files. It defines an alias target for the 'gg' library and sets up include directories for both build and installation contexts. It also configures the location for the package configuration file (`Config.cmake`) and generates a version file. ```cmake include(GNUInstallDirs) include(CMakePackageConfigHelpers) set(PN ${PROJECT_NAME}) # Alias to allow for consistent manipulation as a subproject add_library( ${PN}::gg ALIAS gg ) target_include_directories(gg PUBLIC $ $) # GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share". set(CMAKECONFIG_INSTALL_DIR "share/cmake/${PN}") configure_package_config_file(cmake/${PN}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PN}Config.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}) write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PN}ConfigVersion.cmake VERSION ${${PN}_VERSION} COMPATIBILITY SameMajorVersion) ``` -------------------------------- ### Setup Conda Environment for Skala C++ Integration Source: https://github.com/microsoft/skala/blob/main/examples/cpp/cpp_integration/README.md This snippet shows how to set up a conda environment for C++ integration with Skala. It involves navigating to the example directory, creating a new conda environment using 'environment.yml', and activating it. Ensure you have conda installed and the 'environment.yml' file present. ```bash cd examples/cpp/cpp_integration conda env create -n skala_cpp_integration -f environment.yml conda activate skala_cpp_integration ``` -------------------------------- ### Install gau2grid Python Package Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/README.md This command installs the gau2grid Python package using its `setup.py` script. This installation method includes the Python components but does not build or include the optimized C library. ```bash python setup.py install ``` -------------------------------- ### Install Gau2Grid using Conda Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/py_install.rst Installs the Gau2Grid package and its NumPy dependency using the Conda package manager. This is a straightforward method for users who have Conda installed. ```bash conda install pygau2grid -c psi4 ``` -------------------------------- ### Install Skala Native Library and Configuration Files Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/CMakeLists.txt Installs header files, the target library 'gg', and CMake configuration files for the Skala project. This is conditional on specific CMake variables indicating native Python installation or Python module installation. ```cmake if(${NATIVE_PYTHON_INSTALL_WITH_LIB} OR (NOT(${INSTALL_PYMOD} AND ${NATIVE_PYTHON_INSTALL}))) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gau2grid/gau2grid.h ${CMAKE_CURRENT_BINARY_DIR}/gau2grid/gau2grid_pragma.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PN}) install(TARGETS gg EXPORT "${PN}Targets" ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PN}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PN}ConfigVersion.cmake DESTINATION ${CMAKECONFIG_INSTALL_DIR}) install(EXPORT "${PN}Targets" NAMESPACE "${PN}::" DESTINATION ${CMAKECONFIG_INSTALL_DIR}) export(EXPORT "${PN}Targets" NAMESPACE "${PN}::" FILE "${PROJECT_BINARY_DIR}/${PN}Targets.cmake") endif() ``` -------------------------------- ### Install Skala Python Package Source: https://github.com/microsoft/skala/blob/main/README.md Installs the PyTorch library (CPU version) and the microsoft-skala Python package. This is the first step to using Skala with quantum chemistry packages like PySCF and ASE. ```bash pip install torch --index-url https://download.pytorch.org/whl/cpu # unless you already have GPU Pytorch for something else pip install microsoft-skala ``` -------------------------------- ### Install Headers (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/CMakeLists.txt Installs static headers from the 'include' directory and generated headers from the build directory. Static headers ending with '.hpp' are installed to the root destination. Generated configuration headers are placed in 'include/gauxc'. ```cmake # Install static headers install( DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION . FILES_MATCHING PATTERN "*.hpp" ) # Install generated headers install( FILES ${PROJECT_BINARY_DIR}/include/gauxc/gauxc_config.hpp DESTINATION include/gauxc ) ``` -------------------------------- ### Include GNUInstallDirs Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/CMakeLists.txt This CMake command includes the `GNUInstallDirs` module, which provides standardized variables for installation directories (e.g., `CMAKE_INSTALL_BINDIR`, `CMAKE_INSTALL_LIBDIR`). This promotes consistent installation paths across different systems. ```cmake include( GNUInstallDirs ) ``` -------------------------------- ### Install OneDFT Models Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/CMakeLists.txt If OneDFT is enabled, this code installs the OneDFT model data directory to the appropriate location within the installation prefix. This ensures that the necessary model files are available at runtime. ```cmake if (GAUXC_HAS_ONEDFT) set(GAUXC_ONEDFT_MODEL_PATH_INSTALL "${CMAKE_INSTALL_PREFIX}/share/gauxc/onedft_models") install( DIRECTORY ${GAUXC_ONEDFT_MODEL_PATH} DESTINATION "${CMAKE_INSTALL_PREFIX}/share/gauxc" ) endif() ``` -------------------------------- ### Download Skala Model and Reference LDA Functional Source: https://github.com/microsoft/skala/blob/main/examples/cpp/cpp_integration/README.md This snippet shows how to download the necessary Skala model and a reference LDA functional from HuggingFace using a provided Python script. This is a prerequisite for running the C++ integration example. ```bash ./download_model.py ``` -------------------------------- ### Run Skala Energy and Potential Computations in C++ Source: https://github.com/microsoft/skala/blob/main/examples/cpp/cpp_integration/README.md This snippet shows the command to execute the compiled Skala C++ integration example. It takes the Skala model file ('skala-1.0.fun') and the prepared molecular input directory ('H2') as arguments to perform energy and partial potential computations. ```bash ./_build/skala_cpp_integration skala-1.0.fun H2 ``` -------------------------------- ### Install Skala Python Module Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/CMakeLists.txt Installs the Skala Python module, including its associated Python files and the compiled library. This section dynamically determines Python installation paths and library extensions using Python scripts executed via CMake's `execute_process` command. ```cmake if(${INSTALL_PYMOD}) if(${NATIVE_PYTHON_INSTALL}) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print(sys.prefix);" OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig as s; import os; import sys; cmake_install_prefix = sys.prefix; prefix_lib = s.get_config_var('LIBDIR'); print(prefix_lib.replace(os.path.commonpath([prefix_lib, cmake_install_prefix]), '').strip('/'));" OUTPUT_VARIABLE CMAKE_INSTALL_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig as s; import os; prefix_lib = s.get_config_var('LIBDIR'); spdir = s.get_python_lib(plat_specific=True); print(spdir.replace(os.path.commonpath([prefix_lib, spdir]), ''));" OUTPUT_VARIABLE PYMOD_INSTALL_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) endif() execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from numpy import distutils; print(distutils.misc_util.get_shared_lib_extension(is_python_ext=False))" OUTPUT_VARIABLE PYLIB_EXTENSION OUTPUT_STRIP_TRAILING_WHITESPACE) install(DIRECTORY gau2grid DESTINATION ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR} USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*.py") install(FILES $ DESTINATION ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR}/gau2grid RENAME "gg${PYLIB_EXTENSION}") install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR}/gau2grid) endif() ``` -------------------------------- ### Prepare Molecular Features for Skala Input Source: https://github.com/microsoft/skala/blob/main/examples/cpp/cpp_integration/README.md This snippet illustrates how to prepare molecular features for a test molecule (H2) using a Python script. The output is directed to a specified directory ('H2' in this case). This step is necessary before executing the main C++ integration example. ```bash python ./prepare_inputs.py --output-dir H2 ``` -------------------------------- ### GauXC Integration as Installed Library (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/README.md This CMake snippet shows how to find and link the GauXC library after it has been installed on the system. It uses `find_package` to discover the library and `target_link_libraries` to include it in your project's build. ```cmake # GauXC Discovery find_package( gauxc REQUIRED ) target_link_libraries( my_target PUBLIC gauxc::gauxc ) ``` -------------------------------- ### Install Package Configuration Files (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/CMakeLists.txt Installs CMake configuration files required for other projects to find and use the 'gauxc' package. This includes exporting the 'gauxc-targets' with a specific namespace and file name, creating a version file, configuring the main 'gauxc-config.cmake' file, and installing custom find modules. ```cmake # Export target to script set( INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/gauxc ) install( EXPORT gauxc-targets FILE gauxc-targets.cmake NAMESPACE gauxc:: DESTINATION ${INSTALL_CONFIGDIR} ) # Create config-version.cmake file include( CMakePackageConfigHelpers ) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/gauxc-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) # Setup gauxc-config.cmake configure_package_config_file( ${PROJECT_SOURCE_DIR}/cmake/gauxc-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/gauxc-config.cmake INSTALL_DESTINATION ${INSTALL_CONFIGDIR} ) # Install CMake files install( FILES ${PROJECT_SOURCE_DIR}/cmake/modules/FindMAGMA.cmake ${PROJECT_SOURCE_DIR}/cmake/modules/FindNCCL.cmake ${CMAKE_CURRENT_BINARY_DIR}/gauxc-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/gauxc-config-version.cmake DESTINATION ${INSTALL_CONFIGDIR} ) # Install Custom Find Modules include( ${linalg-cmake-modules_SOURCE_DIR}/LinAlgModulesMacros.cmake ) install_linalg_modules( INSTALL_CONFIGDIR ) ``` -------------------------------- ### CMake Build Setup for GauXC Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/cmake/discovery/CMakeLists.txt Configures the CMake build system for the GauXC project. It specifies the minimum required CMake version, sets the project name, and enables CXX language support. This snippet is essential for initializing the build process. ```cmake cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) project( gauxc_cmake_discovery LANGUAGES CXX ) ``` -------------------------------- ### CMake Project Setup and Module Path Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/CMakeLists.txt Initializes the CMake project, sets version, and adds local CMake modules to the module path. This ensures custom CMake scripts and modules are found during the configuration process. ```cmake cmake_minimum_required( VERSION 3.20 FATAL_ERROR ) include(FetchContent) set( FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE BOOL "Disable FC Updates" ) project( GauXC VERSION 0.0.1 LANGUAGES C CXX ) # Place local modules in the path list( PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ) list( PREPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ) include( gauxc-linalg-modules ) ``` -------------------------------- ### Standalone Driver Executable Setup in CMake Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/CMakeLists.txt This CMake snippet defines and configures the `standalone_driver` executable. It lists its source files and links it with essential libraries like `gauxc`, `gauxc_catch2`, `Eigen3::Eigen`, and `cereal`. It also specifies private include directories for test-related headers. ```cmake add_executable( standalone_driver standalone_driver.cxx standards.cxx basis/parse_basis.cxx ini_input.cxx ) target_link_libraries( standalone_driver PUBLIC gauxc gauxc_catch2 Eigen3::Eigen cereal ) target_include_directories( standalone_driver PRIVATE ${PROJECT_BINARY_DIR}/tests ) target_include_directories( standalone_driver PRIVATE ${PROJECT_SOURCE_DIR}/tests ) ``` -------------------------------- ### Compute Collocation Grid for Multiple Basis Functions (C) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_example.rst Computes collocation matrices for multiple basis functions simultaneously. This example iterates through different angular momentum (L) values, calling gg_collocation for each and accumulating the results into a single output array. It demonstrates how to handle varying output sizes based on angular momentum. ```C #include #include "gau2grid.h" int main() { // Generate grid long int npoints = 5; double xyz[15] = {0, 0, 0, 0, 0, // x components 0, 0, 0, 0, 0}; // y components 0, 1, 2, 3, 4}; // z components long int xyz_stride = 1; // Gaussian data int nprim = 1; double coef[1] = {1}; double exp[1] = {1}; double center[3] = {0, 0, 0}; int order = GG_SPHERICAL_CCA; // Use cartesian components // Size ncomponents * npoints, (1 + 3 + 5) * 5 double output[45] = {0}; int row = 0; for (int L = 0; L < 3; L++) { gg_collocation(L, // The angular momentum npoints, xyz, xyz_stride // Grid data nprim, coef, exp, center, order, // Gaussian data output + (row * npoints)); // Output, shift pointer row += gg_ncomponents(L, spherical); // Increment rows skipped } // Print out by row for (int i = 0; i < row; i += 1) { for (int j = 0; j < npoints; j += 1) { printf("%lf ", output[i * npoints + j]); } printf("\n"); } } ``` ```bash 1.000000 0.367879 0.018316 0.000123 0.000000 // S 0.000000 0.367879 0.036631 0.000370 0.000000 // P_0 0.000000 0.000000 0.000000 0.000000 0.000000 // P^+_0 0.000000 0.000000 0.000000 0.000000 0.000000 // P^-_0 0.000000 0.367879 0.073263 0.001111 0.000002 // D_0 0.000000 0.000000 0.000000 0.000000 0.000000 // D^+_1 0.000000 0.000000 0.000000 0.000000 0.000000 // D^-_1 0.000000 0.000000 0.000000 0.000000 0.000000 // D^+_2 0.000000 0.000000 0.000000 0.000000 0.000000 // D^-_2 ``` -------------------------------- ### Install gauxc Target and Export Dependencies (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/CMakeLists.txt Installs the 'gauxc' library target, its export dependencies, and library/archive files. It also sets export properties for the 'gauxc' target, including various configuration flags like HAS_HOST, HAS_DEVICE, and support for CUDA, HIP, MAGMA, CUTLASS, NCCL, MPI, OpenMP, HDF5, and ONEDFT. Finally, it exports the build tree for 'gauxc-targets' with a 'gauxc::' namespace. ```cmake install( TARGETS gauxc ${GAUXC_EXPORT_DEPENDENCIES} EXPORT gauxc-targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) set_target_properties( gauxc PROPERTIES EXPORT_NAME gauxc ) set(export_properties # currently configurable properties "GAUXC_HAS_HOST" "GAUXC_HAS_DEVICE" "GAUXC_HAS_CUDA" "GAUXC_HAS_HIP" "GAUXC_HAS_MAGMA" "GAUXC_HAS_CUTLASS" "GAUXC_HAS_NCCL" "GAUXC_HAS_MPI" "GAUXC_HAS_OPENMP" "GAUXC_HAS_HDF5" "GAUXC_HAS_ONEDFT" # may become configurable in the future "GAUXC_CPU_XC_MAX_AM" "GAUXC_CPU_SNLINK_MAX_AM" "GAUXC_GPU_XC_MAX_AM" "GAUXC_GPU_SNLINK_MAX_AM" ) set_target_properties(gauxc PROPERTIES "GAUXC_HAS_HOST" ${GAUXC_HAS_HOST} "GAUXC_HAS_DEVICE" ${GAUXC_HAS_DEVICE} "GAUXC_HAS_CUDA" ${GAUXC_HAS_CUDA} "GAUXC_HAS_HIP" ${GAUXC_HAS_HIP} "GAUXC_HAS_MAGMA" ${GAUXC_HAS_MAGMA} "GAUXC_HAS_CUTLASS" ${GAUXC_HAS_CUTLASS} "GAUXC_HAS_NCCL" ${GAUXC_HAS_NCCL} "GAUXC_HAS_MPI" ${GAUXC_HAS_MPI} "GAUXC_HAS_OPENMP" ${GAUXC_HAS_OPENMP} "GAUXC_HAS_HDF5" ${GAUXC_HAS_HDF5} "GAUXC_HAS_ONEDFT" ${GAUXC_HAS_ONEDFT} "GAUXC_CPU_XC_MAX_AM" ${GAUXC_CPU_XC_MAX_AM} "GAUXC_CPU_SNLINK_MAX_AM" ${GAUXC_CPU_SNLINK_MAX_AM} "GAUXC_GPU_XC_MAX_AM" ${GAUXC_GPU_XC_MAX_AM} "GAUXC_GPU_SNLINK_MAX_AM" ${GAUXC_GPU_SNLINK_MAX_AM} ) set_property(TARGET gauxc APPEND PROPERTY EXPORT_PROPERTIES "${export_properties}") # Export build tree export(EXPORT gauxc-targets NAMESPACE gauxc:: FILE "${PROJECT_BINARY_DIR}/gauxc-targets.cmake") ``` -------------------------------- ### Catch2 Test Framework Integration in CMake Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/CMakeLists.txt This CMake code integrates the Catch2 testing framework. It first attempts to find an existing Catch2 installation. If not found, it fetches Catch2 from GitHub, configures its build options to exclude testing and documentation, and then links it to the `gauxc_catch2` interface library. If Catch2 is found, it directly links it. ```cmake find_package( Catch2 CONFIG QUIET ) if( NOT Catch2_FOUND ) FetchContent_Declare( catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v2.13.10 ) set(CATCH_BUILD_TESTING OFF CACHE BOOL "Build SelfTest project" FORCE) set(CATCH_INSTALL_DOCS OFF CACHE BOOL "Install documentation alongside library" FORCE) set(CATCH_INSTALL_HELPERS OFF CACHE BOOL "Install contrib alongside library" FORCE) FetchContent_MakeAvailable( catch2 ) target_link_libraries( gauxc_catch2 INTERFACE Catch2::Catch2 ) else() target_link_libraries( gauxc_catch2 INTERFACE Catch2::Catch2 ) endif() ``` -------------------------------- ### Create Methane Molecule with Skala Calculator Source: https://github.com/microsoft/skala/blob/main/docs/ase.ipynb Shows how to create a methane (CH₄) molecule object for calculations. This example snippet is a prelude to potentially performing calculations on methane, possibly using a different basis set as indicated in the surrounding text. ```python # Create a methane molecule atoms = molecule("CH4") ``` -------------------------------- ### Enable HDF5 Support in GauXC (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/external/CMakeLists.txt This CMake script snippet enables HDF5 support for GauXC. It checks if HDF5 is enabled and found, then configures and fetches the HighFive library. It sets build options for HighFive to disable tests, examples, and documentation, and enables HDF5 bindings. Finally, it adds HDF5-related source files and links the HighFive library to the GauXC target. ```cmake if( GAUXC_ENABLE_HDF5 ) include(FetchContent) find_package(HDF5) if(HDF5_FOUND) set(GAUXC_HAS_HDF5 TRUE CACHE BOOL "" FORCE) message(STATUS "Enabling HDF5 Bindings") message(STATUS "HighFive REPO = ${GAUXC_HIGHFIVE_REPOSITORY}") message(STATUS "HighFive REV = ${GAUXC_HIGHFIVE_REVISION} ") FetchContent_Declare( HighFive GIT_REPOSITORY ${GAUXC_HIGHFIVE_REPOSITORY} GIT_TAG ${GAUXC_HIGHFIVE_REVISION} ) set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "" ) set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "" ) set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "" ) #set(HIGHFIVE_PARALLEL_HDF5 ON CACHE BOOL "" ) set(HIGHFIVE_BUILD_DOCS OFF CACHE BOOL "" ) FetchContent_MakeAvailable( HighFive ) target_sources( gauxc PRIVATE hdf5_write.cxx hdf5_read.cxx ) target_link_libraries( gauxc PUBLIC HighFive ) else() message(WARNING "GAUXC_ENABLE_HDF5 was enabled, but HDF5 was not found, Disabling HDF5 Bindings") endif() else() message(STATUS "Disabling HDF5 Bindings") endif() ``` -------------------------------- ### Build Skala C++ Integration Library with CMake Source: https://github.com/microsoft/skala/blob/main/examples/cpp/cpp_integration/README.md This snippet demonstrates how to build the Skala C++ integration library using CMake and Ninja. It configures the build by specifying the source directory and build directory, then proceeds to build the library. This command should be re-run after any code modifications. ```bash cmake -S . -B _build -G Ninja cmake --build _build ``` -------------------------------- ### Build gau2grid C Library using CMake Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/README.md This snippet shows the basic CMake commands to build the C library for gau2grid. It involves creating a build directory and running the make command. The C library has no required dependencies other than the standard C library. ```bash cmake -H. -Bobjdir cd objdir; make -j2 ``` -------------------------------- ### Build gau2grid Library (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/CMakeLists.txt This snippet defines and configures a static or shared library named 'gg' using generated C source files. It sets C11 standard compliance, position-independent code properties, and SOVERSION. It also conditionally links standard math libraries and potentially other libraries like LIBC_INTERJECT based on build configurations. ```cmake set(sources_list ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_phi.c ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_orbital.c ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_deriv1.c ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_deriv2.c ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_deriv3.c ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_transform.c ${CMAKE_CURRENT_BINARY_DIR}/gau2grid_helper.c) add_library(gg ${sources_list}) if ("${CMAKE_C_COMPILER_ID}" STREQUAL "PGI") set_target_properties(gg PROPERTIES COMPILE_FLAGS "-c11") else() set_target_properties(gg PROPERTIES COMPILE_FLAGS "-std=c11") endif() set_target_properties(gg PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_FPIC} SOVERSION 2) # bump whenever interface has changes or removals if(DISABLE_PRAGMA ) target_compile_definitions( gg PRIVATE $ ) endif() find_package(StandardMathLibraryC) target_link_libraries(gg PRIVATE ${STANDARD_MATH_LIBRARY}) if(${BUILD_SHARED_LIBS}) target_link_libraries(gg PRIVATE ${LIBC_INTERJECT}) endif() ``` -------------------------------- ### GauXC Build Instructions (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/README.md These commands demonstrate how to configure and build the GauXC project using CMake. It includes setting the source and build directories and passing custom configuration options. This is the primary method for compiling GauXC. ```bash cmake -S /path/to/gauxc -B /path/to/build [GauXC configure options] cmake --build /path/to/build ``` -------------------------------- ### CMake: Fetch and Include GauXC Dependency Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/cmake/subproject/CMakeLists.txt This CMake snippet uses the FetchContent module to download and make the GauXC library available. It specifies the Git repository URL and tag (revision) to fetch. This ensures the project has the necessary dependency for building. ```cmake include( FetchContent ) set( FETCHCONTENT_SOURCE_DIR_GAUXC ${CMAKE_CURRENT_LIST_DIR}/../../.. ) FetchContent_Declare( gauxc GIT_REPOSITORY "${GITHUB_URL}/${GITHUB_REPOSITORY}" GIT_TAG ${GIT_REVISION} ) FetchContent_MakeAvailable( gauxc ) ``` -------------------------------- ### Get Maximum Angular Momentum (C) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_api.rst Retrieves the maximum angular momentum compiled into the gau2grid library. This is a fundamental parameter for basis set definitions. ```c int gg_max_L(); ``` -------------------------------- ### Conditional HDF5 Test Setup in CMake Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/CMakeLists.txt This snippet checks if HDF5 is available and enabled. If not, it issues a warning and skips the GauXC tests. This ensures that tests requiring HDF5 are only run when the dependency is properly configured. ```cmake if(NOT GAUXC_HAS_HDF5) message(WARNING "GauXC Tests were ENABLED but HDF5 was not FOUND/ENABLED. Please enable and ensure discovery of HDF5. Skipping Tests") return() endif() message( STATUS "Building GauXC Tests" ) add_library( gauxc_catch2 INTERFACE ) ``` -------------------------------- ### Linking GauXC Library with Executable (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/cmake/discovery/CMakeLists.txt This CMake snippet demonstrates how to find the installed GauXC package and link a test executable against it. It ensures that the 'gauxc_link_tester' executable can utilize the functionalities provided by the GauXC library. ```cmake find_package( gauxc REQUIRED ) add_executable( gauxc_link_tester gauxc_link_tester.cxx ) target_link_libraries( gauxc_link_tester PUBLIC gauxc::gauxc ) ``` -------------------------------- ### Run Skala DFT Computation on Azure AI Foundry (Python) Source: https://github.com/microsoft/skala/blob/main/docs/foundry.rst This Python snippet demonstrates how to initialize a SkalaFoundryClient, define a molecular geometry using QCSchema, configure calculation parameters with SkalaConfig, and execute a DFT computation. It includes error handling for failed tasks and prints the total energy upon success. Dependencies include qcelemental and skala.foundry. ```python import qcelemental as qcel from skala.foundry import SkalaFoundryClient, SkalaConfig client = SkalaFoundryClient(endpoint="https:///score", credential="") water = qcel.models.Molecule.from_data(""" O 0.000000 0.000000 0.000000 H 0.758602 0.000000 0.504284 H -0.758602 0.000000 0.504284 """, molecular_charge=0, molecular_multiplicity=1) config = SkalaConfig(basis="def2-tzvp", grid_level="superfine", max_num_scf_steps=80) status = client.run(water, config=config) if status.status == "succeeded": print("Total energy (Ha):", status.output.total_energy) else: raise RuntimeError(f"Task failed: {status.exception}") ``` -------------------------------- ### Initialize SkalaKS Calculator in PySCF Source: https://github.com/microsoft/skala/blob/main/docs/pyscf/singlepoint.ipynb This code illustrates how to create a PySCF molecule object and then initialize a SkalaKS calculator with the Skala functional. It shows the basic setup for performing self-consistent field calculations using Skala. ```python mol = gto.M( atom="""H 0 0 0; H 0 0 1.4""", basis="def2-tzvp", ) ks = SkalaKS(mol, xc="skala") ks.kernel() print(ks.dump_scf_summary()) ``` -------------------------------- ### Enable Density Fitting with SkalaKS in PySCF Source: https://github.com/microsoft/skala/blob/main/docs/pyscf/singlepoint.ipynb This example shows how to enable density fitting for the Skala functional within PySCF by setting the 'with_density_fit' parameter to True during the SkalaKS calculator initialization. Density fitting can significantly improve computational efficiency. ```python mol = gto.M( atom="""H 0 0 0; H 0 0 1.4""", basis="def2-tzvp", ) ks = SkalaKS(mol, xc="skala", with_density_fit=True) ks.kernel() print(ks.dump_scf_summary()) ``` -------------------------------- ### Generate C Code from Python (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/CMakeLists.txt This custom command uses a Python script to generate C source files for the 'gau2grid' library. It appends the project's source directory to the Python path and then calls a Python function 'generate_c_gau2grid' to create the necessary C files. Dependencies include several Python modules used for code generation. ```cmake add_custom_command( OUTPUT gau2grid/gau2grid.h gau2grid_orbital.c gau2grid_phi.c gau2grid_deriv1.c gau2grid_deriv2.c gau2grid_deriv3.c gau2grid_transform.c gau2grid_helper.c COMMAND ${PYTHON_EXECUTABLE} -c "import sys; \ sys.path.append('${PROJECT_SOURCE_DIR}'); \ import gau2grid as gg; \ gg.c_gen.generate_c_gau2grid(${MAX_AM}, path='${CMAKE_CURRENT_BINARY_DIR}')" DEPENDS gau2grid/c_generator.py gau2grid/c_generator.py gau2grid/codegen.py gau2grid/c_pragma.py gau2grid/c_util_generator.py gau2grid/c_wrapper.py gau2grid/docs_generator.py gau2grid/order.py gau2grid/python_reference.py gau2grid/RSH.py gau2grid/utility.py VERBATIM) ``` -------------------------------- ### CMake: Get Git Revision and Configure Repository Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/cmake/subproject/CMakeLists.txt This CMake script snippet retrieves the current Git revision if not already defined, and sets default GitHub URL and repository information. It then prints these details for confirmation. This is crucial for versioning and fetching the correct code. ```cmake cmake_minimum_required( VERSION 3.18 FATAL_ERROR ) project( gauxc_cmake_subproject LANGUAGES C CXX ) if( NOT GIT_REVISION ) # Get current Git Revision find_package( Git REQUIRED ) execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse HEAD OUTPUT_VARIABLE GIT_REVISION ERROR_QUIET ) string( STRIP "${GIT_REVISION}" GIT_REVISION ) endif() if( NOT GITHUB_URL ) set( GITHUB_URL "https://github.com" ) endif() if( NOT GITHUB_REPOSITORY ) set( GITHUB_REPOSITORY "wavefunction91/gauxc.git" ) endif() message( STATUS "Pulling GIT_URL = ${GITHUB_URL}" ) message( STATUS "Pulling GIT_REPOSITORY = ${GITHUB_REPOSITORY}" ) message( STATUS "Pulling GIT_REVISION = ${GIT_REVISION}" ) ``` -------------------------------- ### GauXC Integration as CMake Subproject (FetchContent) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/README.md This CMake snippet demonstrates how to integrate GauXC into another project as a subproject using CMake's `FetchContent` module. It pulls the GauXC source directly from a Git repository and makes it available for linking. ```cmake # GauXC as CMake Subproject include(FetchContent) # Set GauXC CMake options (see below) # Pull master branch of GauXC FetchContent_Declare( gauxc GIT_REPOSITORY https://github/com/wavefunction91/GauXC.git GIT_TAG master ) FetchContent_MakeAvailable( gauxc ) # Link to target target_link_libraries( my_target PUBLIC gauxc::gauxc ) ``` -------------------------------- ### Configure BLAS Library Discovery (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/xc_integrator/local_work_driver/host/CMakeLists.txt This CMake code snippet configures the build system to find and use the BLAS (Basic Linear Algebra Subprograms) library. It includes logic to prefer the ILP64 version if the GAUXC_BLAS_PREFER_ILP64 variable is set, otherwise it searches for a standard BLAS. This ensures the correct BLAS interface is used for performance-critical computations. ```cmake if(GAUXC_BLAS_PREFER_ILP64) find_package( BLAS REQUIRED OPTIONAL_COMPONENTS ilp64 ) else() find_package( BLAS REQUIRED ) endif() ``` -------------------------------- ### Compute Collocation Grid for Single Basis Function (C) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/external/gau2grid/src/docs/source/c_example.rst Computes a collocation grid for a single basis function using the gg_collocation function. It demonstrates setting up grid data, Gaussian data, and handling the output for Cartesian components. The xyz_stride parameter can be adjusted to handle different data packing formats. ```C #include #include "gau2grid.h" int main() { // Generate grid long int npoints = 5; double xyz[15] = {0, 0, 0, 0, 0, // x components 0, 0, 0, 0, 0}; // y components 0, 1, 2, 3, 4}; // z components long int xyz_stride = 1; // This is a contiguous format // Gaussian data int nprim = 1; double coef[1] = {1}; double exp[1] = {1}; double center[3] = {0, 0, 0}; int order = GG_CARTESIAN_CCA; // Use cartesian components double s_output[5] = {0}; gg_collocation(0, // The angular momentum npoints, xyz, xyz_stride, // Grid data nprim, coef, exp, center, order, // Gaussian data s_output); // Output // Print output to stdout for (int i = 0; i < npoints; i += 1) { printf("%lf ", s_output[i]); } printf("\n"); } ``` ```bash 1.000000 0.367879 0.018316 0.000123 0.000000 ``` -------------------------------- ### Define GauXC Host Source Files (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/xc_integrator/local_work_driver/host/rys/CMakeLists.txt This snippet defines a list of C source files for the GauXC project using CMake's `set` command. These files are essential for the host-side computation within GauXC. ```cmake set( GAUXC_RYS_HOST_SRC src/boys_table.c src/jacobi_table.c src/rys_1rw.c src/rys_2rw.c src/rys_3rw.c src/rys_4rw.c src/rys_5rw.c src/rys_integral.c src/rys_rw.c src/rys_xrw.c ) target_sources( gauxc PRIVATE ${GAUXC_RYS_HOST_SRC} ) ``` -------------------------------- ### Import necessary libraries for Skala and ASE Source: https://github.com/microsoft/skala/blob/main/docs/ase.ipynb Imports essential modules from numpy, ASE, and the Skala library for setting up and performing calculations. These include tools for building molecules, optimization, units, and the Skala calculator itself. ```python import numpy as np from ase.build import molecule from ase.optimize import LBFGSLineSearch as Opt from ase.units import Bohr, Hartree from skala.ase import Skala ``` -------------------------------- ### Configure and Re-run SCF Calculation Source: https://github.com/microsoft/skala/blob/main/docs/pyscf/scf_settings.ipynb Defines a dictionary 'ks_config' to specify custom SCF parameters, including convergence tolerance, gradient tolerance, maximum cycles, dampening, DIIS start cycle, and level shifting. A new SkalaKS object is initialized with these configurations and the Skala functional, then the SCF is re-run. ```python ks_config = { "conv_tol": 5e-6, "conv_tol_grad": 0.001, "max_cycle": 60, "damp": 0.0, "diis_start_cycle": 1, "level_shift": 0.0, } ks = SkalaKS(mol, ks_config=ks_config, xc="skala") ``` -------------------------------- ### Skala ASE Calculator Interface (Python) Source: https://context7.com/microsoft/skala/llms.txt Implements the Atomic Simulation Environment (ASE) calculator interface for the Skala functional. This allows users to perform geometry optimizations, molecular dynamics, and property calculations within the ASE framework. The example demonstrates calculating energy, forces, dipole moment, and performing a geometry optimization for a water molecule. ```python from ase.build import molecule from ase.optimize import BFGS from skala.ase import Skala # Create water molecule atoms = molecule("H2O") # Set up Skala calculator atoms.calc = Skala( xc="skala", basis="def2-tzvp", with_density_fit=True, verbose=0 ) # Calculate energy and forces energy = atoms.get_potential_energy() # in eV forces = atoms.get_forces() # in eV/Angstrom dipole = atoms.get_dipole_moment() # in eV*Angstrom print(f"Energy: {energy:.4f} eV") print(f"Max force: {abs(forces).max():.4f} eV/Å") print(f"Dipole magnitude: {(dipole**2).sum()**0.5:.4f} eV·Å") # Geometry optimization opt = BFGS(atoms, trajectory="h2o_opt.traj") opt.run(fmax=0.01) print(f"Optimized energy: {atoms.get_potential_energy():.4f} eV") print(f"Final positions:\n{atoms.get_positions()}") ``` -------------------------------- ### Build snlink_test Executable (CMake) Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/src/xc_integrator/local_work_driver/device/cuda/obara_saika/test/CMakeLists.txt This CMake snippet defines the build for the `snlink_test` executable. It links against the `snlink_gpu` library, `Libint2::cxx`, and conditionally links against either `CUDA::cudart` or `CUDA::cudart_static` based on the `GAUXC_LINK_CUDA_STATIC` variable. ```cmake add_executable( snlink_test test.cpp ) target_link_libraries( snlink_test PUBLIC snlink_gpu ) target_link_libraries( snlink_test PUBLIC Libint2::cxx ) if(NOT GAUXC_LINK_CUDA_STATIC) target_link_libraries( snlink_test PUBLIC CUDA::cudart ) else() target_link_libraries( snlink_test PUBLIC CUDA::cudart_static ) endif() ``` -------------------------------- ### GauXC Main Test Executable Configuration in CMake Source: https://github.com/microsoft/skala/blob/main/third_party/gauxc/tests/CMakeLists.txt This CMake snippet defines the main test executable `gauxc_test`. It lists all the source files required for the tests and links necessary libraries including `gauxc`, `gauxc_catch2`, `Eigen3::Eigen`, and `cereal`. It also conditionally includes and links `gauxc_cutlass` if `GAUXC_ENABLE_CUTLASS` is defined. ```cmake add_executable( gauxc_test ut_main.cxx moltypes_test.cxx grid_test.cxx molgrid_test.cxx basisset_test.cxx load_balancer_test.cxx xc_integrator.cxx environment.cxx collocation.cxx weights.cxx standards.cxx runtime.cxx basis/parse_basis.cxx dd_psi_potential_test.cxx onedft_test.cxx 2nd_derivative_test.cxx ) target_link_libraries( gauxc_test PUBLIC gauxc gauxc_catch2 Eigen3::Eigen cereal ) if(GAUXC_ENABLE_CUTLASS) include(gauxc-cutlass) target_link_libraries(gauxc_test PUBLIC gauxc_cutlass) endif() ```