Enforce non-negative percents for material.add_nuclide to prevent unintended ao/wo flipping (#3075)

This commit is contained in:
John Vincent Cauilan 2024-07-08 16:29:49 -05:00 committed by GitHub
parent b11f8b73ca
commit e74dc5037e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -519,6 +519,7 @@ class Material(IDManagerMixin):
cv.check_type('nuclide', nuclide, str)
cv.check_type('percent', percent, Real)
cv.check_value('percent type', percent_type, {'ao', 'wo'})
cv.check_greater_than('percent', percent, 0, equality=True)
if self._macroscopic is not None:
msg = 'Unable to add a Nuclide to Material ID="{}" as a ' \
@ -727,6 +728,7 @@ class Material(IDManagerMixin):
cv.check_type('nuclide', element, str)
cv.check_type('percent', percent, Real)
cv.check_greater_than('percent', percent, 0, equality=True)
cv.check_value('percent type', percent_type, {'ao', 'wo'})
# Make sure element name is just that