Changes in src/parser.cpp [29812d:f66195]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/parser.cpp
r29812d rf66195 399 399 * Sums over "E"-terms to create the "F"-terms 400 400 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 401 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order401 * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order 402 402 * \param Order bond order 403 403 * \return true if summing was successful 404 404 */ 405 bool MatrixContainer::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySet , int Order)405 bool MatrixContainer::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySets, int Order) 406 406 { 407 407 // go through each order 408 for (int CurrentFragment=0;CurrentFragment<KeySet .FragmentsPerOrder[Order];CurrentFragment++) {409 //cout << "Current Fragment is " << CurrentFragment << "/" << KeySet .OrderSet[Order][CurrentFragment] << "." << endl;408 for (int CurrentFragment=0;CurrentFragment<KeySets.FragmentsPerOrder[Order];CurrentFragment++) { 409 //cout << "Current Fragment is " << CurrentFragment << "/" << KeySets.OrderSet[Order][CurrentFragment] << "." << endl; 410 410 // then go per order through each suborder and pick together all the terms that contain this fragment 411 411 for(int SubOrder=0;SubOrder<=Order;SubOrder++) { // go through all suborders up to the desired order 412 for (int j=0;j<KeySet .FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder413 if (KeySet .Contains(KeySet.OrderSet[Order][CurrentFragment], KeySet.OrderSet[SubOrder][j])) {414 //cout << "Current other fragment is " << j << "/" << KeySet .OrderSet[SubOrder][j] << "." << endl;412 for (int j=0;j<KeySets.FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder 413 if (KeySets.Contains(KeySets.OrderSet[Order][CurrentFragment], KeySets.OrderSet[SubOrder][j])) { 414 //cout << "Current other fragment is " << j << "/" << KeySets.OrderSet[SubOrder][j] << "." << endl; 415 415 // if the fragment's indices are all in the current fragment 416 for(int k=0;k<RowCounter[ KeySet .OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment417 int m = MatrixValues.Indices[ KeySet .OrderSet[SubOrder][j] ][k];416 for(int k=0;k<RowCounter[ KeySets.OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment 417 int m = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][k]; 418 418 //cout << "Current index is " << k << "/" << m << "." << endl; 419 419 if (m != -1) { // if it's not an added hydrogen 420 for (int l=0;l<RowCounter[ KeySet .OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment421 //cout << "Comparing " << m << " with " << MatrixValues.Indices[ KeySet .OrderSet[Order][CurrentFragment] ][l] << "." << endl;422 if (m == MatrixValues.Indices[ KeySet .OrderSet[Order][CurrentFragment] ][l]) {420 for (int l=0;l<RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment 421 //cout << "Comparing " << m << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l] << "." << endl; 422 if (m == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l]) { 423 423 m = l; 424 424 break; … … 426 426 } 427 427 //cout << "Corresponding index in CurrentFragment is " << m << "." << endl; 428 if (m > RowCounter[ KeySet .OrderSet[Order][CurrentFragment] ]) {429 cerr << "In fragment No. " << KeySet .OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySet.OrderSet[Order][CurrentFragment] ] << "!" << endl;428 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 429 cerr << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current force index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl; 430 430 return false; 431 431 } 432 432 if (Order == SubOrder) { // equal order is always copy from Energies 433 for(int l=ColumnCounter[ KeySet .OrderSet[SubOrder][j] ];l--;) // then adds/subtract each column434 Matrix[ KeySet .OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];433 for(int l=ColumnCounter[ KeySets.OrderSet[SubOrder][j] ];l--;) // then adds/subtract each column 434 Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][l] += MatrixValues.Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l]; 435 435 } else { 436 for(int l=ColumnCounter[ KeySet .OrderSet[SubOrder][j] ];l--;)437 Matrix[ KeySet .OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];436 for(int l=ColumnCounter[ KeySets.OrderSet[SubOrder][j] ];l--;) 437 Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][l] -= Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l]; 438 438 } 439 439 } 440 //if ((ColumnCounter[ KeySet .OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))441 //cout << "Fragments[ KeySet .OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;440 //if ((ColumnCounter[ KeySets.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1)) 441 //cout << "Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl; 442 442 } 443 443 } else { 444 //cout << "Fragment " << KeySet .OrderSet[SubOrder][j] << " is not contained in fragment " << KeySet.OrderSet[Order][CurrentFragment] << "." << endl;444 //cout << "Fragment " << KeySets.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySets.OrderSet[Order][CurrentFragment] << "." << endl; 445 445 } 446 446 } 447 447 } 448 //cout << "Final Fragments[ KeySet .OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << KeySet.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][KeySet.AtomCounter[0]-1][1] << endl;448 //cout << "Final Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << KeySets.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][KeySets.AtomCounter[0]-1][1] << endl; 449 449 } 450 450 … … 534 534 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 535 535 * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments 536 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order536 * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order 537 537 * \param Order bond order 538 538 * \parsm sign +1 or -1 539 539 * \return true if summing was successful 540 540 */ 541 bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySet , int Order, double sign)541 bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySets, int Order, double sign) 542 542 { 543 543 // sum energy 544 544 if (CorrectionFragments == NULL) 545 for(int i=KeySet .FragmentsPerOrder[Order];i--;)546 for(int j=RowCounter[ KeySet .OrderSet[Order][i] ];j--;)547 for(int k=ColumnCounter[ KeySet .OrderSet[Order][i] ];k--;)548 Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySet .OrderSet[Order][i] ][j][k];545 for(int i=KeySets.FragmentsPerOrder[Order];i--;) 546 for(int j=RowCounter[ KeySets.OrderSet[Order][i] ];j--;) 547 for(int k=ColumnCounter[ KeySets.OrderSet[Order][i] ];k--;) 548 Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySets.OrderSet[Order][i] ][j][k]; 549 549 else 550 for(int i=KeySet .FragmentsPerOrder[Order];i--;)551 for(int j=RowCounter[ KeySet .OrderSet[Order][i] ];j--;)552 for(int k=ColumnCounter[ KeySet .OrderSet[Order][i] ];k--;)553 Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySet .OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySet.OrderSet[Order][i] ][j][k]);550 for(int i=KeySets.FragmentsPerOrder[Order];i--;) 551 for(int j=RowCounter[ KeySets.OrderSet[Order][i] ];j--;) 552 for(int k=ColumnCounter[ KeySets.OrderSet[Order][i] ];k--;) 553 Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySets.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySets.OrderSet[Order][i] ][j][k]); 554 554 return true; 555 555 }; … … 641 641 /** Sums the forces and puts into last element of \a ForceMatrix::Matrix. 642 642 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 643 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order643 * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order 644 644 * \param Order bond order 645 645 * \param sign +1 or -1 646 646 * \return true if summing was successful 647 647 */ 648 bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet , int Order, double sign)648 bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign) 649 649 { 650 650 int FragmentNr; 651 651 // sum forces 652 for(int i=0;i<KeySet .FragmentsPerOrder[Order];i++) {653 FragmentNr = KeySet .OrderSet[Order][i];652 for(int i=0;i<KeySets.FragmentsPerOrder[Order];i++) { 653 FragmentNr = KeySets.OrderSet[Order][i]; 654 654 for(int l=0;l<RowCounter[ FragmentNr ];l++) { 655 655 int j = Indices[ FragmentNr ][l]; … … 778 778 /** Sums the hessian entries and puts into last element of \a HessianMatrix::Matrix. 779 779 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 780 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order780 * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order 781 781 * \param Order bond order 782 782 * \param sign +1 or -1 783 783 * \return true if summing was successful 784 784 */ 785 bool HessianMatrix::SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySet , int Order, double sign)785 bool HessianMatrix::SumSubHessians(class HessianMatrix &Fragments, class KeySetsContainer &KeySets, int Order, double sign) 786 786 { 787 787 int FragmentNr; 788 788 // sum forces 789 for(int i=0;i<KeySet .FragmentsPerOrder[Order];i++) {790 FragmentNr = KeySet .OrderSet[Order][i];789 for(int i=0;i<KeySets.FragmentsPerOrder[Order];i++) { 790 FragmentNr = KeySets.OrderSet[Order][i]; 791 791 for(int l=0;l<RowCounter[ FragmentNr ];l++) { 792 792 int j = Indices[ FragmentNr ][l]; … … 823 823 * Sums over "E"-terms to create the "F"-terms 824 824 * \param Matrix MatrixContainer with matrices (LevelCounter by *ColumnCounter) with all the energies. 825 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order825 * \param KeySets KeySetContainer with bond Order and association mapping of each fragment to an order 826 826 * \param Order bond order 827 827 * \return true if summing was successful 828 828 */ 829 bool HessianMatrix::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySet , int Order)829 bool HessianMatrix::SumSubManyBodyTerms(class MatrixContainer &MatrixValues, class KeySetsContainer &KeySets, int Order) 830 830 { 831 831 // go through each order 832 for (int CurrentFragment=0;CurrentFragment<KeySet .FragmentsPerOrder[Order];CurrentFragment++) {833 //cout << "Current Fragment is " << CurrentFragment << "/" << KeySet .OrderSet[Order][CurrentFragment] << "." << endl;832 for (int CurrentFragment=0;CurrentFragment<KeySets.FragmentsPerOrder[Order];CurrentFragment++) { 833 //cout << "Current Fragment is " << CurrentFragment << "/" << KeySets.OrderSet[Order][CurrentFragment] << "." << endl; 834 834 // then go per order through each suborder and pick together all the terms that contain this fragment 835 835 for(int SubOrder=0;SubOrder<=Order;SubOrder++) { // go through all suborders up to the desired order 836 for (int j=0;j<KeySet .FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder837 if (KeySet .Contains(KeySet.OrderSet[Order][CurrentFragment], KeySet.OrderSet[SubOrder][j])) {838 //cout << "Current other fragment is " << j << "/" << KeySet .OrderSet[SubOrder][j] << "." << endl;836 for (int j=0;j<KeySets.FragmentsPerOrder[SubOrder];j++) { // go through all possible fragments of size suborder 837 if (KeySets.Contains(KeySets.OrderSet[Order][CurrentFragment], KeySets.OrderSet[SubOrder][j])) { 838 //cout << "Current other fragment is " << j << "/" << KeySets.OrderSet[SubOrder][j] << "." << endl; 839 839 // if the fragment's indices are all in the current fragment 840 for(int k=0;k<RowCounter[ KeySet .OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment841 int m = MatrixValues.Indices[ KeySet .OrderSet[SubOrder][j] ][k];840 for(int k=0;k<RowCounter[ KeySets.OrderSet[SubOrder][j] ];k++) { // go through all atoms in this fragment 841 int m = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][k]; 842 842 //cout << "Current row index is " << k << "/" << m << "." << endl; 843 843 if (m != -1) { // if it's not an added hydrogen 844 for (int l=0;l<RowCounter[ KeySet .OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment845 //cout << "Comparing " << m << " with " << MatrixValues.Indices[ KeySet .OrderSet[Order][CurrentFragment] ][l] << "." << endl;846 if (m == MatrixValues.Indices[ KeySet .OrderSet[Order][CurrentFragment] ][l]) {844 for (int l=0;l<RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ];l++) { // look for the corresponding index in the current fragment 845 //cout << "Comparing " << m << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l] << "." << endl; 846 if (m == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][l]) { 847 847 m = l; 848 848 break; … … 850 850 } 851 851 //cout << "Corresponding row index for " << k << " in CurrentFragment is " << m << "." << endl; 852 if (m > RowCounter[ KeySet .OrderSet[Order][CurrentFragment] ]) {853 cerr << "In fragment No. " << KeySet .OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySet.OrderSet[Order][CurrentFragment] ] << "!" << endl;852 if (m > RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 853 cerr << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current row index " << m << " is greater than " << RowCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl; 854 854 return false; 855 855 } 856 856 857 for(int l=0;l<ColumnCounter[ KeySet .OrderSet[SubOrder][j] ];l++) {858 int n = MatrixValues.Indices[ KeySet .OrderSet[SubOrder][j] ][l];857 for(int l=0;l<ColumnCounter[ KeySets.OrderSet[SubOrder][j] ];l++) { 858 int n = MatrixValues.Indices[ KeySets.OrderSet[SubOrder][j] ][l]; 859 859 //cout << "Current column index is " << l << "/" << n << "." << endl; 860 860 if (n != -1) { // if it's not an added hydrogen 861 for (int p=0;p<ColumnCounter[ KeySet .OrderSet[Order][CurrentFragment] ];p++) { // look for the corresponding index in the current fragment862 //cout << "Comparing " << n << " with " << MatrixValues.Indices[ KeySet .OrderSet[Order][CurrentFragment] ][p] << "." << endl;863 if (n == MatrixValues.Indices[ KeySet .OrderSet[Order][CurrentFragment] ][p]) {861 for (int p=0;p<ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ];p++) { // look for the corresponding index in the current fragment 862 //cout << "Comparing " << n << " with " << MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][p] << "." << endl; 863 if (n == MatrixValues.Indices[ KeySets.OrderSet[Order][CurrentFragment] ][p]) { 864 864 n = p; 865 865 break; … … 867 867 } 868 868 //cout << "Corresponding column index for " << l << " in CurrentFragment is " << n << "." << endl; 869 if (n > ColumnCounter[ KeySet .OrderSet[Order][CurrentFragment] ]) {870 cerr << "In fragment No. " << KeySet .OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySet.OrderSet[Order][CurrentFragment] ] << "!" << endl;869 if (n > ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ]) { 870 cerr << "In fragment No. " << KeySets.OrderSet[Order][CurrentFragment] << " current column index " << n << " is greater than " << ColumnCounter[ KeySets.OrderSet[Order][CurrentFragment] ] << "!" << endl; 871 871 return false; 872 872 } 873 873 if (Order == SubOrder) { // equal order is always copy from Energies 874 //cout << "Adding " << MatrixValues.Matrix[ KeySet .OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl;875 Matrix[ KeySet .OrderSet[Order][CurrentFragment] ][m][n] += MatrixValues.Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];874 //cout << "Adding " << MatrixValues.Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl; 875 Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][n] += MatrixValues.Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l]; 876 876 } else { 877 //cout << "Subtracting " << Matrix[ KeySet .OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl;878 Matrix[ KeySet .OrderSet[Order][CurrentFragment] ][m][n] -= Matrix[ KeySet.OrderSet[SubOrder][j] ][k][l];877 //cout << "Subtracting " << Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l] << " from [" << k << "][" << l << "] onto [" << m << "][" << n << "]." << endl; 878 Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][m][n] -= Matrix[ KeySets.OrderSet[SubOrder][j] ][k][l]; 879 879 } 880 880 } 881 881 } 882 882 } 883 //if ((ColumnCounter[ KeySet .OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1))884 //cout << "Fragments[ KeySet .OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;883 //if ((ColumnCounter[ KeySets.OrderSet[SubOrder][j] ]>1) && (RowCounter[0]-1 >= 1)) 884 //cout << "Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl; 885 885 } 886 886 } else { 887 //cout << "Fragment " << KeySet .OrderSet[SubOrder][j] << " is not contained in fragment " << KeySet.OrderSet[Order][CurrentFragment] << "." << endl;887 //cout << "Fragment " << KeySets.OrderSet[SubOrder][j] << " is not contained in fragment " << KeySets.OrderSet[Order][CurrentFragment] << "." << endl; 888 888 } 889 889 } 890 890 } 891 //cout << "Final Fragments[ KeySet .OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << KeySet.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][KeySet.AtomCounter[0]-1][1] << endl;891 //cout << "Final Fragments[ KeySets.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySets.OrderSet[Order][CurrentFragment] << " ][" << KeySets.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySets.OrderSet[Order][CurrentFragment] ][KeySets.AtomCounter[0]-1][1] << endl; 892 892 } 893 893
Note:
See TracChangeset
for help on using the changeset viewer.