示例#1
0
    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        x = linspace(0, self.length, 20)
        density = (2 * self.mass / self.length) * (1 - x / self.length)
        fe = BeamFE(x, density=density, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        self.beam = ModalElementFromFE('beam', fe, 0)

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

        # Offset from hinge axis
        self.conn = RigidConnection('offset', [self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.conn)
        self.conn.add_leaf(self.beam)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially
示例#2
0
    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        self.x = x = linspace(0, self.length, 20)
        fe = BeamFE(x, density=2, EA=0, EIy=0, EIz=0)

        # Build the elements
        self.shaft = Hinge('shaft', [1, 0, 0])

        self.roots = []
        self.blades = []
        self.pitch_bearings = []
        for ib in range(1):
            R = rotations(('x', ib*2*pi/3), ('y', -pi/2))
            root_offset = dot(R, [self.root_length, 0, 0])
            root = RigidConnection('root%d' % (ib+1), root_offset, R)
            bearing = Hinge('pitch%d' % (ib+1), [1, 0, 0])
            blade = ModalElementFromFE('blade%d' % (ib+1), fe, 0)

            self.shaft.add_leaf(root)
            root.add_leaf(bearing)
            bearing.add_leaf(blade)

            self.roots.append(root)
            self.blades.append(blade)
            self.pitch_bearings.append(bearing)

        # Build system
        self.system = System()
        self.system.add_leaf(self.shaft)
        self.system.setup()
        self.system.update_kinematics()    # Set up nodal values initially
        self.system.update_matrices()
示例#3
0
    def setUp(self):
        # Rigid body with offset centre of mass
        self.body = RigidBody('body', self.mass, Xc=[self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.body)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially
        self.system.update_matrices()
示例#4
0
    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        x = linspace(0, self.length, 20)
        density = (2 * self.mass / self.length) * (1 - x / self.length)
        fe = BeamFE(x, density=density, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        self.beam = ModalElementFromFE('beam', fe, 0)

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

        # Offset from hinge axis
        self.conn = RigidConnection('offset', [self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.conn)
        self.conn.add_leaf(self.beam)
        self.system.setup()
        self.system.update_kinematics()    # Set up nodal values initially
示例#5
0
    def test_simple_prescribed_integration(self):
        s = System()
        h = Hinge('hinge', [0, 1, 0])
        s.add_leaf(h)
        s.setup()

        s.prescribe(h)
        w = h.vstrain[0] = 0.97  # rad/s

        integ = Integrator(s)
        t, y = integ.integrate(9.0, 0.1)

        # Check time vector and shape of result
        assert_array_equal(t, np.arange(0, 9.0, 0.1))
        self.assertEqual(len(y), 1)
        self.assertEqual(y[0].shape, (len(t), 1))

        # Result should be y = wt, but wrapped to [0, 2pi)
        assert_aae(y[0][:, 0], (w * t) % (2 * np.pi))

        # Check asking for velocity and acceleration works
        h.xstrain[0] = s.time = 0.0  # reset
        integ = Integrator(s, ('pos', 'vel', 'acc'))
        t, y = integ.integrate(1.0, 0.1)
        assert_array_equal(t, np.arange(0, 1.0, 0.1))
        self.assertEqual(len(y), 3)
        for yy in y:
            self.assertEqual(yy.shape, (len(t), 1))
        assert_aae(y[0][:, 0], w * t)
        assert_aae(y[1][:, 0], w)
        assert_aae(y[2][:, 0], 0)
示例#6
0
    def setUp(self):
        # Parameters
        mass = 11.234
        length = 2.54
        gravity = 9.81

        # Build model
        hinge = Hinge('hinge', [0, 1, 0])
        link = RigidConnection('link', [length, 0, 0])
        body = RigidBody('body', mass)

        system = System(gravity=gravity)
        system.add_leaf(hinge)
        hinge.add_leaf(link)
        link.add_leaf(body)
        system.setup()

        # Custom outputs to calculate correct answer
        def force_body_prox_local(s):
            theta = s.q[hinge.istrain][0]
            thetadot = s.qd[hinge.istrain][0]
            thetadotdot = s.qdd[hinge.istrain][0]
            Fx = mass * (-gravity * np.sin(theta) - length * thetadot**2)
            Fz = mass * (+gravity * np.cos(theta) - length * thetadotdot)
            return [Fx, 0, Fz, 0, 0, 0]

        def force_hinge_prox(s):
            theta = s.q[hinge.istrain][0]
            thetadot = s.qd[hinge.istrain][0]
            thetadotdot = s.qdd[hinge.istrain][0]
            A = np.array([[+np.cos(theta), np.sin(theta)],
                          [-np.sin(theta), np.cos(theta)]])
            Fxz = -mass * length * np.dot(A, [thetadot**2, thetadotdot])
            return [Fxz[0], 0, Fxz[1] + gravity * mass, 0, 0, 0]

        # Solver
        integ = Integrator(system, ('pos', 'vel', 'acc'))
        integ.add_output(LoadOutput(hinge.iprox))
        integ.add_output(LoadOutput(link.iprox))
        integ.add_output(LoadOutput(body.iprox))
        integ.add_output(LoadOutput(body.iprox, local=True))
        integ.add_output(CustomOutput(force_hinge_prox, "correct ground"))
        integ.add_output(
            CustomOutput(force_body_prox_local, "correct link distal local"))

        self.system = system
        self.integ = integ
示例#7
0
class TestReactionForcesForCentrifugalForce(unittest.TestCase):
    """
    System
    ------
    A rigid body with offset mass, attached to a spinning hinge.

    Tests
    -----
    Check centrifugal force reaction on hinge is in correct direction.
    """

    mass = 5.0  # kg
    offset = 3.2  # m

    def setUp(self):
        # Rigid body with offset centre of mass
        self.body = RigidBody("body", self.mass, Xc=[self.offset, 0, 0])

        # Hinge with axis along Z axis
        self.hinge = Hinge("hinge", [0, 0, 1])

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.body)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially
        self.system.update_matrices()

    def test_reactions(self):
        # Set angular acceleration
        w = 5.21  # rad/s
        self.hinge.vstrain[0] = w
        self.system.update_kinematics()  # Update nodal values based on DOFs
        self.system.update_matrices()
        self.system.solve_reactions()  # Solve reactions incl d'Alembert

        # Some parameters
        L = self.offset
        m = self.mass

        # Check reactions at beam root
        Pg = self.system.joint_reactions["ground"]
        P0 = self.system.joint_reactions["node-0"]
        Fx_expected = -m * L * w ** 2
        assert_aae(P0, [Fx_expected, 0, 0, 0, 0, 0])
        assert_aae(Pg, P0)
示例#8
0
    def setUp(self):
        # Parameters
        mass = 11.234
        length = 2.54
        gravity = 9.81

        # Build model
        hinge = Hinge('hinge', [0, 1, 0])
        link = RigidConnection('link', [length, 0, 0])
        body = RigidBody('body', mass)

        system = System(gravity=gravity)
        system.add_leaf(hinge)
        hinge.add_leaf(link)
        link.add_leaf(body)
        system.setup()

        # Custom outputs to calculate correct answer
        def force_body_prox_local(s):
            theta = s.q[hinge.istrain][0]
            thetadot = s.qd[hinge.istrain][0]
            thetadotdot = s.qdd[hinge.istrain][0]
            Fx = mass * (-gravity*np.sin(theta) - length*thetadot**2)
            Fz = mass * (+gravity*np.cos(theta) - length*thetadotdot)
            return [Fx, 0, Fz, 0, 0, 0]

        def force_hinge_prox(s):
            theta = s.q[hinge.istrain][0]
            thetadot = s.qd[hinge.istrain][0]
            thetadotdot = s.qdd[hinge.istrain][0]
            A = np.array([[+np.cos(theta), np.sin(theta)],
                          [-np.sin(theta), np.cos(theta)]])
            Fxz = -mass * length * np.dot(A, [thetadot**2, thetadotdot])
            return [Fxz[0], 0, Fxz[1] + gravity*mass, 0, 0, 0]

        # Solver
        integ = Integrator(system, ('pos', 'vel', 'acc'))
        integ.add_output(LoadOutput(hinge.iprox))
        integ.add_output(LoadOutput(link.iprox))
        integ.add_output(LoadOutput(body.iprox))
        integ.add_output(LoadOutput(body.iprox, local=True))
        integ.add_output(CustomOutput(force_hinge_prox, "correct ground"))
        integ.add_output(CustomOutput(force_body_prox_local,
                                      "correct link distal local"))

        self.system = system
        self.integ = integ
示例#9
0
class TestReactionForcesForCentrifugalForce(unittest.TestCase):
    """
    System
    ------
    A rigid body with offset mass, attached to a spinning hinge.

    Tests
    -----
    Check centrifugal force reaction on hinge is in correct direction.
    """
    mass = 5.0  # kg
    offset = 3.2  # m

    def setUp(self):
        # Rigid body with offset centre of mass
        self.body = RigidBody('body', self.mass, Xc=[self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.body)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially
        self.system.update_matrices()

    def test_reactions(self):
        # Set angular acceleration
        w = 5.21  # rad/s
        self.hinge.vstrain[0] = w
        self.system.update_kinematics()  # Update nodal values based on DOFs
        self.system.update_matrices()
        self.system.solve_reactions()  # Solve reactions incl d'Alembert

        # Some parameters
        L = self.offset
        m = self.mass

        # Check reactions at beam root
        Pg = self.system.joint_reactions['ground']
        P0 = self.system.joint_reactions['node-0']
        Fx_expected = -m * L * w**2
        assert_aae(P0, [Fx_expected, 0, 0, 0, 0, 0])
        assert_aae(Pg, P0)
示例#10
0
    def test_call(self):
        s = System()
        c = RigidConnection('conn', [1, 0, 0])
        h = Hinge('hinge', [0, 1, 0])
        b = RigidBody('body', 1)
        s.add_leaf(h)
        h.add_leaf(c)
        c.add_leaf(b)
        s.setup()

        # Set hinge angle
        h.xstrain[0] = 0.82
        h.vstrain[0] = 1.2
        h.astrain[0] = -0.3
        s.update_kinematics()
        s.solve_reactions()

        # Test load outputs
        out = LoadOutput('node-1')
        assert_array_equal(out(s), s.joint_reactions['node-1'])

        out = LoadOutput('node-1', local=True)
        F = s.joint_reactions['node-1']
        assert_array_equal(out(s), np.r_[np.dot(b.Rp.T, F[:3]),
                                         np.dot(b.Rp.T, F[3:])])
示例#11
0
文件: run.py 项目: ricklupton/mbwind
def build_system():
    # Calculate inertia, stiffness and damping
    I2 = mass * length**2
    k = (2*np.pi*natfreq)**2 * I2
    c = 2 * damping_factor * I2 * (2*np.pi*natfreq)

    # Build model
    hinge = Hinge('hinge', [0,0,1])
    hinge.stiffness = k
    hinge.damping = c
    link = RigidConnection('link', [length, 0, 0])
    body = RigidBody('body', mass)

    system = System()
    system.add_leaf(hinge)
    hinge.add_leaf(link)
    link.add_leaf(body)
    system.setup()

    return system
示例#12
0
    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        self.x = x = linspace(0, self.length, 20)
        fe = BeamFE(x, density=2, EA=0, EIy=0, EIz=0)

        # Build the elements
        self.shaft = Hinge('shaft', [1, 0, 0])

        self.roots = []
        self.blades = []
        self.pitch_bearings = []
        for ib in range(1):
            R = rotations(('x', ib * 2 * pi / 3), ('y', -pi / 2))
            root_offset = dot(R, [self.root_length, 0, 0])
            root = RigidConnection('root%d' % (ib + 1), root_offset, R)
            bearing = Hinge('pitch%d' % (ib + 1), [1, 0, 0])
            blade = ModalElementFromFE('blade%d' % (ib + 1), fe, 0)

            self.shaft.add_leaf(root)
            root.add_leaf(bearing)
            bearing.add_leaf(blade)

            self.roots.append(root)
            self.blades.append(blade)
            self.pitch_bearings.append(bearing)

        # Build system
        self.system = System()
        self.system.add_leaf(self.shaft)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially
        self.system.update_matrices()
示例#13
0
文件: run.py 项目: ricklupton/mbwind
    def __init__(self, length, radius, mass, spin):
        self.length = length
        self.radius = radius
        self.mass = mass
        self.spin = spin

        self.bearing = Hinge('bearing', [0, 0, 1])
        self.pivot = Hinge('pivot', [0, 1, 0])
        self.axis = Hinge('axis', [1, 0, 0])
        self.body = self.build_body()

        self.pivot.damping = 200

        self.system = System(gravity=9.81)
        self.system.add_leaf(self.bearing)
        self.bearing.add_leaf(self.pivot)
        self.pivot.add_leaf(self.axis)
        self.axis.add_leaf(self.body)
        self.system.setup()

        # Prescribed DOF accelerations: constant rotational speed
        self.system.prescribe(self.axis)
示例#14
0
    def test_applied_force(self):
        # Set up a hinge with a mass offset on a rigid body. The
        # reduced system should have 1 DOF -- the hinge rotation --
        # with the associated mass being the inertia of the mass about
        # the hinge, and the associated generalised force being the
        # applied moment.
        mass = 36.2
        zforce = -30
        L = 3.2
        s = System()
        h = Hinge('hinge', [0, 1, 0])
        c = RigidConnection('conn', [L, 0, 0])
        b = RigidBody('body', mass, nodal_load=[0, 0, zforce])
        s.add_leaf(h)
        h.add_leaf(c)
        c.add_leaf(b)
        s.setup()

        rsys = ReducedSystem(s)
        self.assertEqual(rsys.M.shape, (1, 1))
        self.assertEqual(rsys.Q.shape, (1, ))
        self.assertEqual(rsys.M[0, 0], mass * L**2)  # inertial about hinge
        self.assertEqual(rsys.Q[0], -zforce * L)  # moment about hinge
示例#15
0
    def test_applied_force(self):
        # Set up a hinge with a mass offset on a rigid body. The
        # reduced system should have 1 DOF -- the hinge rotation --
        # with the associated mass being the inertia of the mass about
        # the hinge, and the associated generalised force being the
        # applied moment.
        mass = 36.2
        zforce = -30
        L = 3.2
        s = System()
        h = Hinge('hinge', [0, 1, 0])
        c = RigidConnection('conn', [L, 0, 0])
        b = RigidBody('body', mass, nodal_load=[0, 0, zforce])
        s.add_leaf(h)
        h.add_leaf(c)
        c.add_leaf(b)
        s.setup()

        rsys = ReducedSystem(s)
        self.assertEqual(rsys.M.shape, (1, 1))
        self.assertEqual(rsys.Q.shape, (1,))
        self.assertEqual(rsys.M[0, 0], mass * L**2)  # inertial about hinge
        self.assertEqual(rsys.Q[0], -zforce * L)  # moment about hinge
示例#16
0
    def setUp(self):
        # Rigid body with offset centre of mass
        self.body = RigidBody('body', self.mass, Xc=[self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.body)
        self.system.setup()
        self.system.update_kinematics()    # Set up nodal values initially
        self.system.update_matrices()
示例#17
0
    def test_call(self):
        s = System()
        c = RigidConnection('conn', [1, 0, 0])
        h = Hinge('hinge', [0, 1, 0])
        b = RigidBody('body', 1)
        s.add_leaf(h)
        h.add_leaf(c)
        c.add_leaf(b)
        s.setup()

        # Set hinge angle
        h.xstrain[0] = 0.82
        h.vstrain[0] = 1.2
        h.astrain[0] = -0.3
        s.update_kinematics()

        # Test node outputs
        out = StateOutput('node-1')
        assert_array_equal(out(s), np.r_[b.rp, b.Rp.flatten()])

        out = StateOutput('node-1', deriv=1)
        assert_array_equal(out(s), b.vp)

        out = StateOutput('node-1', deriv=2)
        assert_array_equal(out(s), b.ap)

        out = StateOutput('node-1', local=True)
        assert_array_equal(out(s), np.r_[np.dot(b.Rp.T, b.rp),
                                         np.eye(3).flatten()])

        out = StateOutput('node-1', deriv=1, local=True)
        assert_array_equal(out(s), np.r_[np.dot(b.Rp.T, b.vp[:3]),
                                         np.dot(b.Rp.T, b.vp[3:])])

        out = StateOutput('node-1', deriv=2, local=True)
        assert_array_equal(out(s), np.r_[np.dot(b.Rp.T, b.ap[:3]),
                                         np.dot(b.Rp.T, b.ap[3:])])

        # Test strain outputs
        out = StateOutput('hinge-strains')
        assert_array_equal(out(s), 0.82)

        out = StateOutput('hinge-strains', deriv=1)
        assert_array_equal(out(s), 1.2)

        out = StateOutput('hinge-strains', deriv=2)
        assert_array_equal(out(s), -0.3)

        # Strains cannot be transformed to local coordinates
        with self.assertRaises(RuntimeError):
            out = StateOutput('hinge-strains', local=True)
            out(s)
示例#18
0
文件: run.py 项目: ricklupton/mbwind
class Gyroscope:
    def __init__(self, length, radius, mass, spin):
        self.length = length
        self.radius = radius
        self.mass = mass
        self.spin = spin

        self.bearing = Hinge('bearing', [0, 0, 1])
        self.pivot = Hinge('pivot', [0, 1, 0])
        self.axis = Hinge('axis', [1, 0, 0])
        self.body = self.build_body()

        self.pivot.damping = 200

        self.system = System(gravity=9.81)
        self.system.add_leaf(self.bearing)
        self.bearing.add_leaf(self.pivot)
        self.pivot.add_leaf(self.axis)
        self.axis.add_leaf(self.body)
        self.system.setup()

        # Prescribed DOF accelerations: constant rotational speed
        self.system.prescribe(self.axis)

    def build_body(self):
        Jx = self.radius**2 / 2
        Jyz = (3*self.radius**2 + self.length**2) / 12
        Jyz_0 = Jyz + (self.length/2)**2  # parallel axis theorem
        inertia = self.mass * np.diag([Jx, Jyz_0, Jyz_0])
        return RigidBody('body', self.mass, inertia, [self.length/2, 0, 0])

    def simulate(self, xpivot=0.0, vpivot=0.0, t1=10, dt=0.05):
        # reset
        self.system.q[:] = 0.0
        self.system.qd[:] = 0.0

        # initial conditions
        self.system.q[self.pivot.istrain][0] = xpivot  # initial elevation
        #self.system.qd[self.pivot.istrain][0] = vpivot # initial elevation spd
        self.system.qd[self.axis.istrain][0] = self.spin  # constant spin speed

        # simulate
        integ = Integrator(self.system, ('pos', 'vel'))
        integ.integrate(t1, dt, nprint=None)
        return integ
示例#19
0
class Gyroscope:
    def __init__(self, length, radius, mass, spin):
        self.length = length
        self.radius = radius
        self.mass = mass
        self.spin = spin

        self.bearing = Hinge('bearing', [0, 0, 1])
        self.pivot = Hinge('pivot', [0, 1, 0])
        self.axis = Hinge('axis', [1, 0, 0])
        self.body = self.build_body()

        self.pivot.damping = 200

        self.system = System(gravity=9.81)
        self.system.add_leaf(self.bearing)
        self.bearing.add_leaf(self.pivot)
        self.pivot.add_leaf(self.axis)
        self.axis.add_leaf(self.body)
        self.system.setup()

        # Prescribed DOF accelerations: constant rotational speed
        self.system.prescribe(self.axis)

    def build_body(self):
        Jx = self.radius**2 / 2
        Jyz = (3 * self.radius**2 + self.length**2) / 12
        Jyz_0 = Jyz + (self.length / 2)**2  # parallel axis theorem
        inertia = self.mass * np.diag([Jx, Jyz_0, Jyz_0])
        return RigidBody('body', self.mass, inertia, [self.length / 2, 0, 0])

    def simulate(self, xpivot=0.0, vpivot=0.0, t1=10, dt=0.05):
        # reset
        self.system.q[:] = 0.0
        self.system.qd[:] = 0.0

        # initial conditions
        self.system.q[self.pivot.istrain][0] = xpivot  # initial elevation
        #self.system.qd[self.pivot.istrain][0] = vpivot # initial elevation spd
        self.system.qd[self.axis.istrain][0] = self.spin  # constant spin speed

        # simulate
        integ = Integrator(self.system, ('pos', 'vel'))
        integ.integrate(t1, dt, nprint=None)
        return integ
示例#20
0
def build_system():
    # Calculate inertia, stiffness and damping
    I2 = mass * length**2
    k = (2 * np.pi * natfreq)**2 * I2
    c = 2 * damping_factor * I2 * (2 * np.pi * natfreq)

    # Build model
    hinge = Hinge('hinge', [0, 0, 1])
    hinge.stiffness = k
    hinge.damping = c
    link = RigidConnection('link', [length, 0, 0])
    body = RigidBody('body', mass)

    system = System()
    system.add_leaf(hinge)
    hinge.add_leaf(link)
    link.add_leaf(body)
    system.setup()

    return system
示例#21
0
    def __init__(self, length, radius, mass, spin):
        self.length = length
        self.radius = radius
        self.mass = mass
        self.spin = spin

        self.bearing = Hinge('bearing', [0, 0, 1])
        self.pivot = Hinge('pivot', [0, 1, 0])
        self.axis = Hinge('axis', [1, 0, 0])
        self.body = self.build_body()

        self.pivot.damping = 200

        self.system = System(gravity=9.81)
        self.system.add_leaf(self.bearing)
        self.bearing.add_leaf(self.pivot)
        self.pivot.add_leaf(self.axis)
        self.axis.add_leaf(self.body)
        self.system.setup()

        # Prescribed DOF accelerations: constant rotational speed
        self.system.prescribe(self.axis)
示例#22
0
class TestReactionForcesOnModalElementFromFE(unittest.TestCase):
    """
    System
    ------
    A triangular rigid beam, offset by a rigid link from a hinge.

    Tests
    -----
    Set the angular acceleration of the hinge. Check the reaction
    forces at the centre and at the root of the beam.
    """
    mass = 5.0     # kg
    length = 20.0  # m
    offset = 3.2   # m
    force = -34.2  # N / m

    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        x = linspace(0, self.length, 20)
        density = (2 * self.mass / self.length) * (1 - x / self.length)
        fe = BeamFE(x, density=density, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        self.beam = ModalElementFromFE('beam', fe, 0)

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

        # Offset from hinge axis
        self.conn = RigidConnection('offset', [self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.conn)
        self.conn.add_leaf(self.beam)
        self.system.setup()
        self.system.update_kinematics()    # Set up nodal values initially

    def test_reactions(self):
        # Set angular acceleration
        alpha = 1.235  # rad/s2
        self.hinge.astrain[0] = alpha
        self.system.update_kinematics()    # Update nodal values based on DOFs
        self.system.solve_reactions()      # Solve reactions incl d'Alembert

        # Some parameters
        L = self.length
        m = self.mass
        Ro = self.offset
        Rg = L / 3   # distance to CoM along beam
        IG = m * L ** 2 / 18
        assert_aae(m, self.beam.mass_vv[0, 0])

        # Check reactions at beam root
        P = self.system.joint_reactions['node-1']
        Fz_expected = (-m * (Ro + Rg) * alpha -
                       self.force * L)
        My_expected = ((IG + m * Rg * (Ro + Rg)) * alpha +
                       self.force * L ** 2 / 2)
        assert_aae(P, [0, 0, Fz_expected, 0, My_expected, 0])
示例#23
0
    def test_update_kinematics_results(self):
        # Test system: (all rigid connections of length 1)
        #
        #                  [hinge]
        #  (gnd)---c1---(0)
        #               (1)---c2---(2)
        #                           |
        #  y                        c3
        #  |                        |
        #  |--> x                  (3)
        #
        s = System()
        c1 = RigidConnection('c1', [1, 0, 0])
        c2 = RigidConnection('c2', [1, 0, 0])
        c3 = RigidConnection('c3', [0, -1, 0])
        hinge = Hinge('hinge', [0, 0, 1])
        s.add_leaf(c1)
        c1.add_leaf(hinge)
        hinge.add_leaf(c2)
        c2.add_leaf(c3)
        s.setup()

        # All velocities and accelerations should be zero
        for el in [c1, c2, c3, hinge]:
            assert_aae(el.vp, 0)
            assert_aae(el.vd, 0)
            assert_aae(el.ap, 0)
            assert_aae(el.ad, 0)

        # (gnd)
        assert_aae(c1.rp, 0)
        assert_aae(c1.Rp, np.eye(3))

        # (0)
        assert_aae(c1.rd, [1, 0, 0])
        assert_aae(c1.Rd, np.eye(3))

        # (1)
        assert_aae(c2.rp, [1, 0, 0])
        assert_aae(c2.Rp, np.eye(3))

        # (2)
        assert_aae(c3.rp, [2, 0, 0])
        assert_aae(c3.Rp, np.eye(3))

        # (3)
        assert_aae(c3.rd, [2, -1, 0])
        assert_aae(c3.Rd, np.eye(3))

        ##### now set angular velocity of hinge #####
        hinge.vstrain[0] = 1.0
        s.update_kinematics()

        # (gnd)
        assert_aae(c1.vp, 0)
        assert_aae(c1.ap, 0)

        # (0)
        assert_aae(c1.vd, 0)
        assert_aae(c1.ad, 0)

        # (1)
        assert_aae(c2.vp, [0, 0, 0, 0, 0, 1.0])
        assert_aae(c2.ap, 0)

        # (2)
        assert_aae(c3.vp, [0, 1, 0, 0, 0, 1.0])
        assert_aae(c3.ap, [-1, 0, 0, 0, 0, 0])   # centripetal acceleration

        # (3)
        assert_aae(c3.vd, [1, 1, 0, 0, 0, 1.0])
        assert_aae(c3.ad, [-1, 1, 0, 0, 0, 0])  # centripetal acceleration
示例#24
0
class TestReactionForcesWithRotatedBeam(unittest.TestCase):
    """Intended to check the transformation from blade loading to rotor
    loading in a wind turbine rotor: the loads are applied to the beam
    in the local rotated coordinate system, check they work through to
    the ground reactions correctly.
    """
    force = 24.1
    length = 4.3
    root_length = 0.0

    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        self.x = x = linspace(0, self.length, 20)
        fe = BeamFE(x, density=2, EA=0, EIy=0, EIz=0)

        # Build the elements
        self.shaft = Hinge('shaft', [1, 0, 0])

        self.roots = []
        self.blades = []
        self.pitch_bearings = []
        for ib in range(1):
            R = rotations(('x', ib * 2 * pi / 3), ('y', -pi / 2))
            root_offset = dot(R, [self.root_length, 0, 0])
            root = RigidConnection('root%d' % (ib + 1), root_offset, R)
            bearing = Hinge('pitch%d' % (ib + 1), [1, 0, 0])
            blade = ModalElementFromFE('blade%d' % (ib + 1), fe, 0)

            self.shaft.add_leaf(root)
            root.add_leaf(bearing)
            bearing.add_leaf(blade)

            self.roots.append(root)
            self.blades.append(blade)
            self.pitch_bearings.append(bearing)

        # Build system
        self.system = System()
        self.system.add_leaf(self.shaft)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially
        self.system.update_matrices()

    def test_reactions(self):
        # Some parameters
        L = self.length
        F = self.length * self.force

        # Set loading - in local z direction
        load = np.zeros((len(self.x), 3))
        load[:, 2] = self.force
        self.blades[0].loading = load
        self.system.update_kinematics()
        self.system.update_matrices()
        self.system.solve_reactions()

        # Check reactions at ground (0, 0, 0)
        P = -self.system.joint_reactions['ground']
        F_expected = [-F, 0, 0]
        M_expected = [0, -F * (L + self.root_length) / 2, 0]
        assert_aae(P, np.r_[F_expected, M_expected])

        # Reactions on other side of hinge
        P2 = -self.system.joint_reactions['node-0']
        assert_aae(P, P2)

        # Now set pitch angle to 45deg
        # NB: hinge rotation is opposite to wind turbine pitch convention
        self.pitch_bearings[0].xstrain[0] = -pi / 4
        self.system.update_kinematics()
        self.system.update_matrices()
        self.system.solve_reactions()

        # Check reactions at ground (0, 0, 0)
        P = -self.system.joint_reactions['ground']
        F_expected = [-F / sqrt(2), F / sqrt(2), 0]
        M_expected = [-F / sqrt(2) * L / 2, -F / sqrt(2) * L / 2, 0]
        assert_aae(P, np.r_[F_expected, M_expected])

        # Reactions on other side of hinge
        P2 = -self.system.joint_reactions['node-0']
        assert_aae(P, P2)
示例#25
0
class TestReactionForcesOnModalElementFromFE(unittest.TestCase):
    """
    System
    ------
    A triangular rigid beam, offset by a rigid link from a hinge.

    Tests
    -----
    Set the angular acceleration of the hinge. Check the reaction
    forces at the centre and at the root of the beam.
    """
    mass = 5.0  # kg
    length = 20.0  # m
    offset = 3.2  # m
    force = -34.2  # N / m

    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        x = linspace(0, self.length, 20)
        density = (2 * self.mass / self.length) * (1 - x / self.length)
        fe = BeamFE(x, density=density, EA=0, EIy=1, EIz=0)
        fe.set_boundary_conditions('C', 'F')
        self.beam = ModalElementFromFE('beam', fe, 0)

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

        # Offset from hinge axis
        self.conn = RigidConnection('offset', [self.offset, 0, 0])

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

        # Build system
        self.system = System()
        self.system.add_leaf(self.hinge)
        self.hinge.add_leaf(self.conn)
        self.conn.add_leaf(self.beam)
        self.system.setup()
        self.system.update_kinematics()  # Set up nodal values initially

    def test_reactions(self):
        # Set angular acceleration
        alpha = 1.235  # rad/s2
        self.hinge.astrain[0] = alpha
        self.system.update_kinematics()  # Update nodal values based on DOFs
        self.system.solve_reactions()  # Solve reactions incl d'Alembert

        # Some parameters
        L = self.length
        m = self.mass
        Ro = self.offset
        Rg = L / 3  # distance to CoM along beam
        IG = m * L**2 / 18
        assert_aae(m, self.beam.mass_vv[0, 0])

        # Check reactions at beam root
        P = self.system.joint_reactions['node-1']
        Fz_expected = (-m * (Ro + Rg) * alpha - self.force * L)
        My_expected = ((IG + m * Rg * (Ro + Rg)) * alpha +
                       self.force * L**2 / 2)
        assert_aae(P, [0, 0, Fz_expected, 0, My_expected, 0])
示例#26
0
class TestReactionForcesWithRotatedBeam(unittest.TestCase):
    """Intended to check the transformation from blade loading to rotor
    loading in a wind turbine rotor: the loads are applied to the beam
    in the local rotated coordinate system, check they work through to
    the ground reactions correctly.
    """
    force = 24.1
    length = 4.3
    root_length = 0.0

    def setUp(self):
        # FE model for beam - no modes, i.e. rigid
        self.x = x = linspace(0, self.length, 20)
        fe = BeamFE(x, density=2, EA=0, EIy=0, EIz=0)

        # Build the elements
        self.shaft = Hinge('shaft', [1, 0, 0])

        self.roots = []
        self.blades = []
        self.pitch_bearings = []
        for ib in range(1):
            R = rotations(('x', ib*2*pi/3), ('y', -pi/2))
            root_offset = dot(R, [self.root_length, 0, 0])
            root = RigidConnection('root%d' % (ib+1), root_offset, R)
            bearing = Hinge('pitch%d' % (ib+1), [1, 0, 0])
            blade = ModalElementFromFE('blade%d' % (ib+1), fe, 0)

            self.shaft.add_leaf(root)
            root.add_leaf(bearing)
            bearing.add_leaf(blade)

            self.roots.append(root)
            self.blades.append(blade)
            self.pitch_bearings.append(bearing)

        # Build system
        self.system = System()
        self.system.add_leaf(self.shaft)
        self.system.setup()
        self.system.update_kinematics()    # Set up nodal values initially
        self.system.update_matrices()

    def test_reactions(self):
        # Some parameters
        L = self.length
        F = self.length * self.force

        # Set loading - in local z direction
        load = np.zeros((len(self.x), 3))
        load[:, 2] = self.force
        self.blades[0].loading = load
        self.system.update_kinematics()
        self.system.update_matrices()
        self.system.solve_reactions()

        # Check reactions at ground (0, 0, 0)
        P = -self.system.joint_reactions['ground']
        F_expected = [-F, 0, 0]
        M_expected = [0, -F*(L+self.root_length)/2, 0]
        assert_aae(P, np.r_[F_expected, M_expected])

        # Reactions on other side of hinge
        P2 = -self.system.joint_reactions['node-0']
        assert_aae(P, P2)

        # Now set pitch angle to 45deg
        # NB: hinge rotation is opposite to wind turbine pitch convention
        self.pitch_bearings[0].xstrain[0] = -pi / 4
        self.system.update_kinematics()
        self.system.update_matrices()
        self.system.solve_reactions()

        # Check reactions at ground (0, 0, 0)
        P = -self.system.joint_reactions['ground']
        F_expected = [-F/sqrt(2), F/sqrt(2), 0]
        M_expected = [-F/sqrt(2)*L/2, -F/sqrt(2)*L/2, 0]
        assert_aae(P, np.r_[F_expected, M_expected])

        # Reactions on other side of hinge
        P2 = -self.system.joint_reactions['node-0']
        assert_aae(P, P2)