HOPSflow

Calculate the reservoir energy change from HOPS data.

The functions in this module mostly take parameter objects which hold relevant information and compute commonly used values ahead of time.

The parameter objects are passed separately but may depend on each other.

class hopsflow.hopsflow.HOPSRun(ψ_0: numpy.ndarray, ψ_1: numpy.ndarray, params: hopsflow.hopsflow.SystemParams)[source]

A parameter object to hold data commonly used by the energy flow calculations.

Parameters
  • ψ_0 (numpy.ndarray) – The HOPS trajectory (time, dim-state).

  • ψ_1 (numpy.ndarray) –

    The first HOPS hierarchy states (time, hierarchy-width * dim-state).

    It will be reshaped to a list containing arrays of the shape``(time, hierarchy-width, dim_state)`` (one for each bath).

  • params (hopsflow.hopsflow.SystemParams) –

nonlinear
norm_squared

The squared norm of the state, may be None for linear HOPS.

normalize_maybe(array: numpy.ndarray)[source]

Normalize the array if nonlinear HOPS is being used.

Parameters

array (numpy.ndarray) –

t_steps

The number of timesteps.

ψ_0
ψ_1_n

The first hierarchy states for each bath.

ψ_coups

ψ_0 with the coupling operator applied for each bath.

class hopsflow.hopsflow.SystemParams(L: list[numpy.ndarray], G: list[numpy.ndarray], W: list[numpy.ndarray], bcf_scale: Optional[list[float]] = None, nonlinear: bool = False, fock_hops: bool = True)[source]

A parameter object to hold information about the physical system and global HOPS parameters.

Parameters
  • L (list[numpy.ndarray]) – the coupling operators as system matrices

  • G (list[numpy.ndarray]) – the coupling factors in the exponential expansion of the BCF

  • W (list[numpy.ndarray]) – the exponents in the exponential expansion of the BCF

  • bcf_scale (Optional[list[float]]) – BCF scale factors

  • nonlinear (bool) – whether the trajectory was obtained through the nonlinear HOPS

  • fock_hops (bool) – whether the now fock hops hierarchy normalization is used

G
L
W
bcf_scale
coupling_flow_prefactors
coupling_interaction_prefactors
dim

the dimensionality of the system

nonlinear
class hopsflow.hopsflow.ThermalParams(ξs: list[Optional[stocproc.stocproc.StocProc]], τ: numpy.ndarray, rand_skip: int = 0, num_deriv: bool = False, dx: float = 0.001, order: int = 3)[source]

Aparameter object to hold information abouth the thermal stochastic process.

Parameters
  • ξ – the thermal stochastic processes

  • τ (numpy.ndarray) – the time points of the trajectory

  • rand_skip (int) – how many random numbers to skip when parametrizing the stochastic process

  • num_deriv (bool) – whether to calculate the derivative of the process numerically or use it directly from the StocProc. The latter alternative is strongly preferred if available.

  • dx (float) – step size for the calculation of the derivative of ξ, only relevant if numerical differentiation is used

  • order (int) – order the calculation of the derivative of ξ, must be odd, see scipy.misc.derivative, only relevant if numerical differentiation is used

  • ξs (list[Optional[stocproc.stocproc.StocProc]]) –

dx
num_deriv
order
rand_skip
ξs
τ
class hopsflow.hopsflow.ThermalRunParams(therm_params: hopsflow.hopsflow.ThermalParams, seed: int)[source]

A parameter object to hold information abouth the thermal stochastic process.

Parameters
  • therm_params (hopsflow.hopsflow.ThermalParams) – information abouth the thermal stochastic process

  • seed (int) – the seed used to generate the random numbers for the process realization

Attr ξ_dots

the process derivatives evaluated at τ :attr

Attr ξ_values

the processes evaluated at τ

Attr ξ_coeff

the coefficients of the realization of the thermal stochastic processes

ξ_coeff
ξ_dots
ξ_values
hopsflow.hopsflow.bath_energy_from_flow(τ: numpy.ndarray, *args, **kwargs) hopsflow.util.EnsembleValue[source]

Calculates the bath energy by integrating the flow. For the arguments see heat_flow_ensemble.

Parameters

τ (numpy.ndarray) – The time points of the simulations.

Returns

The value of the bath energy for each time step.

Return type

hopsflow.util.EnsembleValue

hopsflow.hopsflow.flow_trajectory(run: hopsflow.hopsflow.HOPSRun, params: hopsflow.hopsflow.SystemParams, therm_run: Optional[hopsflow.hopsflow.ThermalRunParams] = None) numpy.ndarray[source]

Calculates the total energy flow for a trajectory.

Parameters
Returns

the value of the flow for each time step

Return type

numpy.ndarray

hopsflow.hopsflow.flow_trajectory_coupling(run: hopsflow.hopsflow.HOPSRun, params: hopsflow.hopsflow.SystemParams) numpy.ndarray[source]

Calculates the \(\langle L^\dagger \dot{B} + c.c.\) part of the energy flow for a single trajectory and for each bath.

Parameters
Returns

the value of the flow for each time step

Return type

numpy.ndarray

hopsflow.hopsflow.flow_trajectory_therm(run: hopsflow.hopsflow.HOPSRun, therm_run: hopsflow.hopsflow.ThermalRunParams) numpy.ndarray[source]

Calculates the \(\langle L^\dagger \dot{\xi} + c.c.\) part of the energy flow for a single trajectory.

Parameters
Returns

the value of the flow for each time step

Return type

numpy.ndarray

hopsflow.hopsflow.heat_flow_ensemble(ψ_0s: Iterator[numpy.ndarray], ψ_1s: Iterator[numpy.ndarray], params: hopsflow.hopsflow.SystemParams, therm_args: Optional[Tuple[Iterator[numpy.ndarray], hopsflow.hopsflow.ThermalParams]] = None, only_therm: bool = False, **kwargs) hopsflow.util.EnsembleValue[source]

Calculates the heat flow for an ensemble of trajectories.

Parameters
Return type

hopsflow.util.EnsembleValue

The rest of the kwargs is passed on to util.ensemble_mean.

Returns

the value of the flow for each time step

Parameters
Return type

hopsflow.util.EnsembleValue

hopsflow.hopsflow.interaction_energy_coupling(run: hopsflow.hopsflow.HOPSRun, params: hopsflow.hopsflow.SystemParams) numpy.ndarray[source]

Calculates the coupling part of the interaction energy expectation value for a trajectory.

Parameters
Returns

the value of the interaction energy for each time step

Return type

numpy.ndarray

hopsflow.hopsflow.interaction_energy_ensemble(ψ_0s: Iterator[numpy.ndarray], ψ_1s: Iterator[numpy.ndarray], params: hopsflow.hopsflow.SystemParams, therm_args: Optional[Tuple[Iterator[int], hopsflow.hopsflow.ThermalParams]] = None, **kwargs) hopsflow.util.EnsembleValue[source]

Calculates the heat flow for an ensemble of trajectories.

Parameters
Return type

hopsflow.util.EnsembleValue

The **kwargs are passed to hopsflow.utility.ensemble_mean. :returns: the value of the flow for each time step

hopsflow.hopsflow.interaction_energy_therm(run: hopsflow.hopsflow.HOPSRun, therm_run: hopsflow.hopsflow.ThermalRunParams) numpy.ndarray[source]

Calculates the thermal part of the interaction energy.

Parameters
Returns

the value of the thermal interaction for each time step

Return type

numpy.ndarray