How to get Rosenbrock23 to work with ODE in ParameterizedFunctions.jl DSL?

*爱你&永不变心* 提交于 2019-12-11 02:28:04

问题


Further to this question, I have the same model implemented in ParameterizedFunctions.jl DSL. The following MWE works:

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)

However, with sol = solve(prob, Rosenbrock23()) (and even with autodiff=false), the following error occurs:

ERROR: LoadError: MethodError: Cannot `convert` an object of type Array{Float64,1} to an object of type Float64

I suppose it is a similar issue like the abovementioned, but since I have not explicitly defined any Float64 vectors here and autodiff=false does not eliminate the error, I don't know how to fix this. Any suggestions?


回答1:


From the comments it seems like this actually works.



来源:https://stackoverflow.com/questions/54438451/how-to-get-rosenbrock23-to-work-with-ode-in-parameterizedfunctions-jl-dsl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!