Пример #1
0
def ang_mom_lowering(ang_mom=None, mag=None):
    """
    Args:    
        ang_mom: The total angular momentum quantum number
        mag: The magnetic quantum number
    
    Returns:    
        If ang_mom == None and mag== None, the general formula for the lowering operator for spherical harmonics is returned.    
        Else, the formula for the lowering operator is computed using Dirac notation
    
    Note:
        Bra(str(j), str(","), str(m))*h_b*sqrt(j*(j+1)-m*(m-1))*Ket(str(j), str(','), str(m-1))
    
    """

    L_x, L_y = symbols("L_x L_y")
    if ang_mom == None and mag == None:
        return Operator(L_x) - I * Operator(L_y)
    if ang_mom == j and mag == m:
        return Bra(str(j), str(","),
                   str(m)) * h_b * sqrt(j * (j + 1) - m * (m - 1)) * Ket(
                       str(j), str(','), str(m - 1))
    if (str(ang_mom), str(","), str(mag)) == (str(ang_mom), str(','),
                                              str(mag - 1)):
        return h_b * sqrt(ang_mom * (ang_mom + 1) - mag * (mag - 1))
    else:
        return 0
Пример #2
0
 def get_matrix_product_form(self):
     self.ket_row = Matrix([Ket(s)
                            for s in self.state_components]).transpose()
     self.bra_col = Matrix([Bra(s) for s in self.state_components])
     self.form = UnevaluatedExpr(self.ket_row) * UnevaluatedExpr(
         self.symmetrized_mat) * UnevaluatedExpr(self.bra_col)
     return self.form
Пример #3
0
def ang_mom_raising(ang_mom=None, mag=None):
    """
    Args:    
        ang_mom: The total angular momentum quantum number
        mag: The magnetic quantum number
    
    Returns:    
        If ang_mom == None and mag == None, the general formula for the raising operator for spherical harmonics is returned.    
        Else, the formula for the raising operator is computed using Dirac notation
    
    Note:
        Bra(str(j), str(","), str(m))*h_b*sqrt(j*(j+1)-m*(m+1))*Ket(str(j), str(','), str(m+1))

        .. math::
          \\langle j, m | \\hbar \\sqrt{ j (j+1) - m (m+1) }  | j, m+1 \\rangle
        
    """

    L_x, L_y, j, m = symbols("L_x L_y j m")
    if ang_mom == None and mag == None:
        return Operator(L_x) + I * Operator(L_y)
    if ang_mom == j and mag == m:
        return Bra(str(j), str(","),
                   str(m)) * h_b * sqrt(j * (j + 1) - m * (m + 1)) * Ket(
                       str(j), str(','), str(m + 1))
    if (str(ang_mom), str(","), str(mag)) == (str(ang_mom), str(','),
                                              str(mag + 1)):
        return h_b * sqrt(ang_mom * (ang_mom + 1) - mag * (mag + 1))
    else:
        return 0
Пример #4
0
def simplify_ladder(expr):
    """
    
    Args:
        expr: the expression of interest
    
    Returns:
        The simplified expression, replacing any a_rasing(symbol)**2 with 0, a_lowering(symbol)**2 with 0, and 
        2*a_raising(symbol)*a_lowering(symbol) with (2*n+1). 
    
    Note:
        The code does not "understand" the difference between a_raising(symbol)*a_lowering(symbol) and a_lowering(symbol)*a_raising(symbol) 
        which are mathematically different and produce different outcomes.
    
    """
    symbol, n = symbols("symbol n")
    return Bra(n) * (simplify(expand(simplify(expand(expr)))).replace(
        (2 * a_raising(symbol) * a_lowering(symbol)),
        (2 * n + 1)).replace(a_raising(symbol)**2, 0).replace(
            a_lowering(symbol)**2, 0)) * Ket(n)
Пример #5
0
def a_lowering(A=None):
    """    
    Args:
        A: this is usually either empty, (no parameter), "normalized" for the normalized ladder operator,
        or a "symbol" for the symbolic representation of the parameter.
    
    Returns:    
        Either the mathematic representation of the "a" lowering operator (commonly used in harmonic oscillator problems),
        the normalized lowering operator (in dirac notation), or the symbol notation of the operator.
    
    """

    m, omega, p, x, a_L, normalized, n, symbol = symbols(
        "m omega p x a_- normalized n symbol")
    if A == None:
        return (1 / sqrt(2 * h_b * m * omega) * (I * p + m * omega * x))
    if A == normalized:
        return Bra(n) * sqrt(n) * Ket(n - 1)
    if A == symbol:
        return a_L
Пример #6
0
def ang_mom_2(ang_mom, mag):
    """
    Args:    
        ang_mom: The total angular momentum quantum number
        mag: The magnetic quantum number
    
    Returns:    
        The L^2 vector magnitude eigenvalue for spherical harmonics.
    
    Note:
        Bra(str(j), str(","), str(m))*j*(j+1)*h_b**2*Ket(str(j), str(","), str(m))
    
    """

    j, m = symbols("j, m")
    if ang_mom == j and mag == m:
        return Bra(str(j), str(","), str(m)) * j * (j + 1) * h_b**2 * Ket(
            str(j), str(","), str(m))
    if (str(ang_mom), str(","), str(mag)) == (str(ang_mom), str(","),
                                              str(mag)):
        return ang_mom * (ang_mom + 1) * h_b**2
    else:
        return 0
Пример #7
0
def ang_mom_z(ang_mom, mag):
    """
    Args:    
        ang_mom: The total angular momentum quantum number
        mag: The magnetic quantum number
    
    Returns:    
        The L_z projection (in the z direction) eigenvalue for spherical harmonics.
    
    Note:
        Bra(str(j), str(","), str(m))*m*h_b*Ket(str(j), str(","), str(m))
    
    """

    j, m = symbols("j, m")
    if ang_mom == j and mag == m:
        return Bra(str(j), str(","), str(m)) * m * h_b * Ket(
            str(j), str(","), str(m))
    if (str(ang_mom), str(","), str(mag)) == (str(ang_mom), str(","),
                                              str(mag)):
        return mag * h_b
    else:
        return 0
Пример #8
0
def test_sympy__physics__quantum__state__Bra():
    from sympy.physics.quantum.state import Bra
    assert _test_args(Bra(0))
Пример #9
0
def test_sympy__physics__quantum__operator__OuterProduct():
    from sympy.physics.quantum.operator import OuterProduct
    from sympy.physics.quantum import Ket, Bra
    b = Bra('b')
    k = Ket('k')
    assert _test_args(OuterProduct(k, b))
Пример #10
0
def test_sympy__physics__quantum__innerproduct__InnerProduct():
    from sympy.physics.quantum import Bra, Ket, InnerProduct
    b = Bra('b')
    k = Ket('k')
    assert _test_args(InnerProduct(b, k))
Пример #11
0
 def __new__(cls, alpha):
     return Bra.__new__(cls, alpha)
Пример #12
0
 def __new__(cls, n):
     return Bra.__new__(cls, n)
Пример #13
0
 def __new__(cls, alpha):
     return Bra.__new__(cls, alpha)
Пример #14
0
 def __new__(cls, n):
     return Bra.__new__(cls, n)
Пример #15
0
 def __new__(cls, n):
     if n not in [0, 1]:
         raise ValueError("n must be 0 or 1")
     return Bra.__new__(cls, n)
Пример #16
0
 def __new__(cls, n):
     if n not in [0, 1]:
         raise ValueError("n must be 0 or 1")
     return Bra.__new__(cls, n)