As an example, let us consider the Helmholtz equation in two space dimensions:
Assuming that the source term is in the form like:
We can easily fabricate an exact solution to this problem: $$ u(x,y)=sin(a_1\pi x)sin(a_2\pi y) $$
python ==3.9
pytorch == 2.0.0+cu117
gpu == NVIDIA GeForce RTX 3050 Ti Laptop GPU(RAM=4GB)
For a typical initial and boundary value problem, loss functions would take the form
For the problem in frequency domain,
According to the problem described before , we need to generate the data for PINN. We assume the area is
First , we seperate the area to the shape of 256*256 as test data.
x_1 = np.linspace(-1,1,256) # 256 points between -1 and 1 [256x1]
x_2 = np.linspace(1,-1,256) # 256 points between 1 and -1 [256x1]
Second , we conduct Latin sampling in the interval as PDE point , 'N_f' is the number of sampled data .
X_f = lb + (ub-lb)*lhs(2,N_f)
Thirdly , we sample boundary point randomly with the number 'N_u'
idx = np.random.choice(all_X_u_train.shape[0], N_u, replace=False)
X_u_train = all_X_u_train[idx[0:N_u], :] #choose indices from set 'idx' (x,t)
u_train = all_u_train[idx[0:N_u],:] #choose corresponding u
- Solve the 2D Helmholtz equation with source correctly ?
- Time used ?
- The influence of bc point number and pde point number ?
N_u = 100
N_f = 10000
Training time: 21.98
Test Error: 0.13519
N_u = 200
N_f = 10000
Training time: 21.98
Test Error: 0.10051
N_u = 300
N_f = 10000
Training time: 22.74
Test Error: 0.10007
N_u = 400
N_f = 10000
Training time: 22.23
Test Error: 0.08802
N_u = 400
N_f = 20000
Training time: 39.04
Test Error: 0.10225
N_u = 400
N_f = 30000
Training time: 50.46
Test Error: 0.07301
N_u = 400
N_f = 40000
Training time: 66.36
Test Error: 0.10518
N_u = 400
N_f = 50000
Training time: 81.16
Test Error: 0.08737