pyyeti.nastran.bulk.asm2uset

pyyeti.nastran.bulk.asm2uset(f, *, try_rdextrn=True, follow_includes=True, include_symbols=None, encoding='utf_8')[source]

Read CORD2* and GRID cards from a “.asm” file to make a USET table

Parameters:
  • f (string or file_like or None) – Either a name of a file, or is a file_like object as returned by open(). If file_like object, it is rewound first. Can also be the name of a directory or None; in these cases, a GUI is opened for file selection.

  • try_rdextrn (bool or “pv_only”; optional) – If True (or bool(try_rdextrn) is True), routine will attempt to read the “EXTRN” card from the “.pch” file. If a filename cannot be determined from f, the attempt to read the “EXTRN” card is quietly skipped and each b-set node is assumed to have all 6 DOF. See Notes below.

  • 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:

  • uset (pandas DataFrame) – A DataFrame as output by pyyeti.nastran.op2.OP2.rdn2cop2(). Contains all GRID and SPOINT DOF in the .asm file in the order specified on the SECONCT card. If some GRIDs do not include all DOF, the user has the option of getting a trimmed uset or not. If trimmed, it is compatible with the model matrices (eg, in the .op4 file). See Notes below.

  • coordref (dictionary) – Dictionary with the keys being the coordinate system id and the values being the 5x3 matrix:

    [id  type 0]  # output coord. sys. id and type
    [xo  yo  zo]  # origin of coord. system
    [    T     ]  # 3x3 transformation to basic
    Note that T is for the coordinate system, not a grid
    (unless type = 1 which means rectangular)
    
  • bset_bool (1d ndarray) – A boolean partition vector with True for the b-set. This is created for convenience by:

    from pyyeti import nastran
    bset_bool = nastran.mksetpv(uset, 'a', 'b')
    
  • kept_dof (1d ndarray; optional) – Only returned if try_rdextrn is “pv_only”. A boolean partition vector with True for DOF included in the a-set. See Notes below.

Notes

This routine will attempt to read the “EXTRN” card from the .pch file in case some b-set nodes do not include all 6 DOF. For example, a model could have 7 b-set DOF and 1 q-set DOF. If the 7 b-set DOF are composed of all 6 DOF for node 100 and just the second DOF for node 200, the EXTRN card would like this:

EXTRN,100,123456,200,2,1001,0

This routine can handle cases like this in two different ways depending on the setting of the try_rdextrn parameter:

try_rdextrn

Description

True

The uset is trimmed to only the retained DOF (it has the same number of rows as the mass and stiffness matrices) and kept_dof is not returned.

“pv_only”

The uset retains all 6 DOF per GRID and kept_dof is returned.

For the above example, uset would look like this if try_rdextrn=True:

           nasset    x    y    z
id   dof
100  1    2097154  0.0  0.0  0.0
     2    2097154  0.0  1.0  0.0
     3    2097154  0.0  0.0  0.0
     4    2097154  1.0  0.0  0.0
     5    2097154  0.0  1.0  0.0
     6    2097154  0.0  0.0  1.0
200  2    2097154  0.0  1.0  0.0
1001 0    4194304  0.0  0.0  0.0

Notice that the “x”, “y” and “z” columns are not that useful, especially for node 200. However, if try_rdextrn="pv_only", the full uset is returned along with kept_dof. Utilizing pandas for illustration:

>>> u, c, b, kept = asm2uset(f, try_rdextrn="pv_only")
>>> kept = pd.Series(kept, index=u.index, name="a-set")
>>> pd.concat((u, kept), axis=1)

           nasset    x    y    z  a-set
id   dof
100  1    2097154  0.0  0.0  0.0   True
     2    2097154  0.0  1.0  0.0   True
     3    2097154  0.0  0.0  0.0   True
     4    2097154  1.0  0.0  0.0   True
     5    2097154  0.0  1.0  0.0   True
     6    2097154  0.0  0.0  1.0   True
200  1    2097154  1.0  0.0  0.0  False
     2    2097154  0.0  1.0  0.0   True
     3    2097154  0.0  0.0  0.0  False
     4    2097154  1.0  0.0  0.0  False
     5    2097154  0.0  1.0  0.0  False
     6    2097154  0.0  0.0  1.0  False
1001 0    4194304  0.0  0.0  0.0   True

Examples

>>> import numpy as np
>>> from io import StringIO
>>> from pyyeti import nastran
>>> asm_bulk = (
...    "$ SE101 ASSEMBLY FILE\n"
...    "SEBULK,101,EXTOP4,,MANUAL,,,101\n"
...    "SECONCT,101,0,,NO\n"
...    ",3,3,110,110,19,19,27,27\n"
...    "$ Coordinate 10:\n"
...    "CORD2R,10,0,0.0,0.0,0.0,1.0,0.0,0.0\n"
...    ",0.0,1.0,0.0\n"
...    "GRID,3,0,600.,0.,300.,0\n"
...    "GRID,19,0,600.,300.,0.,0\n"
...    "GRID,27,0,600.,0.,0.\n"
...    "SPOINT,110\n"
... )
>>> with StringIO(asm_bulk) as f:
...     u, c, b = nastran.asm2uset(f)
>>> u
          nasset      x      y      z
id  dof...
3   1    2097154  600.0    0.0  300.0
    2    2097154    0.0    1.0    0.0
    3    2097154    0.0    0.0    0.0
    4    2097154    1.0    0.0    0.0
    5    2097154    0.0    1.0    0.0
    6    2097154    0.0    0.0    1.0
110 0    4194304    0.0    0.0    0.0
19  1    2097154  600.0  300.0    0.0
    2    2097154    0.0    1.0    0.0
    3    2097154    0.0    0.0    0.0
    4    2097154    1.0    0.0    0.0
    5    2097154    0.0    1.0    0.0
    6    2097154    0.0    0.0    1.0
27  1    2097154  600.0    0.0    0.0
    2    2097154    0.0    1.0    0.0
    3    2097154    0.0    0.0    0.0
    4    2097154    1.0    0.0    0.0
    5    2097154    0.0    1.0    0.0
    6    2097154    0.0    0.0    1.0
>>> c
{0: array([[ 0.,  1.,  0.],
        [ 0.,  0.,  0.],
        [ 1.,  0.,  0.],
        [ 0.,  1.,  0.],
        [ 0.,  0.,  1.]]),
 10: array([[ 10.,   1.,   0.],
        [  0.,   0.,   0.],
        [  0.,   0.,   1.],
        [  1.,   0.,   0.],
        [  0.,   1.,   0.]])}
>>> np.set_printoptions(linewidth=55)
>>> b
array([ True,  True,  True,  True,  True,  True, False,
        True,  True,  True,  True,  True,  True,  True,
        True,  True,  True,  True,  True], dtype=bool)