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.3.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: simple_qsim-0.0.3.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • 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.3.tar.gz
Algorithm Hash digest
SHA256 42965894b2fc1c1a83d6540f554fc1303bc76730aef2c004d61c42a649b26232
MD5 9b0c7677e5f25728af42a08e6d2a11c4
BLAKE2b-256 46c3f43bc89fc1d76b40d8345fab7db089302f74e742a98e7c81d0e0fdeb5dc4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: simple_qsim-0.0.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d5a902017e3761401870fd5e2f212845381afc44dc396849ca49e160952f83fc
MD5 6545d0c82cdd126c1a07ac9141fa0c71
BLAKE2b-256 eda46ce3946671e3762631369d7a04545999fe2cabab2fed8f1f9ec400dce416

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