Пример #1
0
system = [Particle('P1', pP1, m1), Particle('P2', pDs, m2)]

# kinematic differential equations
kde = [u1 - dot(pP1.vel(A), E.x), u2 - dot(pP1.vel(A), E.y), u3 - q3d]
kde_map = solve(kde, qd)
# include second derivatives in kde map
for k, v in kde_map.items():
    kde_map[k.diff(t)] = v.diff(t)

# use nonholonomic partial velocities to find the nonholonomic
# generalized active forces
vc = [dot(pDs.vel(B), E.y).subs(kde_map)]
vc_map = solve(vc, [u3])
partials = partial_velocities(points, [u1, u2], A, kde_map, vc_map)
Fr, _ = generalized_active_forces(partials, forces)
Fr_star, _ = generalized_inertia_forces(partials, system, kde_map, vc_map)

# dynamical equations
dyn_eq = [x + y for x, y in zip(Fr, Fr_star)]
u1d, u2d = ud = [x.diff(t) for x in [u1, u2]]
dyn_eq_map = solve(dyn_eq, ud)

for x in ud:
    print('{0} = {1}'.format(msprint(x), msprint(trigsimp(dyn_eq_map[x]))))

u1d_expected = (-g * sin(q3) + omega**2 * q1 * cos(q3) +
                (m2 * L * omega**2 * cos(q3)**2 - m1 * u2**2 / L) / (m1 + m2))
u2d_expected = -g * cos(q3) - omega**2 * q1 * sin(q3) + u1 * u2 / L
assert expand(trigsimp(dyn_eq_map[u1d] - u1d_expected)) == 0
assert expand(trigsimp(dyn_eq_map[u2d] - u2d_expected)) == 0
Пример #2
0
I_C = inertia(C, m * R ** 2 / 4, m * R ** 2 / 4, m * R ** 2 / 2)
rbC = RigidBody("rbC", pC_star, C, m, (I_C, pC_star))

# forces
R_C_hat = Px * A.x + Py * A.y + Pz * A.z
R_C_star = -m * g * A.z
forces = [(pC_hat, R_C_hat), (pC_star, R_C_star)]

# partial velocities
bodies = [rbC]
system = [i.masscenter for i in bodies] + [i.frame for i in bodies] + list(zip(*forces)[0])
partials = partial_velocities(system, [u1, u2, u3], A, kde_map, vc_map)

# generalized active forces
Fr, _ = generalized_active_forces(partials, forces)
Fr_star, _ = generalized_inertia_forces(partials, bodies, kde_map, vc_map)

# dynamical equations
dyn_eq = subs([x + y for x, y in zip(Fr, Fr_star)], kde_map)
u1d, u2d, u3d = ud = [x.diff(t) for x in [u1, u2, u3]]
dyn_eq_map = solve(dyn_eq, ud)

for x in ud:
    print("{0} = {1}".format(msprint(x), msprint(trigsimp(dyn_eq_map[x]))))

u1d_expected = (u2 ** 2 * tan(q2) - 6 * u2 * u3 - 4 * g * sin(q2) / R) / 5
u2d_expected = 2 * u3 * u1 - u1 * u2 * tan(q2)
u3d_expected = 2 * u1 * u2 / 3
assert trigsimp(expand(dyn_eq_map[u1d] - u1d_expected)) == 0
assert trigsimp(expand(dyn_eq_map[u2d] - u2d_expected)) == 0
assert trigsimp(expand(dyn_eq_map[u3d] - u3d_expected)) == 0
Пример #3
0
rbB = RigidBody('rbB', pB_star, B, mB, (inertia_B, pB_star))
rbC = RigidBody('rbC', pC_star, C, mB, (inertia_C, pC_star))
bodies = [rbA, rbB, rbC]

# forces, torques
forces = [(pS_star, -M*g*F.x), (pQ, Q1*A.x + Q2*A.y + Q3*A.z)]
torques = []

# collect all significant points/frames of the system
system = [y for x in bodies for y in [x.masscenter, x.frame]]
system +=  [x[0] for x in forces + torques]

# partial velocities
partials = partial_velocities(system, [u1, u2, u3], F,
                              kde_map, express_frame=A)

# Fr, Fr*
Fr, _ = generalized_active_forces(partials, forces + torques, uaux=[u3])
Fr_star, _ = generalized_inertia_forces(partials, bodies, kde_map, uaux=[u3])

friction = -u_prime*Q1*(pQ.vel(F).normalize().express(A)).subs(u3, 0)
Q_map = dict(zip([Q2, Q3], [dot(friction, x) for x in [A.y, A.z]]))
Q_map[Q1] = trigsimp(solve(F3 - Fr[-1].subs(Q_map), Q1)[0])

#F3 + F3* = 0
Q_map[Q1] = Q_map[Q1].subs(F3, -Fr_star[2])
print('Q1 = {0}'.format(msprint(Q_map[Q1])))

Q1_expected = e*M*g*cos(theta)/(f - u_prime*R*u2/sqrt(u2**2 + f**2*u1**2))
assert expand(radsimp(Q_map[Q1] - Q1_expected)) == 0
Пример #4
0
forces = [(pP1, R1), (pDs, R2)]
point_masses = [Particle('P1', pP1, m1), Particle('P2', pDs, m2)]
points = [f[0] for f in forces]

# define generalized speeds
kde = [u_i - u_ex for u_i, u_ex in zip(ulist, u_expr)]
kde_map = solve(kde, [q1d, q2d, q3d])

# include second derivatives in kde map
for k, v in kde_map.items():
    kde_map[k.diff(t)] = v.diff(t)

# calculate partials, generalized forces
partials = partial_velocities(points, [u1, u2, u3], A, kde_map)
Fr, _ = generalized_active_forces(partials, forces)
Fr_star, _ = generalized_inertia_forces(partials, point_masses, kde_map)

# use nonholonomic partial velocities to find the nonholonomic
# generalized active forces
vc = [dot(pDs.vel(B), E.y)]
vc_map = solve(subs(vc, kde_map), [u3])
partials_tilde = partial_velocities(points, [u1, u2], A, kde_map, vc_map)
Fr_tilde, _ = generalized_active_forces(partials_tilde, forces)
Fr_tilde_star, _ = generalized_inertia_forces(partials_tilde, point_masses,
                                              kde_map, vc_map)

print("\nFor generalized speeds\n[u1, u2, u3] = {0}".format(msprint(u_expr)))
print("\nGeneralized active forces:")
for i, f in enumerate(Fr, 1):
    print("F{0} = {1}".format(i, msprint(simplify(f))))
print("\nGeneralized inertia forces:")
Пример #5
0
system = [Particle('P1', pP1, m1), Particle('P2', pDs, m2)]

# kinematic differential equations
kde = [u1 - dot(pP1.vel(A), E.x), u2 - dot(pP1.vel(A), E.y), u3 - q3d]
kde_map = solve(kde, qd)
# include second derivatives in kde map
for k, v in kde_map.items():
    kde_map[k.diff(t)] = v.diff(t)

# use nonholonomic partial velocities to find the nonholonomic
# generalized active forces
vc = [dot(pDs.vel(B), E.y).subs(kde_map)]
vc_map = solve(vc, [u3])
partials = partial_velocities(points, [u1, u2], A, kde_map, vc_map)
Fr, _ = generalized_active_forces(partials, forces)
Fr_star, _ = generalized_inertia_forces(partials, system, kde_map, vc_map)

# dynamical equations
dyn_eq = [x + y for x, y in zip(Fr, Fr_star)]
u1d, u2d = ud = [x.diff(t) for x in [u1, u2]]
dyn_eq_map = solve(dyn_eq, ud)

for x in ud:
    print('{0} = {1}'.format(msprint(x),
                             msprint(trigsimp(dyn_eq_map[x]))))

u1d_expected = (-g*sin(q3) + omega**2*q1*cos(q3) +
                (m2*L*omega**2*cos(q3)**2 - m1*u2**2/L)/(m1 + m2))
u2d_expected = -g*cos(q3) - omega**2*q1*sin(q3) + u1*u2/L
assert expand(trigsimp(dyn_eq_map[u1d] - u1d_expected)) == 0
assert expand(trigsimp(dyn_eq_map[u2d] - u2d_expected)) == 0
Пример #6
0
# inertias of bodies A, B, C
# IA22, IA23, IA33 are not specified in the problem statement, but are
# necessary to define an inertia object. Although the values of
# IA22, IA23, IA33 are not known in terms of the variables given in the
# problem statement, they do not appear in the general inertia terms.
inertia_A = inertia(A, IA, IA22, IA33, 0, IA23, 0)
inertia_B = inertia(B, K, K, J)
inertia_C = inertia(C, K, K, J)

# define the rigid bodies A, B, C
rbA = RigidBody('rbA', pA_star, A, mA, (inertia_A, pA_star))
rbB = RigidBody('rbB', pB_star, B, mB, (inertia_B, pB_star))
rbC = RigidBody('rbC', pC_star, C, mB, (inertia_C, pC_star))
bodies = [rbA, rbB, rbC]

# create new partial velocities since we define new points A*, B*, C* and
# new frames B, C
system = []
for b in bodies:
    system += [b.masscenter, b.frame]
partials2 = partial_velocities(system, [u1, u2, u3],
                               F,
                               kde_map,
                               express_frame=A)

Fr_star, _ = generalized_inertia_forces(partials2, bodies, kde_map, uaux=[u3])
print("Generalized inertia forces:")
for i, f in enumerate(Fr_star, 1):
    print("F{0} = {1}".format(i, msprint(expand(trigsimp(f)))))
Пример #7
0
forces = [(pP1, R1), (pP2, R2)]
point_masses = [Particle('P1', pP1, m1), Particle('P2', pP2, m2)]
torques = []

ulist = [u1, u2, u3]
for uset in [u_s1, u_s2, u_s3]:
    print("\nFor generalized speeds:\n[u1, u2, u3] = {0}".format(msprint(uset)))
    # solve for u1, u2, u3 in terms of q1d, q2d, q3d and substitute
    kde = [u_i - u_expr for u_i, u_expr in zip(ulist, uset)]
    kde_map = solve(kde, [q1d, q2d, q3d])

    # include second derivatives in kde map
    for k, v in kde_map.items():
        kde_map[k.diff(t)] = v.diff(t)

    partials = partial_velocities([pP1, pP2], ulist, A, kde_map)
    Fr, _ = generalized_active_forces(partials, forces + torques)
    Fr_star, _ = generalized_inertia_forces(partials, point_masses, kde_map)
    print("Generalized active forces:")
    for i, f in enumerate(Fr, 1):
        print("F{0} = {1}".format(i, msprint(simplify(f))))
    print("Generalized inertia forces:")
    for i, f in enumerate(Fr_star, 1):
        sub_map = {}
        if uset == u_s1: # make the results easier to read
            if i == 1 or i == 3:
                sub_map = solve([u1 - u_s1[0]], [omega*q1*sin(omega*t)])
        print("F{0}* = {1}".format(i, msprint(simplify(f.subs(sub_map)))))

Пример #8
0
# inertia[0] is defined to be the central inertia for each rigid body
rbA = RigidBody('rbA', pA_star, A, mA, (IA, pA_star))
rbB = RigidBody('rbB', pB_star, B, mB, (IB, pB_star))
rbC = RigidBody('rbC', pC_star, C, mC, (IC, pC_star))
rbD = RigidBody('rbD', pD_star, D, mD, (ID, pD_star))
bodies = [rbA, rbB, rbC, rbD]

## --- generalized speeds ---
kde = [
    u1 - dot(A.ang_vel_in(E), A.x), u2 - dot(B.ang_vel_in(A), B.y),
    u3 - dot(pC_star.vel(B), B.z)
]
kde_map = solve(kde, [q0d, q1d, q2d])
for k, v in kde_map.items():
    kde_map[k.diff(t)] = v.diff(t)

print('\nEx8.20')
# inertia torque for a rigid body:
# T* = -dot(alpha, I) - dot(cross(omega, I), omega)
T_star = lambda rb, F: (-dot(rb.frame.ang_acc_in(F), rb.inertia[0]) - dot(
    cross(rb.frame.ang_vel_in(F), rb.inertia[0]), rb.frame.ang_vel_in(F)))
for rb in bodies:
    print('\nT* ({0}) = {1}'.format(rb, msprint(T_star(rb, E).subs(kde_map))))

print('\nEx8.21')
system = [getattr(b, i) for b in bodies for i in ['frame', 'masscenter']]
partials = partial_velocities(system, [u1, u2, u3], E, kde_map)
Fr_star, _ = generalized_inertia_forces(partials, bodies, kde_map)
for i, f in enumerate(Fr_star, 1):
    print("\nF*{0} = {1}".format(i, msprint(simplify(f))))
Пример #9
0
forces = [(pP1, R1), (pDs, R2)]
point_masses = [Particle('P1', pP1, m1), Particle('P2', pDs, m2)]
points = [f[0] for f in forces]

# define generalized speeds
kde = [u_i - u_ex for u_i, u_ex in zip(ulist, u_expr)]
kde_map = solve(kde, [q1d, q2d, q3d])

# include second derivatives in kde map
for k, v in kde_map.items():
    kde_map[k.diff(t)] = v.diff(t)

# calculate partials, generalized forces
partials = partial_velocities(points, [u1, u2, u3], A, kde_map)
Fr, _ = generalized_active_forces(partials, forces)
Fr_star, _ = generalized_inertia_forces(partials, point_masses, kde_map)

# use nonholonomic partial velocities to find the nonholonomic
# generalized active forces
vc = [dot(pDs.vel(B), E.y)]
vc_map = solve(subs(vc, kde_map), [u3])
partials_tilde = partial_velocities(points, [u1, u2], A, kde_map, vc_map)
Fr_tilde, _ = generalized_active_forces(partials_tilde, forces)
Fr_tilde_star, _ = generalized_inertia_forces(partials_tilde, point_masses,
                                              kde_map, vc_map)

print("\nFor generalized speeds\n[u1, u2, u3] = {0}".format(msprint(u_expr)))
print("\nGeneralized active forces:")
for i, f in enumerate(Fr, 1):
    print("F{0} = {1}".format(i, msprint(simplify(f))))
print("\nGeneralized inertia forces:")
Пример #10
0
forces = [(pP1, R1), (pP2, R2)]
point_masses = [Particle('P1', pP1, m1), Particle('P2', pP2, m2)]
torques = []

ulist = [u1, u2, u3]
for uset in [u_s1, u_s2, u_s3]:
    print("\nFor generalized speeds:\n[u1, u2, u3] = {0}".format(
        msprint(uset)))
    # solve for u1, u2, u3 in terms of q1d, q2d, q3d and substitute
    kde = [u_i - u_expr for u_i, u_expr in zip(ulist, uset)]
    kde_map = solve(kde, [q1d, q2d, q3d])

    # include second derivatives in kde map
    for k, v in kde_map.items():
        kde_map[k.diff(t)] = v.diff(t)

    partials = partial_velocities([pP1, pP2], ulist, A, kde_map)
    Fr, _ = generalized_active_forces(partials, forces + torques)
    Fr_star, _ = generalized_inertia_forces(partials, point_masses, kde_map)
    print("Generalized active forces:")
    for i, f in enumerate(Fr, 1):
        print("F{0} = {1}".format(i, msprint(simplify(f))))
    print("Generalized inertia forces:")
    for i, f in enumerate(Fr_star, 1):
        sub_map = {}
        if uset == u_s1:  # make the results easier to read
            if i == 1 or i == 3:
                sub_map = solve([u1 - u_s1[0]], [omega * q1 * sin(omega * t)])
        print("F{0}* = {1}".format(i, msprint(simplify(f.subs(sub_map)))))