Address @wbinventor comments on #826

This commit is contained in:
Paul Romano 2017-03-10 10:43:01 -06:00
parent f342b2a93d
commit d2c7486cfc
3 changed files with 21 additions and 12 deletions

View file

@ -99,6 +99,7 @@ class Cell(object):
self.fill = fill
self.region = region
self._rotation = None
self._rotation_matrix = None
self._temperature = None
self._translation = None
self._paths = []
@ -196,14 +197,7 @@ class Cell(object):
@property
def rotation_matrix(self):
if self.rotation is not None:
phi, theta, psi = self.rotation*(-pi/180.)
c3, s3 = cos(phi), sin(phi)
c2, s2 = cos(theta), sin(theta)
c1, s1 = cos(psi), sin(psi)
return np.array([[c1*c2, c1*s2*s3 - c3*s1, s1*s3 + c1*c3*s2],
[c2*s1, c1*c3 + s1*s2*s3, c3*s1*s2 - c1*s3],
[-s2, c2*s3, c2*c3]])
return self._rotation_matrix
@property
def temperature(self):
@ -288,6 +282,17 @@ class Cell(object):
cv.check_length('cell rotation', rotation, 3)
self._rotation = np.asarray(rotation)
# Save rotation matrix -- the reason we do this instead of having it be
# automatically calculated when the rotation_matrix property is accessed
# is so that plotting on a rotated geometry can be done faster.
phi, theta, psi = self.rotation*(-pi/180.)
c3, s3 = cos(phi), sin(phi)
c2, s2 = cos(theta), sin(theta)
c1, s1 = cos(psi), sin(psi)
return np.array([[c1*c2, c1*s2*s3 - c3*s1, s1*s3 + c1*c3*s2],
[c2*s1, c1*c3 + s1*s2*s3, c3*s1*s2 - c1*s3],
[-s2, c2*s3, c2*c3]])
@translation.setter
def translation(self, translation):
cv.check_type('cell translation', translation, Iterable, Real)

View file

@ -48,6 +48,10 @@ def plot_geometry(output=True, openmc_exec='openmc', cwd='.'):
def plot_inline(plots, openmc_exec='openmc', cwd='.', convert_exec='convert'):
"""Display plots inline in a Jupyter notebook.
This function requires that you have a program installed to convert PPM
files to PNG files. Typically, that would be `ImageMagick
<https://www.imagemagick.org>`_ which includes a `convert` command.
Parameters
----------
plots : Iterable of openmc.Plot

View file

@ -483,8 +483,8 @@ class Plot(object):
The basis directions for the plot
slice_coord : float
The level at which the slice plot should be plotted. For example, if
the basis is 'xy', this would indicate at what z value is used in
the origin.
the basis is 'xy', this would indicate the z value used in the
origin.
"""
cv.check_type('geometry', geometry, openmc.Geometry)
@ -565,7 +565,7 @@ class Plot(object):
seed : int
The random number seed used to generate the color scheme
alpha : float
The value to apply in alpha compisiting
The value between 0 and 1 to apply in alpha compisiting
background : 3-tuple of int or str
The background color to apply in alpha compisiting
@ -794,7 +794,7 @@ class Plots(cv.CheckedList):
seed : int
The random number seed used to generate the color scheme
alpha : float
The value to apply in alpha compisiting
The value between 0 and 1 to apply in alpha compisiting
background : 3-tuple of int or str
The background color to apply in alpha compisiting