mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
added check for decimal points in formula
This commit is contained in:
parent
5fe6576a9c
commit
430b426098
1 changed files with 6 additions and 1 deletions
|
|
@ -598,7 +598,7 @@ class Material(IDManagerMixin):
|
|||
formula : str
|
||||
Formula to add, e.g., 'C2O', 'C6H12O6', or (NH4)2SO4.
|
||||
Note this is case sensitive, elements must start with an uppercase
|
||||
character. Any numbers will be converted to integers (rounded down).
|
||||
character. Multiplier numbers must be integers.
|
||||
percent_type : {'ao', 'wo'}, optional
|
||||
'ao' for atom percent and 'wo' for weight percent. Defaults to atom
|
||||
percent.
|
||||
|
|
@ -622,6 +622,11 @@ class Material(IDManagerMixin):
|
|||
"""
|
||||
cv.check_type('formula', formula, str)
|
||||
|
||||
if '.' in formula:
|
||||
msg = 'Non-integer multiplier values are not accepted. The ' \
|
||||
'input formula {} contains a "." character.'.format(formula)
|
||||
raise ValueError(msg)
|
||||
|
||||
# Tokenizes the formula and check validity of tokens
|
||||
tokens = re.findall(r"([A-Z][a-z]*)(\d*)|(\()|(\))(\d*)", formula)
|
||||
for row in tokens:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue