2

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?

winkmal
  • 622
  • 1
  • 6
  • 16

1 Answers1

1

From the comments it seems like this actually works.

Chris Rackauckas
  • 18,645
  • 3
  • 50
  • 81
  • It used to; when I tried running it today (Julia 1.1.1 on Linux), I got: `ERROR: LoadError: type ConsecutiveParallelReaction has no field Wfact Stacktrace: [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18` Has anything changed in `DifferentialEquations.jl` which makes this code fail? – winkmal Aug 10 '19 at 11:04