yushuang88 commited on
Commit
39f83b7
·
verified ·
1 Parent(s): 5317658

Update README and model configuration

Browse files
Files changed (1) hide show
  1. README.md +131 -0
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ library_name: pytorch
6
+ tags:
7
+ - OneScience
8
+ - fluid-dynamics
9
+ - turbulence
10
+ - fourier-neural-operator
11
+ - physics-informed
12
+ datasets:
13
+ - OneScience-Group/fno
14
+ ---
15
+
16
+ <p align="center">
17
+ <strong><span style="font-size: 30px;">Spectral-Refiner</span></strong>
18
+ </p>
19
+
20
+ # Model Introduction
21
+
22
+ Spectral-Refiner is a physics-residual fine-tuning method for spatiotemporal Fourier neural operators. This project reproduces the two-dimensional forced-turbulence experiment from Table 2 of the paper: an SFNO is first trained on `64 x 64` vorticity trajectories, then its spectral output layer is fine-tuned at `256 x 256` resolution using the \(H^{-1}\) negative Sobolev norm of the Navier–Stokes PDE residual.
23
+
24
+ Paper: [Spectral-Refiner: Accurate Fine-Tuning of Spatiotemporal Fourier Neural Operator for Turbulent Flows](https://arxiv.org/abs/2405.17211)
25
+
26
+ # Model Description
27
+
28
+ The model takes the first 10 time steps of a two-dimensional vorticity field and predicts the next 40. The base SFNO has four spatiotemporal spectral layers, `12 x 12` spatial modes, 5 temporal modes, and width 20. Spectral-Refiner freezes the base network, expands the output spectral layer to `64 x 64 x 6`, and fine-tunes it for 50 steps with an \(H^{-1}\) PDE-residual objective. This project is an independent OneScience reproduction.
29
+
30
+ ## Intended Uses
31
+
32
+ | Use case | Description |
33
+ | :--- | :--- |
34
+ | 2D turbulence prediction | Predict future spatiotemporal evolution from historical vorticity fields. |
35
+ | PDE surrogate | Accelerate periodic fluid problems with a Fourier neural operator. |
36
+ | Physics-residual fine-tuning | Constrain the predicted PDE residual with a negative Sobolev norm. |
37
+
38
+ # Usage
39
+
40
+ ## 1. OneCode
41
+
42
+ [Launch the OneCode AI-for-Science environment](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
43
+
44
+ ## 2. Manual Setup
45
+
46
+ **Hardware requirements**
47
+
48
+ - A GPU or DCU is recommended for full training and inference.
49
+ - A CPU can run imports and the `--smoke` connectivity test.
50
+ - The reported validation used PyTorch 2.5.1 on one DCU.
51
+
52
+ ### Download the model repository from Hugging Face
53
+
54
+ ```bash
55
+ pip install -U huggingface_hub
56
+ hf download OneScience-Group/Spectral-Refiner --local-dir ./Spectral-Refiner
57
+ cd Spectral-Refiner
58
+ ```
59
+
60
+ ### Install the runtime environment
61
+
62
+ **DCU environment**
63
+
64
+ ```bash
65
+ conda create -n onescience311 python=3.11 -y
66
+ conda activate onescience311
67
+ pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
68
+ ```
69
+
70
+ **GPU environment**
71
+
72
+ ```bash
73
+ conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
74
+ conda activate onescience311
75
+ pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
76
+ ```
77
+
78
+ ### Download the training dataset from Hugging Face
79
+
80
+ ```bash
81
+ hf download OneScience-Group/fno \
82
+ --repo-type dataset \
83
+ --local-dir ./data
84
+ ```
85
+
86
+ The required files are:
87
+
88
+ ```text
89
+ data/
90
+ ├── fnodata_extra_64x64_N1280_v1e-3_T50_steps100_alpha2.5_tau7.pt
91
+ └── fnodata_extra_fp64_256x256_N16_v1e-3_T50_steps100_alpha2.5_tau7.pt
92
+ ```
93
+
94
+ Set `data.train_file` and `data.test_file` in `config/config.yaml` to these files. The default experiment uses 1,152 low-resolution trajectories for training and 128 for validation, mapping 10 input steps to 40 output steps. The high-resolution data is used for evaluation and \(H^{-1}\) spectral fine-tuning on the `256 x 256` grid.
95
+
96
+ ### Train
97
+
98
+ ```bash
99
+ python scripts/train.py --config config/config.yaml
100
+ ```
101
+
102
+ `weight/best_model.pt` stores the base SFNO, Spectral-Refiner output layer, configuration, and weight-selection metric.
103
+
104
+ ### Inference
105
+
106
+ ```bash
107
+ python scripts/inference.py
108
+ ```
109
+
110
+ Predictions are saved to `results/predictions.pt`.
111
+
112
+ ### Evaluation
113
+
114
+ ```bash
115
+ python scripts/result.py
116
+ ```
117
+
118
+ Metrics are printed and saved to `results/metrics.json`.
119
+
120
+ # OneScience
121
+
122
+ | Platform | OneScience repository | OneSkills repository |
123
+ | --- | --- | --- |
124
+ | Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
125
+ | GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
126
+
127
+ # Citation and License
128
+
129
+ - Paper: [Spectral-Refiner, arXiv:2405.17211](https://arxiv.org/abs/2405.17211).
130
+ - Public implementation: [scaomath/torch-cfd](https://github.com/scaomath/torch-cfd).
131
+ - This repository uses the Hugging Face-compatible MIT identifier (`mit`). Dataset files and other third-party assets retain their original licenses and terms.