A package for simulating quantum dot behavior and analyzing energy levels, absorption spectra, and wavefunctions
Project description
By: Arjun Skanda Ananda - a middle schooler with a lot of free time...
Quantum Dot Simulation Package (V2.1.1)
Overview
The Quantum Dot Simulation Package is a Python library designed to simulate quantum dots, including their energy levels, wavefunctions, and absorption spectra, and provide 3D visualizations. This package allows users to model quantum dots in different materials and sizes and gain insights into their quantum mechanical properties, which are essential for applications in quantum computing, solar energy, and nanotechnology.
Features
- Energy Levels Calculation: Simulate energy levels in quantum dots based on material properties.
- Wavefunctions Calculation: Calculate wavefunctions for quantum dots to analyze the behavior of electrons.
- Absorption Spectra: Compute absorption spectra to understand light absorption properties.
- Visualization: Generate 2D and 3D plots of quantum dots, energy levels, absorption spectra, an dinteraction wiht plasma.
- Sketching: Create 3D visual representations of quantum dots.
- Utility Functions: Convert energy levels and other outputs into data structures like Pandas DataFrames.
- Plasma Interaction Simulation: Simulate the interaction of quantum dots with plasmas, using PlasmaPy library.
- Multi-Material Heterostructures: Model quantum dots made from multiple materials, each with its own energy level calculation.
Contributing
I welcome contributions! If you would like to improve the package, please do this:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Open a pull request and add a description of your changes.
License
Quantum Dot Simulation Package © 2024 by Arjun Skanda Ananda is licensed under MIT License
Installation
To install the Quantum Dot Simulation package, clone the repository and install it using pip:
git clone https://github.com/ArjunSkanda/quantum_dot_sim.git
cd quantum_dot_sim
pip install -e .
Alternatively, you can use the setup.py file for installation
python setup.py install
Usage
Here is an example of how to use the quantum_dot_sim package:
from quantum_dot_sim import calculate_energy_levels, plot_custom_graph
radius = 5e-9
material_props = {"effective_mass": 9.1e-31}
energy_levels = calculate_energy_levels(material_props, radius)
plot_custom_graph(range(len(energy_levels)), energy_levels, xlabel="Quantum Number", ylabel="Energy (eV)", title="Energy Levels of Quantum Dot")
You can use the functions described below to calculate quantum dot properties and visualize results.
Modules
CONFIG
The quantum_dot_sim package uses a flexible configuration system that can be customized through environment variables. All settings have sensible defaults but can be overridden to suit your specific needs.
Basic Configuration
All configuration options can be customized using environment variables:
Environment Variable: DATASET_PATH Default Value: ./data/unified_combined_physics_dataset.npy Description: Path to the dataset file
Environment Variable: MODEL_PATH Default Value: ./models/quantum_unifiedphysics_model.h5 Description: Path to the trained model
Environment Variable: LOG_LEVEL Default Value: INFO Description: Logging level (DEBUG, INFO, WARNING, ERROR)
Environment Variable: LOG_FILE Default Value: ./output/simulation.log Description: Logging level (DEBUG, INFO, WARNING, ERROR)
Environment Variable: INTERACTIVE_MODE Default Value: True Description: Enable/disable interactive visualization
Environment Variable: DEFAULT_PLOT_TYPE Default Value: line Description: Default visualization style
Environment Variable: DEFAULT_RADIUS Default Value: 1e-9 Description: Default quantum dot radius in meters
Environment Variable: MAX_WAVEFUNCTION_LEVELS Default Value: 5 Description: Maximum number of wavefunction levels
Environment Variable: ENERGY_LEVELS_FILE Default Value: ./data/energy_levels.npy Description: Path to energy levels data
Environment Variable: WAVEFUNCTIONS_FILE Default Value: ./data/wavefunctions.npy Description: Path to wavefunctions data
Environment Variable: OUTPUT_DIR Default Value: ./output Description: Directory for output files
Environment Variable: DEBUG_MODE Default Value: False Description: Enable/disable debug mode
Usage Examples
- Basic Usage with Defaults
from quantum_dot_sim import CONFIG
# Print current configuration
CONFIG.print_config()
- Customizing via Environment Variables
# Linux/Mac
export LOG_LEVEL=DEBUG
export DEFAULT_RADIUS=2e-9
export INTERACTIVE_MODE=false
# Windows
set LOG_LEVEL=DEBUG
set DEFAULT_RADIUS=2e-9
set INTERACTIVE_MODE=false
- Custom Output Directory
import os
os.environ['OUTPUT_DIR'] = '/path/to/custom/output'
from quantum_dot_sim import CONFIG
Important Notes
- All paths are automatically created if they don't exist
- The
OUTPUT_DIRwill be created automatically during initialization - Log levels follow the standard Python logging hierarchy
- The quantum dot radius is specified in meters (default is 1 nm)
- Setting DEBUG_MODE=True enables additional logging and error information
Advanced Configuration
For more complex configurations, you can create a configuration file or subclass the Config class:
from quantum_dot_sim import Config
class CustomConfig(Config):
def __init__(self):
super().__init__()
self.custom_parameter = os.getenv('CUSTOM_PARAM', 'default_value')
Performance Considerations
- Setting
INTERACTIVE_MODE=Falsecan improve performance for batch processing - Adjust
MAX_WAVEFUNCTION_LEVELSbased on your computational resources - Use
DEBUG_MODE=Trueonly when necessary as it may impact performance
data_loader
The data_loader module provides functionality for loading and preprocessing quantum dot simulation datasets and models. It includes robust error handling and logging capabilities to ensure reliable data operations.
Key Features
- Dataset loading with automatic normalization
- Model loading with error handling
- Standardized data preprocessing
- Comprehensive logging
- Custom exception handling
Functions
normalize_data(X)
Normalizes feature data using scikit-learn's StandardScaler for consistent processing across different datasets.
from quantum_dot_sim.data_loader import normalize_data
normalized_features = normalize_data(feature_data)
load_dataset(dataset_path)
Loads and unpacks a dataset from a NumPy file, returning normalized features and corresponding labels.
from quantum_dot_sim.data_loader import load_dataset
features, labels = load_dataset("path/to/dataset.npy")
Dataset format must contain exactly two arrays
- Feature data (X)
- Label data (Y)
load_model(model_path)
Loads a pre-trained TensorFlow Keras model from a specified file path.
from quantum_dot_sim.data_loader import load_model
model = load_model("path/to/model.h5")
Error Handling
The module implements custom exceptions for common error cases:
DatasetNotFoundError: Raised when the specified dataset file doesn't existModelNotFoundError: Raised when the specified model file doesn't existInvalidDatasetFormatError: Raised when the dataset structure doesn't match expected format
Dependencies
numpytensorflowscikit-learnlogging(Python standard library)os(Python standard library)
Logging
The module automatically logs important operations and errors using Python's logging module. Log messages include timestamps and severity levels, making it easier to track and debug data loading operations.
Example log output:
2025-01-07 10:30:15 - INFO - Dataset successfully loaded from data/quantum_dots.npy
2025-01-07 10:30:15 - INFO - Normalizing the feature data.
2025-01-07 10:30:15 - INFO - Dataset successfully unpacked into features and labels.
energy_levels
The energy_levels module is designed to calculate the energy levels of a quantum dot and determine the transition energies between successive levels. This module is part of the quantum_dot_sim package, which provides tools for simulating quantum dot physics and analyzing their behavior.
Features
Calculate Energy Levels:
- Uses the formula for spherical quantum dots to compute discrete energy levels.
- Parameters:
radius(float): Radius of the quantum dot (in meters).material_properties(dict): Dictionary containing material-specific properties, such as the effective mass of the electron. - Returns A list of transition energies in joules.
Usage
from energy_levels import calculate_energy_levels, calculate_transition_energies
# Example inputs
radius = 5e-9 # Quantum dot radius in meters
material_properties = {"effective_mass": 1.2e-31} # Effective mass in kilograms
# Calculate energy levels
energy_levels = calculate_energy_levels(radius, material_properties)
print("Energy Levels (in joules):", energy_levels)
# Calculate transition energies
transition_energies = calculate_transition_energies(energy_levels)
print("Transition Energies (in joules):", transition_energies)
Logging
The module uses Python's logging library to log important information:
- INFO level logs provide details on the number of calculated energy levels and transitions.
- DEBUG level logs include detailed results for energy levels and transitions (can be enabled by configuring the logging level).
Dependencies
numpy: For numerial calculations- Python 3.6 or higher (due to f-string support and enhanced logging).
Notes
- If the
material_propertiesdictionary does not include theeffective_masskey, the module defaults to using the electron mass (9.1e-31kg). - Ensure the
radiusis in meters and theeffective_massis in kilograms for correct results.
wavefunctions
The wavefunctions module provides functionality to compute and visualize wavefunctions and energy levels of a quantum dot. This is an essential component of the quantum_dot_sim package for studying quantum mechanical properties in nanoscale systems.
spectra
This module allows you to compute the absorption spectra of a quantum dot.
Function: calculate_absorption_spectrum(radius, material_properties)
-
radius: Radius of the quantum dot -
material_properties: A dictionary containing material properties like band gap
Example:
absorption_spectrum = calculate_absorption_spectrum(5e-9, {"band_gap": 1.5})
visualization
This module provides functions for visualizing data and plotting graphs
Function: plot_custom_graph(x, y, xlabel, ylabel, title)
x: X axis datay: Y axis dataxlabel: Label for X axisylabel: Label for Y axistitle: Title of graph
Example:
plot_custom_graph(range(10), [i**2 for i in range(10)], xlabel="X", ylabel="Y", title="name-of-ur-graph")
sketch
This module contains the function to draw a 3d sketch of a quantum dot.
Function: draw_quantum_dot(radius)
energy_levels: A list of energy levels (in eV)
Example:
draw_quantum_dot(5e-9) #5 nm quantum dot
utils
This module includes utility functions, such as converting energy levels into a Pandas data frame.
Function: energy_levels_to_dataframe(energy_levels)
energy_levels: A list of energy levels (in eV)
Example:
import pandas as pd
from quantum_dot_sim.utils import energy_levels_to_dataframe
energy_levels = [1.2, 2.3, 3.4]
df = energy_levels_to_dataframe(energy_levels)
print(df)
interactive_mode
This new module provides an interactive mode for continuous predictions and training on quantum dot datasets.
Function: start_interactive_mode()
- Starts an interactive session to load a dataset, train a model, and predict on new data with options to continue or stop after one prediction.
Compatibility
This package is designed to work seamlessly with other scientific computing libraries, such as Numpy, SciPy, matplotlib, Pandas, and SymPy.
You can easily integrate this package with other scientific tools. This package can be a good addition to your project and work if you work with molecular dynamics simulations or other simulations that rely on physics principles.
Thank you for taking the time to read this!
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quantum_dot_sim-2.1.1.tar.gz.
File metadata
- Download URL: quantum_dot_sim-2.1.1.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72ed8ba439f24bff65c88a7fb7f0b25fd2a2af00e113e3667071e4f9d7423627
|
|
| MD5 |
19dd1ec8b46a1c549758256711184f54
|
|
| BLAKE2b-256 |
5839d73b3fea974d2d682e8b75250d03ce6f6974dccbc432005bea56ced83a02
|
File details
Details for the file quantum_dot_sim-2.1.1-py3-none-any.whl.
File metadata
- Download URL: quantum_dot_sim-2.1.1-py3-none-any.whl
- Upload date:
- Size: 38.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25c11e7cbdb549cdec0cff9692bf437885075e3d84fc13915789a49339e8fd1c
|
|
| MD5 |
973943ecfaec357c531e9d31a8b2706f
|
|
| BLAKE2b-256 |
d5a0e6ccd70ea75462abbd856742ed61f78351bd2466a6cd60350d093f684ad4
|