ross.PointMass#

class ross.PointMass(n=None, m=None, mx=None, my=None, mz=None, tag=None, scale_factor=1.0, color='DarkSalmon')#

A point mass element.

This class will create a point mass element. This element can be used to link other elements in the analysis. The mass provided to the element can be different on the x and y direction (e.g. different support inertia for x and y directions).

Parameters:
n: int

Node in which the point mass will be located.

m: float, pint.Quantity, optional

Mass for the element.

mx: float, pint.Quantity, optional

Mass for the element on the x direction.

my: float, pint.Quantity, optional

Mass for the element on the y direction.

mz: float, pint.Quantity, optional

Mass for the element on the z direction.

tag: str

A tag to name the element

scale_factorfloat, optional

The scale factor is used to scale the point mass drawing. Default is 1.

colorstr, optional

A color to be used when the element is represented. Default is “DarkSalmon”.

Examples

>>> p0 = PointMass(n=0, m=2)
>>> p0.M()
array([[2., 0., 0.],
       [0., 2., 0.],
       [0., 0., 2.]])
>>> p1 = PointMass(n=0, mx=2, my=3, mz=4)
>>> p1.M()
array([[2., 0., 0.],
       [0., 3., 0.],
       [0., 0., 4.]])

Methods

C()#

Damping matrix for an instance of a point mass element.

This method will return the damping matrix for an instance of a point mass element.

Returns:
Cnp.ndarray

A matrix of floats containing the values of the damping matrix.

Examples

>>> p1 = PointMass(n=0, mx=2, my=3, mz=4)
>>> p1.C()
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]])
G()#

Gyroscopic matrix for an instance of a point mass element.

This method will return the gyroscopic matrix for an instance of a point mass element.

Returns:
Gnp.ndarray

A matrix of floats containing the values of the gyroscopic matrix.

Examples

>>> p1 = PointMass(n=0, mx=2, my=3, mz=4)
>>> p1.G()
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]])
K()#

Stiffness matrix for an instance of a point mass element.

This method will return the stiffness matrix for an instance of a point mass element.

Returns:
Knp.ndarray

A matrix of floats containing the values of the stiffness matrix.

Examples

>>> p1 = PointMass(n=0, mx=2, my=3, mz=4)
>>> p1.K()
array([[0., 0., 0.],
       [0., 0., 0.],
       [0., 0., 0.]])
M()#

Mass matrix for an instance of a point mass element.

This method will return the mass matrix for an instance of a point mass element.

Returns:
Mnp.ndarray

A matrix of floats containing the values of the mass matrix.

Examples

>>> p1 = PointMass(n=0, mx=2, my=3, mz=4)
>>> p1.M()
array([[2., 0., 0.],
       [0., 3., 0.],
       [0., 0., 4.]])
__init__(n=None, m=None, mx=None, my=None, mz=None, tag=None, scale_factor=1.0, color='DarkSalmon')#
dof_local_index()#

Get the local index for a element specific degree of freedom.

Returns:
local_index: namedtupple

A named tuple containing the local index.

Examples

>>> # Example using BearingElement
>>> from ross.bearing_seal_element import bearing_example
>>> bearing = bearing_example()
>>> bearing.dof_local_index()
LocalIndex(x_0=0, y_0=1, z_0=2)
dof_mapping()#

Degrees of freedom mapping.

Returns a dictionary with a mapping between degree of freedom and its index.

Returns:
dof_mappingdict

A dictionary containing the degrees of freedom and their indexes.

Examples

The numbering of the degrees of freedom for each node.

Being the following their ordering for a node:

x_0 - horizontal translation y_0 - vertical translation z_0 - axial translation

>>> p1 = PointMass(n=0, mx=2, my=3, mz=4)
>>> p1.dof_mapping()
{'x_0': 0, 'y_0': 1, 'z_0': 2}
classmethod get_base_class()#

Get the direct subclass of Element in the inheritance chain.

Returns the first class in the inheritance hierarchy that directly inherits from Element. This is useful for identifying the base element type when working with subclasses or indirect subclasses.

Returns:
base_classtype

The direct subclass of Element in the inheritance chain.

get_class_name_prefix(index=None)#

Extract prefix of the class name preceding ‘Element’, insert spaces before uppercase letters, and append an index number at the end.

Parameters:
indexint, optional

The index number to append at the end of the resulting string. Default is None.

Returns:
prefixstr

The processed class name prefix.

Examples

>>> # Example using BearingElement
>>> from ross.bearing_seal_element import bearing_example
>>> bearing = bearing_example()
>>> bearing.get_class_name_prefix()
'Bearing'
classmethod get_subclasses()#

Get all subclasses of the Element class.

Returns:
subclasseslist

A list containing all subclasses of the Element class.

classmethod load(file)#

Load an element from a .toml or .json file.

Parameters:
filestr, pathlib.Path

The name of the file the element will be loaded from.

Returns:
The element object.
classmethod read_toml_data(data)#

Read and parse data stored in a .toml or .json file.

The data passed to this method needs to be according to the format saved by the .save() method.

Parameters:
datadict

Dictionary obtained from toml.load() or json.load().

Returns:
The element object.

Examples

>>> # Example using BearingElement
>>> from tempfile import tempdir
>>> from pathlib import Path
>>> from ross.bearing_seal_element import bearing_example
>>> from ross.bearing_seal_element import BearingElement
>>> # create path for a temporary file
>>> file = Path(tempdir) / 'bearing1.toml'
>>> bearing1 = bearing_example()
>>> bearing1.save(file)
>>> bearing1_loaded = BearingElement.load(file)
>>> bearing1 == bearing1_loaded
True
save(file)#

Save the element in a .toml or .json file.

This function will save the element to a .toml or .json file. The file will have all the argument’s names and values that are needed to reinstantiate the element.

Parameters:
filestr, pathlib.Path

The name of the file the element will be saved in. The format is determined by the file extension (.toml or .json).

Examples

>>> # Example using DiskElement
>>> from tempfile import tempdir
>>> from pathlib import Path
>>> from ross.disk_element import disk_example
>>> # create path for a temporary file
>>> file = Path(tempdir) / 'disk.toml'
>>> disk = disk_example()
>>> disk.save(file)
summary()#

Present a summary for the element.

A pandas series with the element properties as variables.

Returns:
A pandas series.

Examples

>>> # Example using DiskElement
>>> from ross.disk_element import disk_example
>>> disk = disk_example()
>>> disk.summary()
n                             0
n_l                           0
n_r                           0...