Skip to content

Commit

Permalink
add vbe tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
liwt31 committed Aug 8, 2023
1 parent 2ecf6b1 commit 7d3ec76
Show file tree
Hide file tree
Showing 13 changed files with 1,577 additions and 8 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,6 @@ which is also a good introduction to the software.

### Variational basis state encoder
An efficient algorithm to encode phonon states in electron-phonon systems for quantum computation.
See [examples](https://github.com/tencent-quantum-lab/TenCirChem/tree/master/example).
See [examples](https://github.com/tencent-quantum-lab/TenCirChem/tree/master/example)
and the [tutorial](https://tencent-quantum-lab.github.io/TenCirChem/tutorial_jupyter/vbe_tutorial_td.html).
Reference paper: https://arxiv.org/pdf/2301.01442.pdf (published in PRR).
3 changes: 2 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ TenCirChem 使用 Academic Public License 发布。

### 变分基矢编码器
变分基矢编码器是编码电声子系统中的声子用以量子计算的高效算法。
请参考[例子](https://github.com/tencent-quantum-lab/TenCirChem/tree/master/example).
请参考[例子](https://github.com/tencent-quantum-lab/TenCirChem/tree/master/example)
[教程](https://tencent-quantum-lab.github.io/TenCirChem/tutorial_jupyter/vbe_tutorial_td.html)
参考论文: https://arxiv.org/pdf/2301.01442.pdf (发表于PRR).

1 change: 1 addition & 0 deletions docs/source/tutorial_jupyter/figs/vbe_gs_Fig1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/tutorial_jupyter/figs/vbe_gs_Fig2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/tutorial_jupyter/figs/vbe_td_Fig1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/tutorial_jupyter/figs/vbe_td_Fig2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
656 changes: 656 additions & 0 deletions docs/source/tutorial_jupyter/vbe_tutorial_groundstate.ipynb

Large diffs are not rendered by default.

903 changes: 903 additions & 0 deletions docs/source/tutorial_jupyter/vbe_tutorial_td.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Tutorials
tutorial_jupyter/noisy_simulation.ipynb
tutorial_jupyter/sbm_dynamics.ipynb
tutorial_jupyter/marcus.ipynb
tutorial_jupyter/vbe_tutorial_groundstate.ipynb
tutorial_jupyter/vbe_tutorial_td.ipynb
3 changes: 1 addition & 2 deletions example/vbe_td.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

from tencirchem import set_backend, Op, Mpo, Model, OpSum
from tencirchem.dynamic import get_ansatz, get_deriv, get_jacobian_func, qubit_encode_basis, sbm

from vbe_lib import get_psi_indices, get_contracted_mpo, get_contract_args
from tencirchem.applications.vbe_lib import get_psi_indices, get_contracted_mpo, get_contract_args

set_backend("jax")

Expand Down
7 changes: 3 additions & 4 deletions example/vbe_ti.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from tencirchem import set_backend, Op, BasisSHO, BasisSimpleElectron, Mpo, Model
from tencirchem.dynamic import get_ansatz, qubit_encode_op, qubit_encode_basis
from tencirchem.utils import scipy_opt_wrap

from vbe_lib import get_psi_indices, get_contracted_mpo, get_contract_args
from tencirchem.applications.vbe_lib import get_psi_indices, get_contracted_mpo, get_contract_args

backend = set_backend("jax")

Expand Down Expand Up @@ -130,12 +129,12 @@ def f(x):
es = []
for k, new_b in enumerate(sols):
if not np.allclose(new_b @ new_b.T, np.eye(4)):
print(f"Enforcing orthogonality for the {k}th root of b_array[{i}]")
# print(f"Enforcing orthogonality for the {k}th root of b_array[{i}]")
new_b = np.linalg.qr(new_b.T)[0].T
b_array[i] = new_b
e = psi @ get_contracted_mpo(h_mpo, b_array, n_qubit_per_mode, b_dof_pidx, psi_idx_top + psi_idx_bottom) @ psi
es.append(e)
print(np.array(es))
# print(np.array(es))
lowest_id = np.argmin(es)
return sols[lowest_id]

Expand Down
4 changes: 4 additions & 0 deletions tencirchem/applications/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2023. The TenCirChem Developers. All Rights Reserved.
#
# This file is distributed under ACADEMIC PUBLIC LICENSE
# and WITHOUT ANY WARRANTY. See the LICENSE file for details.
File renamed without changes.

0 comments on commit 7d3ec76

Please sign in to comment.