SteveDoyle2 / pyNastran

A Python-based interface tool for Nastran's file formats
Other
384 stars 147 forks source link

Error in reading an .op4 file created from Superelement run on MSC version >2019. #746

Closed Su-yes closed 8 months ago

Su-yes commented 11 months ago

The .op4 created from V2019 can be read without any issues. The op4 files from version higher than 2019 throws an error in the _read_matrix_binary function. I've tired V2020, 2021, and 2023. I know the content of the op4 files has been updated since the V2019 but I do not know anything about reading binary files to modify the code so it supports the recent versions. I get the following error when attempting the read in the newer versions: NotImplementedError: record_length=4 filename='....\\rocket_se.op4'

Here's is an example file from V2023. Had to zip it since GH doesn't support .op4 files as an attachment. rocket_se.zip

Thank you, Steve. I really appreciate what you do!

SteveDoyle2 commented 11 months ago

I'm not sure. Can you attach the ascii version of it? The op4 is a bit cryptic.

I threw in a few prints and it looks like it gets most of it.

reading binary matrix KAA; matrix_type = Real, Double Precision reading binary matrix MAA; matrix_type = Real, Double Precision reading binary matrix BXX; matrix_type = Real, Double Precision reading binary matrix K4XX; matrix_type = Real, Double Precision reading binary matrix PX; matrix_type = Real, Double Precision reading binary matrix GPXX; matrix_type = Real, Double Precision reading binary matrix GDXX; matrix_type = Real, Double Precision reading binary matrix VAFX; matrix_type = Real, Double Precision reading binary matrix AX; matrix_type = Real, Double Precision reading binary matrix RVAX; matrix_type = Real, Double Precision reading binary matrix KASMX; matrix_type = Real, Double Precision reading binary matrix MASMX; matrix_type = Real, Double Precision reading binary matrix PHBX; matrix_type = Real, Double Precision reading binary matrix VA; matrix_type = Real, Double Precision reading binary matrix MUG1; matrix_type = Real, Double Precision reading binary matrix MUG1O; matrix_type = Real, Double Precision reading binary matrix MELAF1; matrix_type = Real, Double Precision reading binary matrix MES1; matrix_type = Real, Double Precision reading binary matrix MES1O; matrix_type = Real, Double Precision reading binary matrix MEF1; matrix_type = Real, Double Precision reading binary matrix MEF1O; matrix_type = Real, Double Precision reading binary matrix MKQG1; matrix_type = Real, Double Precision reading binary matrix MKQG1O; matrix_type = Real, Double Precision reading binary matrix MMQG1; matrix_type = Real, Double Precision reading binary matrix MBQG1; matrix_type = Real, Double Precision reading binary matrix MK4QG1; matrix_type = Real, Double Precision reading binary matrix MUG1B; matrix_type = Real, Double Precision reading binary matrix MUG1OB; matrix_type = Real, Double Precision reading binary matrix MEE1; matrix_type = Real, Double Precision reading binary matrix MEE1O; matrix_type = Real, Double Precision reading binary matrix MKQMG1; matrix_type = Real, Double Precision reading binary matrix MKQMG1O; matrix_type = Real, Double Precision reading binary matrix MMQMG1; matrix_type = Real, Double Precision reading binary matrix MBQMG1; matrix_type = Real, Double Precision reading binary matrix MK4QMG1; matrix_type = Real, Double Precision reading binary matrix MMNP3; matrix_type = Real, Double Precision reading binary matrix MMNP3O; matrix_type = Real, Double Precision reading binary matrix MMNP1; matrix_type = Real, Double Precision reading binary matrix MMNP1IS; matrix_type = Real, Double Precision reading binary matrix MMNP1ID; matrix_type = Real, Double Precision reading binary matrix MMNPD; matrix_type = Real, Double Precision reading binary matrix MMNPDO; matrix_type = Real, Double Precision reading binary matrix MMNP2; matrix_type = Real, Double Precision reading binary matrix MMNP2O; matrix_type = Real, Double Precision

... strings(s) = (b'\x02\x00\x00\x00\x04\x00\x00\x00\x08\x00\x00\x00 TMNP3 \x08\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x04\x00\x0 MPIDUM \x08\x00\x00\x00\x04\x00\x00\x00\xfd\xff\xff\xff\x04\x00\x0 DUMMY \x0 TMNP1 \x08\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x04\x00\x0 MPIDUM \x08\x00\x00\x00\x04\x00\x00\x00\xfd\xff\xff\xff\x04\x00\x0 DUMMY \x0 TMNPD \x08\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x04\x00\x0 MPIDUM \x08\x00\x00\x00\x04\x00\x00\x00\xfd\xff\xff\xff\x04\x00\x0 DUMMY \x0 ....

Su-yes commented 11 months ago

Thank you for looking into this, Steve! Here's a formatted version of the op4 file.

rocket_se_formatted.zip

Thanks!

SteveDoyle2 commented 11 months ago

If you look at the end of your file, you'll see a bunch of garbage. You're probably writing data to the op4 that you should be writing to the op2.

I've definitely run into that in the past.

Su-yes commented 11 months ago

ahhh...interesting. Thank you for catching this. NASTRAN has no problem handling the fie but I like to read in the matrices in Python to do my work. op4 binary format is how I exchange the files with team so I might have to find a way to tweak your code to just ignore the garbage data. Could you point me to the section in the read_op4_binary method where I might able to make the changes to read this file properly? Thank you!

SteveDoyle2 commented 11 months ago

MSC might be able to tell you what’s going on, but again, I think you’re writing data to the file that is not a sparse/dense matrix of real/complex numbers. That or you’re writing op2 data to the op4 file.

On Mon, Sep 25, 2023 at 7:33 AM Su-yes @.***> wrote:

ahhh...interesting. Thank you for catching this. NASTRAN has no problem handling the fie but I like to read in the matrices in Python to do my work. op4 binary format is how I exchange the files with team so I might have to find a way to tweak your code to just ignore the garbage data. Could you point me to the method where I might able to make the changes to read this file properly? Thank you!

— Reply to this email directly, view it on GitHub https://github.com/SteveDoyle2/pyNastran/issues/746#issuecomment-1733836512, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAICUWOVV2O4CTHMKYWYTK3X4GIZZANCNFSM6AAAAAA5BWW7V4 . You are receiving this because you commented.Message ID: @.***>

Su-yes commented 11 months ago

MSC wasn't able to help either. They just told me they were aware of this and under consideration to be fixed. Looks like I will have to stick with the V2019 to create the op4 file for now. Thank you for the help, Steve!