Changes in src/molecule.cpp [906822:aafd77]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r906822 raafd77 5 5 */ 6 6 7 #ifdef HAVE_CONFIG_H 8 #include <config.h> 9 #endif 10 7 11 #include "Helpers/MemDebug.hpp" 8 12 9 13 #include <cstring> 10 14 #include <boost/bind.hpp> 15 #include <boost/foreach.hpp> 16 17 #include <gsl/gsl_inline.h> 18 #include <gsl/gsl_heapsort.h> 11 19 12 20 #include "World.hpp" … … 22 30 #include "log.hpp" 23 31 #include "molecule.hpp" 24 #include "memoryallocator.hpp" 32 25 33 #include "periodentafel.hpp" 26 34 #include "stackclass.hpp" 27 35 #include "tesselation.hpp" 28 36 #include "vector.hpp" 37 #include "Matrix.hpp" 29 38 #include "World.hpp" 39 #include "Box.hpp" 30 40 #include "Plane.hpp" 31 41 #include "Exceptions/LinearDependenceException.hpp" … … 79 89 void molecule::setName(const std::string _name){ 80 90 OBSERVE; 91 cout << "Set name of molecule " << getId() << " to " << _name << endl; 81 92 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 82 93 } … … 283 294 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 284 295 Vector InBondvector; // vector in direction of *Bond 285 double *matrix = NULL;296 const Matrix &matrix = World::getInstance().getDomain().getM(); 286 297 bond *Binder = NULL; 287 double * const cell_size = World::getInstance().getDomain();288 298 289 299 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 306 316 } // (signs are correct, was tested!) 307 317 } 308 matrix = ReturnFullMatrixforSymmetric(cell_size); 309 Orthovector1.MatrixMultiplication(matrix); 318 Orthovector1 *= matrix; 310 319 InBondvector -= Orthovector1; // subtract just the additional translation 311 delete[](matrix);312 320 bondlength = InBondvector.Norm(); 313 321 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 540 548 break; 541 549 } 542 delete[](matrix);543 550 544 551 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 659 666 * @param three vectors forming the matrix that defines the shape of the parallelpiped 660 667 */ 661 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {668 molecule* molecule::CopyMoleculeFromSubRegion(const Shape ®ion) const { 662 669 molecule *copy = World::getInstance().createMolecule(); 663 670 664 ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped ); 671 BOOST_FOREACH(atom *iter,atoms){ 672 if(iter->IsInShape(region)){ 673 copy->AddCopyAtom(iter); 674 } 675 } 665 676 666 677 //TODO: copy->BuildInducedSubgraph(this); … … 739 750 else 740 751 length = strlen(molname) - strlen(endname); 752 cout << "Set name of molecule " << getId() << " to " << molname << endl; 741 753 strncpy(name, molname, length); 742 754 name[length]='\0'; … … 748 760 void molecule::SetBoxDimension(Vector *dim) 749 761 { 750 double * const cell_size = World::getInstance().getDomain(); 751 cell_size[0] = dim->at(0); 752 cell_size[1] = 0.; 753 cell_size[2] = dim->at(1); 754 cell_size[3] = 0.; 755 cell_size[4] = 0.; 756 cell_size[5] = dim->at(2); 762 Matrix domain; 763 for(int i =0; i<NDIM;++i) 764 domain.at(i,i) = dim->at(i); 765 World::getInstance().setDomain(domain); 757 766 }; 758 767 … … 847 856 bool molecule::CheckBounds(const Vector *x) const 848 857 { 849 double * const cell_size = World::getInstance().getDomain();858 const Matrix &domain = World::getInstance().getDomain().getM(); 850 859 bool result = true; 851 int j =-1;852 860 for (int i=0;i<NDIM;i++) { 853 j += i+1; 854 result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j])); 861 result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i))); 855 862 } 856 863 //return result; … … 880 887 ElementNo[i] = current++; 881 888 } 882 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );889 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 883 890 return true; 884 891 } … … 1003 1010 for(int i=MAX_ELEMENTS;i--;) 1004 1011 ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0); 1005 };1006 1007 1008 /** Counts necessary number of valence electrons and returns number and SpinType.1009 * \param configuration containing everything1010 */1011 void molecule::CalculateOrbitals(class config &configuration)1012 {1013 configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;1014 for(int i=MAX_ELEMENTS;i--;) {1015 if (ElementsInMolecule[i] != 0) {1016 //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl;1017 configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);1018 }1019 }1020 configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);1021 configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;1022 configuration.MaxPsiDouble /= 2;1023 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;1024 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {1025 configuration.ProcPEGamma /= 2;1026 configuration.ProcPEPsi *= 2;1027 } else {1028 configuration.ProcPEGamma *= configuration.ProcPEPsi;1029 configuration.ProcPEPsi = 1;1030 }1031 cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl;1032 if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) {1033 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown;1034 cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl;1035 } else {1036 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp;1037 cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl;1038 }1039 1012 }; 1040 1013
Note:
See TracChangeset
for help on using the changeset viewer.