Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

sdynpy.Geometry

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

NameSummary
__init__Initialize a geometry object with nodes, coordinate systems, tracelines, and elements.
add_coordinate_systemAdds a coordinate system to the geometry
add_element
add_nodeAdds a node to the geometry
add_tracelineAdds a traceline to the geometry
camera_visualizationCreate a geometry used to visualize a camera specified with K and RT
compress_idsCompresses ID numbers to make node, element, etc. contiguous
convert_elements_to_tracelinesTransforms all elements in the geometry into tracelines
coordinate_transformation_matrixCreates a transformation matrix that transforms one geometry to a new geometry with different coordinate systems defined.
copyReturn’s a copy of the current Geometry
editOpen an interactive Qt GUI for editing this geometry in place.
force_kinematic_transformationCreates a kinematic force transformation from the rigid body body shapes for the associated geometry and force coordinates.
from_excel_templateCreate a geometry from Excel file template
from_exodusGenerate a geometry from exodus file data
from_imat_structConstructs a Geometry from an imat_fem class saved to a Matlab structure
from_uffCreate a geometry from universal file format data from readunv
from_unvCreate a geometry from universal file format data from readunv
global_deflectionDirection of local deflection in the global coordinate system
global_geometry_table
global_node_coordinatePosition of the Geometry’s nodes in the global coordinate system
loadLoads a geometry from a numpy .npz or .unv file
map_coordinateMap degrees of freedom from one geometry to the closest aligned on a second geometry.
map_idsMaps id numbers from an original set of ids to a new set of ids.
mass_props_from_rigid_body_shapesComputes mass properties (mass, inertia tensor, center of mass) given a set of mass-normalized rigid body shapes.
modify_idsShifts the id numbers in the geometry
node_by_global_gridSelects nodes in a grid
node_by_global_positionSelect node by closest position
overlay_geometriesCombines several geometries, offsetting the id numbers to avoid conflicts
plotPlots the geometry in an interactive 3D window.
plot_coordinatePlots coordinate arrows on the geometry
plot_deflection_shapePlot deflection shapes shapes on the geometry
plot_shapePlot mode shapes on the geometry
plot_transientCreate a TransientPlotter object to plot displacements over time
reduceReduce the geometry to only contain nodes in node_list
remove_duplicate_tracelinesRemoves tracelines that are effectively equivalent to each other.
response_kinematic_transformationCreates a kinematic response transformation from the rigid body body shapes for the associated geometry and response coordinates.
rigid_body_shapesCreates a set of shapes corresponding to the rigid body motions
saveSaves the geometry to a numpy .npz file
savematSaves the geometry to a .mat file
split_tracelines_into_segmentsSplits long tracelines into many length-2 tracelines
write_excel_templateWrites an Excel File Template for Creating Geometry
write_to_unvWrite the geometry to a unversal file format file

__init__

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

Returns

add_coordinate_system

def sdynpy.Geometry.add_coordinate_system(self, matrix=None, id=None, name='', color=1, cs_type=0)

Adds a coordinate system to the geometry

Parameters

Returns

add_element

def sdynpy.Geometry.add_element(self, elem_type, connectivity, id=None, color=1)

add_node

def sdynpy.Geometry.add_node(self, coordinate, id=None, color=1, def_cs=1, disp_cs=1)

Adds a node to the geometry

Parameters

Returns

add_traceline

def sdynpy.Geometry.add_traceline(self, connectivity, id=None, description='', color=1)

Adds a traceline to the geometry

Parameters

Returns

camera_visualization

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

Returns

compress_ids

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

Returns

convert_elements_to_tracelines

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

Returns

Raises

coordinate_transformation_matrix

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

Returns

copy

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

edit

def sdynpy.Geometry.edit(self=None, node_size=10, line_width=2)

Open an interactive Qt GUI for editing this geometry in place.

Can also be called on the class itself — new_geom = Geometry.edit() — to create a new empty geometry and build it from scratch in the editor. In that case the new Geometry object is returned (populated in place as you edit; if the call blocks in the Qt event loop, it returns once the window is closed).

A window opens with a 3-D view of the geometry (left, resizable via the splitter) beside editable tables for the nodes, coordinate systems, tracelines, and elements (right). Each coordinate system is drawn as a labeled X/Y/Z arrow triad at its origin (labels read e.g. ‘1X+’ for coordinate system 1’s X+ axis). The active tab determines what clicking in the 3-D view selects — nodes, coordinate systems, tracelines, or elements — and what the buttons operate on. Hold Shift to select multiple items; press Escape to deselect everything; changing tabs deselects everything.

On the Nodes and Coord Systems tabs, “Add” immediately appends a new item. On the Tracelines tab, “Add” is a toggle: while active, click the first node and Shift-click the rest in order, then “Create” commits them as a new traceline. On the Elements tab, “Add” is replaced by three mutually exclusive toggles — “Add Beams” (type 21), “Add Triangles” (type 41), and “Add Quadrilaterals” (type 44). While one is active, clicking in the 3-D view picks nodes instead of elements (plain click restarts the pick list, Shift-click extends it), and each element is committed automatically as soon as enough nodes have been picked (2, 3, or 4), ready for the next element of the same type.

All changes are applied to this Geometry object in place, so the object reflects the edits once the window is closed. This method depends only on qtpy/pyvistaqt (already required by :meth:plot) and on the add_node, add_coordinate_system, add_traceline, and add_element methods, so it is self-contained and can be shared as a single method.

Parameters

Returns

force_kinematic_transformation

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

Returns

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

def sdynpy.Geometry.from_excel_template(cls, path_to_xlsx)

Create a geometry from Excel file template

Parameters

Returns

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

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

Returns

from_imat_struct

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

Returns

from_uff

def sdynpy.Geometry.from_uff(cls, unv_dict)

Create a geometry from universal file format data from readunv

Parameters

Returns

from_unv

def sdynpy.Geometry.from_unv(cls, unv_dict)

Create a geometry from universal file format data from readunv

Parameters

Returns

global_deflection

def sdynpy.Geometry.global_deflection(self, coordinate_array)

Direction of local deflection in the global coordinate system

Parameters

Returns

global_geometry_table

def sdynpy.Geometry.global_geometry_table(self, coordinate_array_or_nodelist=None)

global_node_coordinate

def sdynpy.Geometry.global_node_coordinate(self, node_ids=None)

Position of the Geometry’s nodes in the global coordinate system

Parameters

Returns

load

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

Returns

Raises

map_coordinate

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

Returns

Raises

map_ids

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

Returns

mass_props_from_rigid_body_shapes

def sdynpy.Geometry.mass_props_from_rigid_body_shapes(self, rigid_shapes, return_rectified_shapes=False, rectified_rotations_about_center_of_mass=False)

Computes mass properties (mass, inertia tensor, center of mass) given a set of mass-normalized rigid body shapes.

Parameters

Returns

modify_ids

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

Returns

node_by_global_grid

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

Returns

node_by_global_position

def sdynpy.Geometry.node_by_global_position(self, global_position_array)

Select node by closest position

Parameters

Returns

overlay_geometries

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

Returns

plot

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

Returns

Raises

plot_coordinate

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

Returns

plot_deflection_shape

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

Returns

plot_shape

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

Returns

plot_transient

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

Returns

reduce

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

Returns

remove_duplicate_tracelines

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

Returns

response_kinematic_transformation

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

Returns

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

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

Returns

save

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

Returns

savemat

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

Returns

split_tracelines_into_segments

def sdynpy.Geometry.split_tracelines_into_segments(self, in_place=False)

Splits long tracelines into many length-2 tracelines

Parameters

Returns

write_excel_template

def sdynpy.Geometry.write_excel_template(path_to_xlsx)

Writes an Excel File Template for Creating Geometry

Parameters

Returns

Notes

See documentation for from_excel_template for instructions on filling out the template to create a geometry.

write_to_unv

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

Returns