pyyeti.nastran.n2p.mkcordcardinfo

pyyeti.nastran.n2p.mkcordcardinfo(uset, cid=None)[source]

Returns ‘coordinate card’ data from information in USET table

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

  • cid (None or integer) – If integer, it is the id of the coordinate system to get data for. If None, all coordinate system information is returned.

Returns:

ci (list or dictionary) –

If cid was an integer, the return is a list:

[name, [[4x3 matrix as shown below]] ]

The 4x3 matrix is (as described in addgrid()):

[ cid type reference_id ]
[ Ax   Ay   Az          ]
[ Bx   By   Bz          ]
[ Cx   Cy   Cz          ]

If cid was None, the return is a dictionary of lists for all coordinate systems in uset (not including 0):

{cid1 : [name, ...], cid2 : [...]}.

name is either ‘CORD2R’ (type == 1), ‘CORD2C’ (type == 2), or ‘CORD2S’ (type ==3). ref is always 0, regardless what the original reference coordinate system was. A, B, C are the 3-element vectors defining the origin (A), the Z-axis direction (B), and the X-axis direction (C).

Notes

The only way to get the basic system (cid = 0) is to request it specifically (and uset could be anything in this case):

c0 = mkcordcardinfo(uset, 0)

The return dictionary will be empty if cid is None and there are no coordinate systems other than 0 in the uset table.

Raises:

ValueError – When requested cid is not found.

Examples

>>> import numpy as np
>>> from pyyeti import nastran
>>> sccoord = np.array([[501, 1, 0],
...                     [1234.567, 0, 0],
...                     [1234.567, 10, 0],
...                     [2000, 0, 0]])
>>> uset = nastran.addgrid(None, 1001, 'b', sccoord, [0, 0, 0],
...                        sccoord)
>>> np.set_printoptions(precision=4, suppress=True)
>>> nastran.mkcordcardinfo(uset)
{501: ['CORD2R', array([[  501.   ,     1.   ,     0.   ],
       [ 1234.567,     0.   ,     0.   ],
       [ 1234.567,     1.   ,     0.   ],
       [ 1235.567,     0.   ,     0.   ]])]}
>>> nastran.mkcordcardinfo(uset, 0)
['CORD2R', array([[ 0.,  1.,  0.],
       [ 0.,  0.,  0.],
       [ 0.,  0.,  1.],
       [ 1.,  0.,  0.]])]
>>> nastran.mkcordcardinfo(uset, 501)
['CORD2R', array([[  501.   ,     1.   ,     0.   ],
       [ 1234.567,     0.   ,     0.   ],
       [ 1234.567,     1.   ,     0.   ],
       [ 1235.567,     0.   ,     0.   ]])]

Test routine on cylindrical and spherical coordinate systems following these steps:

  1. Define one of each coordinate system manually.

  2. Call addgrid() to create a uset table using both systems. This will create nodes 1002 and 1003.

  3. Call this routine to extract coordinate card information for both systems. This will no doubt look different than the manually entered information from step 1. However, nodes created by both sets should be the same. The next two steps will confirm this.

  4. Call :func: addgrid to create nodes 2002 and 2003, but this time using the information extracted by this routine.

  5. Confirm that node locations match: 2002 matches 1002 and 2003 matches 1003.

>>> # add random-ish cylindrical and spherical systems to test:
>>> cylcoord = np.array([[601, 2, 501],
...                      [10, 20, 30],
...                      [100, 20, 30],
...                      [10, 1, 1]])
>>> sphcoord = np.array([[701, 3, 601],
...                      [35, 15, -10],
...                      [55, 15, -10],
...                      [45, 30, 1]])
>>> uset = nastran.addgrid(uset, 1002, 'b', cylcoord, [2, 90, 5],
...                        cylcoord)
>>> uset = nastran.addgrid(
...     uset, 1003, 'b', sphcoord, [12, 40, 45], sphcoord)
>>> cyl601 = nastran.mkcordcardinfo(uset, 601)
>>> sph701 = nastran.mkcordcardinfo(uset, 701)
>>> uset = nastran.addgrid(uset, 2002, 'b', cyl601[1], [2, 90, 5],
...                        cyl601[1])
>>> uset = nastran.addgrid(
...     uset, 2003, 'b', sph701[1], [12, 40, 45], sph701[1])
>>> np.allclose(uset.loc[(1002, 1), 'x':'z'],
...             uset.loc[(2002, 1), 'x':'z'])
True
>>> np.allclose(uset.loc[(1003, 1), 'x':'z'],
...             uset.loc[(2003, 1), 'x':'z'])
True