当前位置: 首页>>代码示例>>Python>>正文


Python System.solve_reactions方法代码示例

本文整理汇总了Python中mbwind.System.solve_reactions方法的典型用法代码示例。如果您正苦于以下问题:Python System.solve_reactions方法的具体用法?Python System.solve_reactions怎么用?Python System.solve_reactions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mbwind.System的用法示例。


在下文中一共展示了System.solve_reactions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_call

# 需要导入模块: from mbwind import System [as 别名]
# 或者: from mbwind.System import solve_reactions [as 别名]
    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:])])
开发者ID:ricklupton,项目名称:mbwind,代码行数:27,代码来源:test_integrator.py

示例2: test_solve_reactions

# 需要导入模块: from mbwind import System [as 别名]
# 或者: from mbwind.System import solve_reactions [as 别名]
    def test_solve_reactions(self):
        # Check it calls the Element method in the right order: down
        # the tree from leaves to base. It must also reset reactions.
        s = System()
        c0 = RigidConnection('c0')
        c1 = RigidConnection('c1')
        c2 = RigidConnection('c2')
        b1 = RigidBody('b1', 1)
        b2 = RigidBody('b2', 1)
        s.add_leaf(c0)
        c0.add_leaf(c1)
        c0.add_leaf(c2)
        c1.add_leaf(b1)
        c2.add_leaf(b2)
        s.setup()

        # Check elements' iter_reactions() are called
        def mock_iter_reactions(element):
            calls.append(element)
        calls = []
        import types
        for el in s.elements.values():
            el.iter_reactions = types.MethodType(mock_iter_reactions, el)

        # Test
        s.joint_reactions[:] = 3
        s.solve_reactions()
        self.assertEqual(calls, [b2, c2, b1, c1, c0])
        assert_aae(s.joint_reactions, 0)
开发者ID:ricklupton,项目名称:mbwind,代码行数:31,代码来源:test_system.py

示例3: TestReactionForcesForCentrifugalForce

# 需要导入模块: from mbwind import System [as 别名]
# 或者: from mbwind.System import solve_reactions [as 别名]
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)
开发者ID:ricklupton,项目名称:mbwind,代码行数:49,代码来源:test_reaction_forces.py

示例4: hinged_beam_tests

# 需要导入模块: from mbwind import System [as 别名]
# 或者: from mbwind.System import solve_reactions [as 别名]
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
开发者ID:ricklupton,项目名称:mbwind,代码行数:45,代码来源:test_assemblies.py

示例5: TestReactionForcesWithRotatedBeam

# 需要导入模块: from mbwind import System [as 别名]
# 或者: from mbwind.System import solve_reactions [as 别名]
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)
开发者ID:ricklupton,项目名称:mbwind,代码行数:84,代码来源:test_reaction_forces.py

示例6: TestReactionForcesOnModalElementFromFE

# 需要导入模块: from mbwind import System [as 别名]
# 或者: from mbwind.System import solve_reactions [as 别名]
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])
开发者ID:ricklupton,项目名称:mbwind,代码行数:67,代码来源:test_reaction_forces.py


注:本文中的mbwind.System.solve_reactions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。