API
Quantum Optical Device
- class soqcs.qodev(nph, nch, nm=1, ns=1, np=1, dtp=- 1.0, clock=0, R=0, loss=False, ckind='G', mem=4)
A quantum optical device consists in a quantum optical circuit and a photon abstraction of its initial state.
- Nph (int)
Maximum number of photons
- Nch (int)
Number of channels
- Nm (optional[int])
Number of modes
- Ns (optional[int])
Number of packets
- Np (optional[int])
Number of periods
- Dtp (optional[double])
Length of the periods
- Clock (optional[int])
Detector behavior configuration:
0: Counter. The detectors behave as counters.
1: Time. The detectors are able distinguish arrival times but they are blind to frequency. (This mode may change packet numeration).
2: Full. The detectors are able to distinguish arrival times and frequency of the outgoing photons.
3: Manual mode. Like 1. But the user is fully responsible of the packet definitions in order to obtain the correct calculations.
4: Period. Detectors can only distinguish the period in which photons arrive.- R (optional[int])
Number of iterations in the calculation of detector dead time and dark counts effects.
- Loss (optional[bool])
Explicit computation of losses.
- Ckind (optional[char])
Packet shape:
‘G’: Gaussian
‘E’: Exponential- Mem(optional(int))
Number of reserved entries to define the initial state. (Internal memory)
MMI2
(ch1, ch2)Adds a 2x2 MMI to the device attached to channels ch1 and ch2.
NSX
(ch1, ch2, ch3)Adds a NSX circuit element.
add_Bell
(ch1, ch2, ckind[, phi, t1, f1, w1, ...])Adds a path encoded Bell state as a device input.
add_BellP
(ch1, ch2, ckind[, phi, t1, f1, ...])Adds a polarization encoded Bell state as a device input.
add_gate
(chlist, dev[, text])Adds a gate using other device as the gate definition.
add_QD
(ch1, ch2[, t1, f1, w1, t2, f2, w2, ...])Adds a pair of photons to the input of a circuit as if they where emitted by a quantum dot in a XX-X cascade.
add_photons
(N, ch[, P, t, f, w])Adds N photons to the quantum optical device.
apply_condition
(inputst[, ignore])Apply the post-selection condition defined by the detectors in an ideal circuit to a state.
beamsplitter
(ch1, ch2, theta, phi[, colored])Adds a beamsplitter to the quantum device attached to channels ch1 and ch2.
circuit
()Returns a quantum optical circuit equivalent to the quantum device except for the initial conditions that are not defined in a circuit.
concatenate
(dev)Appends the content of two quantum devices with some limitations.
delay
(ch)Increases the optical path of a channel by a quantity equal to a period
detector
(ch[, cond, pol, mpi, mpo, eff, ...])Adds a detector to a channel of the device.
dielectric
(ch1, ch2, t, r)Adds a dieletric film attached to channels ch1 and ch2.
emitted_vis
(i, j)Overlap probability of two wavepackets.
empty_channel
(ch)Adds 0 photons to the device, no packet is defined and the indicator of empty channel is drawn if the circuit is plotted.
half
(ch, alpha)Adds a half waveplate attached to channel ch.
ignore
(ch)Flags the channel to be ignored in the outcome calculations.
input
()Returns a copy of the photon initial state.
loss
(ch, l)Adds a lossy medium with loss probability l to the circuit in channel ch.
newline
()Adds a change in the printing row where the elements are being drawn to see a more clear plot.
noise
(stdev2)Adds Gaussian white noise to the output.
open_channel
(ch)Adds 0 photons to the device, no packet is defined and the indicator of channel to be concatenated is drawn if the circuit is plotted.
phase_shifter
(ch, phi[, colored])Adds a phase shifter to the device in channel ch.
pol_beamsplitter
(ch1, ch2, P, theta)Adds a polarized beamsplitter attached to channels ch1 and ch2.
pol_filter
(ch, P)Adds a polarization filter attached to channel ch.
pol_phase_shifter
(ch, P, phi[, colored])Adds a polarized phase shifter to the device in channel ch.
pol_qubits
(qlist, ancilla, qmap)Initialize the device with photons that represent a list of polarization encoded qubits.
Prints the packet configuration of the quantum device.
quarter
(ch, alpha)Adds a quarter waveplate attached to channel ch.
qubits
(qlist, ancilla, qmap)Initialize the device with photons that represent a list of path encoded qubits.
Creates a circuit defined by a random unitary matrix.
repack
(vec)Changes the Gram-Schmidt orthonormalization order of the photon packets
rewire
(ch1, ch2)Adds a swap gate between two channels
rotator
(ch, theta, phi)Adds a polarization rotation element to the device attached to channel ch.
Adds a separator to the circuit to see a more clear plot.
show
([depth, sizexy, font, slin, rows])Plots the quantum device.
MMI2
- qodev.MMI2(ch1, ch2)
Adds a 2x2 MMI to the device attached to channels ch1 and ch2.
- Ch1 (int)
MMI2 input channel 1.
- Ch2 (int)
MMI2 input channel 2.
NSX
- qodev.NSX(ch1, ch2, ch3)
Adds a NSX circuit element. Post-selection still has to be carried out to obtain the proper functionality.
- Ch1 (int)
NSX input channel 1.
- Ch2 (int)
NSX input channel 2.
- Ch3 (int)
NSX input channel 3.
add_Bell
- qodev.add_Bell(ch1, ch2, ckind, phi=0.0, t1=0.0, f1=1.0, w1=1.0, t2=0.0, f2=1.0, w2=1.0)
Adds a path encoded Bell state as a device input.
||Phi>=||ch1,ch2>+e^(iphi)||ch1,ch2>
- Ch1 (int)
Channel 1 where the Bell state is defined.
- Ch2 (int)
Channel 2 where the Bell state is defined.
- Ckind(optional[char])
Kind og Bell state to be created.
‘+’=||00> + ||11>
‘-‘=||00> - ||11>
‘p’=||01> + ||10>
‘m’=||01> - ||10>- Phi (optional[float])
Relative phase between the first and second ket in the definition of the Bell state.
- T1 (optional[float])
Central emission time of the photon in channel 1.
- F1 (optional[float])
Central emission frequency of the photon in channel 1.
- W1 (optional[float])
Width or decay time of the the photon in channel 1.
- T2 (optional[float])
Central emission time of the photon in channel 2.
- F2 (optional[float])
Central emission frequency of the photon in channel 2.
- W2 (optional[float])
Width or decay time of the the photon in channel 2.
add_BellP
- qodev.add_BellP(ch1, ch2, ckind, phi=0.0, t1=0.0, f1=1.0, w1=1.0, t2=0.0, f2=1.0, w2=1.0)
Adds a polarization encoded Bell state as a device input.
||Phi>=||ch1,ch2>+e^(iphi)||ch1,ch2>
- Ch1 (int)
Channel 1 where the Bell state is defined.
- Ch2 (int)
Channel 2 where the Bell state is defined.
- Ckind(optional[char])
Kind of Bell state to be created.
‘+’=||HH> + ||VV>
‘-‘=||HH> - ||VV>
‘p’=||HV> + ||VH>
‘m’=||HV> - ||VH>- Phi (optional[float])
Relative phase between the first and second ket in the definition of the Bell state.
- T1 (optional[float])
Central emission time of the photon in channel 1.
- F1 (optional[float])
Central emission frequency of the photon in channel 1.
- W1 (optional[float])
Width or decay time of the the photon in channel 1.
- T2 (optional[float])
Central emission time of the photon in channel 2.
- F2 (optional[float])
Central emission frequency of the photon in channel 2.
- W2 (optional[float])
Width or decay time of the the photon in channel 2.
add_gate
- qodev.add_gate(chlist, dev, text='')
Adds a gate using other device as the gate definition.
- Chlist (list[])
List of channels to which the new gate is attached
- Dev (qodev)
Device defining the gate
- Text (string)
Text with the name given to the gate ( to be plotted )
add_QD
- qodev.add_QD(ch1, ch2, t1=0.0, f1=1.0, w1=1.0, t2=0.0, f2=1.0, w2=1.0, S=0.0, k=1.0, tss=1000000.0, thv=1000000.0, cascade=0)
Adds a pair of photons to the input of a circuit as if they where emitted by a quantum dot in a XX-X cascade.
- Ch1 (int)
Channel where the bi-exciton XX photon is emitted.
- Ch2 (int)
Channel where the exciton X photon is emitted.
- T1 (optional[float])
Central time of the XX photon wave-packet
- F1 (optional[float])
Central frequency of the XX photon wave-packet
- W1 (optional[float])
Decay time of the XX photon wave-packet
- T2 (optional[float])
Central time of the X photon wave-packet
- F2 (optional[float])
Central frequency of the X photon wave-packet
- W2 (optional[float])
Decay time of the X photon wave-packet
- S (optional[float])
Fine Structure Splitting (FSS)
- K (optional[float])
Signal to noise ratio.
- Tss (optional[float])
Spin scattering time.
- Thv (optional[float])
Cross dephasing time.
- Cascade (optional[int])
The second photon is considered to be emitted randomly after t2 to simulate a casacase 0=No/1=Yes
add_photons
- qodev.add_photons(N, ch, P=0, t=0.0, f=1.0, w=1.0)
Adds N photons to the quantum optical device.
- N (int)
Number of photons to be added.
- Ch (int)
Channel where the photons are added.
- P (optional[int])
Polarization of the photons.
- T (optional[float])
Central time of the photons wave-packet
- F (optional[float])
Central frequency of the photons wave-packet
- W (optional[float])
Width (Gaussians) or decay time (Exponentials) of the photon packet.
- Return [int]
Packet number if success, a negative value if failure.
apply_condition
- qodev.apply_condition(inputst, ignore=True)
Apply the post-selection condition defined by the detectors in an ideal circuit to a state.
Warning! This can be only applied to ideal devices ns=1 where detector naturally define a single ket projector. Otherwise the conditions lead to a density matrix output and there are other tools available in SOQCS for that purpose. Note that ignored channels are not transcribed but that may lead to collisions between otherwise different terms.
- Inputst(state)
Input state to be post-selected applying the detector conditions.
- Ignore(optional[bool])
Consider ignored channels (False=No/True=Yes)
- Return (state)
Post-selected state
beamsplitter
- qodev.beamsplitter(ch1, ch2, theta, phi, colored=False)
Adds a beamsplitter to the quantum device attached to channels ch1 and ch2.
- Ch1 (int)
Beamsplitter input channel 1.
- Ch2 (int)
Beamsplitter input channel 2.
- Theta (double)
Angle theta in degrees.
- Phi (double)
Angle phi in degrees.
- Colored (bool)
Prints the beamsplitter in a different color than the default one.
circuit
- qodev.circuit()
Returns a quantum optical circuit equivalent to the quantum device except for the initial conditions that are not defined in a circuit.
- Return (qocircuit)
A copy of the defined circuit.
concatenate
- qodev.concatenate(dev)
Appends the content of two quantum devices with some limitations. All the input photons have to be defined in the first circuit and all detectors in the last. Circuits with delays cannot be concatenated either.
- Dev (qodev)
Device to be concatenated.
delay
- qodev.delay(ch)
Increases the optical path of a channel by a quantity equal to a period
- Ch (int)
Channel where the delay is introduced.
detector
- qodev.detector(ch, cond=- 1, pol=- 1, mpi=- 1, mpo=- 1, eff=1.0, blnk=0.0, gamma=0.0)
Adds a detector to a channel of the device.
- Ch (int)
Detector channel.
- Cond (optional[int])
Detection condition.
cond>=0: Readings in the remaining channels are considered only by calculations in probability bins and density matrices if the number of photons in this channel is equal to cond.
cond=-1: There is no condition and works as a normal detector.
cond=-2: The channel is ignored by outcome calculations in probability bins and density matrices.- Pol (optional[int])
Polarization condition. If cond>=0, pol determines the polarization of the photons to fulfill the condition. Note that if pol=-1 no assumption about the polarization of those photons is made.
- Mpi (optional[int])
Initial period of the detection window (if -1 takes the first one as default).
- Mpo (optional[int])
Final period of the detection window (if -1 takes the first one as default).
- Eff (optional[float])
Efficiency of the detector.
- Blnk (optional[float])
Ratio of time in which the detector is inactive due other detections.
- Gamma (optional[float])
Average rate of dark counts in this channel.
dielectric
- qodev.dielectric(ch1, ch2, t, r)
Adds a dieletric film attached to channels ch1 and ch2. It may also work as a dieletric beamsplitter.
- Ch1 (int)
Dielectric input channel 1.
- Ch2 (int)
Dielectric input channel 2.
emitted_vis
- qodev.emitted_vis(i, j)
Overlap probability of two wavepackets.
- I (int)
Packet i.
- J (int)
Packet j.
- Return (double)
Overlap probability
empty_channel
- qodev.empty_channel(ch)
Adds 0 photons to the device, no packet is defined and the indicator of empty channel is drawn if the circuit is plotted. Note that this is different than adding 0 photons with add_photons because in this case no packet is defined.
- Ch (int)
Channel that is left empty.
half
- qodev.half(ch, alpha)
Adds a half waveplate attached to channel ch.
- Ch (int)
Waveplate input channel.
- Alpha (double)
Rotation angle in degrees.
ignore
- qodev.ignore(ch)
Flags the channel to be ignored in the outcome calculations. No detector is placed in this channel.
- Ch (int)
Ignored channel.
input
- qodev.input()
Returns a copy of the photon initial state.
- Return (state)
A copy of the initial state.
loss
- qodev.loss(ch, l)
Adds a lossy medium with loss probability l to the circuit in channel ch.
- Ch (int)
Lossy medium input channel.
- L (float)
Loss probability.
newline
- qodev.newline()
Adds a change in the printing row where the elements are being drawn to see a more clear plot.
noise
- qodev.noise(stdev2)
Adds Gaussian white noise to the output.
- Stdev2 (float)
Dispersion of the Gaussian noise.
open_channel
- qodev.open_channel(ch)
Adds 0 photons to the device, no packet is defined and the indicator of channel to be concatenated is drawn if the circuit is plotted.
- Ch (int)
Channel that is left open.
phase_shifter
- qodev.phase_shifter(ch, phi, colored=False)
Adds a phase shifter to the device in channel ch.
- Ch (int)
Phase shifter input channel.
- Phi (float)
Angle phi in degrees.
- Colored (bool)
Prints the phase shifter in a different color than the default one.
pol_beasmplitter
- qodev.pol_beamsplitter(ch1, ch2, P, theta)
Adds a polarized beamsplitter attached to channels ch1 and ch2.
- Ch1 (int)
Beamsplitter input channel 1.
- Ch2 (int)
Beamsplitter input channel 2.
- P (int)
Polarization to which the beamsplitter is sensitive.
- Theta (float)
Effectiveness of the beamsplitter. 90º => 50/50 beamsplitter. 0º => No sensitivity.
pol_filter
- qodev.pol_filter(ch, P)
Adds a polarization filter attached to channel ch.
- Ch (int)
Polarization filter input channel.
- P (int)
Polarization to be filtered.
pol_phase_shifter
- qodev.pol_phase_shifter(ch, P, phi, colored=False)
Adds a polarized phase shifter to the device in channel ch.
- Ch (int)
Phase shifter input channel.
- P (int)
Polarization to which the phase shifter is sensitive.
- Phi (float)
Angle phi in degrees.
- Colored (bool)
Prints the phase shifter in a different color than the default one.
pol_qubits
- qodev.pol_qubits(qlist, ancilla, qmap)
Initialize the device with photons that represent a list of polarization encoded qubits.
- Qlist (list[int])
Qubit values
- Ancilla (list[int])
List with the values to initalize the ancillas. Values are assigned in order from small to large channel number.
- Qmap(list[])
List with the qubit definitions.
prnt_packets
- qodev.prnt_packets()
Prints the packet configuration of the quantum device.
quarter
- qodev.quarter(ch, alpha)
Adds a quarter waveplate attached to channel ch.
- Ch (int)
Waveplate input channel.
- Alpha (double)
Rotation angle in degrees.
qubits
- qodev.qubits(qlist, ancilla, qmap)
Initialize the device with photons that represent a list of path encoded qubits.
- Qlist (list[int])
Qubit values
- Ancilla (list[int])
List with the values to initalize the ancillas. Values are assigned in order from small to large channel number.
- Qmap (list[][])
2xn matrix with the qubit definitions. Each column has two entries specifying the channels that define the qubit.
random_circuit
- qodev.random_circuit()
Creates a circuit defined by a random unitary matrix.
repack
- qodev.repack(vec)
Changes the Gram-Schmidt orthonormalization order of the photon packets
- Vec (list)
List with the preferred packet order.
rewire
- qodev.rewire(ch1, ch2)
Adds a swap gate between two channels
- Ch1 (int)
Channel 1.
- Ch2 (int)
Channel 2.
rotator
- qodev.rotator(ch, theta, phi)
Adds a polarization rotation element to the device attached to channel ch.
- Ch (int)
Rotator input channel.
- Theta (double)
Angle theta in degrees.
- Phi (double)
Angle phi in degrees.
separator
- qodev.separator()
Adds a separator to the circuit to see a more clear plot.
show
- qodev.show(depth=10, sizexy=100, font=18, slin=0, rows=1)
Plots the quantum device.
- Depth (optional[int])
Number of plot layers. The longer the circuit the more needed.
- Sizexy(optional[int])
How many pixels by layer. Controls the size of the plot.
- Font (optional[int])
Font size of the labels.
- Slin(optional(int))
Starting lines 0=’No’/1=’Yes’. If starting lines is 0 no lines are shown until the channel is initialized.
- Rows(int)
Numbers of printing lines to be used by the plotter.
If rows=1, the plot is printed in one line unless hard separators are used to manually point out the change of printing line.
If rows>1, the plot is drawn in a fixed quantity of lines. In this case the change of line is done automatically.
Quantum Circuit Simulator
- class soqcs.simulator(mem=1000)
Simulator that can be used to calculate the outcomes of a quantum device or the output state of a circuit given an input state.
- Mem(optional([int])
Reserved memory for the output expressed as a maximum number of terms. (Internal memory)
run
(dev[, method, nthreads])Calculates an output outcome from a device using the selected backend/core and the physical detectors definitions established in that device description.
run_st
(istate, qoc[, method, nthreads, st_list])Calculates an output state as a function of an input initial state using the selected backend/core according to the rules established by a quantum circuit.
sample
(dev, N)Sampling of a device using Clifford A algorithm.
metropolis
(dev, mode, N[, Nburn, Nthin])Sampling of a device using a metropolis algorithm.
get_sample
(dev, N, method[, Nburn, Nthin, mode])Get a list of samples of a device .
run
- simulator.run(dev, method=0, nthreads=- 1)
Calculates an output outcome from a device using the selected backend/core and the physical detectors definitions established in that device description.
- Dev(qodev)
Input quantum device.
- Method (optional[int])
Core method selected
0 = Direct method: The calculation is performed similarly on how it is done analytically.
1 = Direct restricted: Same as the direct method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
2 = Glynn method: The calculation is performed using permanents. We use the Balasubramanian/Bax/Franklin/Glynn formula implemented in gray code to calculate the permanents.
3 = Glynn restricted: Same as the Glynn method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
4 = Ryser method: The calculation is performed using permanents. We use the Ryser formula implemented in gray code to calculate the permanents.
5 = Ryser restricted: Same as the Ryser method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
6 = Fast Ryser method: Same as the Ryser method but only those kets with non-zero contribution to post-selection are considered. This restriction speeds up the output.
7 = Fast Ryser restricted: Same as the Fast Ryser method but considering only output states of occupations by level zero or one. This further restricts but speeds up the output.- Nthreads (optional[int])
Number of threads to be used by Ryser methods.
- Return(p_bin)
Device outcome.
run_st
- simulator.run_st(istate, qoc, method=0, nthreads=- 1, st_list=- 1)
Calculates an output state as a function of an input initial state using the selected backend/core according to the rules established by a quantum circuit.
- Istate(state)
Initial state.
- Qoc(qocircuit)
Input quantum circuit.
- Method (optional[int])
Core method selected
0 = Direct method: The calculation is performed similarly on how it is done analytically.
1 = Direct restricted: Same as the direct method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
2 = Glynn method: The calculation is performed using permanents. We use the Balasubramanian/Bax/Franklin/Glynn formula implemented in gray code to calculate the permanents.
3 = Glynn restricted: Same as the Glynn method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
4 = Ryser method: The calculation is performed using permanents. We use the Ryser formula implemented in gray code to calculate the permanents.
5 = Ryser restricted: Same as the Ryser method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
6 = Fast Ryser method: Same as the Ryser method but only those kets with non-zero contribution to post-selection are considered. This restriction speeds up the output.
7 = Fast Ryser restricted: Same as the Fast Ryser method but considering only output states of occupations by level zero or one. This further restricts but speeds up the output.- Nthreads (optional[int])
Number of threads to be used by Ryser methods.
- St_list (optional[state])
State that contains a list of ket (of any amplitude) to be calculated by run_st. If no list is provided the full output state is obtained.
- Return(state)
Output state.
sample
- simulator.sample(dev, N)
Sampling of a device using Clifford A algorithm.
Proceedings of the 2018 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA). Page 146-155. SIAM Publications Library (2018).
Warning! Clifford A is defined to be used with a single input term. Therefor neither Bell or QD initializations are recommended.
- Dev(qodev)
Input quantum device.
- N(int)
Number of samples.
- Return(p_bin)
Device outcome.
metropolis
- simulator.metropolis(dev, mode, N, Nburn=0, Nthin=1)
Sampling of a device using a metropolis algorithm.
Nature Physics 13, 1153-1157 (2017).
Warning! Metropolis is defined to be used with a single input term. Therefor neither Bell or QD initializations are recommended.
- Dev(qodev)
Input quantum device.
- Mode(int)
Sampling mode.
0: f Classical.
1: g Uniform.
2: g Classical.
3: f Classical ( Restricted ).
4: g Uniform ( Restricted ).
5: g Classical ( Restricted ).- N(int)
Number of samples.
- Optional(Nburn(int))
Number of initial samples to be skipped.
- Optional(Nthin(int))
Number of thinning samples.
- Return(p_bin)
Device outcome.
get_sample
- simulator.get_sample(dev, N, method, Nburn=0, Nthin=1, mode=0)
Get a list of samples of a device .
Nature Physics 13, 1153-1157 (2017).
Warning! Metropolis is defined to be used with a single input term. Therefor neither Bell or QD initializations are recommended.
- Dev(qodev)
Input quantum device.
- N(int)
Number of samples.
- Method(int)
Sampling method.
0: Clifford A.
1: Metropolis.
5: g Classical ( Restricted ).- Nburn optional([int])
Number of initial samples to be skipped.
- Nthin optional([int])
Number of thinning samples.
- Mode optional([int])
Sampling mode of the Metropolis sampler.
0: f Classical.
1: g Uniform.
2: g Classical.
3: f Classical ( Restricted ).
4: g Uniform ( Restricted ).
5: g Classical ( Restricted ).- Return(list[])
List of N samples
Thread Server
- class soqcs.thread_server(mem=1000)
Thread server used to launch jobs in parallel.
- Mem(optional([int])
Reserved memory for the output expressed as a maximum number of terms. (Internal memory)
send
(dev[, method])Send job to the server ( Device version )
send_st
(istate, qoc[, method])Send job to the server ( Circuit version )
receive
()Receive a job from the server
send
- thread_server.send(dev, method=0)
Send job to the server ( Device version )
- Istate(int)
Initial state
- Qoc(int)
Quantum optical circuit to which the circuit is referred.
- Method (int)
Core method selected
0 = Direct method: The calculation is performed similarly on how it is done analytically.
1 = Direct restricted: Same as the direct method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
2 = Glynn method: The calculation is performed using permanents. We use the Balasubramanian/Bax/Franklin/Glynn formula implemented in gray code to calculate the permanents.
3 = Glynn restricted: Same as the Glynn method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
4 = Ryser method: The calculation is performed using permanents. We use the Ryser formula implemented in gray code to calculate the permanents.
5 = Ryser restricted: Same as the Ryser method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
6 = Fast Ryser method: Same as the Ryser method but only those kets with non-zero contribution to post-selection are considered. This restriction speeds up the output.
7 = Fast Ryser restricted: Same as the Fast Ryser method but considering only output states of occupations by level zero or one. This further restricts but speeds up the output.
send_st
- thread_server.send_st(istate, qoc, method=0)
Send job to the server ( Circuit version )
- Istate(int)
Initial state
- Qoc(int)
Quantum optical circuit to which the circuit is referred.
- Method (int)
Core method selected
0 = Direct method: The calculation is performed similarly on how it is done analytically.
1 = Direct restricted: Same as the direct method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
2 = Glynn method: The calculation is performed using permanents. We use the Balasubramanian/Bax/Franklin/Glynn formula implemented in gray code to calculate the permanents.
3 = Glynn restricted: Same as the Glynn method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
4 = Ryser method: The calculation is performed using permanents. We use the Ryser formula implemented in gray code to calculate the permanents.
5 = Ryser restricted: Same as the Ryser method but considering only output states of occupations by level zero or one. This restricts but speeds up the output.
6 = Fast Ryser method: Same as the Ryser method but only those kets with non-zero contribution to post-selection are considered. This restriction speeds up the output.
7 = Fast Ryser restricted: Same as the Fast Ryser method but considering only output states of occupations by level zero or one. This further restricts but speeds up the output.
receive
- thread_server.receive()
Receive a job from the server
- Return(state)
Output state.
Measurement / Probability bins
- class soqcs.p_bin(level, nph=- 1, maxket=50, dummy=False)
Outcomes. Set of bins where in each bin it is stored the probability of one particular outcome.
- Level (int)
Number of levels to describe the bins.
- Nph(optional(int))
Maximum number of photons.
- Maxket(optional(int))
Maximum number of bins possible. (Internal memory)
- Dummy(automatic(bool))
If True it creates a dummy empty class. (Option used internally by the library).
add_state
(state)Adds the statistics of a quantum state.
calc_measure
(qoc)Calculates the effect of the detectors defined in a circuit over the outcome contained in this set of probability bins.
pol_translate
(qvec, dev)Translates the labels of a set of probability bins into a qubit encoding.
prnt_bins_qoc
([format, thresh, loss, qoc])Prints a set of probability bins (Circuit version).
prnt_bins
([format, thresh, loss, dev])Prints a set of probability bins (Device version).
prob_idx
(index)Returns the probability of the outcome stored in the bin referred by the index.
prob_qoc
(mtx, qoc)Returns the probability of the outcome stored in the bin described by the provided definition (Circuit version).
prob
(mtx, dev)Returns the probability of the outcome stored in the bin described by the provided definition (Device version).
nbins
()Returns the number of bins stored.
Normalizes the total probability of the set of bins to one.
Returns the number of levels that define each bin.
show
([pmax, sizex, sizey, dpi, angle, font])Plots the outcomes in a bar diagram.
trace
()Obtains the total probability of the set of bins.
tag
(index)Returns the occupation of the bin referred by the index in a string format
translate
(qmap, dev)Translates the labels of a set of probability bins into a qubit encoding.
add_state
- p_bin.add_state(state)
Adds the statistics of a quantum state.
- State (state)
Input state.
trace
- p_bin.trace()
Obtains the total probability of the set of bins. It may be inferior to one due post-selection or encoding procedures.
- Return(double)
Normalization value of the set of probability bins.
normalize
- p_bin.normalize()
Normalizes the total probability of the set of bins to one.
calc_measure
- p_bin.calc_measure(qoc)
Calculates the effect of the detectors defined in a circuit over the outcome contained in this set of probability bins. These effect are post-selection-conditions, detection window ,dark counts, detector dead time, losses and circuit noise.
- Qoc (qocircuit)
Circuit where the detectors are defined.
- Return (p_bin)
Outcomes after detector effects calculations.
nbins
- p_bin.nbins()
Returns the number of bins stored.
- return (int)
Number of bins.
num_levels
- p_bin.num_levels()
Returns the number of levels that define each bin.
- return (int)
Number of levels.
tag
- p_bin.tag(index)
Returns the occupation of the bin referred by the index in a string format
- Index (int)
Index of a bin.
- Return (int)
Occupation in string format.
prob_idx
- p_bin.prob_idx(index)
Returns the probability of the outcome stored in the bin referred by the index.
- Index (int)
Index of a bin
- Return (int)
Returns the probability of the referred bin.
prob_qoc
- p_bin.prob_qoc(mtx, qoc)
Returns the probability of the outcome stored in the bin described by the provided definition (Circuit version).
- Mtx (lilst[][])
Matrix that defines the bin. Each column defines the configuration of one level.
There are four different ways to create a definition depending on the number of rows of the matrix:
4-Row: Channels, polarization, wavepacket and occupation in this order.
3-Row: Channels, polarization and occupation in this order. Wavepackets are assumed to be the same in all cases.
2-Row: Channels and occupation in this order. Polarization and wavepackets are assumed to be the same in all cases.
1-Row: Occupation. In this case the user must provide just a list of occupations for each channel in level ordering.- Qoc (qocircuit)
Circuit to which the outcomes are referred.
- Return (int)
Returns the probability of the referred bin.
prob
- p_bin.prob(mtx, dev)
Returns the probability of the outcome stored in the bin described by the provided definition (Device version).
- Mtx (lilst[][])
Matrix that defines the bin. Each column defines the configuration of one level.
There are four different ways to create a definition depending on the number of rows of the matrix:
4-Row: Channels, polarization, wavepacket and occupation in this order.
3-Row: Channels, polarization and occupation in this order. Wavepackets are assumed to be the same in all cases.
2-Row: Channels and occupation in this order. Polarization and wavepackets are assumed to be the same in all cases.
1-Row: Occupation. In this case the user must provide just a list of occupations for each channel in level ordering.- Dev (qodevice)
Device to which the outcomes are referred.
- Return (int)
Returns the probability of the referred bin.
translate
- p_bin.translate(qmap, dev)
Translates the labels of a set of probability bins into a qubit encoding. (Path encoding version). Those that can not be encoded are ignored and the result is normalized.
Only for ideal circuits (nm=1 and nd=1).
Warning! post-selection over ignored channels may not result in a pure state. Encoding is not possible under those circunstances and a warning will be printed.
- Qmap(list[][])
2xn matrix with the qubit definitions. Each column has two entries specifying the channels that define the qubit.
- Dev(qodev)
Device to which the set of probability bins is related.
- Return out(p_bin)
A translated set of probability bins.
pol_translate
- p_bin.pol_translate(qvec, dev)
Translates the labels of a set of probability bins into a qubit encoding. (Polarization encoding version). Those that can not be encoded are ignored and the result is normalized.
Only for ideal circuits (nm=1 and nd=1).
Warning! post-selection over ignored channels may not result in a pure state. Encoding is not possible under those circunstances and a warning will be printed.
- Qvec(list[])
List with the qubit definitions.
- Dev(qodev)
Device to which the set of probability bins is related.
- Return out(p_bin)
A translated set of probability bins.
prnt_bins_qoc
- p_bin.prnt_bins_qoc(format=0, thresh=0.0, loss=False, qoc=None)
Prints a set of probability bins (Circuit version).
- Format (optional[int])
Format of the output.
- Thresh (optional[float])
Minimum value of a bin to be printed.
- Loss (optional[bool])
Print loss channels in different color (True=Yes, False=No)
- Qoc (optional[qocircuit])
Quantum circuit to whom the bins are referred.
prnt_bins
- p_bin.prnt_bins(format=0, thresh=0.0, loss=False, dev=None)
Prints a set of probability bins (Device version).
- Format (optional[int])
Format of the output.
- Thresh (optional[float])
Minimum value of a bin to be printed.
- Loss (optional[bool])
Print loss channels in different color (True=Yes, False=No)
- Dev (optional[qodev])
Quantum circuit to whom the bins are referred.
show
- p_bin.show(pmax=- 1.0, sizex=8, sizey=5, dpi=100, angle=70, font=14)
Plots the outcomes in a bar diagram.
- Sizex(optional[float])
Size of the plot in the x direction in inches.
- Sizey(optional[float])
Size of the plot in the y direction in inches.
- Dpi(optional[float])
Density of points by inch.
- Angle(optional[float])
Angle of the horizontal axis labels.
- Font(optional[fint])
Size of the font of the horizontal axis labels.
Density matrix
- class soqcs.dmatrix(mem=1000, dummy=False)
Outcomes. Density matrix of states.
- Meme(optional(int))
Maximum number of rows(or/and columns) possible. (Internal memory)
- Dummy(automatic(bool))
If True it creates a dummy empty class. (Option used internally by the library).
add_state
(state, dev)Adds a new state to the density matrix using the post-selection condition defined by the circuit detectors (Device version).
add_state_qoc
(state, qoc)Adds a new state to the density matrix using the post-selection condition defined by the circuit detectors (Circuit version).
calc_measure
(dev)Calculate measure (Device version).
calc_measure_qoc
(qoc)Calculate measure (Circuit version).
fidelity
(state)Calculates the fidelity of a density matrix with respect a reference state.
Normalizes the density matrix to trace = 1.
pol_translate
(qvec, dev)Translates the labels of a set of probability bins into a qubit encoding.
prnt_mtx
([format, thresh, dev])Prints a relevant density submatrix (Device version).
prnt_mtx_qoc
([format, thresh, qoc])Prints a relevant density submatrix (Circuit version).
trace
()Calculates the trace of the density matrix.
translate
(qmap, dev)Translates the labels of a set of probability bins into a qubit encoding.
trace
- dmatrix.trace()
Calculates the trace of the density matrix.
- Return(double)
Trace of the density matrix,
normalize
- dmatrix.normalize()
Normalizes the density matrix to trace = 1.
fidelity
- dmatrix.fidelity(state)
Calculates the fidelity of a density matrix with respect a reference state.
- State(state)
Reference state to compare with the density matrix.
- Return(double)
Fidelity value.
add_state_qoc
- dmatrix.add_state_qoc(state, qoc)
Adds a new state to the density matrix using the post-selection condition defined by the circuit detectors (Circuit version).
- State(state)
State to be added to the set of states used to calculate the density matrix entries.
- Qoc(qocircuit)
Circuit where the detectors are defined.
calc_measure_qoc
- dmatrix.calc_measure_qoc(qoc)
Calculate measure (Circuit version). It means to remove degrees of freedom depending on the circuit configuration of the detectors.
- Qoc(qocircuit)
Circuit to which the density matrix is related.
- Return(dmat)
Reduced matrix.
prnt_mtx_qoc
- dmatrix.prnt_mtx_qoc(format=0, thresh=0.0, qoc=None)
Prints a relevant density submatrix (Circuit version). Only the rows and columns with sum values greater than “thresh” are printed.
- Format (optional[int])
Format of the output.
- Thresh (optional[double])
Threshold value to print.
- Qoc (optional[qocircuit])
Circuit to which the density matrix is related.
add_state
- dmatrix.add_state(state, dev)
Adds a new state to the density matrix using the post-selection condition defined by the circuit detectors (Device version).
- State(state)
State to be added to the set of states used to calculate the density matrix entries.
- Dev(qodev)
Device where the detectors are defined
calc_measure
- dmatrix.calc_measure(dev)
Calculate measure (Device version). It means to remove degrees of freedom depending on the circuit configuration of the detectors.
- Dev(qodev)
Device to which the density matrix is related.
- Return(dmat)
Reduced matrix.
prnt_mtx
- dmatrix.prnt_mtx(format=0, thresh=0.0, dev=None)
Prints a relevant density submatrix (Device version). Only the rows and columns with sum values greater than “thresh” are printed.
- Format (optional[int])
Format of the output.
- Thresh (optional[double])
Threshold value to print.
- Dev (optional[qodev])
Device to which the density matrix is related.
translate
- dmatrix.translate(qmap, dev)
Translates the labels of a set of probability bins into a qubit encoding. (Path encoding version). Those that can not be encoded are ignored and the result is normalized.
Only for ideal circuits (nm=1 and nd=1).
Warning! post-selection over ignored channels may not result in a pure state. Encoding is not possible under those circunstances and a warning will be printed.
- Qmap(list[][])
2xn matrix with the qubit definitions. Each column has two entries specifying the channels that define the qubit.
- Dev(qodev)
Device to which the set of probability bins is related.
- Return out(p_bin)
A translated set of probability bins.
pol_translate
- dmatrix.pol_translate(qvec, dev)
Translates the labels of a set of probability bins into a qubit encoding. (Polarization encoding version). Those that can not be encoded are ignored and the result is normalized.
Only for ideal circuits (nm=1 and nd=1).
Warning! post-selection over ignored channels may not result in a pure state. Encoding is not possible under those circunstances and a warning will be printed.
- Qvec(list[])
List with the qubit definitions.
- Dev(qodev)
Device to which the set of probability bins is related.
- Return out(p_bin)
A translated set of probability bins.
Quantum Optical Circuit
- class soqcs.qocircuit(nch, nm=1, ns=1, np=1, dtp=- 1.0, clock=0, R=0, loss=False, ckind='G', dummy=False)
A quantum circuit consist in a set of interconnected quantum optical elements.
- Nch (int)
Number of channels
- Nm (optional[int])
Number of modes
- Ns (optional[int])
Number of packets
- Np (optional[int])
Number of periods
- Dtp (optional[double])
Length of the periods
- Clock (optional[int])
Detector behavior configuration:
0: Counter. The detectors behave as counters.
1: Time. The detectors are able distinguish arrival times but they are blind to frequency. (This mode may change packet numeration).|br| 2: Full. The detectors are able to distinguish arrival times and frequency of the outgoing photons.
3: Manual mode. Like 1. But the user is fully responsible of the packet definitions in order to obtain the correct calculations.
4: Period. Detectors can only distinguish the period in which photons arrive.- R (optional[int])
Number of iterations in the calculation of detector dead time and dark counts effects.
- Loss (optional[bool])
Explicit computation of losses.
- Ckind (optional[char])
Packet shape:
‘G’: Gaussian
‘E’: Exonetial- Dummy(automatic(bool))
If True it creates a dummy empty class. (Option used internally by the library).
MMI2
(ch1, ch2)Adds a 2x2 MMI to the circut attached to channels ch1 and ch2.
NSX
(ch1, ch2, ch3)Adds a NSX circuit element.
beamsplitter
(ch1, ch2, theta, phi)Adds a beamsplitter to the quantum circuit attached to channels ch1 and ch2.
def_packet
(n, t, f, w)Adds to the circuit a new definition of a wave packet.
delay
(ch)Increases the optical path of a channel by a quantity equal to a period.
detector
(ch[, cond, pol, mpi, mpo, eff, ...])Adds a detector to a channel of the circuit.
dielectric
(ch1, ch2, t, r)Adds a dieletric film attached to channels ch1 and ch2.
emitted_vis
(i, j)Overlap probability between two wave packets.
emitter
()Adds an emitter to the circuit using the packet definition given by def_packet.
general_medium
(ch, t)Adds a general homogeneous medium to the circuit
half
(ch, alpha)Adds a half waveplate attached to channel ch.
ignore
(ch)Flags the channel to be ignored in the outcome calculations.
loss
(ch, l)Adds a lossy medium with loss probability l to the circuit in channel ch.
noise
(stdev2)Adds Gaussian white noise to the output.
Returns the total number of levels of the circuit..
phase_shifter
(ch, phi)Adds a phase shifter to the circuit in channel ch.
prnt
([fmt])Prints the circuit matrix.
pol_beamsplitter
(ch1, ch2, P, theta)Adds a polarized beamsplitter attached to channels ch1 and ch2.
pol_filter
(ch, P)Adds a polarization filter attached to channel ch.
pol_phase_shifter
(ch, P, phi)Adds a polarized phase shifter attached to channel ch.
quarter
(ch, alpha)Adds a quarter waveplate attached to channel ch.
Creates a circuit defined by a random unitary matrix.
rewire
(ch1, ch2)Adds a swap gate between two channels
rotator
(ch, theta, phi)Adds a polarization rotation element to the circuit attached to channel ch.
waveplate
(ch, alpha, gamma)Adds a general waveplate attached to channel ch.
MMI2
- qocircuit.MMI2(ch1, ch2)
Adds a 2x2 MMI to the circut attached to channels ch1 and ch2.
- Ch1 (int)
MMI2 input channel 1.
- Ch2 (int)
MMI2 input channel 2.
NSX
- qocircuit.NSX(ch1, ch2, ch3)
Adds a NSX circuit element. Post-selection still has to be carried out to obtain the proper functionality.
- Ch1 (int)
NSX input channel 1.
- Ch2 (int)
NSX input channel 2.
- Ch3 (int)
NSX input channel 3.
beamsplitter
- qocircuit.beamsplitter(ch1, ch2, theta, phi)
Adds a beamsplitter to the quantum circuit attached to channels ch1 and ch2.
- Ch1 (int)
Beamsplitter input channel 1.
- Ch2 (int)
Beamsplitter input channel 2.
def_packet
- qocircuit.def_packet(n, t, f, w)
Adds to the circuit a new definition of a wave packet.
Warning! Note that when the detectors are not configured as counters the packet numeration may change on emission.
- N(int)
Suggested wavepacket number.
- T(float)
Wavepacket characteristic emission time.
- F(float)
Wavepacket characteristic frequency.
- W(float)
Width or decay length depending if the packet shape model is Gaussian or Exponential.
delay
- qocircuit.delay(ch)
Increases the optical path of a channel by a quantity equal to a period.
- Ch (int)
Channel where the delay is introduced.
detector
- qocircuit.detector(ch, cond=- 1, pol=- 1, mpi=- 1, mpo=- 1, eff=1.0, blnk=0.0, gamma=0.0)
Adds a detector to a channel of the circuit.
- Ch (int)
Detector channel.
- Cond (optional[int])
Detection condition.
cond>=0: Readings in the remaining channels are considered only by calculations in probability bins and density matrices if the number of photons in this channel are equal to cond.
cond=-1: There is no condition and works as a normal detector.
cond=-2: The channel is ignored by outcome calculations in probability bins and density matrices.- Pol (optional[int])
Polarization condition. If cond>=0, pol determines the polarization of the photons to fulfill the condition. Note that if pol=-1 no assumption about the polarization of those photons is made.
- Mpi (optional[int])
Initial period of the detection window (if -1 takes the first one as default).
- Mpo (optional[int])
Final period of the detection window (if -1 takes the first one as default).
- Eff (optional[float])
Efficiency of the detector.
- Blnk (optional[float])
Ratio of time in which the detector is inactive due other detections.
- Gamma (optional[float])
Average rate of dark counts in this channel.
dielectric
- qocircuit.dielectric(ch1, ch2, t, r)
Adds a dieletric film attached to channels ch1 and ch2. It may also work as a dieletric beamsplitter.
- Ch1 (int)
Dielectric input channel 1.
- Ch2 (int)
Dielectric input channel 2.
emitted_vis
- qocircuit.emitted_vis(i, j)
Overlap probability between two wave packets.
- I (int)
Packet i.
- J (int)
Packet j.
- Return(float)
Probability of overlap.
general_medium
- qocircuit.general_medium(ch, t)
Adds a general homogeneous medium to the circuit
- Ch (int)
Input channel.
- T (complex)
Transmitance
half
- qocircuit.half(ch, alpha)
Adds a half waveplate attached to channel ch.
- Ch (int)
Waveplate input channel.
- Alpha (double)
Rotation angle in degrees.
ignore
- qocircuit.ignore(ch)
Flags the channel to be ignored in the outcome calculations. No detector is placed in this channel.
- Ch (int)
Ignored channel.
loss
- qocircuit.loss(ch, l)
Adds a lossy medium with loss probability l to the circuit in channel ch.
- Ch (int)
Lossy medium input channel.
- L (float)
Loss probability.
noise
- qocircuit.noise(stdev2)
Adds Gaussian white noise to the output.
- Stdev2 (float)
Dispersion of the Gaussian noise.
num_levels
- qocircuit.num_levels()
Returns the total number of levels of the circuit..
- Return(int)
Number of levels of the circuit.
phase_shifter
- qocircuit.phase_shifter(ch, phi)
Adds a phase shifter to the circuit in channel ch.
- Ch (int)
Phase shifter input channel.
- Phi (float)
Angle phi in degrees.
prnt
- qocircuit.prnt(fmt=0)
Prints the circuit matrix.
- Fmt(int)
Flag that controls the print style.
0 = Prints numerically.
N = Prints the polarization using the alphabet (H/V).
pol_beasmplitter
- qocircuit.pol_beamsplitter(ch1, ch2, P, theta)
Adds a polarized beamsplitter attached to channels ch1 and ch2.
- Ch1 (int)
Beamsplitter input channel 1.
- Ch2 (int)
Beamsplitter input channel 2.
- P (int)
Polarization to which the beamsplitter is sensitive.
- Theta (float)
Effectiveness of the beamsplitter. 90º => 50/50 beamsplitter. 0º => No sensitivity.
pol_filter
- qocircuit.pol_filter(ch, P)
Adds a polarization filter attached to channel ch.
- Ch (int)
Polarization filter input channel.
- P (int)
Polarization to be filtered.
pol_phase_shifter
- qocircuit.pol_phase_shifter(ch, P, phi)
Adds a polarized phase shifter attached to channel ch.
- Ch (int)
Phase shifter input channel.
- P (int)
Polarization to which the phase shifter is sensitive.
- Phi (double)
Phase in degrees.
quarter
- qocircuit.quarter(ch, alpha)
Adds a quarter waveplate attached to channel ch.
- Ch (int)
Waveplate input channel.
- Alpha (double)
Rotation angle in degrees.
random_circuit
- qocircuit.random_circuit()
Creates a circuit defined by a random unitary matrix.
rewire
- qocircuit.rewire(ch1, ch2)
Adds a swap gate between two channels
- Ch1 (int)
Channel 1.
- Ch2 (int)
Channel 2.
rotator
- qocircuit.rotator(ch, theta, phi)
Adds a polarization rotation element to the circuit attached to channel ch.
- Ch (int)
Rotator input channel.
- Theta (double)
Angle theta in degrees.
- Phi (double)
Angle phi in degrees.
waveplate
- qocircuit.waveplate(ch, alpha, gamma)
Adds a general waveplate attached to channel ch.
- Ch (int)
Waveplate input channel.
- Alpha (double)
Rotation angle in degrees.
- Gamma (double)
Wavenumber delay of one component with respect the other in degrees.
State
- class soqcs.state(level, nph=- 1, maxket=50, dummy=False)
Quantum bosonic state definition. A quantum state is a sum of kets multiplied by amplitudes.
- Level (int)
Number of levels to describe the state.
- Nph(optional(int))
Maximum number of photons.
- Maxket(optional(int))
Maximum number of different terms in the summation. (Internal memory).
- Dummy(automatic(bool))
If True it creates a dummy empty class. (Option used internally by the library).
add_ket
(ampl, vec)Adds a new term to the state using a vector with the level occupation.
add_term
(ampl, mtx, qoc)Adds a new term to the state using a definition of the term.
braket
(state)Performs the bra-ket operation <bra|state> using the complex conjugate of this state as bra.
encode
(qmap, qoc)Encode a state into a qubit encoding (Path encoding version).
decode
(qmap, ancilla, qoc)Decode a state from a qubit encoding into photon encoding.
Normalizes the state.
pol_encode
(qvec, qoc)Encode a state into a qubit encoding (Polarization encoding version).
pol_decode
(qvec, ancilla, qoc)Decode a state from a qubit encoding into photon encoding.
post_selection
(prj)Post-selection over states by the condition defined in the the "projector".
prnt_state
([format, column, loss, qoc])Prints a state in one of the specified the formats.
rephase
(mtx, qoc)Changes the global phase of the state to make real the coefficient of the reference ket defined by mtx.
add_term
- state.add_term(ampl, mtx, qoc)
Adds a new term to the state using a definition of the term.
- Ampl(complex)
Amplitude of the new term.
- Mtx(list[][])
Matrix that defines the new term. Each column defines the configuration of one level.
There are four different ways to create these configurations depending on the number of rows of the term matrix:
4-Row: Channels, polarization, wavepacket and occupation in this order.
3-Row: Channels, polarization and occupation in this order. Wavepackets are assumed to be the same in all cases.
2-Row: Channels and occupation in this order. Polarization and wavepackets are assumed to be the same in all cases.
1-Row: Occupation. In this case the user must provide just a list of occupations for each channel in level ordering.
Except in the 1-Row case the order is irrelevant. Furthermore, levels not configured are assumed to be initialized by zero.- Qoc(qocircuit)
Circuit to which the term is related.
add_ket
- state.add_ket(ampl, vec)
Adds a new term to the state using a vector with the level occupation.
- Ampl(complex)
Amplitude of the new term.
- Vel(list[int])
List with the occupation of each level in the new term.
- Qoc(qocircuit)
Circuit to which the term is related.
braket
- state.braket(state)
Performs the bra-ket operation <bra|state> using the complex conjugate of this state as bra.
- State(state)
State in the right hand side of the braket operation.
- Return (complex)
The complex number result of the projection.
normalize
- state.normalize()
Normalizes the state.
post_selection
- state.post_selection(prj)
Post-selection over states by the condition defined in the the “projector”.
- Prj(projector)
Projector with the description of the levels (and their occupations) to be post-selected.
encode
- state.encode(qmap, qoc)
Encode a state into a qubit encoding (Path encoding version). Those kets that can not be encoded are dismissed and the result is normalized.
Only for ideal circuits (nm=1 and ns=1).
Warning! post-selection over ignored channels may not result in a pure state. Encoding is not possible under those circunstances and a warning will be printed.
- Qmap(list[][])
2xn matrix with the qubit definitions. Each column has two entries specifying the channels that define the qubit.
- Qoc(qocircuit)
Circuit which the state is related.
- Return output(state)
An encoded state.
decode
- state.decode(qmap, ancilla, qoc)
Decode a state from a qubit encoding into photon encoding. (Path encoding version).
Only for ideal circuits (nm=1 and ns=1).
Note that we need to define the values of the extra ancilla channels that are not included into the qubit encoding but they are needed to the circuit to work in the intended way
- Qmap(list[][])
2xn matrix with the qubit definitions. Each column has two entries specifying the channels that define the qubit.
- Ancilla(list[])
List with the values of the ancilla channels (from smaller to large channel number).
- Qoc(qocircuit)
Circuit which the state is related.
- Return output(state)
A decoded state.
pol_encode
- state.pol_encode(qvec, qoc)
Encode a state into a qubit encoding (Polarization encoding version). Those kets that can not be encoded are dismissed and the result is normalized.
Only for ideal circuits (ns=1).
Warning! post-selection over ignored channels may not result in a pure state. Encoding is not possible under those circunstances and a warning will be printed.
- Qvec(list[])
List with the qubit definitions.
- Qoc(qocircuit)
Circuit which the state is related.
- Return output(state)
An encoded state.
pol_decode
- state.pol_decode(qvec, ancilla, qoc)
Decode a state from a qubit encoding into photon encoding. (Polarization encoding version).|br| Only for ideal circuits (ns=1).
Note that we need to define the values of the extra ancilla channels that are not included into the qubit encoding but they are needed to the circuit to work in the intended way
- Qvec(list[])
List with the qubit definitions.
- Ancilla(list[])
List with the values of the ancilla channels (from smaller to large channel number). 0=”Horizontal”/1=”Vertical”.
- Qoc(qocircuit)
Circuit which the state is related.
- Return output(state)
A decoded state.
prnt_state
- state.prnt_state(format=0, column=0, loss=False, qoc=None)
Prints a state in one of the specified the formats. If loss=True loss channels are printed in blue.
- Format (optional[int])
Format of the output.
- Column (optional[int])
Print in row or column. 0=Rows/1=Columns
- Loss (optional[bool])
Print loss channels in different color (True=Yes, False=No)
- Qoc (optional[qocircuit])
Quantum circuit to whom the state is referred.
rephase
- state.rephase(mtx, qoc)
Changes the global phase of the state to make real the coefficient of the reference ket defined by mtx.
- Mtx(list[][])
Matrix that defines the ket which coefficient is used as reference. Each column defines the configuration of one level.
There are four different ways to create these configurations depending on the number of rows of the term matrix:
4-Row: Channels, polarization, wavepacket and occupation in this order.
3-Row: Channels, polarization and occupation in this order. Wavepackets are assumed to be the same in all cases.
2-Row: Channels and occupation in this order. Polarization and wavepackets are assumed to be the same in all cases.
1-Row: Occupation. In this case the user must provide just a list of occupations for each channel in level ordering.
Except in the 1-Row case the order is irrelevant. Furthermore, levels not configured are assumed to be initialized by zero.- Qoc(qocircuit)
Circuit to which the term is related.
Projector
- class soqcs.projector(nlevel, nph=- 1, maxket=10)
Condition that have to be met to accept a state in post-selection.
- Level (int)
Number of levels
- Nph(optional(int))
Maximum number of photons.
- Maxket(optional(int))
Maximum number of terms to define the projector. (Internal memory)
add_term
(ampl, mtx, qoc)Adds a new term to the projector.
add_term
- projector.add_term(ampl, mtx, qoc)
Adds a new term to the projector.
- Ampl(complex)
Amplitude of the new term.
- Mtx(list[][])
Matrix that defines the new tern. Each column defines the configuration of one level.|br| There are four different ways to create these configurations depending on the number of rows of the term matrix:
4-Row: Channels, polarization, wavepacket and occupation in this order.
3-Row: Channels, polarization and occupation in this order. Wavepackets are assumed to be the same in all cases.
2-Row: Channels and occupation in this order. Polarization and wavepackets are assumed to be the same in all cases.
1-Row: Occupation. In this case the user must provide just a list of occupations for each channel in level ordering.
Except in the 1-Row case the order is irrelevant.- Qoc(qocircuit)
Circuit to which the term is related.
Configuration and Plot methods
cfg_soqcs
- soqcs.cfg_soqcs(nph)
It defines the maximum number of photons to be used by SOQCS.
- Nph (int)
Maximum number of photons used by SOQCS.
plot
- soqcs.plot(pfunc, cnvx, cnvy, textx, x0, x1, nxt, texty, y0, y1, nyt, N, argsv=[{0: 0}], colorv=['b'], padb=0.0, padt=0.0)
Plots a multivalued function.
- Pfunc (method)
Method with the function to be plotted pfunc(x,args) where x is a float and args is a dictionary of parameters.
- Cnvx (int)
Size in x of the figure.
- Cnvy (int)
Size in y of the figure.
- Textx (string)
Label x axis.
- X0 (float)
Start x value.
- X1 (float)
End x value.
- Nxt (int)
Number of x ticks.
- Texty (string)
Label y axis.
- Y0 (float)
Start y value.
- Y1 (float)
End y value.
- Nyt (int)
Number of y ticks.
- N (int)
Number of points.
- Argsv(dicc)
Dictionary with the parameters for each sweep to pfunc.
- Colorv(list)
Colors assigned to each sweep of pfunc.
- Padb (float)
Pad bottom. Some extra space at the bottom to better visualization.
- Padt (float)
Pad top. Some extra space at the top to better visualization.
plot_data
- soqcs.plot_data(probs, X, cnvx, cnvy, textx, x0, x1, nxt, texty, y0, y1, nyt, N, colorv=['b'], padb=0.0, padt=0.0)
Scatter plot of (X,Y) pairts
- Y (list[double])
Y-Data to be plotted of a (X,Y) pair
- X (list[double])
X-Data to be plotted of a (X,Y) pair
- Cnvx (int)
Size in x of the figure.
- Cnvy (int)
Size in y of the figure.
- Textx (string)
Label x axis.
- X0 (float)
Start x value.
- X1 (float)
End x value.
- Nxt (int)
Number of x ticks.
- Texty (string)
Label y axis.
- Y0 (float)
Start y value.
- Y1 (float)
End y value.
- Nyt (int)
Number of y ticks.
- N (int)
Number of points.
- Color
Color of the plot.
- Padb (float)
Pad bottom. Some extra space at the bottom to better visualization.
- Padt (float)
Pad top. Some extra space at the top to better visualization.
Auxiliary classes and methods
Memory management
- soqcs.free_ptr(array)
Free memory assigned to pointers defined in C++
- Array(POINTER)
Vector pointer
- soqcs.to_int_ptr(mtx)
Converts a mtx into a integer pointer.
- Mtx(list[][])
Matrix
- soqcs.to_int_vec(vec)
Converts a list into a integer pointer.
- Vec(list[])
List
Qodev auxiliary classes
- class soqcs.auxqodev(nph, nch, nm=1, ns=1, np=1, dtp=- 1.0, clock=0, R=0, loss=False, ckind='G', maxket=1)
Auxiliary class implementing the functionality of a Quantum Optical Device. It is initialized with the same parameters than qodev. Intended for the internal use of the library.
- class soqcs.gcircuit
Auxiliary class implementing the graphical representation of a Quantum Optical Device. Graphical elements definitions are stored in a list that is read when the device is shown. Intended for internal use of the library.