From 7dd7af6dfa87676190bd7043b050a9f79f0652a8 Mon Sep 17 00:00:00 2001 From: Mikolaj Adam Kowalski Date: Mon, 2 Mar 2020 18:54:03 +0000 Subject: [PATCH] Checks for -ve volume and adds it to Cell.__repl_ --- openmc/cell.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openmc/cell.py b/openmc/cell.py index e01cb86137..792f152bef 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -4,6 +4,7 @@ from copy import deepcopy from math import cos, sin, pi from numbers import Real from xml.etree import ElementTree as ET +from uncertainties import UFloat import sys import warnings @@ -134,6 +135,7 @@ class Cell(IDManagerMixin): string += '\t{0: <15}=\t{1}\n'.format('Temperature', self.temperature) string += '{: <16}=\t{}\n'.format('\tTranslation', self.translation) + string += '{: <16}=\t{}\n'.format('\tVolume', self.volume) return string @@ -285,9 +287,18 @@ class Cell(IDManagerMixin): @volume.setter def volume(self, volume): if volume is not None: - cv.check_type('cell volume', volume, Real) + try: + cv.check_type('cell volume', volume, Real) + except TypeError: + cv.check_type('cell volume', volume, UFloat) + cv.check_greater_than('cell volume', volume, 0.0) self._volume = volume + # Forget now invalid info about atoms content + # (sice volume has just changed) + if self._atoms is not None: + self._atoms = None + def add_volume_information(self, volume_calc): """Add volume information to a cell.