Python - ode 上的奇怪情节点

Python - Strange plot points on ode

作为硕士论文的一部分,我目前正在开发车辆的动态模型。

我正在使用 python 附带的 ode 求解器,我得到的结果看起来不错。 但是我注意到一些情节有问题。

我的部分代码如下:

 f = [#0 - x_ctr     
            dx_ctrdt,
        #1 - dx_ctrdt
            (flx_car1_A + flx_car1_B + flx_car2_A + flx_car2_B)/M_car + (x_ctr)*(V_tr**2)/R_curve/R_ctr - F_drag/M_car,
        #2 - y_ctr     
            dy_ctrdt,
        #3 - dy_ctrdt
            (fly_car1_A + fly_car1_B + fly_car2_A + fly_car2_B)/ M_car + (R_curve + y_ctr)*(V_tr**2)/R_curve/R_ctr - 9.8*np.sin(beta),
        #4 - omega_1
            -(flx_car1_A + flx_car1_B)*r/Inertia_1 - 0.5*F_rr*r/Inertia_1 + F_motor_1*r/Inertia_1,
        #5 - omega_2
            -(flx_car2_A + flx_car2_B)*r/Inertia_2 - 0.5*F_rr*r/Inertia_2 + F_motor_2*r/Inertia_2,
        #6 - alpha
            dalphadt,  
        #7 - dalphadt
            (mz_car_1  + mz_car_2 ) / Inertia_car,                            
        #8 - x_1A
            v_1A*cos_theta_1 - (V_tr/R_curve)*R_1A*cos_psi_1A,
        #9 - y_1A
            v_1A*sin_theta_1 - (V_tr/R_curve)*R_1A*sin_psi_1A,
        #10 - x_1B
            v_1B*cos_theta_1 - (V_tr/R_curve)*R_1B*cos_psi_1B,
        #11 - y_1B
            v_1B*sin_theta_1 - (V_tr/R_curve)*R_1B*sin_psi_1B,
        #12 - x_2A
            v_2A*cos_theta_2 - (V_tr/R_curve)*R_2A*cos_psi_2A,
        #13 - y_2A
            v_2A*sin_theta_2 - (V_tr/R_curve)*R_2A*sin_psi_2A,
        #14 - x_2B
            v_2B*cos_theta_2 - (V_tr/R_curve)*R_2B*cos_psi_2B,
        #15- y_2B
            v_2B*sin_theta_2 - (V_tr/R_curve)*R_2B*sin_psi_2B,
        ]

当我绘制 f 的解的图时,我得到了一个平滑的图。

dif_var_initial = [0.000, 0.000,    y_ctr_0,  -0.000, 140.0027, 140.0027, 0.000 ,  0.000,  x_1A_0, y_1A_0,  x_1B_0,  y_1B_0,  x_2A_0,  y_2A_0, x_2B_0, y_2B_0]

def dif_eqts(dif_var, t, kx1, ky1, cy1, M_car):
    global v_ax_1, v_ax_2,R_ctr,psi_ctr,Lamb_tk, A_tk, Time_max, delta_t, y_track_1_vector ,y_track_2_vector,R_curve, dRdt,z,j,v_1A,v_1B,v_2A,v_2B,P

    x_ctr, dx_ctrdt, y_ctr, dy_ctrdt, omega_1, omega_2, alpha, dalphadt, x_1A, y_1A, x_1B, y_1B, x_2A, y_2A, x_2B, y_2B = dif_var 

    #   Track disturbances
    eps_ax_1 = A_tk * np.sin(2.*np.pi*(V_tr/Lamb_tk)*t)
    eps_ax_1_tracker.append(eps_ax_1)
    .
    .
    .

但是,当我使用例如 eps_ax_1_tracker 制作图表时,我得到了不平滑的奇怪图表。(该程序显然不止于此,但我不想让您阅读太多行而感到厌烦的代码。)

例如:

更近:

这种行为正常吗? 我已经搜索过类似的问题,但没有找到任何可以帮助我的东西。

我希望你能对发生这种情况的原因提出一些建议,非常感谢你的帮助。

编辑(1)

我得到 x_ctr 的输出如下: x_ctr

对于部队来说: forces

振荡行为是由于铁轨不规则造成的。 我希望这有帮助。

数值求解器在接近但不在解轨迹上的状态下使用 "probing" 值。笼统地说,这对轨迹周围的方向场进行采样,以便下一步的计算值可能更准确。使用记录的路径获取输出,在 scipy.integrate.ode 中使用通过 sol_out 或类似的密集输出,参见 Using adaptive step sizes with scipy.integrate.ode,对于 scipy.integrate.odeint 使用时间列表输入参数来定义输出中报告的样本点。