Skip to content

Parsing Error with Material library keywords #7

Description

@MicahGale

I ran:

importpymcnppymcnp.Inp.from_file("test.imcnp")

With the file:

MCNP Test Model for MOAA
C cells
c # hidden vertical Do not touch
c
1 1 20
-1000 $ dollar comment
imp:n,p=1 U=350 trcl=5
2 2 8
-1005 -1015 1020 -1025
imp:n=1
imp:p=0.5
3 3 -1
1000 1005 -1010
imp:n,p=1
99 0
1010
imp:n,p=0
5 0
#99
imp:n,p=3 fill=350 (1 0 0 )
c foo end comment
C surfaces
1000 SO 1
1005 RCC 0 1.5 -0.5 0 0 1 0.25
1010 SO 3
1015 CZ 5.0
1020 PZ 10
1025 PZ 15
C data
C materials
C UO2 5 atpt enriched
m1 92235.80c 5 &
92238.80c 95
C Iron
m2 26054.80c 5.85
plib= 80p
26056 91.75
26057 2.12 $ very very very very very very very very very very very very very very long line that exceeds line limit
26058.80c 0.28 $ trailing comment shouldn't move #458.
C water
C foo valid input up to the line length limit
m3 1001.80c 2.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
8016.80c 1
plib=84p
MT3 lwtr.23t h-zr.20t h/zr.28t
C tallies
fc1 Surface current
f1:n,p 1000
fc2 Average surface flux
f2:p 1005
fc4 2-group flux
f4:n 1 2 3
e4 0.625e-6
f6:p 1
f7:n 1
C execution
ksrc 0 0 0
kcode 100000 1.000 50 1050
phys:p j 1 2j 1
mode n p
vol NO 2J 1 1.5 J

This leads to the error:

File~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/_file.py:32, inFile.from_file(cls, filename)
28raiseerrors.CliError(errors.CliCode.RUNTIME_PATH, filename)
30source=filename.read_text()
--->32returncls.from_mcnp(source)
File~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/Inp.py:234, inInp.from_mcnp(source)
232cells=types.Tuple(Cell)(tuple(Cell.from_mcnp(token) fortokenintokens[3].strip().split('\n')))
233surfaces=types.Tuple(Surface)(tuple(Surface.from_mcnp(token) fortokenintokens[4].strip().split('\n')))
-->234data=types.Tuple(Data)(tuple(Data.from_mcnp(token) fortokenintokens[5].strip().split('\n')))
235other=types.String.from_mcnp(tokens[6]) iftokens[6] elseNone237returnInp(
238title,
239cells,
(...)
243other=other,
244 )
File~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/Inp.py:234, in<genexpr>(.0)
232cells=types.Tuple(Cell)(tuple(Cell.from_mcnp(token) fortokenintokens[3].strip().split('\n')))
233surfaces=types.Tuple(Surface)(tuple(Surface.from_mcnp(token) fortokenintokens[4].strip().split('\n')))
-->234data=types.Tuple(Data)(tuple(Data.from_mcnp(token) fortokenintokens[5].strip().split('\n')))
235other=types.String.from_mcnp(tokens[6]) iftokens[6] elseNone237returnInp(
238title,
239cells,
(...)
243other=other,
244 )
File~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/types/Union.py:50, inUnion.<locals>._Union.from_mcnp(cls, source)
48pass49else:
--->50raiseerrors.TypesError(errors.TypesCode.SYNTAX_TYPE, source)
TypesError: MCNPdatatypenotrecognized.
>m226054.80c5.85plib80p2605691.75260572.1226058.80c0.28 $ veryveryveryveryveryveryveryveryveryveryveryveryveryverylonglinethatexceedslinelimit $ trailingcommentshouldn'tmove#458

This is a follow-up to #3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions