def test1_create(self): # molecule mol = Molecule(atom='H 0. 0. 0.; H 0. 0. 1.', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) mol.print_total_energy()
def setUp(self): torch.manual_seed(0) np.random.seed(0) # optimal parameters self.opt_r = 0.69 # the two h are at +0.69 and -0.69 self.opt_sigma = 1.24 # molecule self.mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g') # wave function self.wf = Orbital(self.mol, kinetic='auto', configs='single(2,2)', use_jastrow=True) # sampler self.sampler = Metropolis(nwalkers=1000, nstep=2000, step_size=0.5, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) self.hmc_sampler = Hamiltonian(nwalkers=100, nstep=200, step_size=0.1, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal')) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverOrbital(wf=self.wf, sampler=self.sampler, optimizer=self.opt) # ground state energy self.ground_state_energy = -1.16 # ground state pos self.ground_state_pos = 0.69
def setUp(self): torch.manual_seed(0) np.random.seed(0) set_torch_double_precision() # molecule self.mol = Molecule(atom='Li 0 0 0; H 0 0 3.015', unit='bohr', calculator='pyscf', basis='sto-3g') # wave function self.wf = SlaterJastrowBackFlow(self.mol, kinetic='jacobi', configs='single_double(2,2)', backflow_kernel=BackFlowKernelPowerSum, orbital_dependent_backflow=False, include_all_mo=True) # fc weights self.wf.fc.weight.data = torch.rand(self.wf.fc.weight.shape) # jastrow weights self.wf.jastrow.jastrow_kernel.weight.data = torch.rand( self.wf.jastrow.jastrow_kernel.weight.shape) # sampler self.sampler = Metropolis(nwalkers=500, nstep=200, step_size=0.05, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverSlaterJastrow(wf=self.wf, sampler=self.sampler, optimizer=self.opt) # artificial pos self.nbatch = 10 self.pos = torch.as_tensor( np.random.rand(self.nbatch, self.wf.nelec * 3)) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(0) np.random.seed(0) set_torch_double_precision() # optimal parameters self.opt_r = 0.69 # the two h are at +0.69 and -0.69 self.opt_sigma = 1.24 # molecule self.mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g') # wave function self.wf = CorrelatedOrbital( self.mol, kinetic='auto', configs='cas(2,2)', jastrow_type=FullyConnectedJastrow, # jastrow_type='pade_jastrow', include_all_mo=True) # sampler self.sampler = Metropolis(nwalkers=1000, nstep=2000, step_size=0.5, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverOrbital(wf=self.wf, sampler=self.sampler, optimizer=self.opt) # ground state energy self.ground_state_energy = -1.16 # ground state pos self.ground_state_pos = 0.69
def setUp(self): hvd.init() torch.manual_seed(0) np.random.seed(0) set_torch_double_precision() # optimal parameters self.opt_r = 0.69 # the two h are at +0.69 and -0.69 self.opt_sigma = 1.24 # molecule self.mol = Molecule( atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g', rank=hvd.local_rank()) # wave function self.wf = SlaterJastrow(self.mol, kinetic='jacobi', configs='cas(2,2)', cuda=False) # sampler self.sampler = Metropolis( nwalkers=200, nstep=200, step_size=0.2, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('atomic'), move={ 'type': 'all-elec', 'proba': 'normal'}) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverSlaterJastrowHorovod(wf=self.wf, sampler=self.sampler, optimizer=self.opt, rank=hvd.rank()) # ground state energy self.ground_state_energy = -1.16 # ground state pos self.ground_state_pos = 0.69
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule self.mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g') # orbital self.wf = Orbital(self.mol)
def setUp(self): torch.manual_seed(0) np.random.seed(0) set_torch_double_precision() # molecule path_hdf5 = (PATH_TEST / 'hdf5/LiH_adf_dz.hdf5').absolute().as_posix() self.mol = Molecule(load=path_hdf5) # wave function self.wf = SlaterOrbitalDependentJastrow(self.mol, kinetic='jacobi', configs='cas(2,2)', include_all_mo=True) # fc weights self.wf.fc.weight.data = torch.rand(self.wf.fc.weight.shape) # jastrow weights for ker in self.wf.jastrow.jastrow_kernel.jastrow_functions: ker.weight.data = torch.rand(1) # sampler self.sampler = Metropolis(nwalkers=500, nstep=200, step_size=0.05, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverSlaterJastrow(wf=self.wf, sampler=self.sampler, optimizer=self.opt) # artificial pos self.nbatch = 10 self.pos = torch.as_tensor( np.random.rand(self.nbatch, self.wf.nelec * 3)) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule( atom='Li 0 0 0; H 0 0 3.14', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = SlaterCombinedJastrow(mol, kinetic='auto', include_all_mo=False, configs='single_double(2,2)', jastrow_kernel={ 'ee': PadeJastrowKernelElecElec, 'en': PadeJastrowKernelElecNuc, 'een': BoysHandyJastrowKernel}, jastrow_kernel_kwargs={ 'ee': {'w': 1.}, 'en': {'w': 1.}, 'een': {}}) self.random_fc_weight = torch.rand(self.wf.fc.weight.shape) self.wf.fc.weight.data = self.random_fc_weight self.nbatch = 11 self.pos = torch.Tensor(np.random.rand( self.nbatch, self.wf.nelec*3)) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule(atom='Li 0 0 0; H 0 0 3.015', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = CorrelatedOrbital(mol, kinetic='auto', jastrow_type='pade_jastrow', configs='single_double(2,4)', include_all_mo=True) self.random_fc_weight = torch.rand(self.wf.fc.weight.shape) self.wf.fc.weight.data = self.random_fc_weight self.wf.jastrow.weight.data = torch.rand(self.wf.jastrow.weight.shape) self.nbatch = 3 self.pos = torch.tensor(np.random.rand(self.nbatch, self.wf.nelec * 3)) self.pos.requires_grad = True
class TestH2Stat(unittest.TestCase): def setUp(self): torch.manual_seed(0) np.random.seed(0) # optimal parameters self.opt_r = 0.69 # the two h are at +0.69 and -0.69 self.opt_sigma = 1.24 # molecule self.mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g') # wave function self.wf = SlaterJastrow(self.mol, kinetic='jacobi', configs='single(2,2)') # sampler self.sampler = Metropolis(nwalkers=100, nstep=500, step_size=0.5, ndim=self.wf.ndim, nelec=self.wf.nelec, ntherm=0, ndecor=1, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverSlaterJastrow(wf=self.wf, sampler=self.sampler, optimizer=self.opt) def test_sampling_traj(self): pos = self.solver.sampler(self.solver.wf.pdf) obs = self.solver.sampling_traj(pos) plot_walkers_traj(obs.local_energy) plot_block(obs.local_energy) def test_stat(self): pos = self.solver.sampler(self.solver.wf.pdf) obs = self.solver.sampling_traj(pos) if __PLOT__: plot_blocking_energy(obs.local_energy, block_size=10) plot_correlation_coefficient(obs.local_energy) plot_integrated_autocorrelation_time(obs.local_energy)
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule(atom='Li 0 0 0; H 0 0 3.015', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = SlaterOrbitalDependentJastrow( mol, kinetic='auto', jastrow_kernel=FullyConnectedJastrowKernel, configs='single_double(2,4)', include_all_mo=True) self.random_fc_weight = torch.rand(self.wf.fc.weight.shape) self.wf.fc.weight.data = self.random_fc_weight self.nbatch = 3 self.pos = torch.as_tensor( np.random.rand(self.nbatch, self.wf.nelec * 3)) self.pos.requires_grad = True
def setUp(self): # define the molecule at = 'C 0 0 0' basis = 'dzp' self.mol = Molecule(atom=at, calculator='pyscf', basis=basis, unit='bohr') self.m = gto.M(atom=at, basis=basis, unit='bohr') # define the wave function self.wf = SlaterJastrow(self.mol) self.pos = torch.zeros(100, self.mol.nelec * 3) self.pos[:, 0] = torch.linspace(-5, 5, 100) self.pos[:, 1] = torch.linspace(-5, 5, 100) self.pos[:, 2] = torch.linspace(-5, 5, 100) self.pos = Variable(self.pos) self.pos.requires_grad = True self.x = self.pos[:, 0].detach().numpy()
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule( atom='Li 0 0 0; H 0 0 1.', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = SlaterJastrow(mol, kinetic='auto', configs='ground_state', jastrow_kernel=FullyConnectedJastrowKernel) self.random_fc_weight = torch.rand(self.wf.fc.weight.shape) self.wf.fc.weight.data = self.random_fc_weight self.nbatch = 10 self.pos = 1E-2 * torch.as_tensor(np.random.rand( self.nbatch, self.wf.nelec*3)) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule( atom='Li 0 0 0; H 0 0 1.', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = SlaterJastrow(mol, kinetic='auto', include_all_mo=True, configs='cas(2,2)') self.random_fc_weight = torch.rand(self.wf.fc.weight.shape) self.wf.fc.weight.data = self.random_fc_weight self.nbatch = 10 self.pos = torch.Tensor( np.random.rand(self.nbatch, mol.nelec*3)) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule(atom='Li 0 0 0; H 0 0 3.015', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = SlaterJastrowBackFlow(mol, kinetic='jacobi', jastrow_kernel=PadeJastrowKernel, include_all_mo=True, configs='single_double(2,2)', backflow_kernel=BackFlowKernelInverse, orbital_dependent_backflow=False) self.random_fc_weight = torch.rand(self.wf.fc.weight.shape) self.wf.fc.weight.data = self.random_fc_weight self.nbatch = 5 self.pos = torch.Tensor(np.random.rand(self.nbatch, self.wf.nelec * 3)) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(0) np.random.seed(0) # optimal parameters self.opt_r = 0.69 # the two h are at +0.69 and -0.69 self.opt_sigma = 1.24 # molecule self.mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g') # wave function self.wf = SlaterJastrow(self.mol, kinetic='jacobi', configs='single(2,2)') # sampler self.sampler = Metropolis(nwalkers=100, nstep=500, step_size=0.5, ndim=self.wf.ndim, nelec=self.wf.nelec, ntherm=0, ndecor=1, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverSlaterJastrow(wf=self.wf, sampler=self.sampler, optimizer=self.opt)
def setUp(self): torch.manual_seed(0) # molecule path_hdf5 = (PATH_TEST / 'hdf5/H2_adf_dzp.hdf5').absolute().as_posix() self.mol = Molecule(load=path_hdf5) # wave function self.wf = Orbital(self.mol, kinetic='auto', configs='single(2,2)', use_jastrow=True) # sampler self.sampler = Metropolis(nwalkers=1000, nstep=2000, step_size=0.5, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverOrbital(wf=self.wf, sampler=self.sampler, optimizer=self.opt) # ground state energy self.ground_state_energy = -1.16 # ground state pos self.ground_state_pos = 0.69
def setUp(self): atom_str = 'O 0 0 -0.69; C 0 0 0.69' self.m = gto.M(atom=atom_str, basis='sto-3g', unit='bohr') self.mol = Molecule(atom=atom_str, calculator='pyscf', basis='sto-3g', unit='bohr') # define the wave function self.wf = OrbitalTest(self.mol) self.x = 2 * torch.rand(5, 3 * self.mol.nelec) - 1. self.x.requires_grad = True
def setUp(self): torch.manual_seed(0) np.random.seed(0) path_hdf5 = ( PATH_TEST / 'hdf5/CO2_adf_dzp.hdf5').absolute().as_posix() self.mol = Molecule(load=path_hdf5) # wave function self.wf = SlaterJastrow(self.mol, kinetic='jacobi', configs='ground_state', include_all_mo=False)
def setUp(self): # define the molecule path_hdf5 = PATH_TEST / 'hdf5/C_adf_dzp.hdf5' self.mol = Molecule(load=path_hdf5) # define the wave function self.wf = Orbital(self.mol, include_all_mo=True) # define the grid points npts = 11 self.pos = torch.rand(npts, self.mol.nelec * 3) self.pos = Variable(self.pos) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule(atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='sto-3g') self.orb_conf = OrbitalConfigurations(mol)
def setUp(self): torch.manual_seed(0) np.random.seed(0) # molecule self.mol = Molecule(atom='Li 0 0 0; H 0 0 3.015', unit='bohr', calculator='pyscf', basis='sto-3g') # wave function self.wf = Orbital(self.mol, kinetic='jacobi', configs='single(2,2)', use_jastrow=True, include_all_mo=False) # sampler self.sampler = Metropolis(nwalkers=500, nstep=200, step_size=0.05, ndim=self.wf.ndim, nelec=self.wf.nelec, init=self.mol.domain('normal'), move={ 'type': 'all-elec', 'proba': 'normal' }) # optimizer self.opt = optim.Adam(self.wf.parameters(), lr=0.01) # solver self.solver = SolverOrbital(wf=self.wf, sampler=self.sampler, optimizer=self.opt)
def setUp(self): torch.manual_seed(0) np.random.seed(0) self.mol = Molecule(atom='C 0 0 0; O 0 0 2.190; O 0 0 -2.190', calculator='pyscf', basis='dzp', unit='bohr') # wave function self.wf = SlaterJastrow(self.mol, kinetic='jacobi', configs='ground_state', include_all_mo=False)
def setUp(self): # molecule self.mol = Molecule( atom='H 0 0 -0.69; H 0 0 0.69', unit='bohr', calculator='pyscf', basis='dzp') # wave function self.wf = SlaterJastrow(self.mol, kinetic='jacobi', configs='single(2,2)') npts = 51 self.pos = torch.zeros(npts, 6) self.pos[:, 2] = torch.linspace(-2, 2, npts)
def setUp(self): # define the molecule path_hdf5 = (PATH_TEST / 'hdf5/C_adf_dzp.hdf5').absolute().as_posix() self.mol = Molecule(load=path_hdf5) # define the wave function self.wf = Orbital(self.mol, include_all_mo=True) # define the grid points self.npts = 21 pts = get_pts(self.npts) self.pos = torch.zeros(self.npts**2, self.mol.nelec * 3) self.pos[:, :3] = pts self.pos = Variable(self.pos) self.pos.requires_grad = True
def setUp(self): # define the molecule at = 'C 0 0 0' basis = 'dzp' self.mol = Molecule(atom=at, calculator='pyscf', basis=basis, unit='bohr') # define the wave function self.ao = AtomicOrbitalsBackFlow(self.mol, BackFlowKernelInverse) # define the grid points self.npts = 11 self.pos = torch.rand(self.npts, self.mol.nelec * 3) self.pos = Variable(self.pos) self.pos.requires_grad = True
def setUp(self): torch.manual_seed(101) np.random.seed(101) set_torch_double_precision() # molecule mol = Molecule(atom='C 0 0 0', unit='bohr', calculator='pyscf', basis='sto-3g', redo_scf=True) self.wf = Orbital(mol, kinetic='auto', configs='ground_state').gto2sto() self.pos = -0.25 + 0.5 * torch.tensor(np.random.rand(10, 18)) self.pos.requires_grad = True
def setUp(self): # define the molecule at = 'C 0 0 0' basis = 'dzp' self.mol = Molecule(atom=at, calculator='pyscf', basis=basis, unit='bohr') # define the kernel self.kernel = BackFlowKernelInverse(self.mol) self.edist = ElectronElectronDistance(self.mol.nelec) # define the grid points self.npts = 11 self.pos = torch.rand(self.npts, self.mol.nelec * 3) self.pos = Variable(self.pos) self.pos.requires_grad = True
def setUp(self): # define the molecule at = 'C 0 0 0' basis = 'dzp' self.mol = Molecule(atom=at, calculator='pyscf', basis=basis, unit='bohr') # define the backflow transformation self.backflow_trans = BackFlowTransformation( self.mol, BackFlowKernelInverse) # define the grid points self.npts = 11 self.pos = torch.rand(self.npts, self.mol.nelec * 3) self.pos = Variable(self.pos) self.pos.requires_grad = True
def setUp(self): # define the molecule at = 'C 0 0 0' basis = 'dzp' self.mol = Molecule(atom=at, calculator='pyscf', basis=basis, unit='bohr') self.m = gto.M(atom=at, basis=basis, unit='bohr') # define the wave function self.wf = Orbital(self.mol, include_all_mo=True) # define the grid points npts = 11 self.pos = torch.rand(npts, self.mol.nelec * 3) self.pos = Variable(self.pos) self.pos.requires_grad = True