coordinate_systems
Module¶
All coordinate cards are defined in this file. This includes:
- CORD1R
- CORD1C
- CORD1S
- CORD2R
- CORD2C
- CORD2S
{ug} = [Tgb]{ub} {ub} = [Tbg]{ug}
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD1C
(cid, g1, g2, g3, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Cord1x
,pyNastran.bdf.cards.coordinate_systems.CylindricalCoord
Intilizes the CORD1C
1 2 3 4 5 6 7 8 CORD1C CIDA G1A G2A CIDB G1B G2B G3B Creates the CORD1C card, which defines a cylindrical coordinate system using 3 GRID points.
Parameters: - cid : int
the coordinate id
- g1 : int
grid point 1
- g2 : int
grid point 2
- g3 : int
grid point 3
- comment : str; default=’‘
a comment for the card
-
Type
= 'C'¶
-
type
= 'CORD1C'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD1R
(cid, g1, g2, g3, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Cord1x
,pyNastran.bdf.cards.coordinate_systems.RectangularCoord
Intilizes the CORD1R
1 2 3 4 5 6 7 8 CORD1R CIDA G1A G2A CIDB G1B G2B G3B Creates the CORD1R card, which defines a rectangular coordinate system using 3 GRID points.
Parameters: - cid : int
the coordinate id
- g1 : int
grid point 1
- g2 : int
grid point 2
- g3 : int
grid point 3
- comment : str; default=’‘
a comment for the card
-
Type
= 'R'¶
-
int_type
= 0¶
-
type
= 'CORD1R'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD1S
(cid, g1, g2, g3, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Cord1x
,pyNastran.bdf.cards.coordinate_systems.SphericalCoord
Intilizes the CORD1S
1 2 3 4 5 6 7 8 CORD1S CIDA G1A G2A CIDB G1B G2B G3B Creates the CORD1S card, which defines a spherical coordinate system using 3 GRID points.
Parameters: - cid : int
the coordinate id
- g1 : int
grid point 1
- g2 : int
grid point 2
- g3 : int
grid point 3
- comment : str; default=’‘
a comment for the card
-
Type
= 'S'¶
-
type
= 'CORD1S'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD2C
(cid, origin, zaxis, xzplane, rid=0, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Cord2x
,pyNastran.bdf.cards.coordinate_systems.CylindricalCoord
Intilizes the CORD2C
1 2 3 4 5 6 7 8 CORD2C CID RID A1 A2 A3 B1 B2 B3 C1 C2 C3 Creates the CORD2C card, which defines a cylindrical coordinate system using 3 vectors.
Parameters: - cid : int
coordinate system id
- origin : List[float, float, float]
the origin of the coordinate system
- zaxis : List[float, float, float]
the z-axis of the coordinate system
- xzplane : List[float, float, float]
a point on the xz plane
- rid : int; default=0
the referenced coordinate system that defines the system the vectors
- comment : str; default=’‘
a comment for the card
-
Type
= 'C'¶
-
type
= 'CORD2C'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD2R
(cid, origin, zaxis, xzplane, rid=0, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Cord2x
,pyNastran.bdf.cards.coordinate_systems.RectangularCoord
Intilizes the CORD2R
1 2 3 4 5 6 7 8 CORD2R CID RID A1 A2 A3 B1 B2 B3 C1 C2 C3 Note
no type checking
Creates the CORD2R card, which defines a rectangular coordinate system using 3 vectors.
Parameters: - cid : int
coordinate system id
- origin : List[float, float, float]
the origin of the coordinate system
- zaxis : List[float, float, float]
the z-axis of the coordinate system
- xzplane : List[float, float, float]
a point on the xz plane
- rid : int; default=0
the referenced coordinate system that defines the system the vectors
- comment : str; default=’‘
a comment for the card
-
Type
= 'R'¶
-
type
= 'CORD2R'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD2S
(cid, origin, zaxis, xzplane, rid=0, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Cord2x
,pyNastran.bdf.cards.coordinate_systems.SphericalCoord
Intilizes the CORD2S
1 2 3 4 5 6 7 8 CORD2S CID RID A1 A2 A3 B1 B2 B3 C1 C2 C3 Creates the CORD2C card, which defines a spherical coordinate system using 3 vectors.
Parameters: - cid : int
coordinate system id
- origin : List[float, float, float]
the origin of the coordinate system
- zaxis : List[float, float, float]
the z-axis of the coordinate system
- xzplane : List[float, float, float]
a point on the xz plane
- rid : int; default=0
the referenced coordinate system that defines the system the vectors
- comment : str; default=’‘
a comment for the card
-
Type
= 'S'¶
-
type
= 'CORD2S'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
CORD3G
(cid, method_es, method_int, form, thetas, rid, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Coord
Defines a general coordinate system using three rotational angles as functions of coordinate values in the reference coordinate system. The CORD3G entry is used with the MAT9 entry to orient material principal axes for 3-D composite analysis.
1 2 3 4 5 6 7 8 CORD3G CID METHOD FORM THETAID1 THETAID2 THETAID3 CIDREF CORD3G 100 E313 EQN 110 111 112 0 Defines the CORD3G card
Parameters: - cid : int
coordinate system id
- method_es : str
flag for coordinate system type E : Eularian? S : Space?
- method_int : int
0-1000 E1000 = ‘E’ + 1000
- form : str
EQN
- thetas : List[int]
???
- rid : int
the referenced coordinate system that defines the system the vectors???
- comment : str; default=’‘
a comment for the card
-
classmethod
add_card
(card, comment='')[source]¶ Adds a CORD3G card from
BDF.add_card(...)
Parameters: - card : BDFCard()
a BDFCard object
- comment : str; default=’‘
a comment for the card
-
coord3g_transform_to_global
(self, p)[source]¶ Parameters: - p : (3,) float ndarray
the point to transform
- .. warning:: not done, just setting up how you’d do this
- .. note:: per http://en.wikipedia.org/wiki/Euler_angles
“This means for example that a convention named (YXZ) is the result of performing first an intrinsic Z rotation, followed by X and Y rotations, in the moving axes (Note: the order of multiplication of matrices is the opposite of the order in which they’re applied to a vector).”
-
cross_reference
(self, model)[source]¶ Cross links the card so referenced cards can be extracted directly
Parameters: - model : BDF()
the BDF object
-
type
= 'CORD3G'¶
-
class
pyNastran.bdf.cards.coordinate_systems.
Coord
[source]¶ Bases:
pyNastran.bdf.cards.base_card.BaseCard
Defines a general CORDxx object
-
global_to_local
¶ Gets the 3 x 3 global to local transform
-
is_resolved
= None¶ have all the transformation matricies been determined
-
local_to_global
¶ Gets the 3 x 3 local to global transform
-
move_origin
(self, xyz, maintain_rid=False)[source]¶ Move the coordinate system to a new origin while maintaining the orientation
Parameters: - xyz : the new origin point to move the coordinate to in
the global coordinate system
- maintain_rid : bool; default=False
set the rid to cid=0 if False
-
repr_fields
(self)[source]¶ Gets the fields in their simplified form
Returns: - fields : List[varies]
the fields that define the card
-
setup
(self)[source]¶ - \[e_{13} = e_3 - e_1\]\[e_{12} = e_2 - e_1\]\[k = \frac{e_{12}}{\lvert e_{12} \rvert}\]\[j_{dir} = k \times e_{13}\]\[j = \frac{j_{dir}}{\lvert j_{dir} \rvert}\]\[i = j \times k\]
-
setup_no_xref
(self, model)[source]¶ - \[e_{13} = e_3 - e_1\]\[e_{12} = e_2 - e_1\]\[k = \frac{e_{12}}{\lvert e_{12} \rvert}\]\[j_{dir} = k \times e_{13}\]\[j = \frac{j_{dir}}{\lvert j_{dir} \rvert}\]\[i = j \times k\]
-
type
= 'COORD'¶
-
-
class
pyNastran.bdf.cards.coordinate_systems.
Cord1x
(cid, g1, g2, g3, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Coord
- Parent class for:
- CORD1R
- CORD1C
- CORD1S
Initializes the CORD1R, CORD1C, CORD1S card
Parameters: - cid : int
the coordinate id
- g1 : int
grid point 1
- g2 : int
grid point 2
- g3 : int
grid point 3
- comment : str; default=’‘
a comment for the card
-
classmethod
add_card
(card, icard=0, comment='')[source]¶ Parameters: - card : BDF()
a BDFCard object
- icard : int
the coordinate location on the line (there are possibly 2 coordinates on 1 card)
- comment : str; default=’‘
a comment for the card
-
cid
= None¶ the coordinate ID
-
cross_reference
(self, model)[source]¶ Cross links the card so referenced cards can be extracted directly
Parameters: - model : BDF()
the BDF object
-
g1
= None¶ a Node at the origin
-
g2
= None¶ a Node on the z-axis
-
g3
= None¶ a Node on the xz-plane
-
node_ids
¶ Gets the integers for the node [g1,g2,g3]
-
rid
= 0¶
-
setup
(self)[source]¶ Finds the position of the nodes used define the coordinate system and sets the ijk vectors
-
class
pyNastran.bdf.cards.coordinate_systems.
Cord2x
(cid, origin, zaxis, xzplane, rid=0, comment='')[source]¶ Bases:
pyNastran.bdf.cards.coordinate_systems.Coord
- Parent class for:
- CORD2R
- CORD2C
- CORD2S
This method emulates the CORD2x card.
Parameters: - cid : int
coord id
- origin : ndarray/None
the origin None -> [0., 0., 0.]
- zaxis : ndarray/None
a point on the z-axis None -> [0., 0., 1.]
- xzplane : ndarray/None
a point on the xz-plane None -> [1., 0., 0.]
- rid : int; default=0
reference coord id
- .. note :: no type checking
-
classmethod
add_axes
(cid, rid=0, origin=None, xaxis=None, yaxis=None, zaxis=None, xyplane=None, yzplane=None, xzplane=None, comment='')[source]¶ Create a coordinate system based on a defined axis and point on the plane. This is the generalized version of the CORD2x card.
Parameters: - cid : int
the new coordinate system id
- rid : int; default=0
the new reference coordinate system id
- origin : (3,) ndarray
defines the location of the origin in the global coordinate frame
- xaxis : (3,) ndarray
defines the x axis (default=None)
- yaxis : (3,) ndarray
defines the y axis (default=None)
- zaxis : (3,) ndarray
defines the z axis (default=None)
Notes
One axis (xaxis, yaxis, zaxis) and one plane (xyplane, yzplane, xz plane) must be defined; the others must be None
The axes and planes are defined in the rid coordinate system
-
classmethod
add_ijk
(cid, origin=None, i=None, j=None, k=None, rid=0, comment='')[source]¶ Create a coordinate system based on 2 or 3 perpendicular unit vectors
Parameters: - cid : int
the new coordinate system id
- origin : (3,) ndarray
defines the location of the origin in the global coordinate frame
- rid : int; default=0
the new reference coordinate system id
- i : (3,) ndarray
defines the i unit vector
- j : (3,) ndarray
defines the j unit vector
- k : (3,) ndarray
defines the k unit vector
-
cross_reference
(self, model)[source]¶ Cross links the card so referenced cards can be extracted directly
Parameters: - model : BDF()
the BDF object
- .. warning:: Doesn’t set rid to the coordinate system if it’s in the
global. This isn’t a problem. It’s meant to speed up the code in order to resolve extra coordinate systems.
-
class
pyNastran.bdf.cards.coordinate_systems.
CylindricalCoord
[source]¶ Bases:
object
defines common methods for cylindrical coordinate systems
\[r = \sqrt(x^2+y^2)\]\[\theta = tan^{-1}\left(\frac{y}{x}\right)\]\[z = z\]\[x = r cos(\theta)\]\[y = r sin(\theta)\]\[z = z\]\[p = [x,y,z] + e_1\]http://en.wikipedia.org/wiki/Cylindrical_coordinate_system
See also
-
static
coord_to_xyz
(p)[source]¶ y R | / | / | / theta *------------x
\[x = R \cos(\theta)\]\[y = R \sin(\theta)\]Returns: - xyz : (3,) float ndarray
the point in the local coordinate system
-
static
coord_to_xyz_array
(p)[source]¶ y R | / | / | / theta *------------x
\[x = R \cos(\theta)\]\[y = R \sin(\theta)\]Returns: - xyz : (3,) float ndarray
the point in the local coordinate system
-
static
-
class
pyNastran.bdf.cards.coordinate_systems.
GMCORD
(cid, entity, gm_ids, comment='')[source]¶ Bases:
pyNastran.bdf.cards.base_card.BaseCard
defines the GMCOORD class
GMCORD | CID | ENTITY | ID1 | ID2 | GMCORD | 101 | GMCURV | 26 | 44 |
Creates a GMCOORD
-
classmethod
add_card
(card, comment='')[source]¶ Adds a GMCORD card from
BDF.add_card(...)
Parameters: - card : BDFCard()
a BDFCard object
- comment : str; default=’‘
a comment for the card
-
type
= 'GMCORD'¶
-
classmethod
-
class
pyNastran.bdf.cards.coordinate_systems.
RectangularCoord
[source]¶ Bases:
object
defines common methods for rectangular coordinate systems
-
static
coord_to_xyz
(p)[source]¶ Returns: - xyz : (3,) ndarray
the point in the local coordinate system
-
static
coord_to_xyz_array
(p)[source]¶ Returns: - xyz : (n, 3) ndarray
the point in the local coordinate system
-
static
-
class
pyNastran.bdf.cards.coordinate_systems.
SphericalCoord
[source]¶ Bases:
object
defines common methods for spherical coordinate systems
\[r = \rho = \sqrt(x^2+y^2+z^2)\]\[\theta = \cos^{-1}\left(\frac{z}{r}\right)\]\[\phi = \tan^{-1}\left(\frac{y}{x}\right)\]\[x = r \sin(\theta)\cos(\phi)\]\[y = r \sin(\theta)\sin(\phi)\]\[z = r \cos(\theta)\]\[p = [x,y,z]\]See also
-
static
coord_to_xyz
(p)[source]¶ Returns: - xyz : (3,) float ndarray
the R, theta, phi in the local coordinate system
-
static
coord_to_xyz_array
(p)[source]¶ Returns: - xyz : (3,) float ndarray
the R, theta, phi in the local coordinate system
-
static
-
pyNastran.bdf.cards.coordinate_systems.
_fix_xyz_shape
(xyz, name='xyz')[source]¶ Checks the shape of a grid point location and fixes it if possible
Parameters: - xyz : (N, 3) float ndarray
the xyz locations
- name : str; default=’xyz’
the name in case of an error
-
pyNastran.bdf.cards.coordinate_systems.
_primary_axes
(coord)[source]¶ gets the i,j,k axes from the ???
-
pyNastran.bdf.cards.coordinate_systems.
create_coords_along_line
(model, p1, p2, percents, cid=0, axis=1)[source]¶ Creates a series of coordinate systems
Parameters: - model : BDF()
the model
- p1 : (3,) float ndarray
the start point
- p2 : (3,) float ndarray
the end point
- percents : (ncoords, ) float ndarray
the location of the coords (0. to 1.; inclusive)
- cid : int; default=0
the reference coordinate system
- axis : int; default=1
the axis normal to the plane; defines the “x” axis
Returns: - xyz_cid0 : (nnodes, 3) float ndarray
the xyz locations the global (basic) coordinate system
- nid_cp_cd : (nnodes, 3) int ndarray
the node_id, cp coord, cd coord
- icd_transform : ???
a mapping of the cid to nids???
- cids : List[int]
the created coordinate system ids
- origins : List[(ox, oy, oz)]
the origin of each coordinate system
- cid_to_inids : Dict[cid] -> inids
maps the coord id to the index of the nodes along the axis cid : int
the coord id
inids : (nnodes_in_cid)
Warning
- requires at least 1 node
-
pyNastran.bdf.cards.coordinate_systems.
define_coord_e123
(model, cord2_type, cid, origin, rid=0, xaxis=None, yaxis=None, zaxis=None, xyplane=None, yzplane=None, xzplane=None, add=True)[source]¶ Create a coordinate system based on a defined axis and point on the plane. This is the generalized version of the CORDx card.
Parameters: - model : BDF()
a BDF object
- cord2_type : str
‘CORD2R’, ‘CORD2C’, ‘CORD2S’
- cid : int
the new coordinate system id
- origin : (3,) ndarray
defines the location of the origin in the global coordinate frame
- rid : int; default=0
the new reference coordinate system id
- xaxis : (3,) ndarray
defines the x axis (default=None)
- yaxis : (3,) ndarray
defines the y axis (default=None)
- zaxis : (3,) ndarray
defines the z axis (default=None)
- add : bool; default=True
adds the coordinate system to the model
Returns: - coord : CORD2R, CORD2C, CORD2S
the coordinate system
Notes
One axis (xaxis, yaxis, zaxis) and one plane (xyplane, yzplane, xz plane) must be defined; the others must be None.
The axes and planes are defined in the rid coordinate system
Todo
hasn’t been tested…
-
pyNastran.bdf.cards.coordinate_systems.
define_coord_ijk
(model, cord2_type, cid, origin, rid=0, i=None, j=None, k=None, add=True)[source]¶ Create a coordinate system based on 2 or 3 perpendicular unit vectors
Parameters: - model : BDF()
a BDF object
- cord2_type : str
‘CORD2R’, ‘CORD2C’, ‘CORD2S’
- cid : int
the new coordinate system id
- origin : (3,) ndarray
defines the location of the origin in the global coordinate frame
- rid : int; default=0
the new reference coordinate system id
- i : (3,) ndarray
defines the i unit vector
- j : (3,) ndarray
defines the j unit vector
- k : (3,) ndarray
defines the k unit vector
- add : bool; default=True
adds the coordinate system to the model
Returns: - coord : CORD2R, CORD2C, CORD2S
the coordinate system
-
pyNastran.bdf.cards.coordinate_systems.
define_spherical_cutting_plane
(model, origin, rid, cids, thetas, phis)[source]¶ Creates a series of coordinate systems defined as constant origin, with a series of theta and phi angles, which are defined about the aerodynamic axis <1, 0, 0>. This is intended to be with a supersonic mach plane for calculating wave drag where:
\[\theta = \mu = \frac{1}{\sqrt(Mach^2 - 1)}\]\[\phi = [-\pi, \pi]\]Parameters: - model : BDF()
a BDF object
- origin : (3, ) float ndarray
defines the location of the origin in the global coordinate frame
- rid : int
the new spherical reference coordinate system id
- cids : List[int, …]
list of new coordinate system ids
- thetas : List[float, …]
list of thetas (in radians)
- phis: List[float, …]
list of phis (in radians)
Notes
creates 1 CORD2S and ncid CORD2R coordinate systems
Todo
hasn’t been tested…
-
pyNastran.bdf.cards.coordinate_systems.
get_nodes_along_axis_in_coords
(model, nids, xyz_cp, icp_transform, cids)[source]¶ Parameters: - model : BDF()
the model
- nids : (nnodes, ) ndarray
the nodes of the model
- xyz_cp : (nnodes, 3) float ndarray
the xyz locations in a representative local coordinate system for example, for cid=0, use xyz_cid0
- icp_transform : Dict[cp cid] -> inids
a mapping of the CP coord to the node indices
- icd_transform : Dict[cd cid] -> inids
a mapping of the CD coord to the node indices
- cids : List[int]
the created coordinate system ids
Returns: - #origins : List[(ox, oy, oz)]
#the origin of each coordinate system
- cid_to_inids : Dict[cid] -> inids
maps the coord id to the index of the nodes along the axis cid : int
the coord id
inids : (nnodes_in_cid)
-
pyNastran.bdf.cards.coordinate_systems.
global_to_basic_cylindrical
(coord, xyz_global, dtype='float64')[source]¶
-
pyNastran.bdf.cards.coordinate_systems.
global_to_basic_rectangular
(coord, unused_xyz_global, dtype='float64')[source]¶
-
pyNastran.bdf.cards.coordinate_systems.
global_to_basic_spherical
(coord, xyz_global, dtype='float64')[source]¶
-
pyNastran.bdf.cards.coordinate_systems.
normalize
(v)[source]¶ Normalizes v into a unit vector.
Parameters: - v : (3, ) float ndarray
the vector to normalize
Returns: - vn : (3, ) float ndarray
normalized v
\[v_{norm} = \frac{v}{\lvert v \lvert} ..\]
-
pyNastran.bdf.cards.coordinate_systems.
transform_coords_vectorized
(cps_to_check0, icp_transform, nids, xyz_cp, xyz_cid0, xyz_cid0_correct, coords, do_checks)[source]¶ Transforms coordinates in a vectorized way
Parameters: - cps_to_check0 : List[int]
the Cps to check
- icp_transform : dict{int cp
Dictionary from coordinate id to index of the nodes in
self.point_ids
that their input (CP) in that coordinate system.- nids : (n, ) int ndarray
the GRID/SPOINT/EPOINT ids corresponding to xyz_cp
- xyz_cp : (n, 3) float ndarray
points in the CP coordinate system
- xyz_cid : (n, 3) float ndarray
points in the CID coordinate system
- xyz_cid_correct : (n, 3) float ndarray
points in the CID coordinate system
- unused_in_place : bool, default=False
If true the original xyz_cp is modified, otherwise a new one is created.
- do_checks : bool; default=False
internal value for testing True : makes use of xyz_cid_correct False : xyz_cid_correct is unused
Returns: - nids_checked : (nnodes_checked,) int ndarray
the node ids that were checked
- cps_checked : List[int]
the Cps that were checked
- cps_to_check : List[int]
the Cps that are unreferenceable given the current information