-
Notifications
You must be signed in to change notification settings - Fork 84
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
Cell Rotations and Translations #225
Cell Rotations and Translations #225
Conversation
…/ rotations can now be converted to OpenCG
…ces. Rotations need to be updated.
@wbinventor - this is great! I'll give this a full review later this week. |
if isinstance(fill, openmoc.Lattice): | ||
opencg_cell.fill = get_opencg_lattice(fill) | ||
else: | ||
opencg_cell.fill = get_opencg_universe(fill) | ||
|
||
if openmoc_cell.isRotated(): | ||
rotation = openmoc_cell.getRotation(3) | ||
opencg_cell.rotation = rotation * -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for the -1 here and on line 599?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, it was a little hack while I was trying to figure things out. I've removed it now as I've straightened out things in the roll-pitch-yaw convention of the rotation matrix below.
The rotations are input and stored in degrees, but angles are for the most part handled internally in radians. The |
next_coords->setX(new_x); | ||
next_coords->setY(new_y); | ||
next_coords->setZ(new_z); | ||
next_coords->incrementPhi(cell->getPsi() * M_PI / 180.); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indented one too many spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, it doesn't show up that way in emacs. I removed all whitespace and added it back in so perhaps it will show up properly now.
I've addressed all of the comments made thus far and think this is ready for a final review. |
Thanks for updating the PR @wbinventor. I had a comment on mixing of angle units (radians vs degrees) in the code that it looks like you might have missed. |
@samuelshaner - the rotation angles are now stored internally in radians. The setter and getter routines for the angles now accept a |
|
||
/* The typemap used to match the method signature for the Cell's | ||
* getter method for rotations used by the OpenCG compatibility module. */ | ||
%apply (double* ARGOUT_ARRAY1, int DIM1) {(double* rotations, int num_axes)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this signature need another attribute for the units?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered that too, but it doesn't seem too since it works with my test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm...maybe swig just ignores all arguments after those included in the signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I think. But this is related to the way NumPy typemaps work with SWIG - and that isn't particularly well documented IMHO.
Just tested this out and everything looks good to merge! |
Cell Rotations and Translations
This PR introduces cell rotations and translations. These features enable us to model the fully-detailed (3D) BEAVRS benchmark generated by the OpenCG BEAVRS builder for the first time!
Unfortunately, adding in rotations/translations was a little more difficult than I had expected (but not overly cumbersome). Fortunately, the process of putting in these features required some refactoring of the ray tracing code - but it keeps getting better and better and is far more methodical than a few years ago.
In particular, this PR introduces length 3
_rotation
and_translation
arrays for theCell
class which may be optionally set by the user. The ray tracing code in theGeometry
andUniverse
classes has been refactored such that all updates toLocalCoords
positions take place directly within theLocalCoords
object (which is a cleaner abstraction than before). In addition, the 2D anglephi
wrt the x-axis is now an attribute ofLocalCoords
, where it is defined based on a track's starting angle and the rotations applied to anyCells
found during CSG tree traversal.With the changes made here, it is quite simple to build a full-core OpenMOC model of the 3D BEAVRS core. In particular, with an installation of the BEAVRS model builder from the mit-crpg/PWR_benchmarks repo, along with OpenCG (a pre-requisite for the BEAVRS builder), one can instantiate an OpenMOC model of BEAVRS as follows:
Previously, if one attempted to export the model as above, the baffles were not placed in the correct positions. This is because the baffles have rotations applied. Now that the baffles can be properly treated, the model above can be plotted as shown below and the baffles look as they should.
Full core
Upper right core
Note that the OpenMOC
Geometry
created above will not have a bounding box applied, and hence is not yet ready for ray tracing. In order to make theGeometry
"ray tracing-ready", one would must create aCell
outside the core vessel filled by a dummyMaterial
and bounded by the core vessel'sZCylinder
and some boundingXPlanes
andYPlanes
withVACUUM
boundary conditions.