From 464d7d9561eab8200fedcf823e46962d6ac2fdbc Mon Sep 17 00:00:00 2001 From: "J. S. Kottmann" Date: Mon, 15 Jan 2024 14:24:59 +0100 Subject: [PATCH 1/2] added molecule_arguments explicitly to orbital_optimizer --- src/tequila/quantumchemistry/orbital_optimizer.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tequila/quantumchemistry/orbital_optimizer.py b/src/tequila/quantumchemistry/orbital_optimizer.py index c8c9877e..06b36553 100644 --- a/src/tequila/quantumchemistry/orbital_optimizer.py +++ b/src/tequila/quantumchemistry/orbital_optimizer.py @@ -37,7 +37,7 @@ def __call__(self, local_data, *args, **kwargs): self.iterations += 1 def optimize_orbitals(molecule, circuit=None, vqe_solver=None, pyscf_arguments=None, silent=False, - vqe_solver_arguments=None, initial_guess=None, return_mcscf=False, use_hcb=False, molecule_factory=None, *args, **kwargs): + vqe_solver_arguments=None, initial_guess=None, return_mcscf=False, use_hcb=False, molecule_factory=None, molecule_arguments=None, *args, **kwargs): """ Parameters @@ -60,6 +60,7 @@ def optimize_orbitals(molecule, circuit=None, vqe_solver=None, pyscf_arguments=N initial_guess="random_loc=X_scale=Y" with X and Y being floats This initialized a random guess using numpy.random.normal(loc=X, scale=Y) with X=0.0 and Y=0.1 as defaults return_mcscf: return the PySCF MCSCF structure after optimization + molecule_arguments: arguments to pass to molecule_factory or default molecule constructor | only change if you know what you are doing args: just here for convenience kwargs: just here for conveniece @@ -97,7 +98,10 @@ def optimize_orbitals(molecule, circuit=None, vqe_solver=None, pyscf_arguments=N if n_qubits > n_orbitals: warnings.warn("Potential inconsistency in orbital optimization: use_hcb is switched on but we have\n n_qubits={} in the circuit\n n_orbital={} in the molecule\n".format(n_qubits,n_orbitals), TequilaWarning) - wrapper = PySCFVQEWrapper(molecule_arguments={"parameters":pyscf_molecule.parameters, "transformation":molecule.transformation}, n_electrons=pyscf_molecule.n_electrons, + if molecule_arguments is None: + molecule_arguments = {"parameters": pyscf_molecule.parameters, "transformation": molecule.transformation} + + wrapper = PySCFVQEWrapper(molecule_arguments=molecule_arguments, n_electrons=pyscf_molecule.n_electrons, const_part=c, circuit=circuit, vqe_solver_arguments=vqe_solver_arguments, silent=silent, vqe_solver=vqe_solver, molecule_factory=molecule_factory, *args, **kwargs) mc.fcisolver = wrapper From a6e3774ee3d5a270fa16899eebe4088fa674f4cd Mon Sep 17 00:00:00 2001 From: "J. S. Kottmann" Date: Fri, 2 Feb 2024 10:37:38 +0100 Subject: [PATCH 2/2] verbose=false in pyscf --- src/tequila/quantumchemistry/pyscf_interface.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tequila/quantumchemistry/pyscf_interface.py b/src/tequila/quantumchemistry/pyscf_interface.py index 61c448d2..bed3cc5d 100644 --- a/src/tequila/quantumchemistry/pyscf_interface.py +++ b/src/tequila/quantumchemistry/pyscf_interface.py @@ -45,6 +45,10 @@ def __init__(self, parameters: ParametersQC, # solve restricted HF mf = pyscf.scf.RHF(mol) + mf.verbose = False + if "verbose" in kwargs: + mf.verbose = kwargs["verbose"] + mf.kernel() # only works if point_group is not C1