Skip to content

Parsing Error with Material library keywords #7

@MicahGale

Description

@MicahGale

I ran:

import pymcnp
pymcnp.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, in File.from_file(cls, filename)
     28     raise errors.CliError(errors.CliCode.RUNTIME_PATH, filename)
     30 source = filename.read_text()
---> 32 return cls.from_mcnp(source)

File ~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/Inp.py:234, in Inp.from_mcnp(source)
    232 cells = types.Tuple(Cell)(tuple(Cell.from_mcnp(token) for token in tokens[3].strip().split('\n')))
    233 surfaces = types.Tuple(Surface)(tuple(Surface.from_mcnp(token) for token in tokens[4].strip().split('\n')))
--> 234 data = types.Tuple(Data)(tuple(Data.from_mcnp(token) for token in tokens[5].strip().split('\n')))
    235 other = types.String.from_mcnp(tokens[6]) if tokens[6] else None
    237 return Inp(
    238     title,
    239     cells,
   (...)
    243     other=other,
    244 )

File ~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/Inp.py:234, in <genexpr>(.0)
    232 cells = types.Tuple(Cell)(tuple(Cell.from_mcnp(token) for token in tokens[3].strip().split('\n')))
    233 surfaces = types.Tuple(Surface)(tuple(Surface.from_mcnp(token) for token in tokens[4].strip().split('\n')))
--> 234 data = types.Tuple(Data)(tuple(Data.from_mcnp(token) for token in tokens[5].strip().split('\n')))
    235 other = types.String.from_mcnp(tokens[6]) if tokens[6] else None
    237 return Inp(
    238     title,
    239     cells,
   (...)
    243     other=other,
    244 )

File ~/mambaforge/envs/pymcnp/lib/python3.12/site-packages/pymcnp/types/Union.py:50, in Union.<locals>._Union.from_mcnp(cls, source)
     48         pass
     49 else:
---> 50     raise errors.TypesError(errors.TypesCode.SYNTAX_TYPE, source)

TypesError: MCNP data type not recognized.
> m2 26054.80c 5.85     plib 80p 26056 91.75 26057 2.12 26058.80c 0.28 $ very very very very very very very very very very very very very very long line that exceeds line limit $ trailing comment shouldn't move #458

This is a follow-up to #3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions