Skip to content

Commit

Permalink
Skip compiling SMD by default
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Apr 27, 2024
1 parent c72e21d commit 123c316
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_macos/deps_apt.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
brew reinstall gcc
#brew reinstall gcc
9 changes: 5 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Build wheels
run: |
docker run --rm -v ${{ github.workspace }}:/src/pyscf \
-e CMAKE_BUILD_PARALLEL_LEVEL=4 \
-e CMAKE_BUILD_PARALLEL_LEVEL=4 -e CMAKE_CONFIGURE_ARGS="-DENABLE_SMD=ON" \
pyscf/pyscf-pypa-env:latest \
bash /src/pyscf/docker/pypa-env/build-wheels.sh
- name: List available wheels
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
yum install -y openblas-devel gcc && \
export src=${GITHUB_WORKSPACE:-/src/pyscf} && \
export dst=${GITHUB_WORKSPACE:-/src/pyscf}/linux-wheels && \
export CMAKE_CONFIGURE_ARGS="-DWITH_F12=OFF" && \
export CMAKE_CONFIGURE_ARGS="-DWITH_F12=OFF -DENABLE_SMD=ON" && \
export CMAKE_BUILD_PARALLEL_LEVEL=4 && \
mkdir -p /root/wheelhouse $src/linux-wheels && \
sed -i "/ if basename(fn) not in needed_libs:/s/basename.*libs/1/" /opt/_internal/pipx/venvs/auditwheel/lib/python*/site-packages/auditwheel/wheel_abi.py && \
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
env:
CIBW_BUILD: cp311-macosx_x86_64
CIBW_BUILD_VERBOSITY: "1"
CMAKE_CONFIGURE_ARGS: "-DWITH_F12=OFF"
CMAKE_CONFIGURE_ARGS: "-DWITH_F12=OFF -DENABLE_SMD=ON"
CMAKE_BUILD_PARALLEL_LEVEL: "4"
with:
output-dir: mac-wheels
Expand All @@ -137,7 +137,7 @@ jobs:
CIBW_BUILD_VERBOSITY: "1"
# Cross-platform build for arm64 wheels on x86 platform
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CMAKE_CONFIGURE_ARGS: "-DWITH_F12=OFF"
CMAKE_CONFIGURE_ARGS: "-DWITH_F12=OFF -DENABLE_SMD=OFF"
CMAKE_BUILD_PARALLEL_LEVEL: "4"
CMAKE_OSX_ARCHITECTURES: arm64
with:
Expand Down Expand Up @@ -168,6 +168,7 @@ jobs:
- name: Publish to conda
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=4
export CMAKE_CONFIGURE_ARGS="-DENABLE_SMD=ON"
export ANACONDA_API_TOKEN=${{ secrets.ANACONDA_TOKEN }}
conda install -y anaconda-client conda-build
conda config --set anaconda_upload yes
Expand Down
6 changes: 5 additions & 1 deletion pyscf/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ add_subdirectory(ri)
#add_subdirectory(localizer)
add_subdirectory(pbc)
add_subdirectory(agf2)
add_subdirectory(solvent)

option(ENABLE_SMD "Compiling SMD Fortran code" OFF)
if(ENABLE_SMD)
add_subdirectory(solvent)
endif(ENABLE_SMD)

# Overwrite CMAKE_C_CREATE_SHARED_LIBRARY in Modules/CMakeCInformation.cmake
# to remove the SONAME flag in the so file. The soname information causes
Expand Down
2 changes: 1 addition & 1 deletion pyscf/solvent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pyscf.solvent import ddcosmo, pcm, smd
from pyscf.solvent import ddcosmo, pcm

def ddCOSMO(method_or_mol, solvent_obj=None, dm=None):
'''Initialize ddCOSMO model.
Expand Down
7 changes: 6 additions & 1 deletion pyscf/solvent/smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ def smd_radii(alpha):

import ctypes
from pyscf.lib import load_library
libsolvent = load_library('libsolvent')
try:
libsolvent = load_library('libsolvent')
except NameError:
# SMD module was not compiled
libsolvent = None

def get_cds_legacy(smdobj):
mol = smdobj.mol
natm = mol.natm
Expand Down
6 changes: 5 additions & 1 deletion pyscf/solvent/test/test_smd.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def _check_smd(atom, e_ref, solvent='water'):
assert numpy.abs(e_cds - e_ref) < 1e-3

class KnownValues(unittest.TestCase):
def setUp(self):
if smd.libsolvent is None:
raise self.SkipTest('SMD Fortran library not compiled')

def test_cds_solvent(self):
smdobj = smd.SMD(mol)
smdobj.sasa_ng = 590
Expand Down Expand Up @@ -227,4 +231,4 @@ def test_Cl(self):

if __name__ == "__main__":
print("Full Tests for SMDs")
unittest.main()
unittest.main()
6 changes: 5 additions & 1 deletion pyscf/solvent/test/test_smd_grad.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def _check_grad(atom, solvent='water'):
assert numpy.linalg.norm(fd_cds - grad_cds) < 1e-8

class KnownValues(unittest.TestCase):
def setUp(self):
if smd.libsolvent is None:
raise self.SkipTest('SMD Fortran library not compiled')

def test_grad_water(self):
mf = dft.rks.RKS(mol, xc='b3lyp').SMD()
mf.grids.atom_grid = (99,590)
Expand Down Expand Up @@ -235,4 +239,4 @@ def test_Br(self):

if __name__ == "__main__":
print("Full Tests for Gradient of SMD")
unittest.main()
unittest.main()
6 changes: 5 additions & 1 deletion pyscf/solvent/test/test_smd_hessian.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def _check_hess(atom, solvent='water'):
assert(numpy.linalg.norm(hess_cds[0,:,0,:] - h_fd) < 1e-3)

class KnownValues(unittest.TestCase):
def setUp(self):
if smd.libsolvent is None:
raise self.SkipTest('SMD Fortran library not compiled')

def test_h2o(self):
h2o = gto.Mole()
h2o.atom = '''
Expand Down Expand Up @@ -210,4 +214,4 @@ def test_Br(self):

if __name__ == "__main__":
print("Full Tests for Hessian of SMD")
unittest.main()
unittest.main()

0 comments on commit 123c316

Please sign in to comment.