ross.DiskElement
Contents
ross.DiskElement#
- class ross.DiskElement(n, m, Id, Ip, tag=None, scale_factor=1.0, color='Firebrick')#
A disk element.
This class creates a disk element from input data of inertia and mass.
- Parameters:
- n: int
Node in which the disk will be inserted.
- mfloat, pint.Quantity
Mass of the disk element.
- Idfloat, pint.Quantity
Diametral moment of inertia.
- Ipfloat, pint.Quantity
Polar moment of inertia
- tagstr, optional
A tag to name the element Default is None
- scale_factor: float or str, optional
The scale factor is used to scale the disk drawing. For disks it is also possible to provide ‘mass’ as the scale factor. In this case the code will calculate scale factors for each disk based on the disk with the higher mass. Notice that in this case you have to create all disks with the scale_factor=’mass’. Default is 1.
- colorstr, optional
A color to be used when the element is represented. Default is ‘Firebrick’.
Examples
>>> disk = DiskElement(n=0, m=32, Id=0.2, Ip=0.3) >>> disk.Ip 0.3
Methods
- C()#
Damping matrix for an instance of a disk element.
This method will return the damping matrix for an instance of a disk element.
- Returns:
- Cnp.ndarray
A matrix of floats containing the values of the damping matrix.
Examples
>>> disk = disk_example() >>> disk.C() array([[0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.]])
- G()#
Gyroscopic matrix for an instance of a disk element.
This method will return the gyroscopic matrix for an instance of a disk element.
- Returns:
- G: np.ndarray
Gyroscopic matrix for the disk element.
Examples
>>> disk = DiskElement(0, 32.58972765, 0.17808928, 0.32956362) >>> disk.G().round(2) array([[ 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.33, 0. ], [ 0. , 0. , 0. , -0.33, 0. , 0. ], [ 0. , 0. , 0. , 0. , 0. , 0. ]])
- K()#
Stiffness matrix for an instance of a disk element.
This method will return the stiffness matrix for an instance of a disk element.
- Returns:
- Knp.ndarray
A matrix of floats containing the values of the stiffness matrix.
Examples
>>> disk = disk_example() >>> disk.K().round(2) array([[0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.], [0., 0., 0., 0., 0., 0.]])
- Kdt()#
Dynamic stiffness matrix for an instance of a disk element.
Stiffness matrix for the disk element associated with the transient motion. It needs to be multiplied by the angular acceleration when considered in time dependent analyses.
- Returns:
- Kdtnp.ndarray
A matrix of floats containing the values of the dynamic stiffness matrix.
Examples
>>> disk = disk_example() >>> disk.Kdt().round(2) array([[0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. ], [0. , 0. , 0. , 0.33, 0. , 0. ], [0. , 0. , 0. , 0. , 0. , 0. ]])
- M()#
Mass matrix for an instance of a disk element.
This method will return the mass matrix for an instance of a disk element.
- Returns:
- Mnp.ndarray
A matrix of floats containing the values of the mass matrix.
Examples
>>> disk = DiskElement(0, 32.58972765, 0.17808928, 0.32956362) >>> disk.M().round(2) array([[32.59, 0. , 0. , 0. , 0. , 0. ], [ 0. , 32.59, 0. , 0. , 0. , 0. ], [ 0. , 0. , 32.59, 0. , 0. , 0. ], [ 0. , 0. , 0. , 0.18, 0. , 0. ], [ 0. , 0. , 0. , 0. , 0.18, 0. ], [ 0. , 0. , 0. , 0. , 0. , 0.33]])
- __init__(n, m, Id, Ip, tag=None, scale_factor=1.0, color='Firebrick')#
- static calculate_Id(Ip, m, width)#
- static calculate_Ip(m, i_d, o_d)#
- static calculate_mass(rho, width, i_d, o_d)#
- static calculate_width(rho, m, i_d, o_d)#
- 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 alpha_0 - rotation around horizontal beta_0 - rotation around vertical theta_0 - torsion around axial
>>> disk = disk_example() >>> disk.dof_mapping() {'x_0': 0, 'y_0': 1, 'z_0': 2, 'alpha_0': 3, 'beta_0': 4, 'theta_0': 5}
- classmethod from_geometry(n, material, width, i_d, o_d, tag=None, scale_factor=1.0, color='Firebrick')#
Create a disk element from geometry properties.
This class method will create a disk element from geometry data. Properties are calculated as per [Friswell, 2010], appendix 1 for a hollow cylinder:
Mass:
\(m = \rho \pi w (d_o^2 - d_i^2) / 4\)
Polar moment of inertia:
\(I_p = m (d_o^2 + d_i^2) / 8\)
Diametral moment of inertia:
\(I_d = \frac{1}{2} I_p + \frac{1}{12} m w^2\)
Where \(\rho\) is the material density, \(w\) is the disk width, \(d_o\) is the outer diameter and \(d_i\) is the inner diameter.
- Parameters:
- nint
Node in which the disk will be inserted.
- material: ross.Material
Disk material.
- widthfloat, pint.Quantity
The disk width.
- i_dfloat, pint.Quantity
Inner diameter.
- o_dfloat, pint.Quantity
Outer diameter.
- tagstr, optional
A tag to name the element Default is None
- scale_factor: float, optional
The scale factor is used to scale the disk drawing. Default is 1.
- colorstr, optional
A color to be used when the element is represented. Default is ‘Firebrick’ (Cardinal).
- Attributes:
- mfloat
Mass of the disk element.
- Idfloat
Diametral moment of inertia.
- Ipfloat
Polar moment of inertia
Examples
>>> from ross.materials import steel >>> disk = DiskElement.from_geometry(0, steel, 0.07, 0.05, 0.28) >>> disk.Ip 0.32956362089137037
- classmethod from_table(file, sheet_name=0, tag=None, scale_factor=None, color=None)#
Instantiate one or more disks using inputs from an Excel table.
A header with the names of the columns is required. These names should match the names expected by the routine (usually the names of the parameters, but also similar ones). The program will read every row bellow the header until they end or it reaches a NaN.
- Parameters:
- filestr
Path to the file containing the disk parameters.
- sheet_nameint or str, optional
Position of the sheet in the file (starting from 0) or its name. If none is passed, it is assumed to be the first sheet in the file.
- tag_listlist, optional
list of tags for the disk elements. Default is None
- scale_factor: list, optional
List of scale factors for the disk elements patches. The scale factor is used to scale the disk drawing. Default is 1.
- colorlist, optional
A color to be used when the element is represented. Default is ‘Firebrick’.
- Returns:
- disklist
A list of disk objects.
Examples
>>> import os >>> file_path = os.path.dirname(os.path.realpath(__file__)) + '/tests/data/shaft_si.xls' >>> list_of_disks = DiskElement.from_table(file_path, sheet_name="More") >>> list_of_disks[0] DiskElement(Id=0.0, Ip=0.0, m=15.12, color='Firebrick', n=3, scale_factor=1, tag=None)
- 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()#
- classmethod load(file)#
- 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...