File size: 6,398 Bytes
893fb8e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | ---
license: mit
language:
- en
library_name: pytorch
tags:
- OneScience
- fluid-dynamics
- neural-operator
- radon-transform
- darcy-flow
datasets:
- OneScience-Group/cfd_benchmark
---
<p align="center">
<strong><span style="font-size: 30px;">RNO</span></strong>
</p>
# Model Introduction
RNO (Radon Neural Operator), proposed by researchers from Zhejiang University of Technology, learns PDE solution mappings with both global and local features in the sinogram domain through the Radon transform.
This repository is an independent OneScience reproduction of the Darcy-flow experiment. RNO learns the parameterized Darcy solution operator and predicts steady pressure from a porous-medium permeability or diffusion-coefficient field.
Paper: [Solving Partial Differential Equations via Radon Neural Operator](https://proceedings.neurips.cc/paper_files/paper/2025/file/e66233a208ef32f56df6312263239fa0-Paper-Conference.pdf)
# Model Description
For Darcy flow, RNO maps a two-dimensional permeability or diffusion-coefficient field \(a(x,y)\) to its scalar pressure solution \(u(x,y)\).
The architecture consists of feature lifting, Physics-Attention, a Radon block, and output projection. The input field and spatial coordinates are lifted to high-dimensional features; Physics-Attention extracts nonlocal information; and the Radon block projects features into the sinogram domain. Angle reweighting and sinogram convolution learn the contribution of different projection directions before filtered back-projection restores spatial features for the final Darcy solution.
## Intended Uses
| Use case | Description |
| --- | --- |
| Darcy-flow prediction | Predict steady porous-medium pressure from a two-dimensional permeability or diffusion field. |
| Parameterized PDE solution | Learn an operator from coefficients, initial conditions, or boundary conditions to PDE solutions. |
| Scientific surrogate | Replace part of a costly numerical solve with fast batched prediction. |
| Cross-resolution prediction | Evaluate the learned operator at different spatial resolutions when supported by the training setup. |
# Usage
## 1. OneCode
[Launch the OneCode AI-for-Science environment](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
## 2. Manual Setup
**Hardware requirements**
- A GPU or DCU is recommended.
- A CPU can run imports and small connectivity checks, but full training and inference will be slow.
- DCU users should install DTK 25.04.2 or later, or the OneScience-recommended version for the cluster.
### Download the model repository from Hugging Face
```bash
pip install -U huggingface_hub
hf download OneScience-Group/RNO --local-dir ./RNO
cd RNO
```
### Install the runtime environment
**DCU environment**
```bash
# Activate DTK first.
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[cfd-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
**GPU environment**
```bash
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[cfd-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
### Download the training dataset from Hugging Face
```bash
hf download OneScience-Group/cfd_benchmark \
--repo-type dataset \
--local-dir ./data
```
The Darcy files are stored under `data/data/darcy/` after this download:
```text
data/data/darcy/
├── piececonst_r421_N1024_smooth1.mat
└── piececonst_r421_N1024_smooth2.mat
```
Set `data.root` in `config/config.yaml` to the Darcy directory. Each MAT file contains 1,024 regular-grid samples at the original `421 x 421` resolution:
- `coeff`: the Darcy permeability or diffusion-coefficient field.
- `sol`: the corresponding steady pressure solution.
This experiment uses `piececonst_r421_N1024_smooth1.mat` for training and `piececonst_r421_N1024_smooth2.mat` for testing, with downsampling and normalization defined by the experiment configuration.
### Train
```bash
python scripts/train.py --config config/config.yaml
```
Per-epoch metrics are logged and printed at the configured interval. The checkpoint with the lowest training relative L2 is saved to `weight/best_model.pth`.
### Pretrained weights
The repository includes a Darcy-trained RNO checkpoint at `weight/best_model.pth` for inference or continued training.
### Inference and evaluation
```bash
python scripts/inference.py \
--config config/config.yaml \
--checkpoint weight/best_model.pth \
--device auto
```
The script evaluates the fixed test set, prints the mean per-sample relative L2, computes relative L2 and gradient-relative L2 against paper references, and writes:
```text
results/evaluation_metrics.json
results/predictions.npz
```
`predictions.npz` contains predicted and target pressure fields, normalized permeability fields, and per-sample relative L2 values.
### Visualization
```bash
python scripts/result.py --results results
```
Outputs:
```text
results/training_curve.png
results/darcy_prediction.png
results/visualization_summary.json
```
- `training_curve.png` shows total training loss, relative L2, and gradient-relative L2.
- `darcy_prediction.png` compares permeability, target pressure, predicted pressure, and absolute error.
- `visualization_summary.json` records visualization paths, test relative L2, and the paper comparison.
# OneScience
| Platform | OneScience repository | OneSkills repository |
| --- | --- | --- |
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
# Citation and License
- Paper: [Solving Partial Differential Equations via Radon Neural Operator](https://proceedings.neurips.cc/paper_files/paper/2025/file/e66233a208ef32f56df6312263239fa0-Paper-Conference.pdf).
- Official implementation: [wenbin-lu/Radon-Neural-Operator](https://github.com/wenbin-lu/Radon-Neural-Operator), released under the [MIT License](https://github.com/wenbin-lu/Radon-Neural-Operator/blob/main/LICENSE).
- This repository uses the Hugging Face-compatible MIT identifier (`mit`). The dataset and other third-party resources remain subject to their original licenses and terms.
|