[PYTHON] Verwendung von Qubits Tomography (mein Abschlussprodukt)

How to use Qubits Tomography

I made Qubits Tomography as my graduate product, so I tell you how to use it. SRC is here. The theory of Qubit Tomography is written at my graduate thesis in Japanese. So if you understand it, I recommend you read reference papers. And I alse made Qutrit Tomography, which is three dimentional version of qubit. If you would like to use Qudit Tomography, please use this product. Additionally, if you can't understand these, please give it a thumbs up and comment!

As a result of this, you can get 3D graphics like this. mixed.png

How to use

At first, copy the file of "qubit_tomo.py" in current directory.
The structure of directory may be like this.

.
└project
    └qubit_tomo.py

In command prompt,

~\project>python qubit_tomo.py

enter "python qubit_tomo.py" or "python ./qubit_tomo.py".

------------------------------------------------------------
PLEASE ENTER NUMBER OF QUBITS
------------------------------------------------------------
>>

After that, like this lines are shown, please enter a number of Qubits you want to do.
In this time, I try to simulate for 4 qubits.
And the bases of measurement which I use is written in my graduate thesis.
If you want to use other bases, please rewrite bases in src directly.

 ------------------------------------------------------------
PLEASE ENTER NUMBER OF QUBITS
------------------------------------------------------------
>>
4
------------------------------------------------------------
PLEASE ENTER PATH OF EXPERIMENTAL DATA DIRECTORY

LIKE THIS >> .\datadirectory
------------------------------------------------------------
>> 

Next, please enter directory path which include experimental data files of '*.txt'.
If there are some experimental data files, this simulater can do all of them automatically.
But, while 3D graphics as a result is shown, simulater stop.
So please delete graphics to continue.
When experimental data files is like this, you can enter like this.

.
└project
    |
    ├testdata
    |  |
    |  └test.txt
    |
    └qubit_tomo.py


------------------------------------------------------------
PLEASE ENTER PATH OF EXPERIMENTAL DATA DIRECTORY

LIKE THIS >> .\datadirectory
------------------------------------------------------------
>>
./testdata

Next, please enter a name of result directory.
Any name can be acceptable if your machine allow.
If you enter nothing, the name of result directory is "default".
I try "test".

------------------------------------------------------------
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

After that, you need to select whether you make artificial experimental data sets or not.
When you enter only "yes", artificial experimental data sets is made and simulated.
These data sets is made following poisson distribution.

------------------------------------------------------------
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", you need to enter a file path of experimental data as model.
If you enter another word, your next question will be how many do parallel computing.
After "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

you are asked how many patterns do you make, so please enter a number you want.

------------------------------------------------------------
PLEASE ENTER ITERATION TIME OF EACH POISSON SIMULATION
------------------------------------------------------------
>>
5

Finally, you need to enter how many parallel computing you want.
And the maximum number of parallel that your computer can do is shown, so please refer it.
(※Attention: If you choose too many number of parallel, CPU can't work well. So I recommend about half of that number. And you must check your CPU working rate is proper.)

------------------------------------------------------------
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 that is left is waiting for finishing simulating.
As mentioned above, whem 3D graphics is shown, simulater is stop.
So if you do not need to show this picture, please comment out of line 310 in src.

plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)

Like this.

#plotResult(numberOfQubits, estimatedDensityMatrix, baseNames)

Result

The result is saved in result directory of which you enter the name.

.
└project
    |
    ├result
    |  |
    |  └qubit
    |      |
    |      ├iterative
    |      |  |
    |      |  └test
    |      |      |
    |      |      └result.txt
    |      |
    |      └poisson
    |          |
    |          └test
    |              |
    |              └result.txt
    |
    ├testdata
    |  |
    |  └test.txt
    |
    └qubit_tomo.py

In result.txt, the fidelity between result density matrix and ideal matrix which you prepared.
Ideal matrix is prepared in src directly.
So if you need, please fix your own.

Recommended Posts

Verwendung von Qubits Tomography (mein Abschlussprodukt)
Verwendung der Qubits-Tomographie (Herstellung von Produkten für die Abschlussforschung zur Buddhaschaft)
Wie benutzt man Python-Shell
Hinweise zur Verwendung von tf.data
Verwendung von virtualenv
Wie benutzt man Seaboan?
Verwendung von Image-Match
Wie man Shogun benutzt
Verwendung von Pandas 2
Verwendung von Virtualenv
Verwendung von numpy.vectorize
Verwendung von pytest_report_header
Wie man teilweise verwendet
Wie man Bio.Phylo benutzt
Verwendung von SymPy
Wie man x-means benutzt
Verwendung von WikiExtractor.py
Verwendung von IPython
Verwendung von virtualenv
Wie benutzt man Matplotlib?
Verwendung von iptables
Wie benutzt man numpy?
Verwendung von TokyoTechFes2015
Wie benutzt man venv
Verwendung des Wörterbuchs {}
Wie benutzt man Pyenv?
Verwendung der Liste []
Wie man Python-Kabusapi benutzt
Verwendung von OptParse
Verwendung von return
Wie man Imutils benutzt
Verwendung von Qt Designer
Verwendung der Suche sortiert
[gensim] Verwendung von Doc2Vec
python3: Verwendung der Flasche (2)
Verstehen Sie, wie man Django-Filter verwendet
Verwendung des Generators
[Python] Verwendung von Liste 1
Verwendung von FastAPI ③ OpenAPI
Wie benutzt man Python Argparse?
Verwendung von IPython Notebook
Wie man Pandas Rolling benutzt
[Hinweis] Verwendung von virtualenv
Verwendung von Redispy-Wörterbüchern
Python: Wie man pydub benutzt
[Python] Verwendung von checkio
[Go] Verwendung von "... (3 Perioden)"
So bedienen Sie GeoIp2 von Django
[Python] Verwendung von input ()
Wie benutzt man den Dekorateur?
[Einführung] Verwendung von open3d
Wie benutzt man Python Lambda?
So verwenden Sie Jupyter Notebook
[Python] Verwendung von virtualenv
python3: Verwendung der Flasche (3)
python3: Wie man eine Flasche benutzt
So verwenden Sie Google Colaboratory