How to use the pyqpanda.Hamiltonian.chem_client function in pyqpanda

To help you get started, we’ve selected a few pyqpanda examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OriginQ / QPanda-2 / pyQPanda / pyqpanda / Algorithm / VariationalQuantumEigensolver / vqe.py View on Github external
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
github OriginQ / QPanda-2 / pyQPanda / pyqpanda / Algorithm / VariationalQuantumEigensolver / vqe.py View on Github external
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