diff --git a/openmc/cell.py b/openmc/cell.py index e83d01dcd..b578702bb 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -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) diff --git a/openmc/executor.py b/openmc/executor.py index 518153512..51215e8b7 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -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 + `_ which includes a `convert` command. + Parameters ---------- plots : Iterable of openmc.Plot diff --git a/openmc/plots.py b/openmc/plots.py index d95bc5905..2ba5d9758 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -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