Changeset 1ed5fc for src/bin/mpqc/mpqc.cc
- Timestamp:
- Aug 1, 2012, 4:19:45 PM (13 years ago)
- Children:
- d901f7
- Parents:
- 5ce17f
- File:
-
- 1 edited
-
src/bin/mpqc/mpqc.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/bin/mpqc/mpqc.cc
r5ce17f r1ed5fc 139 139 #include "Jobs/MPQCJob.hpp" 140 140 #include "Jobs/MPQCData.hpp" 141 142 #include <chemistry/qc/basis/obint.h> 143 #include <chemistry/qc/basis/symmint.h> 141 144 #endif 142 145 … … 1480 1483 data.energies.total = mole->energy(); 1481 1484 data.energies.nuclear_repulsion = wfn->nuclear_repulsion_energy(); 1482 // data.energies.electron_repulsion = integral->electron_repulsion();1483 // data.energies.correlation = wfn->corr_energy();1484 // taken from clscf.cc: CLSCF::scf_energy() (but see also Szabo/Ostlund)1485 1485 { 1486 CLHF *clhf = dynamic_cast<CLHF*>(wfn.pointer()); 1487 if (clhf != NULL) { 1488 double ex, ec; 1489 clhf->two_body_energy(ec, ex); 1490 data.energies.electron_coulomb = ec; 1491 data.energies.electron_exchange = ex; 1492 clhf = NULL; 1493 } else { 1494 ExEnv::out0() << "INFO: There is no CLHF information available." << endl; 1495 data.energies.electron_coulomb = 0.; 1496 data.energies.electron_exchange = 0.; 1497 } 1498 } 1499 { 1500 MBPT2 *mbpt2 = dynamic_cast<MBPT2*>(wfn.pointer()); 1501 if (mbpt2 != NULL) { 1502 data.energies.correlation = mbpt2->corr_energy(); 1503 mbpt2 = 0; 1504 } else { 1505 ExEnv::out0() << "INFO: There is no MBPT2 information available." << endl; 1506 data.energies.correlation = 0.; 1507 } 1508 } 1509 { 1510 // taken from clscf.cc: CLSCF::scf_energy() (but see also Szabo/Ostlund) 1486 1511 RefSymmSCMatrix t = wfn->overlap(); 1487 1512 RefSymmSCMatrix cl_dens_ = wfn->ao_density(); … … 1500 1525 cl_dens_ = 0; 1501 1526 } 1502 // data.energies.kinetic = integral->kinetic(); 1527 { 1528 // taken from Wavefunction::core_hamiltonian() 1529 RefSymmSCMatrix hao(wfn->basis()->basisdim(), wfn->basis()->matrixkit()); 1530 hao.assign(0.0); 1531 Ref<PetiteList> pl = wfn->integral()->petite_list(); 1532 Ref<SCElementOp> hc = 1533 new OneBodyIntOp(new SymmOneBodyIntIter(wfn->integral()->kinetic(), pl)); 1534 hao.element_op(hc); 1535 hc=0; 1536 1537 RefSymmSCMatrix h(wfn->so_dimension(), wfn->basis_matrixkit()); 1538 pl->symmetrize(hao,h); 1539 1540 // taken from clscf.cc: CLSCF::scf_energy() (but see also Szabo/Ostlund) 1541 RefSymmSCMatrix cl_dens_ = wfn->ao_density(); 1542 1543 SCFEnergy *eop = new SCFEnergy; 1544 eop->reference(); 1545 Ref<SCElementOp2> op = eop; 1546 h.element_op(op,cl_dens_); 1547 op=0; 1548 eop->dereference(); 1549 1550 data.energies.kinetic = eop->result(); 1551 1552 delete eop; 1553 hao = 0; 1554 h = 0; 1555 cl_dens_ = 0; 1556 } 1503 1557 { 1504 1558 RefSymmSCMatrix t = wfn->core_hamiltonian(); … … 1545 1599 } 1546 1600 } 1547 // times 1548 data.times.walltime = tim->get_wall_time(); 1549 data.times.cputime = tim->get_cpu_time(); 1550 data.times.flops = tim->get_flops(); 1551 1552 // eigenvalues (this only works if we have a OneBodyWavefunction, i.e. SCF procedure) 1553 SCF *scf = require_dynamic_cast<SCF*>(wfn, "mainFunction"); 1554 RefDiagSCMatrix evals = scf->eigenvalues(); 1555 1556 for(int i=0;i<wfn->oso_dimension(); ++i) { 1557 data.energies.eigenvalues.push_back(evals(i)); 1558 std::cout << i << "th eigenvalue is " << evals(i) << std::endl; 1601 { 1602 // times obtain from key "mpqc" which should be the first 1603 double *cpu_time = new double[tim->nregion()]; 1604 double *wall_time = new double[tim->nregion()]; 1605 double *flops = new double[tim->nregion()]; 1606 tim->get_cpu_times(cpu_time); 1607 tim->get_wall_times(wall_time); 1608 tim->get_flops(flops); 1609 if (cpu_time != NULL) 1610 data.times.cputime = cpu_time[0]; 1611 if (wall_time != NULL) 1612 data.times.walltime = wall_time[0]; 1613 if (flops != NULL) 1614 data.times.flops = flops[0]; 1615 delete cpu_time; 1616 delete wall_time; 1617 delete flops; 1559 1618 } 1560 1619 1561 // we now need to sample the density on the grid 1562 // 1. get max and min over all basis function positions 1563 assert( wfn->basis()->ncenter() > 0 ); 1564 SCVector3 min( wfn->basis()->r(0,0), wfn->basis()->r(0,1), wfn->basis()->r(0,2) ); 1565 SCVector3 max( wfn->basis()->r(0,0), wfn->basis()->r(0,1), wfn->basis()->r(0,2) ); 1566 for (int nr = 1; nr< wfn->basis()->ncenter(); ++nr) { 1567 for (int i=0; i < 3; ++i) { 1568 if (wfn->basis()->r(nr,i) < min(i)) 1569 min(i) = wfn->basis()->r(nr,i); 1570 if (wfn->basis()->r(nr,i) > max(i)) 1571 max(i) = wfn->basis()->r(nr,i); 1620 { 1621 // eigenvalues (this only works if we have a OneBodyWavefunction, i.e. SCF procedure) 1622 SCF *scf = dynamic_cast<SCF*>(wfn.pointer()); 1623 if (scf != NULL) { 1624 RefDiagSCMatrix evals = scf->eigenvalues(); 1625 1626 for(int i=0;i<wfn->oso_dimension(); ++i) { 1627 data.energies.eigenvalues.push_back(evals(i)); 1628 //std::cout << i << "th eigenvalue is " << evals(i) << std::endl; 1629 } 1572 1630 } 1573 1631 } 1574 std::cout << "Min is at " << min << " and max is at " << max << std::endl; 1575 1576 // 2. choose an appropriately large grid 1577 // we have to pay attention to capture the right amount of the exponential decay 1578 // and also to have a power of two size of the grid at best 1579 double boundary = 5.; // boundary extent around compact domain containing basis functions 1580 double delta = 1.; // step width in density sampling 1581 1582 // for the moment we always generate a grid of full size 1583 min.x() = data.sampled_grid.begin[0]; 1584 min.y() = data.sampled_grid.begin[1]; 1585 min.z() = data.sampled_grid.begin[2]; 1586 max.x() = min.x() + data.sampled_grid.size; 1587 max.y() = min.y() + data.sampled_grid.size; 1588 max.z() = min.z() + data.sampled_grid.size; 1589 const int gridpoints = pow(2,data.sampled_grid.level); 1590 delta = data.sampled_grid.size / (double) gridpoints; 1591 std::cout << "Grid starts at " << min 1592 << " and ends at " << max 1593 << " with a delta of " << delta 1594 << " to get " << gridpoints << " gridpoints." 1595 << std::endl; 1596 1597 // 3. sample the atomic density 1598 int nbasis = wfn->basis()->nbasis(); 1599 double *b_val = new double[nbasis]; 1600 Ref<Integral> intgrl = Integral::get_default_integral(); 1601 GaussianBasisSet::ValueData vdat(wfn->basis(), integral); 1602 SCVector3 r; 1603 data.sampled_grid.sampled_grid.clear(); 1604 data.sampled_grid.sampled_grid.reserve(gridpoints*gridpoints*gridpoints); 1605 for (r.x() = min.x() ; r.x() < max.x(); r.x() += delta) 1606 for (r.y() = min.y() ; r.y() < max.y(); r.y() += delta) 1607 for (r.z() =min.z() ; r.z() < max.z(); r.z() += delta) { 1608 wfn->basis()->values(r, &vdat, b_val); 1609 double sum = 0.; 1610 for (int i=0; i<nbasis; i++) 1611 sum += wfn->ao_density()->get_element(i,i)*b_val[i]; 1612 data.sampled_grid.sampled_grid.push_back(sum); 1632 { 1633 // we now need to sample the density on the grid 1634 // 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) { 1639 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); 1613 1644 } 1645 } 1646 std::cout << "Min is at " << min << " and max is at " << max << std::endl; 1647 1648 // 2. choose an appropriately large grid 1649 // we have to pay attention to capture the right amount of the exponential decay 1650 // and also to have a power of two size of the grid at best 1651 double boundary = 5.; // boundary extent around compact domain containing basis functions 1652 double delta = 1.; // step width in density sampling 1653 1654 // 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; 1661 const int gridpoints = pow(2,data.sampled_grid.level); 1662 delta = data.sampled_grid.size / (double) gridpoints; 1663 std::cout << "Grid starts at " << min 1664 << " and ends at " << max 1665 << " with a delta of " << delta 1666 << " to get " << gridpoints << " gridpoints." 1667 << std::endl; 1668 1669 // 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 SCVector3 r; 1675 data.sampled_grid.sampled_grid.clear(); 1676 data.sampled_grid.sampled_grid.reserve(gridpoints*gridpoints*gridpoints); 1677 for (r.x() = min.x() ; r.x() < max.x(); r.x() += delta) 1678 for (r.y() = min.y() ; r.y() < max.y(); r.y() += delta) 1679 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); 1685 } 1686 } 1614 1687 1615 1688 // // GaussianShell is the actual orbital functions it seems ...
Note:
See TracChangeset
for help on using the changeset viewer.
