def test_rotations(self): assert_aae(rotations(('z', pi / 2)), [[0, -1, 0], [1, 0, 0], [0, 0, 1]]) # Work these two examples out by hand: apply the rotations in # turn about the updated axes, and see where the body axes end # up pointing. assert_aae(rotations(('z', pi / 2), ('x', pi / 2)), [[0, 0, 1], [1, 0, 0], [0, 1, 0]]) assert_aae(rotations(('z', pi / 2), ('x', pi / 2), ('z', pi / 2)), [[0, 0, 1], [0, -1, 0], [1, 0, 0]]) assert_aae(rotations(('x', pi / 2), ('z', pi / 2)), [[0, -1, 0], [0, 0, -1], [1, 0, 0]])
def test_three_rigid_elements_as_disc_have_ends_in_right_place(self): length = 20.0 offset = 5.0 # Make 3 elements spaced by 120 deg about z axis system = System() elements = [] for i in range(3): rotmat = rotations(('z', i * 2*pi/3)) offset_vector = dot(rotmat, [offset, 0, 0]) conn = RigidConnection('offset%d' % i, offset_vector, rotmat) element = RigidConnection('element%d' % i, [length, 0, 0]) elements.append(element) system.add_leaf(conn) conn.add_leaf(element) system.setup() r = offset R = offset + length assert_aae(elements[0].rp, [r, 0, 0]) assert_aae(elements[1].rp, [-r/2, r*sqrt(3)/2, 0]) assert_aae(elements[2].rp, [-r/2, -r*sqrt(3)/2, 0]) assert_aae(elements[0].rd, [R, 0, 0]) assert_aae(elements[1].rd, [-R/2, R*sqrt(3)/2, 0]) assert_aae(elements[2].rd, [-R/2, -R*sqrt(3)/2, 0])
def test_rotations(self): assert_aae(rotations(('z', pi/2)), [[0, -1, 0], [1, 0, 0], [0, 0, 1]]) # Work these two examples out by hand: apply the rotations in # turn about the updated axes, and see where the body axes end # up pointing. assert_aae(rotations(('z', pi/2), ('x', pi/2)), [[0, 0, 1], [1, 0, 0], [0, 1, 0]]) assert_aae(rotations(('z', pi/2), ('x', pi/2), ('z', pi/2)), [[0, 0, 1], [0, -1, 0], [1, 0, 0]]) assert_aae(rotations(('x', pi/2), ('z', pi/2)), [[0, -1, 0], [0, 0, -1], [1, 0, 0]])
def test_three_elements_forming_a_disc_about_X_have_correct_inertia(self): density = 5 length = 20.0 offset = 1.25 m = density * length # mass of one beam joint = FreeJoint('joint') # Make 3 elements spaced by 120 deg about z axis for i in range(3): # Rotation of -pi/2 about y aligns local x axis of ModalElement rotmat = rotations(('x', i * 2*pi/3), ('y', -pi/2)) offset_vector = dot(rotmat, [offset, 0, 0]) # offset // local x conn = RigidConnection('offset%d' % i, offset_vector, rotmat) element = _mock_rigid_uniform_beam(density, length, 'element%d' % i) joint.add_leaf(conn) conn.add_leaf(element) system = System() system.add_leaf(joint) system.setup() # Calculate reduced system to get rigid body matrices rsys = ReducedSystem(system) # Expected values: perp inertia using projected lengths of beams Iy = m * (length**2 / 12 + (length/2 + offset)**2) Iperp = Iy + Iy/4 + Iy/4 Iaxial = 3 * Iy expected_mass = 3 * m * eye(3) expected_inertia = diag([Iaxial, Iperp, Iperp]) expected_offdiag = zeros((3, 3)) assert_aae(rsys.M[:3, :3], expected_mass) assert_aae(rsys.M[3:, 3:], expected_inertia) assert_aae(rsys.M[3:, :3], expected_offdiag) assert_aae(rsys.M[:3, 3:], expected_offdiag.T)