GSoC 2015 Application Xiang Gao : Adjust the structure of sympy.physics.quantum and implement all exact solutions - sympy/sympy GitHub Wiki

About me

I'm a 1st year graduate student on computational chemistry at University of Florida. I received my bachelor of science in physics and bachelor of engineering in computer science and technology at University of Science and Technology of China in 2014.

Contact Information

Name: Xiang Gao

Email: [email protected]

GitHub: zasdfgbnm

Programming Background and Environment

Language: very familiar with C and C++; familiar with python, php, java, HTML, javascript, LaTeX, Fortran, etc.

System: Now using Mac OS X. Familiar with the usage of Linux; have a little basic knowledge in Linux kernel. Have experience in developing a simple (very simple) character device drive. Familiar with Windows

Editor: Vim

Patch Requirement

See: https://github.com/sympy/sympy/pull/9188

Detailed Description of Ideas

The relationship of wavefunction, bra, ket, operator, Hilbert space, and second quantization are not dealt in a systematic enough 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 states in the direct product space and calculate the partial trace. 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.

1. Proposed adjustment of the structure of sympy.physics.quantum

  1. Modify the class HilbertSpace to take 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. Override the operator “in” in python, so that whether a Ket belongs to a space can be tested by: “myket in myspace”

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

2. Implement well known operators, eigenstates, etc

  1. 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.
  2. Implement useful exact solutions in quantum mechanics as classes in package sympy.physics.quantum.ExcatSolutions.

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

3. Implement operations of density matrix

  1. Implement partial trace and trace.
  2. Implement test for pure state or not
  3. Implement von Neumann entropy

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

4. Implement time evolution of both time-independent and time-dependent Hamiltonian

  1. Implement time evolution for time-independent Hamiltonian
  2. Implement time evolution for time-dependent Hamiltonian

5. Implement perturbation theory

  1. Implement time-independent perturbation theory
  2. Implement time-dependent perturbation theory

Timeline

Community Bonding period

  • Make myself familiar with sympy, being able to write code with sympy as fast as a developer of sympy.

Week 1-2

  • Implement the proposed adjustment to sympy

Week 3-4

  • Implement Space1D,Space3D,AngularMomentum

Week 5

  • Implement Hydrogen like atom and harmonic oscillator in the new proposed structure

Week 6

  • Implement free particles and particles in a box

Week 7

  • Implement quantum 3D-rigid rotor (linear, spherical, symmetric top)

Week 8-9

  • Implement time evolution

Week 10-11

  • Implement perturbation theory

Week 12-13

  • cleaning codes.
  • improve documents and comments.
  • bugfixes.

Future work

Implement second quantization, quantum field theory.

Sample code for second quantization:

>>>h1 = HilbertSpace(“H1”)
>>>ket1 = Space3D(h1).pxpypz_ket()
>>>sq = SecondQuantization(h1)
>>>sq.hilbert_space()
FockSpace(H1) = vacuum + H1+H1*H1+H1*H1*H1+…
>>>h = … # define some operator
>>>h.hilbert_space()
H1*H1
>>>h2 = sq.second_quantize(h,ket1)
express h in second quantization form
>>>h2.hilbert_space()
FockSpace(H1)
>>>sq.vacuum_bra*sq.create_bra(ket1)*sq.create_bra(ket1)*h2*sq.annihilate_ket(ket1)*sq.vacuum_ket
apply wick’s theorem to do calculation