|
| 1 | +import openmc |
| 2 | + |
| 3 | + |
| 4 | +def test_periodic_surface_roundtrip(run_in_tmpdir): |
| 5 | + # Create a simple model with periodic surfaces |
| 6 | + mat = openmc.Material() |
| 7 | + mat.add_nuclide('H1', 1.0) |
| 8 | + mat.set_density('g/cm3', 1.0) |
| 9 | + cyl = openmc.ZCylinder(r=1.0) |
| 10 | + x0 = openmc.XPlane(-5.0, boundary_type='periodic') |
| 11 | + y0 = openmc.YPlane(-5.0, boundary_type='periodic') |
| 12 | + z0 = openmc.ZPlane(-5.0, boundary_type='periodic') |
| 13 | + x1 = openmc.XPlane(5.0, boundary_type='periodic') |
| 14 | + y1 = openmc.YPlane(5.0, boundary_type='periodic') |
| 15 | + z1 = openmc.ZPlane(5.0, boundary_type='periodic') |
| 16 | + x0.periodic_surface = x1 |
| 17 | + y0.periodic_surface = y1 |
| 18 | + z0.periodic_surface = z1 |
| 19 | + cell1 = openmc.Cell(fill=mat, region=-cyl) |
| 20 | + cell2 = openmc.Cell(fill=mat, region=+cyl & +x0 & -x1 & +y0 & -y1 & +z0 & -z1) |
| 21 | + model = openmc.Model() |
| 22 | + model.geometry = openmc.Geometry([cell1, cell2]) |
| 23 | + model.settings.particles = 100 |
| 24 | + model.settings.batches = 1 |
| 25 | + model.settings.run_mode = 'fixed source' |
| 26 | + model.settings.source = openmc.IndependentSource( |
| 27 | + energy=openmc.stats.delta_function(1.0e4) |
| 28 | + ) |
| 29 | + |
| 30 | + # Run model |
| 31 | + model.run() |
| 32 | + |
| 33 | + # Load summary data and check periodic surfaces |
| 34 | + summary = openmc.Summary('summary.h5') |
| 35 | + surfs = summary.geometry.get_all_surfaces() |
| 36 | + for s in [x0, y0, z0, x1, y1, z1]: |
| 37 | + assert surfs[s.id].boundary_type == 'periodic' |
| 38 | + pairs = [(x0, x1), (y0, y1), (z0, z1)] |
| 39 | + for s0, s1 in pairs: |
| 40 | + assert surfs[s0.id].periodic_surface == surfs[s1.id] |
| 41 | + assert surfs[s1.id].periodic_surface == surfs[s0.id] |
0 commit comments