修订版 | 2399ddd2c6b7ad2146b79dff9f29b1e9830a95f9 (tree) |
---|---|
时间 | 2013-02-03 16:10:49 |
作者 | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Refactoring of Cndo2::CalcElectronicTransitionDipoleMoment to speed up. #30670
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1280 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -1676,42 +1676,27 @@ void Cndo2::CalcElectronicTransitionDipoleMoment(double* transitionDipoleMoment, | ||
1676 | 1676 | double const* groundStateDipole) const{ |
1677 | 1677 | int groundState = 0; |
1678 | 1678 | if(from == groundState && to == groundState){ |
1679 | - double valueX=0.0; | |
1680 | - double valueY=0.0; | |
1681 | - double valueZ=0.0; | |
1682 | - double const* xyzCOC = molecule.GetXyzCOC(); | |
1679 | + double const* centerOfDipole = molecule.GetXyzCOC(); | |
1683 | 1680 | int totalAONumber = molecule.GetTotalNumberAOs(); |
1684 | - stringstream ompErrors; | |
1685 | -#pragma omp parallel for reduction(+:valueX,valueY,valueZ) schedule(auto) | |
1686 | - for(int mu=0; mu<totalAONumber; mu++){ | |
1687 | - try{ | |
1688 | - double threadValueX = 0.0; | |
1689 | - double threadValueY = 0.0; | |
1690 | - double threadValueZ = 0.0; | |
1691 | - for(int nu=0; nu<totalAONumber; nu++){ | |
1692 | - threadValueX -= orbitalElectronPopulation[mu][nu] | |
1693 | - *(cartesianMatrix[XAxis][mu][nu]-xyzCOC[XAxis]*overlapAOs[mu][nu]); | |
1694 | - threadValueY -= orbitalElectronPopulation[mu][nu] | |
1695 | - *(cartesianMatrix[YAxis][mu][nu]-xyzCOC[YAxis]*overlapAOs[mu][nu]); | |
1696 | - threadValueZ -= orbitalElectronPopulation[mu][nu] | |
1697 | - *(cartesianMatrix[ZAxis][mu][nu]-xyzCOC[ZAxis]*overlapAOs[mu][nu]); | |
1698 | - } | |
1699 | - valueX += threadValueX; | |
1700 | - valueY += threadValueY; | |
1701 | - valueZ += threadValueZ; | |
1702 | - } | |
1703 | - catch(MolDSException ex){ | |
1704 | -#pragma omp critical | |
1705 | - ompErrors << ex.what() << endl ; | |
1706 | - } | |
1707 | - } | |
1708 | - // Exception throwing for omp-region | |
1709 | - if(!ompErrors.str().empty()){ | |
1710 | - throw MolDSException(ompErrors.str()); | |
1711 | - } | |
1712 | - transitionDipoleMoment[XAxis] = valueX; | |
1713 | - transitionDipoleMoment[YAxis] = valueY; | |
1714 | - transitionDipoleMoment[ZAxis] = valueZ; | |
1681 | + transitionDipoleMoment[XAxis] = 0.0; | |
1682 | + transitionDipoleMoment[YAxis] = 0.0; | |
1683 | + transitionDipoleMoment[ZAxis] = 0.0; | |
1684 | + transitionDipoleMoment[XAxis] -= MolDS_wrappers::Blas::GetInstance()->Ddot(totalAONumber*totalAONumber, | |
1685 | + &orbitalElectronPopulation[0][0], | |
1686 | + &cartesianMatrix[XAxis][0][0]); | |
1687 | + transitionDipoleMoment[YAxis] -= MolDS_wrappers::Blas::GetInstance()->Ddot(totalAONumber*totalAONumber, | |
1688 | + &orbitalElectronPopulation[0][0], | |
1689 | + &cartesianMatrix[YAxis][0][0]); | |
1690 | + transitionDipoleMoment[ZAxis] -= MolDS_wrappers::Blas::GetInstance()->Ddot(totalAONumber*totalAONumber, | |
1691 | + &orbitalElectronPopulation[0][0], | |
1692 | + &cartesianMatrix[ZAxis][0][0]); | |
1693 | + // set orign of dipole | |
1694 | + double temp = MolDS_wrappers::Blas::GetInstance()->Ddot(totalAONumber*totalAONumber, | |
1695 | + &orbitalElectronPopulation[0][0], | |
1696 | + &overlapAOs[0][0]); | |
1697 | + transitionDipoleMoment[XAxis] += centerOfDipole[XAxis]*temp; | |
1698 | + transitionDipoleMoment[YAxis] += centerOfDipole[YAxis]*temp; | |
1699 | + transitionDipoleMoment[ZAxis] += centerOfDipole[ZAxis]*temp; | |
1715 | 1700 | } |
1716 | 1701 | else{ |
1717 | 1702 | stringstream ss; |