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
Hi Lu,
I have a problem writing down the boundary conditions in the PINN forward problem for a 2-D heat equation. The upper boundary condition is a Neumann-type boundary condition, which is shown as follows:
Where K_z is a function of the gradient of the output and input. But something went wrong when I tried to set up the upper BC.
***This is my code. In this case, the H_net is assumed to be 1. I only try to make it work now.
g = 9.81
rho_0 = 998.2
area = 580000000
rho_w = 1000
c_p = 4181
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Lu,

I have a problem writing down the boundary conditions in the PINN forward problem for a 2-D heat equation. The upper boundary condition is a Neumann-type boundary condition, which is shown as follows:
Where K_z is a function of the gradient of the output and input. But something went wrong when I tried to set up the upper BC.
***This is my code. In this case, the H_net is assumed to be 1. I only try to make it work now.
g = 9.81
rho_0 = 998.2
area = 580000000
rho_w = 1000
c_p = 4181
geom = dde.geometry.Interval(Lmin, Lmax)
timedomain = dde.geometry.TimeDomain(0, T)
geomtime = dde.geometry.GeometryXTime(geom, timedomain)
def calc_dens(wtemp):
dens = (999.842594 + (6.793952 * 1e-2 * wtemp) - (9.095290 * 1e-3 wtemp2) +
(1.001685 * 1e-4 * wtemp3) - (1.120083 * 1e-6 wtemp4) +
(6.536336 * 1e-9 * wtemp5))
return dens
def eddy_diffusivity(rho, x):
drho_x = dde.grad.jacobian(rho, x, i=0, j=0)
buoy = abs(drho_x) * g / rho_0
buoy = tf.where(buoy < 7e-5, buoy, 7e-5)
ak = 0.00706 *(area/1E6)(0.56)
kz = ak * (buoy)(-0.43)
return kz
def pde(x, y):
rho = calc_dens(y)
diff = eddy_diffusivity(rho, x) / 86400
dy_t = dde.grad.jacobian(y, x, i=0, j=1)
dy_x = dde.grad.jacobian(y, x, i=0, j=0)
dy_xx = dde.grad.jacobian(diff * dy_x, x, i=0, j=0)
return dy_t - dy_xx
def func_lb(x, y):
return 1/dde.jacobian(y, x, i=0, j=0)c_prho_w
def func_ub(x):
return np.zeros((len(x),1), dtype=np.float64)
def boundary_u(x, _):
return np.isclose(x[0], Lmin)
ub = dde.icbc.NeumannBC(geom, func_ub, boundary_u)
def boundary_l(x, _):
return np.isclose(x[0], Lmax)
lb = dde.icbc.NeumannBC(geom, func_lb, boundary_l)
data = dde.data.TimePDE(
geomtime,
pde,
[ub, lb, ],
num_domain=2540,
num_boundary=200,
num_initial=160,
num_test=2540,
)
net = dde.nn.FNN([2] + [20] * 3 + [1], "tanh", "Glorot normal")
model = dde.Model(data, net)
model.compile("adam", lr=1e-3)
losshistory, train_state = model.train(iterations=50000)
model.compile("L-BFGS-B")
losshistory, train_state = model.train()
model.save('PINNmodel')
Beta Was this translation helpful? Give feedback.
All reactions