API Reference

Full documentation of the TENSO public API. Click any collapsible entry to expand its signature, docstring, and parameter table. For a narrative description of how the layers interact, see the code structure page.

Introduction

TENSO is organized in four conceptual layers that build on one another:

  1. Prototypes — high-level entry points that assemble a complete simulation from a few keyword arguments.
  2. HEOM + State + Operator — the core numerical engine: hierarchy management, TTN state representation, and TDVP propagators.
  3. Bath — bath correlation function decomposition and spectral density utilities.
  4. Basis / ML-MCTDH / Libs — DVR grids, the ML-MCTDH alternative propagator, and shared back-end helpers.
Most users only need tenso.prototypes. The lower layers are exposed for advanced customisation and algorithmic research.

tenso.prototypes

Ready-to-use entry points that wire together bath, system, and propagation parameters into a single callable. These functions are the recommended starting point for new users.

tenso.prototypes.bath

gen_comb_bcf function

Generate a correlation function for a comb-like spectral density.

Parameters ---------- include_drude : bool Whether to include the Drude term for the low-frequency modes. re_d : float Reorganization energy of the Drude term. width_d : float Cutoff frequency of the Drude term. include_brownian : bool Whether to include the Brownian term for the high-frequency modes. dof_b : int Number of Brownian modes. freq_max_b : float Maximum frequency space that the Brownian modes span. re_b : float Reorganization energy of the Brownian modes. width_b : float Cutoff frequency of the Brownian modes. include_discrete : bool Whether to include the discrete vibrational modes. dof_v : int Number of discrete vibrational modes. freq_max_v : float Maximum frequency space that the discrete vibrational modes span. re_v : float Reorganization energy of the discrete vibrational modes. temperature : float Temperature of the bath. decomposition_method : str Method to decompose the Bose-Einstein distribution. n_ltc : int Number of low-temperature correction terms in the decomposition of the Bose-Einstein distribution. **kwargs : dict Ignored arguments.

gen_comb_bcf(
          include_drude: bool,
          re_d: float,
          width_d: float,
          include_brownian: bool,
          dof_b: int,
          freq_max_b: float,
          re_b: float,
          width_b: float,
          include_discrete: bool,
          dof_v: int,
          freq_max_v: float,
          re_v: float,
          temperature: float,
          decomposition_method: str,
          n_ltc: int,
          **kwargs
      ) -> Correlation
ParameterTypeDescription
include_drudeboolWhether to include the Drude term for the low-frequency modes.
re_dfloatReorganization energy of the Drude term.
width_dfloatCutoff frequency of the Drude term.
include_brownianboolWhether to include the Brownian term for the high-frequency modes.
dof_bintNumber of Brownian modes.
freq_max_bfloatMaximum frequency space that the Brownian modes span.
re_bfloatReorganization energy of the Brownian modes.
width_bfloatCutoff frequency of the Brownian modes.
include_discreteboolWhether to include the discrete vibrational modes.
dof_vintNumber of discrete vibrational modes.
freq_max_vfloatMaximum frequency space that the discrete vibrational modes span.
re_vfloatReorganization energy of the discrete vibrational modes.
temperaturefloatTemperature of the bath.
decomposition_methodstrMethod to decompose the Bose-Einstein distribution.
n_ltcintNumber of low-temperature correction terms in the decomposition of the Bose-Einstein distribution.

Returns: Correlation The correlation function for the comb-like spectral density.

gen_bcf function

Generate a correlation function for a composite spectral density for HEOM.

gen_bcf(
          include_drude: bool = True,
          re_d: list[float] | None = None,
          width_d: list[float] | None = None,
          include_brownian: bool = True,
          freq_b: list[float] | None = None,
          re_b: list[float] | None = None,
          width_b: list[float] | None = None,
          include_discrete: bool = True,
          freq_v: list[float] | None = None,
          re_v: list[float] | None = None,
          temperature: float = 300.0,
          decomposition_method: str = 'Pade',
          n_ltc: int = 0,
          include_lindblad: bool = False,
          use_cross: bool = False,
          use_ht_function: bool = False,
          **kwargs
      ) -> Correlation
ParameterTypeDescription
include_drudeWhether to include the Drude term for the low-frequency modes, defaults to True
re_dlist[float]Reorganization energy of every Drude mode
width_dlist[float]Cutoff frequencies of every Drude mode
include_brownianboolWhether to include the Brownian term for the high-frequency modes
freq_blist[float]Frequencies of every Brownian mode
re_blist[float]Reorganization energy of every Brownian mode
width_blist[float]Width of every Brownian modes
include_discretebooleanWhether to include the discrete vibrational mode, defaults to True
freq_vlist[float]Frequency of every discrete vibrational mod
re_vlist[float]Reorganization energy of every discrete vibrational mode
temperaturefloatTemperature of the bath
decomposition_methodstringMethod to decompose the Bose-Einstein distribution, either 'Pade' or 'Matsubara'
n_ltcintNumber of low-temperature correction terms in the decomposition of the Bose-Einstein distribution
include_lindbladbooleanWhether to include the Lindblad rate as in Tanimura's HEOM, defaults to False
use_crossbooleanWhether to use the cross-correlation that includes the trigonometric functions, defaults to False
use_ht_functionboolWhether to use the high-temperature approximation [2 / (beta omega)] of the Bose-Einstein distribution instead of the hyperbolic tangent function, defaults to False

Returns: :class: Correlation — The correlation function for the composite spectral density.

gen_tedopa_bcf function

Generate a correlation function for a composite spectral density based on TEDOPA-type of decompostion but without changing to the chain-like picture.

Parameters ---------- include_drude : bool Whether to include the Drude term for the low-frequency modes. re_d : float Reorganization energy of the Drude term. width_d : float Cutoff frequency of the Drude term. cutoff_type : str Type of cutoff function for the Drude term. Allowed values are 'Lorentz' (Drude-Lorentz) and 'Exp' (Ohmic with exponential cutoff). include_brownian : bool Whether to include the Brownian term for the high-frequency modes. freq_b : list[float] Frequencies of the Brownian modes. re_b : list[float] Reorganization energies of the Brownian modes. width_b : list[float] Broadening of the Brownian modes. temperature : float Temperature of the bath. frequency_cutoff : float Cutoff frequency for the spectral density. n_frequency : int Number of frequency points for the spectral density. n_discretization : int Number of discretization points for the spectral density. **kwargs : dict Ignored arguments.

gen_tedopa_bcf(
          re_d: list[float],
          width_d: list[float],
          freq_b: list[float],
          re_b: list[float],
          width_b: list[float],
          temperature: float,
          frequency_cutoff: float,
          n_frequency: int,
          n_discretization: int,
          cutoff_type: str = 'Lorentz',
          include_brownian: bool = True,
          include_drude: bool = True,
          **kwargs
      ) -> StarBosons
ParameterTypeDescription
include_drudeboolWhether to include the Drude term for the low-frequency modes.
re_dfloatReorganization energy of the Drude term.
width_dfloatCutoff frequency of the Drude term.
cutoff_typestrType of cutoff function for the Drude term. Allowed values are 'Lorentz' (Drude-Lorentz) and 'Exp' (Ohmic with exponential cutoff).
include_brownianboolWhether to include the Brownian term for the high-frequency modes.
freq_blist[float]Frequencies of the Brownian modes.
re_blist[float]Reorganization energies of the Brownian modes.
width_blist[float]Broadening of the Brownian modes.
temperaturefloatTemperature of the bath.
frequency_cutofffloatCutoff frequency for the spectral density.
n_frequencyintNumber of frequency points for the spectral density.
n_discretizationintNumber of discretization points for the spectral density.

Returns: StarBosons The correlation function for the composite spectral density.

gen_heom_like_star_boson function

Generate a correlation function for a composite spectral density for HSEOM but based on HEOM-style BCF decompostion.

Parameters ---------- include_drude : bool Whether to include the Drude term for the low-frequency modes. re_d : list[float] Reorganization energies of every Drude modes. width_d : list[float] Cutoff frequencies of every Drude modes. include_brownian : bool Whether to include the Brownian term for the high-frequency modes. freq_b : list[float] Frequencies of every Brownian modes. re_b : list[float] Reorganization energies of every Brownian modes. width_b : list[float] Broadening of every Brownian modes. include_discrete : bool Whether to include the discrete vibrational modes. freq_v : list[float] Frequencies of every discrete vibrational modes. re_v : list[float] Reorganization energies of every discrete vibrational modes. temperature : float Temperature of the bath. decomposition_method : str Method to decompose the Bose-Einstein distribution. n_ltc : int Number of low-temperature correction terms in the decomposition of the Bose-Einstein distribution. include_lindblad : bool Whether to include the Lindblad rate as in Tanimura's HEOM. use_cross : bool Whether to use the cross-correlation that includes the trigonometric functions. use_ht_function : bool Whether to use the high-temperature approximation [2 / (beta omega)] of the Bose-Einstein distribution instead of the hyperbolic tangent function.

gen_heom_like_star_boson(
          include_drude: bool = True,
          re_d: list[float] | None = None,
          width_d: list[float] | None = None,
          include_brownian: bool = True,
          freq_b: list[float] | None = None,
          re_b: list[float] | None = None,
          width_b: list[float] | None = None,
          include_discrete: bool = True,
          freq_v: list[float] | None = None,
          re_v: list[float] | None = None,
          temperature: float = 300.0,
          decomposition_method: str = 'Pade',
          n_ltc: int = 0,
          include_lindblad: bool = False,
          use_cross: bool = False,
          use_ht_function: bool = False,
          **kwargs
      ) -> StarBosons
ParameterTypeDescription
include_drudeboolWhether to include the Drude term for the low-frequency modes.
re_dlist[float]Reorganization energies of every Drude modes.
width_dlist[float]Cutoff frequencies of every Drude modes.
include_brownianboolWhether to include the Brownian term for the high-frequency modes.
freq_blist[float]Frequencies of every Brownian modes.
re_blist[float]Reorganization energies of every Brownian modes.
width_blist[float]Broadening of every Brownian modes.
include_discreteboolWhether to include the discrete vibrational modes.
freq_vlist[float]Frequencies of every discrete vibrational modes.
re_vlist[float]Reorganization energies of every discrete vibrational modes.
temperaturefloatTemperature of the bath.
decomposition_methodstrMethod to decompose the Bose-Einstein distribution.
n_ltcintNumber of low-temperature correction terms in the decomposition of the Bose-Einstein distribution.
include_lindbladboolWhether to include the Lindblad rate as in Tanimura's HEOM.
use_crossboolWhether to use the cross-correlation that includes the trigonometric functions.
use_ht_functionboolWhether to use the high-temperature approximation [2 / (beta omega)] of the Bose-Einstein distribution instead of the hyperbolic tangent function.

Returns: Correlation The correlation function for the composite spectral density.

gen_star_boson function

Generate a correlation function for a composite spectral density for the star-like decomposition as in spin-boson model. All inputs should be in default units and will be converted to TENSO's internal units.

gen_star_boson(
          temperature: float,
          cutoff: float,
          n_discretization: int,
          re_d: list[float] = None,
          width_d: list[float] = None,
          freq_b: list[float] = None,
          re_b: list[float] = None,
          width_b: list[float] = None,
          freq_v: list[float] = None,
          re_v: list[float] = None,
          include_drude: bool = True,
          include_brownian: bool = True,
          include_discrete: bool = True,
          discretization_method: str = 'Fourier',
          ohmic_type: str = 'Lorentz',
          shift_frequency: bool = True,
          absorb_rate: None | float = None,
          log_base: int = 10,
          log_minimum_frequency: None | float = None,
          int_grid_size: float | None = None,
          int_lower_bound: float | None = None,
          **kwargs
      ) -> StarBosons
ParameterTypeDescription
include_drudebooleanWhether to include the Drude term for the low-frequency modes.
re_dlist[float]Reorganization energies of the Drude modes as a list
width_dlist[float]Cutoff frequencies of the Drude modes.
include_brownianWhether to include the Brownian term for the high-frequency modes, defaults to True
freq_blist[float]Frequencies of the Brownian modes as a list
re_blist[float]Reorganization energies of the Brownian modes as a list
width_blist[float]Broadening of the Brownian modes
include_discreteboolWhether to include the discrete vibrational modes, defaults to True
freq_vlist[float]Frequencies of the discrete vibrational modes
re_vlist[float]Reorganization energies of the discrete vibrational modes.
temperaturefloatTemperature of the bath.
cutofffloatCutoff frequency for the spectral density. Frequencies above this will not be considered
n_discretizationintNumber of discretization points for the spectral density.
ohmic_typestringType of the Drude term. Allowed values are `Lorentz` (Drude-Lorentz) and `Exp` (Ohmic with exponential cutoff), defaults to `Lorentz`
shift_frequencybooleanWhether to shift the frequency to the positive domain.

Returns: :class: StarBosons — StarBosons, the correlation function for the composite spectral density.

tenso.prototypes.heom

system_single_bath function

Spin-Boson model using HEOM with tensor network. Assuming one bath correlation function.

system_single_bath(
          fname: str,
          init_rdo: MatList,
          sys_ham: MatList,
          sys_op: MatList,
          bath_correlation: Correlation,
          td_f: Callable[[float], float] | None = None,
          td_op: MatList | None = None,
          **kwargs
      ) -> Generator[float, None, None]
ParameterTypeDescription
fnamestrThe output file name.
init_rdoMatListThe initial reduced density operator.
hMatListThe system Hamiltonian.
opMatListThe system operator in the system-bath interaction hamiltonian.
bath_correlation:class: CorrelationThe bath correlation function for HEOM.
td_fCallable[[float], float] | NoneThe time-dependent field.
MatlistThe operator associated with the time-dependent field, default none.
kwargsdictionaryOther settings. See `default_parameters.py` for details.

Returns: float — The current time in unit in `default_parameters.py`.

system_multibath function

Spin-Boson model using HEOM with tensor network allowing multiple bath correlation functions.

Parameters: -----------

system_multibath(
          fname: str,
          init_rdo: MatList,
          sys_ham: MatList,
          sys_ops: list[MatList],
          bath_correlations: list[Correlation],
          td_f: Callable[[float], float] | None = None,
          td_op: MatList | None = None,
          **kwargs
      ) -> Generator[float, None, None]
ParameterTypeDescription
fnamestrThe output file name.
init_rdoMatListThe initial reduced density operator.
hMatListThe system Hamiltonian.
opMatListThe system operator in the system-bath interaction hamiltonian.
bath_correlation:class: CorrelationThe bath correlation function for HEOM.
td_fCallable[[float], float] | NoneThe time-dependent field.
td_opMatList | NoneThe operator associated with the time-dependent field.
kwargsdictOther settings. See `default_parameters.py` for details.

Returns: float — The current time in unit in `default_parameters.py`.

tenso.prototypes.mctdh

MCTDH interface functions

system_single_bath function

Spin-boson model with MCTDH.

Parameters ---------- fname : str The filename prefix for the output files. init_wfn : VecList The initial wavefunction. h : MatList The system Hamiltonian. op : MatList The observable. boson_bath : StarBosons The boson bath. td_f : Callable[[float], float], optional The time-dependent field, by default None. td_op : MatList, optional The time-dependent operator, by default None. **kwargs The parameters for the simulation.

system_single_bath(
          fname: str,
          init_wfn: VecList,
          sys_ham: MatList,
          sys_op: MatList,
          bath: StarBosons,
          td_f: Callable[[float], float] | None = None,
          td_op: MatList | None = None,
          **kwargs
      ) -> Generator[float, None, None]
ParameterTypeDescription
fnamestrThe filename prefix for the output files.
init_wfnVecListThe initial wavefunction.
hMatListThe system Hamiltonian.
opMatListThe observable.
boson_bathStarBosonsThe boson bath.
td_fCallable[[float], float], optionalThe time-dependent field, by default None.
td_opMatList, optionalThe time-dependent operator, by default None.
system_single_bath_q function

Spin-boson model with MCTDH.

Parameters ---------- fname : str The filename prefix for the output files. init_wfn : VecList The initial wavefunction. h : MatList The system Hamiltonian. op : MatList The observable. boson_bath : StarBosons The boson bath. td_f : Callable[[float], float], optional The time-dependent field, by default None. td_op : MatList, optional The time-dependent operator, by default None. **kwargs The parameters for the simulation.

system_single_bath_q(
          fname: str,
          init_wfn: VecList,
          sys_ham: MatList,
          sys_op: MatList,
          bath: StarBosons,
          td_f: Callable[[float], float] | None = None,
          td_op: MatList | None = None,
          **kwargs
      ) -> Generator[float, None, None]
ParameterTypeDescription
fnamestrThe filename prefix for the output files.
init_wfnVecListThe initial wavefunction.
hMatListThe system Hamiltonian.
opMatListThe observable.
boson_bathStarBosonsThe boson bath.
td_fCallable[[float], float], optionalThe time-dependent field, by default None.
td_opMatList, optionalThe time-dependent operator, by default None.
system_multibath function

Spin-boson-model-like model with one system DOF and multiple baths with MCTDH.

Parameters ---------- fname : str The filename prefix for the output files. init_wfn : VecList The initial wavefunction. h : MatList The system Hamiltonian. op : MatList The observable. boson_bath : StarBosons The boson bath. td_f : Callable[[float], float], optional The time-dependent field, by default None. td_op : MatList, optional The time-dependent operator, by default None. **kwargs The parameters for the simulation.

system_multibath(
          fname: str,
          init_wfn: VecList,
          sys_ham: MatList,
          sys_ops: list[MatList],
          baths: list[StarBosons],
          td_f: Callable[[float], float] | None = None,
          td_op: MatList | None = None,
          **kwargs
      ) -> Generator[float, None, None]
ParameterTypeDescription
fnamestrThe filename prefix for the output files.
init_wfnVecListThe initial wavefunction.
hMatListThe system Hamiltonian.
opMatListThe observable.
boson_bathStarBosonsThe boson bath.
td_fCallable[[float], float], optionalThe time-dependent field, by default None.
td_opMatList, optionalThe time-dependent operator, by default None.

tenso.bath

Bath utilities: spectral density construction, BCF decomposition into complex exponentials, and Bose–Einstein distribution evaluation.

tenso.bath.correlation

Object for handling the correlation function

Correlation class

This class represents a correlation function for a single bath which may be coupled to the system which is stored in a decomposed form such that `C(t) = \sum_k c_k e^{-\gamma_k}`, with `c_k` and `\gamma_k` being complex.

Attributes:

ParameterTypeDescription
coefficientslist, complexThe values of`c_k`
conj_coefficentslist, complexThe complex conjucates of coefficients
zeropointsInitial states of the bexcitons
derivativesdictionaryThe values of `\gamma_k` in a dictionary where the keys are the pair of integers [k, k] and the value is `\gamma_k.` Format as a dictionary is for historical reasons.
lindblad_rateExperimental parameter for use in more complicated equations of motion
Correlation() -> None

Methods:

Correlation.dump method

Outputs internal state of the correlation function to the output file.

dump(output_file: str) -> None
ParameterTypeDescription
output_filestringFile to write correlation function state to.
Correlation.remove_heom_terms method

Erases all coefficient, zeropoint, derivative and conjugate coefficient information from the correlation function. Note output is in TENSO's internal units.

remove_heom_terms() -> None
Correlation.load method

Imports information from a previously dumped correlation function file. Note that the imported file must be in TENSO's internal units.

load(input_file: str) -> None
ParameterTypeDescription
input_filestringFile formated as from :class: Correlation.dump
Correlation.manual_corr_setup method

Method to initialize the correlation function object if the form of the correlation function in exponential breakdown is already known. This is for an HEOM style bath, not a star boson style bath, and zeropoints will be set to 1. Any complex gamma_k values (within tolerance) will result in gamma_k^* being introduced as an additional feature with a coefficient of 0 and a conjugate coefficient of c_k*.

manual_corr_setup(
          c_ks: list[complex],
          gamma_ks: list[complex],
          unit_convert: bool = False
      )
ParameterTypeDescription
c_kslist[complex]list of c coefficients in the correlation function breakdown
gamma_kslist[complex]list of gamma exponential coefficients in the correlation function breakdown
unit_convertBooleanwhether to convert input to internal units
Correlation.k_max method

Returns the number of features in the correlation function.

k_max()
Correlation.add_discrete_vibration method
add_discrete_vibration(
          frequency: float,
          coupling: float,
          beta: Optional[float]
      ) -> None
Correlation.add_discrete_trigonometric method
add_discrete_trigonometric(
          frequency: float,
          coupling: float,
          beta: Optional[float]
      ) -> None
Correlation.add_spectral_densities method
add_spectral_densities(
          sds: list[SpectralDensity],
          distribution: BoseEinstein,
          zeropoint = 1.0,
          use_ht_function = False
      )
Correlation.add_trigonometric method
add_trigonometric(sds: list[SpectralDensity], distribution: BoseEinstein)
Correlation.real_correlation_function method

Get the real part of the correlation function at time 't'

real_correlation_function(t)
ParameterTypeDescription
tfloatThe time in internal units at which to evaluate the correlation function

Returns: float — The real part of the correlation function

Correlation.imag_correlation_function method

Get the imaginary part of the correlation function at time 't'

imag_correlation_function(t)
ParameterTypeDescription
tfloatThe time in internal units at which to evaluate the correlation function

Returns: float — The imarinary part of the correlation function

tenso.bath.distribution

Decomposition of Bose-Einstein distribution

BoseEinstein class
BoseEinstein(n: int = 0, beta: Optional[float] = None) -> None

Methods:

BoseEinstein.ht_function method
ht_function(w: NDArray) -> NDArray
BoseEinstein.function method
function(w: NDArray) -> NDArray
BoseEinstein.odd method
odd(w: NDArray) -> NDArray
BoseEinstein.even method
even(w: NDArray) -> NDArray
BoseEinstein.get_residues_poles method

The list of (-2 PI I) * residues and poles of the Bose-Einstein distribution with some rational approximant/expansion specified in `decomposition_method`.

Returns: tuple[list[complex], list[complex]] ((-2 PI I) * residues, poles) in the lower half-plane.

get_residues_poles() -> tuple[list[complex], list[complex]]
BoseEinstein.matsubara method
matsubara(n: int) -> tuple[NDArray, NDArray]
BoseEinstein.pade1 method
pade1(n: int) -> tuple[NDArray, NDArray]

tenso.bath.sd

Spectral density factory

SpectralDensity class

Template for a spectral density.

SpectralDensity()

Methods:

SpectralDensity.autocorrelation method
autocorrelation(t: float, beta: Optional[float] = None) -> complex
SpectralDensity.function method
function(w: complex) -> complex
SpectralDensity.get_residues_poles method

Get (-2 PI I * residues) and poles of the spectral density in the lower half-plane.

Returns: tuple[list[complex], list[complex]]: List of (-2 PI I * residues) and poles.

get_residues_poles() -> tuple[list[complex], list[complex]]
Drude class
Drude(reorganization_energy: float, relaxation: float) -> None

Methods:

Drude.function method
function(w: complex) -> complex
Drude.get_residues_poles method
get_residues_poles() -> tuple[list[complex], list[complex]]
UnderdampedBrownian class
UnderdampedBrownian(
          reorganization_energy: float,
          frequency: float,
          relaxation: float
      ) -> None

Methods:

UnderdampedBrownian.function method
function(w: complex) -> complex
UnderdampedBrownian.get_residues_poles method
get_residues_poles() -> tuple[list[complex], list[complex]]
OhmicExp class
OhmicExp(reorganization_energy: float, cutoff: float) -> None

Methods:

OhmicExp.function method
function(w: complex) -> complex
OhmicExp.get_residues_poles method
get_residues_poles()

tenso.bath.star

Diagonal Correlation function object.

StarBosons class
StarBosons() -> None

Methods:

StarBosons.get_reorganization_energy method
get_reorganization_energy() -> float
StarBosons.filter method
filter(underflow: float) -> None
StarBosons.degenerate method
degenerate(multiplicity: int)
StarBosons.dump method
dump(output_file: str) -> None
StarBosons.load method
load(input_file: str) -> None
StarBosons.k_max method
k_max()
StarBosons.add_discrete_vibrations method

ph_parameters: list[frequency, coupling]

add_discrete_vibrations(ph_parameters: list[tuple[float, float]], beta: Optional[float]) -> None
StarBosons.is_diagonalized method
is_diagonalized() -> bool
StarBosons.diagonalize method
diagonalize() -> None
StarBosons.total_reorganization_energy method
total_reorganization_energy() -> float
StarBosons.real_correlation_function method
real_correlation_function(t)
StarBosons.imag_correlation_function method
imag_correlation_function(t)
StarBosons.add_spectral_densities method

Add spectral densities to the diagonal correlation function.

Parameters ---------- sds : list[SpectralDensity] The spectral densities. beta : float The inverse temperature. n : int The number of discrete modes to compute. method : str The method to compute the diagonal correlation function. Currently, 'Fourier', 'LogFourier', 'EqualReorganizationEnergy' and 'Chebyshev' are supported. cutoff : float The cutoff frequency. (for the Chebyshev method) n_int : int The number of points for numerical integration. (for the Chebyshev method) shift_frequency : bool Shift the frequency space to avoid the zero-frequency component. (for the Fourier method) absorb_rate : float The absorption rate. (for the Chebyshev method)

add_spectral_densities(
          sds: list[SpectralDensity],
          beta: None | float,
          n: int,
          method = 'Fourier',
          cutoff: float | None = None,
          n_int: int = N_INT,
          shift_frequency: bool = True,
          log_base: int = 10,
          log_minimum_frequency: float | None = None,
          absorb_rate: float | None = ABSORB_RATE,
          int_grid_size: float | None = None,
          int_lower_bound: float | None = None
      ) -> None
ParameterTypeDescription
sdslist[SpectralDensity]The spectral densities.
betafloatThe inverse temperature.
nintThe number of discrete modes to compute.
methodstrThe method to compute the diagonal correlation function. Currently, 'Fourier', 'LogFourier', 'EqualReorganizationEnergy' and 'Chebyshev' are supported.
cutofffloatThe cutoff frequency. (for the Chebyshev method)
n_intintThe number of points for numerical integration. (for the Chebyshev method)
shift_frequencyboolShift the frequency space to avoid the zero-frequency component. (for the Fourier method)
absorb_ratefloatThe absorption rate. (for the Chebyshev method)
StarBosons.autocorrelation method
autocorrelation(t: float, t0: float = 0.0) -> complex
DiscretizationSolver class
DiscretizationSolver(
          w: NDArray,
          j: NDArray,
          beta: float | None,
          n_max: int
      )

Methods:

DiscretizationSolver.be_function method
be_function(x: NDArray) -> NDArray
DiscretizationSolver.get_star_parameters method
get_star_parameters() -> NotImplementedError
Tedopa class
Tedopa(
          w: NDArray,
          j: NDArray,
          beta: float | None,
          n_max: int
      )

Methods:

Tedopa.get_star_parameters method
get_star_parameters() -> tuple[NDArray, NDArray]
Tedopa.base_function method
base_function(k: int, t: NDArray) -> NDArray
EqualReorganizationEnergy class

Discretize the spectral density into finite modes with equal reorganization energy. Ref: https://doi.org/10.1002/jcc.24527

EqualReorganizationEnergy(
          sds: list[SpectralDensity],
          distr: BoseEinstein,
          n: int,
          int_grid_size: float | None = None
      ) -> None

Methods:

EqualReorganizationEnergy.lambda_w method
lambda_w(w: float) -> float
EqualReorganizationEnergy.jw method
jw(w)
EqualReorganizationEnergy.get_star_parameters method
get_star_parameters() -> tuple[NDArray, NDArray]
EqualReorganizationEnergy.base_function method
base_function(k: int, t: NDArray) -> NDArray
LogFourier class
LogFourier(
          sds: list[SpectralDensity],
          distr: BoseEinstein,
          cutoff_frequency: float,
          n: int,
          base: float = 10.0,
          minimum_frequency: float | None = None,
          _vibrations: Optional[list[tuple[float, float]]] = None
      ) -> None

Methods:

LogFourier.get_star_parameters method
get_star_parameters() -> tuple[NDArray, NDArray]
LogFourier.jw method
jw(w)
LogFourier.base_function method
base_function(k: int, t: NDArray) -> NDArray
Fourier class
Fourier(
          sds: list[SpectralDensity],
          distr: BoseEinstein,
          cutoff_frequency: float,
          n: int,
          shift: bool = True,
          zero_derivative: Optional[float] = None,
          _vibrations: Optional[list[tuple[float, float]]] = None
      ) -> None

Methods:

Fourier.get_star_parameters method
get_star_parameters() -> tuple[NDArray, NDArray]
Fourier.jw method
jw(w)
Fourier.base_function method
base_function(k: int, t: NDArray) -> NDArray
Chebyshev class
Chebyshev(
          w: NDArray,
          j: NDArray,
          beta: float | None,
          n_max: int,
          cutoff_frequency: float | None,
          absorb_rate: float | None = None
      ) -> None

Methods:

Chebyshev.get_star_parameters method
get_star_parameters() -> tuple[NDArray, NDArray]
Chebyshev.base_function method
base_function(k: int, t: NDArray) -> NDArray
LiftedChebyshev class
LiftedChebyshev(
          sds: list[SpectralDensity],
          beta: None,
          n: int,
          max_frequency: float,
          min_frequency: float = 0.0,
          _vibrations = None
      ) -> None

Methods:

LiftedChebyshev.get_star_parameters method
get_star_parameters() -> tuple[NDArray, NDArray]
LiftedChebyshev.autocorrelation method
autocorrelation(t: float) -> complex
LiftedChebyshev.jw method
jw(w)
LiftedChebyshev.c_mat method

(1j *) Derivatives connetions bewteen u_k(t).

c_mat()
LiftedChebyshev.derivative_mat method

(1j *) Derivatives connetions bewteen v_k(t).

derivative_mat()
LiftedChebyshev.eigen_pair method
eigen_pair()
LiftedChebyshev.reduce method
reduce(underflow)

tenso.bath.tedopa

Computing the chain map coefficients used in the (T-)TEDOPA algorithm. Note: This code does not pass the tests yet, and is not ready for production.

Tedopa class
Tedopa(
          w: NDArray,
          j: NDArray,
          beta: Optional[None],
          n_max: int
      )

Methods:

Tedopa.be_function method
be_function(beta: float, w: NDArray) -> NDArray
Tedopa.c0 method

Compute the zeroth-order coefficient.

c0() -> float
Tedopa.chain_frequency method

Compute the chain frequencies.

chain_frequency() -> NDArray
Tedopa.chain_coupling method

Compute the chain couplings.

chain_coupling() -> NDArray
Tedopa.chain_matrix method

Compute the chain matrix.

chain_matrix() -> NDArray
Tedopa.star_parameters method
star_parameters() -> NDArray
Tedopa.int method

Integrate a function with respect to the spectral density.

int(f: NDArray) -> float
Tedopa.generate_polynomials method

Generate the orthogonal polynomials.

generate_polynomials() -> None

tenso.heom

Core numerical engine: hierarchy-of-equations-of-motion derivative operators for single-bath, multi-bath, and interaction-picture propagation.

tenso.heom.eom

Generating the derivative of the extended rho in SoP formalism.

terminate function
terminate(tensor: OptArray, term_dict: dict[int, OptArray])
Hierachy class
Hierachy(
          frame: Frame,
          root: Node,
          sys_ket_end: End,
          sys_bra_end: End,
          bath_ends: list[End],
          sys_dim: int,
          bath_dims: list[int],
          bases: Optional[dict[End, Dvr]] = None
      ) -> None

Methods:

Hierachy.lvn_list method
lvn_list(sys_hamiltonian: ArrayLike) -> list[dict[End, OptArray]]
Hierachy.lindblad_list method
lindblad_list(sys_op: ArrayLike, lindblad_rate: float | None) -> list[dict[End, OptArray]]
Hierachy.i_heom_list method

Interaction picture of oscillating heom mode

i_heom_list(
          sys_op: ArrayLike,
          correlation: Correlation,
          metric: Literal['re', 'abs'] | complex = 're'
      ) -> list[dict[End, OptArray]]
Hierachy.heom_list method
heom_list(
          sys_op: ArrayLike,
          correlation: Correlation,
          metric: Literal['re', 'abs'] | complex = 're'
      ) -> list[dict[End, OptArray]]
Hierachy.initialize_state method

Assume Ends sys_i and sys_j are attached to the root node axes 0 and 1.

initialize_state(rdo: ArrayLike, rank: int) -> Model
Hierachy.get_rdo method
get_rdo(edo: Model) -> OptArray
FrameFactory class
FrameFactory(bath_dof: int) -> None

Methods:

FrameFactory.naive method
naive() -> tuple[Frame, Node]
FrameFactory.tree method
tree(bath_importances: None | list[int] = None, n_ary: int = 2) -> tuple[Frame, Node]
FrameFactory.train method
train() -> tuple[Frame, Node]
FrameFactory.custom method
custom() -> tuple[Frame, Node]

tenso.heom.meom

This file handles generating the derivative of the extend density operator with sum of products form operators.

terminate function
terminate(tensor: OptArray, term_dict: dict[int, OptArray])
Hierachy class
Hierachy(
          frame: Frame,
          root: Node,
          sys_ket_end: End,
          sys_bra_end: End,
          bath_ends: list[list[End]],
          sys_dim: int,
          bath_dims: list[list[int]],
          bases: Optional[dict[End, Dvr]] = None
      ) -> None

Methods:

Hierachy.lvn_list method
lvn_list(sys_hamiltonian: ArrayLike) -> list[dict[End, OptArray]]
Hierachy.lindblad_list method
lindblad_list(sys_op: ArrayLike, lindblad_rate: float | None) -> list[dict[End, OptArray]]
Hierachy.heom_list method
heom_list(
          n_bath: int,
          sys_op: ArrayLike,
          correlation: Correlation,
          metric: Literal['re', 'abs'] | complex = 're'
      ) -> list[dict[End, OptArray]]
Hierachy.initialize_state method

Initialize the state of the tensor network with the assumption that the system ends, sys_i and sys_j, are attached to the root node axes 0 and 1.

initialize_state(rdo: ArrayLike, rank: int) -> Model
Hierachy.get_rdo method
get_rdo(edo: Model) -> OptArray
FrameFactory class

This class produces the frame (tensor network graph structure) for use in a calculation of HEOM with multiple baths. :param bath_dofs: A list of integers associated with a degree of freedom :type bath_dofs: list, int :param bath_dof: The number of degrees of freedom total :type bath_dof: int :param sys_ket_end: String to identify the ket of the system in the graph :type sys_ket_end: string :param sys_bra_end: String to identify the bra of the system in the graph :param chained_bath_ends: List of identifying strings for bath degrees of freedom in the graph :type chained_bath_ends: list, string

Attributes:

ParameterTypeDescription
bath_dofslist, intA list of integers associated with a degree of freedom
bath_dofintThe number of degrees of freedom total
sys_ket_endstringString to identify the ket of the system in the graph
sys_bra_endString to identify the bra of the system in the graph
chained_bath_endslist, stringList of identifying strings for bath degrees of freedom in the graph
FrameFactory(bath_dofs: list[int]) -> None

Methods:

FrameFactory.naive method

Set up a graph structure with every node linked to the root node. :returns: A tuple containing the produced :class: Frame and the :class: Node :rtype: tuple

naive() -> tuple[Frame, Node]
FrameFactory.tree method

Set up a graph structure in the form of an n-ary Huffman tree (default is a binary tree). :param bath_importances: A list of which baths should be deemed most influential when constructing the Huffman tree :type bath_importances: list, optional :param n_ary: The number of links between nodes in the tree, defaults to 2 :type n_vary: int, optional :returns: A tuple containing the produced :class: Frame and the :class: Node :rtype: tuple

tree(bath_importances: None | list[int] = None, n_ary: int = 2) -> tuple[Frame, Node]
ParameterTypeDescription
bath_importanceslist, optionalA list of which baths should be deemed most influential when constructing the Huffman tree
n_aryThe number of links between nodes in the tree, defaults to 2

Returns: tuple — A tuple containing the produced :class: Frame and the :class: Node

FrameFactory.train method

Set up a graph structure in the form of a train. :returns: A tuple containing the produced :class: Frame and the :class: Node :rtype: tuple

train() -> tuple[Frame, Node]
FrameFactory.custom method
custom() -> tuple[Frame, Node]

tenso.heom.multieom

Generating the derivative of the extended rho in SoP formalism.

Hierachy class
Hierachy(
          frame: Frame,
          root: Node,
          sys_ket_ends: list[End],
          sys_bra_ends: list[End],
          bath_ends: list[list[End]],
          sys_dims: list[int],
          bath_dims: list[list[int]],
          bases: Optional[dict[End, Dvr]] = None
      ) -> None

Methods:

Hierachy.lvn_list method
lvn_list(sys_hamiltonians: list[None | ArrayLike], sys_couplings: list[dict[int, ArrayLike]]) -> list[dict[End, OptArray]]
Hierachy.lindblad_list method
lindblad_list(sys_ops: list[dict[int, ArrayLike]], lindblad_rates: list[float | None]) -> list[dict[End, OptArray]]
Hierachy.heom_list method
heom_list(
          sys_ops: list[dict[int, ArrayLike]],
          correlations: list[Correlation],
          metric: Literal['re', 'abs'] | complex = 're'
      ) -> list[dict[End, OptArray]]
Hierachy.initialize_pure_state method
initialize_pure_state(
          local_wfns: list[ArrayLike],
          rank: int,
          local_hs: None | list[None | ArrayLike] = None
      ) -> Model
Hierachy.get_rdo_element method
get_rdo_element(
          edo: Model,
          sys_is: list[None | int],
          sys_js: list[None | int]
      ) -> complex
Hierachy.get_rdo method
get_rdo(edo: Model) -> OptArray
FrameFactory class
FrameFactory(sys_dof: int, bath_dofs: list[int]) -> None

Methods:

FrameFactory.naive method
naive() -> tuple[Frame, Node]
FrameFactory.tree method
tree(importances: None | dict[End, int] = None, n_ary: int = 2) -> tuple[Frame, Node]
FrameFactory.train method
train(end_order: list[End]) -> tuple[Frame, Node]

tenso.state

Tree tensor network state representation.

tenso.state.pureframe

Data structure for topology of tensors in a network

Point class

An abstract class representing a vertex in the graph of the tensor network which is extended by Node and End.

Attributes:

ParameterTypeDescription
__cacheWeakValueDictionaryA weak valued dictionary with keyts of tuple[str, str] and values of Point
Point(name: Optional[str] = None) -> None
Node class

Class representing a vertex in the graph of the tensor network which has more than one neighbor. This extends :class: Point.

Node()
End class

Class representing a vertex in the graph of the tensor network which has only one neighbor. This extends :class: Point

End()
Frame class

Class which holds the topology of the tensor network graph, the :class: Nodes and :class: Ends and the edges that link them together.

Frame()

Methods:

Frame.copy method

Return a full copy of the Frame.

copy()
Frame.add_link method

Add a link between two :class: Points. :class: End can only have one link. :class: Node can have multiple links.

add_link(p: Point, q: Point) -> None
ParameterTypeDescription
p:class: PointFirst :class: Point to be connected.
1Second :class: Point to be connected.
Frame.points method

Get a set of all Points in the frame

points() -> set[Point]
Frame.nodes method

Get a set of all Nodes in the frame

nodes() -> set[Node]
Frame.ends method

Get a set of all Ends in the frame

ends() -> set[End]
Frame.degree method

Get the number of neighbors of a Node

degree(p: Node)
ParameterTypeDescription
p:class: NodeNode of inquiry

Returns: integer — Number of neighbors of p

Frame.dual method
dual(p: Point, i: None | int) -> tuple[Point, None | int]
Frame.axes method
axes(p: Point, q: Point) -> tuple[int, None | int]
Frame.near_points method
near_points(key: Point) -> list[Point]
Frame.near_nodes method

Get a list of all the :class: Nodes in the neighbor list of a given :class: Node, key

near_nodes(key: Node) -> list[Node]
ParameterTypeDescription
key:class: Node:class: Node to retrieve neighbor list for

Returns: list[Node] — The neighbor list of key

Frame.node_link_visitor method
node_link_visitor(start: Node) -> list[tuple[Node, int, Node, int]]
Frame.point_link_visitor method
point_link_visitor(start: Point) -> list[tuple[Point, int, Point, int]]
Frame.node_visitor method
node_visitor(start: Node, method: Literal['DFS', 'BFS'] = 'DFS') -> list[Node]
Frame.point_visitor method
point_visitor(start: Node, method: Literal['DFS', 'BFS'] = 'DFS') -> list[Node]
Frame.get_node_depths method
get_node_depths(start: Node) -> dict[Node, int]
Frame.get_node_axes method
get_node_axes(start: Point) -> dict[Node, Optional[int]]
Frame.get_graph method
get_graph() -> dict[Node, list[Point]]
Frame.construct_from_graph method
construct_from_graph(graph: dict[Node, list[Point]]) -> None

tenso.state.puremodel

triangular function

Produces a Generator which yields the natural number in a triangular order.

triangular(n_list)
ParameterTypeDescription
n_listList of integers "type n_list: list
zeros_model function

Produce a model with the specified shapes given by a dictionary and all zero valuations. The dimension for each Edge is given in dims with adefault of 1.

zeros_model(shapes: dict[Node, list[int]]) -> Model
eye_model function

Get a model with an identity-matrix like valuation.

eye_model(
          frame: Frame,
          root: Node,
          shapes: dict[Node, list[int]]
      ) -> Model
Model class

A class representing a, Model, a :class: Frame with valuation for each Node.

Model(valuation: dict[Node, OptArray] | Iterable[tuple[Node, OptArray]]) -> None

Methods:

Model.save method

Save the model to a file.

save(filename: str) -> None
Model.load method

Load the model from a file.

load(filename: str) -> Model
Model.nodes method
nodes() -> set[Node]
Model.shape method
shape(p: Node) -> list[int]
Model.order method
order(p: Node) -> int
Model.dimension method
dimension(p: Node, i: int) -> int
Model.copy method

Produce a shallow copy of the model.

copy() -> Model
Model.conjugate method

Take the conjugate the model by complex conjugation of all tensor valuations.

conjugate() -> Model
Model.substitute method
substitute(valuation: dict[Node, OptArray] | Iterable[tuple[Node, OptArray]]) -> Model
Model.update method

Update the valuation of the model.

update(valuation: dict[Node, OptArray] | Iterable[tuple[Node, OptArray]]) -> None
Model.zero_like method
zero_like() -> Model

tenso.operator

Sparse operator utilities.

tenso.operator.sparse

SparseSPO class

Class representing the sum of products form operator.

Attributes:

ParameterTypeDescription
op_listdictionaryList of dictionaries where keys are the ends in the tensor network and values are the associated operators in tensor form
initial_timefloat, optionalStart time for the propagation, defaults to 0.0
f_listcallableFunctions representing time dependent operator parts with the
SparseSPO(
          op_list: list[dict[End, OptArray]],
          f_list: None | Callable[[float], list[dict[End, OptArray]]] = None,
          initial_time: float = 0.0
      ) -> None

Methods:

SparseSPO.get_ti_terms method

Return time independent operators in the sum of products form.

tensor form

get_ti_terms() -> list[dict[End, OptArray]]
SparseSPO.get_td_terms method

Returns the time dependent operators in the sum of products form.

tensor form

get_td_terms(t: float) -> list[dict[End, OptArray]]
SparseSPO.ends method
ends() -> set[End]
SPOKet class

Intermediate class for the sparse operations in the model.

SPOKet(
          op: SparseSPO,
          state: Model,
          frame: Frame,
          root: Node,
          time = 0.0
      )

Methods:

SPOKet.canonicalize method

Canonicalize the state.

canonicalize() -> None
SPOKet.close_with_bra method

Calculate the inner product.

close_with_bra(bra: Model | None = None) -> complex
SPOKet.close_with_conj method

Calculate the inner product.

close_with_conj(bras: SPOKet) -> complex
ListModelInnerProduct class

Class used to calculate the inner product of the system.

ListModelInnerProduct(
          frame: Frame,
          root: Node,
          ket_states: list[Model],
          bra_states: list[Model] | None = None
      )

Methods:

ListModelInnerProduct.forward method

Actuall calculate the inner product.

forward() -> complex
SparseSandwich class
SparseSandwich(
          frame: Frame,
          root: Node,
          ket_state: Model,
          bra_state: Model | None = None,
          op: SparseSPO | None = None,
          time = 0.0
      )

Methods:

SparseSandwich.forward method

Calculate the inner product.

forward() -> complex
SparsePropagator class
SparsePropagator(
          op: SparseSPO,
          state: Model,
          frame: Frame,
          root: Node,
          renormalize_root = False,
          init_time = 0.0
      ) -> None

Methods:

SparsePropagator.info method
info()
SparsePropagator.update_settings method
update_settings(**kwargs)
SparsePropagator.renormalize_root method
renormalize_root()
SparsePropagator.update_size_list method
update_size_list()
SparsePropagator.update_td_terms method
update_td_terms(time: float) -> None
SparsePropagator.propagate method
propagate(
          end: float,
          dt: float,
          ps_method: Literal['vmf', 'ps1', 'ps2'] = 'vmf'
      ) -> Generator[tuple[float, Model], None, None]
SparsePropagator.adaptive_propagate method
adaptive_propagate(
          end: float,
          fixed_dt: float,
          fixed_ps_method: Literal['ps1', 'vmf'] = 'vmf',
          fixed_steps: int = 1,
          adaptive_dt: float | None = None,
          adaptive_ps_steps: int = 1
      ) -> Generator[tuple[float, Model], None, None]
SparsePropagator.mixed_propagate method
mixed_propagate(
          end: float,
          dt: float,
          ending_ps_method: Literal['ps2', 'ps1', 'vmf'] = 'ps1',
          starting_dt: float | None = None,
          starting_ps_method: Literal['ps1', 'ps2'] = 'ps2',
          max_starting_rank: int | None = None,
          max_starting_steps: int | None = None
      ) -> Generator[tuple[float, Model], None, None]
SparsePropagator.vmf_step method
vmf_step(dt: float) -> None
SparsePropagator.ps1_step method
ps1_step(dt: float) -> None
SparsePropagator.ps2_step method
ps2_step(dt: float) -> None
DynamicalSparsePropagator class
DynamicalSparsePropagator(
          op: SparseSPO,
          state: Model,
          frame: Frame,
          root: Node,
          renormalize_root = False,
          init_time = 0.0
      ) -> None

tenso.basis

Discrete variable representation (DVR) grids.

tenso.basis.dvr

A simple implementation of a discrete variable representation integrator based on the implementation found in the Heidelberg MCTDH documentation. References ---------- .. [1] http://www.pci.uni-heidelberg.de/tc/usr/mctdh/lit/NumericalMethods.pdf

DiscreteVariationalRepresentation class

Abstract class for any discrete variable representation basis.

DiscreteVariationalRepresentation(num: int) -> None

Methods:

DiscreteVariationalRepresentation.q_mat method

Get the position operator in DVR basis.

q_mat() -> NDArray
DiscreteVariationalRepresentation.dq_mat method
dq_mat() -> NDArray
DiscreteVariationalRepresentation.dq2_mat method
dq2_mat() -> NDArray
DiscreteVariationalRepresentation.creation_mat method

Get the creation operator in the DVR basis

creation_mat() -> NDArray
DiscreteVariationalRepresentation.annihilation_mat method

Get the annihilation operator in the DVR basis

annihilation_mat() -> NDArray
DiscreteVariationalRepresentation.fock2dvr_mat method
fock2dvr_mat() -> NDArray
DiscreteVariationalRepresentation.eigen2dvr_mat method
eigen2dvr_mat(ham) -> NDArray
DiscreteVariationalRepresentation.fbr_func method

Get the `i`-th finite basis representation function

fbr_func(i: int) -> Callable[[NDArray], NDArray]
ParameterTypeDescription
iintegerFunction to retrieve

Returns: Callable — The `i`-th FBR function

DiscreteVariationalRepresentation.numberer_mat method
numberer_mat() -> NDArray
SincDVR class

Class for performing the universal Sinc DVR basis of Colbert and Miller (1982)

SincDVR(
          start: float,
          stop: float,
          num: int
      ) -> None

Methods:

SincDVR.dq_mat method

Get the volume element `d/dq` matrix, alternately -i times momentum, in the DVR basis

dq_mat() -> NDArray
SincDVR.dq2_mat method

Get the square volume element `d2/dq2` matrix, alternately -momentum^2, in the DVR basis

dq2_mat() -> NDArray
SineDVR class

Class for the Sine-DVR

SineDVR(
          start: float,
          stop: float,
          num: int
      ) -> None

Methods:

SineDVR.q_mat method

Get the position operator, q in the DVR basis.

q_mat() -> NDArray
SineDVR.abs_q_mat method

Get the absolute value of the position operator, q in the DVR basis.

abs_q_mat() -> NDArray
SineDVR.abs_dq_mat method

q in DVR basis.

abs_dq_mat() -> NDArray
SineDVR.dq_mat method

Get the volume element `d/dq` matrix, alternately -i times momentum, in the DVR basis

dq_mat() -> NDArray
SineDVR.dq2_mat method

Get the square volume element `d2/dq2` matrix, alternately `-p^2`, in the DVR basis

dq2_mat() -> NDArray
SineDVR.t_mat method

Return the kinetic energy matrix in the DVR basis in internal energy units.

t_mat()
SineDVR.fock2dvr_mat method
fock2dvr_mat() -> NDArray
SineDVR.height method
height()
SineDVR.fbr_func method

`i`-th FBR basis function.

fbr_func(i: int) -> Callable[[NDArray], NDArray]
SineDVR.fbr2cont method

Transform a vector from FBR to the spatial function.

fbr2cont(vec)
SineDVR.dvr2cont method
dvr2cont(vec)

tenso.mctdh

ML-MCTDH alternative propagator.

tenso.mctdh.eom

Generating the derivative of the extended rho in SoP formalism.

trace function

Complex conjugate not included

trace(
          tensor1: OptArray,
          tensor2: OptArray,
          ax: int
      ) -> OptArray
Hierachy class
Hierachy(
          frame: Frame,
          root: Node,
          sys_ends: list[End],
          bath_ends: list[list[End]],
          sys_dims: list[int],
          bath_dims: list[list[int]]
      ) -> None

Methods:

Hierachy.get_densities method
get_densities(state: Model) -> dict[Point, OptArray]
Hierachy.tdse_list method
tdse_list(sys_hamiltonians: list[None | ArrayLike], sys_couplings: list[dict[int, ArrayLike]]) -> list[dict[End, OptArray]]
Hierachy.heom_list method
heom_list(sys_ops: list[dict[int, ArrayLike]], correlations: list[StarBosons]) -> list[dict[End, OptArray]]
Hierachy.bath_q_list method
bath_q_list(correlations: list[StarBosons]) -> list[dict[End, OptArray]]
Hierachy.bath_q2_list method
bath_q2_list(correlations: list[StarBosons]) -> list[dict[End, OptArray]]
Hierachy.initialize_pure_state method
initialize_pure_state(
          local_wfns: list[ArrayLike],
          rank: int,
          local_hs: None | list[None | ArrayLike] = None
      ) -> Model
FrameFactory class
FrameFactory(sys_dof: int, bath_dofs: list[int]) -> None

Methods:

FrameFactory.naive method
naive() -> tuple[Frame, Node]
FrameFactory.tree method
tree(importances: None | dict[End, int] = None, n_ary: int = 2) -> tuple[Frame, Node]
FrameFactory.train method
train(end_order: list[End]) -> tuple[Frame, Node]

tenso.libs

Shared back-end helpers: units, array back-end, logging, drawing, utilities.

tenso.libs.quantity

Objects and functions handling transformation between default, external units and internal TENSO units

Quantity class
Quantity(value: float, unit: Optional[str] = None) -> None

Methods:

Quantity.standardize method

Search the list of synonyms for units that may be supplied and choose the standard representation for that unit. :param unit: Potentially non-standard string representing a unit :type unit: string, optional :returns: The standardized string representing the unit :rtype: string

standardize(unit: Optional[str]) -> Optional[str]
ParameterTypeDescription
unitstring, optionalPotentially non-standard string representing a unit

Returns: string — The standardized string representing the unit

Quantity.au method

Return the value in atomic units.

au() -> float
Quantity.convert_to method

Change the value in the given unit to atomic units. :param unit: The current unit in use :type unit: string, optional

convert_to(unit: Optional[str] = None) -> Quantity
ParameterTypeDescription
unitstring, optionalThe current unit in use
Quantity.to method

Change the value in the given unit to atomic units. :param unit: The current unit in use :type unit: string, optional

to(unit: Optional[str] = None) -> Quantity
ParameterTypeDescription
unitstring, optionalThe current unit in use

tenso.libs.backend

Backend for accelerated array-operations.

opt_to_numpy function

Transform a pytorch tensor to a numpy array

opt_to_numpy(array: OptArray) -> NDArray
ParameterTypeDescription
OptArrayOptArrayInput numpy array

Returns: array — Equivalent numpy array

opt_array function

Transform an array like to a pytorch tensor

opt_array(array: ArrayLike) -> OptArray
ParameterTypeDescription
arrayArrayLikeArray to transform

Returns: :class: OptArray — Equivalent pytorch tensor

opt_zeros function

Get a pytorch tensor with zeros in the given shape (wraps torch.zeros)

opt_zeros(shape: list[int]) -> OptArray
ParameterTypeDescription
shapelist[int]List of dimensions of the tensor

Returns: :class: OptArray — Tensor of zeros in pytorch form

opt_cat function

Stack the listed tensors along the zeroth dimension leading to a tensor with the same number of dimensions as the input tensors, all of which must be the same size except along the dimension to concatenate (wraps torch.cat)

opt_cat(tensors: list[OptArray]) -> OptArray
ParameterTypeDescription
tensors:class: OptArrayInput pytorch tensors to concatenate

Returns: :class: OptArray — Concatenated tensors

opt_stack function

Stack the listed tensors along a new dimension leading to a tensor with one additional dimensions than the input tensors, all of which must be the same size except along the dimension to concatenate (wraps torch.stack)

opt_stack(tensors: list[OptArray] | tuple[OptArray, ...]) -> OptArray
ParameterTypeDescription
tensorslist[:class: OptArray] or tuple[:class: OptArray]Input pytorch tensors to concatenate

Returns: :class: OptArray — Stacked tensors, with the new dimension being the first dimension

opt_split function

Split a tensor into pieces along dimension zero (wraps torch.split)

opt_split(tensors: OptArray, size_list: list[int]) -> list[OptArray]
ParameterTypeDescription
tensors:class: OptArrayInput pytorch tensor to break up

Returns: list[:class: OptArray] — A list of the broken up tensors

opt_einsum function

Perform an Einstein summation over the tensors provided (wraps torch.einsum, see documentation for torch.einsum)

opt_einsum(*args) -> OptArray
ParameterTypeDescription
argsvariesThe required string specification for how to perform the eigensum followed by the tensors to operator on
opt_sum function

Sum over all elements along the given dimension of the tensor (wraps torch.sum)

opt_sum(array: OptArray, dim: int) -> OptArray
ParameterTypeDescription
array:class: OptArrayTensor with elements to sum

Returns: Tensor after summation along requested dimension :rtye: :class: OptArray

opt_tensordot function

Perform a tensor contraction over tensors a and b along the dimensions specified by axes

opt_tensordot(
          a: OptArray,
          b: OptArray,
          axes: tuple[list[int], list[int]]
      ) -> OptArray
ParameterTypeDescription
a:class: OptArrayfirst tensor to contract
b:class: OptArraysecond tensor to contract
axestuble[list[int]]Tuple of lists specifying which dimensions of a and b to perform a contraction over

Returns: :class: OptArray — The requested tensor after contraction

opt_svd function

Perform singular value decomposition (SVD) on the input array without full matrices.

Args: a (OptArray): The input array.

Returns: tuple[OptArray, OptArray, OptArray]: A tuple containing the left singular vectors, singular values, and right singular vectors. Note that the singular values are of the real type.

opt_svd(a: OptArray) -> tuple[OptArray, OptArray, OptArray]
opt_odeint function

Selection of method and parameters for the ordinary differential equation solver Avaliable method: - Home-made integrators: - `iterX` Taylor series up to `X`-th order. - `rk4` Fourth-order Runge-Kutta with 3/8 rule. - Adaptive-step from `torchdiffeq`: - `dopri8` Runge-Kutta 7(8) of Dormand-Prince-Shampine - `dopri5` Runge-Kutta 4(5) of Dormand-Prince. - `bosh3` Runge-Kutta 2(3) of Bogacki-Shampine - `adaptive_heun` Runge-Kutta 1(2) - Fixed-step `torchdiffeq`: - `euler` Euler method. - `midpoint` Midpoint method. - `explicit_adams` Explicit Adams. - `implicit_adams` Implicit Adams. - Scikit.odes/SUNDIALS compatable method (using numpy.array) slow but may handle stiff equations better: - 'cvode' CVODE - 'bdf' Backward Differentiation Formula - 'admo' Adams-Moulton - 'rk8' Runge-Kutta 7(8) - 'rk5' Runge-Kutta 4(5)

opt_odeint(
          func: Callable[[float, OptArray], OptArray],
          t0: float,
          y0: OptArray,
          dt: float,
          atol: float,
          rtol: float,
          method: str = 'dopri5'
      ) -> OptArray
opt_pinv function

Perofrm Moore-Penrose pseudoinverse of the tensor

opt_pinv(a: OptArray, atol) -> OptArray
ParameterTypeDescription
a:class: OptArrayTensor to invert

Returns: :class: OptArray — Tensor pseudoinverse

opt_inv function

Invert the given tensor or throws an error (wraps torch.linalg.inv)

opt_inv(a: OptArray) -> OptArray
ParameterTypeDescription
a:class: OptArrayTensor to invert

Returns: :class: OptArray — Inverted tensor

opt_transform function

Perform a tensor contraction over the specified axes of input tensors then rearrange the dimensions to place the last dimension at the location of contraction

opt_transform(
          op: OptArray,
          tensor: OptArray,
          op_ax: int,
          tensor_ax: int
      )
ParameterTypeDescription
op:class: OptArraySecond tensor in contraction
tensor:class: OptArrayFirst tensor in contraction
op_axintegerContraction dimension of op
tensor_axintegerContraction dimension of tensor

Returns: :class: OptArray — The contracted and rearranged tensor

opt_multitransform function

Perform a series of tensor contractions and rearrangements by repeated calls to opt_transform referencing a dictionary of dimensions to contract and tensors to contract with

opt_multitransform(op_dict: dict[int, OptArray], tensor: OptArray) -> OptArray
ParameterTypeDescription
op_dictdictionary[integer, :class: OptArray]Dictionary associating a dimension with a tensor for transformation
tensor:class: OptArrayTensor on which to carry out transformations

Returns: :class: OptArray — Result of performing the series of transformations

opt_eye function

Obtain a two dimensional identity tensor (wraps torch.eye)

opt_eye(dim1: int, dim2: int | None = None) -> OptArray
ParameterTypeDescription
dim1integerNumber of rows
dim2integerNumber of columns

Returns: :class: OptArray — Two dimensional identity tensor

opt_trace function

Complex conjugate not included

opt_trace(
          tensor1: OptArray,
          tensor2: OptArray,
          ax: int
      ) -> OptArray
opt_inner_product function
opt_inner_product(tensor1: OptArray, tensor2: OptArray) -> complex

tenso.libs.utils

This file includes miscellaneous utility functions without another obvious home.

lazyproperty function

Experimental function to implement just in time evaluation of a property (lazy evaluation)

lazyproperty(func: Callable[..., T]) -> Callable[..., T]
count_calls function

Debugging function used to measure call counts

count_calls(f: Callable[..., T]) -> Callable[..., T]
iter_round_visitor function

Generator used as a round-trip tree visitor with the 'DFS' (depth first search) method

iter_round_visitor(start: T, r: Callable[[T], list[T]]) -> Generator[tuple[T, bool], None, None]
ParameterTypeDescription
start:class: NodeThe object to begin search from
rCallableCallable relation function taking start and returning the neighbor list of start

Returns: :class: Node — A tuple containing the next node in the tree

iter_visitor function

Generator used as an iterative visitor supporting depth first or breadth first

iter_visitor(
          start: T,
          r: Callable[[T], list[T]],
          method: Literal['DFS', 'BFS'] = 'DFS'
      ) -> Generator[T, None, None]
ParameterTypeDescription
start:class: NodeThe object to begin search from
rCallableCallable relation function taking start and returning the neighbor list of start
methodstringEither 'DFS', depth first, or 'BFS', breadth first method, will be used

Returns: :class: Node — A tuple containing the next node in the tree

depths function

Iteratively generate the depth of each component in the tree

depths(start: T, r: Callable[[T], list[T]]) -> dict[T, int]
ParameterTypeDescription
start:class: NodeThe object to begin search from
rCallableCallable relation function taking start and returning the neighbor list of start

Returns: dictionary — Dictionary where keys are :class: Nodes in the tree and values are their depths

path function

Determine the path through the tree between the :class: Nodes start and stop

path(
          start: T,
          stop: T,
          r: Callable[[T], list[T]]
      ) -> None | list[T]
ParameterTypeDescription
start:class: NodeThe object to begin search from
start:class: NodeThe object to search for
rCallableCallable relation function taking start and returning the neighbor list of start

Returns: list or None — Nothing if start and stop are the same, otherwise a list containing the path between start and stop

huffman_tree function

Generate a Tree for the sources as leaves using Huffman coding method.

huffman_tree(
          sources: list[T],
          new_obj: Callable[[], T],
          importances: Optional[list[int]] = None,
          n_ary: int = 2
      ) -> tuple[OrderedDict[T, list[T]], T]
ParameterTypeDescription
sourceslist of :class: EndsThe leaves, :class: Ends, for the tree
importanceslist[int], OptionalImportance ranking of the leaves to guide generation
n_aryintOrder of the tree (how many links an interior :class: Node should have)

Returns: tuple[OrderedDict, :class: Node] — The tree as a tuple containing 1. an ordered dictionary representing the graph where each key is a :class: Node and the values are a list of :class: Nodes representing its neighbors 2. the root of the tree

unzip function

The same as zip(*iter) but returns iterators, instead of expand the iterator. Mostly used for large sequence. Reference: https://gist.github.com/andrix/1063340

unzip(iterable: Iterable) -> Iterable[Iterable]

tenso.libs.drawing

A tool to draw graphs from the Frames

visualize_frame function

Function to draw a simple representation of the graph structure of a given frame to a pdf file.

visualize_frame(frame: Frame, fname = 'frame_graph_output')
ParameterTypeDescription
frame:class: FrameThe :class: Frame whose graph is to be drawn
fnamestringThe file name where the graph will be drawn, default 'frame_graph_output'

tenso.libs.logging

Interface to logging package.

Logger class

Class used to interface with infrastructure for logging at various levels of verbosity ranging from `debug` to `critical`.

Attributes:

ParameterTypeDescription
levelLiteralThe degree of information to log with options being `debug`, `info`, `warning`, `error` and `critical`
filenamestring, optionalFile for logging
stream_fmtstring, optionalFormating string for the stream
file_fmtstring, optionalFile formatting string, default `%(message)s`
Logger(
          filename: Optional[str] = None,
          level: Literal['debug', 'info', 'warning', 'error', 'critical'] = 'info',
          stream_fmt: Optional[str] = None,
          file_fmt: str = '%(message)s'
      )

Methods:

Logger.info method

Log an info message.

info(message: str)
ParameterTypeDescription
strstringMessage to log
Logger.debug method

Log a debug message.

debug(message: str)
ParameterTypeDescription
strstringMessage to log
Logger.warning method

Log a warning message.

warning(message: str)
ParameterTypeDescription
strstringMessage to log
Logger.error method

Log an error message.

error(message: str)
ParameterTypeDescription
strstringMessage to log
Logger.critical method

Log a critical message.

critical(message: str)
ParameterTypeDescription
strstringMessage to log