Quantum system classes (quanguru.classes.QSys)#

Contains classes for Quantum systems.

genericQSys(**kwargs)

Base class for both single (qSystem) and composite (compQSystem) quantum system classes, and I hope to combine those two classes in here.

QuantumSystemOld([sysType])

This class can be used for creating either a composite or a single quantum system depending on the given kwargs, if no kwargs given, it creates a composite system by default.

compQSystem(**kwargs)

Class for composite quantum systems.

termTimeDep(**kwargs)

Parent class for term and qCoupling and I hope to combine those two in here.

term(**kwargs)

Term object for simple (i.e.

qSystem(**kwargs)

Class for single quantum systems, used as the parent for Cavity, Spin, and Qubit.

qCoupling(*args, **kwargs)

Class to create coupling terms between quantum systems.

SpinOld(**kwargs)

Object for a single Spin system with spin j (jValue).

QubitOld(**kwargs)

Spin 1/2 special case of Spin class, i.e. a Qubit.

CavityOld(**kwargs)

Cavity class, the only difference from a generic quantum object is that, by default, its operator is the number operator.

_initStDec(_createAstate)

Decorater to handle different inputs for initial state creation.

_computeDef(sys, state)

Dummy compute method used when creating a copy of quantum systems.

_calculateDef(sys)

Dummy calculate method used when creating a copy of quantum systems.

Function Name

Docstrings

Unit Tests

Tutorials

genericQSys

      ✅

    ❌

    ❌

QuantumSystemOld

      ✅

    ❌

    ❌

compQSystem

      ✅

    ❌

    ❌

termTimeDep

      ✅

    ❌

    ❌

term

      ✅

    ❌

    ❌

qSystem

      ✅

    ❌

    ❌

qCoupling

      ✅

    ❌

    ❌

SpinOld

      ✅

    ❌

    ❌

QubitOld

      ✅

    ❌

    ❌

CavityOld

      ✅

    ❌

    ❌

_initStDec

      ✅

    ❌

    ❌

_computeDef

      ✅

    ❌

    ❌

_calculateDef

      ✅

    ❌

    ❌

_initStDec(_createAstate)[source]#

Decorater to handle different inputs for initial state creation.

_computeDef(sys, state)[source]#

Dummy compute method used when creating a copy of quantum systems. TODO I am not happy with this solution.

_calculateDef(sys)[source]#

Dummy calculate method used when creating a copy of quantum systems. TODO I am not happy with this solution.

class genericQSys(**kwargs)[source]#

Bases: quanguru.classes.QSimComp.QSimComp

Base class for both single (qSystem) and composite (compQSystem) quantum system classes, and I hope to combine those two classes in here. Currently, a proxy QuantumSystem is introduced as a temporary solution.

label: str = 'genericQSys'#

(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

__unitary#

an internal freeEvolution protocol, this is the default evolution when a simulation is run.

__dimension#

dimension of Hilbert space of the quantum system

_inpCoef#

boolean to determine whether initialState inputs contains complex coefficients (the probability amplitudes) or the populations

__dimsBefore#

Total dimension of the other quantum systems before self in a composite system. It is 1, when self` is the first system in the composite system or self is not in a composite system.

__dimsAfter#

Total dimension of the other quantum systems after self in a composite system. It is 1, when self is the last system in the composite system.

__add__(other)[source]#

With this method, + creates a composite quantum system between self and the other quantum system.

_hasInSubs(other)[source]#

Returns True if the given system is in self.subSys or in any other subSys nested inside the self.subSys.

__sub__(other)[source]#

With this method, - removes the other from self, which should be the composite quantum system containing other.

__rmul__(other)[source]#

With this method, * creates a composite quantum system that contains N=other many quantum systems with the same type as self.

copy(**kwargs)[source]#

Create a copy of self and also change the parameter of the newly created copy with kwargs.

property ind#

If self is in a composite quantum system, this return an index representing the position of self in the composite system, else it returns 0. Also, the first system in a composite quantum system is at index 0.

property _dimsBefore#

Property to set and get the __dimsBefore. Getter can be used to get information, but the setter is intended purely for internal use.

property _dimsAfter#

Property to set and get the __dimsAfter. Getter can be used to get information, but the setter is intended purely for internal use.

property dimension#

Property to get the dimension of the quantum system. There is no setter as it is handled internally.

property _totalDim#

genericQSys.dimension returns the dimension of a quantum system itself, meaning it does not contain the dimensions of the other systems if self is in a composite system, _totalDim returns the total dimension by also taking the dimensions before and after self in a composte system.

property _freeEvol#

Property to get the default internal freeEvolution proptocol.

unitary()[source]#

Returns the unitary evolution operator for self.

property initialState#

Getter for the simulation initial state, equivalent to self.simulation.initialState. This works by assuming that its setter/s makes sure that _stateBase__initialState.value is not None for single systems (if its state is set).

_constructMatrices()[source]#

The matrices for 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.

addProtocol(protocol=None, system=None, protocolRemove=None)[source]#

adds the given protocol into self.simulation and uses self as system if it is not given. It also can removed a protocol (protocolRemove) at the same time.

_timeDependency(time=None)[source]#

Passes down the current time in evolution to all the subSys, which eventually are either term or qCoupling objects that are child classes of termTimeDep, which updates the frequency of the corresponding coupling or term using the timeDependency method created and given by the user. TODO Create a demo and hyperlink here.

class QuantumSystemOld(sysType='composite', **kwargs)[source]#

Bases: quanguru.classes.QSys.genericQSys

This class can be used for creating either a composite or a single quantum system depending on the given kwargs, if no kwargs given, it creates a composite system by default.

_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

static __new__(cls, sysType='composite', **kwargs)[source]#
class compQSystem(**kwargs)[source]#

Bases: quanguru.classes.QSys.genericQSys

Class for composite quantum systems.

label: str = 'QuantumSystemOld'#

(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

__qCouplings#

an ordered dictionary for the coupling terms

__qSystems#

an ordered dictionary for the quantum systems

_timeDependency(time=None)[source]#

Passes down the current time in evolution to all the subSys, which eventually are either term or qCoupling objects that are child classes of termTimeDep, which updates the frequency of the corresponding coupling or term using the timeDependency method created and given by the user. TODO Create a demo and hyperlink here.

property subSysDimensions#

Returns a list of dimensions of the quantum systems contained in self, which is a composite system.

property freeHam#

returns the Hamiltonian without the coupling terms.

property totalHam#

returns the total Hamiltonian of self including the coupling terms.

property couplingHam#

returns only the coupling terms of the Hamiltonian.

property qSystems#

returns the ordered dictionary that contains the sub-systems.

addSubSys(subSys, **kwargs)[source]#

Add a quantum system to self. Note that composite systems can contain other composite systems as sub-systems

createSubSys(subSysClass, **kwargs)[source]#

Create a subsystem of the given subSysClass class and also set the given kwargs to newly created system.

__addSub(subSys)#

internal method used to update relevant information (such as dimension before/after) for the existing and newly added sub-systems. This is purely for internal use.

_removeSubSysExc(subSys, _exclude=[])[source]#

Removes a quantum system from the composite system self and updates the relevant information in the remaining sub-systems (such as dimension before/after).

property qCouplings#

returns the ordered dictionary of coupling terms.

__addCoupling(couplingObj)#

Internal method used when adding a coupling term.

createSysCoupling(*args, **kwargs)[source]#

Creates a coupling term, sets the kwargs for that coupling, and uses args for the coupling operators and the corresponding operators, see addTerm in qCoupling to understand how args works. TODO Create a tutorial and hyperlink here

addSysCoupling(couplingObj)[source]#

Adds the given coupling term to self. TODO Create a tutorial and hyperlink here

_createAstate(inp=None)[source]#
_constructMatrices()[source]#

The matrices for 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.

updateDimension(qSys, newDimVal, oldDimVal=None, _exclude=[])[source]#

This method is called when the dimension of a subSys qSys is changed, so that the relevant changes are reflected to dimension before/after information for the other systems in the composite system.

Dicke(couplingStrength, subSys1=None, subSys2=None)#
JC(couplingStrength, subSys1=None, subSys2=None)#
Rabi(couplingStrength, subSys1=None, subSys2=None)#
class termTimeDep(**kwargs)[source]#

Bases: quanguru.classes.baseClasses.paramBoundBase

Parent class for term and qCoupling and I hope to combine those two in here.

label: str = '_timeDep'#

(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

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

__frequency#

frequency of the term, it is is the coupling strength in the case of coupling term

__order#

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

__operator#

operator for the term

copy(**kwargs)[source]#

Create a copy self and change the values of the attributes given in kwargs.

property operator#

Sets and gets the operator for term.

property order#

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

property frequency#

Sets and gets the frequency of the term.

_constructMatrices()[source]#

The matrices for 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. Currently, this is just pass and extended in the child classes, and the goal is to combine those methods in here

property totalHam#

Return the total Hamiltonian for this term.

property freeMat#

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

_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 relevant parameters (such as frequency of the term) as a function of time.

class term(**kwargs)[source]#

Bases: quanguru.classes.QSys.termTimeDep

Term object for simple (i.e. non-coupling) terms in the Hamiltonian.

label: str = 'term'#

(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

property superSys: Any#

superSys property get/sets __superSys protected attribute

property _freeMatSimple#

Return the matrix corresponding to the operator of the term, but this method does not make it into a composite operator even if the term belongs to a system in a composite quantum system.

_constructMatrices(dimsBefore=None, dimsAfter=None, setMat=True)[source]#

The matrices for 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.

class qSystem(**kwargs)[source]#

Bases: quanguru.classes.QSys.genericQSys

Class for single quantum systems, used as the parent for Cavity, Spin, and Qubit.

label: str = 'QuantumSystemOld'#

(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

property dimension#

Property to get the dimension of the quantum system. There is no setter as it is handled internally.

property totalHam#

Returns the total Hamiltonian of the single quantum system.

property _totalHamSimple#

returns the total Hamiltonian of the single quantum system, but this method does not take the dimension before/after into account even if self is a sub-system of a composite system.

property freeMat#

returns the free (i.e. no frequency or, equivalently frequency=1) matrix for the operator of the first term in its Hamiltonian.

property operator#

Gets a list of the operators for the terms in its Hamiltonian, and sets the operator only for the first term.

property frequency#

Setter and getter of the frequency of the first term in its Hamiltonian.

property order#

Sets and gets the order/power of the operator of the first term in its Hamiltonian.

property firstTerm#

Returns the first term in its Hamiltonian

addSubSys(subSys, **kwargs)[source]#

extends the addSubSys method from the parent classes and uses it add terms to its Hamiltonian.

_removeSubSysExc(subSys, _exclude=[])[source]#

Method to remove a term from its Hamiltonian.

property terms#

returns a list of the term objects used for its Hamiltonian.

addTerm(operator, frequency=0, order=1)[source]#

Calls the addSubSys to add terms, this method is created to provide a more intuitive name than addSubSys

removeTerm(termObj)[source]#

Calls the removeSubSys to remove terms, this method is created to provide a more intuitive name than removeSubSys

_createAstate(inp=None)[source]#
class SpinOld(**kwargs)[source]#

Bases: quanguru.classes.QSys.qSystem

Object for a single Spin system with spin j (jValue).

label: str = 'SpinOld'#

(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

__jValue#

spin quantum number

property jValue#

Gets and sets the spin quantum number

class QubitOld(**kwargs)[source]#

Bases: quanguru.classes.QSys.SpinOld

Spin 1/2 special case of Spin class, i.e. a Qubit.

label: str = 'QubitOld'#

(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

class CavityOld(**kwargs)[source]#

Bases: quanguru.classes.QSys.qSystem

Cavity class, the only difference from a generic quantum object is that, by default, its operator is the number operator.

label: str = 'CavityOld'#

(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

class qCoupling(*args, **kwargs)[source]#

Bases: quanguru.classes.QSys.termTimeDep

Class to create coupling terms between quantum systems.

label: str = 'qCoupling'#

(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

property couplingOperators#

returns a list of coupling operators stored in this coupling term

property coupledSystems#

returns the list of coupled systems by this coupling term

property couplingStrength#

Gets and sets the coupling strength for this coupling. This is simply an alternative terminology for frequency.

__coupOrdering(qts)#

method used internally to make some sorting of the operators. This is implemented so that there are some flexibilities for user when creating coupling.

_constructMatrices()[source]#

The matrices for 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.

__addTerm(count, ind, sys, *args)#

used internally when adding terms to the coupling.

addTerm(*args)[source]#

method to add terms to the coupling.

removeSysCoupling(sys)[source]#

method to remove terms from the coupling, simply calls removeSubSys, this method is to create terminology

_removeSubSysExc(subSys, _exclude=[])[source]#

method to remove terms from the coupling