ospgrid.grid.Grid#

class Grid[source]#

Bases: object

A class that provides a user-friendly interface to OpenSeesPy for the analysis of plane elastic grids.

Initialize the grid

Return type

None.

Methods

add_load

Add a load to the grid.

add_member

Adds a member to the grid.

add_node

Adds a node to the grid

add_support

Add a support to a node in the grid.

analyze

Executes the analysis for the grid object using OpenSeesPy

clear

Clears any nodes or members from the grid.

get_displacement

Returns the displacements for a node

get_member

Gets the member from a member object, id, or a tuple of node labels.

get_member_forces

Returns the member end forces for the indicated DOF in the global coordinate system.

get_node

Gets the node from an node object, id or label.

get_reactions

Returns the reactions for a node

get_system_force

Returns the system global force vector after the imposition of boundary conditions.

get_system_stiffness

Returns the system global stiffness matrix after the imposition of boundary conditions.

plot_bmd

Plot the bending moment diagram.

plot_dsd

Plot the deflected shape diagram.

plot_grid

Plot the grid, showing nodes & members, and their indices.

plot_results

Plot the results of the grid analysis including:

plot_sfd

Plot the shear force diagram.

plot_tmd

Plot the torsion moment diagram.

Attributes

FIGSIZE

clear()[source]#

Clears any nodes or members from the grid.

Return type

None.

add_node(label, x, y)[source]#

Adds a node to the grid

Parameters
  • label (str) – A user-friendly label for the node, e.g. “A”.

  • x (float) – The x-axis coordinate of the node.

  • y (float) – The y-axis coordinate of the node.

Returns

node – DESCRIPTION.

Return type

TYPE

add_member(node_i, node_j, EI, GJ)[source]#

Adds a member to the grid.

Parameters
  • node_i (Union[Node,str,int]) – The starting node for the member.

  • node_j (Union[Node,str,int]) – The ending node for the member.

  • EI (float) – The flexural rigidity.

  • GJ (float) – The torsional rigidity.

Returns

member – The member object instance.

Return type

Member

add_load(node, Fz=0, Mx=0, My=0)[source]#

Add a load to the grid.

Parameters
  • node (Union[Node,str,int]) – Node object, label, or id

  • Fz (float, optional) – Vertical load. The default is 0.

  • Mx (float, optional) – Moment about the x-axis. The default is 0.

  • My (float, optional) – Moment about the y-axis. The default is 0.

Raises

ValueError – If node object, label, or id not passed, or is multiple nodes match the label, or no node found.

Return type

None.

add_support(node, support=None)[source]#

Add a support to a node in the grid.

Parameters
  • node (Union[Node,str,int]) – Node object, label, or id

  • support (Union[Support,str]) –

    The support type, a ospgrid.grid.Support object. Alternatively, a single character support descriptor as a str can be used as follows:

    • X = ospgrid.grid.Support.PINNED_X

    • Y = ospgrid.grid.Support.PINNED_Y

    • F = ospgrid.grid.Support.FIXED

    • V = ospgrid.grid.Support.FIXED_V_ROLLER

    • P = ospgrid.grid.Support.PROP

Return type

None.

get_node(node=typing.Union[ospgrid.grid.Node, str, int])[source]#

Gets the node from an node object, id or label.

Parameters

node (Union[Node,str,int]) – Node object, label, or id

Raises

ValueError – If node object, label, or id not passed, or is multiple nodes match the label, or no node found.

Return type

Node object.

get_member(member=typing.Union[ospgrid.grid.Member, int, typing.Tuple[str, str]])[source]#

Gets the member from a member object, id, or a tuple of node labels.

Parameters

member (Union[Member,int, Tuple[str,str]], optional Member object, id, or) – node labels.

Raises

ValueError – If member object, or id not passed, or is multiple nodes match the label, or no node found.

Return type

None.

analyze()[source]#

Executes the analysis for the grid object using OpenSeesPy

Returns

osp – The OpenSeesPy instance, which can be used for querying results directly or otherwise manipulating the model further.

Return type

OpenSeesPy instance

get_displacement(node=typing.Union[ospgrid.grid.Node, str, int], dof=-1)[source]#

Returns the displacements for a node

Parameters
  • node (Union[Node,str,int]) – Node object, label, or id

  • dof (int [optional]) – The degree of freedom of interest. Defaults to all.

Raises

ValueError – If node object, label, or id not passed, or is multiple nodes match the label, or no node found.

Return type

None.

get_reactions(node=typing.Union[ospgrid.grid.Node, str, int], dof=-1)[source]#

Returns the reactions for a node

Parameters
  • node (Union[Node,str,int]) – Node object, label, or id

  • dof (int [optional]) – The degree of freedom of interest. Defaults to all.

Raises

ValueError – If node object, label, or id not passed, or is multiple nodes match the label, or no node found.

Return type

None.

get_system_stiffness()[source]#

Returns the system global stiffness matrix after the imposition of boundary conditions.

Returns

K – A square numpy array of the reduced global stiffness matrix

Return type

np.ndarray

get_system_force()[source]#

Returns the system global force vector after the imposition of boundary conditions.

Returns

F – A numpy vector of the reduced global system force vector

Return type

np.ndarray

get_member_forces(member, dof=-1)[source]#

Returns the member end forces for the indicated DOF in the global coordinate system.

Parameters
  • member (Union[Member, int, Tuple[str,str]]) – Member object, id, or a tuple of node labels.

  • dof (int [optional]) – The degree of freedom of interest. Defaults to all.

Returns

F – A 12 element list: 6 DOFs for node i, and 6 DOFs for node j, in the order Fx, Fy, Fz, Mx, My, Mz.

Return type

np.array

plot_results(figsize=None, axes_on=True, scale_factor=0.0, axis_title=True, save_figs=False, filename='ospgrid_results.pdf', transparent=False, bbox=False, pad=20, values=True)[source]#
Plot the results of the grid analysis including:
  • the grid

  • the deflected shape

  • the BMD, SFD, and TMD

Parameters
  • axes_on (bool, optional) – Whether or not to have the axes on in the plots. The default is True.

  • scale_factor (float, List[float] optional) – If a single float: the scale of the deformations to use. When this value is zero, auto-scaling is done. The default is 0. If a list of floats of size 4, then the scale factors are applied in the order deformations; bending; shear; torsion.

  • axis_title (bool, optional) – Whether or not to have the axes title in the plots. The default is True.

  • save_figs (bool, optional) – Whether or not to save the plots to PDF. The default is False.

  • filename (string) – The file to which the results are saved.

  • transparent (bool, optional) – Whether or not the plots should be transparent. The default is False.

  • bbox (bool, optional) – Whether or not to crop the figure to a bounding box of its contents. Only applies to image files, e.g., png, jpg, etc (not PDF)

  • pad (int, optional) – If applying the bbox cropping to an image, a padding to apply to the contents. Defaults to 20 px.

  • values (bool, optional) – Whether or not to print the salient values on the force diagrams

Return type

None.

plot_grid(figsize=None, axes_on=True, axis_title=True)[source]#

Plot the grid, showing nodes & members, and their indices.

Parameters
  • figsize (TYPE, optional) – The size of the figure in inches. The default is self.FIGSIZE.

  • axes_on (bool, optional) – Whether or not to have the axes on in the plots. The default is True.

  • axis_title (bool, optional) – Whether or not to have the axes title in the plots. The default is True.

Return type

None.

plot_dsd(scale_factor=0, figsize=None, axes_on=True, axis_title=True)[source]#

Plot the deflected shape diagram.

Parameters
  • scale_factor (float) – The scale of the deformations to use. When this value is zero, auto-scaling is done. The default is 0.

  • figsize (TYPE, optional) – The size of the figure in inches. The default is self.FIGSIZE.

  • axes_on (bool, optional) – Whether or not to have the axes on in the plots. The default is True.

  • axis_title (bool, optional) – Whether or not to have the axes title in the plots. The default is True.

Return type

None.

plot_bmd(scale_factor=1.0, figsize=None, axes_on=True, axis_title=True, values=True)[source]#

Plot the bending moment diagram.

Parameters
  • scale_factor (float) – The scale of the bending moment to use. The default is 1.0.

  • figsize (TYPE, optional) – The size of the figure in inches. The default is self.FIGSIZE.

  • axes_on (bool, optional) – Whether or not to have the axes on in the plots. The default is True.

  • axis_title (bool, optional) – Whether or not to have the axes title in the plots. The default is True.

  • values (bool optional) – Wether or not to print the values at the member ends

Return type

None.

plot_sfd(scale_factor=1.0, figsize=None, axes_on=True, axis_title=True, values=True)[source]#

Plot the shear force diagram.

Parameters
  • scale_factor (float) – The scale of the bending moment to use. The default is 1.0. A negative sign is then applied to flip the diagram so that it appears per convention.

  • figsize (TYPE, optional) – The size of the figure in inches. The default is self.FIGSIZE.

  • axes_on (bool, optional) – Whether or not to have the axes on in the plots. The default is True.

  • axis_title (bool, optional) – Whether or not to have the axes title in the plots. The default is True.

  • values (bool optional) – Wether or not to print the values at the member ends

Return type

None.

plot_tmd(scale_factor=1.0, figsize=None, axes_on=True, axis_title=True, values=True)[source]#

Plot the torsion moment diagram.

Parameters
  • scale_factor (float) – The scale of the bending moment to use. The default is 1.0. A negative sign is then applied to flip the diagram so that it appears per convention.

  • figsize (TYPE, optional) – The size of the figure in inches. The default is self.FIGSIZE.

  • axes_on (bool, optional) – Whether or not to have the axes on in the plots. The default is True.

  • axis_title (bool, optional) – Whether or not to have the axes title in the plots. The default is True.

  • values (bool optional) – Wether or not to print the values at the member ends

Return type

None.