Tqsim
TQSim is an open-source anyon-based Topological Quantum Computing simulator
Install / Use
/learn @Constantine-Quantum-Tech/TqsimREADME
TQSim
TQSim stands for Topological Quantum Simulator. It is an open-source library developed by CQTech for simulating topological quantum computers based on Fibonacci anyons.
Documentation for the latest stable version of TQSim is available here.
Installation
You can install TQSim from pip using
pip install --upgrade tqsim
Usage
1. Basic Example
In this example, we create a circuit with 2 qudits, made of 3 anyons each. We then braid the anyons manually.
from tqsim import AnyonicCircuit
circuit = AnyonicCircuit(2, 3) # Create a circuit having 2 qudits and 3 anyons per qudits
circuit.braid(1, 2) # Braids the first with the second anyon
circuit.braid(3, 4) # Braids the first with the second anyon
circuit.braid(2, 1)
circuit.measure() # Measure the system by fusing the anyons
circuit.draw() # Draw the circuit
Here is the output of the draw() method:

Simulating the circuit:
circuit.run(shots = 50)
Output:
{'counts': {'0': 16, '2': 20, '4': 14}, 'memory': array([4, 2, 2, 2, 2, 2, 2, 4, 2, 4, 2, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0, 4,
2, 4, 0, 2, 0, 0, 0, 0, 4, 4, 2, 2, 2, 4, 2, 2, 0, 0, 2, 4, 2, 2,
4, 2, 4, 4, 0, 2])}
2. Simulating a Hadamard gate
Here we simulate the application of a Hadamard gate on a single qudit with 3 anyons. Unlike the previous example, we will use a braiding sequence of braiding operators and their corresponding powers.
from tqsim import AnyonicCircuit
circuit = AnyonicCircuit(nb_qudits=1, nb_anyons_per_qudit=3) # Create a circuit with 1 qudit composed of 3 anyons
circuit.initialize([0,0,1]) # We initialize the circuit in the last state (state 2).
# For this circuit, we have 3 basis states: [0, 1, 2].
# The Hadamard gate braiding sequence in terms of braiding operators
had_sequence = [[1, 2], [2, 2], [1, -2], [2, -2], [1, 2], [2, 4], [1, -2], [2, 2],
[1, 2], [2, -2], [1, 2], [2, -2], [1, 4]]
circuit.braid_sequence(had_sequence) # We apply the braiding sequence.
# This should put our qudit in a superposition of the states 2 and 1.
circuit.measure() # Measure the system by fusing the anyons
circuit.draw() # Draw the circuit
The Hadamard braid looks like this

Simulating the circuit:
result = circuit.run(shots = 1000) # Run the circuit 1000 times.
print(result['counts']) # Show the counts only.
Output:
{'1': 493, '2': 507}
Authors and Citation
Abdellah Tounsi, Mohamed Messaoud Louamri, Nacer eddine Belaloui, and Mohamed Taha Rouabah – Constantine Quantum Technologies.
If you have used TQSim in your work, please use the BibTeX file to cite the authors.
License
Copyright © 2022, Constantine Quantum Technologies. Released under the Apache License 2.0.
Related Skills
node-connect
350.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
