Source code for sigmaepsilon.solid.fourier.result

from typing import Iterable, ClassVar, TYPE_CHECKING, Sequence
import numpy as np


__all__ = [
    "LoadCaseResultLinStat",
    "BeamLoadCaseResultLinStat",
    "PlateLoadCaseResultLinStat",
]


if TYPE_CHECKING:  # pragma: no cover
    import xarray as xr  # Only for type hints
    import pandas as pd  # Only for type hints


[docs] class LoadCaseResultLinStat: """ A class to store results of a linear static analysis for a single load case. """ __slots__ = ["_data", "_name", "_components"] components: ClassVar[Iterable[str]] strain_range: ClassVar[Sequence[int]] = [] def __init__( self, data, *, name: str | None = None, ): self._data = data self._name = name @property def data(self) -> np.ndarray: """ Returns the results as a ``numpy.ndarray``. """ return self._data @property def values(self) -> np.ndarray: """ Returns the results as a ``numpy.ndarray``. """ return self._data @property def strains(self) -> np.ndarray: """ Returns the strains as a ``numpy.ndarray``. """ if self.strain_range is None: # pragma: no cover raise ValueError("Strain range is not defined.") return self._data[:, list(self.strain_range)] @property def name(self) -> str | None: """ Returns the name of the results. """ return self._name @name.setter def name(self, value: str | None): """ Sets the name of the results. """ self._name = value
[docs] def to_xarray(self) -> "xr.DataArray": """ Returns the results as an instance of :class:`xarray.DataArray`. """ import xarray as xr nP = len(self.data) components = self.components coords = [np.arange(nP), components] return xr.DataArray( self.data, coords=coords, dims=["index", "component"], name=self.name )
[docs] def to_pandas(self) -> "pd.DataFrame": """ Returns the results as an instance of :class:`pandas.DataFrame`. """ import pandas as pd nP = len(self.data) components = self.components index = np.arange(nP) columns = components df = pd.DataFrame(self.data, index=index, columns=columns) df.index.name = "index" return df
[docs] class BeamLoadCaseResultLinStat(LoadCaseResultLinStat): """ A class to store results of linear static analysis for beams and a single load case. The class is a subclass of the base class :class:`~LoadCaseResultLinStat`, refer to its documentation for available methods and properties. The underlying data structure is a 2d NumPy array, where the first axis goes along the points of evaluation and the second axis goes along the following components: .. hint:: For a detailed explanation of the sign conventions, refer to the :ref:`theory guide <theory_guide>`. +-------+-------+--------------------------------------------------+ | Index | Name | Description | +=======+=======+==================================================+ | 0 | UY | Displacement in Y direction | +-------+-------+--------------------------------------------------+ | 1 | ROTZ | Rotation around Z axis | +-------+-------+--------------------------------------------------+ | 2 | CZ | Curvature related to bending around Z axis | +-------+-------+--------------------------------------------------+ | 3 | EXY | Engineering shear strain in the X-Y plane | +-------+-------+--------------------------------------------------+ | 4 | MZ | Bending moment around Z axis | +-------+-------+--------------------------------------------------+ | 5 | SY | Shear force in Y direction | +-------+-------+--------------------------------------------------+ See also -------- :class:`~LoadCaseResultLinStat` """ components = [ "UY", "ROTZ", "CZ", "EXY", "MZ", "SY", ] strain_range = range(2, 4)
[docs] class PlateLoadCaseResultLinStat(LoadCaseResultLinStat): """ A class to store results of linear static analysis for plates and a single load case. The class is a subclass of the base class :class:`~LoadCaseResultLinStat`, refer to its documentation for available methods and properties. The underlying data structure is a 2d NumPy array, where the first axis goes along the points of evaluation and the second axis goes along the following components: .. hint:: For a detailed explanation of the sign conventions, refer to the :ref:`theory guide <theory_guide>`. +-------+-------+--------------------------------------------------+ | Index | Name | Description | +=======+=======+==================================================+ | 0 | UZ | Displacement in Z direction | +-------+-------+--------------------------------------------------+ | 1 | ROTX | Rotation around X axis (CCW) | +-------+-------+--------------------------------------------------+ | 2 | ROTY | Rotation around Y axis (CCW) | +-------+-------+--------------------------------------------------+ | 3 | CX | Curvature related to bending around X axis | +-------+-------+--------------------------------------------------+ | 4 | CY | Curvature related to bending around Y axis | +-------+-------+--------------------------------------------------+ | 5 | CXY | Twisting curvature | +-------+-------+--------------------------------------------------+ | 6 | EXZ | Engineering shear strain in X-Z plane | +-------+-------+--------------------------------------------------+ | 7 | EYZ | Engineering shear strain in Y-Z plane | +-------+-------+--------------------------------------------------+ | 8 | MX | Bending moment around Y axis (CCW) | +-------+-------+--------------------------------------------------+ | 9 | MY | Bending moment around X axis (CW) | +-------+-------+--------------------------------------------------+ | 10 | MXY | Twisting moment | +-------+-------+--------------------------------------------------+ | 11 | QX | Shear force on the X-Z plane (+Z) | +-------+-------+--------------------------------------------------+ | 12 | QY | Shear force on the Y-Z plane (+Z) | +-------+-------+--------------------------------------------------+ See also -------- :class:`~LoadCaseResultLinStat` """ components = [ "UZ", "ROTX", "ROTY", "CX", "CY", "CXY", "EXZ", "EYZ", "MX", "MY", "MXY", "QX", "QY", ] strain_range = range(3, 8)