Changeset e1589e for src


Ignore:
Timestamp:
Jul 28, 2009, 1:02:51 PM (15 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:
2319ed
Parents:
d4d0dd
Message:

Convex tesselation is now working also for heptan. But the convex hull of the bigger molecules is too small.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rd4d0dd re1589e  
    319319    AngleReferenceNormalVector.x[(axis + 2) % NDIM] = 1.;
    320320
    321     //*out << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
     321    *out << Verbose(1) << "Axisvector is " << AxisVector << " and AngleReferenceVector is " << AngleReferenceVector << ", and AngleReferenceNormalVector is " << AngleReferenceNormalVector << "." << endl;
    322322
    323323    // 3b. construct set of all points, transformed into cylindrical system and with left and right neighbours
     
    331331
    332332      // correct for negative side
    333       radius = ProjectedVector.Norm();
     333      radius = ProjectedVector.NormSquared();
    334334      if (fabs(radius) > MYEPSILON)
    335335        angle = ProjectedVector.Angle(&AngleReferenceVector);
     
    341341        angle = 2. * M_PI - angle;
    342342      }
    343       //*out << Verbose(2) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
    344       BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle,
    345           DistancePair (radius, Walker)));
    346       if (BoundaryTestPair.second) { // successfully inserted
    347       } else { // same point exists, check first r, then distance of original vectors to center of gravity
     343      *out << Verbose(2) << "Inserting " << *Walker << ": (r, alpha) = (" << radius << "," << angle << "): " << ProjectedVector << endl;
     344      BoundaryTestPair = BoundaryPoints[axis].insert(BoundariesPair(angle, DistancePair (radius, Walker)));
     345      if (!BoundaryTestPair.second) { // same point exists, check first r, then distance of original vectors to center of gravity
    348346        *out << Verbose(2) << "Encountered two vectors whose projection onto axis " << axis << " is equal: " << endl;
    349         *out << Verbose(2) << "Present vector: " << BoundaryTestPair.first->second.second->x << endl;
    350         *out << Verbose(2) << "New vector: " << Walker << endl;
    351         double tmp = ProjectedVector.Norm();
    352         if (tmp > BoundaryTestPair.first->second.first) {
     347        *out << Verbose(2) << "Present vector: " << *BoundaryTestPair.first->second.second << endl;
     348        *out << Verbose(2) << "New vector: " << *Walker << endl;
     349        double tmp = ProjectedVector.NormSquared();
     350        if ((tmp - BoundaryTestPair.first->second.first) > MYEPSILON) {
    353351          BoundaryTestPair.first->second.first = tmp;
    354352          BoundaryTestPair.first->second.second = Walker;
    355           *out << Verbose(2) << "Keeping new vector." << endl;
    356         } else if (tmp == BoundaryTestPair.first->second.first) {
     353          *out << Verbose(2) << "Keeping new vector due to larger projected distance " << tmp << "." << endl;
     354        } else if (fabs(tmp - BoundaryTestPair.first->second.first) < MYEPSILON) {
    357355          helper.CopyVector(&Walker->x);
    358356          helper.SubtractVector(MolCenter);
    359           if (BoundaryTestPair.first->second.second->x.ScalarProduct(&BoundaryTestPair.first->second.second->x) < helper.ScalarProduct(&helper)) { // Norm() does a sqrt, which makes it a lot slower
     357          tmp = helper.NormSquared();
     358          helper.CopyVector(&BoundaryTestPair.first->second.second->x);
     359          helper.SubtractVector(MolCenter);
     360          if (helper.NormSquared() < tmp) {
    360361            BoundaryTestPair.first->second.second = Walker;
    361             *out << Verbose(2) << "Keeping new vector." << endl;
     362            *out << Verbose(2) << "Keeping new vector due to larger distance to molecule center " << helper.NormSquared() << "." << endl;
    362363          } else {
    363             *out << Verbose(2) << "Keeping present vector." << endl;
     364            *out << Verbose(2) << "Keeping present vector due to larger distance to molecule center " << tmp << "." << endl;
    364365          }
    365366        } else {
    366           *out << Verbose(2) << "Keeping present vector." << endl;
     367          *out << Verbose(2) << "Keeping present vector due to larger projected distance " << tmp << "." << endl;
    367368        }
    368369      }
     
    446447          double MinDistance = a * sin(beta) / (sin(delta)) * (((alpha < M_PI / 2.) || (gamma < M_PI / 2.)) ? 1. : -1.);
    447448          //*out << Verbose(2) << " I calculated: a = " << a << ", h = " << h << ", beta(" << left->second.second->Name << "," << left->second.second->Name << "-" << right->second.second->Name << ") = " << beta << ", delta(" << left->second.second->Name << "," << runner->second.second->Name << ") = " << delta << ", Min = " << MinDistance << "." << endl;
    448           //*out << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl;
    449           if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && (h < MinDistance)) {
     449          *out << Verbose(1) << "Checking CoG distance of runner " << *runner->second.second << " " << h << " against triangle's side length spanned by (" << *left->second.second << "," << *right->second.second << ") of " << MinDistance << "." << endl;
     450          if ((fabs(h / fabs(h) - MinDistance / fabs(MinDistance)) < MYEPSILON) && ((h - MinDistance)) < -MYEPSILON) {
    450451            // throw out point
    451             //*out << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;
     452            *out << Verbose(1) << "Throwing out " << *runner->second.second << "." << endl;
    452453            BoundaryPoints[axis].erase(runner);
    453454            flag = true;
     
    11911192  class BoundaryPointSet *peak = NULL;
    11921193  double SmallestAngle, TempAngle;
    1193   Vector NormalVector, VirtualNormalVector, CenterVector, TempVector, PropagationVector, *MolCenter = NULL;
     1194  Vector NormalVector, VirtualNormalVector, CenterVector, TempVector, helper, PropagationVector, *MolCenter = NULL;
    11941195  LineMap::iterator LineChecker[2];
    11951196
     
    12131214        Vector BaseLineCenter, BaseLine;
    12141215        BaseLineCenter.CopyVector(&baseline->second->endpoints[0]->node->x);
    1215         BaseLineCenter.AddVector(&baseline->second->endpoints[0]->node->x);
     1216        BaseLineCenter.AddVector(&baseline->second->endpoints[1]->node->x);
    12161217        BaseLineCenter.Scale(1. / 2.); // points now to center of base line
    12171218        BaseLine.CopyVector(&baseline->second->endpoints[0]->node->x);
     
    12531254            VirtualNormalVector.ProjectOntoPlane(&NormalVector);
    12541255            TempAngle = VirtualNormalVector.Angle(&PropagationVector);
     1256            *out << Verbose(4) << "VirtualNormalVector is " << VirtualNormalVector << " and PropagationVector is " << PropagationVector << "." << endl;
    12551257            if (TempAngle > (M_PI/2.)) { // no bends bigger than Pi/2 (90 degrees)
    12561258              *out << Verbose(4) << "Angle on triangle plane between propagation direction and base line to " << *(target->second) << " is " << TempAngle << ", bad direction!" << endl;
     
    12741276            if ((((LineChecker[0] != baseline->second->endpoints[0]->lines.end()) && (LineChecker[1] != baseline->second->endpoints[1]->lines.end()) && (GetCommonEndpoint(LineChecker[0]->second, LineChecker[1]->second) == peak)))) {
    12751277              *out << Verbose(4) << "Current target is peak!" << endl;
     1278              continue;
     1279            }
     1280
     1281            // check for linear dependence
     1282            TempVector.CopyVector(&baseline->second->endpoints[0]->node->x);
     1283            TempVector.SubtractVector(&target->second->node->x);
     1284            helper.CopyVector(&baseline->second->endpoints[1]->node->x);
     1285            helper.SubtractVector(&target->second->node->x);
     1286            helper.ProjectOntoPlane(&TempVector);
     1287            if (fabs(helper.NormSquared()) < MYEPSILON) {
     1288              *out << Verbose(4) << "Chosen set of vectors is linear dependent." << endl;
    12761289              continue;
    12771290            }
     
    12911304            TempAngle = NormalVector.Angle(&VirtualNormalVector);
    12921305            *out << Verbose(4) << "NormalVector is " << VirtualNormalVector << " and the angle is " << TempAngle << "." << endl;
    1293             if (SmallestAngle > TempAngle) { // set to new possible winner
     1306            if ((SmallestAngle - TempAngle) > MYEPSILON) { // set to new possible winner
    12941307              SmallestAngle = TempAngle;
    12951308              winner = target;
    1296             }
     1309              *out << Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
     1310            } else if (fabs(SmallestAngle - TempAngle) < MYEPSILON) { // check the angle to propagation, both possible targets are in one plane! (their normals have same angle)
     1311              // hence, check the angles to some normal direction from our base line but in this common plane of both targets...
     1312              helper.CopyVector(&target->second->node->x);
     1313              helper.SubtractVector(&BaseLineCenter);
     1314              helper.ProjectOntoPlane(&BaseLine);
     1315              // ...the one with the smaller angle is the better candidate
     1316              TempVector.CopyVector(&target->second->node->x);
     1317              TempVector.SubtractVector(&BaseLineCenter);
     1318              TempVector.ProjectOntoPlane(&VirtualNormalVector);
     1319              TempAngle = TempVector.Angle(&helper);
     1320              TempVector.CopyVector(&winner->second->node->x);
     1321              TempVector.SubtractVector(&BaseLineCenter);
     1322              TempVector.ProjectOntoPlane(&VirtualNormalVector);
     1323              if (TempAngle < TempVector.Angle(&helper)) {
     1324                TempAngle = NormalVector.Angle(&VirtualNormalVector);
     1325                SmallestAngle = TempAngle;
     1326                winner = target;
     1327                *out << Verbose(4) << "New winner " << *winner->second->node << " due to smaller angle " << TempAngle << " to propagation direction." << endl;
     1328              } else
     1329                *out << Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle to propagation direction." << endl;
     1330            } else
     1331              *out << Verbose(4) << "Keeping old winner " << *winner->second->node << " due to smaller angle between normal vectors." << endl;
    12971332          }
    12981333        } // end of loop over all boundary points
Note: See TracChangeset for help on using the changeset viewer.