Changeset d901f7
- Timestamp:
- Aug 9, 2012, 8:20:56 AM (13 years ago)
- Children:
- 4dfef04
- Parents:
- 1ed5fc
- File:
-
- 1 edited
-
src/bin/mpqc/mpqc.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/bin/mpqc/mpqc.cc
r1ed5fc rd901f7 1497 1497 } 1498 1498 } 1499 SCF *scf = NULL; 1499 1500 { 1500 1501 MBPT2 *mbpt2 = dynamic_cast<MBPT2*>(wfn.pointer()); 1501 1502 if (mbpt2 != NULL) { 1502 1503 data.energies.correlation = mbpt2->corr_energy(); 1504 scf = mbpt2->ref().pointer(); 1503 1505 mbpt2 = 0; 1504 1506 } else { 1505 1507 ExEnv::out0() << "INFO: There is no MBPT2 information available." << endl; 1506 1508 data.energies.correlation = 0.; 1509 scf = dynamic_cast<SCF*>(wfn.pointer()); 1510 if (scf == NULL) 1511 abort(); 1507 1512 } 1508 1513 } 1509 1514 { 1510 1515 // 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(); 1513 1519 1514 1520 SCFEnergy *eop = new SCFEnergy; … … 1527 1533 { 1528 1534 // taken from Wavefunction::core_hamiltonian() 1529 RefSymmSCMatrix hao( wfn->basis()->basisdim(), wfn->basis()->matrixkit());1535 RefSymmSCMatrix hao(scf->basis()->basisdim(), scf->basis()->matrixkit()); 1530 1536 hao.assign(0.0); 1531 Ref<PetiteList> pl = wfn->integral()->petite_list();1537 Ref<PetiteList> pl = scf->integral()->petite_list(); 1532 1538 Ref<SCElementOp> hc = 1533 new OneBodyIntOp(new SymmOneBodyIntIter( wfn->integral()->kinetic(), pl));1539 new OneBodyIntOp(new SymmOneBodyIntIter(scf->integral()->kinetic(), pl)); 1534 1540 hao.element_op(hc); 1535 1541 hc=0; 1536 1542 1537 RefSymmSCMatrix h( wfn->so_dimension(), wfn->basis_matrixkit());1543 RefSymmSCMatrix h(scf->so_dimension(), scf->basis_matrixkit()); 1538 1544 pl->symmetrize(hao,h); 1539 1545 1540 1546 // 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(); 1542 1548 1543 1549 SCFEnergy *eop = new SCFEnergy; … … 1556 1562 } 1557 1563 { 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(); 1560 1566 1561 1567 SCFEnergy *eop = new SCFEnergy; … … 1599 1605 } 1600 1606 } 1607 grad = NULL; 1601 1608 { 1602 1609 // times obtain from key "mpqc" which should be the first … … 1613 1620 if (flops != NULL) 1614 1621 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; 1618 1625 } 1619 1626 … … 1631 1638 } 1632 1639 { 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 { 1633 1655 // we now need to sample the density on the grid 1634 1656 // 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) { 1639 1661 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); 1644 1666 } 1645 1667 } 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; 1647 1669 1648 1670 // 2. choose an appropriately large grid … … 1653 1675 1654 1676 // 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; 1661 1686 const int gridpoints = pow(2,data.sampled_grid.level); 1662 1687 delta = data.sampled_grid.size / (double) gridpoints; … … 1668 1693 1669 1694 // 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);1674 1695 SCVector3 r; 1675 1696 data.sampled_grid.sampled_grid.clear(); 1676 1697 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; 1678 1700 for (r.y() = min.y() ; r.y() < max.y(); r.y() += delta) 1679 1701 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 } 1685 1713 } 1714 } 1715 assert( data.sampled_grid.size() == gridpoints*gridpoints*gridpoints); 1686 1716 } 1717 scf = 0; 1687 1718 1688 1719 // // GaussianShell is the actual orbital functions it seems ...
Note:
See TracChangeset
for help on using the changeset viewer.
