# calculate_coherent_simulation

static FunctionNamespace.calculate_coherent_simulation(*, duration, sample_times=None, drives=None, shifts=None, drifts=None, initial_state_vector=None, target=None, result_scope='ALL', **kwargs)

Perform the evolution of a closed quantum system.

Use this function to simulate the dynamics of a system under a Hamiltonian expressed as a sum of piecewise-constant terms. The function calculates the resulting unitary evolution operator. It can also calculate the infidelity with respect to a given target operator and the evolution of a given initial state.

When using this function, you must provide at least one term in drives, shifts, or drifts.

Parameters:
• duration (float) – The duration of the simulation, $$\tau$$. Must be positive and match the duration of each control in drives and shifts.

• sample_times (List[float], optional) – The times at which you want to sample the simulation. If provided, it must contain at least one element, be increasing, and each element must be between 0 and $$\tau$$ (inclusive). Defaults to a singleton array containing duration.

• drives (List[qctrl.dynamic.types.coherent_simulation.Drive], optional) – The list of complex control terms in the system’s Hamiltonian. Each term has the form $$\gamma_{j}(t) C_{j} + \mathrm{H.c.}$$, where $$C_{j}$$ is a non-Hermitian operator and $$\gamma_{j}(t)$$ is a complex piecewise-constant function between 0 and $$\tau$$. Defaults to an empty list.

• shifts (List[qctrl.dynamic.types.coherent_simulation.Shift], optional) – The list of real control terms in the system’s Hamiltonian. Each term has the form $$\alpha_{k}(t) A_{k}$$, where $$A_{k}$$ is a Hermitian operator and $$\alpha_{k}(t)$$ is a real piecewise- constant function between 0 and $$\tau$$. Defaults to an empty list.

• drifts (List[qctrl.dynamic.types.coherent_simulation.Drift], optional) – The list of static terms in the system’s Hamiltonian. Each term has the form of a constant Hermitian operator $$D_{l}$$. Defaults to an empty list.

• initial_state_vector (ndarray, optional) – The initial state vector to be evolved, $$|\psi(0)\rangle$$. If provided, the function calculates its evolution at the sample times.

• target (qctrl.dynamic.types.TargetInput, optional) – The target partial isometry, $$V$$. If provided, the function calculates the infidelity with respect to it at the sample times.

• result_scope (qctrl.dynamic.types.coherent_simulation.ResultScope, optional) – Configuration for the scope of the returned data. Use this to select which data you want returned and which you want to omit.

Returns:

The result of the coherent simulation. It includes the values, at the sample times, of the unitary evolution operator $$U(t)$$, the target operation infidelity $$\mathcal{I}(t)$$ (if requested), and the evolved state $$|\psi(t)\rangle$$ (if requested).

Return type:

qctrl.dynamic.types.coherent_simulation.Result

Warning

This is a legacy function that will be removed in the future. The recommended way of running simulations is through the calculate_graph function. You can read about how to use the calculate_graph function for coherent simulations in the How to simulate quantum dynamics for noiseless systems using graphs user guide.

calculate_graph

Evaluate generic functions.

Notes

This function integrates the time-dependent Schrödinger equation,

$i \frac{d U(t)}{d t} = H(t) U(t),$

with a control Hamiltonian

$H(t) = \sum_{j = 1}^{N_\mathrm{drives}} \left( \gamma_{j}(t) C_{j} + \mathrm{H.c.} \right) + \sum_{k = 1}^{N_\mathrm{shifts}} \alpha_{k}(t) A_{k} + \sum_{l = 1}^{N_\mathrm{drifts}} D_{l} ,$

and returns the unitary evolution operator $$U(t)$$ for each $${t}$$ in sample_times.

If you provide target, the function also returns the infidelity at each sample time, calculated as

$\mathcal{I}(t) = 1 - \left| \frac{\mathrm{Tr} \left(V^\dagger U(t)\right)} {\mathrm{Tr} \left(V^\dagger V\right)} \right|^2 .$

If you provide initial_state_vector, the function also returns the evolved state $$|\psi(t)\rangle = U(t)|\psi(0)\rangle$$ at each sample time.