Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace missing block for outside of sphere surface #15

Merged
merged 6 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 28 additions & 0 deletions test/gold/nested_spheres.jou
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any subtract commands here since I don't think the test case was defined properly

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 3
sphere radius 30.0
#{ id1 = Id("body") }
body { id1 } name "Cell_3"
group "mat:void" add body { id1 }
#CELL 2
sphere radius 20.0
#{ id2 = Id("body") }
body { id2 } name "Cell_2"
group "mat:void" add body { id2 }
#CELL 1
sphere radius 10.0
#{ id3 = Id("body") }
body { id3 } name "Cell_1"
group "mat:void" add body { id3 }
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=-middle_sphere)
pshriwise marked this conversation as resolved.
Show resolved Hide resolved
outer_cell = openmc.Cell(region=-outer_sphere)
pshriwise marked this conversation as resolved.
Show resolved Hide resolved

g = openmc.Geometry([outer_cell, middle_cell, inner_cell])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the order that the cells are listed in going to have an impact? I was expecting to see the outputs in the cubit journal file ordered by cell ID, but it looks reversed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also be worth tacking on a vacuum boundary condition to the outer sphere so that it makes a viable geometry that could ostensibly be run in openmc

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the order that the cells are listed in going to have an impact? I was expecting to see the outputs in the cubit journal file ordered by cell ID, but it looks reversed.

I believe they'll be generated in the order they appear in the iterable passed to the Geometry object. Corresponding IDs on the volume objects in the resulting CAD would be great, but might be difficult to manage based on how Cubit handles ID spaces. An easier short-term solution would be to place each cell in it's own group with the ID in the name for reference to the original model.

could also be worth tacking on a vacuum boundary condition to the outer sphere so that it makes a viable geometry that could ostensibly be run in openmc

Agreed that it would be nice and I'm happy to include those changes here. Right now I'm planning on spending my time covering and verifying more geometry capabilities in the test suite (hopefully correctly in the future) than every test case being runnable in OpenMC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super thanks!

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
Loading