
    Xh                     
   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZmZmZmZ dd	lmZ g d
Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )zBosonic quantum operators.    )Integer)S)	conjugate)exp)sqrt)Operator)HilbertSpace	FockSpaceKetBra)KroneckerDelta)BosonOpBosonFockKetBosonFockBraBosonCoherentKetBosonCoherentBrac                       e Zd ZdZed             Zed             Zed             Zd Z	d Z
d Zd Zd	 Zd
 Zd Zd ZdS )r   a  A 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                     | j         d         S Nr   )argsselfs    m/var/www/tools.fuzzalab.pt/emblema-extractor/venv/lib/python3.11/site-packages/sympy/physics/quantum/boson.pynamezBosonOp.name-   s    y|    c                 6    t          | j        d                   S N   )boolr   r   s    r   is_annihilationzBosonOp.is_annihilation1   s    DIaL!!!r   c                     dS )N)aT r   s    r   default_argszBosonOp.default_args5   s    {r   c                    t          |          dvrt          d|z            t          |          dk    r|d         t          j        f}t          |          dk    r|d         t	          |d                   f}t          j        | g|R  S )N)r      z"1 or 2 parameters expected, got %sr   r   r&   )len
ValueErrorr   Oner   r   __new__)clsr   hintss      r   r*   zBosonOp.__new__9   s    4yyF""ADHIIIt99>>GQU#Dt99>>GWT!W--.D+d++++r   c                     | j         |j         k    r| j        s|j        rt          j        S nd|v r|d         rt          j        S d S )Nindependent)r   r    r   NegativeOneZeror   otherr,   s      r   _eval_commutator_BosonOpz BosonOp._eval_commutator_BosonOpE   sP    9
""' %E,A %}$e##m(<#6Mtr   c                     t           j        S N)r   r0   r1   s      r   _eval_commutator_FermionOpz"BosonOp._eval_commutator_FermionOpQ   s	    vr   c                 .    d|v r|d         rd| z  |z  S d S )Nr.   r&   r#   r1   s      r   _eval_anticommutator_BosonOpz$BosonOp._eval_anticommutator_BosonOpT   s+    E!!eM&:!t8e##tr   c                 R    t          t          | j                  | j                   S r5   )r   strr   r    r   s    r   _eval_adjointzBosonOp._eval_adjoint[   s     s49~~4+?'?@@@r   c                 l    | j         rdt          | j                  z  S dt          | j                  z  S )Nz{%s}z{{%s}^\dagger}r    r:   r   r   printerr   s      r   _print_contents_latexzBosonOp._print_contents_latex^   s3     	6S^^++$s49~~55r   c                 l    | j         rdt          | j                  z  S dt          | j                  z  S )Nz%sz
Dagger(%s)r=   r>   s      r   _print_contentszBosonOp._print_contentsd   s3     	23ty>>)) 3ty>>11r   c                 n    ddl m}  |j        | j        d         g|R  }| j        r|S | |d          z  S )Nr   )
prettyFormu   †) sympy.printing.pretty.stringpictrD   _printr   r    )r   r?   r   rD   pforms        r   _print_contents_prettyzBosonOp._print_contents_prettyj   sX    ??????ty|3d333 	3L**\2222r   N)__name__
__module____qualname____doc__propertyr   r    classmethodr$   r*   r3   r6   r8   r;   r@   rB   rH   r#   r   r   r   r      s         ,   X " " X"   [
, 
, 
,
 
 
    A A A6 6 62 2 23 3 3 3 3r   r   c                   f    e Zd ZdZd Zed             Zed             Zed             Z	d Z
d ZdS )	r   zvFock state ket for a bosonic mode.

    Parameters
    ==========

    n : Number
        The Fock state number.

    c                 ,    t          j        | |          S r5   r   r*   r+   ns     r   r*   zBosonFockKet.__new__~       {3"""r   c                     | j         d         S r   labelr   s    r   rS   zBosonFockKet.n       z!}r   c                     t           S r5   )r   r   s    r   
dual_classzBosonFockKet.dual_class       r   c                     t                      S r5   r
   r+   rW   s     r   _eval_hilbert_spacez BosonFockKet._eval_hilbert_space       {{r   c                 6    t          | j        |j                  S r5   )r   rS   r   brar,   s      r   _eval_innerproduct_BosonFockBraz,BosonFockKet._eval_innerproduct_BosonFockBra   s    dfce,,,r   c                     |j         r,t          | j                  t          | j        dz
            z  S t          | j        dz             t          | j        dz             z  S r   )r    r   rS   r   r   opoptionss      r   _apply_from_right_to_BosonOpz)BosonFockKet._apply_from_right_to_BosonOp   sU     	?<<,tvz":":::
##l46A:&>&>>>r   N)rI   rJ   rK   rL   r*   rM   rS   rN   rZ   r_   rd   ri   r#   r   r   r   r   s   s         # # #   X   [   [- - -? ? ? ? ?r   r   c                   Z    e Zd ZdZd Zed             Zed             Zed             Z	dS )r   zvFock state bra for a bosonic mode.

    Parameters
    ==========

    n : Number
        The Fock state number.

    c                 ,    t          j        | |          S r5   r   r*   rR   s     r   r*   zBosonFockBra.__new__   rT   r   c                     | j         d         S r   rV   r   s    r   rS   zBosonFockBra.n   rX   r   c                     t           S r5   )r   r   s    r   rZ   zBosonFockBra.dual_class   r[   r   c                     t                      S r5   r]   r^   s     r   r_   z BosonFockBra._eval_hilbert_space   r`   r   N)
rI   rJ   rK   rL   r*   rM   rS   rN   rZ   r_   r#   r   r   r   r      s~         # # #   X   [   [  r   r   c                   f    e Zd ZdZd Zed             Zed             Zed             Z	d Z
d ZdS )	r   zCoherent state ket for a bosonic mode.

    Parameters
    ==========

    alpha : Number, Symbol
        The complex amplitude of the coherent state.

    c                 ,    t          j        | |          S r5   rQ   r+   alphas     r   r*   zBosonCoherentKet.__new__       {3&&&r   c                     | j         d         S r   rV   r   s    r   rs   zBosonCoherentKet.alpha   rX   r   c                     t           S r5   )r   r   s    r   rZ   zBosonCoherentKet.dual_class       r   c                     t                      S r5   )r	   r^   s     r   r_   z$BosonCoherentKet._eval_hilbert_space   s    ~~r   c                     | j         |j         k    rt          j        S t          t	          | j                   dz  t	          |j                   dz  z   dt          |j                   z  | j         z  z
   dz            S )Nr&   )rs   r   r)   r   absr   rb   s      r   #_eval_innerproduct_BosonCoherentBraz4BosonCoherentKet._eval_innerproduct_BosonCoherentBra   sm    :""5LTZ!+c#)nna.??!iPSPYFZFZBZ]a]gBgghijjkkkr   c                 (    |j         r
| j        | z  S d S r5   r    rs   rf   s      r   ri   z-BosonCoherentKet._apply_from_right_to_BosonOp   s     	:$$4r   N)rI   rJ   rK   rL   r*   rM   rs   rN   rZ   r_   r{   ri   r#   r   r   r   r      s         ' ' '   X     [    [l l l    r   r   c                   J    e Zd ZdZd Zed             Zed             Zd Z	dS )r   zCoherent state bra for a bosonic mode.

    Parameters
    ==========

    alpha : Number, Symbol
        The complex amplitude of the coherent state.

    c                 ,    t          j        | |          S r5   rl   rr   s     r   r*   zBosonCoherentBra.__new__   rt   r   c                     | j         d         S r   rV   r   s    r   rs   zBosonCoherentBra.alpha   rX   r   c                     t           S r5   )r   r   s    r   rZ   zBosonCoherentBra.dual_class   rw   r   c                 (    |j         s
| j        | z  S d S r5   r}   rf   s      r   _apply_operator_BosonOpz(BosonCoherentBra._apply_operator_BosonOp   s    ! 	:$$4r   N)
rI   rJ   rK   rL   r*   rM   rs   rN   rZ   r   r#   r   r   r   r      sr         ' ' '   X     [     r   r   N)rL   sympy.core.numbersr   sympy.core.singletonr   $sympy.functions.elementary.complexesr   &sympy.functions.elementary.exponentialr   (sympy.functions.elementary.miscellaneousr   sympy.physics.quantumr   r	   r
   r   r   (sympy.functions.special.tensor_functionsr   __all__r   r   r   r   r   r#   r   r   <module>r      s       & & & & & & " " " " " " : : : : : : 6 6 6 6 6 6 9 9 9 9 9 9 * * * * * * C C C C C C C C C C C C C C C C C C  Z3 Z3 Z3 Z3 Z3h Z3 Z3 Z3z!? !? !? !? !?3 !? !? !?H    3   6$ $ $ $ $s $ $ $N    s     r   