Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initial_guess,
basis='sto-3g',
multiplicity=1,
charge=0,
run_mp2=True,
run_cisd=True,
run_ccsd=True,
run_fci=True,
method='Powell'
):
energy=np.zeros(len(distance_range))
for i in range(len(distance_range)):
print(i)
geometry=[['H',[0,0,0]], ['H',[0,0,distance_range[i]]]]
str1=chem_client(
geometry=geometry,
basis=basis,
multiplicity=multiplicity,
charge=charge,
run_mp2=run_mp2,
run_cisd=run_cisd,
run_ccsd=run_ccsd,
run_fci=run_fci,
hamiltonian_type="pauli")
Hamiltonian=convert_operator(str1)
n_qubit = Hamiltonian.get_qubit_count()
n_electron=get_electron_count(geometry)
result=minimize(binding(n_qubit,n_electron,Hamiltonian,shots=1000),initial_guess,method=method)
energy[i]=result.fun
print(energy[i])
return energy
def H2_energy_from_distance(distance):
'''
compute base energy of H2.
distance: distance between two atoms of H2
'''
geometry=[['H',[0,0,0]], ['H',[0,0,distance]]]
basis="sto-3g"
multiplicity=1
charge=0
run_mp2=True
run_cisd=True
run_ccsd=True
run_fci=True
str1=chem_client(
geometry=geometry,
basis=basis,
multiplicity=multiplicity,
charge=charge,
run_mp2=run_mp2,
run_cisd=run_cisd,
run_ccsd=run_ccsd,
run_fci=run_fci,
hamiltonian_type="pauli")
pauli_op=convert_operator(str1)
matrix_=get_matrix(pauli_op)
eigval,_=eig(matrix_)
return min(eigval).real