N2PComponent#

class NaxToPy.Core.Classes.N2PComponent.N2PComponent(name, sections, result_father)[source]#

Bases: object

Class which contains the information associated to a component of a N2PResult instance.

get_result_array(sections=None, aveSections=-1, cornerData=False, aveNodes=-1, variation=100, realPolar=0, coordsys: int = -1000, v1: tuple = (1, 0, 0), v2: tuple = (0, 1, 0)) tuple[list, str][source]#

Deprecated method. Please, use get_result_list instead for asking the results as a list. If a numpy array is preferred, use get_result_ndarray.

get_result_list(sections=None, aveSections=-1, cornerData=False, aveNodes=-1, variation=100, realPolar=0, coordsys: int = -1000, v1: tuple | ndarray = (1, 0, 0), v2: tuple | ndarray = (0, 1, 0)) tuple[list, str][source]#

Get the result array as a list with position information.

Returns a tuple containing the list of floats with the requested results and a string indicating the position/location of the results.

Parameters:
  • sections (list[str] | list[N2PSection]) – Optional. Sections on which to perform operations. If None (default), operations are performed on all sections.

  • aveSections (int, default -1) –

    Optional. Operation to perform among sections:

    • -1: Maximum (default)

    • -2: Minimum

    • -3: Average

    • -4: Extreme

    • -6: Difference

  • cornerData (bool, default False) –

    Optional. Flag to control result location:

    • True: Results at element nodes

    • False: Results at element centroid (default)

  • aveNodes (int, default -1) –

    Optional. Operation among nodes when cornerData=True:

    • 0: None

    • -1: Maximum (default)

    • -2: Minimum

    • -3: Average

    • -6: Difference

  • variation (int, default 100) –

    Optional. Averaging parameter between nodes (0-100):

    • 0: No averaging between nodes

    • 100: Total averaging between nodes (default)

  • realPolar (int, default 0) –

    Optional. Data type for complex results:

    • 1: Real/Imaginary

    • 2: Magnitude/Phase

  • coordsys (int, default -1000) –

    Optional. Coordinate system for result representation:

    • 0: Global coordinate system

    • -1: Material coordinate system

    • -10: User defined coordinate system

    • -20: Element/Node user defined coordinate system

    • -1000: Analysis coordinate system (default)

    • >0: Solver ID of predefined coordinate system

    Note

    In Nastran > 2021 the results in the OP2 could be in material coordinate system if the user requested it.

  • v1 (tuple[float] | numpy.ndarray, default (1, 0, 0)) – Optional. 3D vector defining the x-axis of the coordinate system.

  • v2 (tuple[float] | numpy.ndarray, default (0, 1, 0)) –

    Optional. 3D vector defining the xy-plane. The coordinate system axes are generated as:

    • x = v1

    • z = v1 ^ v2 (cross product)

    • y = z ^ x (cross product)

Returns:

Tuple containing:

  • results list: list of floats with the requested results

  • position: string indicating the location/position of the results

Return type:

tuple[list[float], str]

get_result_ndarray(sections=None, aveSections=-1, cornerData=False, aveNodes=-1, variation=100, realPolar=0, coordsys: int = -1000, v1: tuple | ndarray = (1, 0, 0), v2: tuple | ndarray = (0, 1, 0), filter_list: list = None) tuple[array, str][source]#

Get the result array as a numpy array with position information.

Returns a tuple containing the numpy array of floats with the requested results and a string indicating the position/location of the results.

Parameters:
  • sections (list[str] | list[N2PSection]) – Optional. Sections on which to perform operations. If None (default), operations are performed on all sections.

  • aveSections (int, default -1) –

    Optional. Operation to perform among sections:

    • -1: Maximum (default)

    • -2: Minimum

    • -3: Average

    • -4: Extreme

    • -6: Difference

  • cornerData (bool, default False) –

    Optional. Flag to control result location:

    • True: Results at element nodes

    • False: Results at element centroid (default)

  • aveNodes (int, default -1) –

    Optional. Operation among nodes when cornerData=True:

    • 0: None

    • -1: Maximum (default)

    • -2: Minimum

    • -3: Average

    • -6: Difference

  • variation (int, default 100) –

    Optional. Averaging parameter between nodes (0-100):

    • 0: No averaging between nodes

    • 100: Total averaging between nodes (default)

  • realPolar (int, default 0) –

    Optional. Data type for complex results:

    • 1: Real/Imaginary

    • 2: Magnitude/Phase

  • coordsys (int, default -1000) –

    Optional. Coordinate system for result representation:

    • 0: Global coordinate system

    • -1: Material coordinate system

    • -10: User defined coordinate system

    • -20: Element/Node user defined coordinate system

    • -1000: Analysis coordinate system (default)

    • >0: Solver ID of predefined coordinate system

    Note

    In Nastran > 2021 the results in the OP2 could be in material coordinate system if the user requested it.

  • v1 (tuple[float] | numpy.ndarray, default (1, 0, 0)) – Optional. 3D vector defining the x-axis of the coordinate system.

  • v2 (tuple[float] | numpy.ndarray, default (0, 1, 0)) –

    Optional. 3D vector defining the xy-plane. The coordinate system axes are generated as:

    • x = v1

    • z = v1 ^ v2 (cross product)

    • y = z ^ x (cross product)

  • filter_list (list[N2PElement] | list[N2PNode]) –

    Optional. List of elements or nodes where results are requested. If None, results for all elements/nodes are returned.

    Warning

    Filtering results can slow down extraction. If results are needed for multiple separate lists, extract all results first and filter afterward.

Returns:

Tuple containing:

  • results array: numpy array of floats with the requested results

  • position: string indicating the location/position of the results

Return type:

tuple[numpy.ndarray, str]

Examples

>>> # N2PComponent is a N2PLoadCase.get_results("DISPLACEMENTS").get_component("X")
>>> displ_X_array, where = N2PComponent.get_result_ndarray(
...     aveSections=-3,
...     coordsys=-1
... )
>>> # N2PComponent is a N2PLoadCase.get_results("STRESSES").get_component("XX")
>>> stress_array, where = N2PComponent.get_result_ndarray(
...     v1=(-1, 0, 0),
...     v2=(0, -1, 0)
... )
property IsTransformable: bool#

Property that keeps if the component of a result is transformable in other coordinate system.

property Name: str#

Name of the component.

property Sections: list[N2PSection, ...]#

Returns a list of N2PSection objects with all the sections contained in the component.