在Python中使用scipy.odeint方法进行多次返回

问题描述

我正在尝试使用scipy.odeint()方法来解决二阶偏导函数。
我可以针对常数k的单个值执行此操作,常数k是我具有的函数的常数。
但是我想对k的许多值尝试这种解决方案。
为此,我将所需的值包含在列表k中,并经历了一个循环,我希望将这些值作为参数插入最终解决方案中。
但是,出现错误

错误:额外的参数必须在元组中

import numpy as np
from scipy.integrate import odeint

### Code with a single value of K.THAT WORKS FINE!!!! ###
k = 1   #attributes to be changed
t = [0.1,0.2,0.3] #Data
init = [45,0] #initial values

#Function to apply an integration
def f(init,t,args=(k,)):
    dOdt = init[1]
    dwdt = -np.cos(init[0]) + k*dOdt
    return [dOdt,dwdt]

#integrating function that returns a list of 2D numpy arrays 
zCH = odeint(f,init,t)
################################################################
### Code that DOES NOT WORK!###
k = [1,2,3]   #attributes to be changed
t = [0.1,dwdt]

solutions = []
for i in k:
    #integrating function that returns a list of 2D numpy arrays 
    zCH = odeint(f,(k[i-1]))
    solutions.append(zCH)```


    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)