コード例 #1
0
 def test_energy_nuc_gto_vs_nao(self):
     """ Test computation of matrix elements of nuclear-electron attraction """
     sv = system_vars_c().init_pyscf_gto(mol)
     e_nao = sv.energy_nuc()
     e_gto = mol.energy_nuc()
     self.assertAlmostEqual(e_nao, e_gto)
コード例 #2
0
ファイル: m_ls_part_centers.py プロジェクト: chrinide/pyscf
def is_overlapping(rv1,rcut1, rv2,rcut2, rv3,rcut3, ac_rcut_ratio=1.0):
  """ For a given atom pair (1,2) and a center 3 tell whether function at center overlaps with the product."""
  cond12 = sum((rv1-rv2)**2)<(rcut1+rcut2)**2
  cond = sum((rv2-rv3)**2)<ac_rcut_ratio**2*(rcut2+rcut3)**2 and sum((rv1-rv3)**2)<ac_rcut_ratio**2*(rcut1+rcut3)**2
  return cond and cond12
  
#
#
#
if __name__ == '__main__':
  from pyscf import gto
  from pyscf.nao import system_vars_c
  from numpy import array

  mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0; H 0 0 3; H 0 0 4', unit='angstrom') 
  sv = system_vars_c(gto=mol)
  print( ls_part_centers(sv, 0, 1, ac_rcut_ratio=0.7) )

  
  visualize_3c = False
  if visualize_3c:
    import matplotlib.pyplot as plt
    import pylab

    rv1,rcut1 = array([0.0,  0.0, 0.0]), 3.0
    rv2,rcut2 = array([5.0,  0.0, 0.0]), 3.0
    rv3,rcut3 = array([2.5,  0.0, 0.0]), 2.0
    
    axes = pylab.axes()
    axes.add_patch(pylab.Circle((rv1[0], rv1[1]), radius=rcut1, alpha=.33, color='r', edgecolor='y', lw=3))
    axes.add_patch(pylab.Circle((rv2[0], rv2[1]), radius=rcut2, alpha=.33, color='r', edgecolor='y', lw=3))
コード例 #3
0
    from pyscf.nao.m_vxc_lil import vxc_lil
    return vxc_lil(self.sv, dm, xc_code, deriv=2, ao_log=self.prod_log, **kvargs)
  
  def comp_fxc_pack(self, dm, xc_code, kernel = None, **kvargs):
    """ Computes the packed version of the Hartree kernel """
    from pyscf.nao.m_vxc_pack import vxc_pack

    if kernel is None:
        return vxc_pack(self.sv, dm, xc_code, deriv=2, kernel=kernel, ao_log=self.prod_log, **kvargs)
    else:
        vxc_pack(self.sv, dm, xc_code, deriv=2, kernel=kernel, ao_log=self.prod_log, **kvargs)


#
#
#
if __name__=='__main__':
  from pyscf.nao import prod_basis_c, system_vars_c, comp_overlap_coo
  from pyscf import gto
  import numpy as np
  
  mol = gto.M(atom='O 0 0 0; H 0 0 0.5; H 0 0.5 0', basis='ccpvdz') # coordinates in Angstrom!
  sv = system_vars_c(gto=mol)
  print(sv.atom2s)
  s_ref = comp_overlap_coo(sv).todense()
  pb = prod_basis_c(sv)
  mom0,mom1=pb.comp_moments()
  pab2v = pb.get_vertex_array()
  s_chk = einsum('pab,p->ab', pab2v,mom0)
  print(abs(s_chk-s_ref).sum()/s_chk.size, abs(s_chk-s_ref).max())
コード例 #4
0
from __future__ import print_function, division
import unittest, numpy as np
from pyscf import gto
from pyscf.nao import system_vars_c, conv_yzx2xyz_c

mol = gto.M(
    verbose=1,
    atom='''
        O     0    0        0
        H     0    -0.757   0.587
        H     0    0.757    0.587''',
    basis='cc-pvdz',
)
conv = conv_yzx2xyz_c(mol)
sv = system_vars_c().init_pyscf_gto(mol)


class KnowValues(unittest.TestCase):
    def test_gto2sv(self):
        """ Test transformation of the radial orbitals from GTO to NAO type"""
        self.assertEqual((sv.natoms, sv.norbs, len(sv.ao_log.psi_log)),
                         (3, 24, 2))
        rr = sv.ao_log.rr
        self.assertEqual(len(rr), 1024)
        dr = np.log(rr[1] / rr[0])
        for mu2ff in sv.ao_log.psi_log:
            for ff in mu2ff:
                norm = (ff**2 * sv.ao_log.rr**3).sum() * dr
                self.assertAlmostEqual(norm, 1.0)
コード例 #5
0
 def test_vhartree_gto_vs_nao(self):
     """ Test computation of Hartree potential between NAOs against this computed between GTOs"""
     vh_gto = conv.conv_yzx2xyz_2d(gto_hf.get_j())
     mf = RHF(system_vars_c().init_pyscf_gto(mol))
     vh_nao = mf.vhartree_coo(dm=rdm1)
     self.assertTrue(abs(vh_nao - vh_gto).sum() / vh_gto.size < 1e-5)
コード例 #6
0
ファイル: m_eri2c.py プロジェクト: zzy2014/pyscf
    
    grids = build_3dgrid(me, sp1,np.array(R1), sp2,np.array(R2), **kvargs)

    pf = grids.weights * ao_eval(me.ao2,         np.array(R1), sp1, grids.coords)
    qv =                 ao_eval(me.ao2_hartree, np.array(R2), sp2, grids.coords)

    pq2eri = np.einsum('pr,qr->pq',pf,qv)
    return pq2eri


if __name__=="__main__":
  from pyscf.nao import system_vars_c, ao_matelem_c
  from pyscf.nao.prod_log import prod_log as prod_log_c
  from pyscf.nao.m_eri2c import eri2c
  
  sv = system_vars_c(label='siesta')
  R0 = sv.atom2coord[0,:]
  
  prod_log = prod_log_c(ao_log=sv.ao_log)
  print(prod_log.sp2norbs)
  
  me_prod = ao_matelem_c(prod_log)
  vc_am = me_prod.coulomb_am(0, R0, 0, R0)
  print(vc_am.shape, vc_am.max(), vc_am.min())

  vc_ni = eri2c(me_prod, 0, R0, 0, R0, level=5)
  print(vc_ni.shape, vc_ni.max(), vc_ni.min())
  
  print(abs(vc_ni-vc_am).sum() / vc_am.size, abs(vc_ni-vc_am).max())
  
  
コード例 #7
0
ファイル: test_0005_ao_log.py プロジェクト: zwang123/pyscf
 def test_ao_log_gto(self):
   """ This is indeed for initializing with auxiliary basis set"""
   from pyscf.nao import ao_log_c, system_vars_c
   sv = system_vars_c().init_pyscf_gto(mol)
   ao = ao_log_c().init_ao_log_gto_lm(mol, sv, sv.ao_log)
コード例 #8
0
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function, division
from timeit import default_timer as timer
import os
from pyscf.nao import system_vars_c, prod_basis_c, tddft_iter_c
from numpy import allclose

t1 = timer()
sv = system_vars_c().init_siesta_xml(label='siesta', cd='.', force_gamma=True)
t2 = timer()
print('system_vars_c().init_siesta_xml ', t2 - t1)
t1 = timer()

pbb = prod_basis_c().init_prod_basis_pp_batch(sv)
t2 = timer()
print('prod_basis_c().init_prod_basis_pp_batch(sv) ', t2 - t1)
t1 = timer()

pba = prod_basis_c().init_prod_basis_pp(sv)
t2 = timer()
print('prod_basis_c().init_prod_basis_pp(sv) ', t2 - t1)
t1 = timer()

for a, b in zip(pba.bp2info, pbb.bp2info):
コード例 #9
0
from __future__ import print_function, division
import os,unittest
from pyscf.nao import system_vars_c

sv = system_vars_c().init_siesta_xml(label='water', cd=os.path.dirname(os.path.abspath(__file__)))

class KnowValues(unittest.TestCase):

  def test_init_sv_libnao(self):
    """ Init system variables on libnao's site """
    sv.init_libnao()
    

if __name__ == "__main__": unittest.main()
コード例 #10
0
#
#
#
class simulation_c():
    def __init__(self, sv, **kvargs):
        """ Let's try with simulation"""
        self.sv = sv

    def do_overlap_check_of_pb(self, **kvargs):
        from pyscf.nao import prod_basis_c, vertex_loop_c
        self.pb = prod_basis_c(self.sv, **kvargs)
        self.vl = vertex_loop_c(self.pb, **kvargs)
        self.mom0, self.mom1 = self.pb.prod_log.comp_moments()
        ad2cc = self.pb.get_ad2cc_den()
        pab2v = self.pb.get_vertex_array()


#
# Example of starting a simulation which checks S^ab = V^ab_mu C^mu_nu S^nu
#
if __name__ == "__main__":
    from pyscf import gto
    from pyscf.nao import system_vars_c, simulation_c
    """ Interpreting small Gaussian calculation """
    mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0;',
                basis='ccpvdz')  # coordinates in Angstrom!
    sv = system_vars_c(gto=mol, tol=1e-8, nr=512, rmin=1e-5)
    sim = simulation_c(sv)
    sim.do_overlap_check_of_pb()
コード例 #11
0
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function, division
import os, unittest, numpy as np
from pyscf.nao import system_vars_c, prod_basis_c, tddft_iter_c
import h5py

dname = os.path.dirname(os.path.abspath(__file__))
sv = system_vars_c().init_siesta_xml(label='water', cd=dname)
pb = prod_basis_c().init_prod_basis_pp(sv, jcutoff=7)
td = tddft_iter_c(pb.sv, pb, tddft_iter_broadening=1e-2, xc_code='RPA')

np.savetxt("kernel.txt", td.kernel)
np.save("kernel.npy", td.kernel)

hdf = h5py.File("kernel.hdf5", "w")
hdf.create_dataset("kernel_pack", data=td.kernel)
hdf.close()


class KnowValues(unittest.TestCase):
    def test_non_inter_polariz(self):
        """ This is non-interacting polarizability TDDFT with SIESTA starting point """
        omegas = np.linspace(0.0, 2.0, 500) + 1j * td.eps
コード例 #12
0
ファイル: test_pb_batch.py プロジェクト: chrinide/pyscf
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function, division
from timeit import default_timer as timer
import os
from pyscf.nao import system_vars_c, prod_basis_c, tddft_iter_c
from numpy import allclose


t1 = timer()
sv = system_vars_c().init_siesta_xml(label='siesta', cd='.', force_gamma=True)
t2 = timer(); print(t2-t1); t1 = timer()

pbb = prod_basis_c().init_prod_basis_pp_batch(sv)
t2 = timer(); print(t2-t1); t1 = timer()

pba = prod_basis_c().init_prod_basis_pp(sv)
t2 = timer(); print(t2-t1); t1 = timer()

for a,b in zip(pba.bp2info,pbb.bp2info):
  for a1,a2 in zip(a.atoms,b.atoms): assert a1==a2
  for a1,a2 in zip(a.cc2a, b.cc2a): assert a1==a2
  assert allclose(a.vrtx, b.vrtx)
  assert allclose(a.cc, b.cc)

print(abs(pbb.get_da2cc_coo().tocsr()-pba.get_da2cc_coo().tocsr()).sum(), \
コード例 #13
0
ファイル: test_ae_fii.py プロジェクト: chrinide/pyscf
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function
from pyscf.nao import system_vars_c, prod_log_c, conv_yzx2xyz_c, get_atom2bas_s, ao_matelem_c
from pyscf.nao.m_system_vars import diag_check, overlap_check
from pyscf.nao.m_prod_log import dipole_check
from pyscf import gto
import numpy as np

mol = gto.M(atom='O 0 0 0; H 0 0 1; H 0 1 0', basis='ccpvdz') # coordinates in Angstrom!
sv  = system_vars_c().init_pyscf_gto(mol)
prod_log = prod_log_c().init_prod_log_dp(sv.ao_log)
print(prod_log.overlap_check())
print(prod_log.lambda_check_overlap())
print(dipole_check(sv, prod_log))
print('builtin simple center checks done \n')

me = ao_matelem_c(prod_log)

errmx = 0
for ia1 in range(sv.natoms):
  for ia2 in range(sv.natoms):

    n1,n2 = [sv.atom2s[ia+1]-sv.atom2s[ia] for ia in [ia1,ia2]]
    mol3 = gto.Mole_pure(atom=[sv._atom[ia1], sv._atom[ia2]], basis=sv.basis, unit='bohr').build()
    bs = get_atom2bas_s(mol3._bas)