Changeset d901f7


Ignore:
Timestamp:
Aug 9, 2012, 8:20:56 AM (13 years ago)
Author:
Frederik Heber <heber@…>
Children:
4dfef04
Parents:
1ed5fc
Message:

FIX: MBPT extractions were not working correctly.

  • we need to obtain ref() from MBPT to continue with the remainder of the extraction.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/bin/mpqc/mpqc.cc

    r1ed5fc rd901f7  
    14971497       }
    14981498     }
     1499     SCF *scf = NULL;
    14991500     {
    15001501       MBPT2 *mbpt2 = dynamic_cast<MBPT2*>(wfn.pointer());
    15011502       if (mbpt2 != NULL) {
    15021503         data.energies.correlation = mbpt2->corr_energy();
     1504         scf = mbpt2->ref().pointer();
    15031505         mbpt2 = 0;
    15041506       } else {
    15051507         ExEnv::out0() << "INFO: There is no MBPT2 information available." << endl;
    15061508         data.energies.correlation = 0.;
     1509         scf = dynamic_cast<SCF*>(wfn.pointer());
     1510         if (scf == NULL)
     1511           abort();
    15071512       }
    15081513     }
    15091514     {
    15101515       // taken from clscf.cc: CLSCF::scf_energy() (but see also Szabo/Ostlund)
    1511        RefSymmSCMatrix t = wfn->overlap();
    1512        RefSymmSCMatrix cl_dens_ = wfn->ao_density();
     1516
     1517       RefSymmSCMatrix t = scf->overlap();
     1518       RefSymmSCMatrix cl_dens_ = scf->ao_density();
    15131519
    15141520       SCFEnergy *eop = new SCFEnergy;
     
    15271533     {
    15281534       // taken from Wavefunction::core_hamiltonian()
    1529        RefSymmSCMatrix hao(wfn->basis()->basisdim(), wfn->basis()->matrixkit());
     1535       RefSymmSCMatrix hao(scf->basis()->basisdim(), scf->basis()->matrixkit());
    15301536       hao.assign(0.0);
    1531        Ref<PetiteList> pl = wfn->integral()->petite_list();
     1537       Ref<PetiteList> pl = scf->integral()->petite_list();
    15321538       Ref<SCElementOp> hc =
    1533          new OneBodyIntOp(new SymmOneBodyIntIter(wfn->integral()->kinetic(), pl));
     1539         new OneBodyIntOp(new SymmOneBodyIntIter(scf->integral()->kinetic(), pl));
    15341540       hao.element_op(hc);
    15351541       hc=0;
    15361542
    1537        RefSymmSCMatrix h(wfn->so_dimension(), wfn->basis_matrixkit());
     1543       RefSymmSCMatrix h(scf->so_dimension(), scf->basis_matrixkit());
    15381544       pl->symmetrize(hao,h);
    15391545
    15401546       // taken from clscf.cc: CLSCF::scf_energy() (but see also Szabo/Ostlund)
    1541        RefSymmSCMatrix cl_dens_ = wfn->ao_density();
     1547       RefSymmSCMatrix cl_dens_ = scf->ao_density();
    15421548
    15431549       SCFEnergy *eop = new SCFEnergy;
     
    15561562     }
    15571563     {
    1558        RefSymmSCMatrix t = wfn->core_hamiltonian();
    1559        RefSymmSCMatrix cl_dens_ = wfn->ao_density();
     1564       RefSymmSCMatrix t = scf->core_hamiltonian();
     1565       RefSymmSCMatrix cl_dens_ = scf->ao_density();
    15601566
    15611567       SCFEnergy *eop = new SCFEnergy;
     
    15991605       }
    16001606     }
     1607     grad = NULL;
    16011608     {
    16021609       // times obtain from key "mpqc" which should be the first
     
    16131620       if (flops != NULL)
    16141621         data.times.flops = flops[0];
    1615        delete cpu_time;
    1616        delete wall_time;
    1617        delete flops;
     1622       delete[] cpu_time;
     1623       delete[] wall_time;
     1624       delete[] flops;
    16181625     }
    16191626
     
    16311638     }
    16321639     {
     1640       // fill positions and charges
     1641       data.positions.reserve(wfn->molecule()->natom());
     1642       data.charges.reserve(wfn->molecule()->natom());
     1643       for (int iatom=0;iatom < wfn->molecule()->natom(); ++iatom) {
     1644         data.charges.push_back(wfn->molecule()->Z(iatom));
     1645         std::vector<double> pos(3, 0.);
     1646         for (int j=0;j<3;++j)
     1647           pos[j] = wfn->molecule()->r(iatom, j);
     1648         data.positions.push_back(pos);
     1649       }
     1650       std::cout << "We have "
     1651           << data.positions.size() << " positions and "
     1652           << data.charges.size() << " charges." << std::endl;
     1653     }
     1654     {
    16331655       // we now need to sample the density on the grid
    16341656       // 1. get max and min over all basis function positions
    1635        assert( wfn->basis()->ncenter() > 0 );
    1636        SCVector3 min( wfn->basis()->r(0,0), wfn->basis()->r(0,1), wfn->basis()->r(0,2) );
    1637        SCVector3 max( wfn->basis()->r(0,0), wfn->basis()->r(0,1), wfn->basis()->r(0,2) );
    1638        for (int nr = 1; nr< wfn->basis()->ncenter(); ++nr) {
     1657       assert( scf->basis()->ncenter() > 0 );
     1658       SCVector3 bmin( scf->basis()->r(0,0), scf->basis()->r(0,1), scf->basis()->r(0,2) );
     1659       SCVector3 bmax( scf->basis()->r(0,0), scf->basis()->r(0,1), scf->basis()->r(0,2) );
     1660       for (int nr = 1; nr< scf->basis()->ncenter(); ++nr) {
    16391661         for (int i=0; i < 3; ++i) {
    1640            if (wfn->basis()->r(nr,i) < min(i))
    1641              min(i) = wfn->basis()->r(nr,i);
    1642            if (wfn->basis()->r(nr,i) > max(i))
    1643              max(i) = wfn->basis()->r(nr,i);
     1662           if (scf->basis()->r(nr,i) < bmin(i))
     1663             bmin(i) = scf->basis()->r(nr,i);
     1664           if (scf->basis()->r(nr,i) > bmax(i))
     1665             bmax(i) = scf->basis()->r(nr,i);
    16441666         }
    16451667       }
    1646        std::cout << "Min is at " << min << " and max is at " << max << std::endl;
     1668       std::cout << "Basis min is at " << bmin << " and max is at " << bmax << std::endl;
    16471669
    16481670       // 2. choose an appropriately large grid
     
    16531675
    16541676       // for the moment we always generate a grid of full size
    1655        min.x() = data.sampled_grid.begin[0];
    1656        min.y() = data.sampled_grid.begin[1];
    1657        min.z() = data.sampled_grid.begin[2];
    1658        max.x() = min.x() + data.sampled_grid.size;
    1659        max.y() = min.y() + data.sampled_grid.size;
    1660        max.z() = min.z() + data.sampled_grid.size;
     1677       const double AtomicLengthToAngstroem = 0.52917721;
     1678       SCVector3 min;
     1679       SCVector3 max;
     1680       min.x() = data.sampled_grid.begin[0]/AtomicLengthToAngstroem;
     1681       min.y() = data.sampled_grid.begin[1]/AtomicLengthToAngstroem;
     1682       min.z() = data.sampled_grid.begin[2]/AtomicLengthToAngstroem;
     1683       max.x() = min.x() + data.sampled_grid.size/AtomicLengthToAngstroem;
     1684       max.y() = min.y() + data.sampled_grid.size/AtomicLengthToAngstroem;
     1685       max.z() = min.z() + data.sampled_grid.size/AtomicLengthToAngstroem;
    16611686       const int gridpoints = pow(2,data.sampled_grid.level);
    16621687       delta = data.sampled_grid.size / (double) gridpoints;
     
    16681693
    16691694       // 3. sample the atomic density
    1670        int nbasis = wfn->basis()->nbasis();
    1671        double *b_val = new double[nbasis];
    1672        Ref<Integral> intgrl = Integral::get_default_integral();
    1673        GaussianBasisSet::ValueData vdat(wfn->basis(), integral);
    16741695       SCVector3 r;
    16751696       data.sampled_grid.sampled_grid.clear();
    16761697       data.sampled_grid.sampled_grid.reserve(gridpoints*gridpoints*gridpoints);
    1677        for (r.x() = min.x() ; r.x() < max.x(); r.x() += delta)
     1698       for (r.x() = min.x() ; r.x() < max.x(); r.x() += delta) {
     1699         std::cout << "Sampling now for x=" << r.x() << std::endl;
    16781700         for (r.y() = min.y() ; r.y() < max.y(); r.y() += delta)
    16791701           for (r.z() =min.z() ; r.z() < max.z(); r.z() += delta) {
    1680              wfn->basis()->values(r, &vdat, b_val);
    1681              double sum = 0.;
    1682              for (int i=0; i<nbasis; i++)
    1683                sum += wfn->ao_density()->get_element(i,i)*b_val[i];
    1684              data.sampled_grid.sampled_grid.push_back(sum);
     1702             // only evaluate if we close the basis functions
     1703             if (((r.x() < bmin.x()-boundary) || (r.x() > bmax.x()+boundary))
     1704               || ((r.y() < bmin.y()-boundary) || (r.y() > bmax.y()+boundary))
     1705               || ((r.z() < bmin.z()-boundary) || (r.z() > bmax.y()+boundary))) {
     1706               data.sampled_grid.sampled_grid.push_back(0.);
     1707             } else {
     1708               const double dens_at_r = scf->density(r);
     1709//               if (fabs(dens_at_r) > 1e-4)
     1710//                 std::cout << "Electron density at " << r << " is " << dens_at_r << std::endl;
     1711               data.sampled_grid.sampled_grid.push_back(dens_at_r);
     1712             }
    16851713           }
     1714       }
     1715       assert( data.sampled_grid.size() == gridpoints*gridpoints*gridpoints);
    16861716     }
     1717     scf = 0;
    16871718
    16881719//     // GaussianShell is the actual orbital functions it seems ...
Note: See TracChangeset for help on using the changeset viewer.