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:
- Prototypes — high-level entry points that assemble a complete simulation from a few keyword arguments.
- HEOM + State + Operator — the core numerical engine: hierarchy management, TTN state representation, and TDVP propagators.
- Bath — bath correlation function decomposition and spectral density utilities.
- Basis / ML-MCTDH / Libs — DVR grids, the ML-MCTDH alternative propagator, and shared back-end helpers.
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
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
| Parameter | Type | Description |
|---|---|---|
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. |
Returns: Correlation The correlation function for the comb-like spectral density.
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
| Parameter | Type | Description |
|---|---|---|
include_drude | | Whether to include the Drude term for the low-frequency modes, defaults to True |
re_d | list[float] | Reorganization energy of every Drude mode |
width_d | list[float] | Cutoff frequencies of every Drude mode |
include_brownian | bool | Whether to include the Brownian term for the high-frequency modes |
freq_b | list[float] | Frequencies of every Brownian mode |
re_b | list[float] | Reorganization energy of every Brownian mode |
width_b | list[float] | Width of every Brownian modes |
include_discrete | boolean | Whether to include the discrete vibrational mode, defaults to True |
freq_v | list[float] | Frequency of every discrete vibrational mod |
re_v | list[float] | Reorganization energy of every discrete vibrational mode |
temperature | float | Temperature of the bath |
decomposition_method | string | Method to decompose the Bose-Einstein distribution, either 'Pade' or 'Matsubara' |
n_ltc | int | Number of low-temperature correction terms in the decomposition of the Bose-Einstein distribution |
include_lindblad | boolean | Whether to include the Lindblad rate as in Tanimura's HEOM, defaults to False |
use_cross | boolean | Whether to use the cross-correlation that includes the trigonometric functions, defaults to False |
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, defaults to False |
Returns: :class: Correlation — The correlation function for the composite spectral density.
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
| Parameter | Type | Description |
|---|---|---|
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. |
Returns: StarBosons The correlation function for the composite spectral density.
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
| Parameter | Type | Description |
|---|---|---|
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. |
Returns: Correlation The correlation function for the composite spectral density.
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
| Parameter | Type | Description |
|---|---|---|
include_drude | boolean | Whether to include the Drude term for the low-frequency modes. |
re_d | list[float] | Reorganization energies of the Drude modes as a list |
width_d | list[float] | Cutoff frequencies of the Drude modes. |
include_brownian | | Whether to include the Brownian term for the high-frequency modes, defaults to True |
freq_b | list[float] | Frequencies of the Brownian modes as a list |
re_b | list[float] | Reorganization energies of the Brownian modes as a list |
width_b | list[float] | Broadening of the Brownian modes |
include_discrete | bool | Whether to include the discrete vibrational modes, defaults to True |
freq_v | list[float] | Frequencies of the discrete vibrational modes |
re_v | list[float] | Reorganization energies of the discrete vibrational modes. |
temperature | float | Temperature of the bath. |
cutoff | float | Cutoff frequency for the spectral density. Frequencies above this will not be considered |
n_discretization | int | Number of discretization points for the spectral density. |
ohmic_type | string | Type of the Drude term. Allowed values are `Lorentz` (Drude-Lorentz) and `Exp` (Ohmic with exponential cutoff), defaults to `Lorentz` |
shift_frequency | boolean | Whether to shift the frequency to the positive domain. |
Returns: :class: StarBosons — StarBosons, the correlation function for the composite spectral density.
tenso.prototypes.heom
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]
| Parameter | Type | Description |
|---|---|---|
fname | str | The output file name. |
init_rdo | MatList | The initial reduced density operator. |
h | MatList | The system Hamiltonian. |
op | MatList | The system operator in the system-bath interaction hamiltonian. |
bath_correlation | :class: Correlation | The bath correlation function for HEOM. |
td_f | Callable[[float], float] | None | The time-dependent field. |
Matlist | | The operator associated with the time-dependent field, default none. |
kwargs | dictionary | Other settings. See `default_parameters.py` for details. |
Returns: float — The current time in unit in `default_parameters.py`.
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]
| Parameter | Type | Description |
|---|---|---|
fname | str | The output file name. |
init_rdo | MatList | The initial reduced density operator. |
h | MatList | The system Hamiltonian. |
op | MatList | The system operator in the system-bath interaction hamiltonian. |
bath_correlation | :class: Correlation | The bath correlation function for HEOM. |
td_f | Callable[[float], float] | None | The time-dependent field. |
td_op | MatList | None | The operator associated with the time-dependent field. |
kwargs | dict | Other settings. See `default_parameters.py` for details. |
Returns: float — The current time in unit in `default_parameters.py`.
tenso.prototypes.mctdh
MCTDH interface functions
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]
| Parameter | Type | Description |
|---|---|---|
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. |
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]
| Parameter | Type | Description |
|---|---|---|
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. |
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]
| Parameter | Type | Description |
|---|---|---|
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. |
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
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:
| Parameter | Type | Description |
|---|---|---|
coefficients | list, complex | The values of`c_k` |
conj_coefficents | list, complex | The complex conjucates of coefficients |
zeropoints | | Initial states of the bexcitons |
derivatives | dictionary | The 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_rate | | Experimental parameter for use in more complicated equations of motion |
Correlation() -> None
Methods:
Outputs internal state of the correlation function to the output file.
dump(output_file: str) -> None
| Parameter | Type | Description |
|---|---|---|
output_file | string | File to write correlation function state to. |
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
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
| Parameter | Type | Description |
|---|---|---|
input_file | string | File formated as from :class: Correlation.dump |
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
)
| Parameter | Type | Description |
|---|---|---|
c_ks | list[complex] | list of c coefficients in the correlation function breakdown |
gamma_ks | list[complex] | list of gamma exponential coefficients in the correlation function breakdown |
unit_convert | Boolean | whether to convert input to internal units |
Returns the number of features in the correlation function.
k_max()
add_discrete_vibration(
frequency: float,
coupling: float,
beta: Optional[float]
) -> None
add_discrete_trigonometric(
frequency: float,
coupling: float,
beta: Optional[float]
) -> None
add_spectral_densities(
sds: list[SpectralDensity],
distribution: BoseEinstein,
zeropoint = 1.0,
use_ht_function = False
)
add_trigonometric(sds: list[SpectralDensity], distribution: BoseEinstein)
Get the real part of the correlation function at time 't'
real_correlation_function(t)
| Parameter | Type | Description |
|---|---|---|
t | float | The time in internal units at which to evaluate the correlation function |
Returns: float — The real part of the correlation function
Get the imaginary part of the correlation function at time 't'
imag_correlation_function(t)
| Parameter | Type | Description |
|---|---|---|
t | float | The 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(n: int = 0, beta: Optional[float] = None) -> None
Methods:
ht_function(w: NDArray) -> NDArray
function(w: NDArray) -> NDArray
odd(w: NDArray) -> NDArray
even(w: NDArray) -> NDArray
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]]
matsubara(n: int) -> tuple[NDArray, NDArray]
pade1(n: int) -> tuple[NDArray, NDArray]
tenso.bath.sd
Spectral density factory
Template for a spectral density.
SpectralDensity()
Methods:
autocorrelation(t: float, beta: Optional[float] = None) -> complex
function(w: complex) -> complex
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(reorganization_energy: float, relaxation: float) -> None
Methods:
function(w: complex) -> complex
get_residues_poles() -> tuple[list[complex], list[complex]]
UnderdampedBrownian(
reorganization_energy: float,
frequency: float,
relaxation: float
) -> None
Methods:
function(w: complex) -> complex
get_residues_poles() -> tuple[list[complex], list[complex]]
OhmicExp(reorganization_energy: float, cutoff: float) -> None
Methods:
function(w: complex) -> complex
get_residues_poles()
tenso.bath.star
Diagonal Correlation function object.
StarBosons() -> None
Methods:
get_reorganization_energy() -> float
filter(underflow: float) -> None
degenerate(multiplicity: int)
dump(output_file: str) -> None
load(input_file: str) -> None
k_max()
ph_parameters: list[frequency, coupling]
add_discrete_vibrations(ph_parameters: list[tuple[float, float]], beta: Optional[float]) -> None
is_diagonalized() -> bool
diagonalize() -> None
total_reorganization_energy() -> float
real_correlation_function(t)
imag_correlation_function(t)
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
| Parameter | Type | Description |
|---|---|---|
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) |
autocorrelation(t: float, t0: float = 0.0) -> complex
DiscretizationSolver(
w: NDArray,
j: NDArray,
beta: float | None,
n_max: int
)
Methods:
be_function(x: NDArray) -> NDArray
get_star_parameters() -> NotImplementedError
Tedopa(
w: NDArray,
j: NDArray,
beta: float | None,
n_max: int
)
Methods:
get_star_parameters() -> tuple[NDArray, NDArray]
base_function(k: int, t: NDArray) -> NDArray
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:
lambda_w(w: float) -> float
jw(w)
get_star_parameters() -> tuple[NDArray, NDArray]
base_function(k: int, t: NDArray) -> NDArray
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:
get_star_parameters() -> tuple[NDArray, NDArray]
jw(w)
base_function(k: int, t: NDArray) -> NDArray
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:
get_star_parameters() -> tuple[NDArray, NDArray]
jw(w)
base_function(k: int, t: NDArray) -> NDArray
Chebyshev(
w: NDArray,
j: NDArray,
beta: float | None,
n_max: int,
cutoff_frequency: float | None,
absorb_rate: float | None = None
) -> None
Methods:
get_star_parameters() -> tuple[NDArray, NDArray]
base_function(k: int, t: NDArray) -> NDArray
LiftedChebyshev(
sds: list[SpectralDensity],
beta: None,
n: int,
max_frequency: float,
min_frequency: float = 0.0,
_vibrations = None
) -> None
Methods:
get_star_parameters() -> tuple[NDArray, NDArray]
autocorrelation(t: float) -> complex
jw(w)
(1j *) Derivatives connetions bewteen u_k(t).
c_mat()
(1j *) Derivatives connetions bewteen v_k(t).
derivative_mat()
eigen_pair()
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(
w: NDArray,
j: NDArray,
beta: Optional[None],
n_max: int
)
Methods:
be_function(beta: float, w: NDArray) -> NDArray
Compute the zeroth-order coefficient.
c0() -> float
Compute the chain frequencies.
chain_frequency() -> NDArray
Compute the chain couplings.
chain_coupling() -> NDArray
Compute the chain matrix.
chain_matrix() -> NDArray
star_parameters() -> NDArray
Integrate a function with respect to the spectral density.
int(f: NDArray) -> float
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(tensor: OptArray, term_dict: dict[int, OptArray])
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:
lvn_list(sys_hamiltonian: ArrayLike) -> list[dict[End, OptArray]]
lindblad_list(sys_op: ArrayLike, lindblad_rate: float | None) -> list[dict[End, OptArray]]
Interaction picture of oscillating heom mode
i_heom_list(
sys_op: ArrayLike,
correlation: Correlation,
metric: Literal['re', 'abs'] | complex = 're'
) -> list[dict[End, OptArray]]
heom_list(
sys_op: ArrayLike,
correlation: Correlation,
metric: Literal['re', 'abs'] | complex = 're'
) -> list[dict[End, OptArray]]
Assume Ends sys_i and sys_j are attached to the root node axes 0 and 1.
initialize_state(rdo: ArrayLike, rank: int) -> Model
get_rdo(edo: Model) -> OptArray
FrameFactory(bath_dof: int) -> None
Methods:
naive() -> tuple[Frame, Node]
tree(bath_importances: None | list[int] = None, n_ary: int = 2) -> tuple[Frame, Node]
train() -> tuple[Frame, Node]
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(tensor: OptArray, term_dict: dict[int, OptArray])
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:
lvn_list(sys_hamiltonian: ArrayLike) -> list[dict[End, OptArray]]
lindblad_list(sys_op: ArrayLike, lindblad_rate: float | None) -> list[dict[End, OptArray]]
heom_list(
n_bath: int,
sys_op: ArrayLike,
correlation: Correlation,
metric: Literal['re', 'abs'] | complex = 're'
) -> list[dict[End, OptArray]]
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
get_rdo(edo: Model) -> OptArray
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:
| Parameter | Type | Description |
|---|---|---|
bath_dofs | list, int | A list of integers associated with a degree of freedom |
bath_dof | int | The number of degrees of freedom total |
sys_ket_end | string | String to identify the ket of the system in the graph |
sys_bra_end | | String to identify the bra of the system in the graph |
chained_bath_ends | list, string | List of identifying strings for bath degrees of freedom in the graph |
FrameFactory(bath_dofs: list[int]) -> None
Methods:
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]
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]
| Parameter | Type | Description |
|---|---|---|
bath_importances | list, optional | A list of which baths should be deemed most influential when constructing the Huffman tree |
n_ary | | The number of links between nodes in the tree, defaults to 2 |
Returns: tuple — A tuple containing the produced :class: Frame and the :class: Node
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]
custom() -> tuple[Frame, Node]
tenso.heom.multieom
Generating the derivative of the extended rho in SoP formalism.
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:
lvn_list(sys_hamiltonians: list[None | ArrayLike], sys_couplings: list[dict[int, ArrayLike]]) -> list[dict[End, OptArray]]
lindblad_list(sys_ops: list[dict[int, ArrayLike]], lindblad_rates: list[float | None]) -> list[dict[End, OptArray]]
heom_list(
sys_ops: list[dict[int, ArrayLike]],
correlations: list[Correlation],
metric: Literal['re', 'abs'] | complex = 're'
) -> list[dict[End, OptArray]]
initialize_pure_state(
local_wfns: list[ArrayLike],
rank: int,
local_hs: None | list[None | ArrayLike] = None
) -> Model
get_rdo_element(
edo: Model,
sys_is: list[None | int],
sys_js: list[None | int]
) -> complex
get_rdo(edo: Model) -> OptArray
FrameFactory(sys_dof: int, bath_dofs: list[int]) -> None
Methods:
naive() -> tuple[Frame, Node]
tree(importances: None | dict[End, int] = None, n_ary: int = 2) -> tuple[Frame, Node]
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
An abstract class representing a vertex in the graph of the tensor network which is extended by Node and End.
Attributes:
| Parameter | Type | Description |
|---|---|---|
__cache | WeakValueDictionary | A weak valued dictionary with keyts of tuple[str, str] and values of Point |
Point(name: Optional[str] = None) -> None
Class representing a vertex in the graph of the tensor network which has more than one neighbor. This extends :class: Point.
Node()
Class representing a vertex in the graph of the tensor network which has only one neighbor. This extends :class: Point
End()
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:
Return a full copy of the Frame.
copy()
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
| Parameter | Type | Description |
|---|---|---|
p | :class: Point | First :class: Point to be connected. |
1 | | Second :class: Point to be connected. |
Get a set of all Points in the frame
points() -> set[Point]
Get a set of all Nodes in the frame
nodes() -> set[Node]
Get a set of all Ends in the frame
ends() -> set[End]
Get the number of neighbors of a Node
degree(p: Node)
| Parameter | Type | Description |
|---|---|---|
p | :class: Node | Node of inquiry |
Returns: integer — Number of neighbors of p
dual(p: Point, i: None | int) -> tuple[Point, None | int]
axes(p: Point, q: Point) -> tuple[int, None | int]
near_points(key: Point) -> list[Point]
Get a list of all the :class: Nodes in the neighbor list of a given :class: Node, key
near_nodes(key: Node) -> list[Node]
| Parameter | Type | Description |
|---|---|---|
key | :class: Node | :class: Node to retrieve neighbor list for |
Returns: list[Node] — The neighbor list of key
node_link_visitor(start: Node) -> list[tuple[Node, int, Node, int]]
point_link_visitor(start: Point) -> list[tuple[Point, int, Point, int]]
node_visitor(start: Node, method: Literal['DFS', 'BFS'] = 'DFS') -> list[Node]
point_visitor(start: Node, method: Literal['DFS', 'BFS'] = 'DFS') -> list[Node]
get_node_depths(start: Node) -> dict[Node, int]
get_node_axes(start: Point) -> dict[Node, Optional[int]]
get_graph() -> dict[Node, list[Point]]
construct_from_graph(graph: dict[Node, list[Point]]) -> None
tenso.state.puremodel
Produces a Generator which yields the natural number in a triangular order.
triangular(n_list)
| Parameter | Type | Description |
|---|---|---|
n_list | | List of integers "type n_list: list |
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
Get a model with an identity-matrix like valuation.
eye_model(
frame: Frame,
root: Node,
shapes: dict[Node, list[int]]
) -> Model
A class representing a, Model, a :class: Frame with valuation for each Node.
Model(valuation: dict[Node, OptArray] | Iterable[tuple[Node, OptArray]]) -> None
Methods:
Save the model to a file.
save(filename: str) -> None
Load the model from a file.
load(filename: str) -> Model
nodes() -> set[Node]
shape(p: Node) -> list[int]
order(p: Node) -> int
dimension(p: Node, i: int) -> int
Produce a shallow copy of the model.
copy() -> Model
Take the conjugate the model by complex conjugation of all tensor valuations.
conjugate() -> Model
substitute(valuation: dict[Node, OptArray] | Iterable[tuple[Node, OptArray]]) -> Model
Update the valuation of the model.
update(valuation: dict[Node, OptArray] | Iterable[tuple[Node, OptArray]]) -> None
zero_like() -> Model
tenso.operator
Sparse operator utilities.
tenso.operator.sparse
Class representing the sum of products form operator.
Attributes:
| Parameter | Type | Description |
|---|---|---|
op_list | dictionary | List of dictionaries where keys are the ends in the tensor network and values are the associated operators in tensor form |
initial_time | float, optional | Start time for the propagation, defaults to 0.0 |
f_list | callable | Functions 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:
Return time independent operators in the sum of products form.
tensor form
get_ti_terms() -> list[dict[End, OptArray]]
Returns the time dependent operators in the sum of products form.
tensor form
get_td_terms(t: float) -> list[dict[End, OptArray]]
ends() -> set[End]
Intermediate class for the sparse operations in the model.
SPOKet(
op: SparseSPO,
state: Model,
frame: Frame,
root: Node,
time = 0.0
)
Methods:
Canonicalize the state.
canonicalize() -> None
Calculate the inner product.
close_with_bra(bra: Model | None = None) -> complex
Calculate the inner product.
close_with_conj(bras: SPOKet) -> complex
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:
Actuall calculate the inner product.
forward() -> complex
SparseSandwich(
frame: Frame,
root: Node,
ket_state: Model,
bra_state: Model | None = None,
op: SparseSPO | None = None,
time = 0.0
)
Methods:
Calculate the inner product.
forward() -> complex
SparsePropagator(
op: SparseSPO,
state: Model,
frame: Frame,
root: Node,
renormalize_root = False,
init_time = 0.0
) -> None
Methods:
info()
update_settings(**kwargs)
renormalize_root()
update_size_list()
update_td_terms(time: float) -> None
propagate(
end: float,
dt: float,
ps_method: Literal['vmf', 'ps1', 'ps2'] = 'vmf'
) -> Generator[tuple[float, Model], None, None]
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]
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]
vmf_step(dt: float) -> None
ps1_step(dt: float) -> None
ps2_step(dt: float) -> None
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
Abstract class for any discrete variable representation basis.
DiscreteVariationalRepresentation(num: int) -> None
Methods:
Get the position operator in DVR basis.
q_mat() -> NDArray
dq_mat() -> NDArray
dq2_mat() -> NDArray
Get the creation operator in the DVR basis
creation_mat() -> NDArray
Get the annihilation operator in the DVR basis
annihilation_mat() -> NDArray
fock2dvr_mat() -> NDArray
eigen2dvr_mat(ham) -> NDArray
Get the `i`-th finite basis representation function
fbr_func(i: int) -> Callable[[NDArray], NDArray]
| Parameter | Type | Description |
|---|---|---|
i | integer | Function to retrieve |
Returns: Callable — The `i`-th FBR function
numberer_mat() -> NDArray
Class for performing the universal Sinc DVR basis of Colbert and Miller (1982)
SincDVR(
start: float,
stop: float,
num: int
) -> None
Methods:
Get the volume element `d/dq` matrix, alternately -i times momentum, in the DVR basis
dq_mat() -> NDArray
Get the square volume element `d2/dq2` matrix, alternately -momentum^2, in the DVR basis
dq2_mat() -> NDArray
Class for the Sine-DVR
SineDVR(
start: float,
stop: float,
num: int
) -> None
Methods:
Get the position operator, q in the DVR basis.
q_mat() -> NDArray
Get the absolute value of the position operator, q in the DVR basis.
abs_q_mat() -> NDArray
q in DVR basis.
abs_dq_mat() -> NDArray
Get the volume element `d/dq` matrix, alternately -i times momentum, in the DVR basis
dq_mat() -> NDArray
Get the square volume element `d2/dq2` matrix, alternately `-p^2`, in the DVR basis
dq2_mat() -> NDArray
Return the kinetic energy matrix in the DVR basis in internal energy units.
t_mat()
fock2dvr_mat() -> NDArray
height()
`i`-th FBR basis function.
fbr_func(i: int) -> Callable[[NDArray], NDArray]
Transform a vector from FBR to the spatial function.
fbr2cont(vec)
dvr2cont(vec)
tenso.mctdh
ML-MCTDH alternative propagator.
tenso.mctdh.eom
Generating the derivative of the extended rho in SoP formalism.
Complex conjugate not included
trace(
tensor1: OptArray,
tensor2: OptArray,
ax: int
) -> OptArray
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:
get_densities(state: Model) -> dict[Point, OptArray]
tdse_list(sys_hamiltonians: list[None | ArrayLike], sys_couplings: list[dict[int, ArrayLike]]) -> list[dict[End, OptArray]]
heom_list(sys_ops: list[dict[int, ArrayLike]], correlations: list[StarBosons]) -> list[dict[End, OptArray]]
bath_q_list(correlations: list[StarBosons]) -> list[dict[End, OptArray]]
bath_q2_list(correlations: list[StarBosons]) -> list[dict[End, OptArray]]
initialize_pure_state(
local_wfns: list[ArrayLike],
rank: int,
local_hs: None | list[None | ArrayLike] = None
) -> Model
FrameFactory(sys_dof: int, bath_dofs: list[int]) -> None
Methods:
naive() -> tuple[Frame, Node]
tree(importances: None | dict[End, int] = None, n_ary: int = 2) -> tuple[Frame, Node]
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(value: float, unit: Optional[str] = None) -> None
Methods:
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]
| Parameter | Type | Description |
|---|---|---|
unit | string, optional | Potentially non-standard string representing a unit |
Returns: string — The standardized string representing the unit
Return the value in atomic units.
au() -> float
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
| Parameter | Type | Description |
|---|---|---|
unit | string, optional | The current unit in use |
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
| Parameter | Type | Description |
|---|---|---|
unit | string, optional | The current unit in use |
tenso.libs.backend
Backend for accelerated array-operations.
Transform a pytorch tensor to a numpy array
opt_to_numpy(array: OptArray) -> NDArray
| Parameter | Type | Description |
|---|---|---|
OptArray | OptArray | Input numpy array |
Returns: array — Equivalent numpy array
Transform an array like to a pytorch tensor
opt_array(array: ArrayLike) -> OptArray
| Parameter | Type | Description |
|---|---|---|
array | ArrayLike | Array to transform |
Returns: :class: OptArray — Equivalent pytorch tensor
Get a pytorch tensor with zeros in the given shape (wraps torch.zeros)
opt_zeros(shape: list[int]) -> OptArray
| Parameter | Type | Description |
|---|---|---|
shape | list[int] | List of dimensions of the tensor |
Returns: :class: OptArray — Tensor of zeros in pytorch form
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
| Parameter | Type | Description |
|---|---|---|
tensors | :class: OptArray | Input pytorch tensors to concatenate |
Returns: :class: OptArray — Concatenated tensors
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
| Parameter | Type | Description |
|---|---|---|
tensors | list[:class: OptArray] or tuple[:class: OptArray] | Input pytorch tensors to concatenate |
Returns: :class: OptArray — Stacked tensors, with the new dimension being the first dimension
Split a tensor into pieces along dimension zero (wraps torch.split)
opt_split(tensors: OptArray, size_list: list[int]) -> list[OptArray]
| Parameter | Type | Description |
|---|---|---|
tensors | :class: OptArray | Input pytorch tensor to break up |
Returns: list[:class: OptArray] — A list of the broken up tensors
Perform an Einstein summation over the tensors provided (wraps torch.einsum, see documentation for torch.einsum)
opt_einsum(*args) -> OptArray
| Parameter | Type | Description |
|---|---|---|
args | varies | The required string specification for how to perform the eigensum followed by the tensors to operator on |
Sum over all elements along the given dimension of the tensor (wraps torch.sum)
opt_sum(array: OptArray, dim: int) -> OptArray
| Parameter | Type | Description |
|---|---|---|
array | :class: OptArray | Tensor with elements to sum |
Returns: Tensor after summation along requested dimension :rtye: :class: OptArray
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
| Parameter | Type | Description |
|---|---|---|
a | :class: OptArray | first tensor to contract |
b | :class: OptArray | second tensor to contract |
axes | tuble[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
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]
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
Perofrm Moore-Penrose pseudoinverse of the tensor
opt_pinv(a: OptArray, atol) -> OptArray
| Parameter | Type | Description |
|---|---|---|
a | :class: OptArray | Tensor to invert |
Returns: :class: OptArray — Tensor pseudoinverse
Invert the given tensor or throws an error (wraps torch.linalg.inv)
opt_inv(a: OptArray) -> OptArray
| Parameter | Type | Description |
|---|---|---|
a | :class: OptArray | Tensor to invert |
Returns: :class: OptArray — Inverted tensor
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
)
| Parameter | Type | Description |
|---|---|---|
op | :class: OptArray | Second tensor in contraction |
tensor | :class: OptArray | First tensor in contraction |
op_ax | integer | Contraction dimension of op |
tensor_ax | integer | Contraction dimension of tensor |
Returns: :class: OptArray — The contracted and rearranged tensor
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
| Parameter | Type | Description |
|---|---|---|
op_dict | dictionary[integer, :class: OptArray] | Dictionary associating a dimension with a tensor for transformation |
tensor | :class: OptArray | Tensor on which to carry out transformations |
Returns: :class: OptArray — Result of performing the series of transformations
Obtain a two dimensional identity tensor (wraps torch.eye)
opt_eye(dim1: int, dim2: int | None = None) -> OptArray
| Parameter | Type | Description |
|---|---|---|
dim1 | integer | Number of rows |
dim2 | integer | Number of columns |
Returns: :class: OptArray — Two dimensional identity tensor
Complex conjugate not included
opt_trace(
tensor1: OptArray,
tensor2: OptArray,
ax: int
) -> OptArray
opt_inner_product(tensor1: OptArray, tensor2: OptArray) -> complex
tenso.libs.utils
This file includes miscellaneous utility functions without another obvious home.
Experimental function to implement just in time evaluation of a property (lazy evaluation)
lazyproperty(func: Callable[..., T]) -> Callable[..., T]
Debugging function used to measure call counts
count_calls(f: Callable[..., T]) -> Callable[..., T]
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]
| Parameter | Type | Description |
|---|---|---|
start | :class: Node | The object to begin search from |
r | Callable | Callable relation function taking start and returning the neighbor list of start |
Returns: :class: Node — A tuple containing the next node in the tree
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]
| Parameter | Type | Description |
|---|---|---|
start | :class: Node | The object to begin search from |
r | Callable | Callable relation function taking start and returning the neighbor list of start |
method | string | Either 'DFS', depth first, or 'BFS', breadth first method, will be used |
Returns: :class: Node — A tuple containing the next node in the tree
Iteratively generate the depth of each component in the tree
depths(start: T, r: Callable[[T], list[T]]) -> dict[T, int]
| Parameter | Type | Description |
|---|---|---|
start | :class: Node | The object to begin search from |
r | Callable | Callable 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
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]
| Parameter | Type | Description |
|---|---|---|
start | :class: Node | The object to begin search from |
start | :class: Node | The object to search for |
r | Callable | Callable 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
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]
| Parameter | Type | Description |
|---|---|---|
sources | list of :class: Ends | The leaves, :class: Ends, for the tree |
importances | list[int], Optional | Importance ranking of the leaves to guide generation |
n_ary | int | Order 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
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
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')
| Parameter | Type | Description |
|---|---|---|
frame | :class: Frame | The :class: Frame whose graph is to be drawn |
fname | string | The file name where the graph will be drawn, default 'frame_graph_output' |
tenso.libs.logging
Interface to logging package.
Class used to interface with infrastructure for logging at various levels of verbosity ranging from `debug` to `critical`.
Attributes:
| Parameter | Type | Description |
|---|---|---|
level | Literal | The degree of information to log with options being `debug`, `info`, `warning`, `error` and `critical` |
filename | string, optional | File for logging |
stream_fmt | string, optional | Formating string for the stream |
file_fmt | string, optional | File 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:
Log an info message.
info(message: str)
| Parameter | Type | Description |
|---|---|---|
str | string | Message to log |
Log a debug message.
debug(message: str)
| Parameter | Type | Description |
|---|---|---|
str | string | Message to log |
Log a warning message.
warning(message: str)
| Parameter | Type | Description |
|---|---|---|
str | string | Message to log |
Log an error message.
error(message: str)
| Parameter | Type | Description |
|---|---|---|
str | string | Message to log |
Log a critical message.
critical(message: str)
| Parameter | Type | Description |
|---|---|---|
str | string | Message to log |