在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)```


    

解决方法

这与您将<!DOCTYPE html> <html> <body> <div id="trigger">Click to test</div> </body> </html> 传递到函数(defrule unable-to-diagnose (name ?name) (age ?age) (gender ?gender) (temperature ?C) (or (or (high-fever-days ?days) (and (vomiting no) (abdominal-pain-or-diarrhea no) (muscle-joint-pain no) (sore-muscles-and-joints no) (mild-conjunctival-congestion no)) (and (shock no) (respiratoty-failure no) (hemoptysis-or-purulent-sputum no) (shortness-of-breath) (rales-can-be-heard-in-the-lungs no))) (abnormal-sneezing-or-runny-nose no)) => (assert (diagnosis-result: unable-to-diagnose)) (printout t crlf "=======================================================================" crlf) (printout t crlf "Diagnosis Result of " ?name " : unable-to-diagnose " crlf) (printout t crlf "Treatment Suggestion to You :" crlf) (printout t crlf " " crlf) (printout t crlf "=======================================================================" crlf)) 中的方式有​​关。

以下内容在每次迭代中更改k的值

f()