Exemplo n.º 1
0
def test_complement(reset):
    zcyl = openmc.ZCylinder(r=1., surface_id=1)
    z0 = openmc.ZPlane(-5., surface_id=2)
    z1 = openmc.ZPlane(5., surface_id=3)
    outside = +zcyl | -z0 | +z1
    inside = ~outside
    outside_equiv = ~(-zcyl & +z0 & -z1)
    inside_equiv = ~outside_equiv

    # Check bounding box
    for region in (inside, inside_equiv):
        ll, ur = region.bounding_box
        assert ll == pytest.approx((-1., -1., -5.))
        assert ur == pytest.approx((1., 1., 5.))
    assert_unbounded(outside)
    assert_unbounded(outside_equiv)

    # string represention
    assert str(inside) == '~(1 | -2 | 3)'

    # evaluate method
    assert (0, 0, 0) in inside
    assert (0, 0, 0) not in outside
    assert (0, 0, 6) not in inside
    assert (0, 0, 6) in outside

    # translate method
    inside_t = inside.translate((1.0, 1.0, 1.0))
    ll, ur = inside_t.bounding_box
    assert ll == pytest.approx((0., 0., -4.))
    assert ur == pytest.approx((2., 2., 6.))
Exemplo n.º 2
0
def test_union(reset):
    s1 = openmc.XPlane(x0=5, surface_id=1)
    s2 = openmc.XPlane(x0=-5, surface_id=2)
    region = +s1 | -s2
    assert isinstance(region, openmc.Union)

    # Check bounding box
    assert_unbounded(region)

    # __contains__
    assert (6, 0, 0) in region
    assert (-6, 0, 0) in region
    assert (0, 0, 0) not in region

    # string representation
    assert str(region) == '(1 | -2)'

    # Combining region with intersection
    s3 = openmc.YPlane(surface_id=3)
    reg2 = region & +s3
    assert (6, 1, 0) in reg2
    assert (6, -1, 0) not in reg2
    assert str(reg2) == '((1 | -2) 3)'

    # translate method
    regt = region.translate((2.0, 0.0, 0.0))
    assert (-4, 0, 0) in regt
    assert (6, 0, 0) not in regt
    assert (8, 0, 0) in regt
Exemplo n.º 3
0
def test_bounding_box():
    zcyl = openmc.ZCylinder()
    c = openmc.Cell(region=-zcyl)
    ll, ur = c.bounding_box
    assert ll == pytest.approx((-1., -1., -np.inf))
    assert ur == pytest.approx((1., 1., np.inf))

    # Cell with no region specified
    c = openmc.Cell()
    assert_unbounded(c)
Exemplo n.º 4
0
def test_bounding_box():
    cyl1 = openmc.ZCylinder(r=1.0)
    cyl2 = openmc.ZCylinder(r=2.0)
    c1 = openmc.Cell(region=-cyl1)
    c2 = openmc.Cell(region=+cyl1 & -cyl2)

    u = openmc.Universe(cells=[c1, c2])
    ll, ur = u.bounding_box
    assert ll == pytest.approx((-2., -2., -np.inf))
    assert ur == pytest.approx((2., 2., np.inf))

    u = openmc.Universe()
    assert_unbounded(u)