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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: pytorch
|
| 6 |
+
tags:
|
| 7 |
+
- OneScience
|
| 8 |
+
- fluid-dynamics
|
| 9 |
+
- neural-operator
|
| 10 |
+
- multiwavelet
|
| 11 |
+
datasets:
|
| 12 |
+
- OneScience-Group/fno
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
<p align="center">
|
| 16 |
+
<strong><span style="font-size: 30px;">MWT</span></strong>
|
| 17 |
+
</p>
|
| 18 |
+
|
| 19 |
+
# Model Introduction
|
| 20 |
+
|
| 21 |
+
MWT (Multiwavelet-based Operator Learning), proposed by Gaurav Gupta, Xiongye Xiao, and Paul Bogdan, is a multiwavelet operator-learning framework. It builds fixed decomposition and reconstruction filters from orthogonal polynomials and learns differential-equation solution operators in a multiscale space, enabling data-efficient physical-field prediction and generalization across resolutions.
|
| 22 |
+
|
| 23 |
+
This repository is an independent OneScience reproduction of the two-dimensional Navier–Stokes vorticity experiment described in the paper. On a periodic unit torus, the model combines the first 10 vorticity frames with spatial and temporal coordinates and predicts the remaining \(T-10\) frames in one shot. The experiment uses a regular `64 x 64` grid downsampled from `256 x 256` data.
|
| 24 |
+
|
| 25 |
+
Paper: [Multiwavelet-based Operator Learning for Differential Equations](https://arxiv.org/abs/2109.13459)
|
| 26 |
+
|
| 27 |
+
# Model Description
|
| 28 |
+
|
| 29 |
+
MWT is a multiscale neural architecture for learning differential operators. Its pipeline is input lifting, multiwavelet decomposition, multiscale operator mapping, multiwavelet reconstruction, and vorticity projection. A linear layer first lifts the 13-dimensional input to \(c k^2=36\) features, where \(c=4\) and the Legendre multiwavelet order is \(k=3\). Fixed Legendre filter matrices from the paper and their two-dimensional Kronecker products recursively decompose both spatial dimensions.
|
| 30 |
+
|
| 31 |
+
At each scale, learnable \(A\), \(B\), and \(C\) operators transform detail and smooth coefficients. This implementation uses three-dimensional Fourier spectral and pointwise convolutions over \((x,y,t)\). The coarsest scale is processed by the \(\bar{T}\) map and reconstructed to the original resolution with fixed filters.
|
| 32 |
+
|
| 33 |
+
For the two-dimensional Navier–Stokes experiment, four MWT blocks are stacked with BatchNorm3d and ReLU between blocks. A `36 -> 128 -> 1` output head maps reconstructed features to vorticity at each grid point and prediction time.
|
| 34 |
+
|
| 35 |
+
## Intended Uses
|
| 36 |
+
|
| 37 |
+
| Use case | Description |
|
| 38 |
+
| --- | --- |
|
| 39 |
+
| Navier–Stokes vorticity prediction | Predict the remaining vorticity trajectory from the first 10 two-dimensional frames. |
|
| 40 |
+
| Regular-grid operator learning | Learn mappings between input and output functions on periodic regular grids. |
|
| 41 |
+
| Multiscale physical-field modeling | Combine fixed multiwavelet decomposition with learnable within-scale operators. |
|
| 42 |
+
| Fast spatiotemporal inference | Approximate a numerical solver for batched prediction within the training distribution and viscosity regime. |
|
| 43 |
+
|
| 44 |
+
# Usage
|
| 45 |
+
|
| 46 |
+
## 1. OneCode
|
| 47 |
+
|
| 48 |
+
[Launch the OneCode AI-for-Science environment](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
|
| 49 |
+
|
| 50 |
+
## 2. Manual Setup
|
| 51 |
+
|
| 52 |
+
**Hardware requirements**
|
| 53 |
+
|
| 54 |
+
- A GPU or DCU is recommended.
|
| 55 |
+
- A CPU can run imports and small connectivity checks, but full training and inference will be slow.
|
| 56 |
+
- DCU users should install DTK 25.04.2 or later, or the OneScience-recommended version for the cluster.
|
| 57 |
+
|
| 58 |
+
### Download the model repository from Hugging Face
|
| 59 |
+
|
| 60 |
+
```bash
|
| 61 |
+
pip install -U huggingface_hub
|
| 62 |
+
hf download OneScience-Group/MWT --local-dir ./MWT
|
| 63 |
+
cd MWT
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
### Install the runtime environment
|
| 67 |
+
|
| 68 |
+
**DCU environment**
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
# Activate DTK first.
|
| 72 |
+
conda create -n onescience311 python=3.11 -y
|
| 73 |
+
conda activate onescience311
|
| 74 |
+
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
**GPU environment**
|
| 78 |
+
|
| 79 |
+
```bash
|
| 80 |
+
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
|
| 81 |
+
conda activate onescience311
|
| 82 |
+
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### Download the training dataset from Hugging Face
|
| 86 |
+
|
| 87 |
+
```bash
|
| 88 |
+
hf download OneScience-Group/fno --repo-type dataset --local-dir ./data
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
Set `paths.data_root` in `config/config.yaml` to the downloaded directory. The experiments use:
|
| 92 |
+
|
| 93 |
+
- `ns_V1e-3_N5000_T50.mat`: \(\nu=10^{-3}\), 5,000 samples, and 50 frames.
|
| 94 |
+
- `ns_V1e-4_N10000_T30.mat`: \(\nu=10^{-4}\), 10,000 samples; the experiment uses the first 30 frames.
|
| 95 |
+
- `NavierStokes_V1e-5_N1200_T20.mat`: \(\nu=10^{-5}\), 1,200 samples, and 20 frames.
|
| 96 |
+
|
| 97 |
+
The main MAT variables are:
|
| 98 |
+
|
| 99 |
+
- `u`: the Navier–Stokes vorticity trajectory, converted to `[num_samples, 64, 64, T]` after loading.
|
| 100 |
+
- `t`: temporal coordinates, converted to `[T]`.
|
| 101 |
+
- `a`: the initial condition used by the numerical solver. The model uses the first 10 frames of `u` directly and does not load `a` as a separate input.
|
| 102 |
+
|
| 103 |
+
### Train
|
| 104 |
+
|
| 105 |
+
`config/config.yaml` defines four MWT Navier–Stokes experiments. The default is `ns_1e-3_t50`; choose another with `--experiment`.
|
| 106 |
+
|
| 107 |
+
```bash
|
| 108 |
+
python scripts/train.py \
|
| 109 |
+
--config config/config.yaml \
|
| 110 |
+
--experiment ns_1e-3_t50 \
|
| 111 |
+
--seed 0
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
Supported experiments:
|
| 115 |
+
|
| 116 |
+
- `ns_1e-3_t50`: \(\nu=10^{-3}\), \(T=50\), nominally 1,000 training samples, 500 epochs.
|
| 117 |
+
- `ns_1e-4_t30_n1000`: \(\nu=10^{-4}\), \(T=30\), nominally 1,000 training samples, 500 epochs.
|
| 118 |
+
- `ns_1e-4_t30_n10000`: \(\nu=10^{-4}\), \(T=30\), nominally 10,000 training samples, 200 epochs.
|
| 119 |
+
- `ns_1e-5_t20`: \(\nu=10^{-5}\), \(T=20\), nominally 1,000 training samples, 500 epochs.
|
| 120 |
+
|
| 121 |
+
### Pretrained weights
|
| 122 |
+
|
| 123 |
+
`weight/best_model.pt` contains an MWT checkpoint trained on Navier–Stokes data and can be used directly for inference and numerical evaluation.
|
| 124 |
+
|
| 125 |
+
### Inference
|
| 126 |
+
|
| 127 |
+
Run one-shot inference on the fixed 200-sample test set recorded by the checkpoint and report the mean relative L2 error in physical space:
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
python scripts/inference.py \
|
| 131 |
+
--config config/config.yaml \
|
| 132 |
+
--checkpoint weight/best_model.pt
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
For explicit device, batch-size, and output options:
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
python scripts/inference.py \
|
| 139 |
+
--config config/config.yaml \
|
| 140 |
+
--checkpoint weight/best_model.pt \
|
| 141 |
+
--device auto \
|
| 142 |
+
--batch-size 1 \
|
| 143 |
+
--output-dir results
|
| 144 |
+
```
|
| 145 |
+
|
| 146 |
+
Outputs:
|
| 147 |
+
|
| 148 |
+
```text
|
| 149 |
+
results/
|
| 150 |
+
├── inference_metrics.json
|
| 151 |
+
├── predictions.npy
|
| 152 |
+
├── targets.npy
|
| 153 |
+
└── sample_indices.npy
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
### Evaluation and visualization
|
| 157 |
+
|
| 158 |
+
```bash
|
| 159 |
+
python scripts/result.py --config config/config.yaml --sample 0
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
Generated files:
|
| 163 |
+
|
| 164 |
+
```text
|
| 165 |
+
results/
|
| 166 |
+
├── field_comparison.png
|
| 167 |
+
├── relative_l2_over_time.png
|
| 168 |
+
└── result_summary.json
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
- `field_comparison.png` compares ground-truth vorticity, MWT prediction, and absolute error at the beginning, middle, and end of the forecast interval.
|
| 172 |
+
- `relative_l2_over_time.png` plots spatial relative L2 over the full one-shot forecast interval.
|
| 173 |
+
- `result_summary.json` records experiment settings, sample counts, array shapes, error metrics, paper-reference values, comparability notes, and visualization paths.
|
| 174 |
+
|
| 175 |
+
# OneScience
|
| 176 |
+
|
| 177 |
+
| Platform | OneScience repository | OneSkills repository |
|
| 178 |
+
| --- | --- | --- |
|
| 179 |
+
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
|
| 180 |
+
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
|
| 181 |
+
|
| 182 |
+
# Citation and License
|
| 183 |
+
|
| 184 |
+
- Paper: [Multiwavelet-based Operator Learning for Differential Equations](https://proceedings.neurips.cc/paper/2021/file/c9e5c2b59d98488fe1070e744041ea0e-Paper.pdf), NeurIPS 2021; [arXiv:2109.13459](https://arxiv.org/abs/2109.13459).
|
| 185 |
+
- Official implementation: [gaurav71531/mwt-operator](https://github.com/gaurav71531/mwt-operator).
|
| 186 |
+
- This repository uses the Hugging Face-compatible MIT identifier (`mit`). The paper, upstream implementation, datasets, and all other third-party materials remain subject to their original licenses and terms.
|