Exemplo n.º 1
0
def gen_HCN():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("hcn.wfnoj.xml")
    pos_list, elements = read_qmcpack.read_structure_file("hcn.structure.xml")

    gtos = gaussian_orbitals.GTO_centers(pos_list, elements, basis_sets)
    pos = [0.0, 0.0, 0.0]
    atomic_orbs = gtos.eval_v(*pos)
    #print 'first MO',MO_matrix[0,:]
    #print 'atomic_orbs',atomic_orbs
    mol_orbs = np.dot(MO_matrix, atomic_orbs)
    print '  // Generated from gen_mo.py for position %s' % str(pos)
    for i in range(7):
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (i, mol_orbs[i])

    v, g, l = gtos.eval_vgl(*pos)
    mo_v = np.dot(MO_matrix, v)
    mo_g = np.dot(MO_matrix, g)
    mo_l = np.dot(MO_matrix, l)
    print '  // Generated from gen_mo.py for position %s' % str(pos)
    for i in range(7):
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (i, mo_v[i])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (i, mo_g[i][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (i, mo_g[i][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (i, mo_g[i][2])
        print '  REQUIRE(d2psi[%d] == Approx(%15.10g));' % (i, mo_l[i])
        print ''
Exemplo n.º 2
0
def gen_correction_for_hcn():
  pos_list, elements = read_qmcpack.read_structure_file("hcn.structure.xml")
  basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("hcn.wfnoj.xml", elements)

  gtos = gaussian_orbitals.GTO_centers(pos_list, elements, basis_sets)

  #print("MO matrix")
  #for i in range(MO_matrix.shape[0]):
  #  print(i, MO_matrix[0:7, i])

  phi_list, eta_list, C_no_S = split_by_angular_momentum(pos_list, elements, basis_sets, MO_matrix)

  spo_name, cusp_data = read_qmcpack.read_cusp_correction_file("hcn_downdet.cuspInfo.xml")

  cusp = CuspCorrection(cusp_data, pos_list, gtos, phi_list)

  xgrid = get_grid()
  for center_idx in range(3):
    for mo_idx in range(7):
      #val_data = vals[(center_idx, mo_idx)][0]
      print('  //  Center ',center_idx, ' MO',mo_idx, 'rc = ',cusp_data[center_idx][mo_idx].Rc)
      for i,x in enumerate(xgrid):
        epos = np.array([x, 0.0, 0.0]) + pos_list[center_idx]
        v,g,l = cusp.compute_cusp_correction(center_idx, mo_idx, epos)
        print('  REQUIRE(rad_orb[%d] == Approx(%.10f)); // x = %g'%(i,v,x))
      print()
Exemplo n.º 3
0
def gen_HCN():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("hcn.wfnoj.xml",
                                                      ['N', 'C', 'H'])
    pos_list, elements = read_qmcpack.read_structure_file("hcn.structure.xml")

    gtos = gaussian_orbitals.GTO_centers(pos_list, elements, basis_sets)
    pos = [0.0, 0.0, 0.0]
    atomic_orbs = gtos.eval_v(*pos)
    #print 'first MO',MO_matrix[0,:]
    #print 'atomic_orbs',atomic_orbs
    mol_orbs = np.dot(MO_matrix, atomic_orbs)
    print '  // Generated from gen_mo.py for position %s' % str(pos)
    for i in range(7):
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (i, mol_orbs[i])

    v, g, l = gtos.eval_vgl(*pos)
    mo_v = np.dot(MO_matrix, v)
    mo_g = np.dot(MO_matrix, g)
    mo_l = np.dot(MO_matrix, l)
    print '  // Generated from gen_mo.py for position %s' % str(pos)
    for i in range(7):
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (i, mo_v[i])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (i, mo_g[i][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (i, mo_g[i][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (i, mo_g[i][2])
        print '  REQUIRE(d2psi[%d] == Approx(%15.10g));' % (i, mo_l[i])
        print ''

    v, g, h = gtos.eval_vgh(*pos)
    gh = gtos.eval_gradhess(*pos)
    mo_v = np.dot(MO_matrix, v)
    mo_g = np.dot(MO_matrix, g)
    mo_h = np.dot(MO_matrix, h)
    mo_gh = np.dot(MO_matrix, gh)
    for i in range(7):
        print '  // Generated from gen_mo.py for position %s' % str(pos)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (i, mo_v[i])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (i, mo_g[i][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (i, mo_g[i][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (i, mo_g[i][2])
        print '  //Hessian (xx,xy,xz,yy,yz,zz) '
        print '  REQUIRE(dhpsi[%d][0] == Approx(%15.10g));' % (i, mo_h[i][0])
        print '  REQUIRE(dhpsi[%d][1] == Approx(%15.10g));' % (i, mo_h[i][1])
        print '  REQUIRE(dhpsi[%d][2] == Approx(%15.10g));' % (i, mo_h[i][2])
        print '  REQUIRE(dhpsi[%d][3] == Approx(%15.10g));' % (i, mo_h[i][3])
        print '  REQUIRE(dhpsi[%d][4] == Approx(%15.10g));' % (i, mo_h[i][4])
        print '  REQUIRE(dhpsi[%d][5] == Approx(%15.10g));' % (i, mo_h[i][5])
        print '  //GradHessian (xxx,xxy,xxz,xyy,xyz,xzz,yyy,yyz,yzz,zzz) '
        print '  REQUIRE(dghpsi[%d][0] == Approx(%15.10g));' % (i, mo_gh[i][0])
        print '  REQUIRE(dghpsi[%d][1] == Approx(%15.10g));' % (i, mo_gh[i][1])
        print '  REQUIRE(dghpsi[%d][2] == Approx(%15.10g));' % (i, mo_gh[i][2])
        print '  REQUIRE(dghpsi[%d][3] == Approx(%15.10g));' % (i, mo_gh[i][3])
        print '  REQUIRE(dghpsi[%d][4] == Approx(%15.10g));' % (i, mo_gh[i][4])
        print '  REQUIRE(dghpsi[%d][5] == Approx(%15.10g));' % (i, mo_gh[i][5])
        print '  REQUIRE(dghpsi[%d][6] == Approx(%15.10g));' % (i, mo_gh[i][6])
        print '  REQUIRE(dghpsi[%d][7] == Approx(%15.10g));' % (i, mo_gh[i][7])
        print '  REQUIRE(dghpsi[%d][8] == Approx(%15.10g));' % (i, mo_gh[i][8])
        print '  REQUIRE(dghpsi[%d][9] == Approx(%15.10g));' % (i, mo_gh[i][9])
        print ''
Exemplo n.º 4
0
def gen_wavefunction_plus_correction_for_ethanol():
  pos_list, elements = read_qmcpack.read_structure_file("ethanol.structure.xml")
  basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("ethanol.wfnoj.xml", elements)

  gtos = gaussian_orbitals.GTO_centers(pos_list, elements, basis_sets)

  phi_list, eta_list, C_no_S = split_by_angular_momentum(pos_list, elements, basis_sets, MO_matrix)

  spo_name, cusp_data = read_qmcpack.read_cusp_correction_file("ethanol_downdet.cuspInfo.xml")

  cusp = CuspCorrection(cusp_data, pos_list, gtos, phi_list)

  # Bulk of the MO's - the non-cusp corrected parts
  other_mo = gaussian_orbitals.MolecularOrbital(gtos, C_no_S)

  # set electron position so it falls within rc near O atom
  xyzgrid = [(-2.1, 0.5, 0.0)]
  #xyzgrid = [(0.0, 0.0, 0.0)]
  iat = 0
  for i,epos in enumerate(xyzgrid):
    mo_v, mo_g, mo_l = other_mo.eval_vgl(epos[0], epos[1], epos[2])
    for mo_idx in range(13):
      final_v = mo_v[mo_idx]
      final_g = mo_g[mo_idx, :]
      final_l = mo_l[mo_idx]
      for center_idx in range(9):
        cv,cg,cl = cusp.compute_cusp_correction(center_idx, mo_idx, epos)
        final_v += cv
        final_g += cg
        final_l += cl

      print('  # MO %d'%mo_idx)
      print('  REQUIRE(values[%d] == Approx(%.10f));'%(mo_idx,final_v))
      print('  REQUIRE(dpsi[%d][0] == Approx(%.10f));'%(mo_idx, final_g[0]))
      print('  REQUIRE(dpsi[%d][1] == Approx(%.10f));'%(mo_idx, final_g[1]))
      print('  REQUIRE(dpsi[%d][2] == Approx(%.10f));'%(mo_idx, final_g[2]))
      print('  REQUIRE(d2psi[%d] == Approx(%.10f));'%(mo_idx,final_l))
      print()

      print('  REQUIRE(all_values[%d][%d] == Approx(%.10f));'%(iat, mo_idx, final_v))
      print('  REQUIRE(all_grad[%d][%d][0] == Approx(%.10f));'%(iat, mo_idx, final_g[0]))
      print('  REQUIRE(all_grad[%d][%d][1] == Approx(%.10f));'%(iat, mo_idx, final_g[1]))
      print('  REQUIRE(all_grad[%d][%d][2] == Approx(%.10f));'%(iat, mo_idx, final_g[2]))
      print('  REQUIRE(all_lap[%d][%d] == Approx(%.10f));'%(iat, mo_idx, final_l))
      print()
Exemplo n.º 5
0

def read_cusp_correction_file(fname):
    tree = ET.parse(fname)
    return parse_cusp_correction(tree)


if __name__ == '__main__':
    # For He
    basis_set, MO_matrix = parse_qmc_wf('he_sto3g.wfj.xml', ['He'])

    # For HCN - need ion positions as well
    pos_list, elements = read_structure_file("hcn.structure.xml")

    basis_sets, MO_matrix = parse_qmc_wf('hcn.wfnoj.xml', elements)

    gtos = gaussian_orbitals.GTO_centers(pos_list, elements, basis_sets)
    atomic_orbs = gtos.eval_v(1.0, 0.0, 0.0)
    print np.dot(MO_matrix, atomic_orbs)

    #ccp = read_cusp_correction_file("hcn_downdet.cuspInfo.xml")
    #print ccp

    # Ethanol - example with repeated atoms
    pos_list, elements = read_structure_file("ethanol.structure.xml")
    print len(pos_list), pos_list
    print 'elements', elements

    basis_sets, MO_matrix = parse_qmc_wf("ethanol.wfnoj.xml", elements)
    print MO_matrix.shape
Exemplo n.º 6
0
def gen_HCN_force():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("hcn.wfnoj.xml",
                                                      ['N', 'C', 'H'])
    ionpos, elements = read_qmcpack.read_structure_file("hcn.structure.xml")

    pos = [0.02, -0.1, 0.05]

    delta = 1.0e-6
    deltainv = 1.0 / delta

    Natom = ionpos.shape[0]
    norb = 7

    print '  // Generated from gen_mo.py for position %s' % str(pos)

    for iat in xrange(0, Natom):
        for idim in xrange(0, 3):
            ionpos_p = np.array(ionpos)
            ionpos_m = np.array(ionpos)

            ionpos_p[iat][idim] += delta
            ionpos_m[iat][idim] -= delta

            gtos_p = gaussian_orbitals.GTO_centers(ionpos_p, elements,
                                                   basis_sets)
            gtos_m = gaussian_orbitals.GTO_centers(ionpos_m, elements,
                                                   basis_sets)

            atomic_orbs_p = gtos_p.eval_v(*pos)
            atomic_orbs_m = gtos_m.eval_v(*pos)

            mol_orbs_p = np.dot(MO_matrix, atomic_orbs_p)
            mol_orbs_m = np.dot(MO_matrix, atomic_orbs_m)

            v_p, g_p, l_p = gtos_p.eval_vgl(*pos)
            mo_v_p = np.dot(MO_matrix, v_p)
            mo_g_p = np.dot(MO_matrix, g_p)
            mo_l_p = np.dot(MO_matrix, l_p)

            v_m, g_m, l_m = gtos_m.eval_vgl(*pos)
            mo_v_m = np.dot(MO_matrix, v_m)
            mo_g_m = np.dot(MO_matrix, g_m)
            mo_l_m = np.dot(MO_matrix, l_m)

            dmo_v = 0.5 * deltainv * (mo_v_p - mo_v_m)
            dmo_g = 0.5 * deltainv * (mo_g_p - mo_g_m)
            dmo_l = 0.5 * deltainv * (mo_l_p - mo_l_m)
            print "//============== Ion ", iat, " Component ", idim, "==================="
            for iorb in xrange(0, norb):
                print '  REQUIRE( dionpsi[0][%d][%d]       == Approx(%15.10g) );  ' % (
                    iorb, idim, dmo_v[iorb])
                print '  REQUIRE( diongradpsi[0][%d](%d,0) == Approx(%15.10g) );  ' % (
                    iorb, idim, dmo_g[iorb][0])
                print '  REQUIRE( diongradpsi[0][%d](%d,1) == Approx(%15.10g) );  ' % (
                    iorb, idim, dmo_g[iorb][1])
                print '  REQUIRE( diongradpsi[0][%d](%d,2) == Approx(%15.10g) );  ' % (
                    iorb, idim, dmo_g[iorb][2])
                print '  REQUIRE( dionlaplpsi[0][%d][%d]  == Approx(%15.10g) );  ' % (
                    iorb, idim, dmo_l[iorb])

    print '  // Generated from gen_mo.py for position %s' % str(pos)