Example #1
0
    def test_excited_supersystem(self):
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        H 0. -2.757 2.857
        H 0. 2.757 2.857
        '''
        mol.basis = '3-21g'
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        He 1.0 20.0 0.0
        He 3.0 20.0 0.0'''
        mol2.basis = '3-21g'
        mol2.build()
        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method)

        mol12 = helpers.concat_mols([mol, mol2])
        fs_scf_obj = helpers.gen_scf_obj(mol12, 'm06')

        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2], 'm06', fs_scf_obj, init_guess='minao',
                fs_excited=True, fs_excited_dict={'nroots':4}, ft_excited_relax=True, ft_excited_dict={'nroots':2})

        self.assertTrue(supersystem.fs_excited)
        self.assertTrue(supersystem.ft_excited_relax)
        self.assertDictEqual(supersystem.fs_excited_dict, {'nroots':4})
        self.assertDictEqual(supersystem.ft_excited_dict, {'nroots':2})
        self.assertEqual(supersystem.fs_excited_nroots, 4)
        self.assertEqual(supersystem.ft_excited_nroots, 2)
Example #2
0
    def test_partialghost_supersystem(self):
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        H 0. -2.757 2.857
        H 0. 2.757 2.857
        ghost:H 0. 0. 2.857
        '''
        mol.basis = '3-21g'
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        He 1.0 20.0 0.0
        He 3.0 20.0 0.0'''
        mol2.basis = '3-21g'
        mol2.build()
        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method)

        mol12 = helpers.concat_mols([mol, mol2])
        fs_scf_obj = helpers.gen_scf_obj(mol12, 'b3lyp')

        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2], 'b3lyp', fs_scf_obj, init_guess='minao')
        self.assertEqual(supersystem.env_method, 'b3lyp')
        self.assertEqual(supersystem.proj_oper, 'huz')
        self.assertEqual(supersystem.init_guess, 'minao')
Example #3
0
    def test_density_fitting_supersystem(self):
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        H 0. -2.757 2.857
        H 0. 2.757 2.857
        '''
        mol.basis = '3-21g'
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        He 1.0 20.0 0.0
        He 3.0 20.0 0.0'''
        mol2.basis = '3-21g'
        mol2.build()

        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method)
        mol12 = helpers.concat_mols([mol, mol2])
        fs_scf_obj = helpers.gen_scf_obj(mol12, 'm06', density_fitting=True)
        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2], 'm06', fs_scf_obj, init_guess='minao')

        #Check SCF object
        scf_obj = supersystem.fs_scf_obj
        from pyscf.df.df_jk import _DFHF
        self.assertTrue(isinstance(scf_obj, _DFHF))
        self.assertEqual(scf_obj.xc, 'm06')
        self.assertEqual(scf_obj.density_fitting, True)
Example #4
0
    def test_hsros_supersystem(self):
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        H 0. -2.757 2.857
        H 0. 2.757 2.857
        '''
        mol.basis = '3-21g'
        mol.spin = 2
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        He 1.0 20.0 0.0
        He 3.0 20.0 0.0'''
        mol2.basis = '3-21g'
        mol2.build()

        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method)
        mol12 = helpers.concat_mols([mol, mol2])
        fs_scf_obj = helpers.gen_scf_obj(mol12, 'm06')
        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2], 'm06', fs_scf_obj, init_guess='minao')

        #Check SCF object
        scf_obj = supersystem.fs_scf_obj
        comp_scf_obj = dft.ROKS(gto.mole.conc_mol(mol, mol2))
        self.assertEqual(type(scf_obj), type(comp_scf_obj))
        self.assertEqual(scf_obj.xc, 'm06')
Example #5
0
    def test_excited_hl_subsystem(self):
        t_file = tempfile.NamedTemporaryFile()
        hl_method  = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(self.cs_mol, self.env_method,
                     hl_method, hl_excited=True, hl_excited_dict={'conv':1e-9, 'nroots': 4})

        self.assertTrue(subsys.hl_excited)
        self.assertDictEqual(subsys.hl_excited_dict, {'conv':1e-9,'nroots':4})
        self.assertEqual(subsys.hl_excited_nroots, 4)
        self.assertEqual(subsys.hl_excited_conv, 1e-9)
Example #6
0
    def setUp(self):

        mol1 = gto.Mole()
        mol1.atom = '''
        O 10.0 0.0 0.0
        H 10. 0.7586 0.5043
        H 10. 0.7586 -0.5043'''
        mol1.basis = 'sto-3g'
        mol1.build()
        self.sub1 = cluster_subsystem.ClusterEnvSubSystem(mol1, 'lda', env_order=1)

        mol2 = gto.Mole()
        mol2.atom = '''
        O 20.0 0.0 0.0
        H 20. 0.7586 0.5043
        H 20. 0.7586 -0.5043'''
        mol2.basis = 'sto-3g'
        mol2.build()
        self.sub2 = cluster_subsystem.ClusterEnvSubSystem(mol2, 'm06', env_order=2)

        mol3 = gto.Mole()
        mol3.atom = '''
        O 0.0 0.0 0.0
        H 0. 0.7586 0.5043
        H 0. 0.7586 -0.5043'''
        mol3.basis = 'sto-3g'
        mol3.build()
        self.sub3 = cluster_subsystem.ClusterHLSubSystem(mol3, 'm06', 'rhf', env_order=2)

        mol4 = gto.Mole()
        mol4.verbose=3
        mol4.atom = '''
        O 30.0 0.0 0.0
        H 30. 0.7586 0.5043
        H 30. 0.7586 -0.5043'''
        mol4.basis = 'sto-3g'
        mol4.build()
        self.sub4 = cluster_subsystem.ClusterEnvSubSystem(mol4, 'lda', env_order=2)

        sup1_alt_sub_mol = gto.Mole()
        sup1_alt_sub_mol.verbose = 3
        sup1_alt_sub_mol.atom = '''
        O 0.0 0.0 0.0
        H 0. 0.7586 0.5043
        H 0. 0.7586 -0.5043
        O 20.0 0.0 0.0
        H 20. 0.7586 0.5043
        H 20. 0.7586 -0.5043'''
        sup1_alt_sub_mol.basis = 'sto-3g'
        sup1_alt_sub_mol.build()
        self.sup1_alt_sub = cluster_subsystem.ClusterEnvSubSystem(sup1_alt_sub_mol, 'lda', env_order=2)
Example #7
0
    def test_ovlpghost_supersystem(self):
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        H 0. -2.757 2.857
        H 0. 2.757 2.857
        ghost:He 1.0 20.0 0.0
        ghost:H 0. 0. 2.857
        '''
        mol.basis = '3-21g'
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        ghost:H 0. 2.757 2.857
        He 1.0 20.0 0.0
        He 3.0 20.0 0.0'''
        mol2.basis = '3-21g'
        mol2.build()
        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method)

        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2], 'b3lyp', ft_initguess='minao')
        self.assertEqual(supersystem.fs_method, 'b3lyp')
        self.assertEqual(supersystem.proj_oper, 'huz')
        self.assertEqual(supersystem.ft_cycles, 100)
        self.assertEqual(supersystem.ft_conv, 1e-8)
        self.assertEqual(supersystem.ft_grad, None)
        self.assertEqual(supersystem.ft_initguess, 'minao')
        self.assertEqual(supersystem.ft_updatefock, 0)

        self.assertEqual(supersystem.fs_cycles, None)
        self.assertEqual(supersystem.fs_conv, None)
        self.assertEqual(supersystem.fs_grad, None)
        self.assertEqual(supersystem.fs_damp, 0)
        self.assertEqual(supersystem.fs_shift, 0)
        self.assertEqual(supersystem.fs_smearsigma, 0)
        self.assertEqual(supersystem.fs_initguess, None)
        self.assertEqual(supersystem.grid_level, None)
        self.assertEqual(supersystem.rho_cutoff, None)
        self.assertEqual(supersystem.fs_verbose, None)
Example #8
0
    def test_basic_supersystem(self):
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        H 0. -2.757 2.857
        H 0. 2.757 2.857
        '''
        mol.basis = '3-21g'
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        He 1.0 20.0 0.0
        He 3.0 20.0 0.0'''
        mol2.basis = '3-21g'
        mol2.build()
        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method)

        mol12 = helpers.concat_mols([mol, mol2])
        fs_scf_obj = helpers.gen_scf_obj(mol12, 'm06')

        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2], 'm06', fs_scf_obj, init_guess='minao')
        self.assertEqual(supersystem.env_method, 'm06')
        self.assertEqual(supersystem.proj_oper, 'huz')
        self.assertEqual(supersystem.max_cycle, 200)
        self.assertEqual(supersystem.conv_tol, 1e-9)
        self.assertEqual(supersystem.damp, 0)
        self.assertEqual(supersystem.init_guess, 'minao')
        self.assertEqual(supersystem.fock_subcycles, 1)

        #Check SCF object
        scf_obj = supersystem.fs_scf_obj
        comp_scf_obj = dft.RKS(gto.mole.conc_mol(mol, mol2))
        self.assertEqual(type(scf_obj), type(comp_scf_obj))
        print (comp_scf_obj.mol._basis)
        print (supersystem.mol._basis)
        self.assertTrue(gto.same_mol(comp_scf_obj.mol, supersystem.mol, cmp_basis=False))
        self.assertEqual(scf_obj.xc, 'm06')
Example #9
0
    def test_basic_subsystem(self):
        hl_method = 'ccsd'
        subsys = cluster_subsystem.ClusterHLSubSystem(self.cs_mol, self.env_method, hl_method)

        self.assertEqual(subsys.mol, self.cs_mol)
        self.assertEqual(subsys.env_method, self.env_method)

        self.assertEqual(subsys.env_smearsigma, 0)
        self.assertEqual(subsys.env_damp, 0)
        self.assertEqual(subsys.env_shift, 0)
        self.assertEqual(subsys.env_subcycles, 1)
        self.assertEqual(subsys.freeze, False)
        self.assertEqual(subsys.env_initguess, None)
        self.assertEqual(subsys.verbose, 3)

        self.assertEqual(subsys.hl_method, 'ccsd')
        self.assertEqual(subsys.hl_conv, None)
        self.assertEqual(subsys.hl_grad, None)
        self.assertEqual(subsys.hl_cycles, None)
        self.assertEqual(subsys.hl_damp, 0)
        self.assertEqual(subsys.hl_shift, 0)
        self.assertEqual(subsys.hl_initguess, None)
Example #10
0
    def test_custom_obj_set(self):
        t_file = tempfile.NamedTemporaryFile()
        hl_method  = 'caspt2'
        subsys = cluster_subsystem.ClusterHLSubSystem(self.cs_mol, self.env_method, 
            hl_method, hl_conv=1e-9, hl_grad=1e-8, hl_cycles=2, hl_damp=0.1,
            hl_shift=0.001, hl_initguess='minao', env_smearsigma=0.5, damp=1,
            shift=1, subcycles=10, freeze=True, initguess='supmol',
            verbose=2, save_orbs=True, save_density=True, 
            hl_save_orbs=True, hl_save_density=True, filename=t_file.name, hl_dict={'active_orbs':[2,3,4,5], 'loc_orbs':True})

        self.assertEqual(subsys.mol, self.cs_mol)
        self.assertEqual(subsys.env_method, self.env_method)
        self.assertEqual(subsys.filename, t_file.name)

        self.assertEqual(subsys.env_smearsigma, 0.5)
        self.assertEqual(subsys.env_damp, 1)
        self.assertEqual(subsys.env_shift, 1)
        self.assertEqual(subsys.env_subcycles, 10)
        self.assertEqual(subsys.freeze, True)
        self.assertEqual(subsys.env_initguess, 'supmol')
        self.assertEqual(subsys.verbose, 2)
        self.assertEqual(subsys.save_orbs, True)
        self.assertEqual(subsys.save_density, True)

        # hl methods
        self.assertEqual(subsys.hl_method, 'caspt2')
        self.assertEqual(subsys.cas_loc_orbs, True)
        self.assertEqual(subsys.cas_active_orbs, [2,3,4,5])
        self.assertEqual(subsys.hl_conv, 1e-9)
        self.assertEqual(subsys.hl_grad, 1e-8)
        self.assertEqual(subsys.hl_cycles, 2)
        self.assertEqual(subsys.hl_damp, 0.1)
        self.assertEqual(subsys.hl_shift, 0.001)
        self.assertEqual(subsys.hl_initguess, 'minao')
        self.assertEqual(subsys.hl_save_orbs, True)
        self.assertEqual(subsys.hl_save_density, True)
Example #11
0
    def test_custom_supersystem(self):
        t_file = tempfile.NamedTemporaryFile()
        mol = gto.Mole()
        mol.verbose = 3
        mol.atom = '''
        O 0.0 0.0 0.0
        H 0. -2.757 2.857
        H 0. 2.757 2.857'''
        mol.basis = 'aug-cc-pVDZ'
        mol.build()
        env_method = 'm06'
        hl_method = 'ccsd'
        hl_dict = {'froz_orbs': 10}
        subsys = cluster_subsystem.ClusterHLSubSystem(mol, env_method, hl_method, filename=t_file.name, hl_dict=hl_dict)

        mol2 = gto.Mole()
        mol2.verbose = 3
        mol2.atom = '''
        O 1.0 0.0 0.0
        O 3.0 0.0 0.0'''
        mol2.basis = 'aug-cc-pVDZ'
        mol2.verbose = 1
        mol2.build()
        env_method = 'm06'
        subsys2 = cluster_subsystem.ClusterEnvSubSystem(mol2, env_method, filename=t_file.name)

        mol12 = helpers.concat_mols([mol, mol2])
        fs_scf_obj = helpers.gen_scf_obj(mol12, 'b3lyp', max_cycle=3, conv_tol=2,
                                         damp=1, level_shift_factor=2.1,
                                         init_guess='atom', grid_level=2, 
                                         small_rho_cutoff=1e-2, save_orbs=True,
                                         save_density=True,
                                         stability_analysis='internal')

        supersystem = cluster_supersystem.ClusterSuperSystem([subsys, subsys2],
                          'b3lyp', fs_scf_obj, proj_oper='huzfermi', max_cycle=2, 
                          conv_tol=1e-1, diis_num=3, init_guess='1e', 
                          fock_subcycles=1, set_fermi=-0.1, damp=0.5, 
                          compare_density=True, save_density=True,
                          save_orbs=True, filename=t_file.name)

        self.assertEqual(supersystem.env_method, 'b3lyp')
        self.assertEqual(supersystem.proj_oper, 'huzfermi')
        self.assertEqual(supersystem.filename, t_file.name)
        self.assertEqual(supersystem.max_cycle, 2)
        self.assertEqual(supersystem.conv_tol, 1e-1)
        self.assertEqual(supersystem.damp, 0.5)
        self.assertIsInstance(supersystem.emb_diis, lib.diis.DIIS)
        self.assertIsInstance(supersystem.emb_diis_2, lib.diis.DIIS)
        self.assertEqual(supersystem.set_fermi, -0.1)
        self.assertEqual(supersystem.init_guess, '1e')
        self.assertEqual(supersystem.fock_subcycles, 1)
        self.assertEqual(supersystem.compare_density, True)
        self.assertEqual(supersystem.save_orbs, True)
        self.assertEqual(supersystem.save_density, True)

        fs_scf_obj = supersystem.fs_scf_obj
        self.assertEqual(fs_scf_obj.max_cycle, 3)
        self.assertEqual(fs_scf_obj.conv_tol, 2)
        self.assertEqual(fs_scf_obj.damp, 1)
        self.assertEqual(fs_scf_obj.level_shift_factor, 2.1)
        self.assertEqual(fs_scf_obj.init_guess, 'atom')
        self.assertEqual(fs_scf_obj.grids.level, 2)
        self.assertEqual(fs_scf_obj.small_rho_cutoff, 1e-2)
        self.assertEqual(fs_scf_obj.verbose, 1)
        self.assertEqual(fs_scf_obj.stability_analysis, 'internal')
        self.assertEqual(fs_scf_obj.save_orbs, True)
        self.assertEqual(fs_scf_obj.save_density, True)