Skip to main content

Library and exemples to use the fourier neural operator

Project description

Generic badge PyPI version

Downloads Downloads Downloads

Fourier Neural Operator package

This package come from : https://github.com/zongyi-li/fourier_neural_operator

There is some minor modification to create a "proper" python package

You can install it using

python setup.py install

or :

pip install .

Then to create a fourier model with the pytorch framework :

import fourier_neural_operator.fourier_2d as fourier_2d 
model = fourier_2d.FNO2d(modes1=modes1, modes2=modes2,  width=width, channel_input=3, output_channel=3)

You can also simply import fourier layer :

import fourier_neural_operator.fourier_2d as fourier_2d 
spectral_layer = fourier_2d.SpectralConv2d(width, width, modes1, modes2)

The package is still under construction and modification will come for fourier_3d and 1d.

Fourier Neural Operator

This repository contains the code for the paper:

In this work, we formulate a new neural operator by parameterizing the integral kernel directly in Fourier space, allowing for an expressive and efficient architecture. We perform experiments on Burgers' equation, Darcy flow, and the Navier-Stokes equation (including the turbulent regime). Our Fourier neural operator shows state-of-the-art performance compared to existing neural network methodologies and it is up to three orders of magnitude faster compared to traditional PDE solvers.

It follows from the previous works:

Requirements

  • We have updated the files to support PyTorch 1.8.0. Pytorch 1.8.0 starts to support complex numbers and it has a new implementation of FFT. As a result the code is about 30% faster.
  • Previous version for PyTorch 1.6.0 is avaiable at FNO-torch.1.6.

Files

The code is in the form of simple scripts. Each script shall be stand-alone and directly runnable.

  • fourier_1d.py is the Fourier Neural Operator for 1D problem such as the (time-independent) Burgers equation discussed in Section 5.1 in the paper.
  • fourier_2d.py is the Fourier Neural Operator for 2D problem such as the Darcy Flow discussed in Section 5.2 in the paper.
  • fourier_2d_time.py is the Fourier Neural Operator for 2D problem such as the Navier-Stokes equation discussed in Section 5.3 in the paper, which uses a recurrent structure to propagates in time.
  • fourier_3d.py is the Fourier Neural Operator for 3D problem such as the Navier-Stokes equation discussed in Section 5.3 in the paper, which takes the 2D spatial + 1D temporal equation directly as a 3D problem
  • The lowrank methods are similar. These scripts are the Lowrank neural operators for the corresponding settings.
  • data_generation are the conventional solvers we used to generate the datasets for the Burgers equation, Darcy flow, and Navier-Stokes equation.

Datasets

We provide the Burgers equation, Darcy flow, and Navier-Stokes equation datasets we used in the paper. The data generation configuration can be found in the paper.

The datasets are given in the form of matlab file. They can be loaded with the scripts provided in utilities.py. Each data file is loaded as a tensor. The first index is the samples; the rest of indices are the discretization. For example,

  • Burgers_R10.mat contains the dataset for the Burgers equation. It is of the shape [1000, 8192], meaning it has 1000 training samples on a grid of 8192.
  • NavierStokes_V1e-3_N5000_T50.mat contains the dataset for the 2D Navier-Stokes equation. It is of the shape [5000, 64, 64, 50], meaning it has 5000 training samples on a grid of (64, 64) with 50 time steps.

We also provide the data generation scripts at data_generation.

Models

Here are the pre-trained models. It can be evaluated using eval.py or super_resolution.py.

Citations

@misc{li2020fourier,
      title={Fourier Neural Operator for Parametric Partial Differential Equations}, 
      author={Zongyi Li and Nikola Kovachki and Kamyar Azizzadenesheli and Burigede Liu and Kaushik Bhattacharya and Andrew Stuart and Anima Anandkumar},
      year={2020},
      eprint={2010.08895},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

@misc{li2020neural,
      title={Neural Operator: Graph Kernel Network for Partial Differential Equations}, 
      author={Zongyi Li and Nikola Kovachki and Kamyar Azizzadenesheli and Burigede Liu and Kaushik Bhattacharya and Andrew Stuart and Anima Anandkumar},
      year={2020},
      eprint={2003.03485},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fourier_neural_operator-0.5.tar.gz (13.7 kB view details)

Uploaded Source

File details

Details for the file fourier_neural_operator-0.5.tar.gz.

File metadata

  • Download URL: fourier_neural_operator-0.5.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for fourier_neural_operator-0.5.tar.gz
Algorithm Hash digest
SHA256 fb234e49a57130121a966097b85de6d56e2029edc7ebbf83bc91d9115e4d0d0a
MD5 2706ec740fc59f5f4f6997f8046fada9
BLAKE2b-256 e1072cb680943402358f9de539851bd7a9115590a064824ef83672fb41b6b72a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page