Esempio n. 1
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()
Esempio n. 2
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 ''
Esempio 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 ''
Esempio n. 4
0
def gen_Ne():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("ne_def2_svp.wfnoj.xml",
                                                      ['Ne'])
    gto = gaussian_orbitals.GTO(basis_sets['Ne'])
    for pos in ([0.1, 0.0, 0.0], [1.0, 0.0, 0.0]):
        atomic_orbs = gto.eval_v(*pos)
        mol_orbs = np.dot(MO_matrix, atomic_orbs)

        print '  // Generated from gen_mo.py for position %s' % str(pos)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, mol_orbs[0])

        v, g, l = gto.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)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, mo_v[0])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (0, mo_g[0][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (0, mo_g[0][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (0, mo_g[0][2])
        print '  REQUIRE(d2psi[%d] == Approx(%15.10g));' % (0, mo_l[0])

        v, g, h = gto.eval_vgh(*pos)
        gh = gto.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)
        print '  // Generated from gen_mo.py for position %s' % str(pos)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, mo_v[0])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (0, mo_g[0][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (0, mo_g[0][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (0, mo_g[0][2])
        print '  //Hessian (xx,xy,xz,yy,yz,zz) '
        print '  REQUIRE(dhpsi[%d][0] == Approx(%15.10g));' % (0, mo_h[0][0])
        print '  REQUIRE(dhpsi[%d][1] == Approx(%15.10g));' % (0, mo_h[0][1])
        print '  REQUIRE(dhpsi[%d][2] == Approx(%15.10g));' % (0, mo_h[0][2])
        print '  REQUIRE(dhpsi[%d][3] == Approx(%15.10g));' % (0, mo_h[0][3])
        print '  REQUIRE(dhpsi[%d][4] == Approx(%15.10g));' % (0, mo_h[0][4])
        print '  REQUIRE(dhpsi[%d][5] == Approx(%15.10g));' % (0, mo_h[0][5])
        print '  //GradHessian (xxx,xxy,xxz,xyy,xyz,xzz,yyy,yyz,yzz,zzz) '
        print '  REQUIRE(dghpsi[%d][0] == Approx(%15.10g));' % (0, mo_gh[0][0])
        print '  REQUIRE(dghpsi[%d][1] == Approx(%15.10g));' % (0, mo_gh[0][1])
        print '  REQUIRE(dghpsi[%d][2] == Approx(%15.10g));' % (0, mo_gh[0][2])
        print '  REQUIRE(dghpsi[%d][3] == Approx(%15.10g));' % (0, mo_gh[0][3])
        print '  REQUIRE(dghpsi[%d][4] == Approx(%15.10g));' % (0, mo_gh[0][4])
        print '  REQUIRE(dghpsi[%d][5] == Approx(%15.10g));' % (0, mo_gh[0][5])
        print '  REQUIRE(dghpsi[%d][6] == Approx(%15.10g));' % (0, mo_gh[0][6])
        print '  REQUIRE(dghpsi[%d][7] == Approx(%15.10g));' % (0, mo_gh[0][7])
        print '  REQUIRE(dghpsi[%d][8] == Approx(%15.10g));' % (0, mo_gh[0][8])
        print '  REQUIRE(dghpsi[%d][9] == Approx(%15.10g));' % (0, mo_gh[0][9])
        print ''
Esempio n. 5
0
def gen_He():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("he_sto3g.wfj.xml",
                                                      ['He'])
    gto = gaussian_orbitals.GTO(basis_sets['He'])
    for pos in ([0.1, 0.0, 0.0], [1.0, 0.0, 0.0]):
        atomic_orbs = gto.eval_v(*pos)

        print('  // Generated from gen_mo.py for position %s' % str(pos))
        print('  REQUIRE(values[%d] == Approx(%15.10g));' %
              (0, atomic_orbs[0]))
        print('')

        v, g, l = gto.eval_vgl(*pos)
        print('  // Generated from gen_mo.py for position %s' % str(pos))
        print('  REQUIRE(values[%d] == Approx(%15.10g));' % (0, v[0]))
        print('  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (0, g[0][0]))
        print('  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (0, g[0][1]))
        print('  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (0, g[0][2]))
        print('  REQUIRE(d2psi[%d] == Approx(%15.10g));' % (0, l[0]))
        print('')

        v, g, h = gto.eval_vgh(*pos)
        gh = gto.eval_gradhess(*pos)
        print('  // Generated from gen_mo.py for position %s' % str(pos))
        print('  REQUIRE(values[%d] == Approx(%15.10g));' % (0, v[0]))
        print('  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (0, g[0][0]))
        print('  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (0, g[0][1]))
        print('  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (0, g[0][2]))
        print('  //Hessian (xx,xy,xz,yy,yz,zz) ')
        print('  REQUIRE(dhpsi[%d][0] == Approx(%15.10g));' % (0, h[0][0]))
        print('  REQUIRE(dhpsi[%d][1] == Approx(%15.10g));' % (0, h[0][1]))
        print('  REQUIRE(dhpsi[%d][2] == Approx(%15.10g));' % (0, h[0][2]))
        print('  REQUIRE(dhpsi[%d][3] == Approx(%15.10g));' % (0, h[0][3]))
        print('  REQUIRE(dhpsi[%d][4] == Approx(%15.10g));' % (0, h[0][4]))
        print('  REQUIRE(dhpsi[%d][5] == Approx(%15.10g));' % (0, h[0][5]))
        print('  //GradHessian (xxx,xxy,xxz,xyy,xyz,xzz,yyy,yyz,yzz,zzz) ')
        print('  REQUIRE(dghpsi[%d][0] == Approx(%15.10g));' % (0, gh[0][0]))
        print('  REQUIRE(dghpsi[%d][1] == Approx(%15.10g));' % (0, gh[0][1]))
        print('  REQUIRE(dghpsi[%d][2] == Approx(%15.10g));' % (0, gh[0][2]))
        print('  REQUIRE(dghpsi[%d][3] == Approx(%15.10g));' % (0, gh[0][3]))
        print('  REQUIRE(dghpsi[%d][4] == Approx(%15.10g));' % (0, gh[0][4]))
        print('  REQUIRE(dghpsi[%d][5] == Approx(%15.10g));' % (0, gh[0][5]))
        print('  REQUIRE(dghpsi[%d][6] == Approx(%15.10g));' % (0, gh[0][6]))
        print('  REQUIRE(dghpsi[%d][7] == Approx(%15.10g));' % (0, gh[0][7]))
        print('  REQUIRE(dghpsi[%d][8] == Approx(%15.10g));' % (0, gh[0][8]))
        print('  REQUIRE(dghpsi[%d][9] == Approx(%15.10g));' % (0, gh[0][9]))
        print('')
Esempio n. 6
0
def values_for_He():
    rc_val = 0.1
    Z_val = 2

    basis_set, MO = read_qmcpack.parse_qmc_wf('he_sto3g.wfj.xml')
    he_gto = gaussian_orbitals.GTO(basis_set['He'])

    Xvals = evalX(he_gto, Z_val, rc_val)

    alpha_vals = solve_for_alpha(Xvals, rc_val)
    output_required_xvals_and_alphas(Xvals, alpha_vals)

    El_sym = get_symbolic_effective_local_energy()
    print("El_sym = ", El_sym)

    Zeff_val = 2.0
    el_at_rc = -eval_El(El_sym, rc_val, Zeff_val, alpha_vals)
    dE = el_at_rc
    print('el at rc_val = ', el_at_rc)

    pos = get_grid()

    current_EL = get_current_local_energy(pos, he_gto, El_sym, alpha_vals,
                                          rc_val, dE, Zeff_val)
    original_EL = get_original_local_energy(pos, he_gto, El_sym, alpha_vals,
                                            rc_val, Zeff_val)
    #print('Current effective local energy')
    #for (p,v) in zip(pos,current_EL):
    #  print(p,v)
    print("  // Grid for local energy evaluations")
    output_array(pos, "cusp.pos")

    print("  // Original local energy")
    output_array(original_EL, "cusp.ELorig")

    print("  // Current local energy")
    output_array(current_EL, "cusp.ELcurr")

    print("  // Ideal local energy")
    ideal_EL = get_ideal_local_energy(pos, rc_val)
    output_array(ideal_EL, "cusp.ELideal")

    chi2 = 0.0
    for rval, ideal, curr in zip(pos, ideal_EL, current_EL):
        chi2 += (ideal - curr)**2
    print('  REQUIRE(chi2 == Approx(%.10f)); ' % chi2)
Esempio n. 7
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()
Esempio n. 8
0
def gen_He():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("he_sto3g.wfj.xml")
    gto = gaussian_orbitals.GTO(basis_sets['He'])
    for pos in ([0.1, 0.0, 0.0], [1.0, 0.0, 0.0]):
        atomic_orbs = gto.eval_v(*pos)

        print '  // Generated from gen_mo.py for position %s' % str(pos)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, atomic_orbs[0])
        print ''

        v, g, l = gto.eval_vgl(*pos)
        print '  // Generated from gen_mo.py for position %s' % str(pos)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, v[0])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (0, g[0][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (0, g[0][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (0, g[0][2])
        print '  REQUIRE(d2psi[%d] == Approx(%15.10g));' % (0, l[0])
        print ''
Esempio n. 9
0
def gen_Ne():
    basis_sets, MO_matrix = read_qmcpack.parse_qmc_wf("ne_def2_svp.wfnoj.xml")
    gto = gaussian_orbitals.GTO(basis_sets['Ne'])
    for pos in ([0.00001, 0.0, 0.0], [1.0, 0.0, 0.0]):
        atomic_orbs = gto.eval_v(*pos)
        mol_orbs = np.dot(MO_matrix, atomic_orbs)

        print '  // Generated from gen_mo.py for position %s' % str(pos)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, mol_orbs[0])

        v, g, l = gto.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)
        print '  REQUIRE(values[%d] == Approx(%15.10g));' % (0, mo_v[0])
        print '  REQUIRE(dpsi[%d][0] == Approx(%15.10g));' % (0, mo_g[0][0])
        print '  REQUIRE(dpsi[%d][1] == Approx(%15.10g));' % (0, mo_g[0][1])
        print '  REQUIRE(dpsi[%d][2] == Approx(%15.10g));' % (0, mo_g[0][2])
        print '  REQUIRE(d2psi[%d] == Approx(%15.10g));' % (0, mo_l[0])
Esempio n. 10
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)