Skip to content

Commit 2ec9663

Browse files
committed
inp: added imp check
1 parent df28aba commit 2ec9663

File tree

10 files changed

+92
-8
lines changed

10 files changed

+92
-8
lines changed

examples/create_inp.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@
4545
material_lead = pymcnp.inp.M_0.from_formula(formulas={'Pb': 1})
4646

4747
# Creating cells.
48-
cell_inside = pymcnp.inp.Cell(material=0, geometry=-surface_inner)
49-
cell_shield = pymcnp.inp.Cell(material=material_lead, density=0.5, geometry=+surface_inner & -surface_outer)
50-
cell_air = pymcnp.inp.Cell(material=material_air, density=0.5, geometry=-surface_inner | (+surface_outer & -surface_world))
51-
cell_world = pymcnp.inp.Cell(material=0, geometry=+surface_world)
48+
imp = pymcnp.inp.cell.Imp(designator='n', importance=1)
49+
cell_inside = pymcnp.inp.Cell(material=0, geometry=-surface_inner, options=[imp])
50+
cell_shield = pymcnp.inp.Cell(material=material_lead, density=0.5, geometry=+surface_inner & -surface_outer, options=[imp])
51+
cell_air = pymcnp.inp.Cell(material=material_air, density=0.5, geometry=-surface_inner | (+surface_outer & -surface_world), options=[imp])
52+
cell_world = pymcnp.inp.Cell(material=0, geometry=+surface_world, options=[imp])
5253

5354
# Creating source.
5455
source = pymcnp.inp.Sdef(

examples/read_inp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
"""
2323
Create `Inp`
2424
25-
1 0 -12
26-
2 23 0.5 +12:-13
27-
3 21 0.5 -12 +13:-14
28-
4 0 +14
25+
1 0 -12 imp:n=1
26+
2 23 0.5 +12:-13 imp:n=1
27+
3 21 0.5 -12 +13:-14 imp:n=1
28+
4 0 +14 imp:n=1
2929
3030
12 rpp -5 5 -5 5 -5 5
3131
13 rpp -1 1 -1 1 -1 1

files/inp/todo_03.inp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Test of Cube with hole; lnk3dnt file being imported
2+
C Cell Cards
3+
10 1 -2.03 0 u=2 $ inferred geometry cell
4+
11 1 -2.03 0 u=2 $ inferred geometry cell
5+
12 1 -2.03 0 u=2 $ inferred geometry cell
6+
13 1 -2.03 0 u=2 $ inferred geometry cell
7+
14 1 -2.03 0 u=2 $ inferred geometry cell
8+
15 1 -2.03 0 u=2 $ inferred geometry cell
9+
21 0 0 u=2 $ inferred background cell
10+
30 0 -99 fill=2 $ fill cell
11+
40 0 99
12+
13+
C Surface Cards
14+
99 sph 0. 0. 3. 10.
15+
16+
c Data Cards
17+
m1 1001 -0.02 8016 -0.60 14000 -0.38
18+
c
19+
embed2 meshgeo= abaqus
20+
meeout= sample01.eeout
21+
gmvfile= sample01.gmv
22+
filetype= binary
23+
background= 21
24+
matcell= 1 10 2 11 3 12 4 13 5 14 6 15
25+
c
26+
embee4:n embed=2
27+
embtb4 1 2 3 4 5 1e+39
28+
embeb4 0.1 1.0 1e+10
29+
30+
(MCNP Manual 6.2 Section 3.3.1.6.2)

files/inp/todo_30.inp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
EXAMPLE 43
2+
1 0 -1 -2 3 13 fill=4
3+
2 0 -1 -2 3 -13 fill=1
4+
3 0 -4 5 -6 7 u=1 lat=1
5+
fill=-2:2 -2:0 0:0 1 1 3 1 1 1 3 2 3 1 3 2 3 2 3
6+
4 0 -8 9 -10 11 u=2 fill=3 lat=1
7+
5 1 -0.1 -12 u=3
8+
6 0 12 u=3
9+
7 0 -14 -2 3 u=4 fill=3 trcl=(-60 40 0)
10+
8 like 7 but trcl=(-30 40 0)
11+
9 like 7 but trcl=(0 40 0)
12+
10 like 7 but trcl=(30 40 0)
13+
11 like 7 but trcl=(60 40 0)
14+
12 0 #7 #8 #9 #10 #11 u=4
15+
13 0 1:2:-3
16+
17+
1 cz 100
18+
2 pz 100
19+
3 pz -100
20+
4 px 20
21+
5 px -20
22+
6 py 20
23+
7 py -20
24+
8 px 10
25+
9 px -10
26+
10 py 10
27+
11 py -10
28+
12 cz 5
29+
13 py 19.9
30+
14 cz 10
31+
32+
c f4:n 5 6 (5 6 3) $ 3 bins
33+
c (5<3) (5<(3[-2:2 -2:0 0:0])) $2 bins
34+
c (5<(7 8 9 10 11)) (5<7 8 9 10 11<1) (5<1) $7 bins
35+
c ((5 6)<3[0 -1 0]) ((5 6)<3[0:0 -1:-1 0:0]) ((5 6)<3[8]) $3 bins
36+
c (5<(4[0 0 0]3[8]))(5<4[0 0 0]<3[8])
37+
c (3<(3[1]3[2]3[4]3[5]3[6]3[10])) $3 bins
38+
c (5<u=3) $12 bins
39+
40+
(MCNP Manual 6.2 Section 4.2.6)

src/pymcnp/Inp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ def cells(self, cells: list[str] | list[inp.Cell | inp.Like | inp.Comment]) -> N
420420
if cells is None or None in cells:
421421
raise errors.InpError(errors.InpCode.SEMANTICS_FILE, cells)
422422

423+
if all(isinstance(cell, inp.Cell) and (not cell.options or not any(isinstance(option, inp.cell.Imp) for option in cell.options)) for cell in cells) and (
424+
not hasattr(self, '_data') or all(isinstance(data, inp.data.Imp) for data in self.data)
425+
):
426+
raise errors.InpError(errors.InpCode.SEMANTICS_FILE, cells)
427+
423428
self._cells: types.Tuple(Cell) = cells
424429

425430
@property

tests/test_pymcnp/test_Inp.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ class Test_Init(classes.Test_Init):
7575
'message': consts.string.types.STRING,
7676
'other': consts.string.types.STRING,
7777
},
78+
{
79+
'title': consts.string.types.STRING,
80+
'cells': ['1 0 1'],
81+
'surfaces': [consts.string.inp.SURFACE, consts.string.inp.COMMENT],
82+
'data': [consts.string.inp.VOL, consts.string.inp.COMMENT],
83+
'message': consts.string.types.STRING,
84+
'other': consts.string.types.STRING,
85+
},
7886
]
7987

8088
class Test_Properties:

0 commit comments

Comments
 (0)