Physics-informed neural networks for inverse problems in nano-optics and metamaterials

论文信息

题目:hysics-informed neural networks for inverse problems in nano-optics and metamaterials

作者:Yuyao Chen, Lu Lu, George Em Karniadakis, and Luca Dal Negro

期刊会议:Computational Physics

年份:19

论文地址:

代码:

内容

动机

动机

  • 在强多光散射条件下,复杂多粒子几何中物理驱动的光散射微分模型的逆问题成为一个本质上不定的问题,利用传统方法不能满足预测需求
  • 物理信息神经网络(PINNs)是近年来发展起来的一个通用框架,用于解决偏微分方程的正问题和反问题
  • PINN仅使用一个训练数据集来实现所需的解决方案,从而减轻了替代方案中所需的大量训练数据集所带来的负担

问题定义

逆问题:
f ( x ; ∂ u ^ ∂ x 1 , … , ∂ u ^ ∂ x d ; ∂ 2 u ^ ∂ x 1 ∂ x 1 , … , ∂ 2 u ^ ∂ x 1 ∂ x d ; … ; λ ) = 0 , x ∈ Ω f\left(\mathbf{x} ; \frac{\partial \hat{u}}{\partial x_{1}}, \ldots, \frac{\partial \hat{u}}{\partial x_{d}} ; \frac{\partial^{2} \hat{u}}{\partial x_{1} \partial x_{1}}, \ldots, \frac{\partial^{2} \hat{u}}{\partial x_{1} \partial x_{d}} ; \ldots ; \lambda\right)=0, \quad \mathbf{x} \in \Omega f(x;x1u^,,xdu^;x1x12u^,,x1xd2u^;;λ)=0,xΩ
其中 λ \lambda λ未知,其中loss定义为, L i \mathcal{L}_{i} Li,是初始点的 l o s s loss loss, L b \mathcal{L}_{b} Lb是边界点的 l o s s loss loss

L ( θ , λ ) = w f L f ( θ , λ ; T f ) + w i L i ( θ , λ ; T i ) + w b L b ( θ , λ ; T b ) \mathcal{L}(\boldsymbol{\theta}, \lambda)=w_{f} \mathcal{L}_{f}\left(\boldsymbol{\theta}, \lambda ; \mathcal{T}_{f}\right)+w_{i} \mathcal{L}_{i}\left(\boldsymbol{\theta}, \lambda ; \mathcal{T}_{i}\right)+w_{b} \mathcal{L}_{b}\left(\boldsymbol{\theta}, \lambda ; \mathcal{T}_{b}\right) L(θ,λ)=wfLf(θ,λ;Tf)+wiLi(θ,λ;Ti)+wbLb(θ,λ;Tb)

其中
L f ( θ , λ ; T f ) = 1 ∣ T f ∣ ∑ x ∈ T f ∥ f ( x ; ∂ u ^ ∂ x 1 , … , ∂ u ^ ∂ x d ; ∂ 2 u ^ ∂ x 1 ∂ x 1 , … , ∂ 2 u ^ ∂ x 1 ∂ x d ; … ; λ ) ∥ 2 2 L i ( θ , λ ; T i ) = 1 ∣ T i ∣ ∑ x ∈ T i ∥ u ^ ( x ) − u ( x ) ∥ 2 2 L b ( θ , λ ; T b ) = 1 ∣ T b ∣ ∑ x ∈ T b ∥ B ( u ^ , x ) ∥ 2 2 \begin{aligned} \mathcal{L}_{f}\left(\boldsymbol{\theta}, \lambda ; \mathcal{T}_{f}\right) &=\frac{1}{\left|\mathcal{T}_{f}\right|} \sum_{\mathbf{x} \in \mathcal{T}_{f}}\left\|f\left(\mathbf{x} ; \frac{\partial \hat{u}}{\partial x_{1}}, \ldots, \frac{\partial \hat{u}}{\partial x_{d}} ; \frac{\partial^{2} \hat{u}}{\partial x_{1} \partial x_{1}}, \ldots, \frac{\partial^{2} \hat{u}}{\partial x_{1} \partial x_{d}} ; \ldots ; \lambda\right)\right\|_{2}^{2} \\ \mathcal{L}_{i}\left(\boldsymbol{\theta}, \lambda ; \mathcal{T}_{i}\right) &=\frac{1}{\left|\mathcal{T}_{i}\right|} \sum_{\mathbf{x} \in \mathcal{T}_{i}}\|\hat{u}(\mathbf{x})-u(\mathbf{x})\|_{2}^{2} \\ \mathcal{L}_{b}\left(\boldsymbol{\theta}, \lambda ; \mathcal{T}_{b}\right) &=\frac{1}{\left|\mathcal{T}_{b}\right|} \sum_{\mathbf{x} \in \mathcal{T}_{b}}\|\mathcal{B}(\hat{u}, \mathbf{x})\|_{2}^{2} \end{aligned} Lf(θ,λ;Tf)Li(θ,λ;Ti)Lb(θ,λ;Tb)=Tf1xTff(x;x1u^,,xdu^;x1x12u^,,x1xd2u^;;λ)22=Ti1xTiu^(x)u(x)22=Tb1xTbB(u^,x)22

根据PINN构建如下网络:建立微分方程解的代理模型,在更加 u u u求得 l o s s loss loss,最后最小化 l o s s loss loss求得参数 θ \theta θ λ \lambda λ


具体应用于均质有限尺寸的超材料问题:
∇ 2 E z ( x , y ) + ε r ( x , y ) k 0 2 E z = 0 \nabla^{2} E_{z}(x, y)+\varepsilon_{r}(x, y) k_{0}^{2} E_{z}=0 2Ez(x,y)+εr(x,y)k02Ez=0
其中 E z E_{z} Ez是电厂的z分量, ε r ( x , y ) \varepsilon_{r} (x, y) εr(x,y)是空间相关的相对介电常数, k = 2 π / λ 0 k=2\pi /\lambda_{0} k=2π/λ0

创新

结论

  • 11
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论
好的,以下是用 PINN 求解二阶 Diffusion 方程的 PyTorch 代码: ```python import torch import numpy as np import matplotlib.pyplot as plt # 定义求解区域的左右边界 x_left = 0.0 x_right = 1.0 # 定义时间和空间步长 delta_t = 0.001 delta_x = 0.05 # 定义神经网络的输入维度和隐藏层维度 input_dim = 2 hidden_dim = 10 # 定义神经网络的输出维度 output_dim = 1 # 定义 Diffusion 方程的初始条件和边界条件 def u_init(x): return np.sin(np.pi * x) def u_left(t): return 0.0 def u_right(t): return 0.0 # 定义神经网络模型 class PINN(torch.nn.Module): def __init__(self): super(PINN, self).__init__() self.fc1 = torch.nn.Linear(input_dim, hidden_dim) self.fc2 = torch.nn.Linear(hidden_dim, hidden_dim) self.fc3 = torch.nn.Linear(hidden_dim, output_dim) def forward(self, x, t): # 拼接时间和空间坐标作为神经网络的输入 xt = torch.cat([x, t], dim=1) h1 = torch.tanh(self.fc1(xt)) h2 = torch.tanh(self.fc2(h1)) out = self.fc3(h2) return out # 定义 PINN 的损失函数 def pinn_loss(model, x_left, x_right, delta_t, delta_x): # 定义空间和时间的网格 x = torch.linspace(x_left, x_right, int((x_right - x_left) / delta_x) + 1).unsqueeze(1) t = torch.linspace(0, 1, int(1 / delta_t) + 1).unsqueeze(1) # 计算模型在内部网格点上的预测值 x_internal = x[1:-1] t_internal = t[1:-1] u_internal = model(x_internal, t_internal) # 计算模型在左右边界上的预测值 u_left_boundary = model(x_left, t_internal) u_right_boundary = model(x_right, t_internal) # 计算初始条件和边界条件的损失 init_loss = torch.mean((model(x, torch.zeros_like(x)) - u_init(x)) ** 2) left_boundary_loss = torch.mean((u_left_boundary - u_left(t_internal)) ** 2) right_boundary_loss = torch.mean((u_right_boundary - u_right(t_internal)) ** 2) # 计算 Diffusion 方程的残差 u_x = torch.autograd.grad(u_internal, x_internal, grad_outputs=torch.ones_like(u_internal), create_graph=True)[0] u_xx = torch.autograd.grad(u_x, x_internal, grad_outputs=torch.ones_like(u_x), create_graph=True)[0] f = u_xx - (1 / delta_t) * (u_internal - u_init(x_internal)) # 计算残差的损失 residual_loss = torch.mean(f ** 2) # 计算总的损失 loss = init_loss + left_boundary_loss + right_boundary_loss + residual_loss return loss # 初始化神经网络模型和优化器 model = PINN() optimizer = torch.optim.Adam(model.parameters(), lr=0.001) # 训练神经网络模型 for i in range(10000): optimizer.zero_grad() loss = pinn_loss(model, x_left, x_right, delta_t, delta_x) loss.backward() optimizer.step() if i % 1000 == 0: print("Iteration {}, Loss = {}".format(i, loss.item())) # 使用训练好的神经网络模型进行预测 x_test = torch.linspace(x_left, x_right, 101).unsqueeze(1) t_test = torch.linspace(0, 1, 1001).unsqueeze(1) u_test = model(x_test, t_test).detach().numpy() # 绘制预测结果 X, T = np.meshgrid(x_test, t_test) plt.pcolormesh(X, T, u_test, cmap='coolwarm') plt.colorbar() plt.xlabel("x") plt.ylabel("t") plt.title("PINN Solution to Diffusion Equation") plt.show() ``` 这段代码中,首先定义了求解区域的左右边界、时间和空间步长等参数,然后定义了 Diffusion 方程的初始条件和边界条件,以及神经网络模型和损失函数。在训练神经网络模型时,使用了 Adam 优化器,最后使用训练好的模型进行预测,并绘制了预测结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

pinn山里娃

原创不易请多多支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值