# Quantum Angular Momentum

This file will show how to use the various objects and methods in the `sympy.physics.quantum.spin` module, with some examples. Much of the work in this module is based off Varschalovich "Quantum Theory of Angular Momentum".

## Imports


```python
from IPython.display import display
```


```python
from sympy import init_printing
init_printing(use_latex=True)
```


```python
from sympy import factor, pi, S, Sum, symbols
from sympy.physics.quantum.spin import (
    Jminus, Jx, Jz, J2, J2Op, JzKet, JzKetCoupled, Rotation, WignerD, couple, uncouple
)
from sympy.physics.quantum import (
    Dagger, hbar, qapply, represent, TensorProduct
)
```

## Basic spin states and operators

We can define simple spin states and operators and manipulate them with standard quantum machinery.

Define a spin ket:


```python
jz = JzKet(1,1)
jz
```

Find the vector representation of the state:


```python
represent(jz)
```

Create and evaluate an innerproduct of a bra and a ket:


```python
ip = Dagger(jz)*jz
ip
```


```python
ip.doit()
```

Apply an angular momentum operator to the state:


```python
Jz*jz
```


```python
qapply(Jz*jz)
```


```python
Jminus*jz
```


```python
qapply(Jminus*jz)
```

We can also do this for symbolic angular momentum states:


```python
j, m = symbols('j m')
jz = JzKet(j, m); jz
```


```python
J2*jz
```


```python
qapply(J2*jz)
```

Find the matrix representation of a angular momentum operator:


```python
represent(Jz, j=1)
```

## Utilizing different bases

Angular momentum states and operators can be transformed between different spin bases. We can rewrite states as states in another basis:


```python
jz = JzKet(1, 1)
jz.rewrite("Jx")
```

Vector representation can also be done into different bases:


```python
represent(jz, basis=Jx)
```

When applying operators in another spin basis, any conversion necessary to apply the state is done, then the states are given back in the original basis. So in the following example, the state returned by `qapply` are in the $J_z$ basis:


```python
Jx*jz
```


```python
qapply(Jx*jz)
```

Rewriting states and applying operators between bases can also be done symbolically. In this case, the result is given in terms of Wigner-D matrix elements (see the next section for more information on the `Rotation` operator).


```python
jz = JzKet(j, m)
jz.rewrite("Jx")
```

## Rotation operator

Arbitrary rotations of spin states, written in terms of Euler angles, can be modeled using the rotation operator. These methods are utilized to go between spin bases, as seen in the section above.

Define an arbitrary rotation operator. The given angles are Euler angles in the `z-y-z` convention.


```python
a, b, g = symbols('alpha beta gamma')
Rotation(a, b, g)
```

Find the Wigner-D matrix elements of the rotation operator as given by $\langle j, m'|\mathcal{R}(\alpha, \beta, \gamma)|j,m\rangle$:


```python
mp = symbols('mp')
r = Rotation.D(j, m, mp, a, b, g)
r
```

Numerical matrix elements can be evaluated using the `.doit()` method:


```python
r = Rotation.D(1, 1, 0, pi, pi/2, 0)
r
```


```python
r.doit()
```

The Wigner small-d matrix elements give rotations when $\alpha=\gamma=0$. These matrix elements can be found in the same manner as above:


```python
r = Rotation.d(j, m, mp, b)
r
```


```python
r = Rotation.d(1, 1, 0, pi/2)
r
```


```python
r.doit()
```

You can also directly create a Wigner-D matrix element:


```python
WignerD(j, m, mp, a, b, g)
```

## Coupled and uncoupled states and operators

States and operators can also written in terms of coupled or uncoupled angular momentum spaces.

### Coupled states and operators

Define a simple coupled state of two $j=1$ spin states:


```python
jzc = JzKetCoupled(1, 0, (1, 1)); jzc
```

Note that the Hilbert space of coupled states is the direct sum of the coupled spin spaces. This can be seen in the matrix representation of coupled states:


```python
jzc.hilbert_space
```


```python
represent(jzc)
```

We can also couple more than two spaces together. See the `JzKetCoupled` documentation for more complex coupling schemes involving more than 2 spaces.


```python
jzc = JzKetCoupled(1, 1, (S(1)/2, S(1)/2, 1))
jzc
```

The normal operators are assumed to be diagonal in the corresponding coupled basis:


```python
qapply(Jz*jzc)
```

### Uncoupled states and operators

Uncoupled states are defined as tensor products of states:


```python
jzu = TensorProduct(JzKet(1, 1), JzKet(S(1)/2, -S(1)/2)); jzu
```

Vector representation of tensor product states gives the vector in the direct product space:


```python
represent(jzu)
```

Uncoupled operators are also defined as tensor products:


```python
jzopu = TensorProduct(Jz, 1)
jzopu
```


```python
qapply(jzopu*jzu)
```

Coupled operators which are diagonalized by uncoupled states (e.g. $J_z$ and uncoupled $J_z$ eigenstates) can also be applied:


```python
qapply(Jz*jzu)
```

Rewriting states works as before:


```python
jzu.rewrite("Jx")
```

### Coulping and Uncoupling States

The `couple` method will couple an uncoupled state:


```python
jzu = TensorProduct(JzKet(1, 1), JzKet(S(1)/2, -S(1)/2))
couple(jzu)
```

Similarly, the uncouple method will uncouple a coupled state:


```python
jzc = JzKetCoupled(2, 1, (1, S(1)/2, S(1)/2))
uncouple(jzc)
```

Uncoupling can also be done with the `.rewrite` method:


```python
jzc.rewrite("Jz", coupled=False)
```

The `uncouple` method can also uncouple normal states if given a set of spin bases to consider:


```python
jz = JzKet(2, 1)
uncouple(jz, (1, S(1)/2, S(1)/2))
```

8cb1a7c474049b0d6874c9a158b16eeada99150d
ipynb
Jupyter Notebook
notebooks/angular_momentum.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-17T22:44:27.000Z
2022-03-28T06:26:46.000Z
notebooks/angular_momentum.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-09T05:16:41.000Z
2018-09-22T03:08:29.000Z
notebooks/angular_momentum.ipynb
gvvynplaine/quantum_notebooks
58783823596465fe2d6c494c2cc3a53ae69a9752
BSD-3-Clause
2017-10-09T04:22:19.000Z
2022-03-28T06:25:21.000Z
Qwen/Qwen-72B
1. YES
2. YES