Changeset ce5ac3 for src/molecules.cpp


Ignore:
Timestamp:
Jul 23, 2009, 12:32:48 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
d067d45
Parents:
986c80
Message:

Fix indentation from tabs to two spaces to prepare merging with MultipleMolecules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecules.cpp

    r986c80 rce5ac3  
    5353  BondCount = 0;
    5454  NoNonBonds = 0;
    55         NoNonHydrogen = 0;
     55  NoNonHydrogen = 0;
    5656  NoCyclicBonds = 0;
    5757  ListOfBondsPerAtom = NULL;
     
    117117{
    118118  if (pointer != NULL) {
    119         atom *walker = new atom();
    120         walker->type = pointer->type;   // copy element of atom
    121         walker->x.CopyVector(&pointer->x); // copy coordination
     119    atom *walker = new atom();
     120    walker->type = pointer->type;  // copy element of atom
     121    walker->x.CopyVector(&pointer->x); // copy coordination
    122122    walker->v.CopyVector(&pointer->v); // copy velocity
    123123    walker->FixedIon = pointer->FixedIon;
     
    186186  double *matrix;
    187187
    188 //      *out << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
     188//  *out << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    189189  // create vector in direction of bond
    190190  InBondvector.CopyVector(&TopReplacement->x);
     
    427427  }
    428428
    429 //      *out << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
     429//  *out << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl;
    430430  return AllWentWell;
    431431};
     
    753753Vector * molecule::DetermineCenterOfGravity(ofstream *out)
    754754{
    755         atom *ptr = start->next;  // start at first in list
    756         Vector *a = new Vector();
    757         Vector tmp;
     755  atom *ptr = start->next;  // start at first in list
     756  Vector *a = new Vector();
     757  Vector tmp;
    758758  double Num = 0;
    759759
    760         a->Zero();
     760  a->Zero();
    761761
    762762  if (ptr != end) {   //list not empty?
     
    909909void molecule::PrincipalAxisSystem(ofstream *out, bool DoRotate)
    910910{
    911         atom *ptr = start;  // start at first in list
    912         double InertiaTensor[NDIM*NDIM];
    913         Vector *CenterOfGravity = DetermineCenterOfGravity(out);
    914 
    915         CenterGravity(out, CenterOfGravity);
    916 
    917         // reset inertia tensor
    918         for(int i=0;i<NDIM*NDIM;i++)
    919                 InertiaTensor[i] = 0.;
    920 
    921         // sum up inertia tensor
    922         while (ptr->next != end) {
    923                 ptr = ptr->next;
    924                 Vector x;
    925                 x.CopyVector(&ptr->x);
    926                 //x.SubtractVector(CenterOfGravity);
    927                 InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
    928                 InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);
    929                 InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);
    930                 InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);
    931                 InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
    932                 InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);
    933                 InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);
    934                 InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);
    935                 InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
    936         }
    937         // print InertiaTensor for debugging
    938         *out << "The inertia tensor is:" << endl;
    939         for(int i=0;i<NDIM;i++) {
    940           for(int j=0;j<NDIM;j++)
    941             *out << InertiaTensor[i*NDIM+j] << " ";
    942           *out << endl;
    943         }
    944         *out << endl;
    945 
    946         // diagonalize to determine principal axis system
    947         gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM);
    948         gsl_matrix_view m = gsl_matrix_view_array(InertiaTensor, NDIM, NDIM);
    949         gsl_vector *eval = gsl_vector_alloc(NDIM);
    950         gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM);
    951         gsl_eigen_symmv(&m.matrix, eval, evec, T);
    952         gsl_eigen_symmv_free(T);
    953         gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_DESC);
    954 
    955         for(int i=0;i<NDIM;i++) {
    956                 *out << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i);
    957                 *out << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl;
    958         }
    959 
    960         // check whether we rotate or not
    961         if (DoRotate) {
    962           *out << Verbose(1) << "Transforming molecule into PAS ... ";
    963           // the eigenvectors specify the transformation matrix
    964           ptr = start;
    965           while (ptr->next != end) {
    966             ptr = ptr->next;
    967             for (int j=0;j<MDSteps;j++)
    968               Trajectories[ptr].R.at(j).MatrixMultiplication(evec->data);
    969             ptr->x.MatrixMultiplication(evec->data);
    970           }
    971           *out << "done." << endl;
    972 
    973           // summing anew for debugging (resulting matrix has to be diagonal!)
    974           // reset inertia tensor
     911  atom *ptr = start;  // start at first in list
     912  double InertiaTensor[NDIM*NDIM];
     913  Vector *CenterOfGravity = DetermineCenterOfGravity(out);
     914
     915  CenterGravity(out, CenterOfGravity);
     916
     917  // reset inertia tensor
     918  for(int i=0;i<NDIM*NDIM;i++)
     919    InertiaTensor[i] = 0.;
     920
     921  // sum up inertia tensor
     922  while (ptr->next != end) {
     923    ptr = ptr->next;
     924    Vector x;
     925    x.CopyVector(&ptr->x);
     926    //x.SubtractVector(CenterOfGravity);
     927    InertiaTensor[0] += ptr->type->mass*(x.x[1]*x.x[1] + x.x[2]*x.x[2]);
     928    InertiaTensor[1] += ptr->type->mass*(-x.x[0]*x.x[1]);
     929    InertiaTensor[2] += ptr->type->mass*(-x.x[0]*x.x[2]);
     930    InertiaTensor[3] += ptr->type->mass*(-x.x[1]*x.x[0]);
     931    InertiaTensor[4] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[2]*x.x[2]);
     932    InertiaTensor[5] += ptr->type->mass*(-x.x[1]*x.x[2]);
     933    InertiaTensor[6] += ptr->type->mass*(-x.x[2]*x.x[0]);
     934    InertiaTensor[7] += ptr->type->mass*(-x.x[2]*x.x[1]);
     935    InertiaTensor[8] += ptr->type->mass*(x.x[0]*x.x[0] + x.x[1]*x.x[1]);
     936  }
     937  // print InertiaTensor for debugging
     938  *out << "The inertia tensor is:" << endl;
     939  for(int i=0;i<NDIM;i++) {
     940    for(int j=0;j<NDIM;j++)
     941      *out << InertiaTensor[i*NDIM+j] << " ";
     942    *out << endl;
     943  }
     944  *out << endl;
     945
     946  // diagonalize to determine principal axis system
     947  gsl_eigen_symmv_workspace *T = gsl_eigen_symmv_alloc(NDIM);
     948  gsl_matrix_view m = gsl_matrix_view_array(InertiaTensor, NDIM, NDIM);
     949  gsl_vector *eval = gsl_vector_alloc(NDIM);
     950  gsl_matrix *evec = gsl_matrix_alloc(NDIM, NDIM);
     951  gsl_eigen_symmv(&m.matrix, eval, evec, T);
     952  gsl_eigen_symmv_free(T);
     953  gsl_eigen_symmv_sort(eval, evec, GSL_EIGEN_SORT_ABS_DESC);
     954
     955  for(int i=0;i<NDIM;i++) {
     956    *out << Verbose(1) << "eigenvalue = " << gsl_vector_get(eval, i);
     957    *out << ", eigenvector = (" << evec->data[i * evec->tda + 0] << "," << evec->data[i * evec->tda + 1] << "," << evec->data[i * evec->tda + 2] << ")" << endl;
     958  }
     959
     960  // check whether we rotate or not
     961  if (DoRotate) {
     962    *out << Verbose(1) << "Transforming molecule into PAS ... ";
     963    // the eigenvectors specify the transformation matrix
     964    ptr = start;
     965    while (ptr->next != end) {
     966      ptr = ptr->next;
     967      for (int j=0;j<MDSteps;j++)
     968        Trajectories[ptr].R.at(j).MatrixMultiplication(evec->data);
     969      ptr->x.MatrixMultiplication(evec->data);
     970    }
     971    *out << "done." << endl;
     972
     973    // summing anew for debugging (resulting matrix has to be diagonal!)
     974    // reset inertia tensor
    975975    for(int i=0;i<NDIM*NDIM;i++)
    976976      InertiaTensor[i] = 0.;
     
    10011001    }
    10021002    *out << endl;
    1003         }
    1004 
    1005         // free everything
    1006         delete(CenterOfGravity);
    1007         gsl_vector_free(eval);
    1008         gsl_matrix_free(evec);
     1003  }
     1004
     1005  // free everything
     1006  delete(CenterOfGravity);
     1007  gsl_vector_free(eval);
     1008  gsl_matrix_free(evec);
    10091009};
    10101010
     
    20272027    runner = elemente->start;
    20282028    while (runner->next != elemente->end) { // go through every element
    2029                 runner = runner->next;
     2029      runner = runner->next;
    20302030      if (ElementsInMolecule[runner->Z]) { // if this element got atoms
    20312031        ElementNo++;
     
    21212121bool molecule::Checkout(ofstream *out)  const
    21222122{
    2123         return elemente->Checkout(out, ElementsInMolecule);
     2123  return elemente->Checkout(out, ElementsInMolecule);
    21242124};
    21252125
     
    21742174    runner = elemente->start;
    21752175    while (runner->next != elemente->end) { // go through every element
    2176                 runner = runner->next;
     2176      runner = runner->next;
    21772177      if (ElementsInMolecule[runner->Z]) { // if this element got atoms
    21782178        ElementNo++;
     
    21962196void molecule::CountAtoms(ofstream *out)
    21972197{
    2198         int i = 0;
    2199         atom *Walker = start;
     2198  int i = 0;
     2199  atom *Walker = start;
    22002200  while (Walker->next != end) {
    22012201    Walker = Walker->next;
     
    22042204  if ((AtomCount == 0) || (i != AtomCount)) {
    22052205    *out << Verbose(3) << "Mismatch in AtomCount " << AtomCount << " and recounted number " << i << ", renaming all." << endl;
    2206         AtomCount = i;
     2206    AtomCount = i;
    22072207
    22082208    // count NonHydrogen atoms and give each atom a unique name
    22092209    if (AtomCount != 0) {
    2210             i=0;
    2211             NoNonHydrogen = 0;
     2210      i=0;
     2211      NoNonHydrogen = 0;
    22122212      Walker = start;
    2213             while (Walker->next != end) {
    2214               Walker = Walker->next;
    2215               Walker->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    2216               if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it
    2217                 NoNonHydrogen++;
    2218               Free((void **)&Walker->Name, "molecule::CountAtoms: *walker->Name");
    2219               Walker->Name = (char *) Malloc(sizeof(char)*6, "molecule::CountAtoms: *walker->Name");
    2220               sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
     2213      while (Walker->next != end) {
     2214        Walker = Walker->next;
     2215        Walker->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
     2216        if (Walker->type->Z != 1) // count non-hydrogen atoms whilst at it
     2217          NoNonHydrogen++;
     2218        Free((void **)&Walker->Name, "molecule::CountAtoms: *walker->Name");
     2219        Walker->Name = (char *) Malloc(sizeof(char)*6, "molecule::CountAtoms: *walker->Name");
     2220        sprintf(Walker->Name, "%2s%02d", Walker->type->symbol, Walker->nr+1);
    22212221        *out << "Naming atom nr. " << Walker->nr << " " << Walker->Name << "." << endl;
    2222               i++;
    2223             }
     2222        i++;
     2223      }
    22242224    } else
    2225         *out << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
     2225      *out << Verbose(3) << "AtomCount is still " << AtomCount << ", thus counting nothing." << endl;
    22262226  }
    22272227};
     
    22312231void molecule::CountElements()
    22322232{
    2233         int i = 0;
     2233  int i = 0;
    22342234  for(i=MAX_ELEMENTS;i--;)
    2235         ElementsInMolecule[i] = 0;
    2236         ElementCount = 0;
     2235    ElementsInMolecule[i] = 0;
     2236  ElementCount = 0;
    22372237
    22382238  atom *walker = start;
     
    22432243  }
    22442244  for(i=MAX_ELEMENTS;i--;)
    2245         ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
     2245    ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
    22462246};
    22472247
     
    23342334{
    23352335
    2336         // 1 We will parse bonds out of the dbond file created by tremolo.
    2337                         int atom1, atom2, temp;
    2338                         atom *Walker, *OtherWalker;
    2339 
    2340                 if (!input)
    2341                 {
    2342                         cout << Verbose(1) << "Opening silica failed \n";
    2343                 };
    2344 
    2345                         *input >> ws >> atom1;
    2346                         *input >> ws >> atom2;
    2347                 cout << Verbose(1) << "Scanning file\n";
    2348                 while (!input->eof()) // Check whether we read everything already
    2349                 {
    2350                                 *input >> ws >> atom1;
    2351                                 *input >> ws >> atom2;
    2352                         if(atom2<atom1) //Sort indices of atoms in order
    2353                         {
    2354                                 temp=atom1;
    2355                                 atom1=atom2;
    2356                                 atom2=temp;
    2357                         };
    2358 
    2359                         Walker=start;
    2360                         while(Walker-> nr != atom1) // Find atom corresponding to first index
    2361                         {
    2362                                 Walker = Walker->next;
    2363                         };
    2364                         OtherWalker = Walker->next;
    2365                         while(OtherWalker->nr != atom2) // Find atom corresponding to second index
    2366                         {
    2367                                 OtherWalker= OtherWalker->next;
    2368                         };
    2369                         AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
    2370                        
    2371                 }
    2372 
    2373                 CreateListOfBondsPerAtom(out);
     2336  // 1 We will parse bonds out of the dbond file created by tremolo.
     2337      int atom1, atom2, temp;
     2338      atom *Walker, *OtherWalker;
     2339
     2340          if (!input)
     2341          {
     2342            cout << Verbose(1) << "Opening silica failed \n";
     2343          };
     2344
     2345      *input >> ws >> atom1;
     2346      *input >> ws >> atom2;
     2347          cout << Verbose(1) << "Scanning file\n";
     2348          while (!input->eof()) // Check whether we read everything already
     2349          {
     2350        *input >> ws >> atom1;
     2351        *input >> ws >> atom2;
     2352            if(atom2<atom1) //Sort indices of atoms in order
     2353            {
     2354              temp=atom1;
     2355              atom1=atom2;
     2356              atom2=temp;
     2357            };
     2358
     2359            Walker=start;
     2360            while(Walker-> nr != atom1) // Find atom corresponding to first index
     2361            {
     2362              Walker = Walker->next;
     2363            };
     2364            OtherWalker = Walker->next;
     2365            while(OtherWalker->nr != atom2) // Find atom corresponding to second index
     2366            {
     2367              OtherWalker= OtherWalker->next;
     2368            };
     2369            AddBond(Walker, OtherWalker); //Add the bond between the two atoms with respective indices.
     2370           
     2371          }
     2372
     2373          CreateListOfBondsPerAtom(out);
    23742374
    23752375};
     
    25202520    // preferred over carbon bonds). Beforehand, we had picked the first mismatching partner, which lead to oxygenes with single instead of
    25212521    // double bonds as was expected.
    2522                 if (BondCount != 0) {
     2522    if (BondCount != 0) {
    25232523      NoCyclicBonds = 0;
    2524                   *out << Verbose(1) << "Correcting Bond degree of each bond ... ";
    2525                   do {
    2526                     No = 0; // No acts as breakup flag (if 1 we still continue)
     2524      *out << Verbose(1) << "Correcting Bond degree of each bond ... ";
     2525      do {
     2526        No = 0; // No acts as breakup flag (if 1 we still continue)
    25272527        Walker = start;
    25282528        while (Walker->next != end) { // go through every atom
     
    25382538            for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) { // go through each of its bond partners
    25392539              OtherWalker = ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker);
    2540                     // count valence of second partner
     2540              // count valence of second partner
    25412541              NoBonds = 0;
    25422542              for(j=0;j<NumberOfBondsPerAtom[OtherWalker->nr];j++)
    25432543                NoBonds += ListOfBondsPerAtom[OtherWalker->nr][j]->BondDegree;
    25442544              *out << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;
    2545                     if ((int)(OtherWalker->type->NoValenceOrbitals) > NoBonds) { // check if possible candidate
    2546                       if ((Candidate == NULL) || (NumberOfBondsPerAtom[Candidate->nr] > NumberOfBondsPerAtom[OtherWalker->nr])) { // pick the one with fewer number of bonds first
     2545              if ((int)(OtherWalker->type->NoValenceOrbitals) > NoBonds) { // check if possible candidate
     2546                if ((Candidate == NULL) || (NumberOfBondsPerAtom[Candidate->nr] > NumberOfBondsPerAtom[OtherWalker->nr])) { // pick the one with fewer number of bonds first
    25472547                  Candidate = OtherWalker;
    25482548                  CandidateBondNo = i;
    2549                         *out << Verbose(3) << "New candidate is " << *Candidate << "." << endl;
    2550                       }
    2551                     }
    2552                   }
     2549                  *out << Verbose(3) << "New candidate is " << *Candidate << "." << endl;
     2550                }
     2551              }
     2552            }
    25532553            if ((Candidate != NULL) && (CandidateBondNo != -1)) {
    25542554              ListOfBondsPerAtom[Walker->nr][CandidateBondNo]->BondDegree++;
     
    25582558              FalseBondDegree++;
    25592559          }
    2560                     }
    2561                   } while (No);
    2562                 *out << " done." << endl;
    2563                 } else
    2564                         *out << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;
    2565           *out << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << bonddistance << ", " << FalseBondDegree << " bonds could not be corrected." << endl;
    2566                
    2567           // output bonds for debugging (if bond chain list was correctly installed)
    2568           *out << Verbose(1) << endl << "From contents of bond chain list:";
    2569           bond *Binder = first;
     2560        }
     2561      } while (No);
     2562    *out << " done." << endl;
     2563    } else
     2564      *out << Verbose(1) << "BondCount is " << BondCount << ", no bonds between any of the " << AtomCount << " atoms." << endl;
     2565    *out << Verbose(1) << "I detected " << BondCount << " bonds in the molecule with distance " << bonddistance << ", " << FalseBondDegree << " bonds could not be corrected." << endl;
     2566   
     2567    // output bonds for debugging (if bond chain list was correctly installed)
     2568    *out << Verbose(1) << endl << "From contents of bond chain list:";
     2569    bond *Binder = first;
    25702570    while(Binder->next != last) {
    25712571      Binder = Binder->next;
    2572                         *out << *Binder << "\t" << endl;
     2572      *out << *Binder << "\t" << endl;
    25732573    }
    25742574    *out << endl;
    25752575  } else
    2576         *out << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;
     2576    *out << Verbose(1) << "AtomCount is " << AtomCount << ", thus no bonds, no connections!." << endl;
    25772577  *out << Verbose(0) << "End of CreateAdjacencyList." << endl;
    25782578  Free((void **)&matrix, "molecule::CreateAdjacencyList: *matrix");
     
    36003600int molecule::FragmentMolecule(ofstream *out, int Order, config *configuration)
    36013601{
    3602         MoleculeListClass *BondFragments = NULL;
     3602  MoleculeListClass *BondFragments = NULL;
    36033603  int *SortIndex = NULL;
    36043604  int *MinimumRingSize = new int[AtomCount];
     
    38063806    Walker = ListOfLocalAtoms[Binder->leftatom->nr];  // get one atom in the reference molecule
    38073807    if (Walker != NULL) // if this Walker exists in the subgraph ...
    3808         for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {    // go through the local list of bonds
    3809         OtherAtom = ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker);
    3810               if (OtherAtom == ListOfLocalAtoms[Binder->rightatom->nr]) { // found the bond
    3811                 LocalStack->Push(ListOfBondsPerAtom[Walker->nr][i]);
     3808      for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {    // go through the local list of bonds
     3809        OtherAtom = ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker);
     3810        if (OtherAtom == ListOfLocalAtoms[Binder->rightatom->nr]) { // found the bond
     3811            LocalStack->Push(ListOfBondsPerAtom[Walker->nr][i]);
    38123812                *out << Verbose(3) << "Found local edge " << *(ListOfBondsPerAtom[Walker->nr][i]) << "." << endl;
    3813                 break;
    3814             }
    3815         }
     3813          break;
     3814        }
     3815      }
    38163816    Binder = ReferenceStack->PopFirst();  // loop the stack for next item
    38173817    *out << Verbose(3) << "Current candidate edge " << Binder << "." << endl;
     
    43084308  for (int i=0;i<AtomCount;i++) { // reset all atom labels
    43094309    // initialise each vertex as white with no predecessor, empty queue, color lightgray, not labelled, no sons
    4310                 Labels[i] = -1;
     4310    Labels[i] = -1;
    43114311    SonList[i] = NULL;
    43124312    PredecessorList[i] = NULL;
     
    43164316  for (int i=0;i<BondCount;i++)
    43174317    ColorEdgeList[i] = white;
    4318         RootStack->ClearStack();        // clearstack and push first atom if exists
     4318  RootStack->ClearStack();  // clearstack and push first atom if exists
    43194319  TouchedStack->ClearStack();
    43204320  Walker = start->next;
     
    43354335  ///// OUTER LOOP ////////////
    43364336  while (!RootStack->IsEmpty()) {
    4337         // get new root vertex from atom stack
    4338         Root = RootStack->PopFirst();
     4337    // get new root vertex from atom stack
     4338    Root = RootStack->PopFirst();
    43394339    ShortestPathList[Root->nr] = 0;
    43404340    if (Labels[Root->nr] == -1)
     
    43444344    *out << Verbose(0) << "Root for this loop is: " << Root->Name << ".\n";
    43454345
    4346                 // clear snake stack
    4347           SnakeStack->ClearStack();
     4346    // clear snake stack
     4347    SnakeStack->ClearStack();
    43484348    //SnakeStack->TestImplementation(out, start->next);
    43494349
     
    43524352    // - what about cyclic bonds?
    43534353    Walker = Root;
    4354         do {
     4354    do {
    43554355      *out << Verbose(1) << "Current Walker is: " << Walker->Name;
    43564356      // initial setting of the new Walker: label, color, shortest path and put on stacks
    4357                 if (Labels[Walker->nr] == -1)   {       // give atom a unique, monotonely increasing number
    4358                         Labels[Walker->nr] = RunningIndex++;
     4357      if (Labels[Walker->nr] == -1)  {  // give atom a unique, monotonely increasing number
     4358        Labels[Walker->nr] = RunningIndex++;
    43594359        RootStack->Push(Walker);
    43604360      }
    43614361      *out << ", has label " << Labels[Walker->nr];
    4362                 if ((ColorVertexList[Walker->nr] == white) || ((Binder != NULL) && (ColorEdgeList[Binder->nr] == white))) {     // color it if newly discovered and push on stacks (and if within reach!)
     4362      if ((ColorVertexList[Walker->nr] == white) || ((Binder != NULL) && (ColorEdgeList[Binder->nr] == white))) {  // color it if newly discovered and push on stacks (and if within reach!)
    43634363        if ((Binder != NULL) && (ColorEdgeList[Binder->nr] == white)) {
    43644364          // Binder ought to be set still from last neighbour search
     
    43744374          ColorVertexList[Walker->nr] = darkgray; // mark as dark gray of on snake stack
    43754375        }
    4376                 }
     4376      }
    43774377      *out << ", SP of " << ShortestPathList[Walker->nr]  << " and its color is " << GetColor(ColorVertexList[Walker->nr]) << "." << endl;
    43784378
    43794379      // then check the stack for a newly stumbled upon fragment
    4380                 if (SnakeStack->ItemCount() == Order) { // is stack full?
     4380      if (SnakeStack->ItemCount() == Order) { // is stack full?
    43814381        // store the fragment if it is one and get a removal candidate
    43824382        Removal = StoreFragmentFromStack(out, Root, Walker, Leaflet, SnakeStack, ShortestPathList, SonList, Labels, &FragmentCounter, configuration);
     
    43914391          }
    43924392        }
    4393                 } else
     4393      } else
    43944394        Removal = NULL;
    43954395
     
    43984398      if ((Removal == NULL) || (Walker != PredecessorList[Removal->nr])) {  // don't look, if a new walker has been set above
    43994399        *out << Verbose(2) << "Snake has currently " << SnakeStack->ItemCount() << " item(s)." << endl;
    4400                         OtherAtom = NULL; // this is actually not needed, every atom has at least one neighbour
     4400        OtherAtom = NULL; // this is actually not needed, every atom has at least one neighbour
    44014401        if (ShortestPathList[Walker->nr] < Order) {
    4402                         for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {
     4402          for(int i=0;i<NumberOfBondsPerAtom[Walker->nr];i++) {
    44034403            Binder = ListOfBondsPerAtom[Walker->nr][i];
    44044404            *out << Verbose(2) << "Current bond is " << *Binder << ": ";
    4405                                 OtherAtom = Binder->GetOtherAtom(Walker);
     4405            OtherAtom = Binder->GetOtherAtom(Walker);
    44064406            if ((Labels[OtherAtom->nr] != -1) && (Labels[OtherAtom->nr] < Labels[Root->nr])) { // we don't step up to labels bigger than us
    44074407              *out << "Label " << Labels[OtherAtom->nr] << " is smaller than Root's " << Labels[Root->nr] << "." << endl;
    44084408              //ColorVertexList[OtherAtom->nr] = lightgray;    // mark as explored
    44094409            } else { // otherwise check its colour and element
    4410                                 if (
     4410              if (
    44114411#ifdef ADDHYDROGEN
    44124412              (OtherAtom->type->Z != 1) &&
     
    44304430              }
    44314431            }
    4432                         }
     4432          }
    44334433        } else {  // means we have stepped beyond the horizon: Return!
    44344434          Walker = PredecessorList[Walker->nr];
     
    44364436          *out << Verbose(3) << "We have gone too far, stepping back to " << Walker->Name << "." << endl;
    44374437        }
    4438                         if (Walker != OtherAtom) {      // if no white neighbours anymore, color it black
     4438        if (Walker != OtherAtom) {  // if no white neighbours anymore, color it black
    44394439          *out << Verbose(2) << "Coloring " << Walker->Name << " black." << endl;
    4440                                 ColorVertexList[Walker->nr] = black;
    4441                                 Walker = PredecessorList[Walker->nr];
    4442                         }
    4443       }
    4444         } while ((Walker != Root) || (ColorVertexList[Root->nr] != black));
     4440          ColorVertexList[Walker->nr] = black;
     4441          Walker = PredecessorList[Walker->nr];
     4442        }
     4443      }
     4444    } while ((Walker != Root) || (ColorVertexList[Root->nr] != black));
    44454445    *out << Verbose(2) << "Inner Looping is finished." << endl;
    44464446
     
    45624562        bit = ((i & (1 << j)) != 0);  // mask the bit for the j-th bond
    45634563        if (bit) {  // if bit is set, we add this bond partner
    4564                 OtherWalker = BondsSet[j]->rightatom;   // rightatom is always the one more distant, i.e. the one to add
     4564          OtherWalker = BondsSet[j]->rightatom;  // rightatom is always the one more distant, i.e. the one to add
    45654565          //*out << Verbose(1+verbosity) << "Current Bond is " << ListOfBondsPerAtom[Walker->nr][i] << ", checking on " << *OtherWalker << "." << endl;
    45664566          *out << Verbose(2+verbosity) << "Adding " << *OtherWalker << " with nr " << OtherWalker->nr << "." << endl;
     
    45844584        if (SubOrder > 1) {    // Due to Added above we have to check extra whether we're not already reaching beyond the desired Order
    45854585          // --2-- look at all added end pieces of this combination, construct bond subsets and sweep through a power set of these by recursion
    4586           SP = RootDistance+1;  // this is the next level
     4586          SP = RootDistance+1;  // this is the next level
    45874587          // first count the members in the subset
    45884588          SubSetDimension = 0;
    4589           Binder = FragmentSearch->BondsPerSPList[2*SP];                // start node for this level
    4590           while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) {              // compare to end node of this level
     4589          Binder = FragmentSearch->BondsPerSPList[2*SP];    // start node for this level
     4590          while (Binder->next != FragmentSearch->BondsPerSPList[2*SP+1]) {    // compare to end node of this level
    45914591            Binder = Binder->next;
    45924592            for (int k=TouchedIndex;k--;) {
Note: See TracChangeset for help on using the changeset viewer.