Trouble reading op2 data

72 views
Skip to first unread message

Brian Russell

unread,
Dec 12, 2024, 12:02:47 AM12/12/24
to pyNastran Discuss
Hi Steve,

I am running into an issue reading the contents of an op2 file and not sure what is causing the issue.  Have successfully read .op2 files containing nonlinear stress data in the past.  Any insight into what is causing this?  Thanks in advance!

DEBUG:   op2_reader.py:299            date = (12, 10, 24)
DEBUG:   op2_reader.py:382            mode='nx' version='2020.1'
DEBUG:   op2_scalar.py:2172             table_name=b'PVT0'     (PARAM cards)
DEBUG:   op2_scalar.py:2172             table_name=b'CASECC'   (case control)
DEBUG:   op2_scalar.py:2172             table_name=b'EQEXINS'  (internal/external ids (superelement))
DEBUG:   op2_reader.py:653            eqexin idata=(101, 339401, 0, 0, 0, 0, 0)
DEBUG:   op2_scalar.py:2172             table_name=b'OGPWG'    (grid point weight)
DEBUG:   op2_scalar.py:2172             table_name=b'OQG1'     (spc/mpc forces)
DEBUG:   op2_scalar.py:2172             table_name=b'OUGV1'    (g-set U in CD frame)
DEBUG:   op2_scalar.py:2172             table_name=b'OEF1X'    (element force at intermediate stations)
DEBUG:   op2_scalar.py:2172             table_name=b'OES1X1'   (nonlinear stress)
failed reading b'OES1X1' isubtable=-1542
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\tkinter\__init__.py", line 1967, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\Desktop\hapi\src\hapi\GUIs\post_analysis_tool_guis\op2_summary_report_gui.py", line 39, in run_examine_op2_tool
    op2_tools.create_op2_contents_report(result_paths,
  File "C:\Users\BrianRussell\Desktop\hapi\src\hapi\analyses\nastran\post_tools\op2\op2_tools.py", line 26, in create_op2_contents_report
    op2_data = result.read_op2(exclude_list)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\Desktop\hapi\src\hapi\analyses\nastran\analysis_nastran.py", line 116, in read_op2
    op2_data = read_op2(op2_name, exclude_results=exclude_results)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2.py", line 1424, in read_op2
    model.read_op2(op2_filename=op2_filename, build_dataframe=build_dataframe,
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2.py", line 600, in read_op2
    table_names = OP2_Scalar.read_op2(self, op2_filename=op2_filename,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_scalar.py", line 1998, in read_op2
    self._read_tables(table_name, table_names)
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_scalar.py", line 2194, in _read_tables
    op2_reader.read_results_table()
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 3510, in read_results_table
    self.read_results_table4()
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 3535, in read_results_table4
    self._read_subtables()
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 3751, in _read_subtables
    self._read_subtable_3_4(table3_parser, table4_parser, passer)
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 3852, in _read_subtable_3_4
    record_len = self._get_record_length()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 3438, in _get_record_length
    markers1 = self.get_nmarkers(1, rewind=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 2495, in get_nmarkers
    return self.get_nmarkers4(n, rewind=rewind, macro_rewind=macro_rewind)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 2519, in get_nmarkers4
    data = self.read_block4()
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\op2_interface\op2_reader.py", line 3032, in read_block4
    ndata, = op2.struct_i.unpack(data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes
Screenshot 2024-12-11 144631.png

steve

unread,
Dec 12, 2024, 12:09:42 AM12/12/24
to pyNastran Discuss
You're failing getting the table data, which is done prior to parsing it. That part is very robust, but without a example it's hard to say.

You can run:
    test_op2 fem.op2 -b

to dump a file that will at least say was pulled on the table before that.

Brian Russell

unread,
Dec 12, 2024, 6:08:44 PM12/12/24
to pyNastran Discuss
Steve - Thanks for getting back to me so quickly.  I tried what you suggested and I got a short summary of some values from the FEM results, but then the same error:

PS C:\Users\BrianRussell\Desktop> test_op2 .\fem.op2 -b
OP2_FILENAME = '.\\fem.op2'
autodesk     = False
binarydebug  = True
debug        = False
disablecompare = False
exclude      = []
geometry     = False
help         = False
include      = []
is_mag_phase = False
is_sort2     = False
load_hdf5    = False
nasa95       = False
nocombine    = False
nx           = False
optistruct   = False
pandas       = False
post         = None
profile      = False
quiet        = False
safe         = False
short_stats  = False
subcase      = None
test         = False
version      = False
write_bdf    = False
write_f06    = False
write_hdf5   = False
write_op2    = False
write_xlsx   = False
INFO:    op2_scalar.py:1963           op2_filename = '.\\fem.op2'

failed reading b'OES1X1' isubtable=-1542
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Scripts\test_op2.exe\__main__.py", line 7, in <module>
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\test\test_op2.py", line 878, in main
    run_op2(
  File "C:\Users\BrianRussell\AppData\Local\Programs\Python\Python312\Lib\site-packages\pyNastran\op2\test\test_op2.py", line 326, in run_op2
    op2_nv.read_op2(op2_filename, combine=combine)
Screenshot 2024-12-12 092028.png

Brian Russell

unread,
Dec 12, 2024, 6:08:47 PM12/12/24
to pyNastran Discuss
Steve - Just wanted to let you know we figured out that the .op2 file we were trying to read had been cut off during the file transfer without anyone noticing so we were trying to read an incomplete file.  Sorry to have bugged you about something that was 100% on our end.  Thanks again for getting back to me and tremendous thanks for writing pyNastran and making it available.  Really, really impressive software to open source.

Best Regards,
Brian Russell

On Wednesday, December 11, 2024 at 9:09:42 PM UTC-8 steve wrote:

Steven Doyle

unread,
Dec 12, 2024, 9:02:55 PM12/12/24
to pynastra...@googlegroups.com
Oh yeah…that’ll do it!

The binary debug is a separate file. It can tell you things like if it’s working on time step 0.1, so it can help out, but mostly it’s a shot in the dark.

--
You received this message because you are subscribed to the Google Groups "pyNastran Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pynastran-disc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pynastran-discuss/062efb5c-14e0-43e1-b0a4-341861795fa5n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages