當前位置: 首頁>>代碼示例>>Python>>正文


Python Particle.point方法代碼示例

本文整理匯總了Python中sympy.physics.mechanics.Particle.point方法的典型用法代碼示例。如果您正苦於以下問題:Python Particle.point方法的具體用法?Python Particle.point怎麽用?Python Particle.point使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sympy.physics.mechanics.Particle的用法示例。


在下文中一共展示了Particle.point方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_pend

# 需要導入模塊: from sympy.physics.mechanics import Particle [as 別名]
# 或者: from sympy.physics.mechanics.Particle import point [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 point [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 point [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 point [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 point [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 point [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 point [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.point方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。