Changeset 196a5a
- Timestamp:
- Dec 23, 2008, 11:21:29 AM (16 years ago)
- 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:
- 02bfde
- Parents:
- 7c6712
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r7c6712 r196a5a 1422 1422 * @param c vector third point of triangle 1423 1423 * @param Direction vector indicates up/down 1424 * @param AlternativeDirection vecotr, needed in case the triangles have 90 deg angle 1424 1425 * @param Halfplaneindicator double indicates whether Direction is up or down 1426 * @param AlternativeIndicator doube indicates in case of orthogonal triangles which direction of AlternativeDirection is suitable 1425 1427 * @param alpha double angle at a 1426 1428 * @param beta double, angle at b … … 1430 1432 */ 1431 1433 1432 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector* Direction, double HalfplaneIndicator,1433 double alpha, double beta, double gamma, double RADIUS, double Umkreisradius)1434 void Get_center_of_sphere(Vector* Center, Vector a, Vector b, Vector c, Vector* Direction, Vector* AlternativeDirection, 1435 double HalfplaneIndicator, double AlternativeIndicator, double alpha, double beta, double gamma, double RADIUS, double Umkreisradius) 1434 1436 { 1435 1437 Vector TempNormal, helper; … … 1437 1439 1438 1440 *Center = a * sin(2.*alpha) + b * sin(2.*beta) + c * sin(2.*gamma) ; 1439 Center->Scale(1 /(sin(2*alpha) + sin(2*beta) + sin(2*gamma)));1441 Center->Scale(1./(sin(2.*alpha) + sin(2.*beta) + sin(2.*gamma))); 1440 1442 // Here we calculated center of circumscribing circle, using barycentric coordinates 1441 1443 … … 1445 1447 helper.SubtractVector(&c); 1446 1448 TempNormal.VectorProduct(&helper); 1447 if ( TempNormal.ScalarProduct(Direction)<0 && HalfplaneIndicator >0 || TempNormal.ScalarProduct(Direction)>0 && HalfplaneIndicator<0)1449 if (fabs(HalfplaneIndicator) < MYEPSILON) 1448 1450 { 1449 TempNormal.Scale(-1); 1451 if ((TempNormal.ScalarProduct(AlternativeDirection) <0 and AlternativeIndicator >0) or (TempNormal.ScalarProduct(AlternativeDirection) >0 and AlternativeIndicator <0)) 1452 { 1453 TempNormal.Scale(-1); 1454 } 1455 } 1456 else 1457 { 1458 if (TempNormal.ScalarProduct(Direction)<0 && HalfplaneIndicator >0 || TempNormal.ScalarProduct(Direction)>0 && HalfplaneIndicator<0) 1459 { 1460 TempNormal.Scale(-1); 1461 } 1450 1462 } 1451 1463 … … 1469 1481 * @param a first point 1470 1482 * @param b second point 1483 * *param c atom old third point of old triangle 1471 1484 * @param Candidate base point along whose bonds to start looking from 1472 1485 * @param Parent point to avoid during search as its wrong direction … … 1482 1495 */ 1483 1496 1484 void Find_next_suitable_point_via_Angle_of_Sphere(atom* a, atom* b, atom* Candidate, atom* Parent,1497 void Find_next_suitable_point_via_Angle_of_Sphere(atom* a, atom* b, atom* c, atom* Candidate, atom* Parent, 1485 1498 int RecursionLevel, Vector *Chord, Vector *direction1, Vector *OldNormal, Vector ReferencePoint, 1486 1499 atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol) 1487 1500 { 1488 1489 cout << Verbose(1) << "Candidate is "<< Candidate->nr << endl; 1490 cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl; 1501 //cout << "ReferencePoint is " << ReferencePoint.x[0] << " "<< ReferencePoint.x[1] << " "<< ReferencePoint.x[2] << " "<< endl; 1491 1502 /* OldNormal is normal vector on the old triangle 1492 1503 * direction1 is normal on the triangle line, from which we come, as well as on OldNormal. … … 1501 1512 double CurrentEpsilon = 0.1; 1502 1513 double alpha, beta, gamma, SideA, SideB, SideC, sign, Umkreisradius, Restradius, Distance; 1503 double BallAngle ;1514 double BallAngle, AlternativeSign; 1504 1515 atom *Walker; // variable atom point 1505 1516 … … 1522 1533 gamma = dif_a.Angle(&dif_b); 1523 1534 1524 if (a != Candidate and b != Candidate) 1535 1536 if (a != Candidate and b != Candidate and c != Candidate) 1525 1537 { 1526 1538 … … 1532 1544 if (Umkreisradius < RADIUS) //Checking whether ball will at least rest on points. 1533 1545 { 1546 cout << Verbose(1) << "Candidate is "<< *Candidate << endl; 1534 1547 sign = AngleCheck.ScalarProduct(direction1); 1535 sign /= fabs(sign); // +1 if in direction of triangle plane, -1 if in other direction... 1536 1537 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, sign, alpha, beta, gamma, RADIUS, Umkreisradius); 1548 if (fabs(sign)<MYEPSILON) 1549 { 1550 if (AngleCheck.ScalarProduct(OldNormal)<0) 1551 { 1552 sign =0; 1553 AlternativeSign=1; 1554 } 1555 else 1556 { 1557 sign =0; 1558 AlternativeSign=-1; 1559 } 1560 } 1561 else 1562 { 1563 sign /= fabs(sign); 1564 } 1565 1566 1567 1568 Get_center_of_sphere(&Mittelpunkt, (a->x), (b->x), (Candidate->x), OldNormal, direction1, sign, AlternativeSign, alpha, beta, gamma, RADIUS, Umkreisradius); 1538 1569 1539 1570 AngleCheck.CopyVector(&ReferencePoint); 1540 1571 AngleCheck.Scale(-1); 1541 cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;1572 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1542 1573 AngleCheck.AddVector(&Mittelpunkt); 1543 cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;1574 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1544 1575 1545 1576 BallAngle = AngleCheck.Angle(OldNormal); 1546 cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl; 1547 cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl;1548 sign = AngleCheck.ScalarProduct(direction1);1549 sign /= fabs(sign); 1550 1551 1552 if ( sign >0)1577 1578 //cout << "direction1 is " << direction1->x[0] <<" "<< direction1->x[1] <<" "<< direction1->x[2] <<" " << endl; 1579 //cout << "AngleCheck is " << AngleCheck.x[0] << " "<< AngleCheck.x[1] << " "<< AngleCheck.x[2] << " "<< endl; 1580 1581 cout << Verbose(1) << "BallAngle is " << BallAngle << " Sign is " << sign << endl; 1582 1583 if (AngleCheck.ScalarProduct(direction1) >=0) 1553 1584 { 1554 1585 if (Storage[0]< -1.5) // first Candidate at all … … 1558 1589 Opt_Candidate = Candidate; 1559 1590 Storage[0] = sign; 1560 Storage[1] = BallAngle; 1561 cout << "Angle is " << Storage[1] << ", Halbraum ist " 1591 Storage[1] = AlternativeSign; 1592 Storage[2] = BallAngle; 1593 cout << "Angle is " << Storage[2] << ", Halbraum ist " 1562 1594 << Storage[0] << endl; 1563 1595 … … 1566 1598 else 1567 1599 { 1568 if ( Storage[ 1] > BallAngle)1600 if ( Storage[2] > BallAngle) 1569 1601 { 1570 1602 cout << "Next better candidate is " << *Candidate << " with "; 1571 1603 Opt_Candidate = Candidate; 1572 1604 Storage[0] = sign; 1573 Storage[1] = BallAngle; 1574 cout << "Angle is " << Storage[1] << ", Halbraum ist " 1605 Storage[1] = AlternativeSign; 1606 Storage[2] = BallAngle; 1607 cout << "Angle is " << Storage[2] << ", Halbraum ist " 1575 1608 << Storage[0] << endl; 1576 1609 } 1577 1610 else 1578 1611 { 1579 if (DEBUG) 1580 { 1581 cout << "Looses to better candidate" << endl; 1582 } 1612 //if (DEBUG) 1613 cout << "Looses to better candidate" << endl; 1614 1583 1615 } 1584 1616 } … … 1586 1618 else 1587 1619 { 1588 cout << "Refused due to sign which is " << sign << endl; 1620 //if (DEBUG) 1621 cout << "Refused due to bad direction of ball centre." << endl; 1589 1622 } 1590 1623 } 1591 1624 else 1592 1625 { 1593 if (DEBUG) 1594 { 1595 cout << "Doesn't satisfy requirements for circumscribing circle" << endl; 1596 } 1626 //if (DEBUG) 1627 cout << "Doesn't satisfy requirements for circumscribing circle" << endl; 1597 1628 } 1598 1629 } 1599 1630 else 1600 1631 { 1601 if (DEBUG) 1602 { 1603 cout << "identisch mit Ursprungslinie" << endl; 1604 } 1632 //if (DEBUG) 1633 cout << "identisch mit Ursprungslinie" << endl; 1634 1605 1635 } 1606 1636 1607 1637 1608 1638 1609 if (RecursionLevel < 7) // Fiveis the recursion level threshold.1639 if (RecursionLevel < 9) // Seven is the recursion level threshold. 1610 1640 { 1611 1641 for (int i = 0; i < mol->NumberOfBondsPerAtom[Candidate->nr]; i++) // go through all bond … … 1619 1649 else 1620 1650 { 1621 Find_next_suitable_point_via_Angle_of_Sphere(a, b, Walker, Candidate, RecursionLevel1651 Find_next_suitable_point_via_Angle_of_Sphere(a, b, c, Walker, Candidate, RecursionLevel 1622 1652 + 1, Chord, direction1, OldNormal, ReferencePoint, Opt_Candidate, Storage, RADIUS, 1623 1653 mol); //call function again … … 1910 1940 ofstream *tempstream = NULL; 1911 1941 char filename[255]; 1912 //atom* Walker;1913 1914 double Storage[ 2];1942 atom* OldThirdPoint; 1943 1944 double Storage[3]; 1915 1945 Storage[0] = -2.; // This direction is either +1 or -1 one, so any result will take precedence over initial values 1916 Storage[1] = 9999999.; // This is also lower then any value produced by an eligible atom, which are all positive 1946 Storage[1] = -2.; // This is also lower then any value produced by an eligible atom, which are all positive 1947 Storage[2] = 9999999.; 1917 1948 atom* Opt_Candidate = NULL; 1918 1949 Vector Opt_Mittelpunkt; … … 1925 1956 && T.endpoints[i]->node->nr != Line.endpoints[1]->node->nr) 1926 1957 { 1958 OldThirdPoint = T.endpoints[i]->node; 1927 1959 helper.SubtractVector(&T.endpoints[i]->node->x); 1928 1960 break; … … 1957 1989 1958 1990 Umkreismittelpunkt = (T.endpoints[0]->node->x) * sin(2.*alpha) + T.endpoints[1]->node->x * sin(2.*beta) + (T.endpoints[2]->node->x) * sin(2.*gamma) ; 1959 cout << "UmkreisMittelpunkt is " << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] << " "<< Umkreismittelpunkt.x[2] << " "<< endl;1991 //cout << "UmkreisMittelpunkt is " << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] << " "<< Umkreismittelpunkt.x[2] << " "<< endl; 1960 1992 Umkreismittelpunkt.Scale(1/(sin(2*alpha) + sin(2*beta) + sin(2*gamma))); 1961 1993 cout << "UmkreisMittelpunkt is " << Umkreismittelpunkt.x[0] << " "<< Umkreismittelpunkt.x[1] << " "<< Umkreismittelpunkt.x[2] << " "<< endl; 1994 cout << " We look over line " << Line << " in direction " << direction1.x[0] << " " << direction1.x[1] << " " << direction1.x[2] << " " << endl; 1995 cout << " Old Normal is " << (T.NormalVector.x)[0] << " " << T.NormalVector.x[1] << " " << (T.NormalVector.x)[2] << " " << endl; 1962 1996 1963 1997 1964 1998 cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl; 1965 1999 1966 Find_next_suitable_point_via_Angle_of_Sphere(Line.endpoints[0]->node, Line.endpoints[1]->node, 2000 Find_next_suitable_point_via_Angle_of_Sphere(Line.endpoints[0]->node, Line.endpoints[1]->node, OldThirdPoint, 1967 2001 Line.endpoints[0]->node, Line.endpoints[1]->node, 0, &Chord, &direction1, 1968 2002 &(T.NormalVector), Umkreismittelpunkt, Opt_Candidate, Storage, RADIUS, mol); 1969 Find_next_suitable_point_via_Angle_of_Sphere(Line.endpoints[0]->node, Line.endpoints[1]->node, 2003 Find_next_suitable_point_via_Angle_of_Sphere(Line.endpoints[0]->node, Line.endpoints[1]->node, OldThirdPoint, 1970 2004 Line.endpoints[1]->node, Line.endpoints[0]->node, 0, &Chord, &direction1, 1971 2005 &(T.NormalVector), Umkreismittelpunkt, Opt_Candidate, Storage, RADIUS, mol); 1972 2006 1973 2007 1974 if ((TrianglesOnBoundaryCount % 10) == 0) 2008 cout << "Letzter Winkel bei " << TrianglesOnBoundaryCount << " Winkel ist " << Storage[2] << endl; 2009 2010 2011 if ((TrianglesOnBoundaryCount % 1) == 0) 1975 2012 { 1976 2013 sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten); … … 1982 2019 } 1983 2020 1984 if (TrianglesOnBoundaryCount >1 000 )2021 if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 ) 1985 2022 { 1986 2023 cout << Verbose(1) … … 2010 2047 2011 2048 if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector)) < 0 && Storage[0] > 0) || 2012 (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0)) 2049 (BTS->NormalVector.ScalarProduct(&(T.NormalVector)) > 0 && Storage[0] < 0) || 2050 (fabs(Storage[0]) < MYEPSILON && Storage[1]*BTS->NormalVector.ScalarProduct(&direction1) < 0) ) 2051 2013 2052 { 2014 2053 BTS->NormalVector.Scale(-1); … … 2019 2058 2020 2059 void Find_second_point_for_Tesselation(atom* a, atom* Candidate, atom* Parent, 2021 int RecursionLevel, Vector Oben, atom*& Opt_Candidate, double Storage[ 2],2060 int RecursionLevel, Vector Oben, atom*& Opt_Candidate, double Storage[3], 2022 2061 molecule* mol, double RADIUS) 2023 2062 { … … 2041 2080 if (AngleCheck.Angle(&Oben) < Storage[0]) 2042 2081 { 2043 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[ 1]);2082 //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[2]); 2044 2083 cout << "Next better candidate is " << *Candidate 2045 2084 << " with distance " << norm << ".\n"; 2046 2085 Opt_Candidate = Candidate; 2047 2086 Storage[0] = AngleCheck.Angle(&Oben); 2048 //cout << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[ 1]);2087 //cout << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[2]); 2049 2088 } 2050 2089 else … … 2125 2164 cout << Verbose(1) << "Coordinates of start atom " << *FirstPoint << ": " 2126 2165 << FirstPoint->x.x[0] << endl; 2127 double Storage[ 2];2166 double Storage[3]; 2128 2167 atom* Opt_Candidate = NULL; 2129 2168 Storage[0] = 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. 2130 2169 Storage[1] = 999999.; // This will be an angle looking for the third point. 2170 Storage[2] = 999999.; 2131 2171 cout << Verbose(1) << "Number of Bonds: " 2132 2172 << mol->NumberOfBondsPerAtom[FirstPoint->nr] << endl; … … 2145 2185 Storage[0] = -2.; // This will indicate the quadrant. 2146 2186 Storage[1] = 9999999.; // This will be an angle looking for the third point. 2187 Storage[2] = 9999999.; 2147 2188 2148 2189 Chord.CopyVector(&(FirstPoint->x)); // bring into calling function … … 2151 2192 2152 2193 cout << Verbose(1) << "Looking for third point candidates \n"; 2194 cout << Verbose(1) << " In direction " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << " " << endl; 2153 2195 // look in one direction of baseline for initial candidate 2154 2196 Opt_Candidate = NULL; 2155 2197 CenterOfFirstLine.CopyVector(&Chord); 2156 CenterOfFirstLine.Scale( -0.5);2198 CenterOfFirstLine.Scale(0.5); 2157 2199 CenterOfFirstLine.AddVector(&(SecondPoint->x)); 2158 2200 2159 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, 0,2201 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, SecondPoint, FirstPoint, 0, 2160 2202 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); 2161 2203 // look in other direction of baseline for possible better candidate 2162 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, FirstPoint, SecondPoint, 0,2204 Find_next_suitable_point_via_Angle_of_Sphere(FirstPoint, SecondPoint, SecondPoint, FirstPoint, SecondPoint, 0, 2163 2205 &Chord, &helper, &Oben, CenterOfFirstLine, Opt_Candidate, Storage, RADIUS, mol); 2164 2206 cout << Verbose(1) << "Third Point is " << *Opt_Candidate << endl;
Note:
See TracChangeset
for help on using the changeset viewer.