修订版 | a567ddc69fc1b93cdbf2e8a7d2b6dd5486ee72fb (tree) |
---|---|
时间 | 2013-05-20 23:55:41 |
作者 | Mikiya Fujii <mikiya.fujii@gmai...> |
Commiter | Mikiya Fujii |
refactoring CalcForce in ZindoS and Mndo. #31221
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1339 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -2285,120 +2285,117 @@ void Mndo::CalcForce(const vector<int>& elecStates){ | ||
2285 | 2285 | int firstAOIndexA = atomA.GetFirstAOIndex(); |
2286 | 2286 | int lastAOIndexA = atomA.GetLastAOIndex(); |
2287 | 2287 | for(int b=0; b<this->molecule->GetNumberAtoms(); b++){ |
2288 | - if(a != b){ | |
2289 | - const Atom& atomB = *molecule->GetAtom(b); | |
2290 | - int firstAOIndexB = atomB.GetFirstAOIndex(); | |
2291 | - int lastAOIndexB = atomB.GetLastAOIndex(); | |
2292 | - | |
2293 | - // calc. first derivative of overlapAOs. | |
2294 | - this->CalcDiatomicOverlapAOs1stDerivatives(diatomicOverlapAOs1stDerivs, atomA, atomB); | |
2295 | - // calc. first derivative of two elec two core interaction | |
2296 | - this->CalcDiatomicTwoElecTwoCore1stDerivatives(diatomicTwoElecTwoCore1stDerivs, a, b); | |
2297 | - | |
2298 | - // core repulsion part | |
2299 | - double coreRepulsion[CartesianType_end] = {0.0,0.0,0.0}; | |
2300 | - for(int i=0; i<CartesianType_end; i++){ | |
2301 | - coreRepulsion[i] += this->GetDiatomCoreRepulsion1stDerivative( | |
2288 | + if(a == b){continue;} | |
2289 | + const Atom& atomB = *molecule->GetAtom(b); | |
2290 | + int firstAOIndexB = atomB.GetFirstAOIndex(); | |
2291 | + int lastAOIndexB = atomB.GetLastAOIndex(); | |
2292 | + | |
2293 | + // calc. first derivative of overlapAOs. | |
2294 | + this->CalcDiatomicOverlapAOs1stDerivatives(diatomicOverlapAOs1stDerivs, atomA, atomB); | |
2295 | + // calc. first derivative of two elec two core interaction | |
2296 | + this->CalcDiatomicTwoElecTwoCore1stDerivatives(diatomicTwoElecTwoCore1stDerivs, a, b); | |
2297 | + | |
2298 | + // core repulsion part | |
2299 | + double coreRepulsion[CartesianType_end] = {0.0,0.0,0.0}; | |
2300 | + for(int i=0; i<CartesianType_end; i++){ | |
2301 | + coreRepulsion[i] += this->GetDiatomCoreRepulsion1stDerivative( | |
2302 | + a, b, (CartesianType)i); | |
2303 | + if(Parameters::GetInstance()->RequiresVdWSCF()){ | |
2304 | + coreRepulsion[i] += this->GetDiatomVdWCorrection1stDerivative( | |
2302 | 2305 | a, b, (CartesianType)i); |
2303 | - if(Parameters::GetInstance()->RequiresVdWSCF()){ | |
2304 | - coreRepulsion[i] += this->GetDiatomVdWCorrection1stDerivative( | |
2305 | - a, b, (CartesianType)i); | |
2306 | - } | |
2307 | - } | |
2308 | - // electron core attraction part (ground state) | |
2309 | - double forceElecCoreAttPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2310 | - this->CalcForceSCFElecCoreAttractionPart(forceElecCoreAttPart, | |
2311 | - a, | |
2312 | - b, | |
2313 | - diatomicTwoElecTwoCore1stDerivs); | |
2314 | - // overlapAOs part (ground state) | |
2315 | - double forceOverlapAOsPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2316 | - this->CalcForceSCFOverlapAOsPart(forceOverlapAOsPart, | |
2317 | - a, | |
2318 | - b, | |
2319 | - diatomicOverlapAOs1stDerivs); | |
2320 | - // two electron part (ground state) | |
2321 | - double forceTwoElecPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2322 | - this->CalcForceSCFTwoElecPart(forceTwoElecPart, | |
2306 | + } | |
2307 | + } | |
2308 | + // electron core attraction part (ground state) | |
2309 | + double forceElecCoreAttPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2310 | + this->CalcForceSCFElecCoreAttractionPart(forceElecCoreAttPart, | |
2311 | + a, | |
2312 | + b, | |
2313 | + diatomicTwoElecTwoCore1stDerivs); | |
2314 | + // overlapAOs part (ground state) | |
2315 | + double forceOverlapAOsPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2316 | + this->CalcForceSCFOverlapAOsPart(forceOverlapAOsPart, | |
2323 | 2317 | a, |
2324 | 2318 | b, |
2325 | - diatomicTwoElecTwoCore1stDerivs); | |
2326 | - // sum up contributions from each part (ground state) | |
2319 | + diatomicOverlapAOs1stDerivs); | |
2320 | + // two electron part (ground state) | |
2321 | + double forceTwoElecPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2322 | + this->CalcForceSCFTwoElecPart(forceTwoElecPart, | |
2323 | + a, | |
2324 | + b, | |
2325 | + diatomicTwoElecTwoCore1stDerivs); | |
2326 | + // sum up contributions from each part (ground state) | |
2327 | 2327 | #pragma omp critical |
2328 | - { | |
2329 | - for(int n=0; n<elecStates.size(); n++){ | |
2330 | - for(int i=0; i<CartesianType_end; i++){ | |
2331 | - this->matrixForce[n][a][i] -= coreRepulsion[i]; | |
2332 | - this->matrixForce[n][a][i] += forceElecCoreAttPart[i]; | |
2333 | - this->matrixForce[n][a][i] += forceOverlapAOsPart[i]; | |
2334 | - this->matrixForce[n][a][i] += forceTwoElecPart[i]; | |
2335 | - this->matrixForce[n][b][i] -= forceElecCoreAttPart[i]; | |
2336 | - this->matrixForce[n][b][i] -= forceOverlapAOsPart[i]; | |
2337 | - this->matrixForce[n][b][i] -= forceTwoElecPart[i]; | |
2338 | - } | |
2328 | + { | |
2329 | + for(int n=0; n<elecStates.size(); n++){ | |
2330 | + for(int i=0; i<CartesianType_end; i++){ | |
2331 | + this->matrixForce[n][a][i] -= coreRepulsion[i]; | |
2332 | + this->matrixForce[n][a][i] += forceElecCoreAttPart[i]; | |
2333 | + this->matrixForce[n][a][i] += forceOverlapAOsPart[i]; | |
2334 | + this->matrixForce[n][a][i] += forceTwoElecPart[i]; | |
2335 | + this->matrixForce[n][b][i] -= forceElecCoreAttPart[i]; | |
2336 | + this->matrixForce[n][b][i] -= forceOverlapAOsPart[i]; | |
2337 | + this->matrixForce[n][b][i] -= forceTwoElecPart[i]; | |
2339 | 2338 | } |
2340 | 2339 | } |
2341 | - // excited state potential | |
2342 | - for(int n=0; n<elecStates.size(); n++){ | |
2343 | - if(0<elecStates[n]){ | |
2344 | - // static part | |
2345 | - double forceExcitedStaticPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2346 | - this->CalcForceExcitedStaticPart(forceExcitedStaticPart, | |
2347 | - n, | |
2348 | - a, | |
2349 | - b, | |
2350 | - diatomicTwoElecTwoCore1stDerivs); | |
2351 | - // sum up contributions from static part (excited state) | |
2352 | -#pragma omp critical | |
2353 | - { | |
2354 | - for(int i=0; i<CartesianType_end; i++){ | |
2355 | - this->matrixForce[n][b][i] += forceExcitedStaticPart[i]; | |
2356 | - this->matrixForce[n][a][i] -= forceExcitedStaticPart[i]; | |
2357 | - } | |
2358 | - } | |
2359 | - | |
2360 | - // response part | |
2361 | - // electron core attraction part (excited state) | |
2362 | - double forceExcitedElecCoreAttPart[CartesianType_end]={0.0,0.0,0.0}; | |
2363 | - this->CalcForceExcitedElecCoreAttractionPart( | |
2364 | - forceExcitedElecCoreAttPart, | |
2340 | + } | |
2341 | + // excited state force | |
2342 | + for(int n=0; n<elecStates.size(); n++){ | |
2343 | + if(elecStates[n]<=0){continue;} | |
2344 | + // static part | |
2345 | + double forceExcitedStaticPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2346 | + this->CalcForceExcitedStaticPart(forceExcitedStaticPart, | |
2365 | 2347 | n, |
2366 | 2348 | a, |
2367 | 2349 | b, |
2368 | 2350 | diatomicTwoElecTwoCore1stDerivs); |
2369 | - // overlapAOs part (excited state) | |
2370 | - double forceExcitedOverlapAOsPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2371 | - this->CalcForceExcitedOverlapAOsPart(forceExcitedOverlapAOsPart, | |
2372 | - n, | |
2373 | - a, | |
2374 | - b, | |
2375 | - diatomicOverlapAOs1stDerivs); | |
2376 | - // two electron part (ground state) | |
2377 | - double forceExcitedTwoElecPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2378 | - this->CalcForceExcitedTwoElecPart(forceExcitedTwoElecPart, | |
2379 | - n, | |
2380 | - a, | |
2381 | - b, | |
2382 | - diatomicTwoElecTwoCore1stDerivs); | |
2383 | - // sum up contributions from response part (excited state) | |
2351 | + // sum up contributions from static part (excited state) | |
2384 | 2352 | #pragma omp critical |
2385 | - { | |
2386 | - for(int i=0; i<CartesianType_end; i++){ | |
2387 | - this->matrixForce[n][a][i] += forceExcitedElecCoreAttPart[i]; | |
2388 | - this->matrixForce[n][a][i] += forceExcitedOverlapAOsPart[i]; | |
2389 | - this->matrixForce[n][a][i] += forceExcitedTwoElecPart[i]; | |
2390 | - this->matrixForce[n][b][i] -= forceExcitedElecCoreAttPart[i]; | |
2391 | - this->matrixForce[n][b][i] -= forceExcitedOverlapAOsPart[i]; | |
2392 | - this->matrixForce[n][b][i] -= forceExcitedTwoElecPart[i]; | |
2393 | - } | |
2394 | - } | |
2353 | + { | |
2354 | + for(int i=0; i<CartesianType_end; i++){ | |
2355 | + this->matrixForce[n][b][i] += forceExcitedStaticPart[i]; | |
2356 | + this->matrixForce[n][a][i] -= forceExcitedStaticPart[i]; | |
2357 | + } | |
2358 | + } | |
2395 | 2359 | |
2360 | + // response part | |
2361 | + // electron core attraction part (excited state) | |
2362 | + double forceExcitedElecCoreAttPart[CartesianType_end]={0.0,0.0,0.0}; | |
2363 | + this->CalcForceExcitedElecCoreAttractionPart( | |
2364 | + forceExcitedElecCoreAttPart, | |
2365 | + n, | |
2366 | + a, | |
2367 | + b, | |
2368 | + diatomicTwoElecTwoCore1stDerivs); | |
2369 | + // overlapAOs part (excited state) | |
2370 | + double forceExcitedOverlapAOsPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2371 | + this->CalcForceExcitedOverlapAOsPart(forceExcitedOverlapAOsPart, | |
2372 | + n, | |
2373 | + a, | |
2374 | + b, | |
2375 | + diatomicOverlapAOs1stDerivs); | |
2376 | + // two electron part (ground state) | |
2377 | + double forceExcitedTwoElecPart[CartesianType_end] = {0.0,0.0,0.0}; | |
2378 | + this->CalcForceExcitedTwoElecPart(forceExcitedTwoElecPart, | |
2379 | + n, | |
2380 | + a, | |
2381 | + b, | |
2382 | + diatomicTwoElecTwoCore1stDerivs); | |
2383 | + // sum up contributions from response part (excited state) | |
2384 | +#pragma omp critical | |
2385 | + { | |
2386 | + for(int i=0; i<CartesianType_end; i++){ | |
2387 | + this->matrixForce[n][a][i] += forceExcitedElecCoreAttPart[i]; | |
2388 | + this->matrixForce[n][a][i] += forceExcitedOverlapAOsPart[i]; | |
2389 | + this->matrixForce[n][a][i] += forceExcitedTwoElecPart[i]; | |
2390 | + this->matrixForce[n][b][i] -= forceExcitedElecCoreAttPart[i]; | |
2391 | + this->matrixForce[n][b][i] -= forceExcitedOverlapAOsPart[i]; | |
2392 | + this->matrixForce[n][b][i] -= forceExcitedTwoElecPart[i]; | |
2396 | 2393 | } |
2397 | 2394 | } |
2398 | - } | |
2399 | - } | |
2400 | - } | |
2401 | - } | |
2395 | + } // end of excited state force | |
2396 | + } // end of for(int b) | |
2397 | + } // end of for(int a) | |
2398 | + } // end of try | |
2402 | 2399 | catch(MolDSException ex){ |
2403 | 2400 | #pragma omp critical |
2404 | 2401 | ompErrors << ex.what() << endl ; |
@@ -3850,62 +3850,63 @@ void ZindoS::CalcForce(const vector<int>& elecStates){ | ||
3850 | 3850 | double electronicForce2[CartesianType_end] = {0.0,0.0,0.0}; |
3851 | 3851 | double electronicForce3[CartesianType_end] = {0.0,0.0,0.0}; |
3852 | 3852 | for(int b=0; b<this->molecule->GetNumberAtoms(); b++){ |
3853 | - if(a != b){ | |
3854 | - const Atom& atomB = *molecule->GetAtom(b); | |
3855 | - int firstAOIndexB = atomB.GetFirstAOIndex(); | |
3856 | - int lastAOIndexB = atomB.GetLastAOIndex(); | |
3857 | - double rAB = this->molecule->GetDistanceAtoms(atomA, atomB); | |
3853 | + if(a == b){continue;} | |
3854 | + const Atom& atomB = *molecule->GetAtom(b); | |
3855 | + int firstAOIndexB = atomB.GetFirstAOIndex(); | |
3856 | + int lastAOIndexB = atomB.GetLastAOIndex(); | |
3857 | + double rAB = this->molecule->GetDistanceAtoms(atomA, atomB); | |
3858 | 3858 | |
3859 | - // calc. first derivative of overlapAOs. | |
3860 | - this->CalcDiatomicOverlapAOs1stDerivatives(diatomicOverlapAOs1stDerivs, atomA, atomB); | |
3859 | + // calc. first derivative of overlapAOs. | |
3860 | + this->CalcDiatomicOverlapAOs1stDerivatives(diatomicOverlapAOs1stDerivs, atomA, atomB); | |
3861 | 3861 | |
3862 | - for(int i=0; i<CartesianType_end; i++){ | |
3863 | - coreRepulsion[i] += this->GetDiatomCoreRepulsion1stDerivative( | |
3862 | + for(int i=0; i<CartesianType_end; i++){ | |
3863 | + coreRepulsion[i] += this->GetDiatomCoreRepulsion1stDerivative( | |
3864 | + a, b, (CartesianType)i); | |
3865 | + if(Parameters::GetInstance()->RequiresVdWSCF()){ | |
3866 | + coreRepulsion[i] += this->GetDiatomVdWCorrection1stDerivative( | |
3864 | 3867 | a, b, (CartesianType)i); |
3865 | - if(Parameters::GetInstance()->RequiresVdWSCF()){ | |
3866 | - coreRepulsion[i] += this->GetDiatomVdWCorrection1stDerivative( | |
3867 | - a, b, (CartesianType)i); | |
3868 | - } | |
3869 | - | |
3870 | - electronicForce1[i] += ( atomA.GetCoreCharge() | |
3871 | - *atomicElectronPopulation[b] | |
3872 | - +atomB.GetCoreCharge() | |
3873 | - *atomicElectronPopulation[a]) | |
3874 | - *this->GetNishimotoMatagaTwoEleInt1stDerivative( | |
3875 | - atomA, s, atomB, s, rAB, static_cast<CartesianType>(i)); | |
3876 | 3868 | } |
3877 | - for(int mu=firstAOIndexA; mu<=lastAOIndexA; mu++){ | |
3878 | - OrbitalType orbitalMu = atomA.GetValence(mu-firstAOIndexA); | |
3879 | - for(int nu=firstAOIndexB; nu<=lastAOIndexB; nu++){ | |
3880 | - OrbitalType orbitalNu = atomB.GetValence(nu-firstAOIndexB); | |
3881 | - double bondParameter = 0.5*(atomA.GetBondingParameter( | |
3882 | - this->theory, orbitalMu) | |
3883 | - +atomB.GetBondingParameter( | |
3884 | - this->theory, orbitalNu)); | |
3885 | - for(int i=0; i<CartesianType_end; i++){ | |
3886 | - electronicForce2[i] += 2.0*this->orbitalElectronPopulation[mu][nu] | |
3887 | - *bondParameter | |
3888 | - *diatomicOverlapAOs1stDerivs[mu-firstAOIndexA][nu-firstAOIndexB][i]; | |
3889 | - electronicForce3[i] += (this->orbitalElectronPopulation[mu][mu] | |
3890 | - *this->orbitalElectronPopulation[nu][nu] | |
3891 | - -0.5*pow(this->orbitalElectronPopulation[mu][nu],2.0)) | |
3892 | - *this->GetNishimotoMatagaTwoEleInt1stDerivative( | |
3893 | - atomA, orbitalMu, atomB, orbitalNu, | |
3894 | - rAB, | |
3895 | - static_cast<CartesianType>(i)); | |
3896 | - } | |
3869 | + | |
3870 | + electronicForce1[i] += ( atomA.GetCoreCharge() | |
3871 | + *atomicElectronPopulation[b] | |
3872 | + +atomB.GetCoreCharge() | |
3873 | + *atomicElectronPopulation[a]) | |
3874 | + *this->GetNishimotoMatagaTwoEleInt1stDerivative( | |
3875 | + atomA, s, atomB, s, rAB, static_cast<CartesianType>(i)); | |
3876 | + } | |
3877 | + for(int mu=firstAOIndexA; mu<=lastAOIndexA; mu++){ | |
3878 | + OrbitalType orbitalMu = atomA.GetValence(mu-firstAOIndexA); | |
3879 | + for(int nu=firstAOIndexB; nu<=lastAOIndexB; nu++){ | |
3880 | + OrbitalType orbitalNu = atomB.GetValence(nu-firstAOIndexB); | |
3881 | + double bondParameter = 0.5*(atomA.GetBondingParameter( | |
3882 | + this->theory, orbitalMu) | |
3883 | + +atomB.GetBondingParameter( | |
3884 | + this->theory, orbitalNu)); | |
3885 | + for(int i=0; i<CartesianType_end; i++){ | |
3886 | + electronicForce2[i] += 2.0*this->orbitalElectronPopulation[mu][nu] | |
3887 | + *bondParameter | |
3888 | + *diatomicOverlapAOs1stDerivs[mu-firstAOIndexA][nu-firstAOIndexB][i]; | |
3889 | + electronicForce3[i] += (this->orbitalElectronPopulation[mu][mu] | |
3890 | + *this->orbitalElectronPopulation[nu][nu] | |
3891 | + -0.5*pow(this->orbitalElectronPopulation[mu][nu],2.0)) | |
3892 | + *this->GetNishimotoMatagaTwoEleInt1stDerivative( | |
3893 | + atomA, orbitalMu, atomB, orbitalNu, | |
3894 | + rAB, | |
3895 | + static_cast<CartesianType>(i)); | |
3897 | 3896 | } |
3898 | 3897 | } |
3899 | 3898 | } |
3899 | + } // end of for(int b) | |
3900 | + for(int n=0; n<elecStates.size(); n++){ | |
3901 | + for(int i=0; i<CartesianType_end; i++){ | |
3902 | + this->matrixForce[n][a][i] = -1.0*(coreRepulsion[i] | |
3903 | + -electronicForce1[i] | |
3904 | + +electronicForce2[i] | |
3905 | + +electronicForce3[i]); | |
3906 | + } | |
3900 | 3907 | } |
3901 | - for(int i=0; i<CartesianType_end; i++){ | |
3902 | - this->matrixForce[elecState][a][i] = -1.0*(coreRepulsion[i] | |
3903 | - -electronicForce1[i] | |
3904 | - +electronicForce2[i] | |
3905 | - +electronicForce3[i]); | |
3906 | - } | |
3907 | - } | |
3908 | - } | |
3908 | + } // end of for(int a) | |
3909 | + } // end of try | |
3909 | 3910 | catch(MolDSException ex){ |
3910 | 3911 | #pragma omp critical |
3911 | 3912 | ompErrors << ex.what() << endl ; |