Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
Signed-off-by: Melody Ren <[email protected]>
  • Loading branch information
melody-ren committed Dec 5, 2024
1 parent fb78388 commit 75fa658
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class fermion_compiler : public cudaqx::extension_point<fermion_compiler> {
virtual cudaq::spin_op generate(const double constant,
const cudaqx::tensor<> &hpq,
const cudaqx::tensor<> &hpqrs,
const double tolerance) = 0;
const double tolerance = 1e-15) = 0;
virtual ~fermion_compiler() {}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class RESTPySCFDriver : public MoleculePackageDriver {

// Transform to a spin operator
auto transform = fermion_compiler::get(options.fermion_to_spin);
auto spinHamiltonian = transform->generate(energy, hpq, hpqrs, 1e-15);
auto spinHamiltonian = transform->generate(energy, hpq, hpqrs);

// Return the molecular hamiltonian
return molecular_hamiltonian{spinHamiltonian, hpq, hpqrs,
Expand Down
7 changes: 4 additions & 3 deletions libs/solvers/python/tests/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def test_jordan_wigner():
0,
verbose=True,
casci=True)

op = solvers.jordan_wigner(molecule.hpq, molecule.hpqrs,
molecule.energies['nuclear_energy'])
molecule.energies['nuclear_energy'], 1e-15)
assert molecule.hamiltonian == op
hpq = np.array(molecule.hpq)
hpqrs = np.array(molecule.hpqrs)
Expand Down Expand Up @@ -116,9 +117,9 @@ def test_jordan_wigner_as():
hpq = np.array(molecule.hpq)
hpqrs = np.array(molecule.hpqrs)
hpqJw = solvers.jordan_wigner(hpq, molecule.energies['core_energy'])
hpqrsJw = solvers.jordan_wigner(hpqrs)
hpqrsJw = solvers.jordan_wigner(hpqrs, tolerance=1e-15)
op2 = hpqJw + hpqrsJw

spin_ham_matrix = molecule.hamiltonian.to_matrix()
e, c = np.linalg.eig(spin_ham_matrix)
print(np.min(e))
Expand Down

0 comments on commit 75fa658

Please sign in to comment.