Skip to content

Commit c8f8f4d

Browse files
committed
inp: added lattice specification parsing
1 parent 45ca0e8 commit c8f8f4d

24 files changed

Lines changed: 1278 additions & 251 deletions

File tree

docs/source/pymcnp/inp/data.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@
421421
:inherited-members:
422422
```
423423

424+
### ``F_4`` Class
425+
426+
```{eval-rst}
427+
.. autoclass:: pymcnp.inp.data.F_4
428+
:members:
429+
:inherited-members:
430+
```
431+
424432
### ``Fc`` Class
425433

426434
```{eval-rst}

files/inp/valid_06.inp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ sdef par=p pos=-5 3 3 erg=2
2121
fir5 -5 0 0 0 0 0 0 1 1 1
2222
FS5 -10 9i 10
2323
C5 -10 9i 10
24-
c f16:e (1<1[0:0 -2:2 -2:2]<3)
25-
c f26:e (2<2[0:0 -2:2 -2:2]<4)
24+
f16:e (1<1[0:0 -2:2 -2:2]<3)
25+
f26:e (2<2[0:0 -2:2 -2:2]<4)
2626
f8:e 1
2727
ft8 PHL 1 16 0 $ Region 1
2828
1 26 0 $ Region 2

files/inp/valid_07.inp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ print
1515
prdmp 2j -3
1616
sdef
1717
nps 10000
18-
c f4:p (11<16[-10:10 -10:10 -10:10]<17)
18+
f4:p (11<16[-10:10 -10:10 -10:10]<17)
1919

2020
(MCNP Manual 6.2 Section 3.3.5.1.3)

files/inp/valid_33.inp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ phys:e 2j 1 $ Turn off Brems.
2121
sdef par=p pos=-5 3 3 erg=2
2222
fir5 -5 0 0 0 1 0 0 1 1 1
2323
FS5 -10 9i 10
24-
c CS5 -10 9i 10
25-
c f16:e (1<1[0:0 -2:2 -2:2]<3)
26-
c f26:e (2<2[0:0 -2:2 -2:2]<4)
24+
C S5 -10 9i 10
25+
f16:e (1<1[0:0 -2:2 -2:2]<3)
26+
f26:e (2<2[0:0 -2:2 -2:2]<4)
2727
f8:e 1
2828
ft8 PHL 1 16 0 $ Region 1
2929
1 26 0 $ Region 2

scripts/inp_tests.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,10 @@ def TEST(element, mod):
470470
valid_build[2][attribute.name] = 'consts.ast.types.DESIGNATOR'
471471
valid_init[0][attribute.name] = 'consts.ast.types.DESIGNATOR'
472472
elif attribute.type == 'cell.Geometry':
473-
valid_build[0][attribute.name] = 'consts.string.inp.cell.GEOMETRY'
474-
valid_build[1][attribute.name] = 'consts.string.inp.cell.GEOMETRY'
475-
valid_build[2][attribute.name] = 'consts.ast.inp.cell.GEOMETRY'
476-
valid_init[0][attribute.name] = 'consts.ast.inp.cell.GEOMETRY'
473+
valid_build[0][attribute.name] = 'consts.string.types.GEOMETRY'
474+
valid_build[1][attribute.name] = 'consts.string.types.GEOMETRY'
475+
valid_build[2][attribute.name] = 'consts.ast.types.GEOMETRY'
476+
valid_init[0][attribute.name] = 'consts.ast.types.GEOMETRY'
477477
elif attribute.type == 'types.Substance':
478478
valid_build[0][attribute.name] = 'consts.string.types.SUBSTANCE'
479479
valid_build[1][attribute.name] = 'consts.string.types.SUBSTANCE'
@@ -635,10 +635,10 @@ def TEST(element, mod):
635635
valid_build[2][attribute.name] = '[consts.ast.types.DESIGNATOR]'
636636
valid_init[0][attribute.name] = '[consts.ast.types.DESIGNATOR]'
637637
elif attribute.type == 'types.Tuple(cell.Geometry)':
638-
valid_build[0][attribute.name] = '[consts.string.inp.cell.GEOMETRY]'
639-
valid_build[1][attribute.name] = '[consts.string.inp.cell.GEOMETRY]'
640-
valid_build[2][attribute.name] = '[consts.ast.inp.cell.GEOMETRY]'
641-
valid_init[0][attribute.name] = '[consts.ast.inp.cell.GEOMETRY]'
638+
valid_build[0][attribute.name] = '[consts.string.types.GEOMETRY]'
639+
valid_build[1][attribute.name] = '[consts.string.types.GEOMETRY]'
640+
valid_build[2][attribute.name] = '[consts.ast.types.GEOMETRY]'
641+
valid_init[0][attribute.name] = '[consts.ast.types.GEOMETRY]'
642642
elif attribute.type == 'types.Tuple(types.Substance)':
643643
valid_build[0][attribute.name] = '[consts.string.types.SUBSTANCE]'
644644
valid_build[1][attribute.name] = '[consts.string.types.SUBSTANCE]'

src/pymcnp/inp/Cell.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Cell(_card.Card):
1515
'number': types.Integer,
1616
'material': types.Integer,
1717
'density': types.Real,
18-
'geometry': cell.Geometry,
18+
'geometry': types.Geometry,
1919
'options': types.Tuple(cell.CellOption),
2020
}
2121

@@ -25,7 +25,7 @@ def __init__(
2525
self,
2626
number: types.Integer,
2727
material: types.Integer,
28-
geometry: cell.Geometry,
28+
geometry: types.Geometry,
2929
density: types.Real = None,
3030
options: types.Tuple(cell.CellOption) = None,
3131
):
@@ -46,7 +46,7 @@ def __init__(
4646
self.number: types.Integer = number
4747
self.material: types.Integer = material
4848
self.density: types.Real = density
49-
self.geometry: cell.Geometry = geometry
49+
self.geometry: types.Geometry = geometry
5050
self.options: types.Tuple(cell.CellOption) = options
5151

5252
def to_mcnp(self):
@@ -197,7 +197,7 @@ def density(self, density: str | int | float | types.Real) -> None:
197197
self._density: types.Real = density
198198

199199
@property
200-
def geometry(self) -> cell.Geometry:
200+
def geometry(self) -> types.Geometry:
201201
"""
202202
Cell geometry.
203203
@@ -209,7 +209,7 @@ def geometry(self) -> cell.Geometry:
209209
return self._geometry
210210

211211
@geometry.setter
212-
def geometry(self, geometry: str | cell.Geometry) -> None:
212+
def geometry(self, geometry: str | types.Geometry) -> None:
213213
"""
214214
Sets ``geometry``.
215215
@@ -222,15 +222,15 @@ def geometry(self, geometry: str | cell.Geometry) -> None:
222222
"""
223223

224224
if geometry is not None:
225-
if isinstance(geometry, cell.Geometry):
225+
if isinstance(geometry, types.Geometry):
226226
geometry = geometry
227227
elif isinstance(geometry, str):
228-
geometry = cell.Geometry.from_mcnp(geometry)
228+
geometry = types.Geometry.from_mcnp(geometry)
229229

230230
if geometry is None:
231231
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION, geometry)
232232

233-
self._geometry: cell.Geometry = geometry
233+
self._geometry: types.Geometry = geometry
234234

235235
@property
236236
def options(self) -> types.Tuple(cell.CellOption):

src/pymcnp/inp/Surface.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22

3-
from . import cell
43
from . import surface
54
from . import _card
65
from .. import _show
@@ -85,7 +84,7 @@ def __and__(a, b):
8584
``Surface`` union.
8685
"""
8786

88-
return cell.Geometry(infix=types.String(f'{a.number}:{b.number}'))
87+
return types.Geometry.from_mcnp(f'{a.number}:{b.number}')
8988

9089
def __or__(a, b):
9190
"""
@@ -99,7 +98,7 @@ def __or__(a, b):
9998
``Surface`` intersection.
10099
"""
101100

102-
return cell.Geometry(infix=types.String(f'{a.number} {b.number}'))
101+
return types.Geometry.from_mcnp(f'{a.number} {b.number}')
103102

104103
def __neg__(self):
105104
"""
@@ -109,7 +108,7 @@ def __neg__(self):
109108
``Surface`` negative.
110109
"""
111110

112-
return cell.Geometry(infix=types.String(f'-{self.number}'))
111+
return types.Geometry.from_mcnp(f'-{self.number}')
113112

114113
def __pos__(self):
115114
"""
@@ -119,7 +118,7 @@ def __pos__(self):
119118
``Surface`` positive.
120119
"""
121120

122-
return cell.Geometry(infix=types.String(f'+{self.number}'))
121+
return types.Geometry.from_mcnp(f'+{self.number}')
123122

124123
def __invert__(self):
125124
"""
@@ -129,7 +128,7 @@ def __invert__(self):
129128
``Surface`` complement.
130129
"""
131130

132-
return cell.Geometry(infix=types.String(f'#{self.number}'))
131+
return types.Geometry.from_mcnp(f'#{self.number}')
133132

134133
@property
135134
def number(self) -> types.Integer:

src/pymcnp/inp/cell/Geometry.py

Lines changed: 0 additions & 178 deletions
This file was deleted.

src/pymcnp/inp/cell/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from .Fill_5 import Fill_5
2626
from .Fill_6 import Fill_6
2727
from .Elpt import Elpt
28-
from .Geometry import Geometry
2928
from .Tmp import Tmp
3029
from .Cosy import Cosy
3130
from .Bflcl import Bflcl
@@ -58,7 +57,6 @@
5857
'Fill_5',
5958
'Fill_6',
6059
'Elpt',
61-
'Geometry',
6260
'Tmp',
6361
'Cosy',
6462
'Bflcl',

src/pymcnp/inp/cell/_entry.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)