add capability to set cell temperature to None

This commit is contained in:
josh 2022-12-06 18:31:28 +00:00
parent b6075e0543
commit 5b807d4e6c
2 changed files with 5 additions and 2 deletions

View file

@ -318,12 +318,12 @@ class Cell(IDManagerMixin):
@temperature.setter
def temperature(self, temperature):
# Make sure temperatures are positive
cv.check_type('cell temperature', temperature, (Iterable, Real))
cv.check_type('cell temperature', temperature, (Iterable, Real), none_ok=True)
if isinstance(temperature, Iterable):
cv.check_type('cell temperature', temperature, Iterable, Real)
for T in temperature:
cv.check_greater_than('cell temperature', T, 0.0, True)
else:
elif isinstance(temperature, Real):
cv.check_greater_than('cell temperature', temperature, 0.0, True)
# If this cell is filled with a universe or lattice, propagate

View file

@ -92,6 +92,9 @@ def test_temperature(cell_with_lattice):
assert c2.temperature == 400.0
with pytest.raises(ValueError):
c.temperature = -100.
c.temperature = None
assert c1.temperature == None
assert c2.temperature == None
# distributed temperature
cells, _, _, _ = cell_with_lattice