levisim 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- levisim/__init__.py +34 -0
- levisim/analysis/__init__.py +40 -0
- levisim/analysis/gaussian_states.py +405 -0
- levisim/analysis/spectral_density_estimate.py +626 -0
- levisim/analysis/spectral_density_theory.py +345 -0
- levisim/core/__init__.py +153 -0
- levisim/core/colours.py +224 -0
- levisim/core/constants.py +67 -0
- levisim/core/elk.py +959 -0
- levisim/core/logger.py +322 -0
- levisim/core/plotting.py +96 -0
- levisim/core/testing.py +101 -0
- levisim/core/units.py +155 -0
- levisim/core/utils.py +298 -0
- levisim/core/wrappers.py +177 -0
- levisim/data/__init__.py +15 -0
- levisim/data/experiment.py +187 -0
- levisim/data/simulation.py +543 -0
- levisim/data/trace.py +156 -0
- levisim/multiphysics/__init__.py +142 -0
- levisim/multiphysics/covariance.py +100 -0
- levisim/multiphysics/dimension.py +624 -0
- levisim/multiphysics/enums/__init__.py +29 -0
- levisim/multiphysics/enums/noise_vector.py +41 -0
- levisim/multiphysics/enums/parameter.py +197 -0
- levisim/multiphysics/enums/quantum_linear_theory_method.py +347 -0
- levisim/multiphysics/enums/spectrum.py +52 -0
- levisim/multiphysics/hybridisation.py +515 -0
- levisim/multiphysics/multitone.py +403 -0
- levisim/multiphysics/multitrap/__init__.py +56 -0
- levisim/multiphysics/multitrap/analytic_mixin.py +730 -0
- levisim/multiphysics/multitrap/base.py +1439 -0
- levisim/multiphysics/multitrap/hybridisation_mixin.py +407 -0
- levisim/multiphysics/multitrap/linear_amplifier_mixin.py +371 -0
- levisim/multiphysics/multitrap/omega_model.py +175 -0
- levisim/multiphysics/output_modes.py +554 -0
- levisim/multiphysics/power_series_data/2D_1x2_up_to_2.pickle +0 -0
- levisim/multiphysics/power_series_data/4D_2x2_up_to_4.pickle +0 -0
- levisim/multiphysics/power_series_data/6D_3x2_up_to_6.pickle +0 -0
- levisim/multiphysics/power_series_data/README.md +6 -0
- levisim/multiphysics/quadrature_squeezing.py +174 -0
- levisim/multiphysics/two_tone.py +474 -0
- levisim/multiphysics/two_tone_traps.py +477 -0
- levisim/multiphysics/utils/__init__.py +75 -0
- levisim/multiphysics/utils/animations.py +621 -0
- levisim/multiphysics/utils/comparison.py +1379 -0
- levisim/multiphysics/utils/shelf.py +325 -0
- levisim/physics/__init__.py +28 -0
- levisim/physics/bead.py +193 -0
- levisim/physics/cavity.py +286 -0
- levisim/physics/focal_expansion.py +198 -0
- levisim/physics/focussing_optics.py +575 -0
- levisim/physics/gas.py +120 -0
- levisim/physics/kick.py +75 -0
- levisim/physics/trap.py +1107 -0
- levisim/physics/tweezer.py +285 -0
- levisim-0.1.0.dist-info/METADATA +109 -0
- levisim-0.1.0.dist-info/RECORD +62 -0
- levisim-0.1.0.dist-info/WHEEL +5 -0
- levisim-0.1.0.dist-info/entry_points.txt +2 -0
- levisim-0.1.0.dist-info/licenses/LICENSE +674 -0
- levisim-0.1.0.dist-info/top_level.txt +1 -0
levisim/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
levisim
|
|
3
|
+
=======
|
|
4
|
+
A library to simulate the dynamics of levitated particles
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from importlib.metadata import PackageNotFoundError, version as _version
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
__version__ = _version('levisim')
|
|
13
|
+
except PackageNotFoundError: # running from a clone that was never installed
|
|
14
|
+
__version__ = '0.1.0'
|
|
15
|
+
|
|
16
|
+
from levisim.core import *
|
|
17
|
+
from levisim.physics import *
|
|
18
|
+
from levisim.multiphysics import *
|
|
19
|
+
from levisim.data import *
|
|
20
|
+
from levisim.analysis import *
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def __getattr__(name):
|
|
24
|
+
"""
|
|
25
|
+
Forwards the lazily-built `shelf` fixtures (PEP 562)
|
|
26
|
+
|
|
27
|
+
`FORTRAN_8x2`, `PHASE_EQUAL_xy_dict` and `PHASE_DEPENDENT_xy_dict` are built on first
|
|
28
|
+
access rather than at import time, so they are not re-exported by the `import *` above.
|
|
29
|
+
Forwarding them here keeps `from levisim import FORTRAN_8x2` working as it always did.
|
|
30
|
+
"""
|
|
31
|
+
from levisim.multiphysics.utils import shelf
|
|
32
|
+
if name in shelf._LAZY_ATTRIBUTES:
|
|
33
|
+
return getattr(shelf, name)
|
|
34
|
+
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""
|
|
2
|
+
levisim.analysis
|
|
3
|
+
================
|
|
4
|
+
A module to handle the analysis of the time traces produced by simulation or experiment, including theoretical expressions
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
'SpectralDensityEstimate',
|
|
10
|
+
'SpectralDensityTheory',
|
|
11
|
+
'common_phase_averaged',
|
|
12
|
+
'duan_criterion',
|
|
13
|
+
'gaussian_discord',
|
|
14
|
+
'hillery_zubairy_ratio',
|
|
15
|
+
'is_entangled',
|
|
16
|
+
'is_physical',
|
|
17
|
+
'local_rotation',
|
|
18
|
+
'log_negativity',
|
|
19
|
+
'mean_phonon_numbers',
|
|
20
|
+
'mutual_information',
|
|
21
|
+
'negativity',
|
|
22
|
+
'optimised_duan_criterion',
|
|
23
|
+
'partial_transpose',
|
|
24
|
+
'partially_transposed_symplectic_eigenvalues',
|
|
25
|
+
'phonon_moments',
|
|
26
|
+
'purity',
|
|
27
|
+
'reduced_covariance',
|
|
28
|
+
'rotate_transverse_axes',
|
|
29
|
+
'symplectic_eigenvalues',
|
|
30
|
+
'symplectic_form',
|
|
31
|
+
'symplectic_occupations',
|
|
32
|
+
'thermal_covariance',
|
|
33
|
+
'two_mode_squeezed_vacuum',
|
|
34
|
+
'von_neumann_entropy',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
from levisim.analysis.spectral_density_estimate import SpectralDensityEstimate
|
|
39
|
+
from levisim.analysis.spectral_density_theory import SpectralDensityTheory
|
|
40
|
+
from levisim.analysis.gaussian_states import *
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Gaussian states of bosonic modes, described by their covariance matrices
|
|
3
|
+
|
|
4
|
+
Everything here acts on covariance matrices (plain numpy arrays), so it applies equally to the
|
|
5
|
+
mechanical modes of a `MultiTrap`, to its cavity mode, or to any other set of bosonic modes.
|
|
6
|
+
|
|
7
|
+
Conventions (the same as levisim's light quadratures A = a† + a, P = i(a† - a))::
|
|
8
|
+
|
|
9
|
+
quadratures per mode X = b + b†, P = i(b† - b), so [X, P] = 2i
|
|
10
|
+
quadrature ordering u = (X1, P1, X2, P2, ...)
|
|
11
|
+
covariance matrix V_ij = ½〈{Δu_i, Δu_j}〉, so the vacuum is the identity matrix
|
|
12
|
+
uncertainty principle V + iΩ ≥ 0, i.e. every symplectic eigenvalue ν ≥ 1
|
|
13
|
+
logarithms natural, so a two-mode squeezed vacuum S(r)|0,0〉 has E_N = 2r
|
|
14
|
+
|
|
15
|
+
The entanglement measure used throughout levisim is the logarithmic negativity E_N, computed
|
|
16
|
+
from the symplectic spectrum of the partially transposed covariance matrix. For two modes the
|
|
17
|
+
positivity of the partial transpose (PPT) is necessary AND sufficient for separability of a
|
|
18
|
+
Gaussian state (Simon, PRL 84, 2726 (2000)), so E_N > 0 if and only if the state is entangled.
|
|
19
|
+
The other quantities here (Duan and Hillery-Zubairy witnesses, mutual information, discord,
|
|
20
|
+
purity) are provided because they are often used in its place, and docs/two_tone_entanglement
|
|
21
|
+
shows where each of them gives the wrong answer for levitated-particle states.
|
|
22
|
+
"""
|
|
23
|
+
import numpy as np
|
|
24
|
+
|
|
25
|
+
from scipy.optimize import minimize
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
'symplectic_form',
|
|
30
|
+
'symplectic_eigenvalues',
|
|
31
|
+
'is_physical',
|
|
32
|
+
'reduced_covariance',
|
|
33
|
+
'partial_transpose',
|
|
34
|
+
'partially_transposed_symplectic_eigenvalues',
|
|
35
|
+
'log_negativity',
|
|
36
|
+
'negativity',
|
|
37
|
+
'is_entangled',
|
|
38
|
+
'mean_phonon_numbers',
|
|
39
|
+
'symplectic_occupations',
|
|
40
|
+
'phonon_moments',
|
|
41
|
+
'purity',
|
|
42
|
+
'von_neumann_entropy',
|
|
43
|
+
'mutual_information',
|
|
44
|
+
'gaussian_discord',
|
|
45
|
+
'duan_criterion',
|
|
46
|
+
'optimised_duan_criterion',
|
|
47
|
+
'hillery_zubairy_ratio',
|
|
48
|
+
'local_rotation',
|
|
49
|
+
'common_phase_averaged',
|
|
50
|
+
'rotate_transverse_axes',
|
|
51
|
+
'two_mode_squeezed_vacuum',
|
|
52
|
+
'thermal_covariance',
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# ----------------------------------------------------------------------------------------------
|
|
57
|
+
# SYMPLECTIC STRUCTURE
|
|
58
|
+
# ----------------------------------------------------------------------------------------------
|
|
59
|
+
def symplectic_form(num_modes):
|
|
60
|
+
"""
|
|
61
|
+
Ω = ⊕ [[0, 1], [-1, 0]], so that [u_i, u_j] = 2iΩ_ij
|
|
62
|
+
"""
|
|
63
|
+
return np.kron(np.eye(num_modes), np.array([[0, 1], [-1, 0]]))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _modes_of(V):
|
|
67
|
+
num_quadratures = np.shape(V)[0]
|
|
68
|
+
assert num_quadratures % 2 == 0, f'covariance matrix has odd dimension {num_quadratures}'
|
|
69
|
+
return num_quadratures // 2
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def symplectic_eigenvalues(V):
|
|
73
|
+
"""
|
|
74
|
+
The symplectic eigenvalues ν_k of a covariance matrix, sorted in ascending order
|
|
75
|
+
|
|
76
|
+
They are the moduli of the eigenvalues of iΩV, which come in pairs ±ν_k. A physical state
|
|
77
|
+
has every ν_k ≥ 1, with equality for every mode only if the state is pure.
|
|
78
|
+
"""
|
|
79
|
+
num_modes = _modes_of(V)
|
|
80
|
+
eigenvalues = np.linalg.eigvals(1j * symplectic_form(num_modes) @ np.asarray(V, dtype=float))
|
|
81
|
+
return np.sort(np.abs(eigenvalues))[::2]
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def is_physical(V, tolerance=1e-9):
|
|
85
|
+
"""
|
|
86
|
+
True if V is symmetric, positive definite and satisfies the uncertainty principle
|
|
87
|
+
"""
|
|
88
|
+
V = np.asarray(V, dtype=float)
|
|
89
|
+
if not np.allclose(V, V.T, atol=tolerance * max(1, np.abs(V).max())):
|
|
90
|
+
return False
|
|
91
|
+
if np.min(np.linalg.eigvalsh(V)) <= 0:
|
|
92
|
+
return False
|
|
93
|
+
return bool(symplectic_eigenvalues(V).min() >= 1 - tolerance)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def reduced_covariance(V, modes):
|
|
97
|
+
"""
|
|
98
|
+
Covariance matrix of a subset of the modes (the partial trace of a Gaussian state)
|
|
99
|
+
"""
|
|
100
|
+
indices = np.ravel([[2*m, 2*m + 1] for m in modes])
|
|
101
|
+
return np.asarray(V)[np.ix_(indices, indices)]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def partial_transpose(V, modes=(0,)):
|
|
105
|
+
"""
|
|
106
|
+
Covariance matrix after partial transposition of the given modes
|
|
107
|
+
|
|
108
|
+
Transposition is time reversal, P → -P, on the transposed modes only.
|
|
109
|
+
"""
|
|
110
|
+
flip = np.ones(2 * _modes_of(V))
|
|
111
|
+
for m in modes:
|
|
112
|
+
flip[2*m + 1] = -1
|
|
113
|
+
return flip[:, None] * np.asarray(V, dtype=float) * flip[None, :]
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def partially_transposed_symplectic_eigenvalues(V, modes=(0,)):
|
|
117
|
+
"""
|
|
118
|
+
Symplectic eigenvalues ν̃_k of the partially transposed covariance matrix
|
|
119
|
+
|
|
120
|
+
The state is PPT (and, for 1 × N mode bipartitions, separable) if and only if every ν̃_k ≥ 1.
|
|
121
|
+
"""
|
|
122
|
+
return symplectic_eigenvalues(partial_transpose(V, modes))
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# ----------------------------------------------------------------------------------------------
|
|
126
|
+
# ENTANGLEMENT
|
|
127
|
+
# ----------------------------------------------------------------------------------------------
|
|
128
|
+
def log_negativity(V, modes=(0,)):
|
|
129
|
+
"""
|
|
130
|
+
Logarithmic negativity E_N of the bipartition (modes | all other modes)
|
|
131
|
+
|
|
132
|
+
E_N = Σ_k max(0, -ln ν̃_k)
|
|
133
|
+
|
|
134
|
+
For two modes only the smallest ν̃_- can drop below 1, so E_N = max(0, -ln ν̃_-). It is an
|
|
135
|
+
entanglement monotone (Plenio, PRL 95, 090503 (2005)), an upper bound on the distillable
|
|
136
|
+
entanglement, additive, and invariant under local unitaries such as the free rotation of
|
|
137
|
+
each mode at its own frequency.
|
|
138
|
+
[·]
|
|
139
|
+
"""
|
|
140
|
+
ν_tilde = partially_transposed_symplectic_eigenvalues(V, modes)
|
|
141
|
+
return float(np.sum(np.maximum(0.0, -np.log(ν_tilde))))
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def negativity(V, modes=(0,)):
|
|
145
|
+
"""
|
|
146
|
+
Negativity N = (exp(E_N) - 1)/2, the absolute sum of the negative eigenvalues of ρ^{T_A}
|
|
147
|
+
[·]
|
|
148
|
+
"""
|
|
149
|
+
return float((np.exp(log_negativity(V, modes)) - 1) / 2)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def is_entangled(V, modes=(0,), tolerance=1e-12):
|
|
153
|
+
"""
|
|
154
|
+
PPT test: True if any partially transposed symplectic eigenvalue is below 1
|
|
155
|
+
"""
|
|
156
|
+
return bool(partially_transposed_symplectic_eigenvalues(V, modes).min() < 1 - tolerance)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# ----------------------------------------------------------------------------------------------
|
|
160
|
+
# OCCUPATIONS, PURITY, ENTROPY, CORRELATIONS
|
|
161
|
+
# ----------------------------------------------------------------------------------------------
|
|
162
|
+
def mean_phonon_numbers(V):
|
|
163
|
+
"""
|
|
164
|
+
〈b_j†b_j〉 for each mode (zero mean assumed), including any local squeezing energy
|
|
165
|
+
[·]
|
|
166
|
+
"""
|
|
167
|
+
V = np.asarray(V, dtype=float)
|
|
168
|
+
diagonal = np.diag(V)
|
|
169
|
+
return (diagonal[0::2] + diagonal[1::2]) / 4 - 0.5
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def symplectic_occupations(V):
|
|
173
|
+
"""
|
|
174
|
+
Effective thermal occupation of each mode on its own, from 2n + 1 = √det(V_j)
|
|
175
|
+
|
|
176
|
+
This is the occupation that sets the purity of each reduced state, and is what Deplano et
|
|
177
|
+
al., Nat. Commun. 16, 4215 (2025) quote as n_x, n_y.
|
|
178
|
+
[·]
|
|
179
|
+
"""
|
|
180
|
+
return np.array([
|
|
181
|
+
(np.sqrt(np.linalg.det(reduced_covariance(V, [m]))) - 1) / 2 for m in range(_modes_of(V))
|
|
182
|
+
])
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def phonon_moments(V):
|
|
186
|
+
"""
|
|
187
|
+
Normally ordered second moments (N, M) with N_jk = 〈b_j†b_k〉 and M_jk = 〈b_j b_k〉
|
|
188
|
+
|
|
189
|
+
b_j = (X_j + iP_j)/2. The commutator [X_j, P_j] = 2i only contributes on the diagonal.
|
|
190
|
+
"""
|
|
191
|
+
V = np.asarray(V, dtype=float)
|
|
192
|
+
num_modes = _modes_of(V)
|
|
193
|
+
X, P = slice(0, None, 2), slice(1, None, 2)
|
|
194
|
+
VXX, VPP, VXP, VPX = V[X, X], V[P, P], V[X, P], V[P, X]
|
|
195
|
+
N = (VXX + VPP + 1j*(VXP - VPX)) / 4 - 0.5 * np.eye(num_modes)
|
|
196
|
+
M = (VXX - VPP + 1j*(VXP + VPX)) / 4
|
|
197
|
+
return N, M
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def purity(V):
|
|
201
|
+
"""
|
|
202
|
+
Tr(ρ²) = 1/√det(V)
|
|
203
|
+
[·]
|
|
204
|
+
"""
|
|
205
|
+
return float(1 / np.sqrt(np.linalg.det(np.asarray(V, dtype=float))))
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _entropy_function(ν):
|
|
209
|
+
"""g(ν) = ((ν+1)/2) ln((ν+1)/2) - ((ν-1)/2) ln((ν-1)/2), with g(1) = 0"""
|
|
210
|
+
ν = np.atleast_1d(np.asarray(ν, dtype=float))
|
|
211
|
+
plus, minus = (ν + 1) / 2, (ν - 1) / 2
|
|
212
|
+
with np.errstate(divide='ignore', invalid='ignore'):
|
|
213
|
+
minus_term = np.where(minus > 1e-15, minus * np.log(np.where(minus > 1e-15, minus, 1)), 0.0)
|
|
214
|
+
return plus * np.log(plus) - minus_term
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def von_neumann_entropy(V):
|
|
218
|
+
"""
|
|
219
|
+
S(ρ) = Σ_k g(ν_k) over the symplectic eigenvalues
|
|
220
|
+
[nats]
|
|
221
|
+
"""
|
|
222
|
+
return float(np.sum(_entropy_function(np.maximum(symplectic_eigenvalues(V), 1.0))))
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def mutual_information(V, modes_A=(0,), modes_B=None):
|
|
226
|
+
"""
|
|
227
|
+
I(A:B) = S(A) + S(B) - S(AB)
|
|
228
|
+
|
|
229
|
+
Counts classical AND quantum correlations, so it is positive for separable states too.
|
|
230
|
+
[nats]
|
|
231
|
+
"""
|
|
232
|
+
num_modes = _modes_of(V)
|
|
233
|
+
if modes_B is None:
|
|
234
|
+
modes_B = [m for m in range(num_modes) if m not in modes_A]
|
|
235
|
+
V_AB = reduced_covariance(V, list(modes_A) + list(modes_B))
|
|
236
|
+
S_A = von_neumann_entropy(reduced_covariance(V, modes_A))
|
|
237
|
+
S_B = von_neumann_entropy(reduced_covariance(V, modes_B))
|
|
238
|
+
return float(S_A + S_B - von_neumann_entropy(V_AB))
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def gaussian_discord(V, measured_mode=1):
|
|
242
|
+
"""
|
|
243
|
+
Gaussian quantum discord of a two-mode state, for Gaussian measurements on `measured_mode`
|
|
244
|
+
|
|
245
|
+
Closed form of Adesso & Datta, PRL 105, 030501 (2010), written in the local symplectic
|
|
246
|
+
invariants A = det α, B = det β, C = det γ, D = det V of V = [[α, γ], [γᵀ, β]], where β is
|
|
247
|
+
the block of the measured mode. Discord is positive for almost every correlated state,
|
|
248
|
+
separable ones included, so it does not witness entanglement (Ferraro et al., PRA 81,
|
|
249
|
+
052318 (2010)). It reproduces Deplano et al. (2025)'s published D_X|Y and D_Y|X.
|
|
250
|
+
[nats]
|
|
251
|
+
"""
|
|
252
|
+
V = np.asarray(V, dtype=float)
|
|
253
|
+
assert V.shape == (4, 4), 'gaussian_discord is defined here for two modes'
|
|
254
|
+
if measured_mode == 0:
|
|
255
|
+
swap = np.array([2, 3, 0, 1])
|
|
256
|
+
V = V[np.ix_(swap, swap)]
|
|
257
|
+
α, β, γ = V[:2, :2], V[2:, 2:], V[:2, 2:]
|
|
258
|
+
A, B, C, D = np.linalg.det(α), np.linalg.det(β), np.linalg.det(γ), np.linalg.det(V)
|
|
259
|
+
|
|
260
|
+
if (D - A*B)**2 <= (1 + B) * C**2 * (A + D):
|
|
261
|
+
E_min = (2*C**2 + (B - 1)*(D - A) + 2*np.abs(C)*np.sqrt(C**2 + (B - 1)*(D - A))) / (B - 1)**2
|
|
262
|
+
else:
|
|
263
|
+
E_min = (A*B - C**2 + D - np.sqrt(C**4 + (D - A*B)**2 - 2*C**2*(A*B + D))) / (2*B)
|
|
264
|
+
|
|
265
|
+
ν_minus, ν_plus = np.maximum(symplectic_eigenvalues(V), 1.0)
|
|
266
|
+
g = lambda x: float(_entropy_function(max(x, 1.0))[0])
|
|
267
|
+
return g(np.sqrt(B)) - g(ν_minus) - g(ν_plus) + g(np.sqrt(E_min))
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
# ----------------------------------------------------------------------------------------------
|
|
271
|
+
# WITNESSES THAT ARE ONLY SUFFICIENT
|
|
272
|
+
# ----------------------------------------------------------------------------------------------
|
|
273
|
+
def local_rotation(V, angles):
|
|
274
|
+
"""
|
|
275
|
+
Rotates each mode's quadratures by its angle θ_j, i.e. applies b_j → b_j·exp(-iθ_j)
|
|
276
|
+
|
|
277
|
+
This is free evolution for a time θ_j/Ω_j: X → X cos θ + P sin θ, P → P cos θ - X sin θ.
|
|
278
|
+
"""
|
|
279
|
+
blocks = [np.array([[np.cos(θ), np.sin(θ)], [-np.sin(θ), np.cos(θ)]]) for θ in angles]
|
|
280
|
+
R = np.zeros((2*len(blocks), 2*len(blocks)))
|
|
281
|
+
for m, block in enumerate(blocks):
|
|
282
|
+
R[2*m:2*m + 2, 2*m:2*m + 2] = block
|
|
283
|
+
return R @ np.asarray(V, dtype=float) @ R.T
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def duan_criterion(V, θ1=0.0, θ2=0.0, a=1.0):
|
|
287
|
+
"""
|
|
288
|
+
Duan et al., PRL 84, 2722 (2000) inequality for one choice of local quadratures and weight
|
|
289
|
+
|
|
290
|
+
u = a·X1(θ1) + X2(θ2)/a, v = a·P1(θ1) - P2(θ2)/a
|
|
291
|
+
Every separable state has Var(u) + Var(v) ≥ 2(a² + 1/a²) in these units.
|
|
292
|
+
|
|
293
|
+
Returns the ratio (Var u + Var v) / 2(a² + 1/a²); a value below 1 proves entanglement, but
|
|
294
|
+
a value above 1 proves nothing, because the criterion is only sufficient. With fixed lab
|
|
295
|
+
quadratures it misses entanglement whose correlations sit in rotated quadratures, which is
|
|
296
|
+
always the case for the time-periodic states of a multi-tone drive.
|
|
297
|
+
[·]
|
|
298
|
+
"""
|
|
299
|
+
W = local_rotation(V, [θ1, θ2])
|
|
300
|
+
u = np.array([a, 0, 1/a, 0])
|
|
301
|
+
v = np.array([0, a, 0, -1/a])
|
|
302
|
+
return float((u @ W @ u + v @ W @ v) / (2 * (a**2 + 1/a**2)))
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def optimised_duan_criterion(V, num_starts=12, seed=0):
|
|
306
|
+
"""
|
|
307
|
+
Duan ratio minimised over both local rotations and the weight a
|
|
308
|
+
|
|
309
|
+
Still only a sufficient criterion: local squeezing is not optimised over, so it can miss
|
|
310
|
+
entanglement that the PPT test (log_negativity) detects. Its verdict (ratio < 1) is exactly
|
|
311
|
+
the Hillery-Zubairy one (hillery_zubairy_ratio > 1); see that docstring.
|
|
312
|
+
Returns (ratio, θ1, θ2, a).
|
|
313
|
+
"""
|
|
314
|
+
rng = np.random.default_rng(seed)
|
|
315
|
+
|
|
316
|
+
def objective(p):
|
|
317
|
+
return duan_criterion(V, p[0], p[1], np.exp(p[2]))
|
|
318
|
+
|
|
319
|
+
best = None
|
|
320
|
+
for _ in range(num_starts):
|
|
321
|
+
start = np.array([rng.uniform(0, 2*np.pi), rng.uniform(0, 2*np.pi), rng.normal(0, 0.5)])
|
|
322
|
+
result = minimize(objective, start, method='Nelder-Mead', options=dict(xatol=1e-8, fatol=1e-10, maxiter=4000))
|
|
323
|
+
if best is None or result.fun < best.fun:
|
|
324
|
+
best = result
|
|
325
|
+
θ1, θ2, log_a = best.x
|
|
326
|
+
return float(best.fun), float(θ1 % (2*np.pi)), float(θ2 % (2*np.pi)), float(np.exp(log_a))
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def hillery_zubairy_ratio(V):
|
|
330
|
+
"""
|
|
331
|
+
``|〈b1 b2〉|² / (〈b1†b1〉〈b2†b2〉)``, Hillery & Zubairy, PRL 96, 050503 (2006)
|
|
332
|
+
|
|
333
|
+
A value above 1 proves entanglement; it is only sufficient, and blind to entanglement that
|
|
334
|
+
is not carried by the pair correlation 〈b1 b2〉.
|
|
335
|
+
|
|
336
|
+
It is the same test as optimised_duan_criterion: with u = a·X1 + X2/a, v = a·P1 - P2/a,
|
|
337
|
+
Var(u) + Var(v) = a²(4n1 + 2) + (4n2 + 2)/a² + 8·Re(〈b1 b2〉e^{-i(θ1 + θ2)}), which contains
|
|
338
|
+
neither local squeezing nor the exchange correlation 〈b1†b2〉; minimising over the phases and
|
|
339
|
+
over a gives Var(u) + Var(v) < 2(a² + 1/a²) exactly when ``|〈b1 b2〉|² > n1·n2``.
|
|
340
|
+
[·]
|
|
341
|
+
"""
|
|
342
|
+
N, M = phonon_moments(V)
|
|
343
|
+
n1, n2 = np.real(N[0, 0]), np.real(N[1, 1])
|
|
344
|
+
return float(np.abs(M[0, 1])**2 / (n1 * n2))
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
# ----------------------------------------------------------------------------------------------
|
|
348
|
+
# PHASE REFERENCES AND PARTITIONS
|
|
349
|
+
# ----------------------------------------------------------------------------------------------
|
|
350
|
+
def common_phase_averaged(V, num_angles=16):
|
|
351
|
+
"""
|
|
352
|
+
Averages a two-mode state over a common, unknown phase: b_j → b_j·exp(-iθ) for both modes
|
|
353
|
+
|
|
354
|
+
This is what an observer without a phase reference sees, e.g. a time average of a state
|
|
355
|
+
whose pair correlation 〈b1 b2〉 rotates at Ω1 + Ω2, or not knowing the relative phase of two
|
|
356
|
+
drive tones. Pair (two-mode squeezing) correlations average to zero; exchange correlations
|
|
357
|
+
〈b1†b2〉 survive. The averaged state is not Gaussian; this returns its covariance matrix,
|
|
358
|
+
whose PPT test is still a valid (second-moment) separability test for any state.
|
|
359
|
+
"""
|
|
360
|
+
angles = 2*np.pi * np.arange(num_angles) / num_angles
|
|
361
|
+
return np.mean([local_rotation(V, [θ, θ]) for θ in angles], axis=0)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def rotate_transverse_axes(V, Ω1, Ω2, φ):
|
|
365
|
+
"""
|
|
366
|
+
Covariance matrix of the motion along transverse axes rotated by φ from the principal axes
|
|
367
|
+
|
|
368
|
+
Mode 1 and mode 2 must be the motions of ONE particle along orthogonal principal axes with
|
|
369
|
+
frequencies Ω1 and Ω2. Positions and momenta are rotated together (a point transformation),
|
|
370
|
+
and each new axis is renormalised; local renormalisation does not change entanglement.
|
|
371
|
+
|
|
372
|
+
Because the two zero-point widths differ when Ω1 ≠ Ω2, the trap's product ground state looks
|
|
373
|
+
entangled along rotated axes - exactly E_N = ½|ln(Ω1/Ω2)| at 45° - so 'x-y entanglement' is
|
|
374
|
+
only meaningful for a stated partition, normally the principal axes.
|
|
375
|
+
"""
|
|
376
|
+
S = np.diag([1/np.sqrt(2*Ω1), np.sqrt(Ω1/2), 1/np.sqrt(2*Ω2), np.sqrt(Ω2/2)])
|
|
377
|
+
c, s = np.cos(φ), np.sin(φ)
|
|
378
|
+
R = np.array([[c, 0, s, 0], [0, c, 0, s], [-s, 0, c, 0], [0, -s, 0, c]])
|
|
379
|
+
return R @ (2 * S @ np.asarray(V, dtype=float) @ S.T) @ R.T
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
# ----------------------------------------------------------------------------------------------
|
|
383
|
+
# REFERENCE STATES
|
|
384
|
+
# ----------------------------------------------------------------------------------------------
|
|
385
|
+
def two_mode_squeezed_vacuum(r, θ=0.0):
|
|
386
|
+
"""
|
|
387
|
+
Covariance matrix of the two-mode squeezed vacuum with squeezing r and pair phase θ
|
|
388
|
+
|
|
389
|
+
〈b1 b2〉 = exp(iθ)·sinh(r)·cosh(r); E_N = 2r and ν̃_- = exp(-2r).
|
|
390
|
+
"""
|
|
391
|
+
c, s = np.cosh(2*r), np.sinh(2*r)
|
|
392
|
+
V = np.array([
|
|
393
|
+
[c, 0, s, 0],
|
|
394
|
+
[0, c, 0, -s],
|
|
395
|
+
[s, 0, c, 0],
|
|
396
|
+
[0, -s, 0, c],
|
|
397
|
+
])
|
|
398
|
+
return local_rotation(V, [-θ/2, -θ/2])
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def thermal_covariance(occupations):
|
|
402
|
+
"""
|
|
403
|
+
Product of thermal states with the given mean occupations
|
|
404
|
+
"""
|
|
405
|
+
return np.diag(np.repeat(2*np.asarray(occupations, dtype=float) + 1, 2))
|