-
Notifications
You must be signed in to change notification settings - Fork 0
Temporary documents
The project is under developments and the documents are empty currently, so I add some temporary documents here in Chinese first.
这个是求解量子多体问题的一些函数集合
可以直接 pip install qmb , 也可以自己编译,比如clone下来后 pip install -e . 或者 pip install . 。使用 pip install -e . (-e 表示可编辑) 时,在仓库修改python代码后不需要重新安装。
本仓库含有c++代码,修改c++代码的话,即使 pip install -e . 一般来说也需要重新安装。为了方便开发,qmb文件夹下有个 Makefile 文件, 在此目录下 make 的话,可以更新c++编译后的链接库。
安装后,会安装一个可执行程序 qmb 于 PATH 中,可以直接运行,(这个命令行界面是tyro实现的,强烈安利!)。这个脚本的代码在 /qmb/__main__.py 。
为了运行VMC,可以通过 qmb vmc ... 实现,具体可以看 qmb vmc --help ,结果如下
usage: qmb vmc [-h] [VMC OPTIONS] MODEL NETWORK
╭─ positional arguments ────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ MODEL The model name (required) │
│ NETWORK The network name (required) │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ -h, --help show this help message and exit │
│ --sampling-count INT, -n INT │
│ sampling count (default: 4000) │
│ --learning-rate FLOAT, -r FLOAT │
│ learning rate for the local optimizer (default: 1e-3 for Adam, 1 for LBFGS) │
│ --local-step INT, -s INT │
│ step count for the local optimizer (default: 1000) │
│ --include-outside, --no-include-outside, -o │
│ calculate all psi(s)') (default: False) │
│ --deviation, --no-deviation, -d │
│ Use deviation instead of energy (default: False) │
│ --fix-outside, --no-fix-outside, -f │
│ Fix outside phase when optimizing outside deviation (default: False) │
│ --use-lbfgs, --no-use-lbfgs, -2 │
│ Use LBFGS instead of Adam (default: False) │
│ --omit-deviation, --no-omit-deviation, -i │
│ Do not calculate deviation when optimizing energy (default: False) │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ common options ──────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --physics-args STR, -P STR │
│ Arguments for physical model (repeatable) │
│ --network-args STR, -N STR │
│ Arguments for network (repeatable) │
│ --job-name {None}|STR, -J {None}|STR │
│ The job name used in checkpoint and log, leave empty to use the preset job name given by the model and │
│ network (default: None) │
│ --checkpoint-path PATH, -C PATH │
│ The checkpoint path (default: checkpoints) │
│ --log-path PATH, -L PATH │
│ The log path (default: logs) │
│ --random-seed {None}|INT, -S {None}|INT │
│ The manual random seed, leave empty for set seed automatically (default: None) │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
需要注意,这个VMC算法我做了一点修改,需要加 -o 参数才是标准的vmc 。
这个代码在 /qmb/vmc.py 。
物理模型由一个 MODEL 参数和若干 -P 参数设置,MODEL目前只有三种 “openfermion”, “openfermion_operator” 和 "ising", 见
model_dict = {
"openfermion": openfermion.Model,
"openfermion_operator": openfermion_operator.Model,
"ising": ising.Model,
}
于 /qmb/common.py 。
-P 为传给 MODEL的参数, 为了查看具体的MODEL参数,可以运行 qmb vmc ising naqs -P-h 得到:
usage: qmb [-h] [OPTIONS] INT
╭─ positional arguments ───────────────────────────────────────────╮
│ INT The length of the ising chain (required) │
╰──────────────────────────────────────────────────────────────────╯
╭─ options ────────────────────────────────────────────────────────╮
│ -h, --help show this help message and exit │
│ --X FLOAT, -x FLOAT The coefficient of X (default: 0) │
│ --Y FLOAT, -y FLOAT The coefficient of Y (default: 0) │
│ --Z FLOAT, -z FLOAT The coefficient of Z (default: 0) │
│ --XX FLOAT, -X FLOAT The coefficient of XX (default: 0) │
│ --YY FLOAT, -Y FLOAT The coefficient of YY (default: 0) │
│ --ZZ FLOAT, -Z FLOAT The coefficient of ZZ (default: 0) │
╰──────────────────────────────────────────────────────────────────╯
这里naqs是网络名字,这里没有设计好,即使只是想看model的参数介绍,也需要申明一下网络,我懒得改。
这个ising模型名字也没起好,其实是一个一维的chain,相互作用为
这个ising模型定义在 /qmb/ising.py 。 物理模型的定义里调用了c++写的扩展(比如ising模型调用了_ising.cpp实现的扩展),这个扩展用于对于给定的一群构型
网络通过一个 NETWORK 参数 和若干个 -N 参数定义。
naqs 实现在 /qmb/naqs.py ,参数说明可以通过 qmb vmc ising naqs -N-h 获得naqs相关的参数说明。
我还实现了一下transformers,但是并没有测试,且只能给openfermion模型使用,实现在 /qmb/attention.py 。
如果需要给ising类模型使用,需要在ising.py中定义一个attention函数作为入口。
同时attention.py 中实现的网络是针对自旋1/2的费米子的(自带限制上下自旋的数目),如果要给ising类模型使用,需要修改。
作为例子,naqs.py中我实现了两个类,一个是给openfermion用的WaveFunction,一个是给ising用的WaveFunctionNormal 。