• Categories

  • Archives

Default labels for states in sympy.physics.quantum

This week was my first week working on sympy for GSoC, and my first step was to try to change, the piece of the sympy.physics.quantum code, to handle representations of operators and kets that may be derivatives or arbitrary functions. This is important for my work because many operators represented in the position or momentum bases are actually differential operators (for example, momentum in the position basis).

I first needed to discuss with Brian and Ondrej, my mentors, about what exactly was doing, in the quantum mechanical sense. We concluded that represent should try, if possible, to form an inner product, something like <x | psi>. For operators, it should return the result of <x | A | x’>.

As a first step to this, though, it was necessary to have some default labels for states. For example, if we want to represent something in the basis of XOp, the x operator of the position basis, then what labels for those basis kets should we have (|x_1>, |x_2>, etc.? or |x>, |x’> …). These kets need some default label because when we call represent, all we specify is the operator whose basis we wish to represent the expression in. So, to this end, I added default_label functions to Operator and QExpr, as well as some functions to states and operators so that eigenkets can identify the operator they are associated with and operators know which kets are their eigenkets.

Finally, after this, I changed represent. It currently just looks for a _represent_BasisClass style function in the expression passed to it. Now, however, if this fails, it also tries to form an inner product between an eigenket of the basis and the provided expression, if the expression is a ket or a bra.

The code for all of this is located here:

Still to be implemented is the <x | A | x’> functionality in represent. Also, I will be creating a DifferentialOperator class to be able to represent operators like d/dx which can be applied to wavefunctions. Feedback on the code is greatly appreciated from those sympy people who are interested!