Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

リンドブラッド方程式のモンテカルロソルバ #185

Merged
merged 40 commits into from
Apr 6, 2022

Conversation

kosukemtr
Copy link
Collaborator

@kosukemtr kosukemtr commented Jan 12, 2022

やったこと

リンドブラッド方程式 https://qutip.org/docs/latest/guide/dynamics/dynamics-master.html によるダイナミクスを gate::NoisyEvolution として実装しました。

使い方

T1 T2 緩和の例は以下の通りです。

from qulacs.gate import NoisyEvolution, H
from qulacs import Observable, GeneralQuantumOperator

n_qubits = 2
decay_rate_list = [0.2,0.6,0.1] # decay rate for dephasing, higher, lower ops
time = 1.0 # evolution time
dt = 0.1 # step size for Runge-Kutta evolution used within NoisyEvolution

# hamiltonian
hamiltonian = Observable(n_qubits)
hamiltonian.add_operator(1., "Z 0 Z 1")

# collapse operators
c_ops = [GeneralQuantumOperator(n_qubits) for _ in range(3*n_qubits)]
c_ops[0].add_operator(decay_rate_list[0], "Z 0")
c_ops[1].add_operator(decay_rate_list[0], "Z 1")
c_ops[2].add_operator(decay_rate_list[1]/2, "X 0")
c_ops[2].add_operator(decay_rate_list[1]/2*1j, "Y 0")
c_ops[3].add_operator(decay_rate_list[1]/2, "X 1")
c_ops[3].add_operator(decay_rate_list[1]/2*1j, "Y 1")
c_ops[4].add_operator(decay_rate_list[2]/2, "X 0")
c_ops[4].add_operator(-decay_rate_list[2]/2*1j, "Y 0")
c_ops[5].add_operator(decay_rate_list[2]/2, "X 1")
c_ops[5].add_operator(-decay_rate_list[2]/2*1j, "Y 1")

# simulate
state = QuantumState(n_qubits)
H(0).update_quantum_state(state)
H(1).update_quantum_state(state)
gate = NoisyEvolution(hamiltonian, c_ops, time, dt)
gate.update_quantum_state(state)

モンテカルロソルバなので、意味のある結果を得るためには DepolarizingNoise と同様にアンサンブル平均を取る必要があります。

@kotamanegi
Copy link
Collaborator

Kosuke Mitarai
single thread 化しないと遅かったので single thread version を書く必要が出ました

@kosukemtr
Copy link
Collaborator Author

kosukemtr commented Jan 12, 2022

たまに無限ループが発生してしまうことが判明したので fix しました

@kotamanegi kotamanegi marked this pull request as draft February 4, 2022 11:51
@kotamanegi
Copy link
Collaborator

kotamanegi commented Mar 2, 2022

Kosuke Mitarai: https://qutip.org/docs/latest/guide/dynamics/dynamics-monte.html
https://qutip.org/docs/latest/modules/qutip/mcsolve.html の実装を参考にして作りました

@kotamanegi kotamanegi marked this pull request as ready for review March 30, 2022 00:15
Copy link
Contributor

@KowerKoint KowerKoint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです!
Pythonでも問題なく動作していていい感じです

[&](CPPCTYPE acc, PauliOperator* pauli) {
return acc + pauli->get_expectation_value(state);
});
double sum_real = 0.;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改良部分

@@ -134,7 +134,7 @@ HermitianQuantumOperator::solve_ground_state_eigenvalue_by_lanczos_method(
// So, an eigenvector of A for λ is Vq.
// q_0 = init_state
work_states.at(1).load(init_state);
init_state->multiply_coef(0.0);
init_state->set_zero_norm_state();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改良

@kotamanegi kotamanegi merged commit 09e63a3 into dev Apr 6, 2022
@kotamanegi kotamanegi deleted the kosukemtr/noisy_evolution branch April 6, 2022 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants