SteveDoyle2 / pyNastran

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

How to output the global stiffness matrix and mass matrix to op2 file or f04 file #699

Closed Yinhang97 closed 2 years ago

Yinhang97 commented 2 years ago

I used to output the global stiffness matrix and mass matrix to punch file, using "PARAM,EXTOUT,DMIGPCH". Then the punch files can be read by fopen() function in matlab. However, it suffers from low speed and i have been trying to use pyNastran.

It worked to obtain the modal matrix by read_op2() function in pyNastran while it confused me how to output the global stiffness matrix and mass matrix to op2 file or f04 file before reading it by pyNastran.

SteveDoyle2 commented 2 years ago

That's a very very guts of Nastran question. I know you can do it with a DMAP alter and that there's a DMAP guide, but I'm not sure.

That's something I'd ask your technical support people about.

AlejandroStewart commented 2 years ago

I think it will suffice to put all your nodes in the ASET and then request the desired format. I personally prefer to with op4 and pynastran.

El jue., 23 jun. 2022 21:46, Steven Doyle @.***> escribió:

That's a very very guts of Nastran question. I know you can do it with a DMAP alter and that there's a DMAP guide, but I'm not sure.

That's something I'd ask your technical support people about.

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

Yinhang97 commented 2 years ago

Thanks for your reply and i will try.

Yinhang97 commented 2 years ago

I have tried the following code in bdf.file to obtain the mass matrix. Plz be noted that i have put nodes in the ASET. ASSIGN OUTPUT4='KJJZ.op4',UNIT=102,FORM=FORMATTED,DELETE ASSIGN OUTPUT4='MJJX.op4',UNIT=103,FORM=FORMATTED,DELETE SOL 103 DIAG 8 COMPILE SEMG $ ALTER 'KJJZ.*STIFFNESS' $ OUTPUT4 KJJZ,,,,///102///16 $ ALTER 'MJJX,.*MASS' $ OUTPUT4 MJJX,,,,///103///16 $ CEND And i got this op4 file: mjjx.zip

In pyNastran, i tried:

def op4_stat(**kwargs):
    op4 = OP4()
    bdf_path = kwargs["bdf_path"]
    op4_path = kwargs["op4_path"]
    pd.options.display.precision = 3
    if not os.path.exists(op4_path):
        run_nastran(bdf_path)
        assert os.path.exists(op4_path)
    matrices = op4.read_op4(op4_filename=op4_path, matrix_names='MJJX')

But some errors were reported as:

Traceback (most recent call last):
  File "E:\01-vibration\12s10p_146mm_IPM\python\op2_handler.py", line 58, in <module>
    op4_stat(bdf_path=r"E:\01-vibration\12s10p_146mm_IPM\nastran\fullmodel_modal - v3\nastran_-_fullmodel_mode.bdf",
  File "E:\01-vibration\12s10p_146mm_IPM\python\op2_handler.py", line 49, in op4_stat
    matrices = op4.read_op4(op4_filename=op4_path, matrix_names='MJJX')
  File "E:\01-vibration\12s10p_146mm_IPM\python\venv\lib\site-packages\pyNastran\op4\op4.py", line 138, in read_op4
    return self.read_op4_ascii(op4_filename, matrix_names, precision)
  File "E:\01-vibration\12s10p_146mm_IPM\python\venv\lib\site-packages\pyNastran\op4\op4.py", line 147, in read_op4_ascii
    (name, form, matrix) = self._read_matrix_ascii(op4, matrix_names, precision)
  File "E:\01-vibration\12s10p_146mm_IPM\python\venv\lib\site-packages\pyNastran\op4\op4.py", line 162, in _read_matrix_ascii
    ncols, nrows, form, matrix_type = line[0:32].split()
ValueError: not enough values to unpack (expected 4, got 3)

It checked the first line of op4 file 2528664-2528664 6 1MJJX 1P,3E23.16 If i'am right, the "-" shouldn't appear according to line 162 in _read_matrix_ascii "ncols, nrows, form, matrix_type = line[0:32].split()"