SteveDoyle2 / pyNastran

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

op2 reader fails when reading version/mode from custom OUTPUT2 files #782

Closed M4Nascenzi closed 4 months ago

M4Nascenzi commented 4 months ago

I am trying to read a DSCMCOL table written to an op2 file. When it tries to read the op2, the code fails to read the version/mode. I tried setting the mode when initializing the op2 python object, but that did not help.

Maybe I'm missing something, but I imagine pyNastran should just not attempt to read the mode/version if the user manually sets it. Let me know if you need an example op2 and I will email one to you.

Nastran file: ASSIGN OUTPUT2 = 'dscmcol.op2', UNIT = 95, UNFORMATTED ...ALTER... OUTPUT2 DSCMCOL,,,,//-1/95/'DSCMCOL' OUTPUT2 ,,,,//-9/95 ... Python script: op2=OP2(mode='nx') op2.read_op2('dscmcol.op2')

SteveDoyle2 commented 4 months ago

Looks like you're going into the title block (the first block). It's expecting a [4, 2, 4], [4, 4, 4] at the top, which you can make by writing a 2 and -4 in separate write commands. Not really sure how to do that though. ATA uses the forum, so it's worth asking there.

Alternatively, you could ditch the OUTPUT2 alter and try:

DSAPRT(NOPRINT,EXPORT,END=SENS)

Looks like the param,iunit,95 is also useful image

SteveDoyle2 commented 4 months ago

Oh, nevermind. You do have the title/nastran fort tape code, but you don't list a nastran version. Are you on a new version of Nastran?

M4Nascenzi commented 4 months ago

Thanks for getting back to me Steve.

I am using Siemens Simcenter Nastran 2312. pyNastran can read the main/regular op2 file fine.

Is it intended to read the version/mode even if the user specifies it? If that is the case, why is the user allowed to specify the mode to begin with?

I'm aware of DSAPRT and param,iunit,95 (and pyNastran reads the dscmcol table fine when it is printed to the main/regular op2), but I figured I'd try to get the sensitivity data in its own file to limit the amount of data being read in Python. (It probably is a miniscule amount of efficiency gain, but if the solution is easy and I've already come this far, I figure I might as well continue. If it isn't an easy fix, I'll probably just give up)

SteveDoyle2 commented 4 months ago

That’s the pynastran op2 writer, so it’s not using that code to read it. Mode doesn’t affect the header, so there is an issue with the way the file was written.

Maybe is misunderstood your file units. Set the iunit to the file you want the result to go to. I don’t have access to Nastran, so I can’t debug your DMAP call. You’ll probably get an answer in the forum if you provide enough info.

On Tue, Apr 30, 2024 at 4:35 PM M4Nascenzi @.***> wrote:

Thanks for getting back to me Steve.

I am using Siemens Simcenter Nastran 2312. pyNastran can read the main/regular op2 file fine.

Is it intended to read the version/mode even if the user specifies it? If that is the case, why is the user allowed to specify the mode to begin with?

I'm aware of DSAPRT and param,iunit,95 (and pyNastran reads the dscmcol table fine when it is printed to the main/regular op2), but I figured I'd try to get the sensitivity data in its own file to limit the amount of data being read in Python. (It probably is a miniscule amount of efficiency gain, but if the solution is easy and I've already come this far, I figure I might as well continue. If it isn't an easy fix, I'll probably just give up)

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

SteveDoyle2 commented 4 months ago

This code cause github is bad with 2 pics:

image

The provided op2 has been flagged with the post=-1 option and is nearly complete. It's missing a version, which is throwing things off. The file was probably created wrong in some way, but you should be able to use DSAPRT to get what you want (and have it go to an independent file).

M4Nascenzi commented 4 months ago

Alright, I did some tests. I tried parsing the DSAPRT version of the file and the OUTPUT2 version of the file. I did it with MSC NASTRAN 2021.3, Simcenter Nastran 2312, and Simcenter Nastran 2020.1. Both versions of Simcenter Nastran behaved the same. I also tried it with a range of ITAPE and POST parameters (just in case). I also tried it with modified version of pynastran that ignores version reading if the mode is specified. With an unmodified pyNastran, it can only parse the OUTPUT2 version from MSC nastran.

Here are the results:

with dsaprt: msc: bad closer _ERROR: op2_reader.py:2986 finished table_name = b'DSCMCOL' ERROR: op2reader.py:2991 There was a Nastran FATAL Error. Check the F06. last table=b'DSCMCOL'; post=-2 version='msc' simcenter: bad header RuntimeError: unknown version=b'DSCMCOL' simcenter and force mode to 'nx': bad closer _ERROR: op2_reader.py:2986 finished table_name = b'DSCMCOL' ERROR: op2reader.py:2991 There was a Nastran FATAL Error. Check the F06. last table=b'DSCMCOL'; post=-1 version='nx'

with DSCMCOL and file closer OUTPUT2 commands msc: works simcenter: bad header RuntimeError: unknown version=b'DSCMCOL' simcenter and force mode to 'nx': works

SteveDoyle2 commented 4 months ago

You should try writing the version yourself. You're missing a version string and I think a -1,0 to close the header table (which will write 4,0,4, 4,-1,4).

This is interesting. Label=XXXXXXXX is the flag for MSC Nastran, so presumably you can change that to '2312 ' (8 characters) and it'll work. The version doesn't matter all that much though.

image

I'd start with this

OUTPUT2 ,,,,, //-9/12/ $

The more directly you can write the file, the easier it will be to fix it.

M4Nascenzi commented 4 months ago

I think I'm catching on (and after re-reading your previous post, I think you've already figured it out). It looks like pyNastran is just reading the file label (LABL). I was labeling the output as DSCMCOL, so it read the version as DSCMCOL. This also appears to be something that you've somewhat accounted for in the code. In _parse_nastran_version_8 you have MSC_VERSIONS which includes 'XXXXXXXX'. This is just the default LABL that gets printed. So, if I don't specify a label, pyNastran reads 'XXXXXXXX' and assumes it is MSC. I could also label it 'nx', and pyNastran would assume it is NX. It also works if I don't write a label at all (assumes mode = msc).

I'll also add that in NX, the DSAPRT creates the file with the label 'DSCMCOL', while in MSC the DSARPT creates the file with no label (which nastran parses fine).

SteveDoyle2 commented 4 months ago

Oh ok. Yeah that’s where MSC and NX put the version. It was XXXXXXXX for MSC for like 10 years before they switched in ~2014. NX has been writing it that way since at least NX8.5. IMAT and Optistruct do the same thing.

On Wed, May 1, 2024 at 4:25 PM M4Nascenzi @.***> wrote:

Ok, I think I figured out what is going on. I believe what you are reading as the version is actually the file label (LABL). I was labeling the output as DSCMCOL, so it read the version as DSCMCOL. This also appears to be something that you've somewhat accounted for in the code. In _parse_nastran_version_8 you have MSC_VERSIONS which includes 'XXXXXXXX'. This is just the default LABL that gets printed. So, if I don't specify a label, pyNastran reads 'XXXXXXXX' and assumes it is MSC. I could also label it 'nx', and pyNastran would assume it is NX.

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

SteveDoyle2 commented 4 months ago

I think this is done. Pretty sure it just means that you just do this.

ASSIGN OUTPUT2 = 'dscmcol.op2', UNIT = 95, UNFORMATTED
...ALTER...
OUTPUT2 DSCMCOL,,,,//-1/95/
OUTPUT2 ,,,,//-9/95

and not

ASSIGN OUTPUT2 = 'dscmcol.op2', UNIT = 95, UNFORMATTED
...ALTER...
OUTPUT2 DSCMCOL,,,,//-1/95/'DSCMCOL'
OUTPUT2 ,,,,//-9/95

reopen if not done