Install
openclaw skills install @onescience-ai/cfd-model-runcfd fno models run, also quckliy download code
openclaw skills install @onescience-ai/cfd-model-runUse this skill whenever the user wants to train or adapt a Fourier Neural Operator (FNO) model on their own dataset, perform neural PDE operator training, or build a surrogate model for structured grid data.
This skill downloads the FNO codebase from ModelScope, adapts it to the user's dataset, and launches training and inference.
The first execution automatically downloads the FNO code from ModelScope and caches it locally.
Check whether the FNO codebase already exists locally. If not, use modelscope.snapshot_download with model_id="OneScience/FNO_B" to download it and print the local path.
Required dependencies: Python >= 3.10, PyTorch, scipy, ruamel.yaml, tqdm, matplotlib, numpy.
Install any missing packages with pip. CUDA is optional — the code auto-detects cuda:0 and falls back to CPU.
Ask the user about their data — shape, dimensionality (1D / 2D / 3D grid), number of physical channels, and time steps. The model expects batches with three keys:
| Key | Shape | Description |
|---|---|---|
pos | (B, N, space_dim) | Grid point coordinates |
x | (B, N, t_in × out_dim) | Input time window (flattened grid) |
y | (B, N, t_out × out_dim) | Prediction target (flattened grid) |
where N is the total number of grid points (H for 1D, H*W for 2D, H*W*D for 3D).
Modify NavierStokesDataset._init_data() in navier_stokes.py to load the user's data and populate self.x, self.y, self.pos, and self.spatial_shape with the appropriate tensors and shape tuple.
Then update conf/fno.yaml under datapipe.source to point to the user's data directory and file, and update datapipe.data fields — ntrain, ntest, t_in, t_out, out_dim — to match the actual dataset.
fno_layers.py only ships SpectralConv2d. For other dimensionalities, the user needs to implement the corresponding spectral convolution class and update model.py.
1D grid: Implement SpectralConv1d in fno_layers.py using torch.fft.rfft / irfft with a single weight tensor of shape (in_channels, out_channels, modes1). In model.py, replace SpectralConv2d with SpectralConv1d, replace nn.Conv2d pointwise layers with nn.Conv1d, and reshape the feature tensor to (B, C, L) in the forward pass instead of (B, C, H, W).
3D grid: Implement SpectralConv3d in fno_layers.py using torch.fft.rfftn / irfftn along the last three dimensions with four weight tensors covering the eight frequency corners. In model.py, replace spectral and pointwise layers with their 3D equivalents and reshape to (B, C, D, H, W) in the forward pass.
In both cases, also update conf/fno.yaml: set model.space_dim to 1 or 3, adjust modes1/modes2/modes3 to values that do not exceed half the grid size in each dimension.
Run train.py from the downloaded model directory. The loop evaluates val_rel_l2 and val_mse every eval_interval epochs, saves the best checkpoint as best_model.pt under training.output_dir, and early-stops after patience epochs without improvement.
Key parameters in conf/fno.yaml:
| Parameter | Default | Description |
|---|---|---|
training.num_epochs | 500 | Max training epochs |
training.lr | 0.001 | AdamW learning rate |
training.teacher_forcing | true | Use ground truth as next-step input |
model.hidden_channels | 64 | Hidden feature channels |
model.num_layers | 4 | Fourier layer depth |
Run inference.py from the model directory. Set the FNO_CHECKPOINT environment variable to override the checkpoint path from the config. Outputs are saved to vis_results/ under training.output_dir: a .pt file with pos, input, prediction, target tensors, and a .png comparison plot of Target / Prediction / Abs Error.
FNO
Fourier Neural Operator
Neural PDE
PDE surrogate
Structured grid prediction
Time series flow
Train FNO
Custom dataset FNO
Neural operator training
1D FNO
3D FNO
AI surrogate model
Scientific AI
AI4S
MODELSCOPE_API_TOKEN or use a mirror endpoint.SpectralConv1d / SpectralConv3d do not exist in the downloaded code and must be implemented by the user in fno_layers.py.