You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xs,ys = [domain.domain.lower:dx/10:domain.domain.upper for domain in domains]
analytic_sol_func(x,y) = (sin(pi*x)sin(piy))/(2pi^2)
u_predict = reshape([first(phi([x,y],res.minimizer)) for x in xs for y in ys],(length(xs),length(ys)))
u_real = reshape([analytic_sol_func(x,y) for x in xs for y in ys], (length(xs),length(ys)))
diff_u = abs.(u_predict .- u_real)
Dear all,
I cannot understand my problems. Could you please help me?
Julia v 1.7.3
testpde.zip
Warning: FastChain is being deprecated in favor of Lux.jl. Lux.jl uses functions with explicit parameters f(u,p) like FastChain, but is fully featured and documented machine learning library. See the Lux.jl documentation for more details.
└ @ DiffEqFlux C:\Users\XXX.julia\packages\DiffEqFlux\Em1Aj\src\fast_layers.jl:9
ERROR: MethodError: no method matching NeuralPDE.Phi(::FastChain{Tuple{FastDense{typeof(sigmoid_fast), DiffEqFlux.var"#initial_params#107"{Vector{Float32}}, Nothing}, FastDense{typeof(sigmoid_fast), DiffEqFlux.var"#initial_params#107"{Vector{Float32}}, Nothing}, FastDense{typeof(identity), DiffEqFlux.var"#initial_params#107"{Vector{Float32}}, Nothing}}})
Closest candidates are:
NeuralPDE.Phi(::Chain) at C:\Users\XXX.julia\packages\NeuralPDE\Qjcw1\src\pinn_types.jl:352
NeuralPDE.Phi(::Lux.AbstractExplicitLayer) at C:\Users\XXX.julia\packages\NeuralPDE\Qjcw1\src\pinn_types.jl:348
Stacktrace:
[1] PhysicsInformedNN(chain::FastChain{Tuple{FastDense{typeof(sigmoid_fast), DiffEqFlux.var"#initial_params#107"{Vector{Float32}}, Nothing}, FastDense{typeof(sigmoid_fast), DiffEqFlux.var"#initial_params#107"{Vector{Float32}}, Nothing}, FastDense{typeof(identity), DiffEqFlux.var"#initial_params#107"{Vector{Float32}}, Nothing}}}, strategy::QuadratureTraining{IntegralsCubature.CubatureJLh, Float64}; init_params::Nothing, phi::Nothing, derivative::Nothing, param_estim::Bool, additional_loss::Nothing, adaptive_loss::Nothing, logger::Nothing, log_options::LogOptions, iteration::Nothing, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ NeuralPDE C:\Users\XXX.julia\packages\NeuralPDE\Qjcw1\src\pinn_types.jl:115
[2] PhysicsInformedNN(chain::Function, strategy::QuadratureTraining{IntegralsCubature.CubatureJLh, Float64})
@ NeuralPDE C:\Users\XXX.julia\packages\NeuralPDE\Qjcw1\src\pinn_types.jl:109
[3] top-level scope
@ c:\Users\XXX\Repository\testpde.jl:25
CODE
using NeuralPDE, Flux, ModelingToolkit, GalacticOptim, DiffEqFlux
using Quadrature, Cubature
@parameters x y
@variables u(..)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
2D PDE
eq = Dxx(u(x,y)) + Dyy(u(x,y)) ~ -sin(pi*x)sin(piy)
Boundary conditions
bcs = [u(0,y) ~ 0.f0, u(1,y) ~ -sin(pi1)sin(piy),
u(x,0) ~ 0.f0, u(x,1) ~ -sin(pix)sin(pi1)]
Space and time domains
domains = [x ∈ IntervalDomain(0.0,1.0),
y ∈ IntervalDomain(0.0,1.0)]
Discretization
dx = 0.1
Neural network
dim = 2 # number of dimensions
chain = FastChain(FastDense(dim,16,Flux.σ),FastDense(16,16,Flux.σ),FastDense(16,1))
discretization = PhysicsInformedNN(chain, QuadratureTraining())
pde_system = PDESystem(eq,bcs,domains,[x,y],[u])
prob = discretize(pde_system,discretization)
cb = function (p,l)
println("Current loss is: $l")
return false
end
res = GalacticOptim.solve(prob, ADAM(0.1); cb = cb, maxiters=4000)
prob = remake(prob,u0=res.minimizer)
res = GalacticOptim.solve(prob, ADAM(0.01); cb = cb, maxiters=2000)
phi = discretization.phi
xs,ys = [domain.domain.lower:dx/10:domain.domain.upper for domain in domains]
analytic_sol_func(x,y) = (sin(pi*x)sin(piy))/(2pi^2)
u_predict = reshape([first(phi([x,y],res.minimizer)) for x in xs for y in ys],(length(xs),length(ys)))
u_real = reshape([analytic_sol_func(x,y) for x in xs for y in ys], (length(xs),length(ys)))
diff_u = abs.(u_predict .- u_real)
using Plots
p1 = plot(xs, ys, u_real, linetype=:contourf,title = "analytic");
p2 = plot(xs, ys, u_predict, linetype=:contourf,title = "predict");
p3 = plot(xs, ys, diff_u,linetype=:contourf,title = "error");
plot(p1,p2,p3)
The text was updated successfully, but these errors were encountered: