def test_xs_cache_set_E_g(): xs_cache.clear() # Add an energy stucture xs_cache['E_g'] = [10.0, 1.0] E_g = xs_cache['E_g'] # Assert that the cache is working assert_equal(E_g.shape, (2, )) assert_equal(id(E_g), id(xs_cache['E_g'])) # Assert that the cache has been reloaded xs_cache['E_g'] = [10.0, 2.0, 1.0] assert_not_equal(id(E_g), id(xs_cache['E_g'])) assert_equal(len(E_g), 2) assert_equal(len(xs_cache['E_g']), 3) # Assert that the partial energy matrix is calculated assert_equal(len(xs_cache['partial_energy_matrix']), 2) # Assert that the reloading is done properly xs_cache['has_some_g'] = True xs_cache['E_g'] = [10.0, 8.0, 2.0, 1.0] assert_equal(len(xs_cache['partial_energy_matrix']), 3) assert_true('has_some_g' not in xs_cache)
def test_xs_cache_get_phi_g(): xs_cache.clear() xs_cache['E_g'] = np.array([1E-11, 5.0, 10.0]) xs_cache['phi_g'] = [1.0, 1.0] phi_g = xs_cache['phi_g'] expected = np.array([1.0, 1.0]) assert_array_equal(phi_g, expected)
def test_xs_cache_get_phi_g(): xs_cache.clear() xs_cache['E_g'] = np.array([1E-8, 5.0, 10.0]) xs_cache['phi_g'] = [1.0, 1.0] phi_g = xs_cache['phi_g'] expected = np.array([1.0, 1.0]) assert_array_equal(phi_g, expected)
def test_xs_cache_sigma_f_n(): xs_cache.clear() with tb.openFile(nuc_data, 'r') as f: sigma_f_n_U235 = np.array(f.root.neutron.cinder_xs.fission[28]['xs']) from_cache = xs_cache[922350,'f'] assert_not_equal(id(sigma_f_n_U235), id(from_cache)) assert_equal(id(from_cache), id(xs_cache[922350,'f'])) assert_array_equal(sigma_f_n_U235, xs_cache[922350,'f'])
def test_xs_cache_sigma_a_n(): xs_cache.clear() with tb.openFile(nuc_data, 'r') as f: sigma_a_n_H1 = np.array(f.root.neutron.cinder_xs.absorption[0]['xs']) from_cache = xs_cache[10010, 'a'] assert_not_equal(id(sigma_a_n_H1), id(from_cache)) assert_equal(id(from_cache), id(xs_cache[10010, 'a'])) assert_array_equal(sigma_a_n_H1, xs_cache[10010, 'a'])
def test_xs_cache_sigma_f_n(): xs_cache.clear() with tb.openFile(nuc_data, 'r') as f: sigma_f_n_U235 = np.array(f.root.neutron.cinder_xs.fission[28]['xs']) from_cache = xs_cache[922350, 'f'] assert_not_equal(id(sigma_f_n_U235), id(from_cache)) assert_equal(id(from_cache), id(xs_cache[922350, 'f'])) assert_array_equal(sigma_f_n_U235, xs_cache[922350, 'f'])
def test_xs_cache_sigma_a_n(): xs_cache.clear() with tb.openFile(nuc_data, 'r') as f: sigma_a_n_H1 = np.array(f.root.neutron.cinder_xs.absorption[0]['xs']) from_cache = xs_cache[10010,'a'] assert_not_equal(id(sigma_a_n_H1), id(from_cache)) assert_equal(id(from_cache), id(xs_cache[10010, 'a'])) assert_array_equal(sigma_a_n_H1, xs_cache[10010, 'a'])
def test_xs_cache_E_n(): xs_cache.clear() with tb.openFile(nuc_data, 'r') as f: E_n = np.array(f.root.neutron.cinder_xs.E_g) from_cache = xs_cache['E_n'] assert_not_equal(id(E_n), id(from_cache)) assert_equal(id(from_cache), id(xs_cache['E_n'])) assert_array_equal(E_n, xs_cache['E_n'])
def test_xs_cache_sigma_a_n(): xs_cache.clear() if not cinderds.exists: return with tb.open_file(nuc_data, "r") as f: sigma_a_n_H1 = np.array(f.root.neutron.cinder_xs.absorption[0]["xs"]) from_cache = xs_cache[10010, "abs"] assert_not_equal(id(sigma_a_n_H1), id(from_cache)) assert_equal(id(from_cache), id(xs_cache[10010, "abs"])) assert_array_equal(sigma_a_n_H1, xs_cache[10010, "abs"])
def test_xs_cache_sigma_f_n(): xs_cache.clear() if not cinderds.exists: return with tb.open_file(nuc_data, "r") as f: sigma_f_n_U235 = np.array(f.root.neutron.cinder_xs.fission[28]["xs"]) from_cache = xs_cache[922350, "fiss"] assert_not_equal(id(sigma_f_n_U235), id(from_cache)) assert_equal(id(from_cache), id(xs_cache[922350, "fiss"])) assert_array_equal(sigma_f_n_U235, xs_cache[922350, "fiss"])
def test_xs_cache_set_phi_n(): xs_cache.clear() xs_cache['E_n'] = np.array([0.0, 5.0, 10.0]) xs_cache['E_g'] = np.array([0.0, 5.0, 10.0]) xs_cache['phi_n'] = [1.0, 10.0] assert_array_equal(xs_cache['phi_n'], np.array([1.0, 10.0])) # Test that resetting the flux cleans the cache properly phi_g = xs_cache['phi_g'] assert_true('phi_g' in xs_cache) xs_cache['phi_n'] = [1.0, 5.0] assert_true('E_g' in xs_cache) assert_true('phi_g' not in xs_cache)
def test_xs_cache_set_E_g(): xs_cache.clear() # Add an energy stucture xs_cache['E_g'] = [10.0, 1.0] E_g = xs_cache['E_g'] # Assert that the cache is working assert_equal(E_g.shape, (2, )) assert_equal(id(E_g), id(xs_cache['E_g'])) # Assert that the cache has been reloaded xs_cache['E_g'] = [10.0, 2.0, 1.0] assert_not_equal(id(E_g), id(xs_cache['E_g'])) assert_equal(len(E_g), 2) assert_equal(len(xs_cache['E_g']), 3) # Test auto-clearing xs_cache[10010, 'fiss'] assert_true((10010, 'fiss') in xs_cache) xs_cache['E_g'] = [10.0, 8.0, 2.0, 1.0] assert_true(xs_cache['phi_g'] is None) assert_false((10010, 'fiss') in xs_cache)
def test_xs_cache_set_E_g(): xs_cache.clear() # Add an energy stucture xs_cache['E_g'] = [10.0, 1.0] E_g = xs_cache['E_g'] # Assert that the cache is working assert_equal(E_g.shape, (2, )) assert_equal(id(E_g), id(xs_cache['E_g'])) # Assert that the cache has been reloaded xs_cache['E_g'] = [10.0, 2.0, 1.0] assert_not_equal(id(E_g), id(xs_cache['E_g'])) assert_equal(len(E_g), 2) assert_equal(len(xs_cache['E_g']), 3) # Test auto-clearing xs_cache[10010,'f'] assert_true((10010,'f') in xs_cache) xs_cache['E_g'] = [10.0, 8.0, 2.0, 1.0] assert_true(xs_cache['phi_g'] is None) assert_false((10010,'f') in xs_cache)
def setup(): np.seterr(all='ignore') xs_cache.clear()
def text_xs_get_reaction(): xs_cache.clear() assert_raises(KeyError, xs_cache[10010, 1089, 300])
def setup(): xs_cache.clear()
def setup(): np.seterr(all="ignore") xs_cache.clear()