source: src/Graph/BondGraph.cpp@ b4f72c

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 b4f72c was 94d5ac6, checked in by Frederik Heber <heber@…>, 12 years ago

FIX: As we use GSL internally, we are as of now required to use GPL v2 license.

  • GNU Scientific Library is used at every place in the code, especially the sub-package LinearAlgebra is based on it which in turn is used really everywhere in the remainder of MoleCuilder. Hence, we have to use the GPL license for the whole of MoleCuilder. In effect, GPL's COPYING was present all along and stated the terms of the GPL v2 license.
  • Hence, I added the default GPL v2 disclaimer to every source file and removed the note about a (actually missing) LICENSE file.
  • also, I added a help-redistribute action which again gives the disclaimer of the GPL v2.
  • also, I changed in the disclaimer that is printed at every program start in builder_init.cpp.
  • TEST: Added check on GPL statement present in every module to test CodeChecks project-disclaimer.
  • Property mode set to 100644
File size: 6.8 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 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * bondgraph.cpp
25 *
26 * Created on: Oct 29, 2009
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#include "CodePatterns/MemDebug.hpp"
36
37#include <iostream>
38
39#include "Atom/atom.hpp"
40#include "Bond/bond.hpp"
41#include "Graph/BondGraph.hpp"
42#include "Box.hpp"
43#include "Element/element.hpp"
44#include "CodePatterns/Info.hpp"
45#include "CodePatterns/Log.hpp"
46#include "CodePatterns/Range.hpp"
47#include "CodePatterns/Verbose.hpp"
48#include "molecule.hpp"
49#include "Element/periodentafel.hpp"
50#include "Fragmentation/MatrixContainer.hpp"
51#include "LinearAlgebra/Vector.hpp"
52#include "World.hpp"
53#include "WorldTime.hpp"
54
55const double BondGraph::BondThreshold = 0.4; //!< CSD threshold in bond check which is the width of the interval whose center is the sum of the covalent radii
56
57BondGraph::BondGraph() :
58 BondLengthMatrix(NULL),
59 IsAngstroem(true)
60{}
61
62BondGraph::BondGraph(bool IsA) :
63 BondLengthMatrix(NULL),
64 IsAngstroem(IsA)
65{}
66
67BondGraph::~BondGraph()
68{
69 CleanupBondLengthTable();
70}
71
72void BondGraph::CleanupBondLengthTable()
73{
74 if (BondLengthMatrix != NULL) {
75 delete(BondLengthMatrix);
76 }
77}
78
79bool BondGraph::LoadBondLengthTable(
80 std::istream &input)
81{
82 Info FunctionInfo(__func__);
83 bool status = true;
84 MatrixContainer *TempContainer = NULL;
85
86 // allocate MatrixContainer
87 if (BondLengthMatrix != NULL) {
88 LOG(1, "MatrixContainer for Bond length already present, removing.");
89 delete(BondLengthMatrix);
90 BondLengthMatrix = NULL;
91 }
92 TempContainer = new MatrixContainer;
93
94 // parse in matrix
95 if ((input.good()) && (status = TempContainer->ParseMatrix(input, 0, 1, 0))) {
96 LOG(1, "Parsing bond length matrix successful.");
97 } else {
98 ELOG(1, "Parsing bond length matrix failed.");
99 status = false;
100 }
101
102 if (status) // set to not NULL only if matrix was parsed
103 BondLengthMatrix = TempContainer;
104 else {
105 BondLengthMatrix = NULL;
106 delete(TempContainer);
107 }
108 return status;
109}
110
111double BondGraph::GetBondLength(
112 int firstZ,
113 int secondZ) const
114{
115 double return_length;
116 if ((firstZ < 0) || (firstZ >= (int)BondLengthMatrix->Matrix[0].size()))
117 return -1.;
118 if ((secondZ < 0) || (secondZ >= (int)BondLengthMatrix->Matrix[0][firstZ].size()))
119 return -1.;
120 if (BondLengthMatrix == NULL) {
121 return_length = -1.;
122 } else {
123 return_length = BondLengthMatrix->Matrix[0][firstZ][secondZ];
124 }
125 LOG(4, "INFO: Request for length between " << firstZ << " and "
126 << secondZ << ": " << return_length << ".");
127 return return_length;
128}
129
130range<double> BondGraph::CovalentMinMaxDistance(
131 const element * const Walker,
132 const element * const OtherWalker) const
133{
134 range<double> MinMaxDistance(0.,0.);
135 MinMaxDistance.first = OtherWalker->getCovalentRadius() + Walker->getCovalentRadius();
136 MinMaxDistance.first *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
137 MinMaxDistance.last = MinMaxDistance.first + BondThreshold;
138 MinMaxDistance.first -= BondThreshold;
139 return MinMaxDistance;
140}
141
142range<double> BondGraph::BondLengthMatrixMinMaxDistance(
143 const element * const Walker,
144 const element * const OtherWalker) const
145{
146 ASSERT(BondLengthMatrix, "BondGraph::BondLengthMatrixMinMaxDistance() called without NULL BondLengthMatrix.");
147 ASSERT(Walker, "BondGraph::BondLengthMatrixMinMaxDistance() - illegal element given.");
148 ASSERT(OtherWalker, "BondGraph::BondLengthMatrixMinMaxDistance() - illegal other element given.");
149 range<double> MinMaxDistance(0.,0.);
150 MinMaxDistance.first = GetBondLength(Walker->getAtomicNumber()-1, OtherWalker->getAtomicNumber()-1);
151 MinMaxDistance.first *= (IsAngstroem) ? 1. : 1. / AtomicLengthToAngstroem;
152 MinMaxDistance.last = MinMaxDistance.first + BondThreshold;
153 MinMaxDistance.first -= BondThreshold;
154 return MinMaxDistance;
155}
156
157range<double> BondGraph::getMinMaxDistance(
158 const element * const Walker,
159 const element * const OtherWalker) const
160{
161 range<double> MinMaxDistance(0.,0.);
162 if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet
163 LOG(2, "INFO: Using Covalent radii criterion for [min,max) distances.");
164 MinMaxDistance = CovalentMinMaxDistance(Walker, OtherWalker);
165 } else {
166 LOG(2, "INFO: Using Covalent radii criterion for [min,max) distances.");
167 MinMaxDistance = BondLengthMatrixMinMaxDistance(Walker, OtherWalker);
168 }
169 return MinMaxDistance;
170}
171
172range<double> BondGraph::getMinMaxDistance(
173 const BondedParticle * const Walker,
174 const BondedParticle * const OtherWalker) const
175{
176 return getMinMaxDistance(Walker->getType(), OtherWalker->getType());
177}
178
179range<double> BondGraph::getMinMaxDistanceSquared(
180 const BondedParticle * const Walker,
181 const BondedParticle * const OtherWalker) const
182{
183 // use non-squared version
184 range<double> MinMaxDistance(getMinMaxDistance(Walker, OtherWalker));
185 // and square
186 MinMaxDistance.first *= MinMaxDistance.first;
187 MinMaxDistance.last *= MinMaxDistance.last;
188 return MinMaxDistance;
189}
190
191LinkedCell::LinkedCell_View BondGraph::getLinkedCell(const double max_distance) const
192{
193 return World::getInstance().getLinkedCell(max_distance);
194}
195
196std::set< const element *> BondGraph::getElementSetFromNumbers(const std::set<atomicNumber_t> &Set) const
197{
198 std::set< const element *> PresentElements;
199 for(std::set<atomicNumber_t>::const_iterator iter = Set.begin(); iter != Set.end(); ++iter)
200 PresentElements.insert( World::getInstance().getPeriode()->FindElement(*iter) );
201 return PresentElements;
202}
203
204Box &BondGraph::getDomain() const
205{
206 return World::getInstance().getDomain();
207}
208
209unsigned int BondGraph::getTime() const
210{
211 return WorldTime::getTime();
212}
213
214bool BondGraph::operator==(const BondGraph &other) const
215{
216 if (IsAngstroem != other.IsAngstroem)
217 return false;
218 if (((BondLengthMatrix != NULL) && (other.BondLengthMatrix == NULL))
219 || ((BondLengthMatrix == NULL) && (other.BondLengthMatrix != NULL)))
220 return false;
221 if ((BondLengthMatrix != NULL) && (other.BondLengthMatrix != NULL))
222 if (*BondLengthMatrix != *other.BondLengthMatrix)
223 return false;
224 return true;
225}
Note: See TracBrowser for help on using the repository browser.