|
1 | | -import numpy as np |
2 | | -import openmc |
3 | | -import pytest |
4 | | - |
5 | | - |
6 | | -@pytest.fixture |
7 | | -def empty_sphere(): |
8 | | - openmc.reset_auto_ids() |
9 | | - model = openmc.model.Model() |
10 | | - surf = openmc.Sphere(r=10, boundary_type = 'vacuum') |
11 | | - cell = openmc.Cell(region=-surf) |
12 | | - model.geometry = openmc.Geometry([cell]) |
13 | | - |
14 | | - model.settings.run_mode = 'fixed source' |
15 | | - model.settings.batches = 3 |
16 | | - model.settings.particles = 1000 |
17 | | - model.settings.source = openmc.IndependentSource(space=openmc.stats.Point()) |
18 | | - |
19 | | - tally = openmc.Tally() |
20 | | - tally.scores = ['total', elastic] |
21 | | - tally.nuclides = ['U235'] |
| 1 | +import numpy as np |
| 2 | +import openmc |
| 3 | +import pytest |
| 4 | + |
| 5 | + |
| 6 | +@pytest.fixture |
| 7 | +def empty_sphere(): |
| 8 | + openmc.reset_auto_ids() |
| 9 | + model = openmc.model.Model() |
| 10 | + surf = openmc.Sphere(r=10, boundary_type = 'vacuum') |
| 11 | + cell = openmc.Cell(region=-surf) |
| 12 | + model.geometry = openmc.Geometry([cell]) |
| 13 | + |
| 14 | + model.settings.run_mode = 'fixed source' |
| 15 | + model.settings.batches = 3 |
| 16 | + model.settings.particles = 1000 |
| 17 | + model.settings.source = openmc.IndependentSource(space=openmc.stats.Point()) |
| 18 | + |
| 19 | + tally = openmc.Tally() |
| 20 | + tally.scores = ['total', 'elastic'] |
| 21 | + tally.nuclides = ['U235'] |
22 | 22 | tally.multiply_density = False |
23 | | - model.tallies.append(tally) |
24 | | - |
25 | | - return model |
26 | | - |
27 | | -def test_equivalent_microxs(empty_sphere, run_in_tmpdir): |
28 | | - sp_file = empty_sphere.run() |
29 | | - with openmc.StatePoint(sp_file) as sp: |
30 | | - tally1 = sp.tallies[1] |
31 | | - |
32 | | - mat = openmc.Material() |
33 | | - mat.add_nuclide('H1', 1e-16) |
34 | | - |
35 | | - empty_sphere.geometry.get_all_cells()[1].fill = mat |
36 | | - empty_sphere.materials.append(mat) |
37 | | - |
38 | | - sp_file = empty_sphere.run() |
39 | | - with openmc.StatePoint(sp_file) as sp: |
40 | | - tally2 = sp.tallies[1] |
41 | | - |
| 23 | + model.tallies.append(tally) |
| 24 | + |
| 25 | + return model |
| 26 | + |
| 27 | +def test_equivalent_microxs(empty_sphere, run_in_tmpdir): |
| 28 | + sp_file = empty_sphere.run() |
| 29 | + with openmc.StatePoint(sp_file) as sp: |
| 30 | + tally1 = sp.tallies[1] |
| 31 | + |
| 32 | + mat = openmc.Material() |
| 33 | + mat.add_nuclide('H1', 1e-16) |
| 34 | + |
| 35 | + empty_sphere.geometry.get_all_cells()[1].fill = mat |
| 36 | + empty_sphere.materials.append(mat) |
| 37 | + |
| 38 | + sp_file = empty_sphere.run() |
| 39 | + with openmc.StatePoint(sp_file) as sp: |
| 40 | + tally2 = sp.tallies[1] |
| 41 | + |
42 | 42 | assert np.isclose(tally1.mean.sum(),tally2.mean.sum(), rtol=1e-10, atol=0) |
43 | 43 | assert tally1.mean.sum() > 0 |
0 commit comments