Skip to content

Commit

Permalink
Add qulacs checking
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrein committed Aug 3, 2023
1 parent ba376ad commit caaacb6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions timApp/plugin/quantum_circuit/quantumCircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

from flask import render_template_string

from qulacs import Observable, QuantumCircuit, QuantumState
from qulacs.gate import Y, CNOT, merge

from timApp.tim_app import csrf
from tim_common.markupmodels import GenericMarkupModel
from tim_common.pluginserver_flask import (
Expand Down Expand Up @@ -148,6 +151,22 @@ class QuantumCircuitAnswerModel(
def answer(args: QuantumCircuitAnswerModel) -> PluginAnswerResp:
# initial_circuit = args.markup.initialCircuit

state = QuantumState(3)
state.set_Haar_random_state()

circuit = QuantumCircuit(3)
circuit.add_X_gate(0)
merged_gate = merge(CNOT(0, 1), Y(1))
circuit.add_gate(merged_gate)
circuit.add_RX_gate(1, 0.5)
circuit.update_quantum_state(state)

observable = Observable(3)
observable.add_operator(2.0, "X 2 Y 1 Z 0")
observable.add_operator(-3.0, "Z 2")
value = observable.get_expectation_value(state)
print(value)

model_circuit = args.markup.modelCircuit
model_input = args.markup.modelInput

Expand Down

0 comments on commit caaacb6

Please sign in to comment.