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

Hex lattice #313

Merged
merged 54 commits into from
Feb 24, 2015
Merged

Hex lattice #313

merged 54 commits into from
Feb 24, 2015

Conversation

smharper
Copy link
Contributor

@smharper smharper commented Sep 6, 2014

This pull request gives OpenMC the ability to simulate geometries with hexagonal lattices. In addition to adding the new hexagonal lattice features, this PR makes significant changes to the existing code. Here are the top-level changes:

  • Users can specify a new element, hex_lattice, in the geometry.xml file
  • The documentation has been updated, and two new tests have been added.
  • Lattices in the geometry.xml file no longer need the type element/attribute.
  • pitch is now used rather than width when specifying lattices in the geometry.xml file.
  • In order to handle the changes with type and width, I added deprecation warnings to input.F90. I know that we don't technically need them since we are still in 0.x.y releases, but I think it's more polite to our users. I also added a Python utility to automatically update geometry.xml files.

Low-level changes:

  • The lattice code in geometry.F90 is now a little more modular. Various lattice calculations were moved into the functions get_lat_trans, get_lat_indices, and is_valid_lat_index.
  • Lattices use a polymorphic data structure---a cool feature of the Fortran 2003 standard. There is an abstract Lattice class. Lattice objects can be passed around by most functions without worrying about whether they are actually instances of the RectLattice or HexLattice types. Unfortunately, it also means that the global lattices array needs to be accessed like lattices(i) % obj rather than just lattices(i). Sometime in the future I would like to convert the lattice primitives like get_lat_trans into type-bound procedures.
  • Removed lattice_edge calculations from find_cell. This had no effect on the test suite, and I have not seen any damage caused by it's removal in my larger test calculations.
  • distance_to_boundary stores lattice distances and surface distances in different variables in order to address issue Lattice Corner Crossing #258

Design decisions that may affect performance or readability:

  • Hexagonal lattice cell indexing has an algorithm that uses the particle's distance from various cell centers. It could probably be replaced with an algorithm that uses division remainders, but all of my attempted remainder algorithms suffered from finite precision issues that caused lost particles.
  • The hexagonal lattice portion of distance_to_boundary uses a lot of expensive calculations to measure distances relative to the neighbor cells rather than the current cell. This algorithm is also used due to it's superior finite precision performance.
  • There is a check in distance_to_boundary for negative lattice distances. I needed this for debugging, but I am considering leaving it in so that no future developers accidentally make changes that allow negative distances.
  • cross_lattice now uses get_lat_trans which is a little bit more expensive than the older method of subtracting cell widths from the particle position, but it's agnostic to the lattice type and provides better finite precision performance (I had a lot of finite precision issues, can you tell?).

Verification and validation:

  • I tested a large 2d hex lattice model against a model of manually placed cylinders. I got a disagreement of 3 +/- 12 pcm.
  • I tested a 3d hex lattice model against a model using a 2d hex lattice placed in a 3d rectangular lattice. I got a disagreement of 17 +/- 22 pcm.
  • I used an earlier version of hex_lattice to model various cores in the LR-0 reactor. The calculations differed from MCNP5 calculations by roughly 30 +/ 10 pcm and agreed with the experiment within uncertainties.

I can provide my V&V models to anyone who wants them. I'll also try to rerun them after we've gotten through a lot of the review process to make sure no errors have sneaked in. Also, I should mention that none of the regression test results are different (despite the changes to the handling of rectangular lattices) with the exception of score_flux_yn. I haven't updated that test yet because I am investigating it to see if I can find the reason for the change.

This build is currently causing a weird error in read_xml_files_materials_t
Conflicts:
	src/input_xml.F90
Thanks to @nhorelik for the vast majority of changes in this commit.
Intel Fortran raises a compilation error when a pointer to a polymorphic object is passed from inside a 'type is' block to a dummy argument which is a pointer to the object's parent class.
Checked all non-CMFD tests; they all pass except score_flux_yn; need to investigate that failure closely
Conflicts:
	src/initialize.F90
@paulromano
Copy link
Contributor

Thanks for this @smharper! This is a biggie, so I'm going to say we should shoot for inclusion in v0.7. I'll start reviewing/testing once all the v0.6.1 stuff is complete.

@paulromano paulromano added this to the v0.7 milestone Sep 9, 2014
@smharper
Copy link
Contributor Author

The bug that I mentioned in the comment above was fixed in #359 so I've now removed the crappy fix implemented in 11c490b (it turned out to cause another bug anyway). I have also moved the stuff in the update_lattices.py script over to the update_inputs.py script.

At this point, I don't know of any standing issues with this PR.

@paulromano paulromano self-assigned this Feb 16, 2015
.. math::
:label: rect_indexing

i_x = \Bigg \lceil \frac{x - x_0}{p_0} \Bigg \rceil
Copy link
Contributor

Choose a reason for hiding this comment

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

Did \left and \right (instead of \Bigg) not work for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like \left and \right work fine. I've switched over to those now.

@paulromano
Copy link
Contributor

Need to update models in examples/ folder.

p % coord % next% lattice = c % fill
p % coord % next% lattice_x = i_xyz(1)
p % coord % next% lattice_y = i_xyz(2)
p % coord % next% lattice_z = i_xyz(3)
Copy link
Contributor

Choose a reason for hiding this comment

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

Very clean, I love it!

if (check_for_node(node_lat, "width")) then
call warning("The use of 'width' is deprecated and will be disallowed &
&in a future release. Use 'pitch' instead. The utility openmc/&
&src/utils/update_lattices.py can be used to automatically update &
Copy link
Contributor

Choose a reason for hiding this comment

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

update_inputs.py

integer :: line_wrap ! length of line
integer :: length ! length of message
integer :: indent ! length of indentation
character(:), allocatable :: message ! input message with a prefix
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, allocatable characters break building with gfortran 4.6. Normally, I wouldn't care much, but since we're moving to Travis CI for testing and their VMs still use Ubuntu 12.04 (which in turn uses gcc 4.6), this would prevent building there. Would you mind re-coding this to remove allocatable characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think reworking warning is worth the effort right now. If it's okay with you, I'd rather just revert to the develop version of warning.

paulromano added a commit that referenced this pull request Feb 24, 2015
Hexagonal lattice capability
@paulromano paulromano merged commit 6fd4ed3 into openmc-dev:develop Feb 24, 2015
@paulromano
Copy link
Contributor

Thanks again @smharper!

<hex_lattice id="10" n_rings="3" outer="1">
<center> 0.0 0.0 </center>
<pitch> 1.0 </pitch>
<universes>
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this PR has been posted, but is it a typo that this example hex lattice specification does not include the "n_rings" element? Based on the description of "n_rings" above, I believe this is a required element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "n_rings" is present as an attribute in this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I totally missed that. Sorry for the confusion!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries

@smharper smharper deleted the hex_lattice branch August 6, 2015 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants