qnet package

Main QNET package

The qnet package exposes all of QNET’s functionality for easy interactive or programmative use.

For interactive usage, the package should be initialized as follows:

>>> import qnet
>>> qnet.init_printing()

QNET provides a “flat” API. That is, after

>>> import qnet

all submodules are directly accessible, e.g.

>>> qnet.algebra.core.operator_algebra.OperatorSymbol
<class 'qnet.algebra.core.operator_algebra.OperatorSymbol'>

Furthermore, every package exports the “public” symbols of any of its submodules/subpackages (public symbols are those listed in __all__)

>>> (qnet.algebra.core.operator_algebra.OperatorSymbol is
...  qnet.algebra.core.OperatorSymbol is qnet.algebra.OperatorSymbol is
...  qnet.OperatorSymbol)

In an interactive context (and only there!), a star import such as

from qnet.algebra import *

may be useful.



__all__ Exceptions:

AlgebraError Base class for all algebraic errors
AlgebraException Base class for all algebraic exceptions
BadLiouvillianError Raised when a Liouvillian is not of standard Lindblad form.
BasisNotSetError Raised if the basis or a Hilbert space dimension is unavailable
CannotConvertToSLH Raised when a circuit algebra object cannot be converted to SLH
CannotEliminateAutomatically Raised when attempted automatic adiabatic elimination fails.
CannotSimplify Raised when a rule cannot further simplify an expression
CannotSymbolicallyDiagonalize Matrix cannot be diagonalized analytically.
CannotVisualize Raised when a circuit cannot be visually represented.
IncompatibleBlockStructures Raised for invalid block-decomposition
InfiniteSumError Raised when expanding a sum into an infinite number of terms
NoConjugateMatrix Raised when entries of Matrix have no defined conjugate
NonSquareMatrix Raised when a Matrix fails to be square
OverlappingSpaces Raised when objects fail to be in separate Hilbert spaces.
SpaceTooLargeError Raised when objects fail to be have overlapping Hilbert spaces.
UnequalSpaces Raised when objects fail to be in the same Hilbert space.
WrongCDimError Raised for mismatched channel number in circuit series

__all__ Classes:

Adjoint Symbolic Adjoint of an operator
BasisKet Local basis state, identified by index or label
Beamsplitter Infinite bandwidth beamsplitter component.
Bra The associated dual/adjoint state for any ket
BraKet The symbolic inner product between two states
CPermutation Channel permuting circuit
Circuit Base class for the circuit algebra elements
CircuitSymbol Symbolic circuit element
CoherentDriveCC Coherent displacement of the input field
CoherentStateKet Local coherent state, labeled by a complex amplitude
Commutator Commutator of two operators
Component Base class for circuit components
Concatenation Concatenation of circuit elements
Create Bosonic creation operator
Destroy Bosonic annihilation operator
Displace Unitary coherent displacement operator
Eq Symbolic equation
Expression Base class for all QNET Expressions
Feedback Feedback on a single channel of a circuit
FockIndex Symbolic index labeling a basis state in a LocalSpace
FockLabel Symbolic label that evaluates to the label of a basis state
HilbertSpace Base class for Hilbert spaces
IdxSym Index symbol in an indexed sum or product
IndexOverFockSpace Index range over the integer indices of a LocalSpace basis
IndexOverList Index over a list of explicit values
IndexOverRange Index over the inclusive range between two integers
IndexedSum Base class for indexed sums
IntIndex A symbolic label that evaluates to an integer
Jminus Lowering operator on a spin space
Jplus Raising operator of a spin space
Jz Spin (angular momentum) operator in z-direction
KetBra Outer product of two states
KetIndexedSum Indexed sum over Kets
KetPlus Sum of states
KetSymbol Symbolic state
LocalKet A state on a LocalSpace
LocalOperator Base class for “known” operators on a LocalSpace
LocalSigma Level flip operator between two levels of a LocalSpace
LocalSpace Hilbert space for a single degree of freedom.
MatchDict Result of a Pattern.match()
Matrix Matrix of Expressions
NullSpaceProjector Projection operator onto the nullspace of its operand
Operation Base class for “operations”
Operator Base class for all quantum operators.
OperatorDerivative Symbolic partial derivative of an operator
OperatorIndexedSum Indexed sum over operators
OperatorPlus Sum of Operators
OperatorPlusMinusCC An operator plus or minus its complex conjugate
OperatorSymbol Symbolic operator
OperatorTimes Product of operators
OperatorTimesKet Product of an operator and a state.
OperatorTrace (Partial) trace of an operator
Pattern Pattern for matching an expression
Phase Unitary “phase” operator
PhaseCC Coherent phase shift cicuit component
ProductSpace Tensor product of local Hilbert spaces
PseudoInverse Symbolic pseudo-inverse \(X^+\) of an operator \(X\)
QuantumAdjoint Base class for adjoints of quantum expressions
QuantumDerivative Symbolic partial derivative
QuantumExpression Base class for expressions associated with a Hilbert space
QuantumIndexedSum Base class for indexed sums
QuantumOperation Base class for operations on quantum expression
QuantumPlus General implementation of addition of quantum expressions
QuantumSymbol Symbolic element of an algebra
QuantumTimes General implementation of product of quantum expressions
SLH Element of the SLH algebra
SPost Linear post-multiplication operator
SPre Linear pre-multiplication operator
Scalar Base class for Scalars
ScalarDerivative Symbolic partial derivative of a scalar
ScalarExpression Base class for scalars with non-scalar arguments
ScalarIndexedSum Indexed sum over scalars
ScalarPlus Sum of scalars
ScalarPower A scalar raised to a power
ScalarTimes Product of scalars
ScalarTimesKet Product of a Scalar coefficient and a ket
ScalarTimesOperator Product of a Scalar coefficient and an Operator
ScalarTimesQuantumExpression Product of a Scalar and a QuantumExpression
ScalarTimesSuperOperator Product of a Scalar coefficient and a SuperOperator
ScalarValue Wrapper around a numeric or symbolic value
SeriesInverse Symbolic series product inversion operation
SeriesProduct The series product circuit operation.
SingleQuantumOperation Base class for operations on a single quantum expression
Singleton Metaclass for singletons
SpinIndex Symbolic label for a spin degree of freedom
SpinOperator Base class for operators in a spin space
SpinSpace A Hilbert space for an integer or half-integer spin system
Squeeze Unitary squeezing operator
State Base class for states in a Hilbert space
StateDerivative Symbolic partial derivative of a state
StrLabel Symbolic label that evaluates to a string
SuperAdjoint Adjoint of a super-operator
SuperOperator Base class for super-operators
SuperOperatorDerivative Symbolic partial derivative of a super-operator
SuperOperatorPlus A sum of super-operators
SuperOperatorSymbol Symbolic super-operator
SuperOperatorTimes Product of super-operators
SuperOperatorTimesOperator Application of a super-operator to an operator
TensorKet A tensor product of kets

__all__ Functions:

FB Wrapper for Feedback, defaulting to last channel
KroneckerDelta Kronecker delta symbol
LocalProjector A projector onto a specific level of a LocalSpace
PauliX Pauli-type X-operator
PauliY Pauli-type Y-operator
PauliZ Pauli-type Z-operator
SLH_to_qutip Generate and return QuTiP representation matrices for the Hamiltonian and the collapse operators.
SpinBasisKet Constructor for a BasisKet for a SpinSpace
Sum Instantiator for an arbitrary indexed sum.
adjoint Return the adjoint of an obj.
anti_commutator If B != None, return the anti-commutator \(\{A,B\}\), otherwise return the super-operator \(\{A,\cdot\}\).
ascii Return an ASCII representation of the given object / expression
block_matrix Generate the operator matrix with quadrants
circuit_identity Return the circuit identity for n channels
commutator Commutator of A and B
configure_printing Context manager for temporarily changing the printing system.
connect Connect a list of components according to a list of connections.
convert_to_qutip Convert a QNET expression to a qutip object
convert_to_sympy_matrix Convert a QNET expression to an explicit n x n instance of sympy.Matrix, where n is the dimension of full_space.
decompose_space Simplifies OperatorTrace expressions over tensor-product spaces by turning it into iterated partial traces.
diagm Generalizes the diagonal matrix creation capabilities of numpy.diag to Matrix objects.
dotprint Return the `DOT`_ (graph) description of an Expression tree as a string
draw_circuit Generate a graphic representation of circuit and store them in a file.
draw_circuit_canvas Generate a PyX graphical representation of a circuit expression object.
eval_adiabatic_limit Compute the limiting SLH model for the adiabatic approximation
expand_commutators_leibniz Recursively expand commutators in expr according to the Leibniz rule.
extract_channel Create a CPermutation that extracts channel k
factor_coeff Factor out coefficients of all factors.
factor_for_trace Given a LocalSpace ls to take the partial trace over and an operator op, factor the trace such that operators acting on disjoint degrees of freedom are pulled out of the trace.If the operator acts trivially on ls the trace yields only a pre-factor equal to the dimension of ls.If there are LocalSigma operators among a product, the trace’s cyclical property is used to move to sandwich the full product by LocalSigma operators:.
getABCD Calculate the ABCD-linearization of an SLH model
get_coeffs Create a dictionary with all Operator terms of the expression (understood as a sum) as keys and their coefficients as values.
hstackm Generalizes numpy.hstack to Matrix objects.
identity_matrix Generate the N-dimensional identity matrix.
init_algebra Initialize the algebra system
init_printing Initialize the printing system.
latex Return a LaTeX representation of the given object / expression
lindblad Return the super-operator Lindblad term of the Lindblad operator C
liouvillian Return the Liouvillian super-operator associated with H and Ls
liouvillian_normal_form Return a Hamilton operator H and a minimal list of collapse operators Ls that generate the liouvillian L.
map_channels Create a CPermuation based on a dict of channel mappings
match_pattern Recursively match expr with the given expr_or_pattern
move_drive_to_H Move coherent drives from the Lindblad operators to the Hamiltonian
no_instance_caching Temporarily disable instance caching in create()
pad_with_identity Pad a circuit by adding a n-channel identity circuit at index k
pattern ‘Flat’ constructor for the Pattern class
pattern_head Constructor for a Pattern matching a ProtoExpr
prepare_adiabatic_limit Prepare the adiabatic elimination on an SLH object
print_tree Print a tree representation of the structure of expr
rewrite_with_operator_pm_cc Try to rewrite expr using OperatorPlusMinusCC
singleton_object Class decorator that transforms (and replaces) a class definition (which must have a Singleton metaclass) with the actual singleton object.
sqrt Square root of a Scalar or scalar value
srepr Render the given expression into a string that can be evaluated in an appropriate context to re-instantiate an identical expression.
substitute Substitute symbols or (sub-)expressions with the given replacements and re-evalute the result
symbols The symbols() function from SymPy
temporary_instance_cache Use a temporary cache for instances in create()
temporary_rules Allow temporary modification of rules for create()
tex Alias for latex()
tree Give the output of tree as a multiline string, using line drawings to visualize the hierarchy of expressions (similar to the tree unix command line program for showing directory trees)
try_adiabatic_elimination Attempt to automatically do adiabatic elimination on an SLH object
unicode Return a unicode representation of the given object / expression
vstackm Generalizes numpy.vstack to Matrix objects.
wc Constructor for a wildcard-Pattern
zerosm Generalizes numpy.zeros to Matrix objects.

__all__ Data:

CIdentity Single pass-through channel; neutral element of SeriesProduct
CircuitZero Zero circuit, the neutral element of Concatenation
FullSpace The ‘full space’, i.e.
II IdentityOperator constant (singleton) object.
IdentityOperator IdentityOperator constant (singleton) object.
IdentitySuperOperator Neutral element for product of super-operators
One The neutral element with respect to scalar multiplication
SingletonType A dummy type that may be used to check whether an object is a Singleton:
TrivialKet TrivialKet constant (singleton) object.
TrivialSpace The ‘nullspace’, i.e.
Zero The neutral element with respect to scalar addition
ZeroKet ZeroKet constant (singleton) object for the null-state.
ZeroOperator ZeroOperator constant (singleton) object.
ZeroSuperOperator Neutral element for sum of super-operators
tr Instantiate while applying automatic simplifications