<blockquote>
<p>Is there a way to call these (or other differential equation solvers) without knowing an analytic expression for the derivative?</p>
</blockquote>
<p>是的,你提到的所有解算器(或大多数其他解算器)都不需要导数的解析表达式。相反,它们调用您提供的函数,该函数必须计算给定时间和状态的导数。因此,您的代码大致如下:</p>
<pre><code>def my_derivative(time,flat_Gamma):
Gamma = flat_Gamma.reshape(dim_1,dim_2)
u = get_u_from_time(time)
dGamma_dt = u.dot(Gamma)
return dGamma_dt.flatten()
from scipy.integrate import ode
my_integrator = ode(my_derivative)
…
</code></pre>
<p>您的困难在于,您必须确保<code>get_u_from_time</code>在每次调用它时都提供适当的结果。可能最健壮和最简单的解决方案是使用插值(参见<a href="https://stackoverflow.com/a/47314306/2127008">the other answer</a>)。在</p>
<p>您也可以尝试将集成步骤与您拥有的数据相匹配,但至少对于<code>scipy.integrate.odeint</code>和{<cd3>}来说,这将是非常繁琐的,因为所有的集成器都使用内部步骤,因此不太方便。例如,<a href="https://en.wikipedia.org/wiki/Dormand%E2%80%93Prince_method" rel="nofollow noreferrer">the fifth-order Dormand–Prince method (DoPri5)</a>使用1/5、3/10、4/5、8/9和1的内部步骤。这意味着,如果您有<code>u</code>的时间等距数据,则每个积分步骤需要90个数据点(因为1/90是内部步骤的最大公约数)。唯一可以使这一点远程可行的积分器是来自<a href="http://scipy.github.io/devdocs/generated/scipy.integrate.solve_ivp.html" rel="nofollow noreferrer">^{<cd5>}</a>的<a href="https://en.wikipedia.org/wiki/Bogacki%E2%80%93Shampine_method" rel="nofollow noreferrer">Bogacki–Shampine integrator</a>(RK23),其内部步骤为1/2、3/4和1。在</p>