Defined as:
sdynpy.core.sdynpy_geometry.GeometryModule:
sdynpy.core.sdynpy_geometrySource: GitHub
Signature¶
class sdynpy.Geometry(node= Index, ID, X, Y, Z, DefCS, DisCS
----------- Empty -------------
, coordinate_system= Index, ID, Name, Color, Type
----------- Empty -------------
, traceline= Index, ID, Description, Color, # Nodes
----------- Empty -------------
, element= Index, ID, Type, Color, # Nodes
----------- Empty -------------
)Container for nodes, coordinate systems, tracelines, and elements
Geometry is the class that is most useful for working with the positioning and spatial visualization of test or analysis data. It contains functions to plot and animate 3D geometry
Methods¶
| Name | Summary |
|---|---|
__init__ | Initialize a geometry object with nodes, coordinate systems, tracelines, and elements. |
add_element | |
add_traceline | Adds a traceline to the geometry |
camera_visualization | Create a geometry used to visualize a camera specified with K and RT |
compress_ids | Compresses ID numbers to make node, element, etc. contiguous |
convert_elements_to_tracelines | Transforms all elements in the geometry into tracelines |
coordinate_transformation_matrix | Creates a transformation matrix that transforms one geometry to a new geometry with different coordinate systems defined. |
copy | Return’s a copy of the current Geometry |
force_kinematic_transformation | Creates a kinematic force transformation from the rigid body body shapes for the associated geometry and force coordinates. |
from_excel_template | Create a geometry from Excel file template |
from_exodus | Generate a geometry from exodus file data |
from_imat_struct | Constructs a Geometry from an imat_fem class saved to a Matlab structure |
from_uff | Create a geometry from universal file format data from readunv |
from_unv | Create a geometry from universal file format data from readunv |
global_deflection | Direction of local deflection in the global coordinate system |
global_geometry_table | |
global_node_coordinate | Position of the Geometry’s nodes in the global coordinate system |
load | Loads a geometry from a numpy .npz or .unv file |
map_coordinate | Map degrees of freedom from one geometry to the closest aligned on a second geometry. |
map_ids | Maps id numbers from an original set of ids to a new set of ids. |
modify_ids | Shifts the id numbers in the geometry |
node_by_global_grid | Selects nodes in a grid |
node_by_global_position | Select node by closest position |
overlay_geometries | Combines several geometries, offsetting the id numbers to avoid conflicts |
plot | Plots the geometry in an interactive 3D window. |
plot_coordinate | Plots coordinate arrows on the geometry |
plot_deflection_shape | Plot deflection shapes shapes on the geometry |
plot_shape | Plot mode shapes on the geometry |
plot_transient | Create a TransientPlotter object to plot displacements over time |
reduce | Reduce the geometry to only contain nodes in node_list |
remove_duplicate_tracelines | Removes tracelines that are effectively equivalent to each other. |
response_kinematic_transformation | Creates a kinematic response transformation from the rigid body body shapes for the associated geometry and response coordinates. |
rigid_body_shapes | Creates a set of shapes corresponding to the rigid body motions |
save | Saves the geometry to a numpy .npz file |
savemat | Saves the geometry to a .mat file |
split_tracelines_into_segments | Splits long tracelines into many length-2 tracelines |
write_excel_template | Writes an Excel File Template for Creating Geometry |
write_to_unv | Write the geometry to a unversal file format file |
__init__¶
Source: GitHub
def sdynpy.Geometry.__init__(self, node= Index, ID, X, Y, Z, DefCS, DisCS
----------- Empty -------------
, coordinate_system= Index, ID, Name, Color, Type
----------- Empty -------------
, traceline= Index, ID, Description, Color, # Nodes
----------- Empty -------------
, element= Index, ID, Type, Color, # Nodes
----------- Empty -------------
)Initialize a geometry object with nodes, coordinate systems, tracelines, and elements.
All input arguments will be flattened when passed to the Geometry, as the geometry does not support multi-dimensional object arrays.
Parameters¶
node : NodeArray, optional The set of nodes in the geometry. The default is NodeArray((0,)), an empty NodeArray.
coordinate_system : CoordinateSystemArray, optional The set of coordinate systems in the geometry. The default is CoordinateSystemArray((0,)), an empty CoordinateSystemArray
traceline : TracelineArray, optional The set of tracelines defined in the geometry. The default is TracelineArray((0,)), an empty TracelineArray
element : ElementArray, optional The set of elements defined in the geometry. The default is ElementArray((0,)), an empty element array.
Returns¶
None.
add_element¶
Source: GitHub
def sdynpy.Geometry.add_element(self, elem_type, connectivity, id=None, color=1)add_traceline¶
Source: GitHub
def sdynpy.Geometry.add_traceline(self, connectivity, id=None, description='', color=1)Adds a traceline to the geometry
Parameters¶
connectivity : iterable Iterable containing the node_ids to connect with the traceline
id : TYPE, optional The id number of the new traceline. The default is None, which results in the new traceline having an id of one greater than the current maximum traceline it.
description : str, optional A string description of the new traceline. The default is ‘’.
color : int, optional An integer corresponding to the color of the new traceline. The default is 1.
Returns¶
None. Modifications are made in-place to the current geometry.
camera_visualization¶
Source: GitHub
def sdynpy.Geometry.camera_visualization(cls, K, RT, image_size, size=1, colors=1)Create a geometry used to visualize a camera specified with K and RT
Parameters¶
K : ndarray A (...,3,3) matrix containing the intrinsic parameters of the cameras
RT : ndarray A (...,3,4) matrix containing the extrinsic parameters of the cameras
image_size : ndarray A (...,2) matrix containing the width,height of each camera
size : float The distance that the rays will project from the pinhole of the camera
colors : int or ndarray The colors assigned to each camera
Returns¶
geometry : cls A geoemtry containing the cameras that can be used for visualization
compress_ids¶
Source: GitHub
def sdynpy.Geometry.compress_ids(self, compress_nodes=True, compress_elements=True, compress_tracelines=True, compress_cs=True, return_maps=False)Compresses ID numbers to make node, element, etc. contiguous
Parameters¶
compress_nodes : bool, optional If True, compress the node ids. The default is True.
compress_elements : bool, optional If True, compress the element ids. The default is True.
compress_tracelines : bool, optional If True, compress the traceline ids. The default is True.
compress_cs : bool, optional If True, compress the coordinate system ids. The default is True.
return_maps : bool, optional If True, return id maps for nodes, elements, tracelines, and coordinate systems. Maps will be equal to
Noneif no compression was done on that field. The default is False.
Returns¶
mapped_geometry : Geometry Geometry with contiguous id numbers for the selected fields.
node_map : id_map or
NoneMapping from the old set of nodes to the new set of nodes, only returned ifreturn_mapsis True. Ifcompress_nodesis False, this will beNone.traceline_map : id_map or
NoneMapping from the old set of tracelines to the new set of tracelines, only returned ifreturn_mapsis True. Ifcompress_tracelinesis False, this will beNone.element_map : id_map or
NoneMapping from the old set of elements to the new set of elements, only returned ifreturn_mapsis True. Ifcompress_elementsis False, this will beNone.cs_map : id_map or
NoneMapping from the old set of coordinate systems to the new set of coordinate systems, only returned ifreturn_mapsis True. Ifcompress_csis False, this will beNone.
convert_elements_to_tracelines¶
Source: GitHub
def sdynpy.Geometry.convert_elements_to_tracelines(self, keep_ids=False, start_id=None, in_place=False)Transforms all elements in the geometry into tracelines
Parameters¶
keep_ids : bool, optional If True, the element ids will be used as the new traceline ids. The default is False.
start_id : int, optional The starting id number for the tracelines converted from elements. Only used if keep_ids is False. If not specified, each subsequent element will use the current highest traceline id number + 1.
in_place : bool, optional If True, modify the geometry in place. If False, a copy will be created and returned. The default is False.
Returns¶
geometry : Geometry Only returned if in_place is False.
Raises¶
ValueError
If conflicts are expected to occur between the newly created
traceline IDs and the current existing traceline IDs.
NotImplementedError
If solid element types are converted.
coordinate_transformation_matrix¶
Source: GitHub
def sdynpy.Geometry.coordinate_transformation_matrix(self, to_geometry: 'Geometry', nodes: numpy.ndarray = None, rotations: bool = False)Creates a transformation matrix that transforms one geometry to a new geometry with different coordinate systems defined.
Parameters¶
to_geometry : Geometry Geometry object with coordinate systems that the transformation matrix will transform into
nodes : np.ndarray, optional An array of node id numbers to include in the transformation. The default is to include all nodes in the geometry.
rotations : bool, optional If True, create degrees of freedom for rotations as well as translations.
Returns¶
Matrix
A Matrix object that transforms data or shapes currently
represented by this Geometry to the Geometry specified in the
to_geometryargument.
copy¶
Source: GitHub
def sdynpy.Geometry.copy(self)Return’s a copy of the current Geometry
Changes to the copy will not also be applied to the original geometry
Returns¶
Geometry
A copy of the current Geometry
force_kinematic_transformation¶
Source: GitHub
def sdynpy.Geometry.force_kinematic_transformation(self, force_coordinate, virtual_point_node_number, virtual_point_location=[0, 0, 0])Creates a kinematic force transformation from the rigid body body shapes for the associated geometry and force coordinates.
Parameters¶
force_coordinate : CoordinateArray The “physical” force coordinates for the kinematic transformation.
virtual_point_node_number : int The numeric ID for the virtual point in the kinematic transformation.
virtual_point_location : list or ndarray The [X, Y, Z] coordinates that defined the location of the virtual point. The default is is [0, 0, 0].
Returns¶
transformation : Matrix The kinematic transformation as a matrix object. It is organized with the virtual point CoordinateArray on the rows and the physical force CoordinateArray on the columns.
Notes¶
The transformation automatically handles polarity differences in the geometry and force_coordinate.
References¶
.. [1] M. Van der Seijs, D. van den Bosch, D. Rixen, and D. Klerk, “An improved methodology for the virtual point transformation of measured frequency response functions in dynamic substructuring,” in Proceedings of the 4th International Conference on Computational Methods in Structural Dynamics and Earthquake Engineering, Kos Island, 2013, pp. 4334-4347, doi: 10.7712/120113.4816.C1539.
from_excel_template¶
Source: GitHub
def sdynpy.Geometry.from_excel_template(cls, path_to_xlsx)Create a geometry from Excel file template
Parameters¶
path_to_xlsx : string Path to xlsx Excel file containing geometry information
Returns¶
Geometry
Geometry object created from the Excel file
Notes¶
To use this function, first save out an excel template file using the
write_excel_template function. This will construct an excel
workbook with four worksheets on which the different portions of the
Geometry are defined.
On the Coordinate Systems tab, users will define the various global and local coordinate systems in their geometry. Each geometry requires an ID number. A Name can optionally be given. The Color should be selectred from the dropdown list of colors in the Excel template. The type of the coordinate system should be selected from the dropdown list of coordinate system types.
The origin of the coordinate system can be specified with the X Location, Y Location, Z Location columns. Then rotations of the coordinate system can be specified using rotations about axes. Up to three axes and angles can be specified to create arbitrary compound rotations. The rotation axes should be X, Y, or Z, and the rotation angles are in degrees.
On the Nodes tab, all tabs must be filled out. ID numbers must be unique. Colors should be selected from the dropdown list in the Excel template. The position of the node is specified using the X Location, Y Location, Z Location columns. Each node has a displacement coordinate system in which its position is defined, and a a definition coordinate system in which its displacements are defined. These columns should consist of integers corresponding to ID numbers from the Coordinate Systems tab.
On the Elements tab, elements connecting nodes are defined. The ID
column must consist of unique integer identifiers. The Color tab should
be selected from the dropdown list. The type can be selected from the dropdown list.
If the type column
is empty, an element type based on the number of connections given will
be used. Defult element types for connection length of 2 is “Type 21 - Linear Beam”,
for a connection length of 3 is “Type 41 - Plane Stress Linear Triangle”,
and for a connection length of 4 is “Type 44 - Plane Stress Linear Quadrilateral”.
The columns Node 1 through Node 4 contain the nodes in each element. Only the required
number of nodes must be filled out (e.g. a tri element would only contain
3 nodes, so only columns Node 1, Node 2, and Node 3 would be filled).
On the Trace Lines tab, lines connecting the nodes are defined. The ID column must consist of unique integer identifiers. The Description column contains a string description of the line. The Color should be selected from the dropdown list. The Node 1 through Node 5 columns should contain the nodes for each line. Only the number of nodes in the line must be filled out, so if a line only connects 5 nodes, only Node 1 though Node 5 must be filled. More columns can can be added for additional Nodes if longer tracelines are needed.
from_exodus¶
Source: GitHub
def sdynpy.Geometry.from_exodus(cls, exo: sdynpy.fem.sdynpy_exodus.Exodus, blocks=None, local=False, preferred_local_orientation=array([0., 0., 1.]), secondary_preferred_local_orientation=array([1., 0., 0.]), local_nodes=None)Generate a geometry from exodus file data
Parameters¶
exo : Exodus or ExodusInMemory The exodus data from which geometry will be created.
blocks : iterable, optional Iterable containing a set of block ids to import when creating the geometry. The default is None, which uses all blocks in the model.
local : bool, optional Flag to specify whether or not to create local coordinate systems for each node in the model. This can be useful when creating instrumnetation positions from a finite element model, where the sensor will be oriented perpendicular to the surface it is mounted on. The default is False, which returns all data in a single global coordinate system.
preferred_local_orientation : np.ndarray, optional A preferred direction for the local coordinate system. The first constraint is that the local Z+ axis is perpendicular to the surface. The coordinate system will then try to align itself as much as it can with this direction. The default is np.array((0.0,0.0,1.0)), which points the local coordinate systems along the global Z+ axis.
secondary_preferred_local_orientation : np.ndarray, optional A secondary preferred direction is only used if the surface normal direction is parallel to the primary preferred_local_orientation. The default is np.array((1.0,0.0,0.0)), which points the local coordinate system along the local Z+ axis.
local_nodes : np.ndarray, optional If specified, only create local coordinate systems at the specified nodes.
Returns¶
Geometry
A geometry consisting of the finite element nodes and element
connectivity.
from_imat_struct¶
Source: GitHub
def sdynpy.Geometry.from_imat_struct(cls, imat_fem_struct)Constructs a Geometry from an imat_fem class saved to a Matlab structure
In IMAT, a structure can be created from an imat_fem by using the get()
function. This can then be saved to a .mat file and loaded using
scipy.io.loadmat. The output from loadmat can be passed into this function
Parameters¶
imat_fem_struct : np.ndarray structure from loadmat containing data from an imat_fem
Returns¶
Geometry
Geometry constructed from the data in the imat structure
from_uff¶
Source: GitHub
def sdynpy.Geometry.from_uff(cls, unv_dict)Create a geometry from universal file format data from readunv
Parameters¶
unv_dict : dict Dictionary containing data from read_unv
Returns¶
Geometry
Geometry object read from the unv data
from_unv¶
Source: GitHub
def sdynpy.Geometry.from_unv(cls, unv_dict)Create a geometry from universal file format data from readunv
Parameters¶
unv_dict : dict Dictionary containing data from read_unv
Returns¶
Geometry
Geometry object read from the unv data
global_deflection¶
Source: GitHub
def sdynpy.Geometry.global_deflection(self, coordinate_array)Direction of local deflection in the global coordinate system
Parameters¶
coordinate_array : CoordinateArray A list of coordinates for which the global deformation direction will be computed
Returns¶
global_deflections : np.ndarray numpy array with shape (n,3) where n is the number of coordinates in the specified
coordinate_array. This array contains the 3d direction of motion for each coordinate in the global coordinate system.
global_geometry_table¶
Source: GitHub
def sdynpy.Geometry.global_geometry_table(self, coordinate_array_or_nodelist=None)global_node_coordinate¶
Source: GitHub
def sdynpy.Geometry.global_node_coordinate(self, node_ids=None)Position of the Geometry’s nodes in the global coordinate system
Parameters¶
node_ids : np.ndarray An array of node id numbers to keep in the output coordinate. If not specified, all nodes will be returned in the order they are in the model.
Returns¶
np.ndarray
numpy array with shape (n,3) where n is the number of nodes in the
geometry. This array contains the 3d position of each node in the
global coordinate system.
load¶
Source: GitHub
def sdynpy.Geometry.load(cls, filename)Loads a geometry from a numpy .npz or .unv file
The .npz file must have fields ‘node’, ‘coordinate_system’, ‘element’, and ‘traceline’, with each field storing the respective portion of the geometry
The .unv file will need to have the proper datasets specified to define a geometry
Parameters¶
filename : str Filename to load the geometry from.
Returns¶
Geometry
Geometry constructed from the data in the loaded file
Raises¶
AttributeError
Raised if the calling class does not have a
from_unvmethoddefined
map_coordinate¶
Source: GitHub
def sdynpy.Geometry.map_coordinate(self, dof_list, to_geometry, node_map=None, plot_maps=False)Map degrees of freedom from one geometry to the closest aligned on a second geometry.
Parameters¶
dof_list : CoordinateArray An array of degrees of freedom on the geometry to map.
to_geometry : Geometry The geometry to which the degrees of freedom will be mapped.
node_map : None, str, or id_map, optional If specified, it will map the node ids from the present geometry to the mapping geometry. If the string ‘position’ is specified, then the closest node by position on the mapping geometry to the present geometry will be chosen. To explicitly map between nodes, pass a sdpy.id_map. If not specified, it is assumed that the node numbers in the present geometry map to the nodes in the mapping geometry.
plot_maps : bool If True, it will plot the CoordinateArray on the geometries to visualize the two mapped degrees of freedom.
Returns¶
output_dof_list : CoordinateArray A CoordinateArray of the same size and shape of dof_list with each entry in dof_list corresponding to the same position in output_dof_list.
Raises¶
ValueError
If an invalid mapping is specified.
map_ids¶
Source: GitHub
def sdynpy.Geometry.map_ids(self, node_id_map=None, traceline_id_map=None, element_id_map=None, coordinate_system_id_map=None)Maps id numbers from an original set of ids to a new set of ids.
This function accepts id_map classes defining “from” and “to” ids Existing ids found in the “from” set are transformed to the corresponding id in the “to” set.
Parameters¶
node_id_map : id_map, optional An id_map defining the mapping applied to node ids. The default is None, which results in the ids being unchanged
traceline_id_map : id_map, optional An id_map defining the mapping applied to traceline ids. The default is None, which results in the ids being unchanged
element_id_map : id_map, optional An id_map defining the mapping applied to element ids. The default is None, which results in the ids being unchanged
coordinate_system_id_map : id_map, optional An id_map defining the mapping applied to coordinate system ids. The default is None, which results in the ids being unchanged
Returns¶
geom_out : Geometry A copy of the original geometry with id numbers modified
modify_ids¶
Source: GitHub
def sdynpy.Geometry.modify_ids(self, node_change=0, traceline_change=0, element_change=0, coordinate_system_change=0)Shifts the id numbers in the geometry
Parameters¶
node_change : int, optional The amount to shift the node ids. The default is 0.
traceline_change : int, optional The amount to shift the traceline ids.. The default is 0.
element_change : int, optional The amount to shift the element ids. The default is 0.
coordinate_system_change : int, optional The amount to shift the coordinate system ids. The default is 0.
Returns¶
geom_out : Geometry A copy of the original geometry with id numbers modified
node_by_global_grid¶
Source: GitHub
def sdynpy.Geometry.node_by_global_grid(self, grid_spacing, x_min=None, y_min=None, z_min=None, x_max=None, y_max=None, z_max=None)Selects nodes in a grid
Parameters¶
grid_spacing : float Approximate grid spacing between selected nodes
x_min : float, optional Minimum X-value of the grid. The default is the minimum node x-coordinate.
y_min : float, optional Minimun Y-value of the grid. The default is the minimum node y-coordinate.
z_min : float, optional Minimum Z-value of the grid. The default is the minimum node z-coordinate.
x_max : float, optional Maximum X-value of the grid. The default is the maximum node x-coordinate.
y_max : float, optional Maximum Y-value of the grid. The default is the maximum node y-coordinate.
z_max : float, optional Maximum Z-value of the grid. The default is the maximum node z-coordinate.
Returns¶
NodeArray
NodeArray containing the closest nodes to the grid points
node_by_global_position¶
Source: GitHub
def sdynpy.Geometry.node_by_global_position(self, global_position_array)Select node by closest position
Parameters¶
global_position_array : np.ndarray A (...,3) shape array containing positions of nodes to keep
Returns¶
NodeArray
NodArray containing nodes that were closest to the positions in
position_array.
overlay_geometries¶
Source: GitHub
def sdynpy.Geometry.overlay_geometries(geometries, color_override=None, return_node_id_offset=False)Combines several geometries, offsetting the id numbers to avoid conflicts
Parameters¶
geometries : iterable An iterable of geometry objects that will be combined into a single geometry
color_override : iterable, optional An iterble of integers specifying colors, which will override the existing geometry colors. This should have the same length as the
geometriesinput. The default is None, which keeps the original geometry colors.return_node_id_offset : bool, optional Specifies whether or not the applied node offset should be returned, which is useful if the new node numbers are to be mapped to the old node numbers. The default is False, which only returns the combined geometry.
Returns¶
Geometry
A geometry consisting of a combination of the specified geometries
node_offset
An integer specifying the node id offset applied to avoid conflicts
plot¶
Source: GitHub
def sdynpy.Geometry.plot(self, node_size: int = 5, line_width: int = 1, opacity=1.0, view_up=None, view_from=None, plotter=None, show_edges=False, label_nodes=False, label_tracelines=False, label_elements=False, label_font_size=16, plot_individual_items=False)Plots the geometry in an interactive 3D window.
Parameters¶
node_size : int, optional Size to display the nodes in pixels. Set to 0 to not display nodes. The default is 5.
line_width : int, optional Width to display tracelines and element edges in pixels. Set to 0 to not show tracelines or edges. The default is 1.
opacity : float, optional A float between 0 and 1 to specify the transparency of the geometry. Set to 1 for completely opaque, and 0 for completely transparent (invisible). The default is 1.0, no transparency.
view_up : np.ndarray, optional Set the “up” direction in the plot by passing in a size-3 numpy array. The default is None.
view_from : np.ndarray, optional Specify the direction from which the geometry is viewed. The default is None.
plotter : BackgroundPlotter, optional A plotter can be specified to plot the geometry in an existing plot. The default is None, which creates a new window and plot.
show_edges : bool, optional Specify whether or not to draw edges on elements. The default is False.
label_nodes : bool or iteratble, optional Specify whether or not to label the nodes in the geometry. If True, all nodes will be plotted. If label_nodes is an array or list, it should contain the node numbers to label. The default is False, which does not label nodes.
label_tracelines : bool or iteratble, optional Specify whether or not to label the tracelines in the geometry. If True, all tracelines will be plotted. If label_tracelines is an array or list, it should contain the traceline numbers to label. The default is False, which does not label tracelines.
label_elements : bool or iteratble, optional Specify whether or not to label the elements in the geometry. If True, all elements will be plotted. If label_elements is an array or list, it should contain the element numbers to label. The default is False, which does not label elements.
label_font_size : int, optional Specify the font size of the node labels. The default is 16.
plot_individual_items : bool, optional If True, then each item will be plotted one at a time. This will make the plotting much slower, but it is required for certain features (like exporting to 3D PDF content) where having all data in one mesh is not feasible. Note that volume elements will NOT be plotted in this case.
Returns¶
plotter : BackgroundPlotter A reference to the plotter object that the geometry was plotted in
face_mesh : TYPE A reference to the mesh used to plot surface elements
point_mesh : TYPE A reference to the mesh used to plot nodes and tracelines
solid_mesh : TYPE A reference to the mesh used to plot volume elements
Raises¶
KeyError
If referenced id numbers are not found in the corresponding object,
for example if a traceline references node 11 but there is no node
11 in the NodeArray
ValueError
If an invalid or unknown element type is used
plot_coordinate¶
Source: GitHub
def sdynpy.Geometry.plot_coordinate(self, coordinates: sdynpy.core.sdynpy_coordinate.CoordinateArray = None, arrow_scale=0.1, arrow_scale_type='bbox', label_dofs=False, label_font_size=16, opacity=1.0, arrow_ends_on_node=False, plot_kwargs={}, plot_individual_items=False)Plots coordinate arrows on the geometry
Parameters¶
coordinates : CoordinateArray, optional Coordinates to draw on the geometry. If no coordinates are specified, all translation degrees of freedom at each node will be plotted.
arrow_scale : float | np.ndarray, optional Size of the arrows in proportion to the length of the diagonal of the bounding box of the Geometry if
arrow_scale_typeis ‘bbox’, otherwise the raw length of the arrow. If an ndarray is provided, it should match the shape ofcoordinates. The default is 0.1.arrow_scale_type : str, optional Specifies how to compute the size of the arrows. If ‘bbox’, then the arrow is scaled based on the size of the geometry. Otherwise, the arrow size is the specified length. The default is ‘bbox’.
label_dofs : bool, optional Specify whether or not to label the coordinates with strings. The default is False.
label_font_size : int, optional Specifies the font size for the node labels. Default is 16.
opacity : float, optional A float between 0 and 1 to specify the transparency of the geometry. Set to 1 for completely opaque, and 0 for completely transparent (invisible). The default is 1.0, no transparency.
arrow_ends_on_node : bool, optional If True, arrow tip ends at the node, otherwise the arrow begins at node. Defualt is False
plot_kwargs : dict, optional Any additional keywords that should be passed to the Geometry.plot function. The default is {}.
plot_individual_items : bool, optional If True, then each item will be plotted one at a time. This will make the plotting much slower, but it is required for certain features (like exporting to 3D PDF content) where having all data in one mesh is not feasible. Note that volume elements will NOT be plotted in this case.
Returns¶
plotter : BackgroundPlotter A reference to the window the geometry was plotted in.
plot_deflection_shape¶
Source: GitHub
def sdynpy.Geometry.plot_deflection_shape(self, deflection_shape_data, plot_kwargs={}, background_plotter_kwargs={'editor': False}, undeformed_opacity=0.25, deformed_opacity=1.0, starting_scale=1.0)Plot deflection shapes shapes on the geometry
Parameters¶
deflection_shape_data : NDDataArray Data array containing the deflection shapes to plot
plot_kwargs : dict, optional Any additional keywords that should be passed to the Geometry.plot function. The default is {}.
background_plotter_kwargs : dict, optional Any additional arguments that should be passed to the BackgroundPlotter initializer. The default is {‘editor’:False}.
undeformed_opacity : float, optional A float between 0 and 1 to specify the transparency of the undeformed geometry. Set to 1 for completely opaque, and 0 for completely transparent (invisible). The default is 0.25.
deformed_opacity : float, optional A float between 0 and 1 to specify the transparency of the deformed geometry. Set to 1 for completely opaque, and 0 for completely transparent (invisible). The default is 1.0.
starting_scale : float, optional The starting scale factor of the animation. The default is 1.0.
Returns¶
deflection_shape_data
A reference to the deflection_shape_data object that is created to
plot the animated shapes
plot_shape¶
Source: GitHub
def sdynpy.Geometry.plot_shape(self, shape, plot_kwargs={}, background_plotter_kwargs={'editor': False}, undeformed_opacity=0.25, deformed_opacity=1.0, starting_scale=1.0)Plot mode shapes on the geometry
Parameters¶
shape : ShapeArray The set of shapes to plot
plot_kwargs : dict, optional Any additional keywords that should be passed to the Geometry.plot function. The default is {}.
background_plotter_kwargs : dict, optional Any additional arguments that should be passed to the BackgroundPlotter initializer. The default is {‘editor’:False}.
undeformed_opacity : float, optional A float between 0 and 1 to specify the transparency of the undeformed geometry. Set to 1 for completely opaque, and 0 for completely transparent (invisible). The default is 0.25.
deformed_opacity : float, optional A float between 0 and 1 to specify the transparency of the deformed geometry. Set to 1 for completely opaque, and 0 for completely transparent (invisible). The default is 1.0.
starting_scale : float, optional The starting scale factor of the animation. The default is 1.0.
Returns¶
ShapePlotter
A reference to the ShapePlotter class that is created to plot the
animated shapes
plot_transient¶
Source: GitHub
def sdynpy.Geometry.plot_transient(self, displacement_data, displacement_scale=1.0, frames_per_second=20, undeformed_opacity=0.0, deformed_opacity=1.0, plot_kwargs={}, transformation_shapes=None, num_curves=50, show: bool = True, app=None, window_size=None, off_screen=None, allow_quit_keypress=True, toolbar=True, menu_bar=True, editor=False, update_app_icon=None, **kwargs)Create a TransientPlotter object to plot displacements over time
Parameters¶
displacement_data : TimeHistoryArray Transient displacement data that will be applied
displacement_scale : float, optional Scale factor applied to displacements. The default is 1.0.
frames_per_second : float, optional Number of time steps to plot per second while the displacement is animating. Default is 20.
undeformed_opacity : float, optional Opacity of the undeformed geometry. The default is 0.0, or completely transparent.
deformed_opacity : float, optional Opacity of the deformed geometry. The default is 1.0, or completely opaque.
plot_kwargs : dict, optional Keyword arguments passed to the Geometry.plot function
transformation_shapes : ShapeArray Shape matrix that will be used to expand the data. Must be the same size as the
displacement_datanum_curves : int, optional Maximum number of curves to plot on the time selector. Default is 50.
show : bool, optional Show the plotting window. If
False, show this window by runningshow(). The default is True.app : QApplication, optional Creates a
QApplicationif left asNone. The default is None.window_size : list of int, optional Window size in pixels. Defaults to
[1024, 768]off_screen : TYPE, optional Renders off screen when True. Useful for automated screenshots or debug testing. The default is None.
allow_quit_keypress : bool, optional Allow user to exit by pressing
"q". The default is True.toolbar : bool, optional If True, display the default camera toolbar. Defaults to True.
menu_bar : bool, optional If True, display the default main menu. Defaults to True.
editor : TYPE, optional If True, display the VTK object editor. Defaults to False.
update_app_icon : bool, optional If True, update_app_icon will be called automatically to update the Qt app icon based on the current rendering output. If None, the logo of PyVista will be used. If False, no icon will be set. Defaults to None. The default is None.
title : str, optional Title of plotting window.
multi_samples : int, optional The number of multi-samples used to mitigate aliasing. 4 is a good default but 8 will have better results with a potential impact on performance.
line_smoothing : bool, optional If True, enable line smothing
point_smoothing : bool, optional If True, enable point smothing
polygon_smoothing : bool, optional If True, enable polygon smothing
auto_update : float, bool, optional Automatic update rate in seconds. Useful for automatically updating the render window when actors are change without being automatically
Modified. If set toTrue, update rate will be 1 second.
Returns¶
TransientPlotter
reduce¶
Source: GitHub
def sdynpy.Geometry.reduce(self, node_list)Reduce the geometry to only contain nodes in node_list
Elements and tracelines will only be kept if all nodes in each element
or traceline are in node_list. Coordinate systems will only be kept
if they are required by a node in node_list
Parameters¶
node_list : iterable An iterable of integer node id numbers.
Returns¶
Geometry
A geometry only containing the nodes in
node_list
remove_duplicate_tracelines¶
Source: GitHub
def sdynpy.Geometry.remove_duplicate_tracelines(self, in_place=False)Removes tracelines that are effectively equivalent to each other.
If two tracelines have the same connectivity (or reversed connectivity), then the first will be kept and the second will be discarded. This will not take into account other fields such as description or color.
Parameters¶
in_place : bool, optional If True, the current geometry will be modified in place. The default is False.
Returns¶
geometry : Geometry Only returned if in_place is False.
response_kinematic_transformation¶
Source: GitHub
def sdynpy.Geometry.response_kinematic_transformation(self, response_coordinate, virtual_point_node_number, virtual_point_location=[0, 0, 0])Creates a kinematic response transformation from the rigid body body shapes for the associated geometry and response coordinates.
Parameters¶
response_coordinate : CoordinateArray The “physical” response coordinates for the kinematic transformation.
virtual_point_node_number : int The numeric ID for the virtual point in the kinematic transformation.
virtual_point_location : list or ndarray The [X, Y, Z] coordinates that defined the location of the virtual point. The default is is [0, 0, 0].
Returns¶
transformation : Matrix The kinematic transformation as a matrix object. It is organized with the virtual point CoordinateArray on the rows and the physical response CoordinateArray on the columns.
Notes¶
The transformation automatically handles polarity differences in the geometry and response_coordinate.
References¶
.. [1] M. Van der Seijs, D. van den Bosch, D. Rixen, and D. Klerk, “An improved methodology for the virtual point transformation of measured frequency response functions in dynamic substructuring,” in Proceedings of the 4th International Conference on Computational Methods in Structural Dynamics and Earthquake Engineering, Kos Island, 2013, pp. 4334-4347, doi: 10.7712/120113.4816.C1539.
rigid_body_shapes¶
Source: GitHub
def sdynpy.Geometry.rigid_body_shapes(self, coordinates, mass=1, inertia=array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]), cg=array([0., 0., 0.]), principal_axes=False)Creates a set of shapes corresponding to the rigid body motions
Rigid body translation and rotation shapes are computed analytically from the Geoemtry
Parameters¶
coordinates : CoordinateArray coordinates at which to compute deformations
mass : float, optional The mass of the geometry used to scale the rigid body translation shapes. The default is 1.
inertia : np.ndarray, optional A 3x3 array consisting of the mass moments of inertia, used to scale the rotation shapes. The default is np.eye(3).
cg : np.ndarray, optional The center of gravity of the Geometry about which the rotations occur. The default is np.zeros(3).
principal_axes : bool, optional If True, compute the principal axes of the test article and perform rotations about those axes. The default is False.
Returns¶
output_shape : ShapeArray A set of rigid body shapes for the current geometry
save¶
Source: GitHub
def sdynpy.Geometry.save(self, filename)Saves the geometry to a numpy .npz file
The .npz file will have fields ‘node’, ‘coordinate_system’, ‘element’, and ‘traceline’, with each field storing the respective portion of the geometry
Parameters¶
filename : str Filename to save the geometry to. If the filename doesn’t end with .npz, it will be appended.
Returns¶
None.
savemat¶
Source: GitHub
def sdynpy.Geometry.savemat(self, filename)Saves the geometry to a .mat file
The .mat file will have fields ‘node’, ‘coordinate_system’, ‘element’, and ‘traceline’, with each field storing the respective portion of the geometry
Parameters¶
filename : str Filename to save the geometry to.
Returns¶
None.
split_tracelines_into_segments¶
Source: GitHub
def sdynpy.Geometry.split_tracelines_into_segments(self, in_place=False)Splits long tracelines into many length-2 tracelines
Parameters¶
in_place : bool, optional If True, the current geometry will be modified in place. The default is False.
Returns¶
geometry : Geometry Only returned if in_place is False.
write_excel_template¶
Source: GitHub
def sdynpy.Geometry.write_excel_template(path_to_xlsx)Writes an Excel File Template for Creating Geometry
Parameters¶
path_to_xlsx : string Path to write xlsx Excel file
Returns¶
Nothing
Notes¶
See documentation for from_excel_template for instructions on filling out the template to create a geometry.
write_to_unv¶
Source: GitHub
def sdynpy.Geometry.write_to_unv(self, filename, write_nodes=True, write_coordinate_systems=True, write_tracelines=True, write_elements=True, dataset_2412_kwargs={}, dataset_2420_kwargs={})Write the geometry to a unversal file format file
Parameters¶
filename : str Filename to which the geometry will be written. If None, a unv data dictionary will be returned instead, similar to that obtained from the readunv function in sdynpy
write_nodes : bool, optional If True, write the geometry’s nodes to dataset 2411 in the output file. The default is True.
write_coordinate_systems : True, optional If True, write the geometry’s coordinate systems to dataset 2420 in the output file. The default is True.
write_tracelines : bool, optional If True, write the geometry’s tracelines to dataset 82 in the output file. The default is True.
write_elements : TYPE, optional If True, write the geometry’s elements to dataset 2412 in the output file. The default is True.
dataset_2412_kwargs : dict, optional Allows users to specify additional element parameters not stored by the Geometry. The default is {}.
dataset_2420_kwargs : dict, optional Allows users to specify additional coordinate system parameters not stored by the Geometry. The default is {}.
Returns¶
unv_dict : dict Dictionary containing unv information, similar to that obtained from readunv. Only returned if filename is None.