lululxvi / deepxde

A library for scientific machine learning and physics-informed learning
https://deepxde.readthedocs.io
GNU Lesser General Public License v2.1
2.76k stars 760 forks source link

3D Heat Transfer Problem #210

Closed yuyetang closed 3 years ago

yuyetang commented 3 years ago

I am solving a heat transfer problem using the code.

My PDE is a 3D heat transfer problem of an Aluminum part, boundary condition is convective boundary to surrounding water. I cannot obtain the right answer. Could you please help me with the issue? Thanks a lot. ~Yuye

The code is as follows:

from future import absolute_import from future import division from future import print_function

import numpy as np # import numpy library import tensorflow as tf # import tensorflow library import pandas as pd # import pandas library import deepxde as dde # import deepxde library

Problem Variables

LX = 0.25 # m LY = 0.05 # m LZ = 0.05 # m DY = 0.02 # m DZ = 0.02 # m q_time = 200 # s T_ini = 480 # degree C T_water = 60 # degree C conv_c = 10 # convection coefficient Option = 2 # 1: Define Cube Geom

2: Define L-shape Geom

kappa = 170 # thermal conductivity rho = 2780 # Aluminum density capa = 970 # Aluminum heat capacit alpha = kappa/rho/capa

Define Box-shape Part Geometry

if Option == 1: geom = dde.geometry.Cuboid([0,0,0],[LX,LY,LZ])

Define L-shape Part Geometry

if Option == 2: geom_1 = dde.geometry.Cuboid([0,0,0],[LX,LY,LZ]) geom_2 = dde.geometry.Cuboid([0,DY,DZ],[LX,LY,LZ]) geom = dde.geometry.CSGDifference(geom_1,geom_2)

Define PDE a transient heat transfer problem

def pde(x,u): du_x = tf.gradients(u,x,name = 'dydx')[0] du_x, du_y, du_z, du_t = du_x[:,0:1], du_x[:,1:2], du_x[:,2:3],du_x[:,3:] du_xx = tf.gradients(du_x, x, name = 'dydxx')[0][:,0:1] du_yy = tf.gradients(du_y,x)[0][:,1:2] du_zz = tf.gradients(du_z,x)[0][:,2:3] return du_t - alpha * (du_xx + du_yy + du_zz)

def convection(x,y): return conv_c/kappa(T_water np.ones([len(x),1]) - y)

location for convection

def conv_bc(x,on_boundary): return on_boundary

time span for the quenching process

timedomain = dde.geometry.TimeDomain(0, q_time)

combine the time with the part

geomtime = dde.geometry.GeometryXTime(geom, timedomain)

specify type of boundary condition

conv = dde.RobinBC(geomtime, convection, conv_bc) ic = dde.IC(geomtime, lambda x: Tini*np.ones([len(x),1]), lambda , on_initial: on_initial)

data = dde.data.TimePDE( geomtime, pde, [ic, conv], num_domain = 2000, num_boundary=2000, num_initial =1000,

anchors=temp

    # anchors=anc  
)

net = dde.maps.FNN([4] + [20] * 4 + [1], "tanh", "Glorot normal")

model = dde.Model(data, net) model.compile("adam",lr = 0.001, loss_weights = [1,0.01,0.01])

earlystop = dde.callbacks.EarlyStopping( min_delta = 0.001, patience = 1000 )

variable = dde.callbacks.VariableValue(C, period = 500, filename="variables.dat")

losshistory, train_state = model.train(epochs = 10000,callbacks=[earlystop],display_every = 250)#, callbacks=[checkpointer]) dde.saveplot(losshistory, train_state, issave = True, isplot=True)

lululxvi commented 3 years ago

There are some issues in your code. The main issues are:

You may first try 1D/2D problems before 3D. see https://github.com/lululxvi/deepxde/issues/188