Add rotated lattice test

This commit is contained in:
Paul Romano 2019-05-15 11:30:19 -05:00
parent 3274c25969
commit 4cc90ad589
4 changed files with 158 additions and 0 deletions

View file

@ -0,0 +1,71 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="1" material="1" region="-1" universe="1" />
<cell id="2" material="3" region="1" universe="1" />
<cell id="3" material="2" region="-2" universe="2" />
<cell id="4" material="3" region="2" universe="2" />
<cell id="5" material="3" universe="30" />
<cell fill="4" id="6" region="-3" rotation="0.0 0.0 45.0" translation="-4.0 0.0 0.0" universe="5" />
<cell fill="3" id="7" region="-4" rotation="0.0 0.0 30.0" translation="4.0 0.0 0.0" universe="5" />
<cell id="8" material="3" region="-5 3 4" universe="5" />
<hex_lattice id="3" n_rings="3">
<pitch>1.25</pitch>
<outer>30</outer>
<center>0.0 0.0</center>
<universes>
2
1 1
1 2 1
1 1
1 2 1
1 1
1 1 1
1 1
1</universes>
</hex_lattice>
<lattice id="4">
<pitch>1.25 1.25</pitch>
<outer>30</outer>
<dimension>4 4</dimension>
<lower_left>-2.5 -2.5</lower_left>
<universes>
2 2 2 2
1 1 1 1
1 1 1 1
1 1 1 1 </universes>
</lattice>
<surface coeffs="0.0 0.0 0.25" id="1" type="z-cylinder" />
<surface coeffs="0.0 0.0 0.5" id="2" type="z-cylinder" />
<surface coeffs="-4.0 0.0 4.0" id="3" type="z-cylinder" />
<surface coeffs="4.0 0.0 4.0" id="4" type="z-cylinder" />
<surface boundary="vacuum" coeffs="0.0 0.0 8.0" id="5" type="z-cylinder" />
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material depletable="true" id="1">
<density units="g/cm3" value="10.0" />
<nuclide ao="1.0" name="U235" />
</material>
<material depletable="true" id="2">
<density units="g/cm3" value="10.0" />
<nuclide ao="1.0" name="U238" />
</material>
<material id="3">
<density units="g/cm3" value="1.0" />
<nuclide ao="2.0" name="H1" />
<nuclide ao="1.0" name="O16" />
<sab name="c_H_in_H2O" />
</material>
</materials>
<?xml version='1.0' encoding='utf-8'?>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>1000</particles>
<batches>5</batches>
<inactive>0</inactive>
<source strength="1.0">
<space type="point">
<parameters>0.0 0.0 0.0</parameters>
</space>
</source>
</settings>

View file

@ -0,0 +1,2 @@
k-combined:
4.538090E-01 2.452457E-02

View file

@ -0,0 +1,85 @@
import numpy as np
import openmc
from tests.testing_harness import PyAPITestHarness
def rotated_lattice_model():
model = openmc.model.Model()
# Create some materials
fuel1 = openmc.Material()
fuel1.set_density('g/cm3', 10.0)
fuel1.add_nuclide('U235', 1.0)
fuel2 = openmc.Material()
fuel2.set_density('g/cm3', 10.0)
fuel2.add_nuclide('U238', 1.0)
water = openmc.Material()
water.set_density('g/cm3', 1.0)
water.add_nuclide('H1', 2.0)
water.add_nuclide('O16', 1.0)
water.add_s_alpha_beta('c_H_in_H2O')
model.materials.extend([fuel1, fuel2, water])
# Create universes for lattices
r_pin = openmc.ZCylinder(r=0.25)
fuel_cell = openmc.Cell(fill=fuel1, region=-r_pin)
water_cell = openmc.Cell(fill=water, region=+r_pin)
pin_universe = openmc.Universe(cells=(fuel_cell, water_cell))
r_big_pin = openmc.ZCylinder(r=0.5)
fuel2_cell = openmc.Cell(fill=fuel2, region=-r_big_pin)
water2_cell = openmc.Cell(fill=water, region=+r_big_pin)
big_pin_universe = openmc.Universe(cells=(fuel2_cell, water2_cell))
all_water_cell = openmc.Cell(fill=water)
outer_universe = openmc.Universe(30, cells=(all_water_cell,))
# Create hexagonal lattice
pitch = 1.25
hexlat = openmc.HexLattice()
hexlat.center = (0., 0.)
hexlat.pitch = [pitch]
hexlat.outer = outer_universe
outer_ring = [big_pin_universe] + [pin_universe]*11
middle_ring = [big_pin_universe] + [pin_universe]*5
inner_ring = [big_pin_universe]
hexlat.universes = [outer_ring, middle_ring, inner_ring]
# Create rectangular lattice
rectlat = openmc.RectLattice()
rectlat.center = (0., 0.)
rectlat.pitch = (pitch, pitch)
rectlat.lower_left = (-2*pitch, -2*pitch)
rectlat.outer = outer_universe
rectlat.universes = np.full((4, 4), pin_universe)
rectlat.universes[0] = big_pin_universe
# Create cell filled with translated/rotated rectangular lattice on left
left_cyl = openmc.ZCylinder(x0=-4.0, r=4.0)
left_cell = openmc.Cell(fill=rectlat, region=-left_cyl)
left_cell.translation = (-4.0, 0.0, 0.0)
left_cell.rotation = (0.0, 0.0, 45.0)
# Create cell filled with translated/rotated hexagonal lattice on right
right_cyl = openmc.ZCylinder(x0=4.0, r=4.0)
right_cell = openmc.Cell(fill=hexlat, region=-right_cyl)
right_cell.translation = (4.0, 0.0, 0.0)
right_cell.rotation = (0.0, 0.0, 30.0)
# Finish up with the geometry
outer_cyl = openmc.ZCylinder(r=8.0, boundary_type='vacuum')
main_cell = openmc.Cell(fill=water, region=-outer_cyl & +left_cyl & +right_cyl)
model.geometry = openmc.Geometry([main_cell, left_cell, right_cell])
model.settings.batches = 5
model.settings.inactive = 0
model.settings.particles = 1000
model.settings.source = openmc.Source(space=openmc.stats.Point())
model.settings.export_to_xml()
return model
def test():
model = rotated_lattice_model()
harness = PyAPITestHarness('statepoint.5.h5', model)
harness.main()