我是一个python初学者,目前使用scipy的odeint
来计算耦合的ODE系统,但是,当我运行时,python shell总是告诉我
>>>
Excess work done on this call (perhaps wrong Dfun type).
Run with full_output = 1 to get quantitative information.
>>>
所以,我必须改变我的时间步和最后时间,以使其可积。要做到这一点,我需要尝试不同的组合,这是相当痛苦的。有谁能告诉我怎样才能让odeint
自动改变时间步骤和最终时间来成功地集成这个ode系统吗?
下面是代码的一部分,它调用了odeint:
def main(t, init_pop_a, init_pop_b, *args, **kwargs):
"""
solve the obe for a given set of parameters
"""
# construct initial condition
# initially, rho_ee = 0
rho_init = zeros((16,16))*1j ########
rho_init[1,1] = init_pop_a
rho_init[2,2] = init_pop_b
rho_init[0,0] = 1 - (init_pop_a + init_pop_b)########
rho_init_ravel, params = to_1d(rho_init)
# perform the integration
result = odeint(wrapped_bloch3, rho_init_ravel, t, args=args)
# BUG: need to pass kwargs
# rewrap the result
return from_1d(result, params, prepend=(len(t),))
things = [2*pi, 20*pi, 0,0, 0,0, 0.1,100]
Omega_a, Omega_b, Delta_a, Delta_b, \
init_pop_a, init_pop_b, tstep, tfinal = things
args = ( Delta_a, Delta_b, Omega_a, Omega_b )
t = arange(0, tfinal + tstep, tstep)
data = main(t, init_pop_a, init_pop_b, *args)
plt.plot(t,abs(data[:,4,4]))
其中wrapped_bloch3是compute dy/dt函数。
编辑:我注意到您已经在这里得到了答案:complex ODE systems in scipy
odeint
不适用于复数方程。我明白了您可以通过另一个ode解算器来解方程:
相关问题 更多 >
编程相关推荐