Software Diagnostics and Conformance Testing Division home page

QCSim

Home | Screenshots | QCSim | genadder | Qhdl2Jaq/Jaq2Qhdl | Generate | Download

QCSim is a quantum computation simulator written in C++. It does a discrete-time simulation of 2-level quantum entities (qubits). QCSim reads a file written in a subset of QHDL which includes declaration of qubits, the initial state of the quantum system, and a series of quantum gates and commands. This language comes from "Final Report-A Design Language for Quantum Computing" ORA TR-03-0001, Odyssey Research Associates, Inc., Ithaca, New York. Currently there is no mechanism to add qubits after the initial declaration.

Source code is freely available, and includes simulations of BB84, teleportation, a Hamming [3,1] (3 repetition) error correcting code, Steane 7-qubit ECC, Grover's algorithm, etc.

Input is from a file specified on the command line. All operations are on the current state, stored as complex numbers in a density matrix. Output is printing the current state, i.e., density matrix (or the interesting parts left after tracing over ancilla, etc.).

On our machine, QCSim can only allocate memory for 13 qubits because storage increases exponentially. In an n-qubit system, the density matrix is 2n by 2n.

Example: Swap With Three C-Not Gates

The input declares two qubits, a and b, and initializes them to a state chosen to make it easier to follow how the values "dance". We print the initial state, do the swap, and print the final state.

 

variable a, b:qubit;

# this normalizes to convenient probabilities
=|00>-2i|01>-3|10>+6|11>;

print_state();

# swap
cnot(b, a);
cnot(a, b);
cnot(b, a);

print_state();

 

Welcome to QCSim 1.5
current state: a, b
    0.02    0.04i  -0.06     0.12
   -0.04i   0.08    0.12i   -0.24i
   -0.06   -0.12i   0.18    -0.36
    0.12    0.24i  -0.36     0.72
current state: a, b
    0.02   -0.06    0.04i    0.12
   -0.06    0.18   -0.12i   -0.36
   -0.04i   0.12i   0.08    -0.24i
    0.12   -0.36    0.24i    0.72

Notice that the probabilities of the |01> and |10> states, 0.08 and 0.18, swapped. (The output is slightly edited.) The screen shots page has other inputs and outputs.

Included Tests and Examples

The Tests directory in the distribution has four kinds of tests for QCSim:

Currently Supported Operations

Basic operations and gates include: Hadamard, Pauli X (bit flip), Pauli Z (phase flip), Pauli Y, various controlled not gates, noisy Hadamard, amplitude damping and depolarization "gates", etc. Code for a new gate can be added easily.

Special functions and commands include:

print_state( )
print the density matrix of the current state.
measure(qubit)
measure a qubit and removes correlations. This allows us to later make a nondeterministic choice, if needed, but otherwise keeps as much information as possible.
traceOver(qubit)
remove the qubit from the state.

Some gates are:

genAmpDamp(probDamp, probZero, qubit)
Generalized amplitude damping gate, after Nielsen & Chuang Sect. 8.3.5 page 382. probDamp is the probability of damping - gamma in N&C: 0 is no damping (Identity), 1 is force to probZero|0> + (1-probZero)|1>. probZero is the probability of going to |0>.
probXYZ(prob_X, prob_Y, prob_Z, qubit)
Probabilistic Pauli X, Y, and Z gate. The parameters are the probabilities of an X (bit flip), Y, and Z (phase flip) on the qubit. The probability of identity is 1 - prob_X - prob_Y - prob_Z.
BSWDepolCPhase(p, control, target)
Brennen, Song, & Williams depolarizing CPhase gate from quant-ph/0301012 v2. p is the probability of the controlled phase happening. (1-p) is the probability of depolarization happening. For examples, BSWDepolCPhase(1, control, target) is controlled phase (copZ).

Related Publication

Modeling quantum information systems for simulation.

QCSim was initially written by Matthew Cass at NIST June-August 2002. QHDL parser and additional code by Andrew Lane at NIST June-August 2003. Additional operations and code by Paul E. Black.

Download


Send comments to: webmaster-sdct
Privacy Policy

Created Jul 11 2003
by Andrew Lane

Updated Tue Mar 16 11:25:46 2004
by Paul E. Black

This page's URL is: http://hissa.nist.gov/~black/Quantum/qcsim.html