MixedOp

class MixedOp(data)[source]

Bases: LinearMixin

Mixed operator.

A MixedOp represents a weighted sum of products of operators such as fermionic, bosonic or spin operators acting on respective Hilbert spaces. The terms to be summed are encoded in a dictionary, where each operator product is identified by its key, a tuple of string specifying the names of the local Hilbert spaces on which it acts, and by its value, a list of tuple (corresponding to a sum of operators acting on the same composite Hilbert space) where each tuple encodes the coupling coefficient and the operators themselves (that might also have coefficients associated with them).

Initialization

A MixedOp is initialized with a dictionary, mapping terms to their respective coefficients:

from qiskit_nature.second_q.operators import FermionicOp, SpinOp, MixedOp

fop1 = FermionicOp({"+_0 -_0": 1}) # Acting on Hilbert space "h1"
sop1 = SpinOp({"X_0 Y_0": 1}, num_spins=1) # Acting on Hilbert space "s1"

mop1 = MixedOp({("h1",): [(5.0, fop1)]})
mop2 = MixedOp(
    {
        ("h1", "s1"): [(3, fop1, sop1)],
        ("s1",): [(2, sop1)],
    }
)
# 5.0 * fop1 (acts as identity on the spin Hilbert space)
# 3*(fop1 @ sop1) (fermion-spin coupling term)
# 2*(sop1) (acts as identity on the fermionic Hilbert space)

Algebra

This class supports the following basic arithmetic operations: addition, subtraction, scalar multiplication, operator multiplication. For example,

Addition

fop1 = FermionicOp({"+_0 -_0": 1}) # Acting on Hilbert space "h1"
sop1 = SpinOp({"X_0 Y_0": 1}, num_spins=1) # Acting on Hilbert space "s1"
MixedOp({("h1",): [(5.0, fop1)]}) + MixedOp({("s1",): [(6.0, sop1)]})
# MixedOp({("h1",): [(5.0, fop1)], ("s1",): [(6.0, sop1)]})

Scalar multiplication

fop1 = FermionicOp({"+_0 -_0": 1})
0.5 * MixedOp({("h1",): [(5.0, fop1)]})

Operator multiplication

fop1 = FermionicOp({"+_0 -_0": 1}) # Acting on Hilbert space "h1"
sop1 = SpinOp({"X_0 Y_0": 1}, num_spins=1) # Acting on Hilbert space "s1"
MixedOp({("h1",): [(5.0, fop1)]}) @ MixedOp({("s1",): [(6.0, sop1)]})
# MixedOp({("h1", "s1"): [(30.0, fop1, sop1)]})

Methods

classmethod compose(op_left, op_right)[source]

Returns Operator composition of two mixed operators.

Parameters:
  • op_left (MixedOp) – left MixedOp to tensor.

  • op_right (MixedOp) – right MixedOp to tensor.

Returns:

The tensor product of left with right.

Return type:

MixedOp