Changeset e9fa06f


Ignore:
Timestamp:
Dec 18, 2008, 5:21:34 PM (16 years ago)
Author:
Christian Neuen <neuen@…>
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:
7c6712
Parents:
10af0d
Message:

First change to Ball angle as criteria, however, change sucks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r10af0d re9fa06f  
    14371437 * @param mol molecule structure with atoms and bonds
    14381438 */
    1439 void
    1440 Find_next_suitable_point(atom* a, atom* b, atom* Candidate, atom* Parent,
     1439void Find_next_suitable_point(atom* a, atom* b, atom* Candidate, atom* Parent,
    14411440    int RecursionLevel, Vector *Chord, Vector *d1, Vector *OldNormal,
    14421441    atom*& Opt_Candidate, Vector *Opt_Mittelpunkt, double *Storage, const double RADIUS, molecule* mol)
     
    14481447  Vector dif_a; //Vector from a to candidate
    14491448  Vector dif_b; //Vector from b to candidate
    1450   Vector AngleCheck; // Projection of a difference vector on plane orthogonal on triangle side.
     1449  Vector AngleCheck, AngleCheckReference, DirectionCheckPoint;
    14511450  Vector TempNormal, Umkreismittelpunkt, Mittelpunkt;
    14521451
    14531452  double CurrentEpsilon = 0.1;
    14541453  double alpha, beta, gamma, SideA, SideB, SideC, sign, Umkreisradius, Restradius, Distance;
     1454  double BallAngle;
    14551455  atom *Walker; // variable atom point
    14561456
     
    14601460  dif_b.CopyVector(&(b->x));
    14611461  dif_b.SubtractVector(&(Candidate->x));
    1462   AngleCheck.CopyVector(&dif_a);
    1463   AngleCheck.Scale(-1);
    1464   AngleCheck.ProjectOntoPlane(Chord);
     1462  DirectionCheckPoint.CopyVector(&dif_a);
     1463  DirectionCheckPoint.Scale(-1);
     1464  DirectionCheckPoint.ProjectOntoPlane(Chord);
    14651465
    14661466  SideA = dif_b.Norm();
     
    14841484  if (a != Candidate and b != Candidate)
    14851485    {
    1486 //      alpha = dif_a.Angle(&dif_b) / 2.;
    1487 //      SideA = Chord->Norm() / 2.;// (Chord->Norm()/2.) / sin(0.5*alpha);
    1488 //      SideB = dif_a.Norm();
    1489 //      centerline = SideA * SideA + SideB * SideB - 2. * SideA * SideB * cos(
    1490 //          alpha); // note this is squared of center line length
    1491 // Those are remains from Freddie. Needed?
    1492 
    1493 //      centerline = (Chord->Norm()/2.) / sin(0.5*alpha);
    1494 //      Old Chordtest. Replaced by test for Radius of Circumscribing circle
     1486      //      alpha = dif_a.Angle(&dif_b) / 2.;
     1487      //      SideA = Chord->Norm() / 2.;// (Chord->Norm()/2.) / sin(0.5*alpha);
     1488      //      SideB = dif_a.Norm();
     1489      //      centerline = SideA * SideA + SideB * SideB - 2. * SideA * SideB * cos(
     1490      //          alpha); // note this is squared of center line length
     1491      //      centerline = (Chord->Norm()/2.) / sin(0.5*alpha);
     1492      // Those are remains from Freddie. Needed?
     1493
     1494
    14951495
    14961496      Umkreisradius = SideA / 2.0 / sin(alpha);
     
    14991499      //cout << SideC / 2.0 / sin(gamma) << endl;
    15001500
    1501       if (Umkreisradius < RADIUS)
    1502         {
    1503 
    1504           sign = AngleCheck.ScalarProduct(d1);
    1505           sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
    1506 
    1507           // intermediate calculations:
     1501      if (Umkreisradius < RADIUS && DirectionCheckPoint.ScalarProduct(&(Candidate->x))>0) //Checking whether ball will at least rest o points.
     1502        {
     1503
     1504          // intermediate calculations to aquire centre of sphere, called Mittelpunkt:
    15081505
    15091506          Umkreismittelpunkt = (a->x) * sin(2.*alpha) + b->x * sin(2.*beta) + (Candidate->x) * sin(2.*gamma) ;
    15101507          Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));
    1511 
    15121508
    15131509          TempNormal.CopyVector(&dif_a);
     
    15191515          TempNormal.Normalize();
    15201516          Restradius = sqrt(RADIUS*RADIUS - Umkreisradius*Umkreisradius);
    1521 
    15221517          TempNormal.Scale(Restradius);
    15231518
     
    15251520          Mittelpunkt.AddVector(&TempNormal);  //this is center of sphere supported by a, b and Candidate
    15261521
     1522          AngleCheck.CopyVector(Chord);
     1523          AngleCheck.Scale(-0.5);
     1524          AngleCheck.SubtractVector(&(b->x));
     1525          AngleCheckReference.CopyVector(&AngleCheck);
     1526          AngleCheckReference.AddVector(Opt_Mittelpunkt);
     1527          AngleCheck.AddVector(&Mittelpunkt);
     1528
     1529          BallAngle = AngleCheck.Angle(&AngleCheckReference);
     1530
     1531          d1->ProjectOntoPlane(&AngleCheckReference);
     1532          sign = AngleCheck.ScalarProduct(d1);
     1533          sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction...
    15271534
    15281535
     
    15331540              Opt_Candidate = Candidate;
    15341541              Storage[0] = sign;
    1535               Storage[1] = AngleCheck.Angle(OldNormal);
     1542              Storage[1] = BallAngle;
    15361543              Opt_Mittelpunkt->CopyVector(&Mittelpunkt);
    15371544              cout << "Angle is " << Storage[1] << ", Halbraum ist "
     
    15421549          else
    15431550            {
     1551              /*
     1552               * removed due to change in criterium, now checking angle of ball to old normal.
    15441553              //We will now check for non interference, that is if the new candidate would have the Opt_Candidate
    15451554              //within the ball.
     
    15501559
    15511560              if (Distance >RADIUS) // We have no interference and may now check whether the new point is better.
     1561                */
    15521562                {
    15531563                  //cout << "Atom " << Candidate << " has distance " << Candidate->x.Distance(Opt_Mittelpunkt) << " to Center of Candidate " << endl;
    15541564
    1555                   if (((Storage[0] < 0 && fabs(sign - Storage[0]) > CurrentEpsilon)) || //This will give absolute preference to those in "right-hand" quadrants
    1556                       (Candidate->x.Distance(Opt_Mittelpunkt) < RADIUS))    //and those where Candidate would be within old Sphere.
     1565                  if (((Storage[0] < 0 && fabs(sign - Storage[0]) > CurrentEpsilon))) //This will give absolute preference to those in "right-hand" quadrants
     1566                      //(Candidate->x.Distance(Opt_Mittelpunkt) < RADIUS))    //and those where Candidate would be within old Sphere.
    15571567                    {
    15581568                      cout << "Next better candidate is " << *Candidate << " with ";
    15591569                      Opt_Candidate = Candidate;
    15601570                      Storage[0] = sign;
    1561                       Storage[1] = AngleCheck.Angle(OldNormal);
     1571                      Storage[1] = BallAngle;
    15621572                      Opt_Mittelpunkt->CopyVector(&Mittelpunkt);
    15631573                      cout << "Angle is " << Storage[1] << ", Halbraum ist "
    15641574                          << Storage[0] << endl;
    1565 /*
    1566                       cout << "Umkreismittelpunkt has coordinates" << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] <<" "<<Umkreismittelpunkt.x[2] << endl;
    1567                                     cout << "Candidate has coordinates" << Candidate->x.x[0]<< " " << Candidate->x.x[1] << " " << Candidate->x.x[2] << endl;
    1568                                     cout << "a has coordinates" << a->x.x[0]<< " " << a->x.x[1] << " " << a->x.x[2] << endl;
    1569                                     cout << "b has coordinates" << b->x.x[0]<< " " << b->x.x[1] << " " << b->x.x[2] << endl;
    1570                                     cout << "Mittelpunkt has coordinates" << Mittelpunkt.x[0] << " " << Mittelpunkt.x[1]<< " "  <<Mittelpunkt.x[2] << endl;
    1571                                     cout << "Umkreisradius ist " << Umkreisradius << endl;
    1572                                     cout << "Restradius ist " << Restradius << endl;
    1573                                     cout << "TempNormal has coordinates " << TempNormal.x[0] << " " << TempNormal.x[1] << " " << TempNormal.x[2] << " " << endl;
    1574                                     cout << "OldNormal has coordinates " << OldNormal->x[0] << " " << OldNormal->x[1] << " " << OldNormal->x[2] << " " << endl;
    1575                                     cout << "Dist a to UmkreisMittelpunkt " << a->x.Distance(&Umkreismittelpunkt) << endl;
    1576                                     cout << "Dist b to UmkreisMittelpunkt " << b->x.Distance(&Umkreismittelpunkt) << endl;
    1577                                     cout << "Dist Candidate to UmkreisMittelpunkt " << Candidate->x.Distance(&Umkreismittelpunkt) << endl;
    1578                                     cout << "Dist a to Mittelpunkt " << a->x.Distance(&Mittelpunkt) << endl;
    1579                                     cout << "Dist b to Mittelpunkt " << b->x.Distance(&Mittelpunkt) << endl;
    1580                                     cout << "Dist Candidate to Mittelpunkt " << Candidate->x.Distance(&Mittelpunkt) << endl;
    1581                                     */
     1575
    15821576
    15831577                    }
     
    15851579                    {
    15861580                      if ((fabs(sign - Storage[0]) < CurrentEpsilon && sign > 0
    1587                           && Storage[1] > AngleCheck.Angle(OldNormal)) ||
     1581                          && Storage[1] > BallAngle) ||
    15881582                          (fabs(sign - Storage[0]) < CurrentEpsilon && sign < 0
    1589                           && Storage[1] < AngleCheck.Angle(OldNormal)))
     1583                          && Storage[1] < BallAngle))
    15901584                      //Depending on quadrant we prefer higher or lower atom with respect to Triangle normal first.
    15911585                        {
     
    15931587                          Opt_Candidate = Candidate;
    15941588                          Storage[0] = sign;
    1595                           Storage[1] = AngleCheck.Angle(OldNormal);
     1589                          Storage[1] = BallAngle;
    15961590                          Opt_Mittelpunkt->CopyVector(&Mittelpunkt);
    15971591                          cout << "Angle is " << Storage[1] << ", Halbraum ist "
    15981592                              << Storage[0] << endl;
    15991593                        }
     1594
    16001595                    }
    16011596                }
    1602               else
     1597              /*
     1598               * This is for checking point-angle and presence of Candidates in Ball, currently we are checking the ball Angle.
     1599               *
     1600                else
    16031601                {
    1604                   if (sign>0 && AngleCheck.Angle(OldNormal)>0 && Storage[0]<0)
     1602                  if (sign>0 && BallAngle>0 && Storage[0]<0)
    16051603                    {
    16061604                      cout << "Next better candidate is " << *Candidate << " with ";
    16071605                      Opt_Candidate = Candidate;
    16081606                      Storage[0] = sign;
    1609                       Storage[1] = AngleCheck.Angle(OldNormal);
     1607                      Storage[1] = BallAngle;
    16101608                      Opt_Mittelpunkt->CopyVector(&Mittelpunkt);
    16111609                      cout << "Angle is " << Storage[1] << ", Halbraum ist "
    16121610                      << Storage[0] << endl;
    16131611
    1614 /*
     1612//Debugging purposes only
    16151613                      cout << "Umkreismittelpunkt has coordinates" << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] <<" "<<Umkreismittelpunkt.x[2] << endl;
    1616                                     cout << "Candidate has coordinates" << Candidate->x.x[0]<< " " << Candidate->x.x[1] << " " << Candidate->x.x[2] << endl;
    1617                                     cout << "a has coordinates" << a->x.x[0]<< " " << a->x.x[1] << " " << a->x.x[2] << endl;
    1618                                     cout << "b has coordinates" << b->x.x[0]<< " " << b->x.x[1] << " " << b->x.x[2] << endl;
    1619                                     cout << "Mittelpunkt has coordinates" << Mittelpunkt.x[0] << " " << Mittelpunkt.x[1]<< " "  <<Mittelpunkt.x[2] << endl;
    1620                                     cout << "Umkreisradius ist " << Umkreisradius << endl;
    1621                                     cout << "Restradius ist " << Restradius << endl;
    1622                                     cout << "TempNormal has coordinates " << TempNormal.x[0] << " " << TempNormal.x[1] << " " << TempNormal.x[2] << " " << endl;
    1623                                     cout << "OldNormal has coordinates " << OldNormal->x[0] << " " << OldNormal->x[1] << " " << OldNormal->x[2] << " " << endl;
    1624                                     cout << "Dist a to UmkreisMittelpunkt " << a->x.Distance(&Umkreismittelpunkt) << endl;
    1625                                     cout << "Dist b to UmkreisMittelpunkt " << b->x.Distance(&Umkreismittelpunkt) << endl;
    1626                                     cout << "Dist Candidate to UmkreisMittelpunkt " << Candidate->x.Distance(&Umkreismittelpunkt) << endl;
    1627                                     cout << "Dist a to Mittelpunkt " << a->x.Distance(&Mittelpunkt) << endl;
    1628                                     cout << "Dist b to Mittelpunkt " << b->x.Distance(&Mittelpunkt) << endl;
    1629                                     cout << "Dist Candidate to Mittelpunkt " << Candidate->x.Distance(&Mittelpunkt) << endl;
    1630                                     */
     1614                      cout << "Candidate has coordinates" << Candidate->x.x[0]<< " " << Candidate->x.x[1] << " " << Candidate->x.x[2] << endl;
     1615                      cout << "a has coordinates" << a->x.x[0]<< " " << a->x.x[1] << " " << a->x.x[2] << endl;
     1616                      cout << "b has coordinates" << b->x.x[0]<< " " << b->x.x[1] << " " << b->x.x[2] << endl;
     1617                      cout << "Mittelpunkt has coordinates" << Mittelpunkt.x[0] << " " << Mittelpunkt.x[1]<< " "  <<Mittelpunkt.x[2] << endl;
     1618                      cout << "Umkreisradius ist " << Umkreisradius << endl;
     1619                      cout << "Restradius ist " << Restradius << endl;
     1620                      cout << "TempNormal has coordinates " << TempNormal.x[0] << " " << TempNormal.x[1] << " " << TempNormal.x[2] << " " << endl;
     1621                      cout << "OldNormal has coordinates " << OldNormal->x[0] << " " << OldNormal->x[1] << " " << OldNormal->x[2] << " " << endl;
     1622                      cout << "Dist a to UmkreisMittelpunkt " << a->x.Distance(&Umkreismittelpunkt) << endl;
     1623                      cout << "Dist b to UmkreisMittelpunkt " << b->x.Distance(&Umkreismittelpunkt) << endl;
     1624                      cout << "Dist Candidate to UmkreisMittelpunkt " << Candidate->x.Distance(&Umkreismittelpunkt) << endl;
     1625                      cout << "Dist a to Mittelpunkt " << a->x.Distance(&Mittelpunkt) << endl;
     1626                      cout << "Dist b to Mittelpunkt " << b->x.Distance(&Mittelpunkt) << endl;
     1627                      cout << "Dist Candidate to Mittelpunkt " << Candidate->x.Distance(&Mittelpunkt) << endl;
     1628
    16311629
    16321630
     
    16381636                    }
    16391637                }
     1638                */
    16401639            }
    16411640        }
     
    17281727  Chord.SubtractVector(&(Line.endpoints[1]->node->x));
    17291728
     1729  {
     1730    Vector TempNormal, Umkreismittelpunkt, Mittelpunkt;
     1731    double alpha, beta, gamma, SideA, SideB, SideC, sign, Umkreisradius, Restradius, Distance;
     1732
     1733    SideA = dif_b.Norm();
     1734      SideB = dif_a.Norm();
     1735      SideC = Chord->Norm();
     1736      //Chord->Scale(-1);
     1737
     1738      alpha = Chord->Angle(&dif_a);
     1739      beta = M_PI - Chord->Angle(&dif_b);
     1740      gamma = dif_a.Angle(&dif_b);
     1741
     1742      Umkreismittelpunkt = (a->x) * sin(2.*alpha) + b->x * sin(2.*beta) + (Candidate->x) * sin(2.*gamma) ;
     1743      Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));
     1744  }
    17301745  cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl;
    17311746
Note: See TracChangeset for help on using the changeset viewer.