/VideoMetamaterials

Implementation of 'Inverse-design of nonlinear mechanical metamaterials via video denoising diffusion models'

Primary LanguagePythonMIT LicenseMIT

Inverse-design of nonlinear mechanical metamaterials
via video denoising diffusion models

arXiv DOI

Jan-Hendrik Bastek1 and Dennis M. Kochmann1
1ETH Zurich

$~$

Introduction & Setup

We introduce a framework to create mechanical metamaterials with a given nonlinear stress-strain response via video denoising diffusion as described in Inverse design of nonlinear mechanical metamaterials via video denoising diffusion models.

This code is based on the video denoising diffusion implementation by Phil Wang proposed in Imagen Video.

To conduct similar studies as those presented in the publication, start by cloning this repository via

git clone https://github.com/jhbastek/VideoMetamaterials.git

Next, download the data and model checkpoints provided in the ETHZ Research Collection. Unzip the training data lagrangian.zip in the data folder and the pre-trained model pretrained.zip in the runs folder, as shown below. Note that eulerian.zip must only be provided when training the model in the Eulerian frame, which was only used in preliminary studies.

.
├── data
│   ├── target_responses.csv
│   └── lagrangian
│   │   └── ...
│   └── eulerian (optional)
│       └── ...
└── runs
    └── pretrained
        └── ...

We use the Accelerate library to speed up training when a multi GPU environment is available. Please first configure your setup via accelerate config (note that accelerate can also be used in single GPU/CPU setups).

To generate new metamaterial samples conditioned on the four stress-strain responses shown in the publication simply run

accelerate launch main.py

The generated samples will then be stored in runs/pretrained/eval_target_w_<guidance_weight>/ and should perform similar to the presented samples. We arrange all generated samples in a single grid, in which the row corresponds to row of data/target_responses.csv.

To condition the denoising process on your own stress-strain responses, simply adjust data/target_responses.csv accordingly. Sample generation takes around 1 minute on a single Nvidia Quadro RTX 6000. In case of interest, we store the normalization constants to rescale the pixel values to their physical equivalent in data/<reference_frame>/training/min_max_values.csv.

To experiment with different setups simply change the user input in main.py. Here you can adjust the number of generated samples per conditioning, change the guidance scaling w or also train denoising models from scratch based on the hyperparameters defined in model.yaml (including the option to log to Weights & Biases).

For further information, please first refer to the publication, the Supplementary Information or reach out to Jan-Hendrik Bastek.

Dependencies

The framework was developed and tested on Python 3.11 using CUDA 12.0 and requires the following Python packages.

Package Version (>=)
pytorch 2.0.1
einops 0.6.1
einops-exts 0.6.1
rotary_embedding_torch 0.2.3
accelerate 0.19.0
imageio 2.28.1
tqdm 4.65.0
wandb (optional) 0.15.2

Citation

If this code is useful for your research, please cite our publication.

@article{Bastek2023,
author = {Bastek, Jan-Hendrik and Kochmann, Dennis M.},
doi = {10.1038/s42256-023-00762-x},
journal = {Nature Machine Intelligence},
title = {{Inverse design of nonlinear mechanical metamaterials via video denoising diffusion models}},
url = {https://doi.org/10.1038/s42256-023-00762-x},
volume = {12},
year = {2023}
}