1# Copyright 2014-2020 The PySCF Developers. All Rights Reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15''' 16Density functional theory 17========================= 18 19Simple usage:: 20 21 >>> from pyscf import gto, dft 22 >>> mol = gto.M(atom='N 0 0 0; N 0 0 1', basis='def2-tzvp') 23 >>> mf = dft.RKS(mol) 24 >>> mf.xc = 'pbe,pbe' 25 >>> mf.run() 26''' 27 28try: 29 from pyscf.dft import libxc 30 XC = libxc.XC 31except (ImportError, OSError): 32 pass 33try: 34 from pyscf.dft import xcfun 35 XC = xcfun.XC 36except (ImportError, OSError): 37 pass 38#from pyscf.dft import xc 39from pyscf.dft import rks 40from pyscf.dft import roks 41from pyscf.dft import uks 42from pyscf.dft import gks 43from pyscf.dft import rks_symm 44from pyscf.dft import uks_symm 45from pyscf.dft import gks_symm 46from pyscf.dft import dks 47from pyscf.dft import gen_grid as grid 48from pyscf.dft import radi 49from pyscf.dft import numint 50from pyscf.df import density_fit 51from pyscf.dft.gen_grid import sg1_prune, nwchem_prune, treutler_prune, \ 52 stratmann, original_becke, Grids 53from pyscf.dft.radi import BRAGG_RADII, COVALENT_RADII, \ 54 delley, mura_knowles, gauss_chebyshev, treutler, treutler_ahlrichs, \ 55 treutler_atomic_radii_adjust, becke_atomic_radii_adjust 56 57 58def KS(mol, xc='LDA,VWN'): 59 if mol.spin == 0: 60 return RKS(mol, xc) 61 else: 62 return UKS(mol, xc) 63KS.__doc__ = ''' 64A wrap function to create DFT object (RKS or UKS).\n 65''' + rks.RKS.__doc__ 66DFT = KS 67 68def RKS(mol, xc='LDA,VWN'): 69 if mol.nelectron == 1: 70 return uks.UKS(mol) 71 elif not mol.symmetry or mol.groupname == 'C1': 72 if mol.spin > 0: 73 return roks.ROKS(mol, xc) 74 else: 75 return rks.RKS(mol, xc) 76 else: 77 if mol.spin > 0: 78 return rks_symm.ROKS(mol, xc) 79 else: 80 return rks_symm.RKS(mol, xc) 81RKS.__doc__ = rks.RKS.__doc__ 82 83def ROKS(mol, xc='LDA,VWN'): 84 if mol.nelectron == 1: 85 return uks.UKS(mol) 86 elif not mol.symmetry or mol.groupname == 'C1': 87 return roks.ROKS(mol, xc) 88 else: 89 return rks_symm.ROKS(mol, xc) 90ROKS.__doc__ = roks.ROKS.__doc__ 91 92def UKS(mol, xc='LDA,VWN'): 93 if not mol.symmetry or mol.groupname == 'C1': 94 return uks.UKS(mol, xc) 95 else: 96 return uks_symm.UKS(mol, xc) 97UKS.__doc__ = uks.UKS.__doc__ 98 99def GKS(mol, xc='LDA,VWN'): 100 if not mol.symmetry or mol.groupname == 'C1': 101 return gks.GKS(mol, xc) 102 else: 103 return gks_symm.GKS(mol, xc) 104GKS.__doc__ = gks.GKS.__doc__ 105 106def DKS(mol, xc='LDA,VWN'): 107 from pyscf.scf import dhf 108 if dhf.zquatev and mol.spin == 0: 109 return dks.RDKS(mol, xc=xc) 110 else: 111 return dks.UDKS(mol, xc=xc) 112