pyyeti.nastran.bulk.rddmig¶
- pyyeti.nastran.bulk.rddmig(f, dmig_names=None, *, expanded=False, square=False, follow_includes=True, include_symbols=None, encoding='utf_8')[source]¶
Read DMIG entries from a Nastran punch (bulk) or output2 file.
- Parameters:
f (string or file_like or None) – Either a name of a punch or output2 file, or is a file_like object as returned by
open(). If handle, punch format is assumed and file is rewound first. Can also be the name of a directory or None; in these cases, a GUI is opened for file selection.dmig_names (None, string, or list_like of strings) – If not None, it is the name or names of DMIG entry(s) to read. If None, all DMIG entries will be returned.
expanded (bool; optional; must be named) – If True, row and column indices for “GRID” IDs will be expanded to include all 6 DOF, even if some of those DOF are not used. Otherwise, if expanded is False, only the row and column DOF actually referenced on the DMIG will be included.
square (bool; optional; must be named) – Only used for “square” matrices (
form=1). If True, ensures that the row and column indices are the same by filling in zeros as necessary.follow_includes (bool; optional) – If True, INCLUDE statements will be followed recursively. Note that if f is a StringIO object, or another object that does not have a name property, this parameter will be set to False.
include_symbols (dict; optional) – A dictionary mapping Nastran symbols to an associated path. These can be read from a file using
rdsymbols().encoding (string; optional) – Encoding to use when opening text file. This option will be passed to any files read in via the follow_includes option.
- Returns:
dct (dictionary) – Dictionary of pandas DataFrames containing the DMIG entries. The column and row indices are pandas MultiIndex objects with node ID in level 0 and DOF in level 1 (the names are “id” and “dof”). The exception is for form “9” matrices: the column index in that case is just the column number (as specified by Nastran).
Notes
For the punch format, this routine first reads all DMIG entries via
rdcards()using the ‘list’ output option. It then builds a dictionary of DataFrames for only those entries specified in dmig_names. It is assumed that DMIG entries are in order in the file.For the output2 format, this routine scans through the file looking for matching DMIG data-blocks and only reads those in.
Note
This routine is more lenient than Nastran. Nastran will issue a FATAL message if a symmetric matrix has entries for element (i, j) and (j, i). This routine does not check for that (the last value for (i, j) or (j, i) will be used for both).
Examples
Manually create a punch format DMIG string, treat it as a file, and read it in with a couple different options:
>>> import numpy as np >>> from pyyeti import nastran >>> from io import StringIO >>> dmig = ( ... 'DMIG MAT 0 1 2 0' ... ' 2\n' ... 'DMIG* MAT 1 1\n' ... '* 1 3 1.200000000D+01\n' ... '* 10 0 1.000000000D+02\n' ... ) >>> with StringIO(dmig) as f: ... dct1 = nastran.rddmig(f) ... dct2 = nastran.rddmig(f, expanded=True) ... dct3 = nastran.rddmig(f, square=True) ... dct4 = nastran.rddmig(f, expanded=True, square=True) >>> dct1['mat'] id 1 dof 1 id dof... 1 3 12.0 10 0 100.0 >>> dct2['mat'] id 1... dof 1 2 3 4 5 6 id dof... 1 1 0.0 0.0 0.0 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 0.0 0.0 3 12.0 0.0 0.0 0.0 0.0 0.0 4 0.0 0.0 0.0 0.0 0.0 0.0 5 0.0 0.0 0.0 0.0 0.0 0.0 6 0.0 0.0 0.0 0.0 0.0 0.0 10 0 100.0 0.0 0.0 0.0 0.0 0.0 >>> dct3['mat'] id 1 10 dof 1 3 0 id dof... 1 1 0.0 0.0 0.0 3 12.0 0.0 0.0 10 0 100.0 0.0 0.0 >>> dct4['mat'] id 1 10 dof 1 2 3 4 5 6 0 id dof... 1 1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 3 12.0 0.0 0.0 0.0 0.0 0.0 0.0 4 0.0 0.0 0.0 0.0 0.0 0.0 0.0 5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 6 0.0 0.0 0.0 0.0 0.0 0.0 0.0 10 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0