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

Periodic boundary conditions isn't working. #733

Open
knuds opened this issue Sep 9, 2023 · 1 comment
Open

Periodic boundary conditions isn't working. #733

knuds opened this issue Sep 9, 2023 · 1 comment

Comments

@knuds
Copy link

knuds commented Sep 9, 2023

Periodic boundary conditions is not working.

When I run the following code

using NeuralPDE, Lux, ModelingToolkit, Optimization, OptimizationOptimisers, Random, Plots
import ModelingToolkit: Interval

@parameters x,y,t
@variables u(..)

L=1
tmax=1
domains = [x  Interval(-L, +L),
          y  Interval(-L, +L),
	  t  Interval(0, tmax)]
	  

Dx = Differential(x)
Dy = Differential(y)
Dxx = Differential(x)^2
Dyy = Differential(y)^2
Dtt = Differential(t)^2

eq=Dtt(u(x,y,t))~Dxx(u(x,y,t))+Dyy(u(x,y,t))

bcs=[u(x,y,0)~cos(x)*cosh(y),u(-L,y,t)~u(L,y,t),u(x,-L,t)~u(x,L,t), Dx(u(-L,y,t))~Dx(u(L,y,t)),Dy(u(x,-L,t))~Dy(u(x,L,t))]

in=length(domains)
n=9
chain = Lux.Chain(Dense(in, n, Lux.asinh), Dense(n, n, Lux.asinh),Dense(n, n, Lux.asinh), Dense(n, 1))

discretization = PhysicsInformedNN(chain, QuadratureTraining())

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

prob = discretize(pdesystem, discretization)
sym_prob = symbolic_discretize(pdesystem, discretization)
callback = function (p, l)
    println("loss: ", l)
    println(" pde: ", map(l_ -> l_(p), sym_prob.loss_functions.pde_loss_functions))
    println(" bcs: ", map(l_ -> l_(p), sym_prob.loss_functions.bc_loss_functions))
    println()
    return false
end

inter=200
res = Optimization.solve(prob, Adam(0.1); callback = callback, maxiters = inter)

I get output like:

loss: 13.413393568816456
 pde: [0.5311505128711426]
 bcs: [12.882243055945313, 0.0, 0.0, 0.0, 0.0]

With the periodic conditions all zero.

@knuds
Copy link
Author

knuds commented Sep 9, 2023

Symmetric conditions like:
,u(-x,y,t)~u(x,y,t),u(x,-y,t)~u(x,y,t)
Does not work either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant