from sympy import * init_printing() from sympy.physics.quantum import * from sympy.physics.quantum.boson import * from sympy.physics.quantum.fermion import * from sympy.physics.quantum.operatorordering import * #help(BosonOp) #help(FermionOp) help(normal_order) help(normal_ordered_form) a = BosonOp('a') b = BosonOp('b') a.is_annihilation, Dagger(a).is_annihilation Commutator(a, Dagger(a)).doit() Commutator(Dagger(a), a).doit() Commutator(a, a).doit() Commutator(Dagger(a), Dagger(a)).doit() Dagger(Dagger(Dagger(a))) Commutator(a, Dagger(Dagger(a))) #.doit() Commutator(a, b).doit() Commutator(a, b).doit(independent=True) c = FermionOp('c') d = FermionOp('d') Commutator(c,Dagger(c)) AntiCommutator(c,Dagger(c)) AntiCommutator(c, Dagger(c)).doit() AntiCommutator(Dagger(c), c).doit() AntiCommutator(c,d).doit() Commutator(a, c).doit() normal_ordered_form(Dagger(a) * a) normal_ordered_form(a * Dagger(a)) normal_ordered_form(a * Dagger(a) * a) normal_ordered_form(a * a * Dagger(a)) normal_ordered_form(a * a * a * Dagger(a)) normal_ordered_form(a * Dagger(a) * a * Dagger(a)) normal_ordered_form(a * Dagger(a) * Dagger(a) * Dagger(a)) normal_ordered_form(a * Dagger(b)) normal_ordered_form(a * Dagger(b)).doit() normal_ordered_form(a * Dagger(b), independent=True) normal_ordered_form(a * Dagger(b) * Dagger(a)) normal_ordered_form(a * Dagger(b) * Dagger(a), independent=True) normal_order(Dagger(a) * a) normal_order(a * Dagger(a)) normal_order(a * a * a * Dagger(a)) normal_order(a * Dagger(a) * a * Dagger(a) * a) a * Dagger(a) - normal_order(a * Dagger(a)) normal_ordered_form(a * Dagger(a) - normal_order(a * Dagger(a))) normal_ordered_form(Dagger(c) * c) normal_ordered_form(c * Dagger(c)) normal_ordered_form(c * c * Dagger(c)) normal_ordered_form(c * c * c * Dagger(c)) normal_ordered_form(c * Dagger(c) * c * Dagger(c)) normal_ordered_form(c * Dagger(d)) normal_ordered_form(c * Dagger(d), independent=True) normal_order(Dagger(c) * c) normal_order(c * Dagger(c)) normal_order(c * Dagger(c) * c * Dagger(c) * c) c * Dagger(c) - normal_order(c * Dagger(c)) normal_ordered_form(c * Dagger(c) - normal_order(c * Dagger(c))) ket = BosonFockKet(2) ket bra = BosonFockBra(2) bra type(bra), type(ket) a * ket, qapply(a * ket) bra * a, qapply(bra * a, dagger=True) qapply(Dagger(ket) * ket) (Dagger(ket) * ket).doit() (bra * Dagger(bra)).doit() Dagger(ket) * Dagger(a) * ket, qapply(Dagger(ket) * Dagger(a) * ket).doit() (bra * Dagger(a) * Dagger(a) * a * a * ket).doit() qapply(Dagger(ket) * Dagger(a) * a * ket).doit() qapply(bra * Dagger(a) * a * Dagger(bra)).doit() ket = BosonFockKet(4) bra = BosonFockBra(2) bra * a * a * ket, qapply(bra * a * a * ket).doit() alpha, beta = symbols("alpha, beta") ket = BosonCoherentKet(alpha) ket bra = BosonCoherentBra(beta) bra bra * ket (bra * ket).doit() qapply((bra * qapply(a * ket))).doit() qapply(Dagger(ket) * Dagger(a) * a * ket, dagger=True) normal_ordered_form(a * Dagger(a)) qapply(bra * a * Dagger(a) * ket, dagger=True) qapply(bra * normal_ordered_form(a * Dagger(a)) * ket, dagger=True) ket = FermionFockKet(1) ket bra = FermionFockBra(0) bra (bra * ket).doit() c * ket qapply(c * ket) qapply(c * c * ket) qapply(Dagger(c) * ket) qapply(Dagger(c) * c * ket) Dagger(c) * c qapply(Dagger(ket) * Dagger(c) * c * ket).doit() qapply(bra * Dagger(c) * c * Dagger(bra)).doit() I2 = TensorProduct(IdentityOperator(), IdentityOperator()) I2 psi = TensorProduct(BosonFockKet(1),BosonFockKet(2)) psi I2 * psi qapply(I2 * psi) a1 = TensorProduct(BosonOp("a"), IdentityOperator()) a2 = TensorProduct(IdentityOperator(), BosonOp("a")) a1, a2 a1 * psi psi1 = qapply(a1 * psi) psi1 psi2 = qapply(a2 * psi) psi2 qapply(Dagger(psi1) * psi2).doit() qapply(Dagger(psi2) * psi2).doit() e = TensorProduct(IdentityOperator(), BosonFockKet(1)) e qapply(Dagger(psi2) * e).doit() qapply(qapply(Dagger(psi2) * e) * TensorProduct(BosonFockKet(1), IdentityOperator())).doit() bra = TensorProduct(BosonFockBra(1),BosonFockBra(2)) ket = TensorProduct(BosonFockKet(1),BosonFockKet(2)) qapply(bra * ket).doit() e = qapply(qapply(TensorProduct(IdentityOperator(), BosonCoherentBra(2)) * TensorProduct(a, normal_ordered_form(Dagger(b)*b*Dagger(b)*b)) * TensorProduct(IdentityOperator(), BosonCoherentKet(2)))) e ket = TensorProduct(IdentityOperator(), BosonFockKet(2)) bra = Dagger(ket) qapply(qapply(bra * TensorProduct(a, normal_ordered_form(Dagger(b)*b*Dagger(b)*b)) * ket)).doit() #%install_ext http://raw.github.com/jrjohansson/version_information/master/version_information.py %reload_ext version_information %version_information sympy