Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
GSoC 2015 Application Xiang Gao : Adjust the structure of sympy.physics.quantum and implement all exact solutions
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.
Name: Xiang Gao
Programming Background and Environment
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
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
- Modify the class HilbertSpace to take a string parameter to denote different spaces.
- 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.
- 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
- 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.
- 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
- Implement partial trace and trace.
- Implement test for pure state or not
- 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
- Implement time evolution for time-independent Hamiltonian
- Implement time evolution for time-dependent Hamiltonian
5. Implement perturbation theory
- Implement time-independent perturbation theory
- Implement time-dependent perturbation theory
Community Bonding period
- Make myself familiar with sympy, being able to write code with sympy as fast as a developer of sympy.
- Implement the proposed adjustment to sympy
- Implement Space1D,Space3D,AngularMomentum
- Implement Hydrogen like atom and harmonic oscillator in the new proposed structure
- Implement free particles and particles in a box
- Implement quantum 3D-rigid rotor (linear, spherical, symmetric top)
- Implement time evolution
- Implement perturbation theory
- cleaning codes.
- improve documents and comments.
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