idaholab / MontePy

MontePy is the most user friendly Python library (API) to read, edit, and write MCNP input files.
https://www.montepy.org/
MIT License
32 stars 7 forks source link

Fail to parse FQ cards #584

Open dodu94 opened 1 month ago

dodu94 commented 1 month ago

Describe the bug

It seems that montepy is not able to parse correctly FQ cards

To Reproduce

problem = montepy.read_input("foo.imcnp")

Error Message (if any)

Traceback (most recent call last):
  File "D:\DATA\laghida\Documents\test\profiler_cmodel.py", line 11, in <module>
    problem = montepy.read_input(input_file)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\input_parser\input_reader.py", line 31, in read_input
    problem.parse_input(replace=replace)
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\mcnp_problem.py", line 382, in parse_input
    raise e
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\mcnp_problem.py", line 367, in parse_input
    obj = obj_parser(input)
          ^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\data_inputs\data_parser.py", line 47, in parse_data
    return data_input.DataInput(input, prefix=prefix)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\data_inputs\data_input.py", line 340, in __init__
    super().__init__(input, fast_parse)
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\data_inputs\data_input.py", line 58, in __init__
    super().__init__(input, self._parser)
  File "C:\ProgramData\Anaconda3\envs\monte\Lib\site-packages\montepy\mcnp_object.py", line 59, in __init__
    raise ParsingError(
montepy.errors.ParsingError:     test.i, line 13

        14| FQ11    s u
        15| C
The input ended prematurely.
sly: Parse error in input. EOF

MCNP input file snippet

If applicable, please include a small section of the input file you were working on. If it includes any specific values please change or remove them. For example:

TEST
1 0 -1 IMP:N=1
2 0 1 IMP:N=0

1 SO 20

NPS 1
MODE N
C
FC11    Neutron current
F11:N   1
FT11    INC
FU11    0 1
FM11    1.9730E+19
FQ11    s u
C

Version

MicahGale commented 1 month ago

Thanks @dodu94. This doesn't surprise me with how FQ syntax is. This should be tackled with #11.

Though a stop gap measure is probably a good idea.

dodu94 commented 1 month ago

I quickly went through #11 and, if I understand correctly, that is about having a full support of tallies. I support that, but in the meantime I guess montepy should just recognize FQ simply as a data card without knowing what it is exactly and just go on with the parsing right?

MicahGale commented 1 month ago

Yes. It's just that we don't have a rule for a data input that is all text right now. So yes we'll do a stop gap measure to just make it parsable and not error out.