K idZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl m Z mZmZmZdd lmZgd ZGd d e ZGd deZGddeZGddeZGddeZy)zBosonic quantum operators.)Integer)S) conjugate)exp)sqrt)Operator) HilbertSpace FockSpaceKetBra)KroneckerDelta)BosonOp BosonFockKet BosonFockBraBosonCoherentKetBosonCoherentBracpeZdZdZedZedZedZdZ dZ dZ dZ d Z d Zd Zd Zy )raA bosonic operator that satisfies [a, Dagger(a)] == 1. Parameters ========== name : str A string that labels the bosonic mode. annihilation : bool A bool that indicates if the bosonic operator is an annihilation (True, default value) or creation operator (False) Examples ======== >>> from sympy.physics.quantum import Dagger, Commutator >>> from sympy.physics.quantum.boson import BosonOp >>> a = BosonOp("a") >>> Commutator(a, Dagger(a)).doit() 1 c |jdSNr)argsselfs a/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/physics/quantum/boson.pynamez BosonOp.name-syy|c2t|jdSN)boolrrs ris_annihilationzBosonOp.is_annihilation1sDIIaL!!rcy)N)aTrs r default_argszBosonOp.default_args5srct|dvrtd|zt|dk(r|dtjf}t|dk(r|dt |df}t j |g|S)N)rz"1 or 2 parameters expected, got %srrr&)len ValueErrorrOnerr__new__)clsrhintss rr*zBosonOp.__new__9st4yF"ADHI I t9>GQUU#D t9>GWT!W-.D+d++rc |j|jk(r)|js|jrtjSyd|vr|drtjSy)N independent)rr r NegativeOneZerorotherr,s r_eval_commutator_BosonOpz BosonOp._eval_commutator_BosonOpEsO 99 "''E,A,A}}$  e #m(<66Mrc "tjSN)rr0r1s r_eval_commutator_FermionOpz"BosonOp._eval_commutator_FermionOpQs vv rc &d|vr |drd|z|zSy)Nr.r&r#r1s r_eval_anticommutator_BosonOpz$BosonOp._eval_anticommutator_BosonOpTs# E !eM&:t8e# #rcVtt|j|j Sr5)rstrrr rs r _eval_adjointzBosonOp._eval_adjoint[s s499~4+?+?'?@@rcz|jrdt|jzSdt|jzS)Nz{%s}z{{%s}^\dagger}r r:rrprinterrs r_print_contents_latexzBosonOp._print_contents_latex^s1   S^+ +$s499~5 5rcz|jrdt|jzSdt|jzS)Nz%sz Dagger(%s)r=r>s r_print_contentszBosonOp._print_contentsds1   3tyy>) ) 3tyy>1 1rcddlm}|j|jdg|}|jr|S||dzS)Nr) prettyFormu†) sympy.printing.pretty.stringpictrD_printrr )rr?rrDpforms r_print_contents_prettyzBosonOp._print_contents_prettyjs@?tyy|3d3   L*\22 2rN)__name__ __module__ __qualname____doc__propertyrr classmethodr$r*r3r6r8r;r@rBrHr#rrrrsl,"" , A6 2 3rrcReZdZdZdZedZedZedZ dZ dZ y) rzvFock state ket for a bosonic mode. Parameters ========== n : Number The Fock state number. c.tj||Sr5r r*r+ns rr*zBosonFockKet.__new__~{{3""rc |jdSrlabelrs rrSzBosonFockKet.nzz!}rctSr5)rrs r dual_classzBosonFockKet.dual_classrctSr5r r+rWs r_eval_hilbert_spacez BosonFockKet._eval_hilbert_space {rc Bt|j|jSr5)r rSrbrar,s r_eval_innerproduct_BosonFockBraz,BosonFockKet._eval_innerproduct_BosonFockBrasdffcee,,rc |jr.t|jt|jdz zSt|jdzt|jdzzSr)r rrSrropoptionss r_apply_from_right_to_BosonOpz)BosonFockKet._apply_from_right_to_BosonOpsP  <,tvvz":: : #l466A:&>> >rN) rIrJrKrLr*rMrSrNrZr_rdrir#rrrrssR#-?rrcFeZdZdZdZedZedZedZ y)rzvFock state bra for a bosonic mode. Parameters ========== n : Number The Fock state number. c.tj||Sr5r r*rRs rr*zBosonFockBra.__new__rTrc |jdSrrVrs rrSzBosonFockBra.nrXrctSr5)rrs rrZzBosonFockBra.dual_classr[rctSr5r]r^s rr_z BosonFockBra._eval_hilbert_spacer`rN) rIrJrKrLr*rMrSrNrZr_r#rrrrsH#rrcReZdZdZdZedZedZedZ dZ dZ y) rzCoherent state ket for a bosonic mode. Parameters ========== alpha : Number, Symbol The complex amplitude of the coherent state. c.tj||Sr5rQr+alphas rr*zBosonCoherentKet.__new__{{3&&rc |jdSrrVrs rrszBosonCoherentKet.alpharXrctSr5)rrs rrZzBosonCoherentKet.dual_classrctSr5)r r^s rr_z$BosonCoherentKet._eval_hilbert_spaces ~rc |j|jk(rtjStt |jdzt |jdzzdt |jz|jzz dz S)Nr&)rsrr)rabsrrbs r#_eval_innerproduct_BosonCoherentBraz4BosonCoherentKet._eval_innerproduct_BosonCoherentBrasp :: "55LTZZ!+c#))na.??!iPSPYPYFZBZ]a]g]gBgghijjk krc :|jr|j|zSyr5r rsrfs rriz-BosonCoherentKet._apply_from_right_to_BosonOps  ::$ $rN) rIrJrKrLr*rMrsrNrZr_r{rir#rrrrsS'  l rrc<eZdZdZdZedZedZdZ y)rzCoherent state bra for a bosonic mode. Parameters ========== alpha : Number, Symbol The complex amplitude of the coherent state. c.tj||Sr5rlrrs rr*zBosonCoherentBra.__new__rtrc |jdSrrVrs rrszBosonCoherentBra.alpharXrctSr5)rrs rrZzBosonCoherentBra.dual_classrwrc :|js|j|zSyr5r}rfs r_apply_operator_BosonOpz(BosonCoherentBra._apply_operator_BosonOps!!::$ $rN) rIrJrKrLr*rMrsrNrZrr#rrrrs9'  rrN)rLsympy.core.numbersrsympy.core.singletonr$sympy.functions.elementary.complexesr&sympy.functions.elementary.exponentialr(sympy.functions.elementary.miscellaneousrsympy.physics.quantumrr r r r (sympy.functions.special.tensor_functionsr __all__rrrrrr#rrrsk &":69*CCC Z3hZ3z!?3!?H36$s$Nsr