对于这个问题,我在ParameterizedFunctions.jl
DSL 中实现了相同的模型。以下 MWE 有效:
using DifferentialEquations
using Plots
# Modeling a consecutive / parallel reaction in a CSTR
# A --> 2B --> C, C --> 2B, B --> D
# PETERSEN-Matrix
# No. A B C D Rate
# 1 -1 2 k1*A
# 2 -2 1 k2*B*B
# 3 2 -1 k3*C
# 4 -1 1 k4*B
fpr! = @ode_def ConsecutiveParallelReaction begin
dA = -k_1*A + q_in/V_liq*(A_in - A)
dB = 2*k_1*A - 2*k_2*B*B + 2*k_3*C - k_4*B + q_in/V_liq*(B_in - B)
dC = k_2*B*B - k_3*C + q_in/V_liq*(C_in - C)
dD = k_4*B + q_in/V_liq*(D_in - D)
end k_1 k_2 k_3 k_4 q_in V_liq A_in B_in C_in D_in
u0 = [1.5, 0.1, 0, 0]
params = [1.0, 1.5, 0.75, 0.15, 3, 15, 0.5, 0, 0, 0]
tspan = (0.0, 15.0)
prob = ODEProblem(fpr!, u0, tspan, params)
sol = solve(prob)
plot(sol)
但是,使用sol = solve(prob, Rosenbrock23())
(甚至使用autodiff=false
),会发生以下错误:
ERROR: LoadError: MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type Float64
我想这是与上述类似的问题,但由于我没有Float64
在这里明确定义任何向量并且autodiff=false
没有消除错误,我不知道如何解决这个问题。有什么建议么?