# Passing array as parameter to a PDESystem

Hello, I am trying to solve an inverse diffusion+source problem based on some data on the surface of a cylinder. I already tried several PINN implementations I have used before but with no luck.

What I am trying to do is to pass a Neural Network as the source function in the diffusion equation which is solved by MethodOfLines discretization

rng =  StableRNG(111)
Source = Lux.Chain(Lux.Dense(3, 10, Lux.tanh), Lux.Dense(10, 10, Lux.tanh), Lux.Dense(10, 1))
p, st = Lux.setup(rng, Source)
p = p |> ComponentArray

source_f(x,y,t,p)=Source([x,y,t],p,st)[1][1]

#alternative where parameters as an array
#ax = getaxes(p)
#source_f(x,y,t,p)=Source([x,y,t],ComponentArray(p, ax),st)[1][1]

# SCIML
@parameters x y t
@variables u(..)
@parameters NNp

Dt = Differential(t)
Dxx = Differential(x)^2
Dyy = Differential(y)^2

k=1.0 #Diffusion rate
x_min = 0.0
x_max = 2pi
y_min = -3.5
y_max = 3.5
t_min=0.0
t_max = 2.0

# Diffusion + Source Equation
eq = [Dt(u(x, y, t)) ~ k*(Dxx(u(x, y, t)) /R^2.0 + Dyy(u(x, y, t))) + source_f(x,y,t,NNp)]

domains = [x ∈ Interval(x_min, x_max),
y ∈ Interval(y_min, y_max),
t ∈ Interval(t_min, t_max)]

# Periodic BCs
bcs = [u(x, y, t_min) ~ 0.0,
u(0.0,y,t) ~ u(2pi,y,t),
u(x,y_min,t) ~ 0.0,
u(x,y_max,t) ~ 0.0,
]

@named pdesys = PDESystem(eq, bcs, domains, [x, y, t], [u(x, y, t)], [NNp=>p])


If instead I just pass the NN parameters p

eq = [Dt(u(x, y, t)) ~ k*(Dxx(u(x, y, t)) /R^2.0 + Dyy(u(x, y, t))) + f_lux(x,y,t,p)]


then PDESystem returns the complex differential equation
\begin{align} \frac{\mathrm{d}}{\mathrm{d}t} u\left( x, y, t \right) =& - 0.15283 \tanh\left( - 0.24307 \tanh\left( 0.36912 x + 0.23229 y + 0.96265 t \right) - 0.25029 \tanh\left( - 0.19622 t + 0.69493 x + 0.28371 y \right) + 0.12704 \tanh\left( - 0.095981 t + 0.63144 x - 0.99337 y \right) \right) - 1.0571 \tanh\left( 0.29481 \tanh\left( 0.36912 x + 0.23229 y + 0.96265 t \right) + 0.39887 \tanh\left( - 0.19622 t + 0.69493 x + 0.28371 y \right) + 0.34252 \tanh\left( - 0.095981 t + 0.63144 x - 0.99337 y \right) \right) + 1.1411 \tanh\left( - 0.26456 \tanh\left( 0.36912 x + 0.23229 y + 0.96265 t \right) - 0.59344 \tanh\left( - 0.19622 t + 0.69493 x + 0.28371 y \right) + 0.59808 \tanh\left( - 0.095981 t + 0.63144 x - 0.99337 y \right) \right) + 0.69444 \frac{\mathrm{d}}{\mathrm{d}x} \frac{\mathrm{d}}{\mathrm{d}x} u\left( x, y, t \right) + \frac{\mathrm{d}}{\mathrm{d}y} \frac{\mathrm{d}}{\mathrm{d}y} u\left( x, y, t \right) \end{align}
and it is ready to be solved. By the way this seems not to be working in Flux and SimpleChains.

If I pass p through the parameters term in the PDESystem (in order to optimize it through a loss function and the remake function) however I get

MethodError: no method matching ComponentArrays.ComponentArray(::Symbolics.Num, ::Tuple{ComponentArrays.Axis{(layer_1 = ViewAxis(1:12, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_2 = ViewAxis(13:24, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_3 = ViewAxis(25:28, Axis(weight = ViewAxis(1:3, ShapedAxis((1, 3), NamedTuple())), bias = ViewAxis(4:4, ShapedAxis((1, 1), NamedTuple())))))}})


Am I missing something?

I have been experimenting with something similar, but unfortunately was not able to get it to work elegantly.

I suggest you try:

@register_symbolic source_f(x,y,t,p)


somewhere before the eq declaration, please let me know if that works. If not, this is moving up the list of things to fix soon.

1 Like

Thanks xtalax, indeed @register_symbolic source_f(x,y,t,p) allows to move it forward, now it breaks in the problem definition.

@named pdesys = PDESystem(eq, bcs, domains, [x, y, t], [u(x, y, t)], [Symbolics.scalarize(NNp) .=>p])

Nx = 10
Ny = 10
dx = (x_max - x_min) / Nx
dy = (y_max - y_min) / Ny
xx=collect(x_min:dx:x_max)
yy=collect(y_min:dy:y_max)
order = 2
discretization = MOLFiniteDifference([x => dx, y => dy], t, approx_order = order, grid_align = center_align)


EDIT: After I saw a similar question in github (discretization fails when there is a default array-valued parameter · Issue #103 · SciML/MethodOfLines.jl · GitHub) I changed @named pdesys = PDESystem(eq, bcs, domains, [x, y, t], [u(x, y, t)], [Symbolics.scalarize(NNp) .=>p]). (I think this should go somewhere in documentation)

now using MethodOfLines discretize breaks

prob = discretize(pdesys, discretization);


returns

type Array has no field first
getproperty@Base.jl:38[inlined]
(::MethodOfLines.var"#221#230")(::Vector{Pair{Symbolics.Num, Float32}})@variable_map.jl:19
iterate@generator.jl:47[inlined]
_collect@array.jl:807[inlined]
collect_similar@array.jl:716[inlined]
map@abstractarray.jl:2933[inlined]
MethodOfLines.VariableMap(::Vector{Symbolics.Equation}, ::Vector{Symbolics.Num}, ::Vector{Symbolics.VarDomainPairing}, ::Symbolics.Num, ::Vector{Vector{Pair{Symbolics.Num, Float32}}})@variable_map.jl:18
MethodOfLines.VariableMap(::ModelingToolkit.PDESystem, ::Symbolics.Num)@variable_map.jl:41
symbolic_discretize(::ModelingToolkit.PDESystem, ::MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})@MOL_discretization.jl:35
var"#discretize#555"(::Nothing, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.discretize), ::ModelingToolkit.PDESystem, ::MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization})@MOL_discretization.jl:132
discretize@MOL_discretization.jl:131[inlined]
top-level scope@Local: 1[inlined]


Your ps pairs are already array valued, remove the []

1 Like

Yes I removed it thanks, now the problem definition worked.
But now it breaks on the next step:

prob = discretize(pdesys, discretization); #this works
sol = solve(prob, Tsit5(), saveat = 0.1);


as the source_f(x,y,t,p) is used as source_f(::Float64, ::Float64, ::Float64, ::Float64) the solve tris to pass the p not as an array but as a number:

here the source_f is defined as

@register_symbolic source_f(x,y,t,p)
source_f(x,y,t,p)=U([x,y,t],ComponentArray(p, ax),st)[1][1]


so ComponentArray(p, ax) breaks for p not an array.

MethodError: no method matching ComponentArrays.ComponentArray(::Float64, ::Tuple{ComponentArrays.Axis{(layer_1 = ViewAxis(1:12, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_2 = ViewAxis(13:24, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_3 = ViewAxis(25:28, Axis(weight = ViewAxis(1:3, ShapedAxis((1, 3), NamedTuple())), bias = ViewAxis(4:4, ShapedAxis((1, 1), NamedTuple())))))}})
Closest candidates are:
ComponentArrays.ComponentArray(!Matched::A, ::Axes) where {T, N, A<:AbstractArray{T, N}, Axes<:Tuple{Vararg{ComponentArrays.AbstractAxis}}} at ~/.julia/packages/ComponentArrays/NM9IH/src/componentarray.jl:35
ComponentArrays.ComponentArray(!Matched::UndefInitializer, ::Axes) where Axes<:Tuple at ~/.julia/packages/ComponentArrays/NM9IH/src/componentarray.jl:41
ComponentArrays.ComponentArray(::Any, !Matched::ComponentArrays.FlatAxis...) at ~/.julia/packages/ComponentArrays/NM9IH/src/componentarray.jl:50

...

source_f(::Float64, ::Float64, ::Float64, ::Float64)@Other: 16
macro expansion@code.jl:395[inlined]
macro expansion@build_function.jl:520[inlined]
macro expansion@code.jl:352[inlined]
macro expansion@RuntimeGeneratedFunctions.jl:178[inlined]
macro expansion@none:0[inlined]
generated_callfunc@none:0[inlined]
(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x94c306f3, 0xd8bcd132, 0xa49245e4, 0x1eacb80f, 0xd95ae4e2)})(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)@RuntimeGeneratedFunctions.jl:165
f@abstractodesystem.jl:286[inlined]
Void@utils.jl:468[inlined]
(::FunctionWrappers.CallWrapper{Nothing})(::SciMLBase.Void{ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x19386cc3, 0x9c2fef78, 0x806f5896, 0xd7c805af, 0x443c5c09)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x94c306f3, 0xd8bcd132, 0xa49245e4, 0x1eacb80f, 0xd95ae4e2)}}}, ::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)@FunctionWrappers.jl:65
macro expansion@FunctionWrappers.jl:137[inlined]
do_ccall@FunctionWrappers.jl:125[inlined]
FunctionWrapper@FunctionWrappers.jl:144[inlined]
_call@FunctionWrappersWrappers.jl:12[inlined]
FunctionWrappersWrapper@FunctionWrappersWrappers.jl:10[inlined]
ODEFunction@scimlfunctions.jl:2126[inlined]
initialize!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Vector{Float64}}, SciMLBase.ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.Stats, Nothing}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, OrdinaryDiffEq.PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, SciMLBase.CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Float64, Tuple{}}, Vector{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})@low_order_rk_perform_step.jl:766
var"#__init#628"(::Float64, ::Tuple{}, ::Tuple{}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Nothing, ::Nothing, ::Bool, ::Bool, ::Float64, ::Nothing, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Nothing, ::Nothing, ::Rational{Int64}, ::Nothing, ::Bool, ::Int64, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::OrdinaryDiffEq.DefaultInit, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.__init), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}})@solve.jl:499
#__solve#627@solve.jl:5[inlined]
#solve_call#22@solve.jl:509[inlined]
#solve_up#29@solve.jl:932[inlined]
var"#solve#27"(::Nothing, ::Nothing, ::Nothing, ::Val{true}, ::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:saveat,), Tuple{Float64}}}, ::typeof(CommonSolve.solve), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x19386cc3, 0x9c2fef78, 0x806f5896, 0xd7c805af, 0x443c5c09)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x94c306f3, 0xd8bcd132, 0xa49245e4, 0x1eacb80f, 0xd95ae4e2)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})@solve.jl:842
top-level scope@Local: 1[inlined]


Symbolics’ Shashi says the way is to use type annotations in the type registration, but truth is I wasn’t able to get it to work.

This may require a PR to Symbolics to get working, but if you have the time/energy please keep trying since we need a way to do this.

1 Like

Ok, the next thing I tried is defining a symbolic parameter as array, which shamefully didn’t check already…

@parameters x y t
@variables u(..)
@parameters NNp[1:28]


now the errors is on Lux I think

prob = discretize(pdesys, discretization); #this works
sol = solve(prob, Tsit5(), saveat = 0.1);

MethodError: no method matching tanh_fast(::SymbolicUtils.BasicSymbolic{Real})
Closest candidates are:
tanh_fast(!Matched::AbstractArray, !Matched::Any...) at ~/.julia/packages/NNlib/ydqxJ/src/activations.jl:736
tanh_fast(!Matched::Float32) at ~/.julia/packages/NNlib/ydqxJ/src/activations.jl:766
tanh_fast(!Matched::Float64) at ~/.julia/packages/NNlib/ydqxJ/src/activations.jl:775

...

__apply_activation@utils.jl:242[inlined]
Dense@basic.jl:227[inlined]
apply(::Lux.Dense{true, typeof(NNlib.tanh_fast), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}, ::Vector{Float64}, ::ComponentArrays.ComponentVector{SymbolicUtils.BasicSymbolic{Real}, SubArray{SymbolicUtils.BasicSymbolic{Real}, 1, Vector{SymbolicUtils.BasicSymbolic{Real}}, Tuple{UnitRange{Int64}}, true}, Tuple{ComponentArrays.Axis{(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))}}}, ::NamedTuple{(), Tuple{}})@LuxCore.jl:100
macro expansion@abstractarray.jl:0[inlined]
applychain(::NamedTuple{(:layer_1, :layer_2, :layer_3), Tuple{Lux.Dense{true, typeof(NNlib.tanh_fast), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}, Lux.Dense{true, typeof(NNlib.tanh_fast), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}, Lux.Dense{true, typeof(identity), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}}}, ::Vector{Float64}, ::ComponentArrays.ComponentVector{SymbolicUtils.BasicSymbolic{Real}, Vector{SymbolicUtils.BasicSymbolic{Real}}, Tuple{ComponentArrays.Axis{(layer_1 = ViewAxis(1:12, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_2 = ViewAxis(13:24, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_3 = ViewAxis(25:28, Axis(weight = ViewAxis(1:3, ShapedAxis((1, 3), NamedTuple())), bias = ViewAxis(4:4, ShapedAxis((1, 1), NamedTuple())))))}}}, ::NamedTuple{(:layer_1, :layer_2, :layer_3), Tuple{NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}}})@containers.jl:460
(::Lux.Chain{NamedTuple{(:layer_1, :layer_2, :layer_3), Tuple{Lux.Dense{true, typeof(NNlib.tanh_fast), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}, Lux.Dense{true, typeof(NNlib.tanh_fast), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}, Lux.Dense{true, typeof(identity), typeof(Lux.glorot_uniform), typeof(Lux.zeros32)}}}})(::Vector{Float64}, ::ComponentArrays.ComponentVector{SymbolicUtils.BasicSymbolic{Real}, Vector{SymbolicUtils.BasicSymbolic{Real}}, Tuple{ComponentArrays.Axis{(layer_1 = ViewAxis(1:12, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_2 = ViewAxis(13:24, Axis(weight = ViewAxis(1:9, ShapedAxis((3, 3), NamedTuple())), bias = ViewAxis(10:12, ShapedAxis((3, 1), NamedTuple())))), layer_3 = ViewAxis(25:28, Axis(weight = ViewAxis(1:3, ShapedAxis((1, 3), NamedTuple())), bias = ViewAxis(4:4, ShapedAxis((1, 1), NamedTuple())))))}}}, ::NamedTuple{(:layer_1, :layer_2, :layer_3), Tuple{NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}, NamedTuple{(), Tuple{}}}})@containers.jl:457
f_lux(::Float64, ::Float64, ::Float64, ::Vector{SymbolicUtils.BasicSymbolic{Real}})@Other: 16
macro expansion@code.jl:395[inlined]
macro expansion@build_function.jl:520[inlined]
macro expansion@code.jl:352[inlined]
macro expansion@RuntimeGeneratedFunctions.jl:178[inlined]
macro expansion@none:0[inlined]
generated_callfunc@none:0[inlined]
(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xd54ed3d1, 0x86d67a99, 0x01e49d10, 0x43ad19d4, 0xd2369ec2)})(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)@RuntimeGeneratedFunctions.jl:165
f@abstractodesystem.jl:286[inlined]
Void@utils.jl:468[inlined]
(::FunctionWrappers.CallWrapper{Nothing})(::SciMLBase.Void{ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x2dae767a, 0x72fb05fa, 0x8960861e, 0xa72a1961, 0xee9f6334)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xd54ed3d1, 0x86d67a99, 0x01e49d10, 0x43ad19d4, 0xd2369ec2)}}}, ::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)@FunctionWrappers.jl:65
macro expansion@FunctionWrappers.jl:137[inlined]
do_ccall@FunctionWrappers.jl:125[inlined]
FunctionWrapper@FunctionWrappers.jl:144[inlined]
_call@FunctionWrappersWrappers.jl:12[inlined]
FunctionWrappersWrapper@FunctionWrappersWrappers.jl:10[inlined]
ODEFunction@scimlfunctions.jl:2126[inlined]
initialize!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Vector{Float64}}, SciMLBase.ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.Stats, Nothing}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, OrdinaryDiffEq.PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, SciMLBase.CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Float64, Tuple{}}, Vector{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})@low_order_rk_perform_step.jl:766
var"#__init#628"(::Float64, ::Tuple{}, ::Tuple{}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Nothing, ::Nothing, ::Bool, ::Bool, ::Float64, ::Nothing, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Nothing, ::Nothing, ::Rational{Int64}, ::Nothing, ::Bool, ::Int64, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::OrdinaryDiffEq.DefaultInit, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.__init), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}})@solve.jl:499
#__solve#627@solve.jl:5[inlined]
#solve_call#22@solve.jl:509[inlined]
#solve_up#29@solve.jl:932[inlined]
var"#solve#27"(::Nothing, ::Nothing, ::Nothing, ::Val{true}, ::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:saveat,), Tuple{Float64}}}, ::typeof(CommonSolve.solve), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x2dae767a, 0x72fb05fa, 0x8960861e, 0xa72a1961, 0xee9f6334)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xd54ed3d1, 0x86d67a99, 0x01e49d10, 0x43ad19d4, 0xd2369ec2)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})@solve.jl:842
top-level scope@Local: 1[inlined]


and by using another activation function (instead of Lux.tanh) such as rbf(x) = exp.(-(x .^ 2))

the problem gets

MethodError: Cannot convert an object of type SymbolicUtils.BasicSymbolic{Real} to an object of type Float64
Closest candidates are:
convert(::Type{T}, !Matched::Unitful.Gain) where T<:Real at ~/.julia/packages/Unitful/8xf5j/src/logarithm.jl:62
convert(::Type{T}, !Matched::Unitful.Level) where T<:Real at ~/.julia/packages/Unitful/8xf5j/src/logarithm.jl:22
convert(::Type{T}, !Matched::Unitful.Quantity) where T<:Real at ~/.julia/packages/Unitful/8xf5j/src/conversion.jl:145

...

setindex!(::Vector{Float64}, ::SymbolicUtils.BasicSymbolic{Real}, ::Int64)@array.jl:966
macro expansion@code.jl:395[inlined]
macro expansion@build_function.jl:520[inlined]
macro expansion@code.jl:352[inlined]
macro expansion@RuntimeGeneratedFunctions.jl:178[inlined]
macro expansion@none:0[inlined]
generated_callfunc@none:0[inlined]
(::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xd54ed3d1, 0x86d67a99, 0x01e49d10, 0x43ad19d4, 0xd2369ec2)})(::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)@RuntimeGeneratedFunctions.jl:165
f@abstractodesystem.jl:286[inlined]
Void@utils.jl:468[inlined]
(::FunctionWrappers.CallWrapper{Nothing})(::SciMLBase.Void{ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x2dae767a, 0x72fb05fa, 0x8960861e, 0xa72a1961, 0xee9f6334)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xd54ed3d1, 0x86d67a99, 0x01e49d10, 0x43ad19d4, 0xd2369ec2)}}}, ::Vector{Float64}, ::Vector{Float64}, ::Vector{Float64}, ::Float64)@FunctionWrappers.jl:65
macro expansion@FunctionWrappers.jl:137[inlined]
do_ccall@FunctionWrappers.jl:125[inlined]
FunctionWrapper@FunctionWrappers.jl:144[inlined]
_call@FunctionWrappersWrappers.jl:12[inlined]
FunctionWrappersWrapper@FunctionWrappersWrappers.jl:10[inlined]
ODEFunction@scimlfunctions.jl:2126[inlined]
initialize!(::OrdinaryDiffEq.ODEIntegrator{OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, true, Vector{Float64}, Nothing, Float64, Vector{Float64}, Float64, Float64, Float64, Float64, Vector{Vector{Float64}}, SciMLBase.ODESolution{Float64, 2, Vector{Vector{Float64}}, Nothing, Nothing, Vector{Float64}, Vector{Vector{Vector{Float64}}}, SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.InterpolationData{SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Vector{Vector{Float64}}, Vector{Float64}, Vector{Vector{Vector{Float64}}}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}}, DiffEqBase.Stats, Nothing}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, OrdinaryDiffEq.DEOptions{Float64, Float64, Float64, Float64, OrdinaryDiffEq.PIController{Rational{Int64}}, typeof(DiffEqBase.ODE_DEFAULT_NORM), typeof(LinearAlgebra.opnorm), Nothing, SciMLBase.CallbackSet{Tuple{}, Tuple{}}, typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, DataStructures.BinaryHeap{Float64, DataStructures.FasterForward}, Nothing, Nothing, Int64, Tuple{}, Float64, Tuple{}}, Vector{Float64}, Float64, Nothing, OrdinaryDiffEq.DefaultInit}, ::OrdinaryDiffEq.Tsit5Cache{Vector{Float64}, Vector{Float64}, Vector{Float64}, typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})@low_order_rk_perform_step.jl:766
var"#__init#628"(::Float64, ::Tuple{}, ::Tuple{}, ::Nothing, ::Bool, ::Bool, ::Bool, ::Nothing, ::Nothing, ::Bool, ::Bool, ::Float64, ::Nothing, ::Float64, ::Bool, ::Bool, ::Rational{Int64}, ::Nothing, ::Nothing, ::Rational{Int64}, ::Int64, ::Int64, ::Int64, ::Nothing, ::Nothing, ::Rational{Int64}, ::Nothing, ::Bool, ::Int64, ::Int64, ::typeof(DiffEqBase.ODE_DEFAULT_NORM), ::typeof(LinearAlgebra.opnorm), ::typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN), ::typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK), ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Int64, ::String, ::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), ::Nothing, ::Bool, ::Bool, ::Bool, ::Bool, ::OrdinaryDiffEq.DefaultInit, ::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(SciMLBase.__init), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, FunctionWrappersWrappers.FunctionWrappersWrapper{Tuple{FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Float64}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}, FunctionWrappers.FunctionWrapper{Nothing, Tuple{Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}, Vector{Float64}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}}}, false}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False}, ::Tuple{}, ::Tuple{}, ::Tuple{}, ::Type{Val{true}})@solve.jl:499
#__solve#627@solve.jl:5[inlined]
#solve_call#22@solve.jl:509[inlined]
#solve_up#29@solve.jl:932[inlined]
var"#solve#27"(::Nothing, ::Nothing, ::Nothing, ::Val{true}, ::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:saveat,), Tuple{Float64}}}, ::typeof(CommonSolve.solve), ::SciMLBase.ODEProblem{Vector{Float64}, Tuple{Float64, Float64}, true, Vector{Float64}, SciMLBase.ODEFunction{true, SciMLBase.AutoSpecialize, ModelingToolkit.var"#f#520"{RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0x2dae767a, 0x72fb05fa, 0x8960861e, 0xa72a1961, 0xee9f6334)}, RuntimeGeneratedFunctions.RuntimeGeneratedFunction{(:ˍ₋out, :ˍ₋arg1, :ˍ₋arg2, :t), ModelingToolkit.var"#_RGF_ModTag", ModelingToolkit.var"#_RGF_ModTag", (0xd54ed3d1, 0x86d67a99, 0x01e49d10, 0x43ad19d4, 0xd2369ec2)}}, LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Vector{Symbol}, Symbol, Vector{Symbol}, ModelingToolkit.var"#544#generated_observed#528"{Bool, ModelingToolkit.ODESystem, Dict{Any, Any}}, Nothing, ModelingToolkit.ODESystem}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, MethodOfLines.MOLMetadata{Val{true}(), MethodOfLines.DiscreteSpace{2, 1, MethodOfLines.CenterAlignedGrid}, MethodOfLines.MOLFiniteDifference{MethodOfLines.CenterAlignedGrid, MethodOfLines.ScalarizedDiscretization}, ModelingToolkit.PDESystem, Base.RefValue{Any}, MethodOfLines.ScalarizedDiscretization}}, ::OrdinaryDiffEq.Tsit5{typeof(OrdinaryDiffEq.trivial_limiter!), typeof(OrdinaryDiffEq.trivial_limiter!), Static.False})@solve.jl:842
top-level scope@Local: 1[inlined]


That’s the exact error I got, I think it’s because the function isn’t registering properly, it shouldn’t ever be called with symbolics. Last thing I can think to try is using a DestructuredArgs(p) in the registration but that’s a long shot.

Else support needs to be added to symbolics for that

I don’t know why but now it works
Here is the code

rng =  StableRNG(111)
rbf(x) = exp.(-(x .^ 2))

w=3
U = Lux.Chain(Lux.Dense(3, w, rbf), Lux.Dense(w, w, rbf), Lux.Dense(w, 1))
p, st = Lux.setup(rng, U)
p = p |> ComponentArray

ax = getaxes(p)
@register_symbolic f_source(x,y,t,p)
f_source(x,y,t,p)=U([x,y,t],ComponentArray(p, ax),st)[1][1]
p_flat=collect(p)

@parameters x y t
@variables u(..)
@parameters NNp[1:length(p_flat)]

Dt = Differential(t)
Dxx = Differential(x)^2
Dyy = Differential(y)^2

R=1.2

x_min = 0.0
x_max = 2pi
y_min = -3.5
y_max = 3.5
t_min=0.0
t_max = 2.0

k=1.0
eq = [Dt(u(x, y, t)) ~ k*(Dxx(u(x, y, t)) /R^2.0 + Dyy(u(x, y, t))) + f_source(x,y,t,NNp)]

domains = [x ∈ Interval(x_min, x_max),
y ∈ Interval(y_min, y_max),
t ∈ Interval(t_min, t_max)]

# Periodic BCs
bcs = [u(x, y, t_min) ~ 0.0,
u(0.0,y,t) ~ u(2pi,y,t),
u(x,y_min,t) ~ 0.0,
u(x,y_max,t) ~ 0.0,
]

@named pdesys = PDESystem(eq, bcs, domains, [x, y, t], [u(x, y, t)], Symbolics.scalarize(NNp) .=>p_flat)

Nx = 10
Ny=10

dx = (x_max - x_min) / Nx
dy = (y_max - y_min) / Ny

xx=collect(x_min:dx:x_max)
yy=collect(y_min:dy:y_max)

order = 2

discretization = MOLFiniteDifference([x => dx, y => dy], t, approx_order = order, grid_align = center_align)
prob = discretize(pdesys, discretization);

function predict(θ)
_prob = remake(prob, p = θ)
_sol = solve(_prob, Tsit5(), saveat = 0.1);
end


sol=predict(p_flat)
solu = sol[u(x, y, t)];
heatmap(xx,yy,solu[:,:,10]')


1 Like

You’re a wizard, this is great news! Can you retry with tanh again to see if its getting called?

Is the plot what you expect?

Yes tanh works also.
About the plot I don’t have any idea ¯_(ツ)_/¯ because Source function is random. Now I am trying to train it using some data. This is another beast.
Thanks for the help!

1 Like

Hey @Mixpap, Could you please consider adding this to our docs as an example? We need to showcase this.

2 Likes