Hi,
Below are my initial thought on what to do for sympy.physics. I didn't wrote plans about second quantization because it require more thinking and discussing and it's better to work on this part first. Since there are a lot of changes, I think I need to discuss first. Do you have any suggestions about that?
Current status:
The relationship of wavefunction, bra, ket, operator, Hilbert space, and second quantization are not dealt in a good way. For example, in sympy.physics.hydrogen, sympy.physics.qho_1d, and sympy.physics.sho, the wavefunctions and energy levels are defined, however there is no corresponding object of class Ket is defined. It is impossible for me to get the corresponding Ket object of the eigenstates of these systems. Another example is that, it is impossible for me to do the following calculation: |a> is in space A, |b> is in space B, I want to deal with the direct product |a>|b> and calculate the Hilbert space it is in. Another example is, in Configuration Interaction and Coupled Cluster theory in theoretical chemistry, creation and annihilation operator is used to populate electrons of a molecule to excited state, there are a lot of algebra in this area on second quantization, but sympy don’t support it yet.
Ways of Improvement:
To solve these problems, reorganize maybe helpful. I suggest reorganize in the following way:
1. The class HilbertSpace takes a string parameter to denote different spaces.
2. When a Ket is initialized, two parameters must be given: one is the Hilbert space that this Ket is in another is can be a string or a Symbol. If the Ket is initialized with a string, the behavior of this Ket is similar to numbers (the members in sympy.core.numbers) in sympy. If the Ket is initialized with a Symbol, the behavior will be similar to a symbol (the members in sympy.core.symbol) in sympy.
3. Implement |x>, |p>, operator x, operator p, in the class sympy.physics.quantum.Space1D; implement |xyz>, |rθφ>, |pxpypz> and operators in the class sympy.physics.quantum.Space3D. The constructor of class Space1D and class Space3D takes the Hilbert space as its parameter. Implement angular momentums as sympy.physics.quantum.AngularMomentum.
4. Override the operator “in” in python, so that whether a Ket belongs to a space can be tested by: “myket in myspace”
5. Implement all exact solutions in quantum mechanics and quantum field theory as classes in package sympy.physics.quantum.ExcatSolutions.
6. Implement partial trace and trace
Expected Result:
Sample Code 1
>>>h1 = HilbertSpace(“H1”)
>>>h2 = HilbertSpace(“H2”)
>>>myket1 = Ket(h1,’a’)
>>>myket2 = Ket(h2,’b’)
>>>myket1 in h1
True
>>>myket2 in h1
False
>>>myket1*myket2 in h1*h2 #direct product
True
>>>myket1*myket1
Error: undefined operation
>>>myket1+myket2
Error: undefined operation
Sample code 2:
>>>h1 = HilbertSpace(“H1”) # Hilbert space of particle 1
>>>sp1 = Space3D(h1)
>>>hydrogen1 = HydrogenLike(h1)
>>>h2 = HilbertSpace(“H2”) # Hilbert space of particle 1
>>>sp2 = Space3D(h2)
>>>ho2 = HarmonicOscillator3D(h2)
>>>sp1.r_theta_phi_bra*hydrogen1.eigenstate(n=0,l=0,m=0)
Should output the wave function with variable r,theta,phi here
>>>sp2.xyz_bra*ho2.coherent_state(n=0,l=0,m=0)
Should output the wave function with variable x,y,z of coherent state of quantum harmonic oscillator.
>>> sp1.r_theta_phi_bra*ho2.coherent_state(n=0,l=0,m=0)
Error, incompatible space
Sample code 3:
>>>h1 = HilbertSpace(“H1”)
>>>h2 = HilbertSpace(“H2”)
>>>a1 = AngularMomentum(h1)
>>>a2 = AngularMomentum(h2)
>>>total_L = a1 + a2
>>>total_L.hilbert_space()
should output direct product of h1 and h2
>>>(a1.eigenbra(j=1/2,m=1/2)*a2.eigenbra(j=3,m=0)) * total_L.eigenket(j=3/2,m=1/2)
Should output Clebsch-Gordan coefficient
Sample code 4:
>>>h1 = HilbertSpace(“H1”)
>>>h2 = HilbertSpace(“H2”)
>>>h3 = HilbertSpace(“H3”)
>>>h4 = HilbertSpace(“H4”)
>>>density_matrix = … # codes that defines density matrix here
>>>density_matrix.trace()
Should output the trace
>>>density_matrix.trace(h1,h2)
Should output the result of the partial trace
Hi,
You mean that a+|0> would return an explicit first-quantized wavefunction if possible ?
For the application of the Wicks theorem, you would like to somehow include it into the simplify() routines ? Depending on the case, the user may not want to apply Wicks theorem in some particular formula.
In general, I think SymPy should not apply non-trivial transformations unless explicitly asked to do so, but maybe others can comment on that too.