LayerForge is a tool made for generating comprehensive datasets of multilayer material designs and their corresponding optical properties. The project leverages the refractiveindex.info database for material properties and tmm-fast for accurate spectrum computations.
.
├── config.yaml # Configuration file for materials and simulation parameters
├── requirements.txt # Python dependencies
├── src/
│ ├── __init__.py
│ ├── material_generator.py # Functions for generating random material sequences
│ └── spectrum_calculator.py # Functions for computing optical properties
├── tests/ # Unit tests for the project
├── data/ # Directory for storing generated datasets
└── notebooks/ # Jupyter notebooks for analysis and visualization
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txtLayerForge utilizes tmm-fast to compute optical properties of multilayer materials. The workflow consists of:
- Generating random material sequences with specified thicknesses
- Computing their optical properties (absorption/reflection spectra)
- Creating paired datasets for supervised learning
Edit config.yaml to customize:
- Available materials
- Layer thickness ranges
- Number of layers
- Wavelength ranges
- Dataset parameters
from src.material_generator import MaterialGenerator
generator = MaterialGenerator()
sequence = generator.generate_sequence()
print(generator.sequence_to_string(sequence)) # Output format: "Au_10+Ag_20+SiO2_15"Generate datasets using the main.py script:
python main.pyThis will:
- Generate random material sequences
- Calculate their optical properties
- Save the results in the data/ directory
The project includes comprehensive unit tests to ensure reliability. Run the tests using pytest:
pytest tests/The tests cover:
- Material sequence generation
- Optical property calculations
- Configuration handling
- Error cases and edge conditions
The generated dataset consists of pairs:
- X: Sequence of materials and thicknesses (e.g., "Au_10+Ag_20+SiO2_15")
- Y: Dictionary of wavelength-value pairs representing optical properties
MIT License