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
25 changes: 14 additions & 11 deletions cmake/ase.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@
# limitations under the License.

include_guard()
include(python/python)

#[[[ Determines if ASE is installed.
#
# At present FriendZone can not install
#]]
function(find_ase)
assert_python_module("ase")
message("Found ASE: ${ASE_FOUND}")
endfunction()
if("${BUILD_PYBIND11_PYBINDINGS}")
include(python/python)

#[[[ Determines if ASE is installed.
#
# At present FriendZone can not install
#]]
function(find_ase)
assert_python_module("ase")
message("Found ASE: ${ASE_FOUND}")
endfunction()

if("${ENABLE_ASE}")
find_ase()
if("${ENABLE_ASE}")
find_ase()
endif()
endif()

add_library(ase INTERFACE)
31 changes: 17 additions & 14 deletions cmake/nwchem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@
# limitations under the License.

include_guard()
include(python/python)

#[[[ Determines if NWChem and the necessary Python interface are installed.
#
# At present FriendZone can not install
#]]
function(find_nwchem)
find_program(NWCHEM_FOUND nwchem REQUIRED)
assert_python_module("qcelemental")
assert_python_module("qcengine")
assert_python_module("networkx")
message("Found nwchem: ${NWCHEM_FOUND}")
endfunction()
if("${BUILD_PYBIND11_PYBINDINGS}")
include(python/python)

#[[[ Determines if NWChem and the necessary Python interface are installed.
#
# At present FriendZone can not install
#]]
function(find_nwchem)
find_program(NWCHEM_FOUND nwchem REQUIRED)
assert_python_module("qcelemental")
assert_python_module("qcengine")
assert_python_module("networkx")
message("Found nwchem: ${NWCHEM_FOUND}")
endfunction()

if("${ENABLE_NWCHEM}")
find_nwchem()
if("${ENABLE_NWCHEM}")
find_nwchem()
endif()
endif()

add_library(nwchem INTERFACE)
4 changes: 3 additions & 1 deletion src/python/friendzone/nwx2ase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# limitations under the License.

from ..friends import is_friend_enabled
from .nwchem_via_ase import NWChemEnergyViaASE, NWChemGradientViaASE

if is_friend_enabled("ase"):
from .nwchem_via_ase import NWChemEnergyViaASE, NWChemGradientViaASE


def load_ase_modules(mm):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

import unittest

from ase import Atoms
from friendzone.nwx2ase.chemical_system_conversions import (
chemical_system2atoms,
)
from friendzone.friends import is_friend_enabled
from molecules import make_h2, make_h2o

if is_friend_enabled("ase"):
from ase import Atoms
from friendzone.nwx2ase.chemical_system_conversions import (
chemical_system2atoms,
)


def compare_ase(self, lhs, rhs):
for lhs_Z, rhs_Z in zip(
Expand Down Expand Up @@ -63,3 +66,7 @@ def test_h2o(self):
h2o_nwx = make_h2o()
ase_mol = chemical_system2atoms(h2o_nwx)
compare_ase(self, ase_mol, corr)

def setUp(self):
if not is_friend_enabled("ase"):
self.skipTest("ASE is not enabled!")
5 changes: 4 additions & 1 deletion tests/python/unit_tests/nwx2ase/test_nwchem_via_ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ def test_ccsd_t(self):
self.assertAlmostEqual(np.array(egy), -1.122251361965036, places=4)

def setUp(self):
if not friends.is_friend_enabled("nwchem"):
nwchem_enabled = friends.is_friend_enabled("nwchem")
ase_enabled = friends.is_friend_enabled("ase")

if not nwchem_enabled or not ase_enabled:
self.skipTest("NWChem backend is not enabled!")

self.mm = ModuleManager()
Expand Down