Python odeint()获取了意外的关键字参数';事件';

Python odeint()获取了意外的关键字参数';事件';,python,events,odeint,Python,Events,Odeint,如何使用“事件”停止集成? 我正在使用odeint研究飞机坠毁时的自由落体。高度与时间的函数,当高度接近0时,我想停止不均衡 #numerical integration import numpy as np import scipy.integrate as spi import matplotlib.pyplot as plt from scipy.integrate import solve_ivp m = 63974. # particle's mass in kg k = 12.

如何使用“事件”停止集成? 我正在使用odeint研究飞机坠毁时的自由落体。高度与时间的函数,当高度接近0时,我想停止不均衡

#numerical integration
import numpy as np
import scipy.integrate as spi
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp

m = 63974.  # particle's mass in kg
k = 12.  
g = 9.81  


v0 = np.zeros(4)
v0[1] = 1668. 
v0[3] = 98. 


def f(v, t0, k,):
    u, udot = v[:2], v[2:]
    udotdot = (-k / m) * np.power(udot,2) 
    udotdot[1] -= g
    return np.r_[udot, udotdot]


fig, ax = plt.subplots(1, 1, figsize=(8, 4))

t = np.linspace(0., 40., 100,) 

def hit_ground(t,v0): return v0[0]
hit_ground.terminal = True
hit_ground.direction = -1


v = spi.odeint(f, v0, t, args=(k,),events=hit_ground)
ax.plot(t,v[:,1],'o-', mew=1, ms=8, mec='w')

ax.legend()
ax.set_xlabel('Time') 
ax.set_ylabel('Altitude') 
ax.set_xlim(0, 40)
ax.set_ylim(0, 2500)
print(v[:,1])
spi.odeint(f,v0,t,args=(k,),events=hit\u ground)
没有
events
参数。