PINN解决频域helmholtz方程,其中一个边界条件是dp/dx-iZnCUnK*ρ=0,Zn=1,ρ=1.259,C=340,K=10,Un=10,边界条件包括虚数i,这该怎么处理?我写的代码这左边界条件损失函数一直维持在42801附近?该怎么解决?
def equation2(net): # 左边界
x, y, cond = sample2(size1)
preal = net(torch.cat([x, y], dim=1))[:, 0].unsqueeze(-1)
pimage = net(torch.cat([x, y], dim=1))[:, 1].unsqueeze(-1)
preal_x = gradients(preal, x, 1)
pimage_x = gradients(pimage, x, 1)
p_x = preal_x + 1j * pimage_x
ke = torch.tensor(10, dtype=torch.float32)
c = torch.tensor(340, dtype=torch.float32)
rou = torch.tensor(1.259, dtype=torch.float32)
z = torch.tensor(1, dtype=torch.float32)
uba = torch.tensor(10, dtype=torch.float32)
left_fun = p_x - 1j * ke * z * rou * c * uba
loss_left = torch.mean(torch.abs(left_fun))
return loss_left