SciML / NeuralPDE.jl

Physics-Informed Neural Networks (PINN) Solvers of (Partial) Differential Equations for Scientific Machine Learning (SciML) accelerated simulation
https://docs.sciml.ai/NeuralPDE/stable/
Other
988 stars 199 forks source link

Add support for symbolic vectors #425

Open killah-t-cell opened 2 years ago

killah-t-cell commented 2 years ago

I tried defining an array parameter and apply it to NeuralPDE.discretize:

@parameters x[1:2]

This fails with LoadError: MethodError: no method matching nameof(::Term{Real, Base.ImmutableDict{DataType, Any}}) due to this line here:

https://github.com/SciML/NeuralPDE.jl/blob/ab09aecff69c1f2915e4673b4b1a4b0994eeacdc/src/pinns_pde_solve.jl#L608

The fix is theoretically easy, just change nameof(ModelingToolkit.value(argument)) to ModelingToolkit.getname(argument). The only problem with that, is that if I run

# if I run this
@parameters t[1:2]
ModelingToolkit.getname(t[1])
# or this
@parameters y[1:2]
y = Symbolics.scalarize(y)
ModelingToolkit.getname.(y)

The output is always just :y which basically defeats the purpose of setting parameters with arrays. I wonder if this is a ModelingToolkit problem @ChrisRackauckas

For now I worked around this by doing t = Symbolics.variables(:t, 1:2) # 2-element Vector{Num}: t₁ t₂, but I don't know if ModelingToolkit will get mad at me for using Symbolics.variables for parameters. So far the code compiles and converges though.

ChrisRackauckas commented 2 years ago

Symbolic vectors are not handled here yet. Symbolics.variables(:t, 1:2) is not a symbolic vector which is why it works.