Skip to content
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

Update neural adapter tests with heterogeneous inputs #405

Merged
merged 4 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/src/pinn/neural_adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ domains_map = map(xs_domain) do (xs_dom)
end

analytic_sol_func(x,y) = (sin(pi*x)*sin(pi*y))/(2pi^2)
function create_bcs(bcs,x_domain_,phi_bound)
function create_bcs(x_domain_,phi_bound)
x_0, x_e = x_domain_.left, x_domain_.right
if x_0 == 0.0
bcs = [u(0,y) ~ 0.0,
Expand All @@ -171,7 +171,7 @@ for i in 1:count_decomp
phi_bound(x,y) = phi_in(vcat(x,y))
@register phi_bound(x,y)
Base.Broadcast.broadcasted(::typeof(phi_bound), x,y) = phi_bound(x,y)
bcs_ = create_bcs(bcs,domains_[1].domain, phi_bound)
bcs_ = create_bcs(domains_[1].domain, phi_bound)
@named pde_system_ = PDESystem(eq, bcs_, domains_, [x, y], [u(x, y)])
push!(pde_system_map,pde_system_)
strategy = NeuralPDE.GridTraining([0.1/count_decomp, 0.1])
Expand Down
11 changes: 5 additions & 6 deletions test/neural_adapter_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ discretization = NeuralPDE.PhysicsInformedNN(chain1,
quadrature_strategy;
init_params = initθ)

@named pde_system = PDESystem(eq,bcs,domains,[x,y],[u])
@named pde_system = PDESystem(eq,bcs,domains,[x,y],[u(x,y)])
prob = NeuralPDE.discretize(pde_system,discretization)
sym_prob = NeuralPDE.symbolic_discretize(pde_system,discretization)
res = GalacticOptim.solve(prob, BFGS(); maxiters=2000)
Expand Down Expand Up @@ -169,7 +169,7 @@ domains_map = map(xs_domain) do (xs_dom)
end

analytic_sol_func(x,y) = (sin(pi*x)*sin(pi*y))/(2pi^2)
function create_bcs(bcs,x_domain_,phi_bound)
function create_bcs(x_domain_,phi_bound)
x_0, x_e = x_domain_.left, x_domain_.right
if x_0 == 0.0
bcs = [u(0,y) ~ 0.0,
Expand All @@ -196,10 +196,9 @@ for i in 1:count_decomp
# phi_bound(x,y) = if (x isa Matrix) phi_in(vcat(x, fill(y,size(x)))) else phi_in(vcat(fill(x,size(y)),y)) end
phi_bound(x,y) = phi_in(vcat(x,y))
@register phi_bound(x,y)
#TODO fix broadcast
Base.Broadcast.broadcasted(::typeof(phi_bound), x,y) = phi_bound(x,y)
bcs_ = create_bcs(bcs,domains_[1].domain, phi_bound)
@named pde_system_ = PDESystem(eq, bcs_, domains_, [x, y], [u])
bcs_ = create_bcs(domains_[1].domain, phi_bound)
@named pde_system_ = PDESystem(eq, bcs_, domains_, [x, y], [u(x,y)])
push!(pde_system_map,pde_system_)
strategy = NeuralPDE.GridTraining([0.1/count_decomp, 0.1])

Expand Down Expand Up @@ -265,7 +264,7 @@ chain2 = FastChain(FastDense(2,inner_,af),

initθ2 =Float64.(DiffEqFlux.initial_params(chain2))

@named pde_system = PDESystem(eq, bcs, domains, [x, y], [u])
@named pde_system = PDESystem(eq, bcs, domains, [x, y], [u(x,y)])

losses = map(1:count_decomp) do i
loss(cord,θ) = chain2(cord,θ) .- phis[i](cord,reses[i].minimizer)
Expand Down