Changes in src/molecule.cpp [906822:c550dd]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r906822 rc550dd 9 9 #include <cstring> 10 10 #include <boost/bind.hpp> 11 #include <boost/foreach.hpp> 11 12 12 13 #include "World.hpp" … … 27 28 #include "tesselation.hpp" 28 29 #include "vector.hpp" 30 #include "Matrix.hpp" 29 31 #include "World.hpp" 32 #include "Box.hpp" 30 33 #include "Plane.hpp" 31 34 #include "Exceptions/LinearDependenceException.hpp" … … 79 82 void molecule::setName(const std::string _name){ 80 83 OBSERVE; 84 cout << "Set name of molecule " << getId() << " to " << _name << endl; 81 85 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 82 86 } … … 283 287 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 284 288 Vector InBondvector; // vector in direction of *Bond 285 double *matrix = NULL;289 const Matrix &matrix = World::getInstance().getDomain().getM(); 286 290 bond *Binder = NULL; 287 double * const cell_size = World::getInstance().getDomain();288 291 289 292 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 306 309 } // (signs are correct, was tested!) 307 310 } 308 matrix = ReturnFullMatrixforSymmetric(cell_size); 309 Orthovector1.MatrixMultiplication(matrix); 311 Orthovector1 *= matrix; 310 312 InBondvector -= Orthovector1; // subtract just the additional translation 311 delete[](matrix);312 313 bondlength = InBondvector.Norm(); 313 314 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 540 541 break; 541 542 } 542 delete[](matrix);543 543 544 544 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 659 659 * @param three vectors forming the matrix that defines the shape of the parallelpiped 660 660 */ 661 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {661 molecule* molecule::CopyMoleculeFromSubRegion(const Shape ®ion) const { 662 662 molecule *copy = World::getInstance().createMolecule(); 663 663 664 ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped ); 664 BOOST_FOREACH(atom *iter,atoms){ 665 if(iter->IsInShape(region)){ 666 copy->AddCopyAtom(iter); 667 } 668 } 665 669 666 670 //TODO: copy->BuildInducedSubgraph(this); … … 739 743 else 740 744 length = strlen(molname) - strlen(endname); 745 cout << "Set name of molecule " << getId() << " to " << molname << endl; 741 746 strncpy(name, molname, length); 742 747 name[length]='\0'; … … 748 753 void molecule::SetBoxDimension(Vector *dim) 749 754 { 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); 755 Matrix domain; 756 for(int i =0; i<NDIM;++i) 757 domain.at(i,i) = dim->at(i); 758 World::getInstance().setDomain(domain); 757 759 }; 758 760 … … 847 849 bool molecule::CheckBounds(const Vector *x) const 848 850 { 849 double * const cell_size = World::getInstance().getDomain();851 const Matrix &domain = World::getInstance().getDomain().getM(); 850 852 bool result = true; 851 int j =-1;852 853 for (int i=0;i<NDIM;i++) { 853 j += i+1; 854 result = result && ((x->at(i) >= 0) && (x->at(i) < cell_size[j])); 854 result = result && ((x->at(i) >= 0) && (x->at(i) < domain.at(i,i))); 855 855 } 856 856 //return result; … … 880 880 ElementNo[i] = current++; 881 881 } 882 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );882 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 883 883 return true; 884 884 } … … 1003 1003 for(int i=MAX_ELEMENTS;i--;) 1004 1004 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 1005 }; 1040 1006
Note:
See TracChangeset
for help on using the changeset viewer.