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


Python Particle.mass方法代码示例

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


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

示例1: test_pend

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_pend():
    q, u = dynamicsymbols('q u')
    qd, ud = dynamicsymbols('q u', 1)
    m, l, g = symbols('m l g')
    N = ReferenceFrame('N')
    P = Point('P')
    P.set_vel(N, -l * u * sin(q) * N.x + l * u * cos(q) * N.y)
    kd = [qd - u]

    FL = [(P, m * g * N.x)]
    pa = Particle()
    pa.mass = m
    pa.point = P
    BL = [pa]

    KM = Kane(N)
    KM.coords([q])
    KM.speeds([u])
    KM.kindiffeq(kd)
    KM.kanes_equations(FL, BL)
    MM = KM.mass_matrix
    forcing = KM.forcing
    rhs = MM.inv() * forcing
    rhs.simplify()
    assert expand(rhs[0]) == expand(-g / l * sin(q))
开发者ID:101man,项目名称:sympy,代码行数:27,代码来源:test_kane.py

示例2: test_particle

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_particle():
    m, m2, v1, v2, v3, r, g, h = symbols('m m2 v1 v2 v3 r g h')
    P = Point('P')
    P2 = Point('P2')
    p = Particle('pa', P, m)
    assert p.mass == m
    assert p.point == P
    # Test the mass setter
    p.mass = m2
    assert p.mass == m2
    # Test the point setter
    p.point = P2
    assert p.point == P2
    # Test the linear momentum function
    N = ReferenceFrame('N')
    O = Point('O')
    P2.set_pos(O, r * N.y)
    P2.set_vel(N, v1 * N.x)
    assert p.linear_momentum(N) == m2 * v1 * N.x
    assert p.angular_momentum(O, N) == -m2 * r *v1 * N.z
    P2.set_vel(N, v2 * N.y)
    assert p.linear_momentum(N) == m2 * v2 * N.y
    assert p.angular_momentum(O, N) == 0
    P2.set_vel(N, v3 * N.z)
    assert p.linear_momentum(N) == m2 * v3 * N.z
    assert p.angular_momentum(O, N) == m2 * r * v3 * N.x
    P2.set_vel(N, v1 * N.x + v2 * N.y + v3 * N.z)
    assert p.linear_momentum(N) == m2 * (v1 * N.x + v2 * N.y + v3 * N.z)
    assert p.angular_momentum(O, N) == m2 * r * (v3 * N.x - v1 * N.z)
    p.set_potential_energy(m * g * h)
    assert p.potential_energy == m * g * h
    # TODO make the result not be system-dependent
    assert p.kinetic_energy(
        N) in [m2*(v1**2 + v2**2 + v3**2)/2,
        m2 * v1**2 / 2 + m2 * v2**2 / 2 + m2 * v3**2 / 2]
开发者ID:AALEKH,项目名称:sympy,代码行数:37,代码来源:test_particle.py

示例3: test_one_dof

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_one_dof():
    # This is for a 1 dof spring-mass-damper case.
    # It is described in more detail in the Kane docstring.
    q, u = dynamicsymbols('q u')
    qd, ud = dynamicsymbols('q u', 1)
    m, c, k = symbols('m c k')
    N = ReferenceFrame('N')
    P = Point('P')
    P.set_vel(N, u * N.x)

    kd = [qd - u]
    FL = [(P, (-k * q - c * u) * N.x)]
    pa = Particle()
    pa.mass = m
    pa.point = P
    BL = [pa]

    KM = Kane(N)
    KM.coords([q])
    KM.speeds([u])
    KM.kindiffeq(kd)
    KM.kanes_equations(FL, BL)
    MM = KM.mass_matrix
    forcing = KM.forcing
    rhs = MM.inv() * forcing
    assert expand(rhs[0]) == expand(-(q * k + u * c) / m)
    assert KM.linearize() == (Matrix([[0, 1], [k, c]]), Matrix([]))
开发者ID:101man,项目名称:sympy,代码行数:29,代码来源:test_kane.py

示例4: test_particle

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_particle():
    m, m2, v1, v2, v3, r = symbols('m m2 v1 v2 v3 r')
    P = Point('P')
    P2 = Point('P2')
    p = Particle('pa', P, m)
    assert p.mass == m
    assert p.point == P
    # Test the mass setter
    p.mass = m2
    assert p.mass == m2
    # Test the point setter
    p.point = P2
    assert p.point == P2
    # Test the linear momentum function
    N = ReferenceFrame('N')
    O = Point('O')
    P2.set_pos(O, r * N.y)
    P2.set_vel(N, v1 * N.x)
    assert p.linearmomentum(N) == m2 * v1 * N.x
    assert p.angularmomentum(O, N) == -m2 * r *v1 * N.z
    P2.set_vel(N, v2 * N.y)
    assert p.linearmomentum(N) == m2 * v2 * N.y
    assert p.angularmomentum(O, N) == 0
    P2.set_vel(N, v3 * N.z)
    assert p.linearmomentum(N) == m2 * v3 * N.z
    assert p.angularmomentum(O, N) == m2 * r * v3 * N.x
    P2.set_vel(N, v1 * N.x + v2 * N.y + v3 * N.z)
    assert p.linearmomentum(N) == m2 * (v1 * N.x + v2 * N.y + v3 * N.z)
    assert p.angularmomentum(O, N) == m2 * r * (v3 * N.x - v1 * N.z)
开发者ID:piyushbansal,项目名称:sympy,代码行数:31,代码来源:test_particle.py

示例5: test_two_dof

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_two_dof():
    # This is for a 2 d.o.f., 2 particle spring-mass-damper.
    # The first coordinate is the displacement of the first particle, and the
    # second is the relative displacement between the first and second
    # particles. Speeds are defined as the time derivatives of the particles.
    q1, q2, u1, u2 = dynamicsymbols('q1 q2 u1 u2')
    q1d, q2d, u1d, u2d = dynamicsymbols('q1 q2 u1 u2', 1)
    m, c1, c2, k1, k2 = symbols('m c1 c2 k1 k2')
    N = ReferenceFrame('N')
    P1 = Point('P1')
    P2 = Point('P2')
    P1.set_vel(N, u1 * N.x)
    P2.set_vel(N, (u1 + u2) * N.x)
    kd = [q1d - u1, q2d - u2]

    # Now we create the list of forces, then assign properties to each
    # particle, then create a list of all particles.
    FL = [(P1, (-k1 * q1 - c1 * u1 + k2 * q2 + c2 * u2) * N.x), (P2, (-k2 *
        q2 - c2 * u2) * N.x)]
    pa1 = Particle()
    pa2 = Particle()
    pa1.mass = m
    pa2.mass = m
    pa1.point = P1
    pa2.point = P2
    BL = [pa1, pa2]

    # Finally we create the Kane object, specify the inertial frame, pass
    # relevant information, and form Fr & Fr*. Then we calculate the mass
    # matrix and forcing terms, and finally solve for the udots.
    KM = Kane(N)
    KM.coords([q1, q2])
    KM.speeds([u1, u2])
    KM.kindiffeq(kd)
    KM.kanes_equations(FL, BL)
    MM = KM.mass_matrix
    forcing = KM.forcing
    rhs = MM.inv() * forcing
    assert expand(rhs[0]) == expand((-k1 * q1 - c1 * u1 + k2 * q2 + c2 * u2)/m)
    assert expand(rhs[1]) == expand((k1 * q1 + c1 * u1 - 2 * k2 * q2 - 2 *
                                    c2 * u2) / m)
开发者ID:101man,项目名称:sympy,代码行数:43,代码来源:test_kane.py

示例6: test_particle

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_particle():
    m = Symbol('m')
    P = Point('P')
    p = Particle()
    assert p.mass == None
    assert p.point == None
    # Test the mass setter
    p.mass = m
    assert p.mass == m
    # Test the point setter
    p.point = P
    assert p.point == P
开发者ID:101man,项目名称:sympy,代码行数:14,代码来源:test_particle.py

示例7: test_particle

# 需要导入模块: from sympy.physics.mechanics import Particle [as 别名]
# 或者: from sympy.physics.mechanics.Particle import mass [as 别名]
def test_particle():
    m, m2 = symbols("m m2")
    P = Point("P")
    P2 = Point("P2")
    p = Particle("pa", P, m)
    assert p.mass == m
    assert p.point == P
    # Test the mass setter
    p.mass = m2
    assert p.mass == m2
    # Test the point setter
    p.point = P2
    assert p.point == P2
开发者ID:ness01,项目名称:sympy,代码行数:15,代码来源:test_particle.py


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