Skip to main content

A simple Quantum Simulator

Project description

Quantum Computer Simulator

This is a simple project to simulate quantum behaviour on your local machine. One of the benefit of running this locally is there is essentially no limit on how many qubits can scale too, it comes down to your PC's specs and how many qubits you as a person handle.

How to use

  1. Create a simple python file, say main.py, with the following content.
import simple_qsim

# Register number of qubits you want to use.
s = [
	simple_qsim.q() for _ in  range(3)
]

# Sample Circuit
c = [
["H", s[0]],
["H", s[1]],
["H", s[2]],
["Z", s[2]],
["CZ", s[0], s[1]],
["H", s[0]],
["H", s[1]],
["H", s[2]],
]

# Run the circuit
simple_qsim.run(s, shots=10000, circuit=c)
  1. Then run it using python python3 main.py
  2. You should see something like:
8 Possible States


[25.85, [0, 1, 1]]
[25.07, [1, 0, 1]]
[24.77, [1, 1, 1]]
[24.31, [0, 0, 1]]

You can verify or use the GUI on IBM's platform here: IBM Quantum Composer

Available Gates

You can learn more about quantum gates at Wikipeida

  1. Single Qubit Gates
	a. Hadamard Gate (H)
		Puts the qubit in super position
		Use - ```["H", q[n]]```
	b. Pauli Gates (X,Y,Z)
		Spins the qubit 90deg in that axis
		Use - ["X", q[n]]
			  ["Y", q[n]]
			  ["Z", q[n]]
  1. Controlled Gates
	a. Controlled-NOT (CNOT)
		Performs a not operation on targed when the control bit is |1⟩
		Use - ["CNOT", <target>, <control>]
	b. Controlled-Z (CZ)
		Performs a Pauli Z operation on targed when the control bit is |1⟩
		Use - ["CZ", <target>, <control>]

Contribution

I might or might not update this repo myself, however I am open to contribution!

License

All the code available in this repo is under apache 2.0 license.

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

simple_qsim-0.0.2.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

simple_qsim-0.0.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file simple_qsim-0.0.2.tar.gz.

File metadata

  • Download URL: simple_qsim-0.0.2.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for simple_qsim-0.0.2.tar.gz
Algorithm Hash digest
SHA256 06d253c9a2192883bfa00facc53775a5f44c30eb3984fa9e6425154c4a460062
MD5 2864b5bfb8741c92ccdcdd638828bd56
BLAKE2b-256 29ac34f5cff506a55a83bcb3c32dbc6b3928372c962569aba7a405f66f41752e

See more details on using hashes here.

File details

Details for the file simple_qsim-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: simple_qsim-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for simple_qsim-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d11a7ccb8be30cbd1352d2b40b79455b2f4ebad6ed9ac89027bbb199c5a12a41
MD5 dd306d765e9a216a15cae4de4f1d378b
BLAKE2b-256 1cda66dba40f2cbf9678f6922be5899b8f13feffac3e0ce0db42802689a55f7a

See more details on using hashes here.

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