diff --git a/quantumsim/variational/adapt/molecular.py b/quantumsim/variational/adapt/molecular.py index f918445..28ed729 100644 --- a/quantumsim/variational/adapt/molecular.py +++ b/quantumsim/variational/adapt/molecular.py @@ -55,5 +55,4 @@ def __init__(self, symbols, coordinates, params= None): basis= self.basis, method= self.method, active_electrons=self.active_electrons, - active_orbitals=self.active_orbitals, - load_data=True) + active_orbitals=self.active_orbitals) diff --git a/quantumsim/variational/struct/struct.py b/quantumsim/variational/struct/struct.py index 8e04600..10089ec 100644 --- a/quantumsim/variational/struct/struct.py +++ b/quantumsim/variational/struct/struct.py @@ -1,5 +1,3 @@ -from quantumsim.ansatz import * -from quantumsim.optimizers import * from pennylane import qchem from pennylane import numpy as np @@ -64,8 +62,7 @@ def __init__(self, symbols, coordinates, params= None): basis= self.basis, method= self.method, active_electrons=self.active_electrons, - active_orbitals=self.active_orbitals, - load_data=True) + active_orbitals=self.active_orbitals) self.begin_state = qml.qchem.hf_state(self.active_electrons, self.qubits) @@ -93,7 +90,7 @@ def grad_x(self, theta, x): delta = 0.01 n = len(x) shift = np.eye( n ) * 0.5 * delta - grad = [ self.node( theta=theta, obs=((self.H(x + shift[i]) - self.H(x - shift[i])) / delta) ) for i in range(n)] + grad = [ self.node( theta=theta, obs=((self.hamiltonian_x(x + shift[i]) - self.hamiltonian_x(x - shift[i])) / delta) ) for i in range(n)] return np.array(grad) @@ -104,8 +101,8 @@ def grad_x(self, theta, x): output: h: hamiltoniano molecular """ - def H(self, x): - h, q = qchem.molecular_hamiltonian(symbols= self.symbols, + def hamiltonian_x(self, x): + h, _ = qchem.molecular_hamiltonian(symbols= self.symbols, coordinates= x, mapping= self.mapping, charge= self.charge, @@ -113,8 +110,7 @@ def H(self, x): basis= self.basis, method= self.method, active_electrons=self.active_electrons, - active_orbitals=self.active_orbitals, - load_data=True) + active_orbitals=self.active_orbitals) return h @@ -127,6 +123,6 @@ def H(self, x): result: evaluacion de la funcion de coste dado theta y x. """ def cost_function(self, theta, x): - hamiltonian = self.H(x) + hamiltonian = self.hamiltonian_x(x) result = self.node( theta=theta, obs=hamiltonian ) - return result \ No newline at end of file + return result