Пример #1
0
    def test_solve_accelerations(self):
        # solve_accelerations() should find:
        #  (a) response of system to forces (here, gravity)
        #  (b) include any prescribed accelerations in qdd vector
        g = 9.81
        s = System(gravity=g)
        j = FreeJoint('joint')
        b = RigidBody('body', mass=23.54, inertia=52.1 * np.eye(3))
        s.add_leaf(j)
        j.add_leaf(b)
        s.setup()

        # Prescribe horizontal acceleration. Vertical acceleration
        # should result from gravity.
        s.prescribe(j, 2.3, part=[0])  # x acceleration

        # Initially accelerations are zero
        assert_aae(j.ap, 0)
        assert_aae(j.ad, 0)
        assert_aae(j.astrain, 0)

        # Solve accelerations & check
        s.solve_accelerations()
        s.update_kinematics()
        assert_aae(j.ap, 0)  # ground
        assert_aae(j.ad, [2.3, 0, -g, 0, 0, 0])
        assert_aae(j.astrain, j.ad)  # not always true, but works for FreeJoint
Пример #2
0
    def test_solve_accelerations_coupling(self):
        # Further to test above, check that coupling between prescribed
        # accelerations and other dofs is correct. For example, if there
        # is a rigid body vertically offset from the joint, then a
        # prescribed horizontal acceleration should cause an angular
        # acceleration as well as the translational acceleration.
        s = System()
        j = FreeJoint('joint')
        c = RigidConnection('conn', [0, 0, 1.7])
        b = RigidBody('body', mass=23.54, inertia=74.1 * np.eye(3))
        s.add_leaf(j)
        j.add_leaf(c)
        c.add_leaf(b)
        s.setup()

        # Prescribe horizontal acceleration, solve other accelerations
        s.prescribe(j, 2.3, part=[0])  # x acceleration
        s.update_kinematics()          # update system to show prescribed acc
        s.solve_accelerations()        # solve free accelerations
        s.update_kinematics()          # update system to show solution

        # Ground shouldn't move
        assert_aae(j.ap, 0)

        # Need angular acceleration = (m a_x L) / I0
        I0 = 74.1 + (23.54 * 1.7**2)
        expected_angular_acc = -(23.54 * 2.3 * 1.7) / I0
        assert_aae(j.ad, [2.3, 0, 0, 0, expected_angular_acc, 0])
        assert_aae(j.astrain, j.ad)  # not always true, but works for FreeJoint
Пример #3
0
    def test_distal_forces_cause_acceleration(self):
        j = FreeJoint('joint')
        b = RigidBody('body', mass=3, inertia=np.diag([7, 7, 7]))
        s = System()
        s.add_leaf(j)
        j.add_leaf(b)
        s.setup()

        # Constant loading
        j.distal_forces = np.array([2, 0, 0, 0, 0, 0])
        s.update_kinematics()
        s.update_matrices()
        s.solve_accelerations()
        s.update_kinematics()
        assert_array_equal(j.ad, [2. / 3, 0, 0, 0, 0, 0])
Пример #4
0
class hinged_beam_tests(unittest.TestCase):
    density = 5.0
    length = 20.0
    force = 34.2  # N/m
    hinge_torque = 0.0
    free_beam = False

    def setUp(self):
        # FE model for beam
        x = linspace(0, self.length, 20)
        fe = BeamFE(x, density=self.density, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        self.beam = ModalElementFromFE('beam', fe, 0)

        # Set loading - in negative Z direction
        load = np.zeros((len(x), 3))
        load[:, 2] = -self.force
        self.beam.loading = load

        # Hinge with axis along Y axis
        self.hinge = Hinge('hinge', [0, 1, 0])
        self.hinge.internal_torque = self.hinge_torque

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.beam)
        self.system.setup()

        if not self.free_beam:
            # Prescribe hinge to be fixed
            self.system.prescribe(self.hinge)

        # Initial calculations
        self.recalc()

    def recalc(self):
        self.system.update_kinematics()    # Set up nodal values initially
        self.system.update_matrices()
        self.system.solve_accelerations()  # Calculate accelerations of DOFs
        self.system.update_kinematics()    # Update nodal values based on DOFs
        self.system.update_matrices()
        self.system.solve_reactions()      # Solve reactions incl d'Alembert
Пример #5
0
    def test_find_equilibrium(self):
        g = 9.81
        m = 23.1
        k = 45.2
        s = System(gravity=g)
        slider = PrismaticJoint('slider', [0, 0, 1])
        slider.stiffness = k
        body = RigidBody('body', mass=m)
        s.add_leaf(slider)
        slider.add_leaf(body)
        s.setup()

        # Initially position should be zero and acceleration nonzero
        s.solve_accelerations()
        assert_aae(slider.xstrain, 0)
        assert_aae(slider.astrain, -g)

        # At equilibrium, position should be nozero and force on body zero
        s.find_equilibrium()
        s.update_matrices()      # recalculate stiffness force
        s.solve_accelerations()
        assert_aae(slider.xstrain, -m * g / k)
        assert_aae(slider.astrain, 0)