zkit.io.tdm

Read transition-dipole-moment (TDM) data from TDSEZ static HDF5 output.

The full transition-dipole matrices d_ij = ⟨i|D_α|j⟩ between the saved eigenstates are written by TDSE-Z’s dipoles.x (run it in the run directory after a solve with NBoundStatesSave = 1 and SaveDipoleAxes):

static/<name>_tdm_Dx.npy, _tdm_Dy.npy, _tdm_Dz.npy   complex (N, N)

read_tdm() reads them next to static/<name>_eigen.h5 (also under the former names TDM_Dx_<name>.inp.npy), or the datasets tdm_x/y/z (shape (N*N, 2), [re, im]) when an eigen file carries them. The text summary static/<name>_tdm.txt drops small and diagonal entries and is not read.

This module complements the eigen reader (zkit.io.eigen.read_eigen()): read the HDF5 EigenData file with either helper and combine the spectrum/energies with the TDM matrices.

zkit.io.tdm.read_tdm(path)

Read the full transition-dipole matrices from a TDSEZ EigenData HDF5.

Parameters:

path (str | Path) – Path to static/<name>_eigen.h5 (the same file that carries spectrum / psi_* / run_metadata).

Returns:

Keys "tdm_x", "tdm_y", "tdm_z" (each an (N, N) complex np.ndarray of ⟨i|D_α|j⟩), present only for the spatial axes actually assembled by the run. If no TDM datasets are found, an empty dict is returned (e.g. the file predates this feature).

Return type:

dict

zkit.io.tdm.tdm_of_state(path, source_state, axes=None)

Return the dipole TDM out of eigenstate source_state for every axis.

The result is the source_state-th row of the requested TDM matrix/matrices, i.e. the vector [⟨source_state\|D_α\|0⟩, ⟨source_state\|D_α\|1⟩, ..., ⟨source_state\|D_α\|N-1⟩] of transition dipoles from state source_state into all other eigenstates.

Parameters:
  • path (str | Path) – EigenData HDF5 path (passed to read_tdm()).

  • source_state (int) – Source eigenstate index (0-based).

  • axes (str | List[str] | None) – Which axes to return. One of "x", "y", "z", a list of those, or None (default → all axes present in the file).

Returns:

Mapping axis -> (N,) complex ndarray (the row of that TDM matrix). If axes is a single string the dict still uses that string as key.

Return type:

dict

Raises:
  • IndexError – If source_state is out of range for the stored TDM matrices.

  • KeyError – If a requested axis has no TDM dataset in the file.

zkit.io.tdm.tdm_magnitude_of_state(path, source_state, axes=None)

Convenience: |⟨source_state|D_α|j⟩| (Euclidean norm over the requested axes) per j.

Returns an (N,) real array giving the total dipole-transition magnitude out of state source_state into every other state, summed in quadrature over the requested axes.

Parameters:
  • path (str | Path)

  • source_state (int)

  • axes (str | List[str] | None)

Return type:

ndarray