Changeset a37350


Ignore:
Timestamp:
Jul 9, 2009, 1:33:39 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, 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:
21c017, 321a11
Parents:
8cede7
Message:

FIX: Now tries each of the axis direction to find a starting triangle

  • if BTS was not set, as no third point was found, output of NormalVector caused error. This is fixed.
  • also, we move in a loop over all three axis direction and try to create a starting triangle.
  • Therefore, the candidates in the list have to be free'd. This is done.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r8cede7 ra37350  
    22482248  }
    22492249  // then go through the current and all neighbouring cells and check the contained atoms for possible candidates
    2250   cout << Verbose(2) << "LC Intervals from [";
     2250  cout << Verbose(3) << "LC Intervals from [";
    22512251  for (int i=0;i<NDIM;i++) {
    22522252  cout << " " << N[i] << "<->" << LC->N[i];
     
    22962296                angle = AngleCheck.Angle(&Oben);
    22972297                if (angle < Storage[0]) {
    2298                   //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
    2299                   cout << Verbose(2) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";
     2298                  //cout << Verbose(3) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
     2299                  cout << Verbose(3) << "Current candidate is " << *Candidate << ": Is a better candidate with distance " << norm << " and angle " << angle << " to oben " << Oben << ".\n";
    23002300                  Opt_Candidate = Candidate;
    23012301                  Storage[0] = angle;
    2302                   //cout << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);
     2302                  //cout << Verbose(3) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]);
    23032303                } else {
    2304                   //cout << Verbose(2) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *Opt_Candidate << endl;
     2304                  //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Looses with angle " << angle << " to a better candidate " << *Opt_Candidate << endl;
    23052305                }
    23062306              } else {
    2307                 //cout << Verbose(2) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;
     2307                //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Refused due to Radius " << norm << endl;
    23082308              }
    23092309            } else {
    2310               //cout << Verbose(2) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;
     2310              //cout << Verbose(3) << "Current candidate is " << *Candidate << ": Candidate is equal to first endpoint." << *a << "." << endl;
    23112311            }
    23122312          }
    23132313        } else {
    2314           cout << "Linked cell list is empty." << endl;
     2314          cout << Verbose(3) << "Linked cell list is empty." << endl;
    23152315        }
    23162316      }
     
    23712371    cout << i << ": " << *MaxAtom[i] << "\t";
    23722372  cout << endl;
    2373   const int k = 1;    // arbitrary choice
    2374   Oben.x[k] = 1.;
    2375   FirstPoint = MaxAtom[k];
    2376   cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << "." << endl;
    2377 
    2378   double ShortestAngle;
    2379   atom* Opt_Candidate = NULL;
    2380   ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
    2381 
    2382   Find_second_point_for_Tesselation(FirstPoint, NULL, Oben, Opt_Candidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
    2383   SecondPoint = Opt_Candidate;
    2384   cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n";
    2385 
    2386   helper.CopyVector(&(FirstPoint->x));
    2387   helper.SubtractVector(&(SecondPoint->x));
    2388   helper.Normalize();
    2389   Oben.ProjectOntoPlane(&helper);
    2390   Oben.Normalize();
    2391   helper.VectorProduct(&Oben);
    2392   ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
    2393 
    2394   Chord.CopyVector(&(FirstPoint->x)); // bring into calling function
    2395   Chord.SubtractVector(&(SecondPoint->x));
    2396   double radius = Chord.ScalarProduct(&Chord);
    2397   double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
    2398   helper.CopyVector(&Oben);
    2399   helper.Scale(CircleRadius);
    2400   // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized)
    2401 
    2402   // look in one direction of baseline for initial candidate
     2373
     2374  BTS = NULL;
    24032375  CandidateList *Opt_Candidates = new CandidateList();
    2404   SearchDirection.MakeNormalVector(&Chord, &Oben);  // whether we look "left" first or "right" first is not important ...
    2405 
    2406   // adding point 1 and point 2 and the line between them
    2407   AddTrianglePoint(FirstPoint, 0);
    2408   AddTrianglePoint(SecondPoint, 1);
    2409   AddTriangleLine(TPS[0], TPS[1], 0);
    2410 
    2411   //cout << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n";
    2412   Find_third_point_for_Tesselation(
    2413     Oben, SearchDirection, helper, BLS[0], NULL, *&Opt_Candidates, &ShortestAngle, RADIUS, LC
    2414   );
    2415   cout << Verbose(1) << "List of third Points is ";
    2416   for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) {
    2417       cout << " " << *(*it)->point;
    2418   }
    2419   cout << endl;
    2420 
    2421   for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) {
    2422           // add third triangle point
    2423           AddTrianglePoint((*it)->point, 2);
    2424           // add the second and third line
    2425           AddTriangleLine(TPS[1], TPS[2], 1);
    2426           AddTriangleLine(TPS[0], TPS[2], 2);
    2427           // ... and triangles to the Maps of the Tesselation class
    2428           BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    2429           AddTriangle();
    2430           // ... and calculate its normal vector (with correct orientation)
    2431           (*it)->OptCenter.Scale(-1.);
    2432           cout << Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl;
    2433           BTS->GetNormalVector((*it)->OptCenter);  // vector to compare with should point inwards
    2434           cout << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and "
    2435                 << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n";
    2436 
    2437           // if we do not reach the end with the next step of iteration, we need to setup a new first line
    2438           if (it != Opt_Candidates->end()--) {
    2439                   FirstPoint = (*it)->BaseLine->endpoints[0]->node;
    2440                   SecondPoint = (*it)->point;
    2441                   // adding point 1 and point 2 and the line between them
    2442                   AddTrianglePoint(FirstPoint, 0);
    2443                   AddTrianglePoint(SecondPoint, 1);
    2444                   AddTriangleLine(TPS[0], TPS[1], 0);
    2445           }
    2446   }
     2376  for (int k=0;k<NDIM;k++) {
     2377    Oben.x[k] = 1.;
     2378    FirstPoint = MaxAtom[k];
     2379    cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << " at " << FirstPoint->x << "." << endl;
     2380
     2381    double ShortestAngle;
     2382    atom* Opt_Candidate = NULL;
     2383    ShortestAngle = 999999.; // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
     2384
     2385    Find_second_point_for_Tesselation(FirstPoint, NULL, Oben, Opt_Candidate, &ShortestAngle, RADIUS, LC); // we give same point as next candidate as its bonds are looked into in find_second_...
     2386    SecondPoint = Opt_Candidate;
     2387    if (SecondPoint == NULL)  // have we found a second point?
     2388      continue;
     2389    else
     2390      cout << Verbose(1) << "Found second point is " << *SecondPoint << " at " << SecondPoint->x << ".\n";
     2391
     2392    helper.CopyVector(&(FirstPoint->x));
     2393    helper.SubtractVector(&(SecondPoint->x));
     2394    helper.Normalize();
     2395    Oben.ProjectOntoPlane(&helper);
     2396    Oben.Normalize();
     2397    helper.VectorProduct(&Oben);
     2398    ShortestAngle = 2.*M_PI; // This will indicate the quadrant.
     2399
     2400    Chord.CopyVector(&(FirstPoint->x)); // bring into calling function
     2401    Chord.SubtractVector(&(SecondPoint->x));
     2402    double radius = Chord.ScalarProduct(&Chord);
     2403    double CircleRadius = sqrt(RADIUS*RADIUS - radius/4.);
     2404    helper.CopyVector(&Oben);
     2405    helper.Scale(CircleRadius);
     2406    // Now, oben and helper are two orthonormalized vectors in the plane defined by Chord (not normalized)
     2407
     2408    // look in one direction of baseline for initial candidate
     2409    SearchDirection.MakeNormalVector(&Chord, &Oben);  // whether we look "left" first or "right" first is not important ...
     2410
     2411    // adding point 1 and point 2 and the line between them
     2412    AddTrianglePoint(FirstPoint, 0);
     2413    AddTrianglePoint(SecondPoint, 1);
     2414    AddTriangleLine(TPS[0], TPS[1], 0);
     2415
     2416    //cout << Verbose(2) << "INFO: OldSphereCenter is at " << helper << ".\n";
     2417    Find_third_point_for_Tesselation(
     2418      Oben, SearchDirection, helper, BLS[0], NULL, *&Opt_Candidates, &ShortestAngle, RADIUS, LC
     2419    );
     2420    cout << Verbose(1) << "List of third Points is ";
     2421    for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) {
     2422        cout << " " << *(*it)->point;
     2423    }
     2424    cout << endl;
     2425
     2426    for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) {
     2427      // add third triangle point
     2428      AddTrianglePoint((*it)->point, 2);
     2429      // add the second and third line
     2430      AddTriangleLine(TPS[1], TPS[2], 1);
     2431      AddTriangleLine(TPS[0], TPS[2], 2);
     2432      // ... and triangles to the Maps of the Tesselation class
     2433      BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     2434      AddTriangle();
     2435      // ... and calculate its normal vector (with correct orientation)
     2436      (*it)->OptCenter.Scale(-1.);
     2437      cout << Verbose(2) << "Anti-Oben is currently " << (*it)->OptCenter << "." << endl;
     2438      BTS->GetNormalVector((*it)->OptCenter);  // vector to compare with should point inwards
     2439      cout << Verbose(0) << "==> Found starting triangle consists of " << *FirstPoint << ", " << *SecondPoint << " and "
     2440      << *(*it)->point << " with normal vector " << BTS->NormalVector << ".\n";
     2441
     2442      // if we do not reach the end with the next step of iteration, we need to setup a new first line
     2443      if (it != Opt_Candidates->end()--) {
     2444        FirstPoint = (*it)->BaseLine->endpoints[0]->node;
     2445        SecondPoint = (*it)->point;
     2446        // adding point 1 and point 2 and the line between them
     2447        AddTrianglePoint(FirstPoint, 0);
     2448        AddTrianglePoint(SecondPoint, 1);
     2449        AddTriangleLine(TPS[0], TPS[1], 0);
     2450      }
     2451      cout << Verbose(2) << "Projection is " << BTS->NormalVector.Projection(&Oben) << "." << endl;
     2452    }
     2453    if (BTS != NULL) // we have created one starting triangle
     2454      break;
     2455    else {
     2456      // remove all candidates from the list and then the list itself
     2457      class CandidateForTesselation *remover = NULL;
     2458      for (CandidateList::iterator it = Opt_Candidates->begin(); it != Opt_Candidates->end(); ++it) {
     2459        remover = *it;
     2460        delete(remover);
     2461      }
     2462      Opt_Candidates->clear();
     2463    }
     2464  }
     2465
    24472466  // remove all candidates from the list and then the list itself
    24482467  class CandidateForTesselation *remover = NULL;
     
    24522471  }
    24532472  delete(Opt_Candidates);
    2454   cout << Verbose(2) << "Projection is " << BTS->NormalVector.Projection(&Oben) << "." << endl;
    24552473  cout << Verbose(1) << "End of Find_starting_triangle\n";
    24562474};
Note: See TracChangeset for help on using the changeset viewer.