# ms_displacements

Source: https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/ions/ms_displacements

```python
ions.ms_displacements(drives, lamb_dicke_parameters, relative_detunings, sample_times=None, *, name=None)
```

Calculate the displacements for each mode and ion combination where ions are described by
a Mølmer–Sørensen-type interaction.

Use this function to calculate the displacements for each ion and each mode
at the final time of the drives, or at the sample times that you provide.

### Parameters
* **drives** (*list* *[*[*Pwc*](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Pwc.md#boulderopal.graph.Pwc) *or* *None* *]*) – The piecewise-constant drives, $\{\gamma_j\}$, one for each of the $N$ ions.
  Drive values must be in rad/s and durations must be in seconds.
  All drives must have the same total duration, but can have different segmentations.
  If an ion is not addressed, you can pass None for its drive (this leads to a
  more efficient calculation than passing a zero drive).
* **lamb_dicke_parameters** (*np.ndarray*) – The laser-ion coupling strength, $\{\eta_{jkl}\}$.
  Its shape must be `(3, N, N)`, where the dimensions indicate,
  respectively, axis, collective mode, and ion.
* **relative_detunings** (*np.ndarray*) – The difference $\{\delta_{jk} = \nu_{jk} - \delta\}$ (in Hz) between each motional
  mode frequency and the laser detuning from the qubit transition frequency
  $\omega_0$.  Its shape must be `(3, N)`, where the dimensions indicate,
  respectively, axis and collective mode.
* **sample_times** (*np.ndarray* *or* *None* *,* *optional*) – The times (in seconds) at which to calculate the displacements, $\{t_i\}$.
  If you provide it, it must be 1D, ordered, and contain at least one element.
  If you omit it, the displacements are only calculated at the final time of the drives.
* **name** (*str* *or* *None* *,* *optional*) – The name of the node.
### Returns
Displacements $\{\eta_{jkl}\alpha_{jkl}(t_i)\}$ for all mode-ion combinations.
If you provide sample_times, the shape of the returned value is `(T, 3, N, N_d)`,
where the dimensions indicate, respectively, time, axis, collective mode, and ion.
Otherwise, the shape is `(3, N, N_d)`, with the outer time dimension removed.
Here, `N_d` is the number of addressed ions (drives that are not None);
the displacements of undriven ions are not returned (as they are zero).
### Return type
[Tensor](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Tensor.md#boulderopal.graph.Tensor)(complex)

### SEE ALSO
[`Graph.ions.ms_infidelity`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/graph/Graph/ions/ms_infidelity.md#boulderopal.graph.ions.ms_infidelity)
: Final operational infidelity of a Mølmer–Sørensen gate.

[`boulderopal.ions.obtain_ion_chain_properties`](https://docs.q-ctrl.com/references/boulder-opal/boulderopal/ions/obtain_ion_chain_properties.md#boulderopal.ions.obtain_ion_chain_properties)
: Function to calculate the properties of an ion chain.

## Notes

This function calculates, at sample times $\{t_i\}$, the contribution
to the displacement of mode $k$ in dimension $j$ from ion $l$,
namely $\eta_{jkl}\alpha_{jkl}(t_i)$, where

$$
\alpha_{jkl}(t) \equiv \int_0^t d\tau \frac{\gamma_l(\tau)}{2}
    \exp(i 2 \pi \delta_{jk} \tau) .
$$

You can calculate the state-dependent displacement by summing over the contributions
from all ions. That is, using the displacement superoperator $\mathcal{D}_{jk}$,
the displacement in phase space for mode $(j,k)$ is

$$
\mathcal{D}_{jk} \left(\sum_{l=1}^N \sigma_{x,l}\eta_{jkl}\alpha_{jkl}(t_i) \right) .
$$

## Examples

Refer to the [How to optimize error-robust Mølmer–Sørensen gates for trapped ions](https://docs.q-ctrl.com/boulder-opal/user-guides/how-to-optimize-error-robust-molmer-sorensen-gates-for-trapped-ions) user guide to find how to use this and related nodes.
