I created Qubits Tomography in my graduation research, so I will explain how to use it. The src can be found here [https://github.com/outk/graduate_thesis). The theory of Qubit Tomography is written in the thesis. (If you feel like it, I will also summarize it on Qiita.) I also created a three-level Qutrit Tomography. If any of your readers are doing Qudit Tomography, please use it. Also, people who don't know what they're saying are good! Please press to comment. ()
As a result of the simulation, you can get something like this with 3D graphics.
First, copy qubit_tomo.py under your working directory (project). The directory structure is as follows.
.
└project
└qubit_tomo.py
At the command prompt
~\project>python qubit_tomo.py
Enter.
------------------------------------------------------------
PLEASE ENTER NUMBER OF QUBITS
------------------------------------------------------------
>>
Is displayed, enter the number of Qubits you want to simulate. This time I will try with four. In addition, the measurement basis is as described in the graduation thesis. Rewrite the code when measuring with other bases.
------------------------------------------------------------
PLEASE ENTER NUMBER OF QUBITS
------------------------------------------------------------
>>
4
------------------------------------------------------------
PLEASE ENTER PATH OF EXPERIMENTAL DATA DIRECTORY
LIKE THIS >> .\datadirectory
------------------------------------------------------------
>>
Next, enter the directory path that contains the experimental data saved in the txt file. Even if there are multiple experimental data, they will tomography all of them. However, the simulation will not proceed if the 3D drawing screen remains displayed. be careful. If you have saved the experimental data as follows, you can specify as follows.
.
└project
|
├testdata
| |
| └test.txt
|
└qubit_tomo.py
------------------------------------------------------------
PLEASE ENTER PATH OF EXPERIMENTAL DATA DIRECTORY
LIKE THIS >> .\datadirectory
------------------------------------------------------------
>>
./testdata
Next, enter the output destination directory name of the calculation result. Anything is fine here. If nothing is entered, it will be "default". For example
------------------------------------------------------------
PLEASE ENTER NAME OF RESULT DIRECTORY
THE RESULT DATA WILL SAVED AT
'.\result\qubit\iterative(or poisson)\{ YOUR ENTED DIRECTORY NAME }\{ EXPERIMENTAL DATA FILE NAME }_result.txt'
IF EMPTY, THE NAME OF RESULT DIRECTORY IS 'default'
------------------------------------------------------------
>>
test
At this point, you will be asked if you want to create simulated experiment data. All inputs other than "yes" are considered "no". Pseudo-experimental data is randomly generated along the Poisson distribution with the number of times of each experimental data as the expected value.
------------------------------------------------------------
PLEASE ENTER ANSWER WHETHER DO POISSON DISTRIBUTED SIMULATION
IF YOU DO, PLEASE ENTER 'yes'
IF YOU ENTER ANOTHER WORD OR EMPTY, YOUR ANSWER IS REGARED AS 'no'
------------------------------------------------------------
>>
yes
YOUR ANSWER IS: 'yes'
------------------------------------------------------------
PLEASE ENTER PATHS OF EXPERIMENTAL DATA
IF THERE ARE MULTIPLE DATA FILE YOU WANT TO TOMOGRAPHY,
ENTER ALL PATHS SEPARATED WITH SPACE.
LIKE THIS >> .\datadirectory\ex1.txt .\datadirectory\ex2.txt ...
------------------------------------------------------------
>>
If you enter "yes", it will be displayed like this. Enter the experimental data ** file path ** that will be the source of the simulated experiment data. If "no", it will be skipped to the last parallelization number input. If "yes", for example
YOUR ANSWER IS: 'yes'
------------------------------------------------------------
PLEASE ENTER PATHS OF EXPERIMENTAL DATA
IF THERE ARE MULTIPLE DATA FILE YOU WANT TO TOMOGRAPHY,
ENTER ALL PATHS SEPARATED WITH SPACE.
LIKE THIS >> .\datadirectory\ex1.txt .\datadirectory\ex2.txt ...
------------------------------------------------------------
>>
./testdata/test.txt
Then, you will be asked how many patterns to generate the simulated experiment data, so enter the number you want to generate.
------------------------------------------------------------
PLEASE ENTER ITERATION TIME OF EACH POISSON SIMULATION
------------------------------------------------------------
>>
5
Finally, you will be asked how many parallels you want to calculate. Also, the maximum number of computers currently in use that can be parallelized is displayed, so please refer to it. (** * Note: ** If it is not about half of the maximum number that can be parallelized, the CPU usage will jump up and the simulation will not proceed. After executing the simulation, be sure to check the CPU usage with a resource monitor etc. Please give me.)
------------------------------------------------------------
HOW MANY TIMES DO YOU WANT TO PARALLELIZE?
IF THE NUMBER IS TOO LARGE, THE PARFORMANCE OF SIMULATION BECOME LOWER.
THE NUMBER OF LOGICAL PROCESSOR OF YOUR COMPUTER IS >>
6
RECOMENDED NUMBER IS LESS THAN THE ABOVE NUMBER.
------------------------------------------------------------
>>
2
All you have to do is wait for the simulation to finish. As mentioned above, other simulations will not proceed while the 3D drawing is displayed, so if you do not need it, use l.310 in src.
plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)
Please comment out as follows.
#plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)
The output result is saved in the following directory.
.
└project
|
├result
| |
| └qubit
| |
| ├iterative
| | |
| | └test
| | |
| | └result.txt
| |
| └poisson
| |
| └test
| |
| └result.txt
|
├testdata
| |
| └test.txt
|
└qubit_tomo.py
The fidelity with the ideal state is saved in result.txt
.
The ideal state is provided directly in qubit_tomo.py
.
Please rewrite if necessary.
Recommended Posts