Using code from Example 1 in the library repo README to get started.
I’m getting ERROR: MethodError: no method matching zero(::Type{Vector{Float64}})
and not clear how to decode the Stacktrace …
using OrdinaryDiffEq, ModelingToolkit, DiffEqOperators, DomainSets, DifferentialEquations, Interpolations
###
function uniform_linear_sample(data_in, n_samples)
# Resample a 1D dataset using a given number of sample points using linear interpolation.
nodes_in = range(1, size(data_in)[1], length=length(data_in))
nodes_eval = range(1, Int(nodes_in[end]), length = Int(n_samples))
int = interpolate((nodes_in,), data_in, Gridded(Linear()))
data_out = zeros(length(nodes_eval))
idx = trues(length(nodes_eval))
data_out[idx] = int(nodes_eval[idx])
return data_out
end
n_nodes = 1000
x_ic = range(0,Float64(2pi),length=10000)
data_vector = cos.(x_ic) .+ 1
ic() = uniform_linear_sample(data_vector,n_nodes)
@register ic()
###
# Parameters, variables, and derivatives
@parameters t x
@variables u(..)
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) ~ ic(),
u(t,0) ~ exp(-t),
u(t,Float64(pi)) ~ -exp(-t)]
# Space and time domains
domains = [t ∈ Interval(0.0,1.0),
x ∈ Interval(0.0,Float64(2pi))]
# PDE system
@named pdesys = PDESystem(eq,bcs,domains,[t,x],[u(t,x)])
# Method of lines discretization
dx = 0.1
order = 2
discretization = MOLFiniteDifference([x=>dx],t;centered_order=order)
# Convert the PDE problem into an ODE problem
prob = discretize(pdesys,discretization)
# Solve ODE problem
sol = solve(prob,saveat=0.1)
ERROR: LoadError: MethodError: no method matching zero(::Type{Vector{Float64}})
Closest candidates are:
zero(::Union{Type{P}, P}) where P<:Dates.Period at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Dates\src\periods.jl:53
zero(::ExtendedJumpArray) at C:\Users\thompsmj.X-MJIS3050PC09\.julia\packages\DiffEqJump\x05Qi\src\extended_jump_array.jl:26
zero(::Unitful.AbstractQuantity{T, D, U} where {T, D, U<:(Unitful.Units{N, D, A} where {N, D, A<:Unitful.Affine})}) at C:\Users\thompsmj.X-MJIS3050PC09\.julia\packages\Unitful\yI5QN\src\quantities.jl:374
...
Stacktrace:
[1] zero(x::Vector{Vector{Float64}})
@ Base .\abstractarray.jl:1085