# openqemist.quantum_solvers.microsoft_qsharp package¶

## openqemist.quantum_solvers.microsoft_qsharp.generate_uccsd_operators module¶

openqemist.quantum_solvers.microsoft_qsharp.generate_uccsd_operators.alpha_spinorbital(MO)[source]

Return the corresponding alpha spinorbital index given a molecular orbital (MO) index :param MO: molecular orbital index :type MO: int

Returns

alpha spin-orbital index

Return type

(2*MO)(int)

openqemist.quantum_solvers.microsoft_qsharp.generate_uccsd_operators.beta_spinorbital(MO)[source]

Return the corresponding beta spinorbital index given a molecular orbital (MO) index :param MO: molecular orbital index :type MO: int

Returns

beta spin-orbital index

Return type

(2*MO + 1)(int)

openqemist.quantum_solvers.microsoft_qsharp.generate_uccsd_operators.complex_as_dict(re, im)[source]
openqemist.quantum_solvers.microsoft_qsharp.generate_uccsd_operators.compute_cluster_operator(n_spinorbitals, n_electrons, amplitudes, multiply=False, operator=[])[source]

Compute or update the cluster operator for a given UCCSD-VQE run

n_spinorbitals(int): integer representing the number of spinorbitals (qubits) for

a given molecule and basis set

n_electrons(int): integer representing the number of electrons for a given molecule amplitudes(list): list of the amplitudes, with the singles appearing first, followed

by the diagonal (i,i,a,a) doubles and then the off-diagonal (i,j,a,b) doubles

multiply(bool): optional boolean to indicate whether we are performing an amplitude

update (i.e. multiplying a new set of amplitudes by the corresponding operators) or not

operator(list): optional list of the contributions to the cluster operator

Returns

tuple of tuples representing the reference configuration t(list): list of tuples representing the cluster operator

Return type

ref(tuple)

openqemist.quantum_solvers.microsoft_qsharp.generate_uccsd_operators.count_amplitudes(n_spinorbitals, n_electrons)[source]

Count the number of singles and doubles amplitudes for a given UCCSD-VQE run :param n_spinorbitals: integer representing the number of spinorbitals (qubits) for

a given molecule and basis set

Parameters

n_electrons (int) – integer representing the number of electrons for a given molecule

Returns

integer representing the total number of amplitudes (MO basis)

Return type

n_amplitudes(int)

## openqemist.quantum_solvers.microsoft_qsharp.integrals_pyscf module¶

openqemist.quantum_solvers.microsoft_qsharp.integrals_pyscf.compute_integrals_fragment(mol, myhf)[source]

Compute the electronic integrals and store them in a data-structure that can be used by MicrosoftQSharp backend

## openqemist.quantum_solvers.microsoft_qsharp.microsoft_qsharp_parametric_solver module¶

class openqemist.quantum_solvers.microsoft_qsharp.microsoft_qsharp_parametric_solver.MicrosoftQSharpParametricSolver(ansatz, molecule, mean_field=None, backend_options=None)[source]

Performs an energy estimation for a molecule with a parametric circuit.

Performs energy estimations for a given molecule and a choice of ansatz circuit that is supported.

n_samples

The number of samples to take from the hardware emulator.

Type

int

optimized_amplitudes

The optimized amplitudes.

Type

list

verbose

Toggles the printing of debug statements.

Type

bool

class Ansatze[source]

Bases: enum.Enum

Enumeration of the ansatz circuits that are supported.

UCCSD = 0
default_initial_var_parameters()[source]

Returns initial variational parameters for a VQE simulation.

Returns initial variational parameters for the circuit that is generated for a given ansatz.

Returns

Initial parameters.

Return type

list

get_rdm()[source]

Obtain the RDMs from the optimized amplitudes.

Obtain the RDMs from the optimized amplitudes by using the same function for energy evaluation. The RDMs are computed by using each fermionic Hamiltonian term, transforming them and computing the elements one-by-one. Note that the Hamiltonian coefficients will not be multiplied as in the energy evaluation. The first element of the Hamiltonian is the nuclear repulsion energy term, not the Hamiltonian term.

Returns

One & two-particle RDMs (rdm1_np & rdm2_np, float64).

Return type

(numpy.array, numpy.array)

simulate(amplitudes)[source]

Perform the simulation for the molecule.

If the mean field is not provided it is automatically calculated.

Parameters

amplitudes (list) – The initial amplitudes (float64).

Returns

The total energy (energy).

Return type

float64