Revision | b939902d293d262e2de4a8ee0bd726eabe5d21ce (tree) |
---|---|
Zeit | 2012-11-16 18:03:52 |
Autor | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
Parallelization of calculation of the dipole moment of the ground state is modified to be more efficient for many core machines. #30111
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1119 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -1660,30 +1660,18 @@ void Cndo2::CalcElectronicDipoleMomentGroundState(double*** electronicTransition | ||
1660 | 1660 | double const* const* orbitalElectronPopulation, |
1661 | 1661 | double const* const* overlapAOs) const{ |
1662 | 1662 | int groundState = 0; |
1663 | - stringstream ompErrors; | |
1664 | -#pragma omp parallel for schedule(auto) | |
1665 | 1663 | for(int axis=0; axis<CartesianType_end; axis++){ |
1666 | - try{ | |
1667 | - electronicTransitionDipoleMoments[groundState][groundState][axis] = this->GetElectronicTransitionDipoleMoment( | |
1668 | - groundState, | |
1669 | - groundState, | |
1670 | - static_cast<CartesianType>(axis), | |
1671 | - NULL, | |
1672 | - NULL, | |
1673 | - cartesianMatrix, | |
1674 | - molecule, | |
1675 | - orbitalElectronPopulation, | |
1676 | - overlapAOs, | |
1677 | - NULL); | |
1678 | - } | |
1679 | - catch(MolDSException ex){ | |
1680 | -#pragma omp critical | |
1681 | - ompErrors << ex.what() << endl ; | |
1682 | - } | |
1683 | - } | |
1684 | - // Exception throwing for omp-region | |
1685 | - if(!ompErrors.str().empty()){ | |
1686 | - throw MolDSException(ompErrors.str()); | |
1664 | + electronicTransitionDipoleMoments[groundState][groundState][axis] = this->GetElectronicTransitionDipoleMoment( | |
1665 | + groundState, | |
1666 | + groundState, | |
1667 | + static_cast<CartesianType>(axis), | |
1668 | + NULL, | |
1669 | + NULL, | |
1670 | + cartesianMatrix, | |
1671 | + molecule, | |
1672 | + orbitalElectronPopulation, | |
1673 | + overlapAOs, | |
1674 | + NULL); | |
1687 | 1675 | } |
1688 | 1676 | } |
1689 | 1677 |
@@ -1695,16 +1683,31 @@ double Cndo2::GetElectronicTransitionDipoleMoment(int to, int from, CartesianTyp | ||
1695 | 1683 | double const* const* orbitalElectronPopulation, |
1696 | 1684 | double const* const* overlapAOs, |
1697 | 1685 | double const* groundStateDipole) const{ |
1698 | - double value = 0.0; | |
1699 | 1686 | int groundState = 0; |
1700 | 1687 | if(from == groundState && to == groundState){ |
1688 | + double value = 0.0; | |
1701 | 1689 | int totalAONumber = molecule.GetTotalNumberAOs(); |
1690 | + stringstream ompErrors; | |
1691 | +#pragma omp parallel for reduction(+:value) schedule(auto) | |
1702 | 1692 | for(int mu=0; mu<totalAONumber; mu++){ |
1703 | - for(int nu=0; nu<totalAONumber; nu++){ | |
1704 | - value -= orbitalElectronPopulation[mu][nu] | |
1705 | - *(cartesianMatrix[mu][nu][axis]-molecule.GetXyzCOC()[axis]*overlapAOs[mu][nu]); | |
1693 | + try{ | |
1694 | + double threadValue = 0.0; | |
1695 | + for(int nu=0; nu<totalAONumber; nu++){ | |
1696 | + threadValue -= orbitalElectronPopulation[mu][nu] | |
1697 | + *(cartesianMatrix[mu][nu][axis]-molecule.GetXyzCOC()[axis]*overlapAOs[mu][nu]); | |
1698 | + } | |
1699 | + value += threadValue; | |
1700 | + } | |
1701 | + catch(MolDSException ex){ | |
1702 | +#pragma omp critical | |
1703 | + ompErrors << ex.what() << endl ; | |
1706 | 1704 | } |
1707 | 1705 | } |
1706 | + // Exception throwing for omp-region | |
1707 | + if(!ompErrors.str().empty()){ | |
1708 | + throw MolDSException(ompErrors.str()); | |
1709 | + } | |
1710 | + return value; | |
1708 | 1711 | } |
1709 | 1712 | else{ |
1710 | 1713 | stringstream ss; |
@@ -1714,7 +1717,6 @@ double Cndo2::GetElectronicTransitionDipoleMoment(int to, int from, CartesianTyp | ||
1714 | 1717 | ss << this->errorMessageCartesianType << CartesianTypeStr(axis) << endl; |
1715 | 1718 | throw MolDSException(ss.str()); |
1716 | 1719 | } |
1717 | - return value; | |
1718 | 1720 | } |
1719 | 1721 | |
1720 | 1722 | // calculate Cartesian matrix between atomic orbitals. |