1#!/usr/bin/env python 2# Copyright 2014-2019 The PySCF Developers. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16# Author: Qiming Sun <osirpt.sun@gmail.com> 17# 18 19''' 20Non-relativistic Restricted Kohn-Sham 21''' 22 23from pyscf.scf import hf_symm 24from pyscf.dft import rks 25from pyscf.dft import uks 26 27 28class SymAdaptedRKS(hf_symm.SymAdaptedRHF, rks.KohnShamDFT): 29 ''' Restricted Kohn-Sham ''' 30 def __init__(self, mol, xc='LDA,VWN'): 31 hf_symm.RHF.__init__(self, mol) 32 rks.KohnShamDFT.__init__(self, xc) 33 34 def dump_flags(self, verbose=None): 35 hf_symm.RHF.dump_flags(self, verbose) 36 rks.KohnShamDFT.dump_flags(self, verbose) 37 return self 38 39 get_veff = rks.get_veff 40 get_vsap = rks.get_vsap 41 energy_elec = rks.energy_elec 42 43 init_guess_by_vsap = rks.init_guess_by_vsap 44 45 reset = rks.KohnShamDFT.reset 46 47 def nuc_grad_method(self): 48 from pyscf.grad import rks 49 return rks.Gradients(self) 50 51RKS = SymAdaptedRKS 52 53 54class SymAdaptedROKS(hf_symm.SymAdaptedROHF, rks.KohnShamDFT): 55 ''' Restricted Kohn-Sham ''' 56 def __init__(self, mol, xc='LDA,VWN'): 57 hf_symm.ROHF.__init__(self, mol) 58 rks.KohnShamDFT.__init__(self, xc) 59 60 def dump_flags(self, verbose=None): 61 hf_symm.ROHF.dump_flags(self, verbose) 62 rks.KohnShamDFT.dump_flags(self, verbose) 63 return self 64 65 get_veff = uks.get_veff 66 get_vsap = rks.get_vsap 67 energy_elec = uks.energy_elec 68 69 init_guess_by_vsap = rks.init_guess_by_vsap 70 71 reset = rks.KohnShamDFT.reset 72 73 def nuc_grad_method(self): 74 from pyscf.grad import roks 75 return roks.Gradients(self) 76 77ROKS = SymAdaptedROKS 78 79 80if __name__ == '__main__': 81 from pyscf import gto 82 mol = gto.Mole() 83 mol.verbose = 2 84 mol.output = '/dev/null' 85 86 mol.atom.extend([['He', (0.,0.,0.)], ]) 87 mol.basis = { 'He': 'cc-pvdz'} 88 mol.symmetry = 1 89 mol.build() 90 91 m = RKS(mol) 92 m.xc = 'b3lyp' 93 print(m.scf()) # -2.89992555753 94 95