Question on PINO Implementation for BIF-to-Temperature Operator #2051
Unanswered
JarifulHassan
asked this question in
Q&A
Replies: 1 comment
-
|
Duplicate of #2054 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Dear DeepXDE Team,
I am using DeepXDE to learn an operator mapping from a BIF (Bi_u : Biot number) to the transient temperature field in a 2D heat conduction problem.
The setup is as follows:
Domain: 2D rectangle ([0,L_x] × [0,L_y]) with time t ∈ [0,t_f]
PDE: du/dt = d²u/dx² + d²u/dy²
Boundary conditions:
Initial condition: u(x,y,0) = 1
I am implementing a physics-informed DeepONet (PINO) using DeepXDE:
TimePDEto generate the training data domain points, boundary points, and initial points and compute the PDE and BC residuals.PDEOperatorwithPowerSeriesfunction space is used to represent the BIF top one , which is the input function to the operator.DeepONetbranch-trunk network maps the BIF to the solution field u(x,y,t).#!/usr/bin/env python3
-- coding: utf-8 --
"""
Minimal reproducible PINO example for 2D heat conduction with DeepXDE
Author: Jariful Hassan
"""
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import deepxde as dde
import numpy as np
-------------------------------
Geometry and Time Domain
-------------------------------
Lx, Ly = 1.0, 1.0
t_f = 1.0
geom = dde.geometry.Rectangle([0, 0], [Lx, Ly])
timedomain = dde.geometry.TimeDomain(0, t_f)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)
-------------------------------
PDE: du/dt = d²u/dx² + d²u/dy²
-------------------------------
def pde(x, u, Bi_f):
u_t = dde.grad.jacobian(u, x, i=0, j=2)
u_xx = dde.grad.hessian(u, x, i=0, j=0)
u_yy = dde.grad.hessian(u, x, i=1, j=1)
return u_t - u_xx - u_yy
-------------------------------
Boundary functions
-------------------------------
def boundary_l(x, on_boundary):
return on_boundary and np.isclose(x[0], 0.0)
def boundary_r(x, on_boundary):
return on_boundary and np.isclose(x[0], Lx)
def boundary_d(x, on_boundary):
return on_boundary and np.isclose(x[1], 0.0)
def boundary_u(x, on_boundary):
return on_boundary and np.isclose(x[1], Ly)
Neumann BC left & bottom
bc_l = dde.icbc.NeumannBC(geomtime, lambda x: 0.0, boundary_l)
bc_d = dde.icbc.NeumannBC(geomtime, lambda x: 0.0, boundary_d)
Robin BC right & top
Bi_r = 1.0 # Example value
Bi_u = 1.0 # Example value
bc_r = dde.icbc.OperatorBC(geomtime, lambda x, u, _: dde.grad.jacobian(u, x, i=0, j=0) + Bi_r * u, boundary_r)
bc_u = dde.icbc.OperatorBC(geomtime, lambda x, u, Bi_f: dde.grad.jacobian(u, x, i=0, j=1) + Bi_f * u, boundary_u)
Initial condition: u(x,y,0) = 1
def initial_func(x):
return np.ones((len(x), 1), dtype=np.float32)
-------------------------------
PDE data for operator learning
-------------------------------
data = dde.data.TimePDE(
geomtime,
pde=pde,
ic_bcs=[bc_l, bc_r, bc_d, bc_u],
num_domain=1000,
num_boundary=500,
num_test=500,
train_distribution="pseudo",
)
-------------------------------
Operator / function space
-------------------------------
degree = 3
func_space = dde.data.PowerSeries(N=degree + 1)
x_vals = np.linspace(0, 1, 60)[:, None] # dummy BIF discretization
pde_op = dde.data.PDEOperator(
data,
func_space,
x_vals,
num_function=500,
function_variables=[0],
)
-------------------------------
DeepONet branch-trunk network
-------------------------------
neurons = 64
net = dde.nn.DeepONet(
[60] + [neurons]*3, # branch
[3] + [neurons]*3, # trunk
"tanh",
"Glorot normal"
)
Output transform to enforce initial condition
net.apply_output_transform(lambda x, u: tf.ones_like(x[1][:,2:3]) + x[1][:,2:3]*u)
-------------------------------
Model
-------------------------------
model = dde.Model(pde_op, net)
model.compile("adam", lr=1e-3, loss_weights=[1.0, 1.0, 1.0, 1.0, 10.0]) # Emphasize bc_up
-------------------------------
Training
-------------------------------
losshistory, train_state = model.train(iterations=1000, batch_size=32)
-------------------------------
Save model and plot loss
-------------------------------
model.save("pino_model", verbose=1)
dde.utils.external.plot_loss_history(losshistory, "pino_loss.png")
Despite following this approach, the predictions are not accurate, and the errors are high. I suspect there may be an issue in my implementation or formulation, particularly in the operator representation or training setup.
Could you please advise:
Thank you very much for your time and guidance.
Best regards,
Jariful Hassan
Project Associate
Department of Mechanical Engineering
Indian Institute of Technology Palakkad
Beta Was this translation helpful? Give feedback.
All reactions