Trajectree 0.0.2__tar.gz → 0.0.4__tar.gz

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.
Files changed (21) hide show
  1. {trajectree-0.0.2 → trajectree-0.0.4}/PKG-INFO +1 -1
  2. {trajectree-0.0.2 → trajectree-0.0.4}/Trajectree.egg-info/PKG-INFO +1 -1
  3. {trajectree-0.0.2 → trajectree-0.0.4}/pyproject.toml +1 -1
  4. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/fock_optics/measurement.py +6 -6
  5. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/fock_optics/outputs.py +10 -6
  6. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/fock_optics/utils.py +3 -0
  7. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/sequence/swap.py +7 -6
  8. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/trajectory.py +3 -2
  9. {trajectree-0.0.2 → trajectree-0.0.4}/LICENSE +0 -0
  10. {trajectree-0.0.2 → trajectree-0.0.4}/README.md +0 -0
  11. {trajectree-0.0.2 → trajectree-0.0.4}/Trajectree.egg-info/SOURCES.txt +0 -0
  12. {trajectree-0.0.2 → trajectree-0.0.4}/Trajectree.egg-info/dependency_links.txt +0 -0
  13. {trajectree-0.0.2 → trajectree-0.0.4}/Trajectree.egg-info/requires.txt +0 -0
  14. {trajectree-0.0.2 → trajectree-0.0.4}/Trajectree.egg-info/top_level.txt +0 -0
  15. {trajectree-0.0.2 → trajectree-0.0.4}/setup.cfg +0 -0
  16. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/__init__.py +0 -0
  17. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/experimental/sparse.py +0 -0
  18. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/fock_optics/devices.py +0 -0
  19. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/fock_optics/light_sources.py +0 -0
  20. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/fock_optics/noise_models.py +0 -0
  21. {trajectree-0.0.2 → trajectree-0.0.4}/trajectree/optical_quant_info.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Trajectree
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Trajectree is a quantum trajectory theory and tensor network based quantum optics simulator.
5
5
  Author-email: Ansh Singal <asingal@u.northwestern.edu>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Trajectree
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Trajectree is a quantum trajectory theory and tensor network based quantum optics simulator.
5
5
  Author-email: Ansh Singal <asingal@u.northwestern.edu>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "Trajectree"
7
- version = "0.0.2"
7
+ version = "0.0.4"
8
8
  authors = [{ name="Ansh Singal", email="asingal@u.northwestern.edu" },]
9
9
  description = "Trajectree is a quantum trajectory theory and tensor network based quantum optics simulator."
10
10
  readme = "README.md"
@@ -127,26 +127,26 @@ def bell_state_measurement(psi, N, site_tags, num_modes, efficiencies, dark_coun
127
127
  if return_MPOs:
128
128
  returned_MPOs = [U_BS_H, U_BS_V]
129
129
  if use_trajectory:
130
- quantum_channel_list = [quantum_channel(N = N, num_modes = num_modes, formalism = "closed", unitary_MPOs = BSM_MPO, name = "BSM") for BSM_MPO in returned_MPOs]
130
+ quantum_channel_list = [quantum_channel(N = N, num_modes = num_modes, formalism = "closed", unitary_MPOs = BSM_MPO, name = "beam splitter") for BSM_MPO in returned_MPOs]
131
131
 
132
132
  damping_kraus_ops_0 = single_mode_bosonic_noise_channels(noise_parameter = 1-efficiencies[0], N = N)
133
133
  damping_kraus_ops_1 = single_mode_bosonic_noise_channels(noise_parameter = 1-efficiencies[1], N = N)
134
134
  two_mode_kraus_ops_0 = [sp.kron(op1, op2) for op1 in damping_kraus_ops_0 for op2 in damping_kraus_ops_0]
135
135
  two_mode_kraus_ops_1 = [sp.kron(op1, op2) for op1 in damping_kraus_ops_1 for op2 in damping_kraus_ops_1]
136
- quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((2,3), two_mode_kraus_ops_0))) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
137
- quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((6,7), two_mode_kraus_ops_1))) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
136
+ quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((2,3), two_mode_kraus_ops_0), name = "detector inefficiency")) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
137
+ quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((6,7), two_mode_kraus_ops_1), name = "detector inefficiency")) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
138
138
 
139
139
  amplification_kraus_ops_0 = single_mode_bosonic_noise_channels(noise_parameter = dark_counts_gain[0], N = N)
140
140
  amplification_kraus_ops_1 = single_mode_bosonic_noise_channels(noise_parameter = dark_counts_gain[1], N = N)
141
141
  two_mode_kraus_ops_0 = [sp.kron(op1, op2) for op1 in amplification_kraus_ops_0 for op2 in amplification_kraus_ops_0]
142
142
  two_mode_kraus_ops_1 = [sp.kron(op1, op2) for op1 in amplification_kraus_ops_1 for op2 in amplification_kraus_ops_1]
143
- quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((2,3), two_mode_kraus_ops_0))) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
144
- quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((6,7), two_mode_kraus_ops_1))) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
143
+ quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((2,3), two_mode_kraus_ops_0), name = "dark counts")) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
144
+ quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((6,7), two_mode_kraus_ops_1), name = "dark counts")) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
145
145
 
146
146
  BSM_POVM_1_OPs = generate_sqrt_POVM_MPO(sites=measurements[1], outcome = det_outcome, total_sites=num_modes, efficiency=1, N=N, pnr = pnr)
147
147
  BSM_POVM_1_OPs.extend(generate_sqrt_POVM_MPO(sites=measurements[0], outcome = 0, total_sites=num_modes, efficiency=1, N=N, pnr = pnr))
148
148
 
149
- det_quantum_channels = [quantum_channel(N = N, num_modes = num_modes, formalism = "closed", unitary_MPOs = DET_MPO, name = "DET") for DET_MPO in BSM_POVM_1_OPs]
149
+ det_quantum_channels = [quantum_channel(N = N, num_modes = num_modes, formalism = "closed", unitary_MPOs = DET_MPO, name = "Det POVM") for DET_MPO in BSM_POVM_1_OPs]
150
150
  quantum_channel_list.extend(det_quantum_channels)
151
151
 
152
152
  return quantum_channel_list
@@ -20,7 +20,7 @@ def generate_labels(num_systems, N):
20
20
  labels.append(new_label[:-1])
21
21
  return labels
22
22
 
23
- def read_quantum_state(TN_state, N, num_states = 4, return_dense = False, precision = 10):
23
+ def read_quantum_state(TN_state, N, num_states = 4, return_dense = False, precision = 10, return_string = False):
24
24
  dense_state = TN_state.to_dense()
25
25
  if return_dense: return dense_state
26
26
  dense_state = np.reshape(dense_state.data, (-1, 1), order = 'C')
@@ -28,14 +28,18 @@ def read_quantum_state(TN_state, N, num_states = 4, return_dense = False, precis
28
28
  dense_state.data = np.round(dense_state.data, precision)
29
29
  dense_state.eliminate_zeros()
30
30
 
31
- print_quantum_state(N, dense_state, num_states)
31
+ return print_quantum_state(N, dense_state, num_states, return_string)
32
32
 
33
- def print_quantum_state(N, dense_state, num_states = 4):
33
+ def print_quantum_state(N, dense_state, num_states = 4, return_string = False):
34
34
  labels = generate_labels(num_states,N)
35
35
  state = dense_state.nonzero()[0]
36
- print("Corresponding Basis terms:")
37
- for k in state: print(labels[k],"-",k,"-",dense_state[k].data)
38
-
36
+ output = []
37
+ output.append("Corresponding Basis terms:")
38
+ for k in state: output.append(f"{labels[k]} - {k} - {dense_state[k].data}")
39
+ if not return_string:
40
+ print("\n".join(map(str, output)))
41
+ else:
42
+ return output
39
43
 
40
44
 
41
45
  def plot_coincidences(coincidence, idler_angles, signal_angles, title = ''):
@@ -8,6 +8,8 @@ from quimb.tensor.tensor_core import new_bond #type: ignore
8
8
  from quimb.tensor.tensor_1d_compress import enforce_1d_like #type: ignore
9
9
  from quimb.tensor.tensor_1d import TensorNetwork1DOperator #type: ignore
10
10
 
11
+ from .outputs import read_quantum_state
12
+
11
13
  import qutip as qt
12
14
  import re
13
15
 
@@ -154,6 +156,7 @@ def create_bimode_bell_state(bell_state, N, error_tolerance = 1e-12):
154
156
  elif bell_state == "phi_minus":
155
157
  psi = tensor_network_apply_op_vec(NOT_MPO_0, vacuum, compress=True, contract = True, cutoff = error_tolerance)
156
158
 
159
+ # read_quantum_state(psi, N)
157
160
 
158
161
  psi = tensor_network_apply_op_vec(H_MPO, psi, compress=True, contract = True, cutoff = error_tolerance)
159
162
  # read_quantum_state(psi, N, num_states = 2)
@@ -2,6 +2,7 @@ from ..fock_optics.noise_models import *
2
2
  from ..fock_optics.measurement import *
3
3
  from ..fock_optics.utils import *
4
4
  from ..fock_optics.light_sources import *
5
+ from ..fock_optics.outputs import *
5
6
 
6
7
  from ..trajectory import *
7
8
 
@@ -15,8 +16,8 @@ def generate_swapping_circuit(N, num_modes, site_tags, bsm_det_effs, bsm_dark_co
15
16
  # Amplitude damping due to fibers
16
17
  damping_kraus_ops = single_mode_bosonic_noise_channels(noise_parameter = channel_loss, N = N)
17
18
  two_mode_kraus_ops = [sp.kron(op, op) for op in damping_kraus_ops]
18
- quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((2,3), two_mode_kraus_ops))) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
19
- quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((6,7), two_mode_kraus_ops))) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
19
+ quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((2,3), two_mode_kraus_ops), name = "fiber_attenuation")) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
20
+ quantum_channel_list.append(quantum_channel(N = N, num_modes = num_modes, formalism = "kraus", kraus_ops_tuple = ((6,7), two_mode_kraus_ops), name = "fiber_attenuation")) # The tuples in this list are defined as (sites, kraus_ops). The sites are the sites where the Kraus ops are applied.
20
21
 
21
22
  # Quantum channel for the Bell state measurement
22
23
  # BSM_MPOs = bell_state_measurement(None, N, site_tags, num_modes, bsm_det_effs, error_tolerance, measurements = bsm_measurements, pnr = False, use_trajectory = True, return_MPOs = True, compress=True, contract=True)
@@ -29,7 +30,7 @@ def generate_swapping_circuit(N, num_modes, site_tags, bsm_det_effs, bsm_dark_co
29
30
  def analyze_entanglement(quantum_channel_list, N, site_tags, num_modes, efficiency, error_tolerance, idler_angles, signal_angles):
30
31
  PA_MPOs = rotate_and_measure(None, N, site_tags, num_modes, efficiency, error_tolerance, idler_angles, signal_angles, return_MPOs = True)
31
32
  PA_quantum_channels = [quantum_channel(N = N, num_modes = num_modes, formalism = "closed", unitary_MPOs = PA_MPO) for PA_MPO in PA_MPOs]
32
- print("num pa quantum channels:", len(PA_quantum_channels))
33
+ # print("num pa quantum channels:", len(PA_quantum_channels))
33
34
  quantum_channel_list.extend(PA_quantum_channels)
34
35
 
35
36
 
@@ -50,7 +51,7 @@ def perform_swapping_simulation(N, num_modes, num_simulations, params, error_tol
50
51
  quantum_channels = generate_swapping_circuit(N, num_modes, psi.site_tags, [params["BSM_det_loss_1"], params["BSM_det_loss_2"]], [params["BSM_dark_counts_1"], params["BSM_dark_counts_2"]], params["BSM_meas"], params["channel_loss"], error_tolerance)
51
52
 
52
53
  if params["if_analyze_entanglement"]:
53
- analyze_entanglement(quantum_channels, N, psi.site_tags, num_modes, params["PA_det_loss"], error_tolerance, params["alpha_list"], params["delta_list"])
54
+ analyze_entanglement(quantum_channels, N, psi.site_tags, num_modes, params["PA_det_eff"], error_tolerance, params["alpha_list"], params["delta_list"])
54
55
 
55
56
  t_eval = trajectory_evaluator(quantum_channels)
56
57
 
@@ -64,13 +65,13 @@ def perform_swapping_simulation(N, num_modes, num_simulations, params, error_tol
64
65
  probabilities.append(psi_iter.normalize())
65
66
 
66
67
  if params["calc_fidelity"]:
67
- fidelity = np.abs(calc_fidelity_swapping(psi_iter, "psi_minus", N, error_tolerance))
68
+ fidelity = np.abs(calc_fidelity_swapping(psi_iter, "psi_plus", N, error_tolerance))
68
69
  fidelities.append(fidelity)
69
70
 
70
71
  time_taken = time.time() - start
71
72
  # print("time taken for simulation", i, ":", time_taken)
72
73
 
73
- print("completed set", "cache_hits:", t_eval.cache_hit, "cache_partial_hits:", t_eval.cache_partial_hit, "cache_misses:", t_eval.cache_miss, "time taken:", time_taken)
74
+ # print("completed set", "cache_hits:", t_eval.cache_hit, "cache_partial_hits:", t_eval.cache_partial_hit, "cache_misses:", t_eval.cache_miss, "time taken:", time_taken)
74
75
 
75
76
  return fidelities, probabilities, t_eval
76
77
 
@@ -1,7 +1,7 @@
1
1
  import numpy as np
2
2
  from quimb.tensor import MatrixProductOperator as mpo #type: ignore
3
3
  from quimb.tensor.tensor_arbgeom import tensor_network_apply_op_vec #type: ignore
4
-
4
+ from .fock_optics.outputs import read_quantum_state
5
5
 
6
6
 
7
7
  class quantum_channel:
@@ -84,7 +84,7 @@ class trajectory_evaluator():
84
84
  def cache_trajectree_node(self, trajectory_probs, trajectories):
85
85
  sorted_indices = np.argsort(trajectory_probs)
86
86
 
87
- print("trajectory_probs", trajectory_probs)
87
+ # print("trajectory_probs", trajectory_probs)
88
88
 
89
89
  cached_trajectory_indices = sorted_indices[-self.cache_size:]
90
90
  cached_trajectories = np.array(trajectories)[cached_trajectory_indices]
@@ -206,5 +206,6 @@ class trajectory_evaluator():
206
206
  else:
207
207
  # print("unitary skipped:", self.traversed_nodes)
208
208
  pass
209
+ pass
209
210
 
210
211
  return psi
File without changes
File without changes
File without changes