Skip to content

Commit

Permalink
Merge pull request #15 from pshriwise/nested-spheres
Browse files Browse the repository at this point in the history
Replace missing block for outside of sphere surface
  • Loading branch information
eepeterson authored Nov 7, 2024
2 parents c312dbf + e2a95d3 commit 70fea9a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Test examples
run: |
micromamba activate test-env
OPENMC_EXAMPLES_DIR=$HOME/openmc/examples pytest -v ./test/test_examples.py
OPENMC_EXAMPLES_DIR=$HOME/openmc/examples pytest -v ./test
- name: Setup tmate session
if: ${{ failure() }}
Expand Down
5 changes: 5 additions & 0 deletions src/openmc_cad_adapter/surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ def to_cubit_surface_inner(self, ent_type, node, extents, inner_world=None, hex=
cad_cmds.append( f"sphere radius {self.r}")
ids = emit_get_last_id(ent_type, cad_cmds)
move(ids, self.x0, self.y0, self.z0, cad_cmds)
if node.side != '-':
cad_cmds.append( f"brick x {extents[0]} y {extents[1]} z {extents[2]}" )
wid = emit_get_last_id( ent_type , cad_cmds)
cad_cmds.append(f"subtract body {{ {ids} }} from body {{ {wid} }}")
ids = wid
return ids, cad_cmds

@classmethod
Expand Down
46 changes: 46 additions & 0 deletions test/gold/nested_spheres.jou
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 3
sphere radius 20.0
#{ id1 = Id("body") }
brick x 500 y 500 z 500
#{ id2 = Id("body") }
subtract body { id1 } from body { id2 }
sphere radius 30.0
#{ id3 = Id("body") }
#{ id4 = Id("body") }
intersect body { id2 } { id3 }
#{ id5 = Id("body") }
#{id6 = ( id4 == id5 ) ? id3 : id5}
body { id6 } name "Cell_3"
group "mat:void" add body { id6 }
#CELL 2
sphere radius 10.0
#{ id7 = Id("body") }
brick x 500 y 500 z 500
#{ id8 = Id("body") }
subtract body { id7 } from body { id8 }
sphere radius 20.0
#{ id9 = Id("body") }
#{ id10 = Id("body") }
intersect body { id8 } { id9 }
#{ id11 = Id("body") }
#{id12 = ( id10 == id11 ) ? id9 : id11}
body { id12 } name "Cell_2"
group "mat:void" add body { id12 }
#CELL 1
sphere radius 10.0
#{ id13 = Id("body") }
body { id13 } name "Cell_1"
group "mat:void" add body { id13 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
15 changes: 15 additions & 0 deletions test/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ def test_planes(request, run_in_tmpdir):
diff_gold_file('plane.jou')


@reset_openmc_ids
def test_nested_spheres(request, run_in_tmpdir):
inner_sphere = openmc.Sphere(r=10.0)
middle_sphere = openmc.Sphere(r=20.0)
outer_sphere = openmc.Sphere(r=30.0)

inner_cell = openmc.Cell(region=-inner_sphere)
middle_cell = openmc.Cell(region=+inner_sphere & -middle_sphere)
outer_cell = openmc.Cell(region=+middle_sphere & -outer_sphere)

g = openmc.Geometry([outer_cell, middle_cell, inner_cell])
to_cubit_journal(g, world=(500, 500, 500), filename='nested_spheres.jou')
diff_gold_file('nested_spheres.jou')


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

0 comments on commit 70fea9a

Please sign in to comment.