Merge pull request #2323 from joshmay1/unset_temp

Add capability to unset cell temperatures
This commit is contained in:
Paul Romano 2022-12-09 07:19:07 -06:00 committed by GitHub
commit a8a6f6c49b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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