This repository is part of the submitted work Gaming self-consistent field theory: Generative block polymer phase discovery, which describes a method to train Deep Convolutional Generative Adversarial Networks (DCGANs) to generate initial guess fields for Self-Consistent Field Theory (SCFT) simulations for phase discovery.
- Data Source: 3D density fields of five established block polymer phases from SCFT trajectories.
- Data Augmentation: Tiling, random translation, and rotation.
- Purpose of DCGANs: Fields generated from DCGANs seeded new SCFT simulations, enabling the discovery of novel phases.
Fig. 1: Overview of the polymer field theory generation process.
For referencing or leveraging parts of this work, please refer to:
Pengyu Chen, Kevin D. Dorfman, Gaming self-consistent field theory: Generative block polymer phase discovery, 120 (45) e2308698120 (2023)
- GANs: Generative Adversarial Networks.
- DCGANs: Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks.
- DCGANs Tutorials: PyTorch implementation and TensorFlow implementation.
- SCFT: Broadly Accessible Self-Consistent Field Theory for Block Polymer Materials Discovery.
- Software Tools:
- SCFT Simulations: PSCF (C++/CUDA).
- Visualization of Density Fields: Polymer Visual.
pip install -r requirements.txt
Acquire both raw and processed density fields here.
The data.pt
file, located in the data
folder, contains 18,273 3D density field datasets. These datasets can be treated as grayscale 3D images.
The data is stored as a PyTorch tensor with dimensions (18,273 x 1 x 32 x 32 x 32) and can be directly loaded for training.
- Data Generation:
The raw density data are extracted from SCFT trajectories that converge to five known network phases: single gyroid, single diamond, single primitive, double gyroid, and double primitive. The initial guesses and example SCFT simulation are provided in Data Repository for U of M (DRUM).
-
Data Augmentation:
-
Description:
Each.rf
file, representing a density field obtained from the SCFT calculation, undergoes a series of data augmentation techniques: tiling, random translation, and rotation. Fields with unphysical density values, specifically wherephi_A > 1
orphi_A < 0
, are excluded. -
Command Line Execution:
Navigate to the preprocessing directory and execute the data processing script:cd ./preprocessing python data_processor.py --in_filename /path/to/input.rf --out_filename /path/to/output.pt --grid 32 32 32
--in_filename
: Path to the input density field file (.rf
).
--out_filename
: Path to the output 3D image. Must end with.pt
or.pth
--grid
: (Optional) A tuple specifying the output dimensions. The default is (32, 32, 32). -
Python Method Execution:
Instead of command-line execution, you can utilize it directly within a Python script:processor = DataProcessor() processor.process_files(<input_filename>, <output_filename>)
-
-
Training the DCGANs with Preprocessed Data:
Run the training script using the following commands:
cd ./train python GAN_train.py --dataroot /path/to/data.pt --out_dir_images /path/to/output/image/dir --out_dir_model /path/to/output/model/dir
--dataroot
: path to processed training data (.pt
)
--out_dir_images
: directory to save generated images as tensors (.pt
) of size (64 x 1 x 32 x 32 x 32) during the training process.
--out_dir_model
: directory to save model parameters (.pt
) during the training process.
Optional arguments, such as batch size, can be found in the scripts.
-
Visualizing the Training Progression:
The output images from a set of fixed noise can be visualized to track the training progression usingisosurface_visualizer
. An example is provided in./train/visualize_progress.py
.visualizer = IsosurfaceVisualizer(isosurface_value=0.5) visualizer.visualize_directory(<input_directory>, <output_directory>>)
<input_directory>
: directory to the generated images, which are saved as tensors (.pt
) of size (64 x 1 x 32 x 32 x 32).
<output_directory>
: directory to save isosurface plots (.png
).
Fig. 2: Progression of generated density fields during the training process.
Generate density fields by feeding random latent vectors to the generator.
cd ./postprocessing
python generate_guess.py --weight_path ../model/Gweights_45.pt --out_dir /path/to/output/dir --num_images 5000
--weight_path
: path to the model parameters for the pretrained generator.
--out_dir
: directory to save generated guesses.
--num_images
: number of density initial guesses to generate.
Generated density fields are used as initial guesses for SCFT simulations at a fixed state point. All the PSCF inputs and outputs are provided in DRUM.
- Convergence: 545 out of 5000 SCFT calculations converged
- Candidate network phases: 349
- De novo generation of all known network phases
- Discovery of novel network phases
Fig. 3: Free energy histogram of generated candidate network phases and representive network phases.
For contributing or submitting pull requests, please contact the author:
- Pengyu Chen [email protected]
The authors would like to thank Qingyuan Jiang, Benjamin Magruder, Dr. Guo Kang Cheong, Prof. Chris Bartel, and Prof. Frank Bates for their valuable inputs.
This work was supported primarily by the National Science Foundation through the University of Minnesota MRSEC under Award Number DMR-2011401. Computational resources were provided in part by the Minnesota Supercomputing Institute.