thuerey-group/SFBC_dataset_I
收藏Hugging Face2024-07-19 更新2025-04-12 收录
下载链接:
https://hf-mirror.com/datasets/thuerey-group/SFBC_dataset_I
下载链接
链接失效反馈官方服务:
资源简介:
---
license: mit
---
# Symmetric basis convolutions for learning lagrangian fluid mechanics (Published at ICLR 2024) - Test Case I
This dataset contains the data for the first test case (1D compressible SPH) for the paper Symmetric basis convolutions for learning lagrangian fluid mechanics (Published at ICLR 2024).
You can find the full paper [here](https://arxiv.org/abs/2403.16680).
The source core repository is available [here](https://github.com/tum-pbs/SFBC/) and also contains information on the data generation. You can install our BasisConvolution framework simply by running
`pip install BasisConvolution`
For the other test case datasets look here:
[Test Case I (compressible 1D)](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_i)
[Test Case II (wcsph 2D)](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_ii)
[Test Case III (isph 2D)](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_iii)
[Test Case IV (3D)](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_iv)
## File Layout
The datasets are stored as hdf5 files with a single file per experiment. Within each file there is a set of configuration parameters and each frame of the simulation stored separately as a group. Each frame contains information for all fluid particles and all potentially relevant information. For the 2D test cases there is a pre-defined test/train split on a simulation level, wheras the 1D and 3D cases do not contain such a split.
## Demonstration
This repository contains a simple Jupyter notebook (Visualizer.ipynb) that loads the dataset in its current folder and visualizes it first:

And then runs a simple training on it to learn the SPH summation-based density for different basis functions:

## Minimum Working Example
Below you can find a fully work but simple example of loading our dataset, building a network (based on our SFBC framework) and doing a single network step. This relies on our SFBC/BasisConvolution framework that you can find [here](https://github.com/tum-pbs/SFBC/) or simply install it via pip (`pip install BasisConvolution`)
```py
from BasisConvolution.util.hyperparameters import parseHyperParameters, finalizeHyperParameters
from BasisConvolution.util.network import buildModel, runInference
from BasisConvolution.util.augment import loadAugmentedBatch
from BasisConvolution.util.arguments import parser
import shlex
import torch
from torch.utils.data import DataLoader
from BasisConvolution.util.dataloader import datasetLoader, processFolder
# Example arguments
args = parser.parse_args(shlex.split(f'--fluidFeatures constant:1 --boundaryFeatures constant:1 --groundTruth compute[rho]:constant:1/constant:rho0 --basisFunctions ffourier --basisTerms 4 --windowFunction "None" --maxUnroll 0 --frameDistance 0 --epochs 1'))
# Parse the arguments
hyperParameterDict = parseHyperParameters(args, None)
hyperParameterDict['device'] = 'cuda' # make sure to use a gpu if you can
hyperParameterDict['iterations'] = 2**10 # Works good enough for this toy problem
hyperParameterDict['batchSize'] = 4 # Automatic batched loading is supported
hyperParameterDict['boundary'] = False # Make sure the data loader does not expect boundary data (this yields a warning if not set)
# Build the dataset
datasetPath = 'dataset'
train_ds = datasetLoader(processFolder(hyperParameterDict, datasetPath))
# And its respective loader/iterator combo as a batch sampler (this is our preferred method)
train_loader = DataLoader(train_ds, shuffle=True, batch_size = hyperParameterDict['batchSize']).batch_sampler
train_iter = iter(train_loader)
# Align the hyperparameters with the dataset, e.g., dimensionality
finalizeHyperParameters(hyperParameterDict, train_ds)
# Build a model for the given hyperparameters
model, optimizer, scheduler = buildModel(hyperParameterDict, verbose = False)
# Get a batch of data
try:
bdata = next(train_iter)
except StopIteration:
train_iter = iter(train_loader)
bdata = next(train_iter)
# Load the data, the data loader does augmentation and neighbor searching automatically
configs, attributes, currentStates, priorStates, trajectoryStates = loadAugmentedBatch(bdata, train_ds, hyperParameterDict)
# Run the forward pass
optimizer.zero_grad()
predictions = runInference(currentStates, configs, model, verbose = False)
# Compute the Loss
gts = [traj[0]['fluid']['target'] for traj in trajectoryStates]
losses = [torch.nn.functional.mse_loss(prediction, gt) for prediction, gt in zip(predictions, gts)]
# Run the backward pass
loss = torch.stack(losses).mean()
loss.backward()
optimizer.step()
# Print the loss
print(loss.item())
print('Done')
```
许可证:MIT
# 用于学习拉格朗日流体力学的对称基卷积(发表于国际学习表征会议(ICLR)2024)——测试用例I
本数据集对应论文《用于学习拉格朗日流体力学的对称基卷积》(发表于ICLR 2024)中的首个测试用例:一维可压缩光滑粒子流体动力学(SPH)。
您可通过[此处](https://arxiv.org/abs/2403.16680)获取完整论文。
核心源代码仓库可通过[此处](https://github.com/tum-pbs/SFBC/)获取,其中也包含了数据集生成的相关说明。您仅需运行`pip install BasisConvolution`即可安装我们的基卷积框架。
如需获取其他测试用例的数据集,请参见:
- 测试用例I(可压缩一维):[Wi-Re/SFBC_dataset_i](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_i)
- 测试用例II(二维wcsph):[Wi-Re/SFBC_dataset_ii](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_ii)
- 测试用例III(二维isph):[Wi-Re/SFBC_dataset_iii](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_iii)
- 测试用例IV(三维):[Wi-Re/SFBC_dataset_iv](https://huggingface.co/datasets/Wi-Re/SFBC_dataset_iv)
## 文件结构
数据集采用HDF5文件格式存储,每个实验对应一个独立文件。每个文件内包含一组配置参数,且模拟的每一帧均作为单独的组存储。每一帧包含所有流体粒子的全部相关信息以及所有潜在必要数据。对于二维测试用例,已在模拟层面预先定义了训练集与测试集的划分;而一维和三维测试用例则未包含此类划分。
## 演示说明
本仓库包含一个简易的Jupyter Notebook(Visualizer.ipynb),可加载当前文件夹中的数据集并完成可视化:

随后可针对不同基函数运行简易训练,以学习基于SPH求和的密度计算方法:

## 最小可运行示例
下述代码为一个完整且简易的示例,展示如何加载本数据集、基于我们的SFBC框架构建网络并完成单步网络前向传播。该示例依赖我们的SFBC/基卷积框架,您可通过[此处](https://github.com/tum-pbs/SFBC/)获取,或直接通过pip安装(`pip install BasisConvolution`)。
py
from BasisConvolution.util.hyperparameters import parseHyperParameters, finalizeHyperParameters
from BasisConvolution.util.network import buildModel, runInference
from BasisConvolution.util.augment import loadAugmentedBatch
from BasisConvolution.util.arguments import parser
import shlex
import torch
from torch.utils.data import DataLoader
from BasisConvolution.util.dataloader import datasetLoader, processFolder
# 示例参数
args = parser.parse_args(shlex.split(f'--fluidFeatures constant:1 --boundaryFeatures constant:1 --groundTruth compute[rho]:constant:1/constant:rho0 --basisFunctions ffourier --basisTerms 4 --windowFunction "None" --maxUnroll 0 --frameDistance 0 --epochs 1'))
# 解析参数
hyperParameterDict = parseHyperParameters(args, None)
hyperParameterDict['device'] = 'cuda' # 如有条件请使用GPU
hyperParameterDict['iterations'] = 2**10 # 该参数对该toy示例已足够
hyperParameterDict['batchSize'] = 4 # 支持自动批加载
hyperParameterDict['boundary'] = False # 若未设置该参数,数据加载器将发出警告,提示无需边界数据
# 构建数据集
datasetPath = 'dataset'
train_ds = datasetLoader(processFolder(hyperParameterDict, datasetPath))
# 构建对应的加载器/迭代器组合作为批采样器(这是我们推荐的方式)
train_loader = DataLoader(train_ds, shuffle=True, batch_size = hyperParameterDict['batchSize']).batch_sampler
train_iter = iter(train_loader)
# 对齐超参数与数据集,例如维度信息
finalizeHyperParameters(hyperParameterDict, train_ds)
# 基于给定超参数构建模型
model, optimizer, scheduler = buildModel(hyperParameterDict, verbose = False)
# 获取一批数据
try:
bdata = next(train_iter)
except StopIteration:
train_iter = iter(train_loader)
bdata = next(train_iter)
# 加载数据,数据加载器将自动完成数据增强与邻域搜索
configs, attributes, currentStates, priorStates, trajectoryStates = loadAugmentedBatch(bdata, train_ds, hyperParameterDict)
# 执行前向传播
optimizer.zero_grad()
predictions = runInference(currentStates, configs, model, verbose = False)
# 计算损失
gts = [traj[0]['fluid']['target'] for traj in trajectoryStates]
losses = [torch.nn.functional.mse_loss(prediction, gt) for prediction, gt in zip(predictions, gts)]
# 执行反向传播
loss = torch.stack(losses).mean()
loss.backward()
optimizer.step()
# 打印损失值
print(loss.item())
print('完成')
提供机构:
thuerey-group



