你能用变量常数解决ode吗?

问题描述 投票:1回答:1

我有一个单一的任务,我必须创建月球下降模型。模型从高处开始,随着两个放置在一个角度下的引擎而下降。这是我遇到的代码的一部分:

F1 = f*np.array([1, 1, 0.5, 0, 0, 1, 1]) #f-thrust in newtons
F2 = f*np.array([1, 1, 0.5, 0, 0, 1, 1]) #F1 and F2 regime of engines for each time step(percentage of thrust)

t = np.arange(0, np.size(F1), dt) #time domain

#a,b - angles of engines according to global coordinate system
#s0x, v0x, s0y, v0y, fi0, omg0 - initial values
#m - mass
def model_engine(u, t):
    x, vx, y, vy, phi, w = u   
    d1 = vx
    d2 = (1/(m))*(F1*np.cos((a)) - F2*np.cos((b)))
    d3 = vy
    d4 = (1/(m))*(F1*np.sin((a)) + F2*np.sin((b))) + g 
    d5 = w
    d6 = (F1*np.cos(a)*(h/2) - F1*np.sin(a)*(w/2) + F2*np.sin(b)*(w/2) - 
             F2*np.cos(b)*(h/2))/((1/12)*(m)*h**2)
    return np.array([d1, d2, d3, d4, d5, d6])

U = odeint(model_engine, [s0x, v0x, s0y, v0y, fi0, omg0], t)
  1. 我不知道如何在定义中为每个时间步执行不同的F1?我得到qazxsw poi同样是变量质量,它取决于引擎制度。
  2. 该解决方案给出了航天器的角度(d6)。以这种方式写的方程总是给出a和b为45度,这显然是不正确的,因为航天器旋转。如何从前一步骤中获取解决方案(角度)并将其置于当前步骤中?见照片澄清

python numpy physics ode odeint
1个回答
0
投票

这是第一个问题的方法:如何实现变量系数?假设推力仅是ValueError: setting an array element with a sequence.的阶梯函数。它是通过在相应的时间插入给定的推力指令而获得的。插值函数作为附加参数传递给t函数。

该模型被简化为具有恒定质量的垂直着陆器。

model_engine
© www.soinside.com 2019 - 2024. All rights reserved.