Skip to content

Commit 8eafcfa

Browse files
committed
inp/data: fixed edge cases
1 parent 7a0d8a0 commit 8eafcfa

43 files changed

Lines changed: 1377 additions & 178 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

scripts/inp_data.py

Lines changed: 140 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,51 @@ def __init__(
344344
attributes=[
345345
AttributeScheme(
346346
name='transformation',
347-
type='types.Transformation',
347+
type='types.Transformation_0',
348+
description='Cell transformation.',
349+
),
350+
],
351+
),
352+
ElementScheme(
353+
name='trcl_2',
354+
mnemonic='trcl',
355+
attributes=[
356+
AttributeScheme(
357+
name='transformation',
358+
type='types.Transformation_1',
359+
description='Cell transformation.',
360+
),
361+
],
362+
),
363+
ElementScheme(
364+
name='trcl_3',
365+
mnemonic='trcl',
366+
attributes=[
367+
AttributeScheme(
368+
name='transformation',
369+
type='types.Transformation_2',
370+
description='Cell transformation.',
371+
),
372+
],
373+
),
374+
ElementScheme(
375+
name='trcl_4',
376+
mnemonic='trcl',
377+
attributes=[
378+
AttributeScheme(
379+
name='transformation',
380+
type='types.Transformation_3',
381+
description='Cell transformation.',
382+
),
383+
],
384+
),
385+
ElementScheme(
386+
name='trcl_5',
387+
mnemonic='trcl',
388+
attributes=[
389+
AttributeScheme(
390+
name='transformation',
391+
type='types.Transformation_4',
348392
description='Cell transformation.',
349393
),
350394
],
@@ -392,7 +436,7 @@ def __init__(
392436
),
393437
AttributeScheme(
394438
name='transformation',
395-
type='types.Transformation',
439+
type='types.Transformation_0',
396440
description='Cell fill transformation',
397441
optional=True,
398442
),
@@ -401,6 +445,78 @@ def __init__(
401445
ElementScheme(
402446
name='fill_2',
403447
mnemonic='fill',
448+
attributes=[
449+
AttributeScheme(
450+
name='universe',
451+
type='types.Integer',
452+
description='Cell fill universe number',
453+
restriction='0 <= universe <= 99_999_999',
454+
),
455+
AttributeScheme(
456+
name='transformation',
457+
type='types.Transformation_1',
458+
description='Cell fill transformation',
459+
optional=True,
460+
),
461+
],
462+
),
463+
ElementScheme(
464+
name='fill_3',
465+
mnemonic='fill',
466+
attributes=[
467+
AttributeScheme(
468+
name='universe',
469+
type='types.Integer',
470+
description='Cell fill universe number',
471+
restriction='0 <= universe <= 99_999_999',
472+
),
473+
AttributeScheme(
474+
name='transformation',
475+
type='types.Transformation_2',
476+
description='Cell fill transformation',
477+
optional=True,
478+
),
479+
],
480+
),
481+
ElementScheme(
482+
name='fill_4',
483+
mnemonic='fill',
484+
attributes=[
485+
AttributeScheme(
486+
name='universe',
487+
type='types.Integer',
488+
description='Cell fill universe number',
489+
restriction='0 <= universe <= 99_999_999',
490+
),
491+
AttributeScheme(
492+
name='transformation',
493+
type='types.Transformation_3',
494+
description='Cell fill transformation',
495+
optional=True,
496+
),
497+
],
498+
),
499+
ElementScheme(
500+
name='fill_5',
501+
mnemonic='fill',
502+
attributes=[
503+
AttributeScheme(
504+
name='universe',
505+
type='types.Integer',
506+
description='Cell fill universe number',
507+
restriction='0 <= universe <= 99_999_999',
508+
),
509+
AttributeScheme(
510+
name='transformation',
511+
type='types.Transformation_4',
512+
description='Cell fill transformation',
513+
optional=True,
514+
),
515+
],
516+
),
517+
ElementScheme(
518+
name='fill_6',
519+
mnemonic='fill',
404520
attributes=[
405521
AttributeScheme(
406522
name='i',
@@ -423,6 +539,12 @@ def __init__(
423539
description='Fill universe numbers',
424540
restriction='len(universes) == (i.upper - i.lower) * (j.upper - j.lower) * (k.upper - k.lower)',
425541
),
542+
AttributeScheme(
543+
name='m',
544+
type='types.Integer',
545+
description='Displacement vector origin',
546+
optional=True,
547+
)
426548
],
427549
),
428550
ElementScheme(
@@ -4556,31 +4678,31 @@ def from_formula(number: int, formulas: dict[str, float], atomic_or_weight: bool
45564678
name='ides',
45574679
type='types.IntegerOrJump',
45584680
description='Generation of elections by photon controls',
4559-
restriction='ides in {0, 1}',
4681+
restriction='isinstance(types.Jump, ides) and ides in {0, 1}',
45604682
),
45614683
AttributeScheme(
45624684
name='nocoh',
45634685
type='types.IntegerOrJump',
45644686
description='Coherent Thomson scattering controls',
4565-
restriction='nocoh in {0, 1}',
4687+
restriction='isinstance(types.Jump, nocoh) and nocoh in {0, 1}',
45664688
),
45674689
AttributeScheme(
45684690
name='ispn',
45694691
type='types.IntegerOrJump',
45704692
description='Photonuclear particle production controls',
4571-
restriction='ispn in {-1, 0, 1}',
4693+
restriction='isinstance(types.Jump, ispn) and ispn in {-1, 0, 1}',
45724694
),
45734695
AttributeScheme(
45744696
name='nodop',
45754697
type='types.IntegerOrJump',
45764698
description='Photon Doppler energy broadening controls',
4577-
restriction='nodop in {0, 1}',
4699+
restriction='isinstance(types.Jump, nodop) and nodop in {0, 1}',
45784700
),
45794701
AttributeScheme(
45804702
name='fism',
45814703
type='types.IntegerOrJump',
45824704
description='Selection of photofission method controls',
4583-
restriction='fism in {0, 1}',
4705+
restriction='isinstance(types.Jump, fism) and fism in {0, 1}',
45844706
),
45854707
],
45864708
),
@@ -6447,46 +6569,54 @@ def from_formula(number: int, formulas: dict[str, float], atomic_or_weight: bool
64476569
type='types.IntegerOrJump',
64486570
description='Number of source histories per cycle',
64496571
restriction='nsrck >= 0',
6572+
optional=True,
64506573
),
64516574
AttributeScheme(
64526575
name='rkk',
64536576
type='types.RealOrJump',
64546577
description='Initial guess of keff',
6578+
optional=True,
64556579
),
64566580
AttributeScheme(
64576581
name='ikz',
64586582
type='types.IntegerOrJump',
64596583
description='Number of cycles to be skipped before beginning tally accumulation',
6584+
optional=True,
64606585
),
64616586
AttributeScheme(
64626587
name='kct',
64636588
type='types.IntegerOrJump',
64646589
description='Total number of cycles to be done',
64656590
restriction='kct > 0',
6591+
optional=True,
64666592
),
64676593
AttributeScheme(
64686594
name='msrk',
6469-
type='types.IntegerOrJump',
6595+
type='types.Integer',
64706596
description='Number of source points to allocate for',
64716597
restriction='msrk < 40 * nsrck',
6598+
optional=True,
64726599
),
64736600
AttributeScheme(
64746601
name='knrm',
64756602
type='types.IntegerOrJump',
64766603
description='Normalization of tallies setting',
6477-
restriction='knrm.value in {0, 1}',
6604+
restriction='knrm in {0, 1}',
6605+
optional=True,
64786606
),
64796607
AttributeScheme(
64806608
name='mrkp',
64816609
type='types.IntegerOrJump',
64826610
description='Maximum number of cycle values on MCTAL or RUNTPE files',
64836611
restriction='mrkp > 0',
6612+
optional=True,
64846613
),
64856614
AttributeScheme(
64866615
name='kc8',
64876616
type='types.IntegerOrJump',
64886617
description='Number of cylces for average setting',
6489-
restriction='kc8.value in {0, 1}',
6618+
restriction='kc8 in {0, 1}',
6619+
optional=True,
64906620
),
64916621
],
64926622
),

src/pymcnp/Inp.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def from_mcnp(source: str):
129129
for line in tokens[3].strip().split('\n'):
130130
try:
131131
cells_comments.append(inp.Comment.from_mcnp(line))
132-
break
132+
continue
133133
except errors.InpError:
134134
pass
135135

@@ -140,7 +140,7 @@ def from_mcnp(source: str):
140140
for line in tokens[4].strip().split('\n'):
141141
try:
142142
surfaces_comments.append(inp.Comment.from_mcnp(line))
143-
break
143+
continue
144144
except errors.InpError:
145145
pass
146146

@@ -151,7 +151,7 @@ def from_mcnp(source: str):
151151
for line in tokens[5].strip().split('\n'):
152152
try:
153153
data_comments.append(inp.Comment.from_mcnp(line))
154-
break
154+
continue
155155
except errors.InpError:
156156
pass
157157

src/pymcnp/inp/cell/Fill_0.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Fill_0(CellOption_, keyword='fill'):
2121
}
2222

2323
_REGEX = re.compile(
24-
rf'\Afill( {types.Integer._REGEX.pattern})( {types.Integer._REGEX.pattern})?\Z'
24+
rf'\Afill( {types.Integer._REGEX.pattern})( {types.Integer._REGEX.pattern}| [(]{types.Integer._REGEX.pattern}[)])?\Z'
2525
)
2626

2727
def __init__(self, universe: types.Integer, transformation: types.Integer = None):

src/pymcnp/inp/cell/Fill_1.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ class Fill_1(CellOption_, keyword='fill'):
1717

1818
_ATTRS = {
1919
'universe': types.Integer,
20-
'transformation': types.Transformation,
20+
'transformation': types.Transformation_0,
2121
}
2222

2323
_REGEX = re.compile(
24-
rf'\Afill( {types.Integer._REGEX.pattern})( {types.Transformation._REGEX.pattern})?\Z'
24+
rf'\Afill( {types.Integer._REGEX.pattern})( {types.Transformation_0._REGEX.pattern}| [(]{types.Transformation_0._REGEX.pattern}[)])?\Z'
2525
)
2626

27-
def __init__(self, universe: types.Integer, transformation: types.Transformation = None):
27+
def __init__(self, universe: types.Integer, transformation: types.Transformation_0 = None):
2828
"""
2929
Initializes ``Fill_1``.
3030
@@ -47,4 +47,4 @@ def __init__(self, universe: types.Integer, transformation: types.Transformation
4747
)
4848

4949
self.universe: typing.Final[types.Integer] = universe
50-
self.transformation: typing.Final[types.Transformation] = transformation
50+
self.transformation: typing.Final[types.Transformation_0] = transformation

src/pymcnp/inp/cell/Fill_2.py

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,35 @@ class Fill_2(CellOption_, keyword='fill'):
1616
"""
1717

1818
_ATTRS = {
19-
'i': types.Index,
20-
'j': types.Index,
21-
'k': types.Index,
22-
'universes': types.Tuple[types.Integer],
19+
'universe': types.Integer,
20+
'transformation': types.Transformation_1,
2321
}
2422

2523
_REGEX = re.compile(
26-
rf'\Afill( {types.Index._REGEX.pattern})( {types.Index._REGEX.pattern})( {types.Index._REGEX.pattern})((?: {types.Integer._REGEX.pattern})+?)\Z'
24+
rf'\Afill( {types.Integer._REGEX.pattern})( {types.Transformation_1._REGEX.pattern}| [(]{types.Transformation_1._REGEX.pattern}[)])?\Z'
2725
)
2826

29-
def __init__(
30-
self, i: types.Index, j: types.Index, k: types.Index, universes: types.Tuple[types.Integer]
31-
):
27+
def __init__(self, universe: types.Integer, transformation: types.Transformation_1 = None):
3228
"""
3329
Initializes ``Fill_2``.
3430
3531
Parameters:
36-
i: Lattice parameter #1.
37-
j: Lattice parameter #2.
38-
k: Lattice parameter #3.
39-
universes: Fill universe numbers.
32+
universe: Cell fill universe number.
33+
transformation: Cell fill transformation.
4034
4135
Raises:
4236
InpError: SEMANTICS_OPTION_VALUE.
4337
"""
4438

45-
if i is None:
46-
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, i)
47-
if j is None:
48-
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, j)
49-
if k is None:
50-
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, k)
51-
if universes is None or not (
52-
len(universes) == (i.upper - i.lower) * (j.upper - j.lower) * (k.upper - k.lower)
53-
):
54-
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, universes)
39+
if universe is None or not (0 <= universe <= 99_999_999):
40+
raise errors.InpError(errors.InpCode.SEMANTICS_OPTION_VALUE, universe)
5541

5642
self.value: typing.Final[types.Tuple] = types.Tuple(
5743
[
58-
i,
59-
j,
60-
k,
61-
universes,
44+
universe,
45+
transformation,
6246
]
6347
)
6448

65-
self.i: typing.Final[types.Index] = i
66-
self.j: typing.Final[types.Index] = j
67-
self.k: typing.Final[types.Index] = k
68-
self.universes: typing.Final[types.Tuple[types.Integer]] = universes
49+
self.universe: typing.Final[types.Integer] = universe
50+
self.transformation: typing.Final[types.Transformation_1] = transformation

0 commit comments

Comments
 (0)