def m_degeneracy(N, m): """Calculate the number of Dicke states |j, m> with same energy. Parameters ---------- N: int The number of two-level systems. m: float Total spin z-axis projection eigenvalue (proportional to the total energy). Returns ------- degeneracy: int The m-degeneracy. """ jvals = j_vals(N) maxj = np.max(jvals) if m < -maxj: e = "m value is incorrect for this N." e += " Minimum m value can be {}".format(-maxj) raise ValueError(e) degeneracy = N / 2 + 1 - abs(m) return int(degeneracy)
def m_degeneracy(N, m): """Calculate the number of Dicke states :math:`|j, m\\rangle` with same energy. Parameters ---------- N: int The number of two-level systems. m: float Total spin z-axis projection eigenvalue (proportional to the total energy). Returns ------- degeneracy: int The m-degeneracy. """ jvals = j_vals(N) maxj = np.max(jvals) if m < -maxj: e = "m value is incorrect for this N." e += " Minimum m value can be {}".format(-maxj) raise ValueError(e) degeneracy = N/2 + 1 - abs(m) return int(degeneracy)
def test_j_vals(self): """ PIQS: Test calculation of j values for given N. """ N_list = [1, 2, 3, 4, 7] j_vals_real = [np.array([0.5]), np.array([0., 1.]), np.array([0.5, 1.5]), np.array([0., 1., 2.]), np.array([0.5, 1.5, 2.5, 3.5])] j_vals_calc = [j_vals(i) for i in N_list] for (i, j) in zip(j_vals_calc, j_vals_real): assert_array_equal(i, j)
def test_j_vals(self): """ PIQS: Test calculation of j values for given N. """ N_list = [1, 2, 3, 4, 7] j_vals_real = [np.array([0.5]), np.array([0., 1.]), np.array([0.5, 1.5]), np.array([0., 1., 2.]), np.array([0.5, 1.5, 2.5, 3.5])] j_vals_calc = [j_vals(i) for i in N_list] for (i, j) in zip(j_vals_calc, j_vals_real): assert_array_equal(i, j)