pyNastran icon indicating copy to clipboard operation
pyNastran copied to clipboard

Issue reading OSTR1 matrix

Open leakec opened this issue 5 months ago • 1 comments

I'm getting the following error when reading an op2 file with the OSTR1 matrix.

failed reading b'OSTR1' isubtable=-4
Traceback (most recent call last):
  File "/hdd/Downloads/pyNastran/test.py", line 4, in <module>
    op2.read_op2("recovery.op2")
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2.py", line 601, in read_op2
    table_names = OP2_Scalar.read_op2(self, op2_filename=op2_filename,
                                      load_as_h5=load_as_h5, mode=mode)
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2_interface/op2_scalar.py", line 1998, in read_op2
    self._read_tables(table_name, table_names)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2_interface/op2_scalar.py", line 2194, in _read_tables
    op2_reader.read_results_table()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2_interface/op2_reader.py", line 3513, in read_results_table
    self.read_results_table4()
    ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2_interface/op2_reader.py", line 3540, in read_results_table4
    self._read_subtables()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2_interface/op2_reader.py", line 3763, in _read_subtables
    self._read_subtable_3_4(table3_parser, table4_parser, passer)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/op2_interface/op2_reader.py", line 3937, in _read_subtable_3_4
    unused_n = op2._read_subtable_results(table4_parser, record_len)
  File "/hdd/Downloads/pyNastran/pyNastran/op2/fortran_format.py", line 180, in _read_subtable_results
    n = table4_parser(data, ndata)
  File "/hdd/Downloads/pyNastran/pyNastran/op2/tables/oes_stressStrain/oes.py", line 584, in _read_ostr1_4
    n = self._read_ostr_4_sort(data, ndata)
  File "/hdd/Downloads/pyNastran/pyNastran/op2/tables/oes_stressStrain/oes.py", line 687, in _read_ostr_4_sort
    n = self._read_oes1_loads(data, ndata)
  File "/hdd/Downloads/pyNastran/pyNastran/op2/tables/oes_stressStrain/oes.py", line 1518, in _read_oes1_loads
    n, nelements, ntotal = self._oes_cbeam(data, ndata, dt, is_magnitude_phase,
                           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                           result_type, prefix, postfix)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/hdd/Downloads/pyNastran/pyNastran/op2/tables/oes_stressStrain/oes.py", line 2293, in _oes_cbeam
    assert table_name_bytes in TABLES_BYTES, table_name_bytes
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: b'OSTR1'

The error is technically on an unsupported Nastran version (NX 2412.5); however, I believe it will affect all versions, as the OSTR1 matrix is a cbeam strain matrix. I was able to get this working by just including OSTR1 in the op2_codes.

I will submit a merge request with this change shortly, as it fixes the bug and allows me to read the entire file. I can also upload a reg test that reads this op2 file after the fix. I will do these in separate commits, in case it's better to split it off into a simpler unit test that just reads that matrix.

leakec avatar Jun 14 '25 14:06 leakec

PR submitted. The op2 file I mentioned above is added to the test case in this commit of the PR.

leakec avatar Jun 14 '25 15:06 leakec

Fixed by @SteveDoyle2 in https://github.com/SteveDoyle2/pyNastran/commit/057b73b584e20b63839ee5f210c09e2e9d65e1ae. Thank you!

leakec avatar Jun 23 '25 13:06 leakec