def __init__(self): self._cache = {} self._get_fns = {'E_n': get_E_n, 'sigma_f_n': get_sigma_f_n, 'sigma_a_n': get_sigma_a_n, 'sigma_rx_n': get_sigma_a_reaction_n, 'phi_g': lambda: phi_g(self['E_g'], self['E_n'], self['phi_n']), }
def test_phi_g2(): E_g = np.array([0.0, 5.0, 10.0]) E_n = np.array([0.0, 5.0, 10.0]) phi_n = np.ones(2) observed = phi_g(E_g, E_n, phi_n) expected = np.array([1.0, 1.0]) assert_array_equal(observed, expected)
def test_phi_g5(): E_g = np.array([0.0, 4.0, 10.0]) E_n = np.array([0.0, 2.5, 5.0, 7.5, 10.0]) phi_n = np.ones(4) observed = phi_g(E_g, E_n, phi_n) expected = np.array([1.6, 2.4]) assert_array_equal(observed, expected)
def test_phi_g7(): E_g = np.array([0.0, 4.0, 8.0]) E_n = np.array([0.0, 2.5, 5.0, 7.5, 10.0]) phi_n = np.array([0.0, 2.0, 1.0, 0.5]) observed = phi_g(E_g, E_n, phi_n) expected = np.array([1.2, 1.9]) # Floating point error here requires 'alomst' equal assert_array_almost_equal(observed, expected)
def test_phi_g6(): E_g = np.array([0.0, 4.0, 8.0]) E_n = np.array([0.0, 2.5, 5.0, 7.5, 10.0]) phi_n = np.ones(4) observed = phi_g(E_g, E_n, phi_n) expected = np.array([1.6, 1.6]) # Floating point error here requires 'alomst' equal assert_array_almost_equal(phi_g, expected)
def test_group_collapse1(): E_g = np.array([0.0, 4.0, 8.0]) E_n = np.array([0.0, 2.5, 5.0, 7.5, 10.0]) phi_n = np.array([0.0, 2.0, 1.0, 0.5]) sigma_n = np.array([1.0, 2.0, 3.0, 4.0]) expected = np.array([2.0, 5.0 / 1.9]) # First way of calling observed = group_collapse(sigma_n, phi_n, E_g=E_g, E_n=E_n) assert_array_almost_equal(observed, expected) # Second method of calling p_g = phi_g(E_g, E_n, phi_n) pem = partial_energy_matrix(E_g, E_n) observed = group_collapse(sigma_n, phi_n, phi_g=p_g, partial_energies=pem) assert_array_almost_equal(observed, expected) # bad call assert_raises(ValueError, group_collapse, sigma_n, phi_n)