Skip to content

Commit

Permalink
Basis exchange package removed
Browse files Browse the repository at this point in the history
Basis exchange package removed
  • Loading branch information
javinoram authored May 8, 2024
2 parents da091a9 + cd85f07 commit e1562d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions quantumsim/variational/adapt/molecular.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 7 additions & 11 deletions quantumsim/variational/struct/struct.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from quantumsim.ansatz import *
from quantumsim.optimizers import *
from pennylane import qchem
from pennylane import numpy as np

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)


Expand All @@ -104,17 +101,16 @@ 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,
mult= self.mult,
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


Expand All @@ -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
return result

0 comments on commit e1562d8

Please sign in to comment.