Example #1
0
 def setup(self):
     # Define a mode shape with deflection x^2 in the y direction
     self.x = x = arange(0, 10.1, 1)
     self.L = self.x[-1]
     zero = 0 * x
     shapes = c_[zero, x**2, zero].reshape((len(x), 3, 1))
     rotations = c_[zero, 2 * x, zero].reshape((len(x), 3, 1))
     self.modes = ModalRepresentation(x,
                                      freqs=[1],
                                      shapes=shapes,
                                      rotations=rotations)
Example #2
0
 def setup(self):
     # Define a mode shape with deflection x^2 in the y direction
     self.x = x = arange(0, 10.1, 1)
     self.L = self.x[-1]
     zero = 0*x
     shapes    = c_[zero, x**2, zero].reshape((len(x), 3, 1))
     rotations = c_[zero, 2*x,  zero].reshape((len(x), 3, 1))
     self.modes = ModalRepresentation(x, freqs=[1], shapes=shapes,
                                      rotations=rotations)
Example #3
0
class ModalRepesentationWithNoModes_Tests:
    def setup(self):
        # Define a mode shape with deflection x^2 in the y direction
        self.x = x = arange(0, 10.1, 1)
        self.L = self.x[-1]
        zero = 0 * x
        shapes = c_[zero, x**2, zero].reshape((len(x), 3, 1))
        rotations = c_[zero, 2 * x, zero].reshape((len(x), 3, 1))
        self.modes = ModalRepresentation(x,
                                         freqs=[1],
                                         shapes=shapes,
                                         rotations=rotations)

    def _uniform_force(self, direction, magnitude):
        P = zeros((len(self.x), 3))
        P[:, direction] = magnitude
        return P

    def test_distributed_loading_for_uniform_axial_loading(self):
        P = self._uniform_force(0, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [0])
        assert_aae(Qr, [3.4 * 10, 0, 0])
        assert_aae(Qw, [0, 0, 0])  # axial so no moment
        assert_aae(Qe, [0])  # axial so no strain force

    def test_distributed_loading_uniform_loading_aligned_with_mode(self):
        P = self._uniform_force(1, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [0])
        assert_aae(Qr, [0, 3.4 * 10, 0])
        assert_aae(Qw, [0, 0, 3.4 * self.L**2 / 2])
        # Generalised force should be integral of applied
        # force and deflection. Integral of x^2 if L^3 / 3
        assert_aae(Qe, [3.4 * trapz(self.x**2, self.x)])

    def test_distributed_loading_uniform_loading_not_aligned_with_mode(self):
        P = self._uniform_force(2, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [0])
        assert_aae(Qr, [0, 0, 3.4 * 10])
        assert_aae(Qw, [0, -3.4 * self.L**2 / 2, 0])
        assert_aae(Qe, [0])
Example #4
0
class ModalRepesentationWithNoModes_Tests:
    def setup(self):
        # Define a mode shape with deflection x^2 in the y direction
        self.x = x = arange(0, 10.1, 1)
        self.L = self.x[-1]
        zero = 0*x
        shapes    = c_[zero, x**2, zero].reshape((len(x), 3, 1))
        rotations = c_[zero, 2*x,  zero].reshape((len(x), 3, 1))
        self.modes = ModalRepresentation(x, freqs=[1], shapes=shapes,
                                         rotations=rotations)

    def _uniform_force(self, direction, magnitude):
        P = zeros((len(self.x), 3))
        P[:, direction] = magnitude
        return P

    def test_distributed_loading_for_uniform_axial_loading(self):
        P = self._uniform_force(0, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [0])
        assert_aae(Qr, [3.4 * 10, 0, 0])
        assert_aae(Qw, [0, 0, 0])         # axial so no moment
        assert_aae(Qe, [0])               # axial so no strain force

    def test_distributed_loading_uniform_loading_aligned_with_mode(self):
        P = self._uniform_force(1, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [0])
        assert_aae(Qr, [0, 3.4 * 10, 0])
        assert_aae(Qw, [0, 0, 3.4 * self.L**2 / 2])
        # Generalised force should be integral of applied
        # force and deflection. Integral of x^2 if L^3 / 3
        assert_aae(Qe, [3.4 * trapz(self.x**2, self.x)])

    def test_distributed_loading_uniform_loading_not_aligned_with_mode(self):
        P = self._uniform_force(2, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [0])
        assert_aae(Qr, [0, 0, 3.4 * 10])
        assert_aae(Qw, [0, -3.4 * self.L**2 / 2, 0])
        assert_aae(Qe, [0])
    def setup(self):
        x = linspace(0, self.length, 50)
        density = self.mass / self.length
        # One mode shape: linear in z direction.
        shape = linspace(0, 1, 50)
        rotation = -np.ones(50) / self.length
        shapes = c_[0 * x, 0 * x, shape].reshape((len(x), 3, 1))
        rotations = c_[0 * x, rotation, 0 * x].reshape((len(x), 3, 1))

        # Natural frequency: w^2 = k/I
        I0 = self.mass * (self.length**2 / 3)  # inertia about end
        freq = (self.stiffness / I0)**0.5
        modes = ModalRepresentation(x, density, shapes, rotations, [freq])
        self.beam = ModalElement('beam', modes)
Example #6
0
class ModalRepesentationWithNoModes_Tests:
    def setup(self):
        self.x = arange(0, 10.1, 1)
        self.L = self.x[-1]
        self.modes = ModalRepresentation(self.x)

    def _uniform_force(self, direction, magnitude):
        P = zeros((len(self.x), 3))
        P[:, direction] = magnitude
        return P

    def test_distributed_loading_for_uniform_axial_loading(self):
        P = self._uniform_force(0, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [])
        assert_aae(Qr, [3.4 * self.L, 0, 0])
        assert_aae(Qw, [0, 0, 0])         # axial so no moment
        assert_equal(Qe.shape, (0,))

    def test_distributed_loading_for_uniform_perpendicular_loading(self):
        P = self._uniform_force(1, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [])
        assert_aae(Qr, [0, 3.4 * self.L, 0])
        assert_aae(Qw, [0, 0, 3.4 * self.L**2 / 2])
        assert_equal(Qe.shape, (0,))
Example #7
0
class ModalRepesentationWithNoModes_Tests:
    def setup(self):
        self.x = arange(0, 10.1, 1)
        self.L = self.x[-1]
        self.modes = ModalRepresentation(self.x)

    def _uniform_force(self, direction, magnitude):
        P = zeros((len(self.x), 3))
        P[:, direction] = magnitude
        return P

    def test_distributed_loading_for_uniform_axial_loading(self):
        P = self._uniform_force(0, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [])
        assert_aae(Qr, [3.4 * self.L, 0, 0])
        assert_aae(Qw, [0, 0, 0])  # axial so no moment
        assert_equal(Qe.shape, (0, ))

    def test_distributed_loading_for_uniform_perpendicular_loading(self):
        P = self._uniform_force(1, 3.4)
        Qr, Qw, Qe = self.modes.distributed_loading(P, [])
        assert_aae(Qr, [0, 3.4 * self.L, 0])
        assert_aae(Qw, [0, 0, 3.4 * self.L**2 / 2])
        assert_equal(Qe.shape, (0, ))
def make_a_modal_beam(length, density=None, section_inertia=None):
    x = linspace(0, length, 10)
    modes = ModalRepresentation(x, density, section_inertia=section_inertia)
    beam = ModalElement('beam', modes)
    return beam
def _mock_rigid_uniform_modes(density, length):
    """Return empty modal representation of 20m long rigid beam"""
    x = arange(0, length + 0.01)
    return ModalRepresentation(x, density * ones_like(x))
Example #10
0
 def setup(self):
     self.x = arange(0, 10.1, 1)
     self.L = self.x[-1]
     self.modes = ModalRepresentation(self.x)
Example #11
0
 def setup(self):
     self.x = arange(0, 10.1, 1)
     self.L = self.x[-1]
     self.modes = ModalRepresentation(self.x)