使用径向基函数神经网络求解薛定谔方程
项目描述
Schrodinet
使用径向基函数神经网络进行一维问题的量子蒙特卡洛模拟。
安装
克隆仓库并使用pip
安装代码
git clone https://github.com/NLESC-JCER/Schrodinet/
cd Schrodinet
pip install .
一维简谐振子
下面的脚本说明了如何优化一维简谐振子的波函数。
import torch
from torch import optim
from schrodinet.sampler.metropolis import Metropolis
from schrodinet.wavefunction.wf_potential import Potential
from schrodinet.solver.solver_potential import SolverPotential
from schrodinet.solver.plot_potential import plot_results_1d, plotter1d
def pot_func(pos):
'''Potential function desired.'''
return 0.5*pos**2
def ho1d_sol(pos):
'''Analytical solution of the 1D harmonic oscillator.'''
return torch.exp(-0.5*pos**2)
# Define the domain and the number of RBFs
# wavefunction
wf = Potential(pot_func, domain, ncenter, fcinit='random', nelec=1, sigma=0.5)
# sampler
sampler = Metropolis(nwalkers=1000, nstep=2000,
step_size=1., nelec=wf.nelec,
ndim=wf.ndim, init={'min': -5, 'max': 5})
# optimizer
opt = optim.Adam(wf.parameters(), lr=0.05)
scheduler = optim.lr_scheduler.StepLR(opt, step_size=100, gamma=0.75)
# Solver
solver = SolverPotential(wf=wf, sampler=sampler,
optimizer=opt, scheduler=scheduler)
# Train the wave function
plotter = plotter1d(wf, domain, 100, sol=ho1d_sol)
solver.run(300, loss='variance', plot=plotter, save='model.pth')
# Plot the final wave function
plot_results_1d(solver, domain, 100, ho1d_sol, e0=0.5, load='model.pth')
优化后,可以轻松生成以下轨迹
可以在不同的势能上执行相同的程序。下面的图显示了该方法在简谐振子和 Morse 势能上的性能。
项目详细信息
下载文件
下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
schrodinet-0.1.2.tar.gz (23.6 kB 查看哈希值)
构建分发
schrodinet-0.1.2-py3-none-any.whl (28.7 kB 查看哈希值)
关闭
schrodinet-0.1.2.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9eb95a73ffc3aa49c3c1d0f28ef40a6a9a75afc4a5cb30efa2004b4a47fecb29 |
|
MD5 | 555520efcb7dc5fb412191ff7ee8c363 |
|
BLAKE2b-256 | f48aa60d3d1c7ddafa38858076aa9e1f389a089ee19ce028e83ca8492bf4c364 |
关闭
schrodinet-0.1.2-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7f40f000ea7a8a99bbab12d9ee588cad9624f902429c442874b00409aa4f2fa3 |
|
MD5 | d218b0efe5103f92002fb700eacb4913 |
|
BLAKE2b-256 | 6534f0d0586d95b401b968c3523ce85321e61321c58a01abbe144b7546c5c7d1 |