Skip to main content

A quantum simulator

Project description

Qter

This is a package for a quantum simulator. This package can simulate errors similar to the real quantum device, here error comes with each gate, and similar to the actual device it also uses swap operation if the two-qubit gate is applied between two far available qubits. In this version all qubits are assumed to be straight but soon in the next version we can provide flexibility to chose devise architecture.

This package makes use of the following module:

  1. numpy
  2. cmath
  3. math
  4. random

How to install Qter

you can just pip install Qter by typing:

pip install Qter

To import Qter

import Qter as Qter

To Import quantum gate:

To use this quantum simulator you have to first import a quantum gate and save it in the local variable list of quantum gate currently available is:

  1. X = Pauli-X
  2. I = Identity
  3. Y = Pauli-Y
  4. Z = Pauli-Z
  5. H = Hadamard
  6. T = T-gate
  7. CX = controlled Pauli-X
  8. SW = Swap gate
  9. S = S-gate

Code to import Quantum Gate :

    H = Qter.H
    Y = Qter.Y
    X = Qter.X
    CX = Qter.CX

To run the simulator

To run this simulator you have to import run and rub it with 6 variables.

x, y = Qter.run(cir, n, count, error, Transpiler)
  1. Cir is an array containing information of circuit as:
  cir =  [[H, 0], [H, 2], [H, 3], [X, 3], [CX, [1, 3]], [X, 3], [X, 1], [CX, [1, 3]], [CX, [4, 3]], [CX, [0, 3]]]
Here each gate is applied as a list where the first position is for the name of the gate and the second position is for the position of that gate. If the type of gate is a two-qubit gate then the position of the gate is passed under a list. 
  1. n is the number of qubits.
  2. Count is the number of shots or samples you want to take.
  3. Error is a boolean variable for error. This can take true if you want to error in the circuit if you did not want an Error in your circuit you can just pass False in it.
  4. Transpiler is a boolean variable for Transpilation of the circuit. This can take true if you want to transpile your circuit, if you did not want to transpile your circuit you can just pass False in it.
  5. err is a variable for the value of the average error you want.

This run function returns you two arrays

  • In the first array, each element contains two values, probability, and its corresponding quantum state.
  • In the second array, each element contains two values, count, and its corresponding quantum state.

To Draw your Circuit

the code to draw your circuit

from Qter import draw as draw
draw(cir,n) 

To plot Result:

from Qter import plot as plot
y=[5,2]
plot(x,y)

Here y is size of image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Qter-0.2.3.tar.gz (6.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page