-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Can I use this approach with PDE in 2D? #46
Comments
This should be fine. You'd just use the same apply function from Lux |
Hi @ChrisRackauckas Similar to https://discourse.julialang.org/t/methodoflines-pdesystem-with-internal-systems/104409 |
What did you try? |
I tried this:
Outputs: |
@SebastianM-C is going to try to get an example together. |
Hi @SebastianM-C, |
There are several places where a NN could go, I think that starting with a boundary condition is an option. I'm looking at an example with the heat equation. Are you looking for something else? |
I couldn't think of boundary condition options. And Heat equation example has 2 parameters (t,x) whereas I have 3 (t, x, y) in my case, although that is manageable. I am trying this:
|
I'm working on a simpler version first, I think it would be good to start from a 1D PDE and then move to 2D. For the heat equation you can do it in more than 1D. The main thing is that you can't currently use the block components approach with PDEs, so you would have to reformulate it to the direct calls to In this case your equations would look something like function hab_ude(chain)
# @named nn_in = RealInputArray(nin = nnf)
# @named nn_out = RealOutputArray(nout = nnf)
# println("Shape of nn_out.u:", size(nn_out.u))
# Dt(N(t,x,y)) ~ a - b * N(t,x,y) * P(t,x,y) - e * N(t,x,y) +
# DN * (Dxx(N(t,x,y)) + Dyy(N(t,x,y))),
# Dt(P(t,x,y)) ~ c * N(t,x,y) * P(t,x,y) - d * P(t,x,y)
# - τ * (P(t,x,y)^2 / (μ^2 + P(t,x,y)^2)) + DP * (Dxx(P(t,x,y)) + Dyy(P(t,x,y)))
@variables nn_in(t)[1:nnf]
@variables nn_out(t)[1:nnf]
ps_nn_init, st_nn = Lux.setup(StableRNG(1234), chain)
ca_nn = ComponentArray{Float64}(ps_nn_init)
@parameters p_nn[1:length(ca_nn)] = Vector(ca_nn)
@parameters T_nn::typeof(typeof(ca_nn))=typeof(ca_nn) [tunable = false]
eqs = [Dt(N(t,x,y)) ~ a .- reshape(nn_in[1:L], nx, ny) .- e .* N(t,x,y),
N(t,x,y) ~ reshape(nn_out[1:L], nx, ny),
Dt(P(t,x,y)) ~ reshape(nn_in[L+1:end], nx, ny) .- d .* P(t,x,y) .- τ .* (P(t,x,y)^2 ./(μ^2 .+ P(t,x,y)^2)),
P(t,x,y) ~ reshape(nn_out[L+1:end], nx, ny),
nn_out ~ LuxCore.stateless_apply(chain, nn_in, lazyconvert(T_nn, p_nn))
]
# return ODESystem(eqs, t, name = :hab, systems = [nn_in, nn_out])
return PDESystem(eqs, bcs, domains, [t,x,y], [N(t,x,y), P(t,x,y)],
name = :hab)
end but currently there are some issues in how discretization interacts with vector quantities, so it doesn't work for now. |
Question❓
Can implement the symbolic UDE approach in 2D PDE?
Similar to https://github.com/SciML/MethodOfLines.jl/blob/master/test/pde_systems/MOL_2D_Diffusion.jl
since ModelingToolKit provides a nice way of solving the equations and discretization methods. Would be happy to know other way around to apply missing physics UDE in 2D PDEs.
The text was updated successfully, but these errors were encountered: