mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Merge pull request #2081 from paulromano/region-parenthesis-fix
Fix a corner case in Region.from_expression
This commit is contained in:
commit
fc3820191b
3 changed files with 10 additions and 1 deletions
|
|
@ -1403,7 +1403,7 @@ given analytically by
|
|||
.. math::
|
||||
:label: coherent-elastic-angle
|
||||
|
||||
\mu = 1 - \frac{E_i}{E}
|
||||
\mu = 1 - \frac{2E_i}{E}
|
||||
|
||||
where :math:`E_i` is the energy of the Bragg edge that scattered the neutron.
|
||||
|
||||
|
|
|
|||
|
|
@ -106,6 +106,11 @@ class Region(ABC):
|
|||
# If special character appears immediately after a non-operator,
|
||||
# create a token with the appropriate half-space
|
||||
if i_start >= 0:
|
||||
# When an opening parenthesis appears after a non-operator,
|
||||
# there's an implicit intersection operator between them
|
||||
if expression[i] == '(':
|
||||
tokens.append(' ')
|
||||
|
||||
j = int(expression[i_start:i])
|
||||
if j < 0:
|
||||
tokens.append(-surfaces[abs(j)])
|
||||
|
|
|
|||
|
|
@ -204,3 +204,7 @@ def test_from_expression(reset):
|
|||
# Make sure ")(" is handled correctly
|
||||
r = openmc.Region.from_expression('(-1|2)(2|-3)', surfs)
|
||||
assert str(r) == '((-1 | 2) (2 | -3))'
|
||||
|
||||
# Opening parenthesis immediately after halfspace
|
||||
r = openmc.Region.from_expression('1(2|-3)', surfs)
|
||||
assert str(r) == '(1 (2 | -3))'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue