pyyeti.nastran.n2p.replace_basic_cs

pyyeti.nastran.n2p.replace_basic_cs(uset, new_cs_id, new_cs_in_basic=None)[source]

Define a new coordinate system as the base for a USET table

This routine enables the translation and/or rotation of a model. The new rectangular coordinate system is “inserted” between all the local systems that exist in the USET table and the basic coordinate system. In other words, this routine replaces the original basic coordinate system with a new one.

Parameters:
  • uset (pandas DataFrame) – A DataFrame as output by pyyeti.nastran.op2.OP2.rdn2cop2()

  • new_cs_id (integer or 4 x 3 array_like) – If integer, it is the ID for the new rectangular system and new_cs_in_basic is a required input. Otherwise, if 4x3 matrix, format is as on a Nastran CORD2* card:

    [ id type=1 reference_id=0 ]
    [ Ax   Ay   Az             ]
    [ Bx   By   Bz             ]
    [ Cx   Cy   Cz             ]
    

    The type must be 1 (rectangular) and the reference_id must be 0. The A, B, C points are as defined for a CORD2R bulk card for the new coordinate system (which replaces the old basic) relative to the basic system. “A” defines the origin of the new system, “B” defines the positive Z axis of the new system, and “C” defines the positive X axis direction of the new system.

  • new_cs_in_basic (3 x 3 array_like; optional) –

    The A, B, C points as defined for a CORD2R bulk card:

    [ Ax   Ay   Az ]
    [ Bx   By   Bz ]
    [ Cx   Cy   Cz ]
    

    See description in new_cs_id. This input is ignored if new_cs_id is a 4x3 matrix. If new_cs_id is an integer, new_cs_in_basic is a required input.

Returns:

uset_new (pandas DataFrame) – The updated USET table. See notes below.

Notes

This routine does the following:

  1. Computes the transform T from the new system to basic

  2. Adjusts all node locations (in basic) by:

    new_location = T @ old_location + A
    
  3. Adjusts all coordinate system origins similarly

  4. Updates any “0” ID reference coordinate system numbers to be new_cs_id

  5. Apply transform T to all transforms in the USET table

Note

The new coordinate system id new_cs_id will not be present in the final USET table uset_new if no nodes output in the old basic system.

Raises:
  • ValueError – When new_cs_id is already in use

  • ValueError – If type is not 1 or reference_id is not 0 in the new_cs_id 4 x 3 input.

Examples

Create a USET table with node 1 located at (0, 0, 0) in the basic coordinate system.

>>> import numpy as np
>>> from pyyeti.nastran import n2p
>>> uset = n2p.addgrid(None, 1, 'b', 0, [0., 0., 0.], 0.)
>>> uset
         nasset    x    y    z
id dof...
1  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

Next, use replace_basic_cs() to move the node to (10, 10, 10).

>>> new_cs_id = 50
>>> new_cs_in_basic = np.array([[10., 10., 10.],
...                             [10., 10., 11.],
...                             [11., 10., 10.]])
>>> uset_new = n2p.replace_basic_cs(
...    uset, new_cs_id, new_cs_in_basic
... )
>>> uset_new
         nasset     x     y     z
id dof...
1  1    2097154  10.0  10.0  10.0
   2    2097154  50.0   1.0   0.0
   3    2097154  10.0  10.0  10.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

As a second example, in addition to translation, rotate the coordinate system of the node such that its Z axis is aligned with the new X_basic direction and its X axis is aligned with the new Z_basic.

Also, demonstrate the 4x3 input new_cs_id and not inputting new_cs_in_basic

>>> new_cs_id_2 = np.array([[60, 1, 0],
...                         [10., 10., 10.],
...                         [11., 10., 10.],
...                         [10., 10., 11.]])
>>> uset_new_2 = n2p.replace_basic_cs(uset, new_cs_id_2)
>>> uset_new_2
         nasset     x     y     z
id dof...
1  1    2097154  10.0  10.0  10.0
   2    2097154  60.0   1.0   0.0
   3    2097154  10.0  10.0  10.0
   4    2097154   0.0   0.0   1.0
   5    2097154   0.0  -1.0   0.0
   6    2097154   1.0   0.0   0.0