Skip to content

Commit

Permalink
Merge pull request #9 from openmc-dev/fix_plane
Browse files Browse the repository at this point in the history
Plane arguments correction
  • Loading branch information
pshriwise authored Nov 5, 2024
2 parents f38ab3b + 4121f81 commit 01932e3
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/openmc_cad_adapter/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ def to_cubit_surface_inner(self, ent_type, node, extents, inner_world=None, hex=
ns = cd * n

cmds.append( f"create surface rectangle width { 2*extents[0] } zplane")
sur, cmd = emit_get_last_id( "surface" )
cmds.append(cmd)
surf, cmd = emit_get_last_id( "body" )
sur = emit_get_last_id("surface", cmds)
surf = emit_get_last_id("body", cmds)

n = n/np.linalg.norm(n)
ns = cd * n
Expand All @@ -81,7 +80,7 @@ def to_cubit_surface_inner(self, ent_type, node, extents, inner_world=None, hex=
cmds.append(f"Rotate body {{ {surf} }} about 0 0 0 direction {n3[0]} {n3[1]} {n3[2]} Angle {angle}")
cmds.append(f"body {{ { surf } }} move {ns[0]} {ns[1]} {ns[2]}")
cmds.append(f"brick x {extents[0]} y {extents[1]} z {extents[2]}" )
ids = emit_get_last_id( ent_type )
ids = emit_get_last_id( ent_type, cmds)
cmds.append(f"section body {{ {ids} }} with surface {{ {sur} }} {self.lreverse(node)}")
cmds.append(f"del surface {{ {sur} }}")

Expand All @@ -90,7 +89,7 @@ def to_cubit_surface_inner(self, ent_type, node, extents, inner_world=None, hex=

@classmethod
def from_openmc_surface_inner(cls, plane):
return cls(plane.a, plane.b, plane.c, plane.d, plane.boundary_type, plane.albedo, plane.name, plane.id)
return cls(a=plane.a, b=plane.b, c=plane.c, d=plane.d, boundary_type=plane.boundary_type, albedo=plane.albedo, name=plane.name, surface_id=plane.id)


class CADXPlane(CADSurface, openmc.XPlane):
Expand Down
96 changes: 96 additions & 0 deletions test/gold/plane.jou
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 1
create surface rectangle width 1000 zplane
#{ id1 = Id("surface") }
#{ id2 = Id("body") }
# n3 0.7071067811865475 -0.7071067811865475 0.0
Rotate body { id2 } about 0 0 0 direction 0.7071067811865475 -0.7071067811865475 0.0 Angle -90.0
body { id2 } move -3.5355339059327373 -3.5355339059327373 -0.0
brick x 500 y 500 z 500
#{ id3 = Id("body") }
section body { id3 } with surface { id1 } reverse
del surface { id1 }
create surface rectangle width 1000 zplane
#{ id4 = Id("surface") }
#{ id5 = Id("body") }
# n3 0.7071067811865475 -0.7071067811865475 0.0
Rotate body { id5 } about 0 0 0 direction 0.7071067811865475 -0.7071067811865475 0.0 Angle -90.0
body { id5 } move 3.5355339059327373 3.5355339059327373 0.0
brick x 500 y 500 z 500
#{ id6 = Id("body") }
section body { id6 } with surface { id4 }
del surface { id4 }
#{ id7 = Id("body") }
intersect body { id3 } { id6 }
#{ id8 = Id("body") }
#{id9 = ( id7 == id8 ) ? id6 : id8}
create surface rectangle width 1000 zplane
#{ id10 = Id("surface") }
#{ id11 = Id("body") }
# n3 0.7071067811865475 0.0 0.0
Rotate body { id11 } about 0 0 0 direction 0.7071067811865475 0.0 0.0 Angle -45.0
body { id11 } move -0.0 -3.5355339059327373 -3.5355339059327373
brick x 500 y 500 z 500
#{ id12 = Id("body") }
section body { id12 } with surface { id10 } reverse
del surface { id10 }
#{ id13 = Id("body") }
intersect body { id9 } { id12 }
#{ id14 = Id("body") }
#{id15 = ( id13 == id14 ) ? id12 : id14}
create surface rectangle width 1000 zplane
#{ id16 = Id("surface") }
#{ id17 = Id("body") }
# n3 0.7071067811865475 0.0 0.0
Rotate body { id17 } about 0 0 0 direction 0.7071067811865475 0.0 0.0 Angle -45.0
body { id17 } move 0.0 3.5355339059327373 3.5355339059327373
brick x 500 y 500 z 500
#{ id18 = Id("body") }
section body { id18 } with surface { id16 }
del surface { id16 }
#{ id19 = Id("body") }
intersect body { id15 } { id18 }
#{ id20 = Id("body") }
#{id21 = ( id19 == id20 ) ? id18 : id20}
create surface rectangle width 1000 zplane
#{ id22 = Id("surface") }
#{ id23 = Id("body") }
# n3 0.0 -0.7071067811865475 0.0
Rotate body { id23 } about 0 0 0 direction 0.0 -0.7071067811865475 0.0 Angle -45.0
body { id23 } move -3.5355339059327373 -0.0 -3.5355339059327373
brick x 500 y 500 z 500
#{ id24 = Id("body") }
section body { id24 } with surface { id22 } reverse
del surface { id22 }
#{ id25 = Id("body") }
intersect body { id21 } { id24 }
#{ id26 = Id("body") }
#{id27 = ( id25 == id26 ) ? id24 : id26}
create surface rectangle width 1000 zplane
#{ id28 = Id("surface") }
#{ id29 = Id("body") }
# n3 0.0 -0.7071067811865475 0.0
Rotate body { id29 } about 0 0 0 direction 0.0 -0.7071067811865475 0.0 Angle -45.0
body { id29 } move 3.5355339059327373 0.0 3.5355339059327373
brick x 500 y 500 z 500
#{ id30 = Id("body") }
section body { id30 } with surface { id28 }
del surface { id28 }
#{ id31 = Id("body") }
intersect body { id27 } { id30 }
#{ id32 = Id("body") }
#{id33 = ( id31 == id32 ) ? id30 : id32}
body { id33 } name "Cell_1"
group "mat:void" add body { id33 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
12 changes: 11 additions & 1 deletion test/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@
from test import run_in_tmpdir


def test_planes(request, run_in_tmpdir):
plane1 = openmc.Plane(A=1.0, B=1.0, C=0.0, D=-5.0)
plane2 = openmc.Plane(A=1.0, B=1.0, C=0.0, D=5.0)
plane3 = openmc.Plane(A=0.0, B=1.0, C=1.0, D=-5.0)
plane4 = openmc.Plane(A=0.0, B=1.0, C=1.0, D=5.0)
plane5 = openmc.Plane(A=1.0, B=0.0, C=1.0, D=-5.0)
plane6 = openmc.Plane(A=1.0, B=0.0, C=1.0, D=5.0)
g = openmc.Geometry([openmc.Cell(region=+plane1 & -plane2 & +plane3 & -plane4 & +plane5 & -plane6)])
to_cubit_journal(g, world=(500, 500, 500), filename='plane.jou')
diff_gold_file('plane.jou')

# Test the XCylinder and YCylinder classes, the ZCylinder surface is tested
# extensively in the OpenMC example tests

def test_xcylinder(request, run_in_tmpdir):
x_cyl = openmc.XCylinder(r=1.0, y0=10.0, z0=5.0)
g = openmc.Geometry([openmc.Cell(region=-x_cyl)])
Expand Down

0 comments on commit 01932e3

Please sign in to comment.