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

Uploaded Source

File details

Details for the file Qter-0.2.3.tar.gz.

File metadata

  • Download URL: Qter-0.2.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for Qter-0.2.3.tar.gz
Algorithm Hash digest
SHA256 f354a9ba7baea29b74bc44f9040f571d9e63eff61e0317ce298c850d6b8df841
MD5 77955a891c2650d3155b9963642243a5
BLAKE2b-256 f43ed8dcea61203a3b4ce25ebd2415c7f675a206cbd88a4648cefe37d88f2d6a

See more details on using hashes here.

Supported by

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