我有以下代码:
def multirk4(funcs, x0, y0, step, xmax):
n = len(funcs)
table = [[x0] + y0]
f1, f2, f3, f4 = [0]*n, [0]*n, [0]*n, [0]*n
while x0 < xmax:
y1 = [0]*n
for i in range(n): f1[i] = funcs[i](x0, y0)
for j in range(n): y1[j] = y0[j] + (0.5*step*f1[j])
for i in range(n): f2[i] = funcs[i]((x0+(0.5*step)), y1)
for j in range(n): y1[j] = y0[j] + (0.5*step*f2[j])
for i in range(n): f3[i] = funcs[i]((x0+(0.5*step)), y1)
for j in range(n): y1[j] = y0[j] + (step*f3[j])
for i in range(n): f4[i] = funcs[i]((x0+step), y1)
x0 = x0 + step
for i in range(n): y1[i] = y0[i] + (step * \
(f1[i] + (2.0*f2[i]) + (2.0*f3[i]) + f4[i]) / 6.0)
table.append([x0] + y1)
y0 = y1
return table
system1 = range(2)
system2 = range(2)
y = range(2)
y[0] = 0.0
y[1] = 0.0
def mRNA(t, y): return 6e-8 - (0.01 * y[0])
def protein(t, y): return (0.05 * y[0]) - (0.001 * y[1])
system1[0] = mRNA
system1[1] = protein
system2[0] = protein
system2[1] = mRNA
t0 = 0.0
tmax = 100.0
dt = 0.1
s1 = multirk4(system1, t0, y, dt, tmax)
s2 = multirk4(system2, t0, y, dt, tmax)
for i in range(len(s1)):
print ','.join([str(s1[i][0]), str(s1[i][1]), str(s1[i][2]),
str(s2[i][1]), str(s2[i][2])])
我发现 s1 和 s2 给出不同的结果,这本质上是方程(mRNA和蛋白质)的不同顺序。
我是否可以进行任何修改以使订购不会产生影响?
提前致谢。