license:mit size_categories:n<1K format:parquet modality:tabular library:datasets library:pandas library:mlcroissant library:polars region:us
---
license: mit
dataset_info:
  features:
  - name: pos
    sequence:
      sequence:
        sequence: float32
  - name: mat
    sequence: int32
  - name: n_particles
    dtype: int64
  - name: n_steps
    dtype: int64
  - name: friction_angle
    sequence: float64
  splits:
  - name: train
    num_bytes: 20283072
    num_examples: 5
  download_size: 13846270
  dataset_size: 20283072
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
---
## MPM 2D Sand Dataset
This dataset includes trajectories of a sand cube simulated using Taichi's MPM framework. The initial position, velocity, size of the cube are randomized.

## Installation
To download the dataset you don't need an account for huggingface. You only need to install the package by running
```py
pip install datasets
```

## Loading Dataset
```py
from datasets import load_dataset

ds = load_dataset("chhsiao93/mpm_sand_2d_single_cube", split='train')
n = 0 # the first trajectory
trajectory = ds[n]
for key, _ in trajectory.items():
    print(key) # show all the keys in the dictionary
```

You can also load the data as an iterable table. Here is an example:
```py
# loading as an iterable dataset
ds = load_dataset("chhsiao93/mpm_sand_2d_single_cube", split='train', streaming=True)
# iterate through each trajectory and save it as an npz file
for i, traj in enumerate(iter(ds)):
    temp = {}
    for key, value in traj.items():
        temp[key] = np.array(value)
    np.savez(f'trajectory{i}.npz', **temp)
    print(f'saving trajectory{i} as npz')

```
