Rovibrational wave-packet simulation toolkit
Project description
rovibrational-excitation
Python package for time-dependent quantum dynamics of linear molecules (rotation ร vibration) driven by femtosecondโpicosecond laser pulses.
| CPU / GPU (CuPy) | Numba-JIT RK4 propagator | Lazy, cached dipole matrices |
|---|
Key features
๐ง High-Performance Time Evolution Engine
- RungeโKutta 4 (RK-4) propagators for the Schrรถdinger and Liouvilleโvon Neumann equations (
complex128, cache-friendly). - Split-operator method with CPU/GPU backends for efficient propagation.
โก High-Speed Dipole Matrix Construction
- Lazy, high-speed construction of transition-dipole matrices (
rovibrational_excitation.dipole.*)- rigid-rotor + harmonic / Morse vibration
- Numba (CPU) or CuPy (GPU) backend
- Lazy evaluation & caching for fast computation
๐ Flexible Electric Field Control
- Vector electric-field objects with Gaussian envelopes, chirp, optional sinusoidal and binned modulation.
- Gaussian envelope, chirp functionality
- Sinusoidal and binned modulation options
- Vector field support
๐ Batch Processing & Analysis
- Batch runner for pumpโprobe / parameter sweeps with automatic directory creation, progress-bar and compressed output (
.npz). - Pump-probe experiment simulation
- Parameter sweep capabilities
- Automatic directory creation
- Progress bar display
- Compressed output (
.npz)
๐ฌ Supported Molecules
- Currently, only linear molecules are supported; that is, only the rotational quantum numbers J and M are taken into account.
- Future extension to non-linear molecules is planned.
๐๏ธ Pure Python Implementation
- 100 % pure-Python, no compiled extension to ship (Numba compiles at runtime).
Testing & Coverage
The package includes a comprehensive test suite with 63% code coverage across all modules.
- ๐ข Basis classes: 100% coverage (LinMol, TwoLevel, VibLadder)
- ๐ก Core physics: 55% overall coverage
- States: 98% coverage
- Propagator: 83% coverage
- Hamiltonian: 67% coverage
- ๐ก Electric field: 53% coverage
- ๐ก Dipole matrices: 52-96% coverage (varies by subsystem)
- ๐ด Low-level propagators: 25-38% coverage (ongoing development)
- ๐ก Simulation runner: 62% coverage
See tests/README.md for detailed coverage reports and test instructions.
# Run tests
cd tests/ && python -m pytest -v
# Generate coverage report
coverage run -m pytest && coverage report
Installation
Stable Release (PyPI)
# From PyPI (stable)
pip install rovibrational-excitation # installs sub-packages as well
Development Version (GitHub)
# Or from GitHub (main branch, bleeding-edge)
pip install git+https://github.com/1160-hrk/rovibrational-excitation.git
GPU Acceleration (Optional)
CuPy (optional) โ for GPU acceleration
pip install cupy-cuda12x # pick the wheel that matches your CUDA
Requirements
Python Environment
- Python: 3.10+
- NumPy: Array operations & numerical computing
- SciPy: Scientific computing library
- Numba: JIT compilation (CPU acceleration)
Optional Dependencies
- CuPy: GPU computing (requires CUDA)
- Matplotlib: Graph plotting
- tqdm: Progress bars
๐ Documentation
For detailed usage instructions and parameter reference:
| Document | Description | Audience |
|---|---|---|
| docs/PARAMETER_REFERENCE.md | Complete parameter reference | All users |
| docs/SWEEP_SPECIFICATION.md | Parameter sweep specification | Intermediate |
| docs/README.md | Documentation index & quick guides | All users |
| examples/params_template.py | Parameter file template | Beginners |
๐ Getting Started
- Read the parameter reference: docs/PARAMETER_REFERENCE.md
- Copy the template:
cp examples/params_template.py my_params.py - Edit parameters according to your system
- Run simulation:
python -m rovibrational_excitation.simulation.runner my_params.py
Quick start : library API
import numpy as np
import rovibrational_excitation as rve
# --- 1. Basis & dipole matrices ----------------------------------
c_vacuum = 299792458 * 1e2 / 1e15 # cm/fs
debye_unit = 3.33564e-30 # 1 D โ Cยทm
Omega01_rad_phz = 2349*2*np.pi*c_vacuum
Delta_omega_rad_phz = 25*2*np.pi*c_vacuum
B_rad_phz = 0.39e-3*2*np.pi*c_vacuum
Mu0_Cm = 0.3 * debye_unit # 0.3 Debye ็ธๅฝ
Potential_type = "harmonic" # or "morse"
V_max = 2
J_max = 4
basis = rve.LinMolBasis(
V_max=V_max,
J_max=J_max,
use_M = True,
omega_rad_phz = Omega01_rad_phz,
delta_omega_rad_phz = Delta_omega_rad_phz
) # |v J Mโฉ direct-product
dip = rve.LinMolDipoleMatrix(
basis, mu0=Mu0_Cm, potential_type=Potential_type,
backend="numpy", dense=True) # CSR on GPU
mu_x = dip.mu_x # lazy-built, cached thereafter
mu_y = dip.mu_y
mu_z = dip.mu_z
# --- 2. Hamiltonian ----------------------------------------------
H0 = rve.generate_H0_LinMol(
basis,
omega_rad_phz = Omega01_rad_phz,
delta_omega_rad_phz = Delta_omega_rad_phz,
B_rad_phz = B_rad_phz,
)
# --- 3. Electric field -------------------------------------------
t = np.linspace(-200, 200, 4001) # fs
E = rve.ElectricField(tlist=t)
E.add_dispersed_Efield(
envelope_func=rve.core.electric_field.gaussian_fwhm,
duration=50.0, # FWHM (fs)
t_center=0.0,
carrier_freq=2349*2*np.pi*c_vacuum, # rad/fs
amplitude=1.0,
polarization=[1.0, 0.0], # x-pol.
)
# --- 4. Initial state |v=0,J=0,M=0โฉ ------------------------------
from rovibrational_excitation.core.states import StateVector
psi0 = StateVector(basis)
psi0.set_state((0,0,0), 1.0)
psi0.normalize()
# --- 5. Time propagation (Schrรถdinger) ---------------------------
psi_t = rve.schrodinger_propagation(
H0, E, dip,
psi0.data,
axes="xy", # Exโฮผx, Eyโฮผy
sample_stride=10,
backend="numpy") # or "cupy"
population = np.abs(psi_t)**2
print(population.shape) # (Nt, dim)
Quick start : batch runner
- Create a parameter file (
params_CO2.py)
# description is used in results/<timestamp>_<description>/
description = "CO2_antisymm_stretch"
# --- time axis (fs) ---------------------------------------------
t_start, t_end, dt = -200.0, 200.0, 0.1 # Unit is fs
# --- electric-field scan ----------------------------------------
duration = [50.0, 80.0] # Gaussian FWHM (fs)
polarization = [[1,0], [1/2**0.5,1j/2**0.5]]
t_center = [0.0, 100.0]
carrier_freq = 2349*2*np.pi*1e12*1e-15 # rad/fs
amplitude = 1.0e9 # V/m
# --- molecular constants ----------------------------------------
V_max, J_max = 2, 4
omega_rad_phz = carrier_freq * 2 * np.pi
mu0_Cm = 0.3 * 3.33564e-30 # 0.3 D
- Run
python -m rovibrational_excitation.simulation.runner \
examples/params_CO2.py -j 4 # 4 processes
- Creates
results/YYYY-MM-DD_hh-mm-ss_CO2_antisymm_stretch/โฆ - For each case a folder with
result.npz,parameters.json - Top-level
summary.csv(final populations etc.)
Add
--dry-runto just list cases without running.
Applications
CO2 Antisymmetric Stretch Vibration Excitation
- Molecule: CO2 (linear triatomic molecule)
- Excitation mode: Antisymmetric stretch vibration (ฮฝโ โ 2349 cmโปยน)
- Laser: Femtosecond pulse
- Analysis: Population transfer between vibrational levels
Pump-Probe Experiments
- Pump pulse: Molecular excitation
- Probe pulse: State exploration after time delay
- Measurements: Time-resolved spectra, population dynamics
Directory layout
rovibrational_excitation/
โโโ src/rovibrational_excitation/
โ โโโ __init__.py # public re-export
โ โโโ core/ # low-level numerics
โ โ โโโ basis/ # quantum basis classes
โ โ โ โโโ __init__.py
โ โ โ โโโ base.py # abstract base class
โ โ โ โโโ linmol.py # linear molecule basis
โ โ โ โโโ twolevel.py # two-level system
โ โ โ โโโ viblad.py # vibrational ladder
โ โ โโโ propagator.py # time evolution
โ โ โโโ electric_field.py
โ โ โโโ hamiltonian.py # DEPRECATED
โ โ โโโ states.py # quantum state vectors
โ โ โโโ _rk4_schrodinger.py
โ โ โโโ _rk4_lvne.py
โ โ โโโ _splitop_schrodinger.py
โ โโโ dipole/ # transition dipole matrices
โ โ โโโ linmol/ # linear molecules
โ โ โ โโโ builder.py # matrix construction
โ โ โ โโโ cache.py # caching system
โ โ โโโ twolevel/ # two-level systems
โ โ โโโ viblad/ # vibrational ladder
โ โ โโโ rot/ # rotational elements
โ โ โ โโโ j.py # J quantum number
โ โ โ โโโ jm.py # J,M quantum numbers
โ โ โโโ vib/ # vibrational elements
โ โ โโโ harmonic.py # harmonic oscillator
โ โ โโโ morse.py # Morse oscillator
โ โโโ plots/ # visualization helpers
โ โ โโโ plot_electric_field.py
โ โ โโโ plot_electric_field_vector.py
โ โ โโโ plot_population.py
โ โโโ simulation/ # batch runner & CLI
โ โโโ runner.py # main execution engine
โ โโโ manager.py # execution management
โ โโโ config.py # configuration handling
โโโ tests/ # unit tests (pytest)
โโโ validation/ # physics validation scripts
โ โโโ core/ # core physics validation
โ โโโ dipole/ # dipole matrix validation
โ โโโ simulation/ # integration validation
โโโ examples/ # usage examples
โโโ docs/ # documentation
Validation vs Testing
tests/: Unit tests for code correctness (fast, comprehensive)validation/: Physics validation for scientific accuracy (slower, focused on physical laws)
# Run unit tests
pytest tests/ -v
# Run physics validation
python validation/core/check_core_basis.py
find validation/ -name "check_*.py" -exec python {} \;
Development
git clone https://github.com/1160-hrk/rovibrational-excitation.git
cd rovibrational-excitation
python -m venv .venv && source .venv/bin/activate
pip install -r requirements-dev.txt
pytest -v
Development Tools
- Black: Code formatter
- Ruff: High-speed linter
- MyPy: Static type checking
- pytest: Testing framework
Black + Ruff + MyPy configs are in pyproject.toml.
Contributing
- Issue Reports: Bug reports & feature requests
- Pull Requests: Code improvements & new features
- Documentation: Usage examples & tutorials
Development Guidelines
- PEP8-compliant code style
- Type hints required
- Maintain test coverage
- Detailed docstrings
References
- Quantum Mechanics: Griffiths, "Introduction to Quantum Mechanics"
- Molecular Spectroscopy: Herzberg, "Molecular Spectra and Molecular Structure"
- Numerical Methods: Press et al., "Numerical Recipes"
License
ยฉ 2025 Hiroki Tsusaka. All rights reserved.
Contact
- GitHub Issues: Repository
- Email: Please check the project page
Last updated: January 2025
Project details
Release history Release notifications | RSS feed
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 rovibrational_excitation-0.2.6.tar.gz.
File metadata
- Download URL: rovibrational_excitation-0.2.6.tar.gz
- Upload date:
- Size: 163.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c615ca244fae215c33ac8ee627dd11338271280384049e9b4438841041ae3a9c
|
|
| MD5 |
28ad2c80dd9fa21f910c259b4bb2cf14
|
|
| BLAKE2b-256 |
bf7c8b5f45e1941eaaf33197410a1324133217826de3b8b3e655ac12045f79bc
|
File details
Details for the file rovibrational_excitation-0.2.6-py3-none-any.whl.
File metadata
- Download URL: rovibrational_excitation-0.2.6-py3-none-any.whl
- Upload date:
- Size: 152.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed4d510cd4875b565472125bd93c285a62579b483bd4c6f28bdec0ca7b114458
|
|
| MD5 |
bad50b4c50ee8680c830ca0861ede7c5
|
|
| BLAKE2b-256 |
3a01eb273df53203789a9c2d00fe51d416034d826db2202dbbbb062b65783c5b
|