pytdscf.util package
Submodules
pytdscf.util.anim_density_matrix module
- class pytdscf.util.anim_density_matrix.ComplexMatrixAnimation(data: ndarray[tuple[int, ...], dtype[complex128]], time: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, title: str = 'Complex Matrix Hinton Plot', row_names: list[str] | None = None, col_names: list[str] | None = None, time_unit: str = 'fs', cmap: str = 'hsv', figshape: tuple[int, int] = (14, 10), add_text: bool = False)[source]
- Bases: - object- ax: Axes
 - cax: Axes
 - property cols: int
 - create_animation(interval: int = 200) tuple[Figure, FuncAnimation][source]
- Create an animation of complex matrix Hinton plots. - Parameters:
- data – Complex array of shape (time, row, column) 
- interval – Time interval between frames in milliseconds 
 
- Returns:
- Figure and Animation objects 
 
 - fig: Figure
 - plot_each_element(i: int, j: int, cmap: Colormap, norm: ndarray, phase: ndarray, data: ndarray) None[source]
- Plot each element of the complex matrix. - Parameters:
- i – Row index 
- j – Column index 
- cmap – Colormap object 
- norm – Magnitude of the complex number 
- phase – Phase of the complex number 
- data – Complex matrix data 
 
 
 - property rows: int
 
- pytdscf.util.anim_density_matrix.get_anim(data: ndarray[tuple[int, ...], dtype[complex128]], time: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, title: str = 'Density Matrix Evolution', row_names: list[str] | None = None, col_names: list[str] | None = None, time_unit: str = 'fs', save_gif: bool = False, gif_filename: str = 'animation.gif', cmap: str = 'hsv', fps: int = 5, dpi: int = 100, add_text: bool = False) tuple[Figure, FuncAnimation][source]
- Main function to create Hinton plot animation from complex matrix data. - Parameters:
- data (NDArray[np.complex128]) – Complex array of shape (time, row, column). 
- time (NDArray | None, optional) – Array of time points corresponding to the data. Defaults to None. 
- title (str, optional) – Title of the plot. Defaults to “Complex Matrix Hinton Plot”. 
- row_names (list[str] | None, optional) – List of row names. Defaults to None. 
- col_names (list[str] | None, optional) – List of column names. Defaults to None. 
- time_unit (str, optional) – Unit of time to display on the plot. Defaults to “”. 
- save_gif (bool, optional) – Whether to save the animation as a GIF. Defaults to False. 
- gif_filename (str, optional) – Output filename for GIF. Defaults to “animation.gif”. 
- cmap (str, optional) – Colormap to use for the plot. Defaults to “hsv”. cmap should be cyclic such as ‘twilight’, ‘twilight_shifted’, ‘hsv’. See also https://matplotlib.org/stable/users/explain/colors/colormaps.html#cyclic. 
- fps (int, optional) – Frames per second for GIF. Defaults to 5. 
- dpi (int, optional) – Dots per inch for the output GIF. Defaults to 100. 
- add_text (bool, optional) – Display matrix_element or not. Defaults to False. 
 
- Returns:
- Figure and Animation objects. 
- Return type:
- tuple[plt.Figure, animation.FuncAnimation] 
 - Example - >>> # Create a 3x3 complex matrix that evolves over 10 time steps >>> t = np.linspace(0, 2*np.pi, 10) >>> data = np.zeros((10, 3, 3), dtype=np.complex128) >>> for i in range(10): ... data[i] = np.exp(1j * t[i]) * np.random.random((3, 3)) >>> fig, anim = main(data, time=t, save_gif=True) >>> plt.show() 
pytdscf.util.gout2dipole module
Gaussian anharmonic dipole output to PyTDSCF dipole (mu_orig) converter - How to use
$ python3 gout2dipole.py *.log N_FRQS
N_FRQS = (number of atom)*3 -6 (if molecule is straight, -6 -> -5)
- Gaussian input file needs “freq=(Anharm, noRaman) Symmetry=None”. 
pytdscf.util.gout2mop module
Gaussian output anharmonic PES to MIDAS, SINDO PES(.mop) converter - How to use
$ python3 gout2mop.py **.log N_FRQS **.mop
N_FRQS = (number of atom)*3 -6 (if molecule is straight, -6 -> -5)
- param outputfile:
- default is - prop_no_1.mop(for MIDAS)
- defaut nMR is 4 in g16. 
- When product Qi odd times, sgn can be reversed. 
- Qi and Qj can be swaped. 
- Gaussian input file needs “freq=(Anharm, HPMode) Symmetry=None iop(4/34=1) iop(7/33=1)”. 
pytdscf.util.grid2qff module
MakePES to PyTDSCF polynomial PES converter (least-aquare based)
$ python grid2qff.py pes_mrpes
pytdscf.util.helper_input module
This module have been deprecated. But for testing, this module is still used.
- pytdscf.util.helper_input.matJ_1D_exciton(nmol, nspf, s0, s1, coupleJ, *, deltaE=0.0, coupleE=0.0, coupleH=0.0, ndof_per_site=1, with_CT=False)[source]
pytdscf.util.hess_util module
Hessian Utility Scripts
- pytdscf.util.hess_util.get_displce_from_hess(hess: ndarray, mass: List[float], massweighted: bool | None = True, onedim: bool | None = False) Tuple[ndarray, ndarray][source]
- Get displacement vector (normal mode) from mass-weighted hessian - Parameters:
- hess (np.ndarray) – hessian in a.u. 
- mass (List[float]) – List of atom weight in AMU. 
- massweighted (Optional[bool]) – input hessian is mass-weighted hessian. Defaults to True 
- onedim (Optional[bool]) – input hessian is one-dimensional array of upper-triangle part. Defaults to False. 
 
- Returns:
- Non-mass weighted displacement vectors in a.u. and frequency in cm-1. 
- Return type:
- Tuple[np.ndarray, np.ndarray] 
 
- pytdscf.util.hess_util.read_fchk_g16(file_path: str) Tuple[str, ndarray, ndarray, ndarray, ndarray][source]
- Read Hessian in .fchk files from Gaussian16. - Parameters:
- file_path (str) – Path to - fchkfile.
- use_trans (bool) – Use translational vector. Defaults to - False.
- use_rot (bool) – Use rotatinal vector. Defaults to - False.
 
- Returns:
- multiple contents listed below. 
- Return type:
- Tuple 
 - Return contents:
- list(str) : atoms 
- numpy.ndarray : mass in AMU. 
- numpy.ndarray : coordinate in a.u. Shape is - (natom, 3), where- natom = len(atoms).
- numpy.ndarray : frequency in cm-1. Shape is - (ndof, ), where- ndof=- 3*natom-6or- 3*natom-5.- Nanrepresents imaginary frequency.
- numpy.ndarray : displacement vectors in a.u. . Shape is - (ndof, natom, 3). Not mass weighted and normalized !!
 
 
- pytdscf.util.hess_util.read_minfo(file_path, use_trans: bool | None = False, use_rot: bool | None = False)[source]
- Read .minfo files from MakePES in SINDO package. Not supported localized coordinate by JSindo. - Parameters:
- file_path (str) – Path to - .minfofile.
- use_trans (bool) – Use translational vector. Defaults to - False.
- use_rot (bool) – Use rotatinal vector. Defaults to - False.
 
- Returns:
- multiple contents listed below. 
- Return type:
- tuple 
 - Return contents:
- list(str) : atoms 
- numpy.ndarray : mass in AMU. 
- numpy.ndarray : coordinate in a.u. Shape is - (natom, 3), where- natom = len(atoms).
- numpy.ndarray : frequency in cm-1. Shape is - (ndof, ), where- ndof = 3*natom-6.
- numpy.ndarray : displacement vectors in a.u. . Shape is - (ndof, natom, 3). Not mass weighted and normalized !!
 
 
pytdscf.util.korig2mop module
PyTDSCF polynomial operator(k_orig) to SINDO, MIDAS PES (.mop) converter
pytdscf.util.korig2op module
PyTDSCF polynomial operator(kroig) to QUANTICS operator(.op) converter * How to use
$ python3 PyTDSCH2mop.py N_FRQS
N_FRQS = (number of atom)*3 -6 (if molecule is straight, -6 -> -5)
Qi and Qj can be swaped.
pytdscf.util.minfo2gout module
SINDO .minfo to Gaussian output converter * How to use
$ python3 minf2gout.py ---.log N_FRQS
N_FRQS = (number of atom)*3 -6
(if molecule is straight, -6 -> -5)
Qi and Qj can be swapped.
pytdscf.util.mop2korig module
MIDAS, SINDO PES(.mop) to PyTDSCF polynomial PES(k_orig) converter * How to use
$ python3 mop2PyTDSCH_hamiltonian.py input.mop N_FRQS
N_FRQS = (number of atom)*3 -6 (if molecule is straight, -6 -> -5)
Qi and Qj can be swapped.
pytdscf.util.plot_heatmap module
Plot potential Heatmap from PyTDSCF PES (wat3 example)
pytdscf.util.read_nc module
Module contents
- pytdscf.util.get_anim(data: ndarray[tuple[int, ...], dtype[complex128]], time: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None = None, title: str = 'Density Matrix Evolution', row_names: list[str] | None = None, col_names: list[str] | None = None, time_unit: str = 'fs', save_gif: bool = False, gif_filename: str = 'animation.gif', cmap: str = 'hsv', fps: int = 5, dpi: int = 100, add_text: bool = False) tuple[Figure, FuncAnimation][source]
- Main function to create Hinton plot animation from complex matrix data. - Parameters:
- data (NDArray[np.complex128]) – Complex array of shape (time, row, column). 
- time (NDArray | None, optional) – Array of time points corresponding to the data. Defaults to None. 
- title (str, optional) – Title of the plot. Defaults to “Complex Matrix Hinton Plot”. 
- row_names (list[str] | None, optional) – List of row names. Defaults to None. 
- col_names (list[str] | None, optional) – List of column names. Defaults to None. 
- time_unit (str, optional) – Unit of time to display on the plot. Defaults to “”. 
- save_gif (bool, optional) – Whether to save the animation as a GIF. Defaults to False. 
- gif_filename (str, optional) – Output filename for GIF. Defaults to “animation.gif”. 
- cmap (str, optional) – Colormap to use for the plot. Defaults to “hsv”. cmap should be cyclic such as ‘twilight’, ‘twilight_shifted’, ‘hsv’. See also https://matplotlib.org/stable/users/explain/colors/colormaps.html#cyclic. 
- fps (int, optional) – Frames per second for GIF. Defaults to 5. 
- dpi (int, optional) – Dots per inch for the output GIF. Defaults to 100. 
- add_text (bool, optional) – Display matrix_element or not. Defaults to False. 
 
- Returns:
- Figure and Animation objects. 
- Return type:
- tuple[plt.Figure, animation.FuncAnimation] 
 - Example - >>> # Create a 3x3 complex matrix that evolves over 10 time steps >>> t = np.linspace(0, 2*np.pi, 10) >>> data = np.zeros((10, 3, 3), dtype=np.complex128) >>> for i in range(10): ... data[i] = np.exp(1j * t[i]) * np.random.random((3, 3)) >>> fig, anim = main(data, time=t, save_gif=True) >>> plt.show()