I’m trying to follow the example for solving the heat equation PDE from the DiffEqOperators page, but I am running into an error in the discretization step. The code is
using OrdinaryDiffEq, ModelingToolkit, DiffEqOperators # Parameters, variables, and derivatives @parameters t x @variables u(..) # Warning: `@derivatives D'''~x` is deprecated. Use `Differential(x)^3` instead. #@derivatives Dt'~t #@derivatives Dxx''~x Dt = Differential(t) Dxx = Differential(x)^2 # 1D PDE and boundary conditions eq = Dt(u(t,x)) ~ Dxx(u(t,x)) bcs = [u(0,x) ~ cos(x), u(t,0) ~ exp(-t), u(t,Float64(pi)) ~ -exp(-t)] # Space and time domains domains = [t ∈ IntervalDomain(0.0, 1.0), x ∈ IntervalDomain(0.0, Float64(pi))] # PDE system pdesys = PDESystem(eq,bcs,domains,[t,x],[u]) # Method of lines discretization dx = 0.1 order = 2 discretization = MOLFiniteDifference(dx,order) # Convert the PDE problem into an ODE problem prob = discretize(pdesys,discretization) # <--- Error occurs here # Solve ODE problem sol = solve(prob,Tsit5(),saveat=0.1)
Side note, using
@derivatives as in the example gives a deprecation warning. With this setup, the error I get is
julia> prob = discretize(pdesys,discretization) ERROR: LoadError: type Int64 has no field val
This is with Julia v1.6.1 and
(diffeq) pkg> st Status `~/dev/learning/diffeq/Project.toml` [9fdde737] DiffEqOperators v4.24.0 [961ee093] ModelingToolkit v5.16.0 [1dea7af3] OrdinaryDiffEq v5.52.4 [91a5bcdd] Plots v1.12.0
Thank you in advance for any help.
Edit: This error seems similar to this one, however, that issue was traced to using complex numbers, which does not seem to be the case here.