コード例 #1
0
    wf = HarmOsc1D(nelec=1, ndim=1)
    sampler = Metropolis(nwalkers=1000,
                         nstep=1000,
                         step_size=3,
                         nelec=1,
                         ndim=1,
                         domain={
                             'min': -2,
                             'max': 2
                         })
    # sampler = PYMC3(nwalkers=1000,ndim=1)

    optimizer = Minimize(method='bfgs', maxiter=25, tol=1E-4)
    # optimizer = Swarm( maxiter=25)

    # VMC solver
    vmc = VMC(wf=wf, sampler=sampler, optimizer=optimizer)

    # single point
    opt_param = [0.5]
    pos, e, s = vmc.single_point(opt_param)
    print('Energy   : ', e)
    print('Variance : ', s)
    vmc.plot_density(pos)

    # optimization
    init_param = [1.]
    vmc.optimize(init_param)
    vmc.plot_history()
コード例 #2
0
ファイル: test_ho1d.py プロジェクト: fieldplay/pyCHAMP
 def test_vmc_opt(self):
     vmc = VMC(wf=self.wf, sampler=self.sampler, optimizer=self.optimizer)
     init_param = [1.25]
     vmc.optimize(init_param)
     vf = vmc.history['variance'][-1]
     assert np.allclose([vf], [0.0], atol=1E-3)
コード例 #3
0
ファイル: sand_box.py プロジェクト: fieldplay/pyCHAMP
        return 0


if __name__ == "__main__":

    # wf = HarmOsc2D(nelec=1, ndim=2)
    wf = PYSCF_WF(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='dzp')
    # sampler = Metropolis(nwalkers=100, nstep=100, step_size = 3,
    # 	                 nelec=wf.nelec, ndim=wf.ndim, domain = {'min':-5,'max':5})
    sampler = PYMC3(nwalkers=100, ndim=wf.nelec * wf.ndim)

    optimizer = Minimize(method='bfgs', maxiter=25, tol=1E-4)
    optlin = Linear(wf=wf, maxiter=25, tol=1E-6)

    # VMS solver
    vmc = VMC(wf=wf, sampler=sampler, optimizer=None)
    pos = vmc.sample([])
    vmc.plot_density(pos)
    e = vmc.wf.energy([], pos)

    # single point
    # opt_param = [0.5]
    # pos,e,s = vmc.single_point(opt_param)
    # print('Energy   : ', e)
    # print('Variance : ', s)
    # vmc.plot_density(pos)

    # optimization
    # init_param = [1.25]
    # vmc.optimize(init_param)
    # vmc.plot_history()
コード例 #4
0
ファイル: test_ho1d.py プロジェクト: fieldplay/pyCHAMP
 def test_vmc_single_point(self):
     vmc = VMC(wf=self.wf, sampler=self.sampler, optimizer=None)
     opt_param = [0.5]
     _, e, s = vmc.single_point(opt_param)
     assert np.allclose([e, s], [0.5, 0], atol=1E-3)
コード例 #5
0
if __name__ == "__main__":

    wf = H2(nelec=2, ndim=3)
    sampler = Metropolis(nwalkers=1000,
                         nstep=1000,
                         step_size=3,
                         nelec=2,
                         ndim=3,
                         domain={
                             'min': -5,
                             'max': 5
                         })
    # sampler = PYMC3(nwalkers=100,ndim=6)
    # sampler = Hamiltonian(nwalkers=1000, nstep=1000, step_size = 3, nelec=1, ndim=3)
    # optimizer = Minimize(method='bfgs', maxiter=25, tol=1E-4)

    # VMS solver
    vmc = VMC(wf=wf, sampler=sampler, optimizer=None)

    # single point
    opt_param = [1.]
    pos, e, s = vmc.single_point(opt_param)
    print('Energy   : ', e)
    print('Variance : ', s)
    vmc.plot_density(pos)

    # # optimization
    # init_param = [0.5]
    # vmc.optimize(init_param)
    # vmc.plot_history()