Skip to content

Commit

Permalink
Merge pull request #405 from SciML/fix_neural_adapter_tests
Browse files Browse the repository at this point in the history
Update neural adapter tests with heterogeneous inputs
  • Loading branch information
KirillZubov authored Sep 23, 2021
2 parents 8b2c745 + 7d728dd commit 2b99f6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
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

0 comments on commit 2b99f6c

Please sign in to comment.