Skip to content
Open
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
11 changes: 10 additions & 1 deletion quantnbody/fermionic/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from itertools import combinations
from numba import njit, prange
import matplotlib.pyplot as plt
import psi4

E_ = False
e_ = False
Expand Down Expand Up @@ -1650,6 +1649,16 @@ def get_info_from_psi4( string_geometry,
Energy of the nuclei repulsion

"""

try:
import psi4
except ImportError as exc:
raise RuntimeError(
"psi4 is not installed. This function need psi4 to work."
"Install it before using get_info_from_psi4"
) from exc


if not TELL_ME:
# To prevent psi4 from printing the output in the terminal
psi4.core.set_output_file("output_Psi4.txt", False)
Expand Down
12 changes: 11 additions & 1 deletion quantnbody/fermionic_fockspace/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np
from itertools import combinations
from numba import njit, prange
import psi4

E_ = False
e_ = False
Expand Down Expand Up @@ -1340,6 +1339,17 @@ def get_info_from_psi4( string_geometry,
Energy of the nuclei repulsion

"""

try:
import psi4
except ImportError as exc:
raise RuntimeError(
"psi4 is not installed. This function need psi4 to work. "
"Install it before using get_info_from_psi4"
) from exc



if not TELL_ME:
# To prevent psi4 from printing the output in the terminal
psi4.core.set_output_file("output_Psi4.txt", False)
Expand Down
13 changes: 11 additions & 2 deletions quantnbody/hybrid_fermionic_bosonic/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from numba import njit, prange
import matplotlib.pyplot as plt
import scipy.sparse
import psi4


# =============================================================================
Expand Down Expand Up @@ -717,6 +716,16 @@ def cqed_rhf(lambda_vector, molecule_string, psi4_options_dict):
>>> cqed_rhf_dictionary = cqed_rhf([0., 0., 1e-2], '''\nMg\nH 1 1.7\nsymmetry c1\n1 1\n''', psi4_options_dictionary)

"""
try:
import psi4
except ImportError as exc:
raise RuntimeError(
"psi4 is not installed. This function need psi4 to work."
"Install it before using cqed_rhf"
) from exc



# define geometry using the molecule_string
mol = psi4.geometry(molecule_string)
# define options for the calculation
Expand Down Expand Up @@ -1813,4 +1822,4 @@ def binom(n, k):
for i in range(1, k+1):
numerator *= (n - (k - i))
denominator *= i
return numerator // denominator
return numerator // denominator
11 changes: 10 additions & 1 deletion testing/TESTS.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import unittest
import numpy as np
import psi4
import scipy
import quantnbody as qnb

def _psi4_is_available():
try:
import psi4
return True
except ImportError:
return False

class MyTestCase(unittest.TestCase):

def test_FERMION_BASICS(self):
# ========================================================|
# Parameters for the simulation
Expand Down Expand Up @@ -89,6 +95,9 @@ def test_FERMION_MODEL_HAMILTONIAN(self):

def test_FERMION_AB_INITIO_HAMILTONIAN(self):

if not _psi4_is_available():
self.skipTest("psi4 not installed, test skipped")

psi4.core.set_output_file("output_Psi4.txt", False)
basisset = 'sto-3g'
nelec_active = 2 # Number of active electrons in the Active-Space
Expand Down