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
995 stars 200 forks source link

Example of integro-differential equation does not work #403

Closed dapias closed 3 years ago

dapias commented 3 years ago

Hello. I am testing the code here and got an error with the first couple of lines

using ModelingToolkit, DomainSets
@parameters t
@variables i(..)
Ii = Integral(t in DomainSets.ClosedInterval(0, t))

This rises:

TypeError: non-boolean (Num) used in boolean context

killah-t-cell commented 3 years ago

For what is worth I just tested this and it worked for me. Try ] up to make sure you get the latest version of the packages.

Screenshot 2021-09-22 at 10 07 58
dapias commented 3 years ago

Thank you. I apologise. It works with the latest version of the packages in Julia1.6.

killah-t-cell commented 3 years ago

No problem!

ChrisRackauckas commented 3 years ago

Soon v1.6 will be the new LTS for Julia which will make this simpler.

dapias commented 3 years ago

Could you please check the next part of the example? I have got problems with the command pde_system. After this:

using NeuralPDE, Flux, ModelingToolkit, GalacticOptim, Optim, DiffEqFlux, DomainSets
import ModelingToolkit: Interval, infimum, supremum

@parameters t
@variables i(..)
Di = Differential(t)
Ii = Integral(t in DomainSets.ClosedInterval(0, t))
eq = Di(i(t)) + 2*i(t) + 5*Ii(i(t)) ~ 1
bcs = [i(0.) ~ 0.0]
domains = [t ∈ Interval(0.0,2.0)]
chain = Chain(Dense(1,15,Flux.σ),Dense(15,1))
initθ = Float64.(DiffEqFlux.initial_params(chain))

strategy_ = GridTraining(0.05)
discretization = PhysicsInformedNN(chain,
                                   strategy_;
                                   init_params = nothing,
                                   phi = nothing,
                                   derivative = nothing)
pde_system = PDESystem(eq,bcs,domains,[t],[i(t)])

I got:

ERROR: UndefKeywordError: keyword argument name not assigned Stacktrace: [1] PDESystem(eqs::Equation, bcs::Vector{Equation}, domain::Vector{Symbolics.VarDomainPairing}, ivs::Vector{Num}, dvs::Vector{Num}, ps::SciMLBase.NullParameters) (repeats 2 times) @ ModelingToolkit ~/.julia/packages/ModelingToolkit/iEq0Q/src/systems/pde/pdesystem.jl:70 [2] top-level scope @ REPL[31]:1

killah-t-cell commented 3 years ago

That one is our bad

Do @named pde_system = PDESystem(eq,bcs,domains,[t],[i(t)]) and it should work

killah-t-cell commented 3 years ago

https://github.com/SciML/NeuralPDE.jl/pull/404

dapias commented 3 years ago

@killah-t-cell thank you! I was able to run the whole example :)