Computational fluid dynamics is one of the most important techniques in the field of fluid mechanics in the 21st century. The flow analysis, prediction and control can be realized by solving the governing equations of fluid mechanics by numerical method. Traditional finite element method (FEM) and finite difference method (FDM) are inefficient because of the complex simulation process (physical modeling, meshing, numerical discretization, iterative solution, etc.) and high computing costs. Therefore, it is necessary to improve the efficiency of fluid simulation with AI.
Machine learning methods provide a new paradigm for scientific computing by providing a fast solver similar to traditional methods. Classical neural networks learn mappings between finite dimensional spaces and can only learn solutions related to a specific discretization. Different from traditional neural networks, Fourier Neural Operator (FNO) is a new deep learning architecture that can learn mappings between infinite-dimensional function spaces. It directly learns mappings from arbitrary function parameters to solutions to solve a class of partial differential equations. Therefore, it has a stronger generalization capability. More information can be found in the paper, Fourier Neural Operator for Parametric Partial Differential Equations.
This tutorial describes how to solve the 1-d Burgers' equation using Fourier neural operator.
The 1-d Burgers’ equation is a non-linear PDE with various applications including modeling the one dimensional flow of a viscous fluid. It takes the form
$$ \partial_t u(x, t)+\partial_x (u^2(x, t)/2)=\nu \partial_{xx} u(x, t), \quad x \in(0,1), t \in(0, 1] $$
$$ u(x, 0)=u_0(x), \quad x \in(0,1) $$
where $u$ is the velocity field, $u_0$ is the initial condition and $\nu$ is the viscosity coefficient.
We aim to learn the operator mapping the initial condition to the solution at time one:
$$ u_0 \mapsto u(\cdot, 1) $$
The Fourier Neural Operator consists of the Lifting Layer, Fourier Layers, and the Decoding Layer.
Fourier layers: Start from input V. On top: apply the Fourier transform $\mathcal{F}$; a linear transform R on the lower Fourier modes and filters out the higher modes; then apply the inverse Fourier transform $\mathcal{F}^{-1}$. On the bottom: apply a local linear transform W. Finally, the Fourier Layer output vector is obtained through the activation function.
You can download dataset from data_driven/burgers/. Save these dataset at ./dataset
.
train.py
from command linepython train.py --config_file_path ./configs/fno1d.yaml --mode GRAPH --device_target Ascend --device_id 0
where:
--config_file_path
indicates the path of the parameter file. Default './configs/fno1d.yaml';
--device_target
indicates the computing platform. You can choose 'Ascend' or 'GPU'. Default 'Ascend'.
--device_id
indicates the index of NPU or GPU. Default 0.
--mode
is the running mode. 'GRAPH' indicates static graph mode. 'PYNATIVE' indicates dynamic graph mode.
You can run the training and validation code line by line using the Chinese or English version of the Jupyter Notebook Chinese Version and English Version.
Parameter | Ascend | GPU |
---|---|---|
Hardware | Ascend 910A, 32G;CPU: 2.6GHz, 192 cores | NVIDIA V100 32G |
MindSpore version | 2.1 | 2.1 |
train loss | 5e-3 | 4e-3 |
valid loss | 9e-4 | 8e-4 |
speed | 4.2s/epoch | 3.9s/epoch |
gitee id:liulei277
email: liulei2770919@163.com
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。