Quantum system classes (quanguru.classes.QTerms)#

Contains the QTerm object that is used for the terms of the quantum system Hamiltonians

QTerm(**kwargs)

Class for Hamiltonian terms, both for single system terms and couplings.

Function Name

Docstrings

Unit Tests

Tutorials

QTerm

      ✅

    ✅

    ❌

class QTerm(**kwargs)[source]#

Bases: quanguru.classes.baseClasses.paramBoundBase

Class for Hamiltonian terms, both for single system terms and couplings.

label: str = 'QTerm'#

(class attribute) class label used in default naming

_internalInstances: int = 0#

(class attribute) number of instances created internally by the library

_externalInstances: int = 0#

(class attribute) number of instances created explicitly by the user

_instances: int = 0#

(class attribute) number of total instances = _internalInstances + _externalInstances

__qSys#

attribute to store the quantum systems of the term. This is either a single quantum system or a list/tuple of quantum systems, and these are needed for the dimension information of the matrix creations

__frequency#

frequency of the term which needs to be a numerical value (and None by default). A numerical default could lead to mistakes, therefore it is None by default.

__operator#

operator for the term needs to be a function (pointer) and it is used for the creation of the matrix representation of the operator. The library passes the dimension information into this function and converts the returned matrix into composite operator if needed. Therefore, this function only needs to return the simple matrix (not the composite) by using the dimension information.

__order#

the order/power for the operator of the term. The operator is raised to the power in this value

__HamiltonianTerm#

used for storing the matrix corresponding to this term

timeDependency#

function that can be assigned by the user to update the parameters a function of time. The library passes the current time to this function, and any desired parameter can be updated as a function of time.

_timeDependency(time=None)[source]#

Internal method that passes the current time to timeDependency method that needs to be defined by the user to update the desired parameters (such as frequency of the term) as a function of time.

property superSys: Any#

superSys property get/sets __superSys protected attribute

property qSystem#

Property to set and get the single quantum system or a list/tuple of quantum systems that are used by the term for the dimension information during the matrix creations. Setter replaces the existing system/s with the given and also resets the order and operator values to their defaults (with the subSys dict which holds other terms if self has more than 1 quantum system, i.e. coupling)

_removeTermIfQSysInList(qSys, subSys)[source]#

removes self (the term) from the terms of given qSys if a particular subSys is in qSystem list of self. This is an internal method used in removeSubSys of quantum systems.

static _createTerm(superSys, qSystem, operator, order=None, frequency=None, **kwargs)[source]#

Factory method to create new QTerm with the given qSystem, operator, and optional orders and frequency.

Parameters
  • qSystem – Single or a list/tuple of quantum systems for qSystem of the newly created QTerm

  • operator – Single or a list/tuple of operator/s (same number as qSystem) for the newly created QTerm

  • order – Single or a list/tuple of order values for each operator (same number as operator/s) for the newly created QTerm, default is 1 for each operator.

  • frequency – Frequency of the newly created QTerm

Returns

Newly created QTerm object

Return type

QTerm

_checkAndUpdateParamsWhenMultiple(vals, attrName, attrPrintName)[source]#

This is used internally when setting the operator and/or order of the term to ensure that the number of the operator and order are the same as qSystem. Before updating the value of operator and/or order, it makes couple of checks that raise errors, if there is no qSystem and/or the number of the qSystem and the vals does not match.

Parameters
  • vals – New value of the attribute

  • attrName (str) – Name of the attribute whose value is going to be changed.

  • attrPrintName (str) – Simplified name of the attribute to use with the error messages of the checks to avoid printing the name-mangled attribute names

property operator#

Sets and gets the operator/s of the term.

property order#

Sets and gets the order/s of the operator/s of the term.

property frequency#

Sets and gets the frequency of the term.

property totalHamiltonian#

Return the total Hamiltonian (ie frequency*operator) for this term.

property _freeMatrix#

Gets and sets the free matrix, ie without the frequency (or, equivalently frequency=1) of the term.

static _isOperPauli(oper)[source]#

Static method to determine if the given operator/s is a Pauli operator.

static _isCorrectPauliDim(qsys, oper, dim=None)[source]#

Static method to determine if the dimension of a system is consistent with given operator

static _dimInput(qsys, oper, order)[source]#

Static method to create the composite operator for a given quantum system and operator. This method is used in _constructMatrices, where the system and operator are passed.

_constructMatrices()[source]#

The matrices for the operators constructed and de-constructed whenever they should be, and this method is used internally in various places when the matrices are needed to be constructed.