Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Quantum
提交
f0c60d50
Q
Quantum
项目概览
PaddlePaddle
/
Quantum
1 年多 前同步成功
通知
20
Star
492
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
5
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Quantum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
5
Issue
5
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f0c60d50
编写于
11月 05, 2021
作者:
Y
yangguohao
提交者:
GitHub
11月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create 单测文件.py
上级
201f7858
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
0 deletion
+47
-0
documents/单测文件.py
documents/单测文件.py
+47
-0
未找到文件。
documents/单测文件.py
0 → 100644
浏览文件 @
f0c60d50
from
paddle_quantum.circuit
import
UAnsatz
from
paddle_quantum.utils
import
Hamiltonian
,
NKron
,
gate_fidelity
,
SpinOps
,
dagger
from
paddle_quantum.trotter
import
construct_trotter_circuit
,
get_1d_heisenberg_hamiltonian
,
__group_hamiltonian_xyz
,
optimal_circuit
,
__sort_pauli_word
from
paddle
import
matmul
,
transpose
,
trace
import
paddle
import
numpy
as
np
import
scipy
from
scipy
import
linalg
import
matplotlib.pyplot
as
plt
def
get_evolve_op
(
t
):
return
scipy
.
linalg
.
expm
(
-
1j
*
t
*
h
.
construct_h_matrix
())
n_qubits
=
2
h
=
get_1d_heisenberg_hamiltonian
(
length
=
n_qubits
,
j_x
=
1
,
j_y
=
1
,
j_z
=
2
,
h_z
=
2
*
np
.
random
.
rand
(
2
)
-
1
,
periodic_boundary_condition
=
False
)
#
t
=
2
r
=
1
cir
=
UAnsatz
(
n_qubits
)
construct_trotter_circuit
(
cir
,
h
,
tau
=
t
/
r
,
steps
=
r
)
print
(
'系统的哈密顿量为:'
)
print
(
h
)
print
(
'电路的酉矩阵与正确的演化算符之间的保真度为:%.2f'
%
gate_fidelity
(
cir
.
U
.
numpy
(),
get_evolve_op
(
t
)))
optimal_cir
=
UAnsatz
(
n_qubits
)
construct_trotter_circuit
(
optimal_cir
,
h
,
tau
=
t
,
steps
=
r
,
grouping
=
'optimal'
)
print
(
'优化电路的酉矩阵与正确的演化算符之间的保真度为:%.2f'
%
gate_fidelity
(
optimal_cir
.
U
.
numpy
(),
get_evolve_op
(
t
)))
print
(
cir
)
print
(
optimal_cir
)
"""
系统的哈密顿量为:
1.0 X0, X1
1.0 Y0, Y1
2.0 Z0, Z1
0.8437864330659737 Z0
0.13446464627645072 Z1
电路的酉矩阵与正确的演化算符之间的保真度为:0.67
优化电路的酉矩阵与正确的演化算符之间的保真度为:0.67
--H----*-----------------*----H----Rx(1.571)----*-----------------*----Rx(-1.57)----*-----------------*----Rz(3.375)--
| | | | | |
--H----x----Rz(4.000)----x----H----Rx(1.571)----x----Rz(4.000)----x----Rx(-1.57)----x----Rz(8.000)----x----Rz(0.538)--
---------------x----Rz(6.429)----*-----------------x----Rz(-1.57)----Rz(3.375)--
| | |
--Rz(1.571)----*----Ry(-3.85)----x----Ry(3.854)----*----Rz(0.538)---------------
"""
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录