Skip to content

Interface

oqd_trical.light_matter.interface

AtomicEmulatorCircuit

Bases: TypeReflectBaseModel

Class representing a quantum information experiment represented in terms of atomic operations expressed in terms of their Hamiltonians.

Attributes:

Name Type Description
frame Optional[Operator]

Operator that defines the rotating frame of reference.

base Operator

Free Hamiltonian.

sequence List[AtomicEmulatorGate]

List of gates to apply.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/emulator.py
class AtomicEmulatorCircuit(TypeReflectBaseModel):
    """
    Class representing a quantum information experiment represented in terms of atomic operations expressed in terms of their Hamiltonians.

    Attributes:
        frame (Optional[Operator]): [`Operator`][oqd_trical.light_matter.interface.operator.Operator] that defines the rotating frame of reference.
        base (Operator): Free Hamiltonian.
        sequence (List[AtomicEmulatorGate]): List of gates to apply.

    """

    frame: Optional[OperatorSubTypes] = None
    sequence: List[AtomicEmulatorGate]

AtomicEmulatorGate

Bases: TypeReflectBaseModel

Class representing a gate represented in terms of atomic operations expressed in terms of their Hamiltonians.

Attributes:

Name Type Description
hamiltonian Operator

Hamiltonian to evolve by.

duration float

Time to evolve for.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/emulator.py
class AtomicEmulatorGate(TypeReflectBaseModel):
    """
    Class representing a gate represented in terms of atomic operations expressed in terms of their Hamiltonians.

    Attributes:
        hamiltonian (Operator): Hamiltonian to evolve by.
        duration (float): Time to evolve for.
    """

    hamiltonian: OperatorSubTypes
    duration: float

Annihilation

Bases: OperatorLeaf

Class representing an annihilation operator: $$ \hat{a} $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Annihilation(OperatorLeaf):
    """
    Class representing an annihilation operator:
    $$
    \\hat{a}
    $$
    """

    pass

Coefficient

Bases: TypeReflectBaseModel

Class representing a scalar coefficient for an operator.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Coefficient(TypeReflectBaseModel):
    """
    Class representing a scalar coefficient for an operator.
    """

    def __neg__(self):
        return CoefficientMul(
            coeff1=WaveCoefficient(amplitude=-1, frequency=0, phase=0),
            coeff2=self,
        )

    def __pos__(self):
        return self

    def __add__(self, other):
        return CoefficientAdd(coeff1=self, coeff2=other)

    def __sub__(self, other):
        return self + (-other)

    def __mul__(self, other):
        if isinstance(other, Coefficient):
            return CoefficientMul(coeff1=self, coeff2=other)
        else:
            return other * self

    def __rmul__(self, other):
        return self * other

    def __truediv__(self, other):
        if isinstance(self, WaveCoefficient) and isinstance(other, WaveCoefficient):
            return CoefficientMul(
                coeff1=self,
                coeff2=WaveCoefficient(
                    amplitude=1 / other.amplitude,
                    frequency=-other.frequency,
                    phase=-other.phase,
                ),
            )
        if isinstance(self, CoefficientAdd) and isinstance(other, WaveCoefficient):
            return CoefficientAdd(
                coeff1=self.coeff1 / other, coeff2=self.coeff2 / other
            )
        if isinstance(self, CoefficientMul) and isinstance(other, WaveCoefficient):
            return CoefficientMul(coeff1=self.coeff1, coeff2=self.coeff2 / other)
        else:
            raise TypeError("Division only supported for WaveCoefficients denominator")

    def conj(self):
        return Post(ConjugateCoefficient())(self)

    pass

CoefficientAdd

Bases: Coefficient

Class representing the addition of coefficients

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class CoefficientAdd(Coefficient):
    """
    Class representing the addition of coefficients
    """

    coeff1: CoefficientSubTypes
    coeff2: CoefficientSubTypes

CoefficientMul

Bases: Coefficient

Class representing the multiplication of coefficients

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class CoefficientMul(Coefficient):
    """
    Class representing the multiplication of coefficients
    """

    coeff1: CoefficientSubTypes
    coeff2: CoefficientSubTypes

Creation

Bases: OperatorLeaf

Class representing an annihilation operator: $$ \hat{a}^{\dagger} $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Creation(OperatorLeaf):
    """
    Class representing an annihilation operator:
    $$
    \\hat{a}^{\\dagger}
    $$
    """

    pass

Displacement

Bases: OperatorLeaf

Class representing a displacement operator: $$ e^{\alpha \hat{a}^{\dagger} - \alpha^* \hat{a}} $$

Attributes:

Name Type Description
alpha Coefficient

Displacement angle.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Displacement(OperatorLeaf):
    """
    Class representing a displacement operator:
    $$
    e^{\\alpha \\hat{a}^{\\dagger} - \\alpha^* \\hat{a}}
    $$

    Attributes:
        alpha (Coefficient): Displacement angle.
    """

    alpha: CoefficientSubTypes

Identity

Bases: OperatorLeaf

Class representing an identity operator: $$ \hat{\mathbb{I}} $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Identity(OperatorLeaf):
    """
    Class representing an identity operator:
    $$
    \\hat{\\mathbb{I}}
    $$
    """

    pass

KetBra

Bases: OperatorLeaf

Class representing a transition operator: $$ |i \rangle \langle j| $$

Attributes:

Name Type Description
ket int

End state.

bra int

Start state.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class KetBra(OperatorLeaf):
    """
    Class representing a transition operator:
    $$
    |i \\rangle \\langle j|
    $$

    Attributes:
        ket (int): End state.
        bra (int): Start state.

    """

    ket: int
    bra: int

Operator

Bases: TypeReflectBaseModel

Class representing a quantum operator.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Operator(TypeReflectBaseModel):
    """
    Class representing a quantum operator.
    """

    def __neg__(self):
        return OperatorScalarMul(
            op=self, coeff=WaveCoefficient(amplitude=-1, frequency=0, phase=0)
        )

    def __pos__(self):
        return self

    def __add__(self, other):
        return OperatorAdd(op1=self, op2=other)

    def __sub__(self, other):
        return OperatorAdd(
            op1=self,
            op2=OperatorScalarMul(
                op=other, coeff=WaveCoefficient(amplitude=-1, frequency=0, phase=0)
            ),
        )

    def __matmul__(self, other):
        if isinstance(other, Coefficient):
            raise TypeError(
                "Tried Kron product between Operator and Coefficient. "
                + "Scalar multiplication of Coefficient and Operator should be bracketed when perfoming Kron product."
            )
        return OperatorKron(op1=self, op2=other)

    def __mul__(self, other):
        if isinstance(other, Operator):
            return OperatorMul(op1=self, op2=other)
        else:
            return OperatorScalarMul(op=self, coeff=other)

    def __rmul__(self, other):
        return self * other

    pass

OperatorAdd

Bases: Operator

Class representing the addtition of Operators.

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorAdd(Operator):
    """
    Class representing the addtition of [`Operators`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
    """

    op1: OperatorSubTypes
    op2: OperatorSubTypes

OperatorKron

Bases: Operator

Class representing the tensor product of Operators.

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorKron(Operator):
    """
    Class representing the tensor product of [`Operators`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
    """

    op1: OperatorSubTypes
    op2: OperatorSubTypes

OperatorLeaf

Bases: Operator

Class representing a leaf operator

Attributes:

Name Type Description
subsystem Annotated[str, AfterValidator(issubsystem)]

Label for the subsystem the operator acts on.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorLeaf(Operator):
    """
    Class representing a leaf operator

    Attributes:
        subsystem (Annotated[str, AfterValidator(issubsystem)]): Label for the subsystem the operator acts on.
    """

    subsystem: Annotated[str, AfterValidator(issubsystem)]

OperatorMul

Bases: Operator

Class representing the multiplication of Operators.

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorMul(Operator):
    """
    Class representing the multiplication of [`Operators`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
    """

    op1: OperatorSubTypes
    op2: OperatorSubTypes

OperatorScalarMul

Bases: Operator

Class representing the scalar multiplication of a Coefficient and an Operator.

Attributes:

Name Type Description
op Operator

Operator to multiply.

coeff Coefficient

Coefficient to multiply.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorScalarMul(Operator):
    """
    Class representing the scalar multiplication of a [`Coefficient`][oqd_trical.light_matter.interface.operator.Coefficient]
    and an [`Operator`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op (Operator): [`Operator`][oqd_trical.light_matter.interface.operator.Operator] to multiply.
        coeff (Coefficient): [`Coefficient`][oqd_trical.light_matter.interface.operator.Coefficient] to multiply.
    """

    op: OperatorSubTypes
    coeff: CoefficientSubTypes

WaveCoefficient

Bases: Coefficient

Class representing a wave coefficient for an operator of the following form: $$ A e^{i(\omega t + \phi)}. $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class WaveCoefficient(Coefficient):
    """
    Class representing a wave coefficient for an operator of the following form:
    $$
    A e^{i(\\omega t + \\phi)}.
    $$
    """

    amplitude: CastMathExpr
    frequency: CastMathExpr
    phase: CastMathExpr

ConstantCoefficient(value)

Function to create a constant coefficient.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
def ConstantCoefficient(value):
    """
    Function to create a constant coefficient.
    """
    return WaveCoefficient(amplitude=value, frequency=0, phase=0)

emulator

AtomicEmulatorCircuit

Bases: TypeReflectBaseModel

Class representing a quantum information experiment represented in terms of atomic operations expressed in terms of their Hamiltonians.

Attributes:

Name Type Description
frame Optional[Operator]

Operator that defines the rotating frame of reference.

base Operator

Free Hamiltonian.

sequence List[AtomicEmulatorGate]

List of gates to apply.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/emulator.py
class AtomicEmulatorCircuit(TypeReflectBaseModel):
    """
    Class representing a quantum information experiment represented in terms of atomic operations expressed in terms of their Hamiltonians.

    Attributes:
        frame (Optional[Operator]): [`Operator`][oqd_trical.light_matter.interface.operator.Operator] that defines the rotating frame of reference.
        base (Operator): Free Hamiltonian.
        sequence (List[AtomicEmulatorGate]): List of gates to apply.

    """

    frame: Optional[OperatorSubTypes] = None
    sequence: List[AtomicEmulatorGate]

AtomicEmulatorGate

Bases: TypeReflectBaseModel

Class representing a gate represented in terms of atomic operations expressed in terms of their Hamiltonians.

Attributes:

Name Type Description
hamiltonian Operator

Hamiltonian to evolve by.

duration float

Time to evolve for.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/emulator.py
class AtomicEmulatorGate(TypeReflectBaseModel):
    """
    Class representing a gate represented in terms of atomic operations expressed in terms of their Hamiltonians.

    Attributes:
        hamiltonian (Operator): Hamiltonian to evolve by.
        duration (float): Time to evolve for.
    """

    hamiltonian: OperatorSubTypes
    duration: float

operator

Coefficient

Bases: TypeReflectBaseModel

Class representing a scalar coefficient for an operator.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Coefficient(TypeReflectBaseModel):
    """
    Class representing a scalar coefficient for an operator.
    """

    def __neg__(self):
        return CoefficientMul(
            coeff1=WaveCoefficient(amplitude=-1, frequency=0, phase=0),
            coeff2=self,
        )

    def __pos__(self):
        return self

    def __add__(self, other):
        return CoefficientAdd(coeff1=self, coeff2=other)

    def __sub__(self, other):
        return self + (-other)

    def __mul__(self, other):
        if isinstance(other, Coefficient):
            return CoefficientMul(coeff1=self, coeff2=other)
        else:
            return other * self

    def __rmul__(self, other):
        return self * other

    def __truediv__(self, other):
        if isinstance(self, WaveCoefficient) and isinstance(other, WaveCoefficient):
            return CoefficientMul(
                coeff1=self,
                coeff2=WaveCoefficient(
                    amplitude=1 / other.amplitude,
                    frequency=-other.frequency,
                    phase=-other.phase,
                ),
            )
        if isinstance(self, CoefficientAdd) and isinstance(other, WaveCoefficient):
            return CoefficientAdd(
                coeff1=self.coeff1 / other, coeff2=self.coeff2 / other
            )
        if isinstance(self, CoefficientMul) and isinstance(other, WaveCoefficient):
            return CoefficientMul(coeff1=self.coeff1, coeff2=self.coeff2 / other)
        else:
            raise TypeError("Division only supported for WaveCoefficients denominator")

    def conj(self):
        return Post(ConjugateCoefficient())(self)

    pass

WaveCoefficient

Bases: Coefficient

Class representing a wave coefficient for an operator of the following form: $$ A e^{i(\omega t + \phi)}. $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class WaveCoefficient(Coefficient):
    """
    Class representing a wave coefficient for an operator of the following form:
    $$
    A e^{i(\\omega t + \\phi)}.
    $$
    """

    amplitude: CastMathExpr
    frequency: CastMathExpr
    phase: CastMathExpr

CoefficientAdd

Bases: Coefficient

Class representing the addition of coefficients

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class CoefficientAdd(Coefficient):
    """
    Class representing the addition of coefficients
    """

    coeff1: CoefficientSubTypes
    coeff2: CoefficientSubTypes

CoefficientMul

Bases: Coefficient

Class representing the multiplication of coefficients

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class CoefficientMul(Coefficient):
    """
    Class representing the multiplication of coefficients
    """

    coeff1: CoefficientSubTypes
    coeff2: CoefficientSubTypes

Operator

Bases: TypeReflectBaseModel

Class representing a quantum operator.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Operator(TypeReflectBaseModel):
    """
    Class representing a quantum operator.
    """

    def __neg__(self):
        return OperatorScalarMul(
            op=self, coeff=WaveCoefficient(amplitude=-1, frequency=0, phase=0)
        )

    def __pos__(self):
        return self

    def __add__(self, other):
        return OperatorAdd(op1=self, op2=other)

    def __sub__(self, other):
        return OperatorAdd(
            op1=self,
            op2=OperatorScalarMul(
                op=other, coeff=WaveCoefficient(amplitude=-1, frequency=0, phase=0)
            ),
        )

    def __matmul__(self, other):
        if isinstance(other, Coefficient):
            raise TypeError(
                "Tried Kron product between Operator and Coefficient. "
                + "Scalar multiplication of Coefficient and Operator should be bracketed when perfoming Kron product."
            )
        return OperatorKron(op1=self, op2=other)

    def __mul__(self, other):
        if isinstance(other, Operator):
            return OperatorMul(op1=self, op2=other)
        else:
            return OperatorScalarMul(op=self, coeff=other)

    def __rmul__(self, other):
        return self * other

    pass

OperatorLeaf

Bases: Operator

Class representing a leaf operator

Attributes:

Name Type Description
subsystem Annotated[str, AfterValidator(issubsystem)]

Label for the subsystem the operator acts on.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorLeaf(Operator):
    """
    Class representing a leaf operator

    Attributes:
        subsystem (Annotated[str, AfterValidator(issubsystem)]): Label for the subsystem the operator acts on.
    """

    subsystem: Annotated[str, AfterValidator(issubsystem)]

KetBra

Bases: OperatorLeaf

Class representing a transition operator: $$ |i \rangle \langle j| $$

Attributes:

Name Type Description
ket int

End state.

bra int

Start state.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class KetBra(OperatorLeaf):
    """
    Class representing a transition operator:
    $$
    |i \\rangle \\langle j|
    $$

    Attributes:
        ket (int): End state.
        bra (int): Start state.

    """

    ket: int
    bra: int

Annihilation

Bases: OperatorLeaf

Class representing an annihilation operator: $$ \hat{a} $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Annihilation(OperatorLeaf):
    """
    Class representing an annihilation operator:
    $$
    \\hat{a}
    $$
    """

    pass

Creation

Bases: OperatorLeaf

Class representing an annihilation operator: $$ \hat{a}^{\dagger} $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Creation(OperatorLeaf):
    """
    Class representing an annihilation operator:
    $$
    \\hat{a}^{\\dagger}
    $$
    """

    pass

Displacement

Bases: OperatorLeaf

Class representing a displacement operator: $$ e^{\alpha \hat{a}^{\dagger} - \alpha^* \hat{a}} $$

Attributes:

Name Type Description
alpha Coefficient

Displacement angle.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Displacement(OperatorLeaf):
    """
    Class representing a displacement operator:
    $$
    e^{\\alpha \\hat{a}^{\\dagger} - \\alpha^* \\hat{a}}
    $$

    Attributes:
        alpha (Coefficient): Displacement angle.
    """

    alpha: CoefficientSubTypes

Identity

Bases: OperatorLeaf

Class representing an identity operator: $$ \hat{\mathbb{I}} $$

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class Identity(OperatorLeaf):
    """
    Class representing an identity operator:
    $$
    \\hat{\\mathbb{I}}
    $$
    """

    pass

OperatorAdd

Bases: Operator

Class representing the addtition of Operators.

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorAdd(Operator):
    """
    Class representing the addtition of [`Operators`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
    """

    op1: OperatorSubTypes
    op2: OperatorSubTypes

OperatorMul

Bases: Operator

Class representing the multiplication of Operators.

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorMul(Operator):
    """
    Class representing the multiplication of [`Operators`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
    """

    op1: OperatorSubTypes
    op2: OperatorSubTypes

OperatorKron

Bases: Operator

Class representing the tensor product of Operators.

Attributes:

Name Type Description
op1 Operator

Left hand side Operator

op2 Operator

Right hand side Operator

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorKron(Operator):
    """
    Class representing the tensor product of [`Operators`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op1 (Operator): Left hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
        op2 (Operator): Right hand side [`Operator`][oqd_trical.light_matter.interface.operator.Operator]
    """

    op1: OperatorSubTypes
    op2: OperatorSubTypes

OperatorScalarMul

Bases: Operator

Class representing the scalar multiplication of a Coefficient and an Operator.

Attributes:

Name Type Description
op Operator

Operator to multiply.

coeff Coefficient

Coefficient to multiply.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
class OperatorScalarMul(Operator):
    """
    Class representing the scalar multiplication of a [`Coefficient`][oqd_trical.light_matter.interface.operator.Coefficient]
    and an [`Operator`][oqd_trical.light_matter.interface.operator.Operator].

    Attributes:
        op (Operator): [`Operator`][oqd_trical.light_matter.interface.operator.Operator] to multiply.
        coeff (Coefficient): [`Coefficient`][oqd_trical.light_matter.interface.operator.Coefficient] to multiply.
    """

    op: OperatorSubTypes
    coeff: CoefficientSubTypes

ConstantCoefficient(value)

Function to create a constant coefficient.

Source code in oqd-trical/src/oqd_trical/light_matter/interface/operator.py
def ConstantCoefficient(value):
    """
    Function to create a constant coefficient.
    """
    return WaveCoefficient(amplitude=value, frequency=0, phase=0)