24小时热门版块排行榜    

查看: 1189  |  回复: 0

jackyma

新虫 (小有名气)

[求助] 请教一个关于重力系统下质点球平抛落地反弹的运动轨迹数学模型建立的问题

有一个简单的物理问题想用Python 来实现,
问题:
有一质量为1kg的质点,在时刻t=0【s】时从高度0.5米的位置水平以1.0m/s的速度水平弹出(考虑重力向下),
与高度为0m,最大静止摩擦系数0.5,动摩擦系数为0.1且不会变形的平面接触(球与平面的反弹系数为0.3)后反弹,并反复落下反弹运动直至静止于平面之上,模拟出t=T[s]为止球的运动轨迹,间隔相同时间(Δ t)输出球的位置坐标。
T 和Δ t任意选择。

这个问题应该属于球体平抛反弹的轨迹模拟,网络上有类似问题建模。

在http://www.matlabsky.com/thread-13700-1-1.html里有考虑空气摩擦力的微分方程公式,但是我的问题是不需考虑空气摩擦,只要考虑地面摩擦力,有没有数学建模高手给指点一下。我这个模型要如何实现?

下面是我参考那个Matlab的帖子,写的一个python版,
可是问题是python的scipy的odeint函数没有办法判断着陆点y=0的时刻,也就意味着质点落地后反弹的运动轨迹无法模拟。
另外觉得那个帖子里的微分方程有点问题,请知道的大侠指点迷津!

再此先做感谢!
CODE:
import numpy as np
from scipy.integrate import odeint
import matplotlib.pyplot as plt

def fun(w, t, p):
    """Define the  equation for throw
    Arguments:
        w: vector of the state variables:
            w = [x,y, vx, vy]
        t: time
        p: vector of the parameters:
            p = [m, mu, g, e]
    :return: f
    """
    x, y, vx, vy = w
    m, mu, g, k = p

    # create f = (x',y', vx', vy'):

    f = [vx,                          # x' = dx/dt = vx
         -mu * vx / m,                 # vx' = dvx/dt = -mu * vx / m
         vy,                           # y' = dy/dt = vy
         -mu * vy / m - g,             # vy' = dvy/dt = -mu * vy /m - g
         ]
    return f

def main():
    # Parameter values
    # Masses
    m = 1
    # Friction coefficients
    mu = 0.1
    # Acceleration
    g = 9.8
    # Restitution coefficients
    k = 0.3

    # Initial conditions
    x = 0
    y = 0.5
    vx = 1
    vy = 0


    # ODE solver parameters
    abserr = 1.0e-8
    relerr = 1.0e-6
    # stop time for movement simulation
    stoptime = 0.7
    # delta time
    numpoints = 30

    # Create the time samples for the output of the ODE solver.
    t = [stoptime * float(i) / (numpoints - 1) for i in range(numpoints)]

    # Pack up the parameters and initial conditions:
    p = [m, mu, g, k]
    w0 = [x, y, vx, vy]

    # Call the ODE solver
    wsol = odeint(fun, w0, t, args=(p,), atol=abserr, rtol=relerr)

    with open('ball_movement.dat', 'w') as fi:
        # print and save the solution.
        for t1, w1 in zip(t, wsol):
            if w1[2] >= 0:
                print >> fi, t1, w1[0], w1[2]
            else:
                # print >> fi, "The ball is landing to floor!"

                x = w1[0]
                y = w1[2]
                vx = w1[1]
                vy = w1[3]
    # wsol = odeint(fun, w0, )

    # Plot the solution that was generated

    from numpy import loadtxt
    from pylab import figure, plot, xlabel, grid, hold, legend, title, savefig
    from matplotlib.font_manager import FontProperties

    t, x, y = loadtxt('ball_movement.dat', unpack=True)

    figure(1, figsize=(6, 4.5))

    xlabel('t')
    grid(True)
    hold(True)
    lw = 1

    plot(x, y, 'b', linewidth=lw)
    #plot(t, y, 'g', linewidth=lw)

    legend((r'$x$', r'$y$'), prop=FontProperties(size=16))
    title('Ball Mass System')
    savefig('ball_movement.png', dpi=100)


if __name__ == "__main__":
    main()

回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 jackyma 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 综述论文作为代表作会不会影响评审专家的印象分? +9 yufeiwaner 2026-08-09 9/450 2026-08-10 12:25 by 流流伤
[基金申请] 2026国自然放榜时间 +9 布布和一二 2026-08-08 9/450 2026-08-10 11:22 by xxxx2020
[基金申请] 据悉今年马上要出结果了 +5 瞬息宇宙 2026-08-10 6/300 2026-08-10 10:38 by Tide man
[基金申请] 面上项目filecode邪修 +5 西山十月 2026-08-09 7/350 2026-08-10 07:32 by 仁砚薪传
[基金申请] 关于代码变化问题,想知道的进来 +15 且听虎啸 2026-08-07 22/1100 2026-08-09 22:13 by 布布和一二
[基金申请] fileCode有新解读? +10 Tide man 2026-08-08 18/900 2026-08-09 12:55 by 仁砚薪传
[基金申请] 关于filecode,很负责任的告诉大家 +6 爱看书的可乐 2026-08-08 7/350 2026-08-08 22:13 by a_niu
[基金申请] 关于豆爷回答的JTJC与%2F数量 +5 yang182083 2026-08-06 7/350 2026-08-08 18:29 by zhanghaozhu
[基金申请] 基金中了 +14 laoda193707 2026-08-06 14/700 2026-08-08 00:23 by 实验小白ha
[基金申请] 娱乐 +6 Tide man 2026-08-03 6/300 2026-08-07 22:40 by 铁帽子农民
[基金申请] 化学口download_prp&fileCode的固定段好像这几天一直没变,有变的大神么? +3 Tide man 2026-08-07 4/200 2026-08-07 22:39 by Tide man
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
[基金申请] 听说今天filecode变了 +24 布布和一二 2026-08-06 47/2350 2026-08-07 16:02 by zhiyanjiang
[基金申请] filecode变化情况 +6 布布和一二 2026-08-07 22/1100 2026-08-07 14:45 by 且听虎啸
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 7/350 2026-08-07 13:11 by 医学老男孩
[基金申请] filecode +14 等待解的谜 2026-08-06 19/950 2026-08-07 12:20 by wlwhappy
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 求各位大神看下 100+6 hpkpkpkp 2026-08-05 33/1650 2026-08-06 14:49 by zhiyanjiang
[基金申请] 8月时间戳变的,举个手。玩一下,释放压力 +9 archvillain 2026-08-04 11/550 2026-08-05 20:06 by wlwhappy
[基金申请] 纯娱乐,不喜欢勿喷 +7 Tide man 2026-08-04 10/500 2026-08-04 15:10 by loufangrui
信息提示
请填处理意见