def velocity(stateVec, t):
"""
velocity in the full state space.
stateVec: state vector [x1, y1, x2, y2]
t: just for convention of odeint, not used.
return: velocity at stateVec. Dimension [1 x 4]
"""
x1 = stateVec[0]
y1 = stateVec[1]
x2 = stateVec[2]
y2 = stateVec[3]
r2 = x1**2 + y1**2
velo = np.array([(G_mu1-r2) * x1 + G_c1 * (x1*x2 + y1*y2),
(G_mu1-r2) * y1 + G_c1 * (x1*y2 - x2*y1),
x2 + y2 + x1**2 - y1**2 + G_a2 * x2 * r2,
-x2 + y2 + 2.0 * x1 * y1 + G_a2 * y2 * r2])
return velo
评论列表
文章目录