aerosandbox.weights.mass_properties#

Module Contents#

Classes#

MassProperties

Mass properties of a rigid 3D object.

Attributes#

mp1

class aerosandbox.weights.mass_properties.MassProperties(mass=None, x_cg=0.0, y_cg=0.0, z_cg=0.0, Ixx=0.0, Iyy=0.0, Izz=0.0, Ixy=0.0, Iyz=0.0, Ixz=0.0)[source]#

Bases: aerosandbox.common.AeroSandboxObject

Mass properties of a rigid 3D object.

## Notes on Inertia Tensor Definition

This class uses the standard mathematical definition of the inertia tensor, which is different from the alternative definition used by some CAD and CAE applications (such as SolidWorks, NX, etc.). These differ by a sign flip in the products of inertia.

Specifically, we define the inertia tensor using the standard convention:

[ I11 I12 I13 ] [ Ixx Ixy Ixz ] [sum(m*(y^2+z^2)) -sum(m*x*y) -sum(m*x*z) ]

I = [ I21 I22 I23 ] = [ Ixy Iyy Iyz ] = [-sum(m*x*y) sum(m*(x^2+z^2)) -sum(m*y*z) ]

[ I31 I32 I33 ] [ Ixz Iyz Izz ] [-sum(m*x*z) -sum(m*y*z) sum(m*(x^2+y^2))]

Whereas SolidWorks, NX, etc. define the inertia tensor as:

[ I11 I12 I13 ] [ Ixx -Ixy -Ixz ] [sum(m*(y^2+z^2)) -sum(m*x*y) -sum(m*x*z) ]

I = [ I21 I22 I23 ] = [-Ixy Iyy -Iyz ] = [-sum(m*x*y) sum(m*(x^2+z^2)) -sum(m*y*z) ]

[ I31 I32 I33 ] [-Ixz -Iyz Izz ] [-sum(m*x*z) -sum(m*y*z) sum(m*(x^2+y^2))]

See also: https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_tensor

Parameters:
  • mass (Union[float, aerosandbox.numpy.ndarray]) –

  • x_cg (Union[float, aerosandbox.numpy.ndarray]) –

  • y_cg (Union[float, aerosandbox.numpy.ndarray]) –

  • z_cg (Union[float, aerosandbox.numpy.ndarray]) –

  • Ixx (Union[float, aerosandbox.numpy.ndarray]) –

  • Iyy (Union[float, aerosandbox.numpy.ndarray]) –

  • Izz (Union[float, aerosandbox.numpy.ndarray]) –

  • Ixy (Union[float, aerosandbox.numpy.ndarray]) –

  • Iyz (Union[float, aerosandbox.numpy.ndarray]) –

  • Ixz (Union[float, aerosandbox.numpy.ndarray]) –

property xyz_cg[source]#
property inertia_tensor[source]#
__repr__()[source]#

Return repr(self).

Return type:

str

__getitem__(index)[source]#

Indexes one item from each attribute of an MassProperties instance. Returns a new MassProperties instance.

Parameters:

index – The index that is being called; e.g.,: >>> first_mass_props = mass_props[0]

Return type:

MassProperties

Returns: A new MassProperties instance, where each attribute is subscripted at the given value, if possible.

__len__()[source]#
__array__(dtype='O')[source]#

Allows NumPy array creation without infinite recursion in __len__ and __getitem__.

__neg__()[source]#
Return type:

MassProperties

__add__(other)[source]#

Combines one MassProperties object with another.

Parameters:

other (MassProperties) –

Return type:

MassProperties

__radd__(other)[source]#

Allows sum() to work with MassProperties objects.

Basically, makes addition commutative.

Parameters:

other (MassProperties) –

Return type:

MassProperties

__sub__(other)[source]#

Subtracts one MassProperties object from another. (opposite of __add__() )

Parameters:

other (MassProperties) –

Return type:

MassProperties

__mul__(other)[source]#

Returns a new MassProperties object that is equivalent to if you had summed together N (with other interpreted as N) identical MassProperties objects.

Parameters:

other (float) –

Return type:

MassProperties

__rmul__(other)[source]#

Allows multiplication of a scalar by a MassProperties object. Makes multiplication commutative.

Parameters:

other (float) –

Return type:

MassProperties

__truediv__(other)[source]#

Returns a new MassProperties object that is equivalent to if you had divided the mass of the current MassProperties object by a factor.

Parameters:

other (float) –

Return type:

MassProperties

allclose(other, rtol=1e-05, atol=1e-08, equal_nan=False)[source]#
Parameters:

other (MassProperties) –

Return type:

bool

inv_inertia_tensor()[source]#

Computes the inverse of the inertia tensor, in a slightly more efficient way than raw inversion by exploiting its known structure.

If you are effectively using this inertia tensor to solve a linear system, you should use a linear algebra solve() method (ideally via Cholesky decomposition) instead, for best speed.

get_inertia_tensor_about_point(x=0.0, y=0.0, z=0.0, return_tensor=True)[source]#

Returns the inertia tensor about an arbitrary point. Using https://en.wikipedia.org/wiki/Parallel_axis_theorem#Tensor_generalization

Parameters:
  • x (float) – x-position of the new point, in the same axes as this MassProperties instance is specified in.

  • y (float) – y-position of the new point, in the same axes as this MassProperties instance is specified in.

  • z (float) – z-position of the new point, in the same axes as this MassProperties instance is specified in.

  • return_tensor (bool) – A switch for the desired return type; see below for details. [boolean]

Returns:

Returns the new inertia tensor, as a 2D numpy ndarray. If return_tensor is False:

Returns the components of the new inertia tensor, as a tuple. If J is the new inertia tensor, the tuple returned is: (Jxx, Jyy, Jzz, Jxy, Jyz, Jxz)

Return type:

If return_tensor is True

is_physically_possible()[source]#

Checks whether it’s possible for this MassProperties object to correspond to the mass properties of a real physical object.

Assumes that all physically-possible objects have a positive mass (or density).

Some special edge cases:

  • A MassProperties object with mass of 0 (i.e., null object) will return True. Note: this will return

True even if the inertia tensor is not zero (which would basically be infinitesimal point masses at infinite distance).

  • A MassProperties object that is a point mass (i.e., inertia tensor is all zeros) will return True.

Returns:

True if the MassProperties object is physically possible, False otherwise.

Return type:

bool

is_point_mass()[source]#

Returns True if this MassProperties object corresponds to a point mass, False otherwise.

Return type:

bool

generate_possible_set_of_point_masses(method='optimization', check_if_already_a_point_mass=True)[source]#

Generates a set of point masses (represented as MassProperties objects with zero inertia tensors), that, when combined, would yield this MassProperties object.

Note that there are an infinite number of possible sets of point masses that could yield this MassProperties object. This method returns one possible set of point masses, but there are many others.

Example

>>> mp = MassProperties(mass=1, Ixx=1, Iyy=1, Izz=1, Ixy=0.1, Iyz=-0.1, Ixz=0.1)
>>> point_masses = mp.generate_possible_set_of_point_masses()
>>> mp.allclose(sum(point_masses))  # Asserts these are equal, within tolerance
True
Parameters:
  • method – The method to use to generate the set of point masses. Currently, only “optimization” is supported.

  • check_if_already_a_point_mass (bool) –

Returns:

A list of MassProperties objects, each of which is a point mass (i.e., zero inertia tensor).

Return type:

List[MassProperties]

export_AVL_mass_file(filename)[source]#

Exports this MassProperties object to an AVL mass file.

Note: AVL uses the SolidWorks convention for inertia tensors, which is different from the typical mathematical convention, and the convention used by this MassProperties class. In short, these differ by a sign flip in the products of inertia. More details available in the MassProperties docstring. See also: https://en.wikipedia.org/wiki/Moment_of_inertia#Inertia_tensor

Parameters:

filename – The filename to export to.

Return type:

None

Returns: None

aerosandbox.weights.mass_properties.mp1[source]#