Source code for tracesuite.trace.eigenmode

"""Contains the general representation of an Eigenmode as well as related classes and methods."""
from __future__ import annotations

import numpy as np

from tracesuite.trace import _trace

from .trace_entity_base import TraceEntityBase


[docs] class Eigenmode(TraceEntityBase): """Python class representing a general eigenmode in the Trace context, handled by an instance of `SolverCntl`.""" def __init__(self, cntl, trace_eigenmode): """Construct instance from associated TRACE eigenmode and the Simulation handle it belongs to. :param cntl: Links this Eigenmode to the associated Trace computation and allows convenient access to e.g. its global meta data. :type cntl: _trace.SolverCntl :param trace_eigenmode: Uniquely links this class to a Trace c-struct of type `SolidEigenmodeGroupMetadata`. :type trace_eigenmode: _trace.TraceEigenmode """ TraceEntityBase.__init__(self, cntl) self._trace_eigenmode = trace_eigenmode self._raw_data = trace_eigenmode.get_data() self.dim_f_dis = _trace.get_dimension_factor_by_name("ModalDisplacementReal") self.dim_f_vel = _trace.get_dimension_factor_by_name("ModalVelocityReal") self.dim_f_acc = _trace.get_dimension_factor_by_name("ModalAccelerationReal") self.dim_f_for = _trace.get_dimension_factor_by_name("ModalForceReal") self.modal_mass = (np.array(self._raw_data["mass"], copy=False)[0] * _trace.get_dimension_factor_by_name("ModalMass")) self.modal_damping = (np.array(self._raw_data["damping"], copy=False)[0] * _trace.get_dimension_factor_by_name("ModalDamping")) self.modal_stiffness = (np.array(self._raw_data["stiffness"], copy=False)[0] * _trace.get_dimension_factor_by_name("ModalStiffness")) self.ibpa = (np.array(self._raw_data["ibpa"], copy=False)[0] * _trace.get_dimension_factor_by_name("InterBladePhaseAngle")) self.force_offset = (np.array(self._raw_data["TimeStepCurrent"]["staticforce"], copy=False)[0] * _trace.get_dimension_factor_by_name( "ModalForceReal")) self.amplification_factor = (np.array(self._raw_data["ampfactor"], copy=False)[0] * _trace.get_dimension_factor_by_name("AmplificationFactor")) @property def name(self): """Return the name of this eigenmode.""" return self._trace_eigenmode.name @property def displacement(self): """The modal displacement at the next time step. Is readable and writeable.""" return np.array(self._raw_data["TimeStepNext"]["displacement"], copy=False)[0] * self.dim_f_dis @displacement.setter def displacement(self, d): np.array(self._raw_data["TimeStepNext"]["displacement"], copy=False)[0] = d / self.dim_f_dis self._trace_eigenmode.set_modified() @property def velocity(self): """The modal velocity at the next time step. Is readable and writeable.""" return np.array(self._raw_data["TimeStepNext"]["velocity"], copy=False)[0] * self.dim_f_vel @velocity.setter def velocity(self, d): np.array(self._raw_data["TimeStepNext"]["velocity"], copy=False)[0] = d / self.dim_f_vel self._trace_eigenmode.set_modified() @property def acceleration(self): """The modal acceleration at the next time step. Is readable and writeable.""" return np.array(self._raw_data["TimeStepNext"]["acceleration"], copy=False)[0] * self.dim_f_acc @acceleration.setter def acceleration(self, d): np.array(self._raw_data["TimeStepNext"]["acceleration"], copy=False)[0] = d / self.dim_f_acc self._trace_eigenmode.set_modified() @property def force(self): """The modal force at the next time step. Is only readable.""" return np.array(self._raw_data["TimeStepNext"]["force"], copy=False)[0] * self.dim_f_for @property def current_force(self): """The modal force at the current time step. Is only readable.""" return np.array(self._raw_data["TimeStepCurrent"]["force"], copy=False)[0] * self.dim_f_for @property def current_displacement(self): """The modal displacement at the current time step. Is only readable.""" return np.array(self._raw_data["TimeStepCurrent"]["displacement"], copy=False)[0] * self.dim_f_dis @property def current_velocity(self): """The modal velocity at the current time step. Is only readable.""" return np.array(self._raw_data["TimeStepCurrent"]["velocity"], copy=False)[0] * self.dim_f_vel @property def current_acceleration(self): """The modal acceleration at the current time step. Is only readable.""" return np.array(self._raw_data["TimeStepCurrent"]["acceleration"], copy=False)[0] * self.dim_f_acc