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
- Runge–Kutta 4 (RK-4) propagators for the Schrödinger and Liouville–von Neumann equations (
complex128, cache-friendly). - Lazy, high-speed construction of transition-dipole matrices (
rovibrational_excitation.dipole.*)- rigid-rotor + harmonic / Morse vibration
- Numba (CPU) or CuPy (GPU) backend
- Vector electric-field objects with Gaussian envelopes, chirp, optional sinusoidal and binned modulation.
- Batch runner for pump–probe / parameter sweeps with automatic directory creation, progress-bar and compressed output (
.npz). - 100 % pure-Python, no compiled extension to ship (Numba compiles at runtime).
- Currently, only linear molecules are supported; that is, only the rotational quantum numbers J and M are taken into account.
Testing & Coverage
The package includes a comprehensive test suite with 75% code coverage across all modules.
- 🟢 Basis classes: 100% coverage (LinMol, TwoLevel, VibLadder)
- 🟢 Core physics: 83-98% coverage (Hamiltonian, States, Propagator)
- 🟡 Electric field: 53% coverage
- 🔴 Low-level propagators: 25-38% coverage (ongoing development)
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
# From PyPI (stable)
pip install rovibrational-excitation # installs sub-packages as well
# Or from GitHub (main branch, bleeding-edge)
pip install git+https://github.com/1160-hrk/rovibrational-excitation.git
CuPy (optional) – for GPU acceleration
pip install cupy-cuda12x # pick the wheel that matches your CUDA
📚 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.
Directory layout (after refactor)
rovibrational_excitation/
__init__.py # public re-export
core/ # low-level numerics
basis.py, propagator.py, ...
dipole/
linmol/ # high-level dipole API
builder.py, cache.py
rot/ # rotational TDM formulae
jm.py, j.py
vib/
harmonic.py, morse.py
plots/ # helper scripts (matplotlib)
simulation/ # batch manager, CLI
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
Black + Ruff + MyPy configs are in pyproject.toml.
License
© 2025 Hiroki Tsusaka. All rights reserved.
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.0.tar.gz.
File metadata
- Download URL: rovibrational_excitation-0.2.0.tar.gz
- Upload date:
- Size: 82.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3b4d0792ee0297f6906115407068a6309f9e8f50ce249cc08d095f6b91a385a
|
|
| MD5 |
57b40d46f039ee57a5b61a4158b28568
|
|
| BLAKE2b-256 |
596039011badf54a7a0f4099cd106b6f82a87fc90237e6fc454ab5ba87620823
|
File details
Details for the file rovibrational_excitation-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rovibrational_excitation-0.2.0-py3-none-any.whl
- Upload date:
- Size: 57.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c59a9fac54444266ebfed134d52797167bc861240fa37629d75894fc87e32423
|
|
| MD5 |
a4e78f73558881d17cfa3de4845841e8
|
|
| BLAKE2b-256 |
8e371d5fc18f8a33a354ef0f744824eb97b6e8e79ba3b8f34ce8bb106980e5f1
|