Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CallWithMetadata has no field val error for simple PDE system #180

Closed
harrybooth opened this issue Oct 21, 2022 · 2 comments
Closed

CallWithMetadata has no field val error for simple PDE system #180

harrybooth opened this issue Oct 21, 2022 · 2 comments

Comments

@harrybooth
Copy link

using DifferentialEquations
using ModelingToolkit, MethodOfLines

@parameters x
@variables t c(..)

Dx = Differential(x)
Dxx = Differential(x)^2
Dt = Differential(t)

L = 1.
D = 0.16
k = 1.
j0 = 0.4

eq  = Dt(c(t,x)) ~ D*Dxx(c(t,x)) - k*c(t,x)

# Initial and boundary conditions
bcs = [c(0,x) ~ 0., 
       Dx(c(t,0)) ~ -j0, Dx(c(t,L)) ~ 0.]

# Space and time domains
domains = [t ∈ (0.0,12.0),
           x ∈ (0.0,L)]

@named pde_system = PDESystem(eq,bcs,domains,[t,x],[c])

dx = 0.01
order = 2
discretization = MOLFiniteDifference([x => dx], t)

prob = discretize(pde_system,discretization)

produces the error

type CallWithMetadata has no field val

Stacktrace:
 [1] getproperty
   @ ./Base.jl:38 [inlined]
 [2] (::MethodOfLines.var"#418#435")(x::Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}})
   @ MethodOfLines ~/.julia/packages/MethodOfLines/EqHjt/src/MOL_discretization.jl:16
 [3] iterate
   @ ./generator.jl:47 [inlined]
 [4] _collect
   @ ./array.jl:807 [inlined]
 [5] collect_similar(cont::Vector{Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}}}, itr::Base.Generator{Vector{Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}}}, MethodOfLines.var"#418#435"})
   @ Base ./array.jl:716
 [6] map(f::Function, A::Vector{Symbolics.CallWithMetadata{SymbolicUtils.FnType{Tuple, Real}, Base.ImmutableDict{DataType, Any}}})
   @ Base ./abstractarray.jl:2933
 [7] symbolic_discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid})
   @ MethodOfLines ~/.julia/packages/MethodOfLines/EqHjt/src/MOL_discretization.jl:16
 [8] discretize(pdesys::PDESystem, discretization::MOLFiniteDifference{MethodOfLines.CenterAlignedGrid})
   @ MethodOfLines ~/.julia/packages/MethodOfLines/EqHjt/src/MOL_discretization.jl:162
 [9] top-level scope
   @ ~/Documents/Hadjivasiliou_Julia_Tutorial/notebooks/Tutorial_SymbolicNumerics.ipynb:1

Project.toml:

  [6e4b80f9] BenchmarkTools v1.3.1
  [2b5f629d] DiffEqBase v6.105.1
  [ebbdde9d] DiffEqBayes v3.1.0
  [459566f4] DiffEqCallbacks v2.24.2
  [1130ab10] DiffEqParamEstim v1.27.0
  [0c46a032] DifferentialEquations v7.5.0
  [634d3b9d] DrWatson v2.11.1
  [94925ecb] MethodOfLines v0.5.1
⌃ [961ee093] ModelingToolkit v8.29.0
  [76087f3c] NLopt v0.6.5
⌃ [91a5bcdd] Plots v1.35.4
  [731186ca] RecursiveArrayTools v2.32.0
  [0c5d862f] Symbolics v4.13.0
  [fce5fe82] Turing v0.21.12
  [e88e6eb3] Zygote v0.6.49
  [37e2e46d] LinearAlgebra
@ChrisRackauckas ChrisRackauckas transferred this issue from SciML/ModelingToolkit.jl Oct 21, 2022
@xtalax
Copy link
Member

xtalax commented Oct 21, 2022

Please give the arguments of c in the PDESystem; try:

@named pde_system = PDESystem(eq,bcs,domains,[t,x],[c(t,x)])

@harrybooth
Copy link
Author

Ok done, and solved!

Might need to change the example in the Modeling toolkit documentation? : https://mtk.sciml.ai/stable/systems/PDESystem/

Currently it doesn't say to give the arguments (t,x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants