-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qkdc_photon.py
57 lines (50 loc) · 1.43 KB
/
qkdc_photon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pennylane as qml
from jax import numpy as jnp
# prepare coherent state
def prepareCohState(input, pepper):
if pepper is None:
pepper = [0.0] * input.size
for q in range(input.size):
a = pepper[q]
phi = jnp.tan(a)
qml.CoherentState(a, phi, q)
# induce thermal state
def thermalState(input):
for c,q in enumerate(input):
nbar = q * jnp.tan(q)
qml.ThermalState(nbar, wires=c)
# displacement step
def displaceStep(input):
for q in range(input.size):
if q == 0:
dx = input.size
else:
dx = input.size * (q+1)
qml.Displacement(input.size, dx, wires=q)
# cubic phase rotations
def cubicPhase(input):
for c,q in enumerate(input):
gamma = q * jnp.tan(q)
qml.CubicPhase(gamma, wires=c)
# cross kerr interactions
def crossKerr(input):
for c,q in enumerate(input):
theta = q * (input.size * jnp.tan(q))
if c == 0:
pass
else:
qml.CrossKerr(theta, wires=[0, c])
# photonic rotations
def photonRotate(input):
for c,q in enumerate(input):
phi = q * jnp.tan(q)
qml.Rotation(phi, wires=c)
# beamsplitter interactions
def beamSplit(input):
for c,q in enumerate(input):
phi = q * (input.size * jnp.tan(q))
theta = q * (input.size * jnp.tan(q))
if c == 0:
pass
else:
qml.Beamsplitter(theta, phi, wires=[0, c])