diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..7a059ec --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,62 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + pyscf-version: + - "git+https://github.com/cnyeh/pyscf.git@x2c1e_kpoints" + - "pyscf" + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + sudo apt update + sudo apt install libblas-dev liblapack-dev libeigen3-dev libgmp-dev libmpfr-dev libfftw3-dev libhdf5-dev + sudo apt install build-essential + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade pip + python -m pip install flake8 pytest numpy h5py + pip install --upgrade-strategy only-if-needed ${{ matrix.pyscf-version }} + - name: Install package + run: | + python -m pip install . + - name: Tweak library versions + run: | + if [ ${{ matrix.pyscf-version }} = "git+https://github.com/cnyeh/pyscf.git@x2c1e_kpoints" ]; then + pip install --upgrade "scipy<1.11.0"; + pip install "scs==3.2.3"; + pip install "cvxpy==1.4" + fi + - name: Install Green-MBTools and Test igen + run: | + pip install --upgrade-strategy only-if-needed green-mbtools + python -c "import scipy; print('Scipy version: ', scipy.__version__)" + cd ../ + git clone https://github.com/green-phys/green-mbtools + cd green-mbtools/tests + pytest -v + # - name: Lint with flake8 + # run: | + # # stop the build if there are Python syntax errors or undefined names + # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics diff --git a/CMakeLists.txt b/CMakeLists.txt index ffaedac..0b9fa72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,9 @@ set(MIN_EXPCUTOFF ${libcint_MIN_EXPCUTOFF}) set(KEEP_GOING ${libcint_KEEP_GOING}) set(CMAKE_C_CREATE_SHARED_LIBRARY ${libcint_CMAKE_C_CREATE_SHARED_LIBRARY}) +check_library_exists(quadmath logq "" HAVE_LIBQUADMATH) +check_include_file("quadmath.h" HAVE_QUADMATH_H) + add_subdirectory(src) add_library(GREEN::IGEN ALIAS pbc0) add_dependencies(pbc0 cint) diff --git a/pyproject.toml b/pyproject.toml index da54c9d..1dbc9b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,9 +9,10 @@ cmake.verbose = true [project] name = "green-igen" -version = "0.2.6" +version = "0.2.7" authors = [ - { name="Sergei Iskakov", email="siskakov@umich.edu" }, + { name="Sergei Iskakov" }, + { name="Gaurav Harsha", email="gharsha@umich.edu" }, ] dependencies = ["numpy", "h5py", "scipy", "pyscf"] diff --git a/python/green_igen/df.py b/python/green_igen/df.py index a575204..5fb27dc 100644 --- a/python/green_igen/df.py +++ b/python/green_igen/df.py @@ -52,9 +52,7 @@ from pyscf.pbc.df import df_ao2mo from pyscf.pbc.df.aft import get_nuc from pyscf.pbc.df.df_jk import zdotCN -from pyscf.pbc.lib.kpts_helper import (is_zero, gamma_point, member, unique, unique_with_wrap_around, - KPT_DIFF_TOL) -from pyscf.pbc.df.aft import _sub_df_jk_ +from pyscf.pbc.lib.kpts_helper import (is_zero, gamma_point, member, unique, KPT_DIFF_TOL) from pyscf import __config__ LINEAR_DEP_THR = getattr(__config__, 'pbc_df_df_DF_lindep', 1e-9) @@ -66,6 +64,19 @@ # cutoff penalty due to lattice summation LATTICE_SUM_PENALTY = 1e-1 + +def unique_with_wrap_around(cell, kpts): + '''Search unique kpts in first Brillouin zone.''' + scaled_kpts = cell.get_scaled_kpts(kpts).round(5) + scaled_kpts = numpy.modf(scaled_kpts)[0] + scaled_kpts[scaled_kpts >= .5] -= 1 + scaled_kpts[scaled_kpts < -.5] += 1 + + uniq_index, uniq_inverse = unique(scaled_kpts)[1:3] + uniq_kpts = kpts[uniq_index] + return uniq_kpts, uniq_index, uniq_inverse + + def make_auxmol(mol, auxbasis): '''Generate a fake Mole object which uses the density fitting auxbasis as the basis sets. If auxbasis is not specified, the optimized auxiliary fitting diff --git a/python/green_igen/linalg_helper.py b/python/green_igen/linalg_helper.py index e1354f4..fd7640c 100644 --- a/python/green_igen/linalg_helper.py +++ b/python/green_igen/linalg_helper.py @@ -1478,7 +1478,7 @@ def cho_solve(a, b, strict_sym_pos=True): on matrix a ''' try: - return scipy.linalg.solve(a, b, sym_pos=True) + return scipy.linalg.solve(a, b, assume_a='pos') except numpy.linalg.LinAlgError: if strict_sym_pos: raise diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81208c6..3cc36d0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,4 +36,8 @@ set_target_properties(pbc0 PROPERTIES COMPILE_FLAGS ${OpenMP_C_FLAGS} LINK_FLAGS ${OpenMP_C_FLAGS}) -target_link_libraries(pbc0 ${BLAS_LIBRARIES}) +target_link_libraries(pbc0 PUBLIC ${BLAS_LIBRARIES} m) +if (HAVE_LIBQUADMATH AND HAVE_QUADMATH_H) + target_link_libraries(pbc0 PUBLIC quadmath) + target_compile_definitions(pbc0 PUBLIC USE_LIBQUADMATH) +endif()