source: src/Tesselation/CandidateForTesselation.cpp@ 2a0271

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
Last change on this file since 2a0271 was 0aa122, checked in by Frederik Heber <heber@…>, 13 years ago

Updated all source files's copyright note to current year 2012.

  • Property mode set to 100644
File size: 7.0 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * CandidateForTesselation.cpp
10 *
11 * Created on: Jul 29, 2010
12 * Author: heber
13 */
14
15// include config.h
16#ifdef HAVE_CONFIG_H
17#include <config.h>
18#endif
19
20#include "CodePatterns/MemDebug.hpp"
21
22#include "CandidateForTesselation.hpp"
23
24#include <iostream>
25#include <iomanip>
26
27#include "BoundaryLineSet.hpp"
28#include "BoundaryPointSet.hpp"
29#include "Atom/TesselPoint.hpp"
30
31#include "CodePatterns/Assert.hpp"
32#include "CodePatterns/Info.hpp"
33#include "CodePatterns/Log.hpp"
34#include "LinearAlgebra/Vector.hpp"
35#include "LinkedCell/linkedcell.hpp"
36
37using namespace std;
38
39
40const double CandidateForTesselation::HULLEPSILON = 1e-9;
41
42
43/** Constructor of class CandidateForTesselation.
44 */
45CandidateForTesselation::CandidateForTesselation(BoundaryLineSet* line) :
46 BaseLine(line),
47 ThirdPoint(NULL),
48 T(NULL),
49 ShortestAngle(2. * M_PI),
50 OtherShortestAngle(2. * M_PI)
51{
52 Info FunctionInfo(__func__);
53}
54;
55
56/** Constructor of class CandidateForTesselation.
57 */
58CandidateForTesselation::CandidateForTesselation(TesselPoint *candidate, BoundaryLineSet* line, BoundaryPointSet* point, const Vector &OptCandidateCenter, const Vector &OtherOptCandidateCenter) :
59 BaseLine(line),
60 ThirdPoint(point),
61 T(NULL),
62 OptCenter(OptCandidateCenter),
63 OtherOptCenter(OtherOptCandidateCenter),
64 ShortestAngle(2. * M_PI),
65 OtherShortestAngle(2. * M_PI)
66{
67 Info FunctionInfo(__func__);
68};
69
70
71/** Destructor for class CandidateForTesselation.
72 */
73CandidateForTesselation::~CandidateForTesselation()
74{
75}
76;
77
78/** Checks validity of a given sphere of a candidate line.
79 * Sphere must touch all candidates and the baseline endpoints and there must be no other atoms inside.
80 * \param RADIUS radius of sphere
81 * \param *LC LinkedCell_deprecated structure with other atoms
82 * \return true - sphere is valid, false - sphere contains other points
83 */
84bool CandidateForTesselation::CheckValidity(const double RADIUS, const LinkedCell_deprecated *LC) const
85{
86 Info FunctionInfo(__func__);
87
88 const double radiusSquared = RADIUS * RADIUS;
89 list<const Vector *> VectorList;
90 VectorList.push_back(&OptCenter);
91 //VectorList.push_back(&OtherOptCenter); // don't check the other (wrong) center
92
93 if (!pointlist.empty())
94 LOG(1, "INFO: Checking whether sphere contains candidate list and baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ...");
95 else
96 LOG(1, "INFO: Checking whether sphere with no candidates contains baseline " << *BaseLine->endpoints[0] << "<->" << *BaseLine->endpoints[1] << " only ...");
97 // check baseline for OptCenter and OtherOptCenter being on sphere's surface
98 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
99 for (int i = 0; i < 2; i++) {
100 const double distance = fabs((*VRunner)->DistanceSquared(BaseLine->endpoints[i]->node->getPosition()) - radiusSquared);
101 if (distance > HULLEPSILON) {
102 ELOG(1, "Endpoint " << *BaseLine->endpoints[i] << " is out of sphere at " << *(*VRunner) << " by " << distance << ".");
103 return false;
104 }
105 }
106 }
107
108 // check Candidates for OptCenter and OtherOptCenter being on sphere's surface
109 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
110 const TesselPoint *Walker = *Runner;
111 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
112 const double distance = fabs((*VRunner)->DistanceSquared(Walker->getPosition()) - radiusSquared);
113 if (distance > HULLEPSILON) {
114 ELOG(1, "Candidate " << *Walker << " is out of sphere at " << *(*VRunner) << " by " << distance << ".");
115 return false;
116 } else {
117 LOG(1, "Candidate " << *Walker << " is inside by " << distance << ".");
118 }
119 }
120 }
121
122 LOG(1, "INFO: Checking whether sphere contains no others points ...");
123 bool flag = true;
124 for (list<const Vector *>::const_iterator VRunner = VectorList.begin(); VRunner != VectorList.end(); ++VRunner) {
125 // get all points inside the sphere
126 TesselPointList *ListofPoints = LC->GetPointsInsideSphere(RADIUS, (*VRunner));
127
128 LOG(1, "The following atoms are inside sphere at " << (*VRunner) << ":");
129 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
130 LOG(1, " " << *(*Runner) << " with distance " << (*Runner)->distance(*(*VRunner)) << ".");
131
132 // remove baseline's endpoints and candidates
133 for (int i = 0; i < 2; i++) {
134 LOG(1, "INFO: removing baseline tesselpoint " << *BaseLine->endpoints[i]->node << ".");
135 ListofPoints->remove(BaseLine->endpoints[i]->node);
136 }
137 for (TesselPointList::const_iterator Runner = pointlist.begin(); Runner != pointlist.end(); ++Runner) {
138 LOG(1, "INFO: removing candidate tesselpoint " << *(*Runner) << ".");
139 ListofPoints->remove(*Runner);
140 }
141 if (!ListofPoints->empty()) {
142 ELOG(1, "CheckValidity: There are still " << ListofPoints->size() << " points inside the sphere.");
143 flag = false;
144 ELOG(1, "External atoms inside of sphere at " << *(*VRunner) << ":");
145 for (TesselPointList::const_iterator Runner = ListofPoints->begin(); Runner != ListofPoints->end(); ++Runner)
146 ELOG(1, " " << *(*Runner) << " at distance " << setprecision(13) << (*Runner)->distance(*(*VRunner)) << setprecision(6) << ".");
147
148 // check with animate_sphere.tcl VMD script
149 if (ThirdPoint != NULL) {
150 ELOG(1, "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " " << ThirdPoint->Nr + 1 << " " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2));
151 } else {
152 ELOG(1, "Check by: ... missing third point ...");
153 ELOG(1, "Check by: animate_sphere 0 " << BaseLine->endpoints[0]->Nr + 1 << " " << BaseLine->endpoints[1]->Nr + 1 << " ??? " << RADIUS << " " << OldCenter[0] << " " << OldCenter[1] << " " << OldCenter[2] << " " << (*VRunner)->at(0) << " " << (*VRunner)->at(1) << " " << (*VRunner)->at(2));
154 }
155 }
156 delete (ListofPoints);
157
158 }
159 return flag;
160}
161;
162
163/** output operator for CandidateForTesselation.
164 * \param &ost output stream
165 * \param &a boundary line
166 */
167ostream & operator <<(ostream &ost, const CandidateForTesselation &a)
168{
169 ost << "[" << a.BaseLine->Nr << "|" << a.BaseLine->endpoints[0]->node->getName() << "," << a.BaseLine->endpoints[1]->node->getName() << "] with ";
170 if (a.pointlist.empty())
171 ost << "no candidate.";
172 else {
173 ost << "candidate";
174 if (a.pointlist.size() != 1)
175 ost << "s ";
176 else
177 ost << " ";
178 for (TesselPointList::const_iterator Runner = a.pointlist.begin(); Runner != a.pointlist.end(); Runner++)
179 ost << *(*Runner) << " ";
180 ost << " at angle " << (a.ShortestAngle) << ".";
181 }
182
183 return ost;
184}
185;
186
Note: See TracBrowser for help on using the repository browser.