You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be an error when calling getmetadata somewhere with a Pair instead of Num.
(Background: The minimal example below begins to simulate an advection-diffusion problem but with parameters D, v, and C0 as @parameters, while simulation domain length L for example is not an @parameter).
Expected behavior
Expected the library to produce a discretization, but it failed.
Minimal Reproducible Example 👇
using ModelingToolkit, MethodOfLines, DomainSets
@parameters t x
@parameters D, v, C0
@variablesc(..)
Dt =Differential(t)
Dx =Differential(x)
Dxx =Differential(x)^2
p = (
D =0.5,
C0 =1.0,
v =0.1,
T =1.0,
L =1.0,
)
@unpack L, T, C0 = p
dx =0.01
order =2# 1D PDE and boundary conditions
eq = [
Dt(c(t, x)) ~ D *Dxx(c(t, x))
]
bcs = [
c(0, x) ~ C0 *exp(-(x .- L/2).^2),
Dx(c(t, 0)) ~ (v/D) *c(t, 0),
Dx(c(t, L)) ~ (v/D) *c(t, L)
]
# Space and time domains
domains = [
t ∈Interval(0.0, T),
x ∈Interval(0.0, L),
]
# PDE system@named pdesys =PDESystem(
eq, bcs, domains,
[t, x], [c(t, x),],
[D=>p.D, v=>p.v,],
)
discretization =MOLFiniteDifference([x => dx], t, approx_order=order)
# Convert the PDE problem into an ODE problem
prob =discretize(pdesys, discretization)
Error & Stacktrace ⚠️
2-element Vector{Num}:
t
x
3-element Vector{Num}:
D
v
C0
1-element Vector{Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}}}:
c⋆Differential(t)
Differential(x)
Differential(x) ∘Differential(x)
(D =0.5, C0 =1.0, v =0.1, T =1.0, L =1.0)
(D =0.5, C0 =1.0, v =0.1, T =1.0, L =1.0)
0.0121-element Vector{Equation}:Differential(t)(c(t, x)) ~ D*Differential(x)(Differential(x)(c(t, x)))
3-element Vector{Equation}:c(0, x) ~exp(-((-0.5+ x)^2))
Differential(x)(c(t, 0)) ~ (v*c(t, 0)) / D
Differential(x)(c(t, 1.0)) ~ (v*c(t, 1.0)) / D
2-element Vector{Symbolics.VarDomainPairing}:
Symbolics.VarDomainPairing(t, 0.0..1.0)
Symbolics.VarDomainPairing(x, 0.0..1.0)
PDESystem
Equations: Equation[Differential(t)(c(t, x)) ~ D*Differential(x)(Differential(x)(c(t, x)))]
Boundary Conditions: Equation[c(0, x) ~exp(-((-0.5+ x)^2)), Differential(x)(c(t, 0)) ~ (v*c(t, 0)) / D, Differential(x)(c(t, 1.0)) ~ (v*c(t, 1.0)) / D]
Domain: Symbolics.VarDomainPairing[Symbolics.VarDomainPairing(t, 0.0..1.0), Symbolics.VarDomainPairing(x, 0.0..1.0)]
Dependent Variables: Num[c(t, x)]
Independent Variables: Num[t, x]
Parameters: Pair{Num, Float64}[D =>0.5, v =>0.1]
Default Parameter ValuesDict{Any, Any}()
MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}(Dict{Num, Float64}(x =>0.01), t, 2, UpwindScheme(1), MethodOfLines.CenterAlignedGrid(), true, false, MethodOfLines.ScalarizedDiscretization(), true, Any[], Base.Pairs{Symbol, Union{}, Tuple{}, @NamedTuple{}}())
The system of equations is:
Discretization failed, please post an issue on https://github.com/SciML/MethodOfLines.jl with the failing code and system at low point count.
ERROR: MethodError: no method matching getmetadata(::Pair{Num, Float64}, ::Type{ModelingToolkit.VariableGuess}, ::Nothing)
The function`getmetadata` exists, but no method is defined for this combination of argument types.
Closest candidates are:getmetadata(::SymbolicUtils.Symbolic, ::Any, ::Any)
@ SymbolicUtils ~/.julia/packages/SymbolicUtils/jf8aQ/src/types.jl:658getmetadata(::Num, ::Any)
@ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/Symbolics.jl:188getmetadata(::Complex{Num}, ::Any)
@ Symbolics ~/.julia/packages/Symbolics/GYV9b/src/Symbolics.jl:188...
Stacktrace:
[1] getguess(x::Pair{Num, Float64})
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/variables.jl:516
[2] (::ModelingToolkit.var"#776#789")(st::Pair{Num, Float64})
@ ModelingToolkit ./none:0
[3] iterate
@ ./generator.jl:48 [inlined]
[4] collect
@ ./array.jl:780 [inlined]
[5] ODESystem(deqs::Vector{…}, iv::Num, dvs::Vector{…}, ps::Vector{…}; controls::Vector{…}, observed::Vector{…}, systems::Vector{…}, tspan::Nothing, name::Symbol, description::String, default_u0::Dict{…}, default_p::Dict{…}, defaults::Dict{…}, guesses::Dict{…}, initializesystem::Nothing, initialization_eqs::Vector{…}, schedule::Nothing, connector_type::Nothing, preface::Nothing, continuous_events::Nothing, discrete_events::Nothing, parameter_dependencies::Vector{…}, checks::Bool, metadata::MethodOfLines.MOLMetadata{…}, gui_metadata::Nothing, is_dde::Nothing)
@ ModelingToolkit ~/.julia/packages/ModelingToolkit/89pF2/src/systems/diffeqs/odesystem.jl:265
[6] generate_system(disc_state::PDEBase.EquationState, s::MethodOfLines.DiscreteSpace{…}, u0::Vector{…}, tspan::Tuple{…}, metadata::MethodOfLines.MOLMetadata{…}, disc::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/VVGPP/src/discretization_state.jl:40
[7] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/VVGPP/src/symbolic_discretize.jl:89
[8] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…}; analytic::Nothing, kwargs::@Kwargs{})
@ PDEBase ~/.julia/packages/PDEBase/VVGPP/src/discretization_state.jl:57
[9] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{…})
@ PDEBase ~/.julia/packages/PDEBase/VVGPP/src/discretization_state.jl:54
[10] top-level scope
@ ~/Documents/GitHub/divergentMRIflow/scripts/getmetadataproblem.jl:47
Some type information was truncated. Use `show(err)` to see complete types.
Environment (please complete the following information):
But I'm wondering why your boundary conditions works fine, the problem can be discretized, while my problem failed, they are all Neumann type boundary conditions
Describe the bug 🐞
There seems to be an error when calling getmetadata somewhere with a Pair instead of Num.
(Background: The minimal example below begins to simulate an advection-diffusion problem but with parameters D, v, and C0 as @parameters, while simulation domain length L for example is not an @parameter).
Expected behavior
Expected the library to produce a discretization, but it failed.
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: