Changes in src/molecule.cpp [274d45:84c494]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r274d45 r84c494 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 } … … 154 158 molecule::const_iterator molecule::erase( atom * key ) 155 159 { 156 cout << "trying to erase atom" << endl;157 160 molecule::const_iterator iter = find(key); 158 161 if (iter != end()){ … … 284 287 Vector Orthovector1, Orthovector2; // temporary vectors in coordination construction 285 288 Vector InBondvector; // vector in direction of *Bond 286 double *matrix = NULL;289 const Matrix &matrix = World::getInstance().getDomain().getM(); 287 290 bond *Binder = NULL; 288 double * const cell_size = World::getInstance().getDomain();289 291 290 292 // Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl; … … 307 309 } // (signs are correct, was tested!) 308 310 } 309 matrix = ReturnFullMatrixforSymmetric(cell_size); 310 Orthovector1.MatrixMultiplication(matrix); 311 Orthovector1 *= matrix; 311 312 InBondvector -= Orthovector1; // subtract just the additional translation 312 delete[](matrix);313 313 bondlength = InBondvector.Norm(); 314 314 // Log() << Verbose(4) << "Corrected InBondvector is now: "; … … 541 541 break; 542 542 } 543 delete[](matrix);544 543 545 544 // Log() << Verbose(3) << "End of AddHydrogenReplacementAtom." << endl; … … 660 659 * @param three vectors forming the matrix that defines the shape of the parallelpiped 661 660 */ 662 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const double *parallelepiped) const {661 molecule* molecule::CopyMoleculeFromSubRegion(const Vector offset, const Matrix ¶llelepiped) const { 663 662 molecule *copy = World::getInstance().createMolecule(); 664 663 665 ActOnCopyWithEachAtomIfTrue ( &molecule::AddCopyAtom, copy, &atom::IsInParallelepiped, offset, parallelepiped ); 664 BOOST_FOREACH(atom *iter,atoms){ 665 if(iter->IsInParallelepiped(offset,parallelepiped)){ 666 copy->AddCopyAtom(iter); 667 } 668 } 666 669 667 670 //TODO: copy->BuildInducedSubgraph(this); … … 740 743 else 741 744 length = strlen(molname) - strlen(endname); 745 cout << "Set name of molecule " << getId() << " to " << molname << endl; 742 746 strncpy(name, molname, length); 743 747 name[length]='\0'; … … 749 753 void molecule::SetBoxDimension(Vector *dim) 750 754 { 751 double * const cell_size = World::getInstance().getDomain(); 752 cell_size[0] = dim->at(0); 753 cell_size[1] = 0.; 754 cell_size[2] = dim->at(1); 755 cell_size[3] = 0.; 756 cell_size[4] = 0.; 757 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); 758 759 }; 759 760 … … 848 849 bool molecule::CheckBounds(const Vector *x) const 849 850 { 850 double * const cell_size = World::getInstance().getDomain();851 const Matrix &domain = World::getInstance().getDomain().getM(); 851 852 bool result = true; 852 int j =-1;853 853 for (int i=0;i<NDIM;i++) { 854 j += i+1; 855 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))); 856 855 } 857 856 //return result; … … 881 880 ElementNo[i] = current++; 882 881 } 883 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 ); 884 883 return true; 885 884 } … … 1004 1003 for(int i=MAX_ELEMENTS;i--;) 1005 1004 ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0); 1006 };1007 1008 1009 /** Counts necessary number of valence electrons and returns number and SpinType.1010 * \param configuration containing everything1011 */1012 void molecule::CalculateOrbitals(class config &configuration)1013 {1014 configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0;1015 for(int i=MAX_ELEMENTS;i--;) {1016 if (ElementsInMolecule[i] != 0) {1017 //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;1018 configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence);1019 }1020 }1021 configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2);1022 configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2;1023 configuration.MaxPsiDouble /= 2;1024 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;1025 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {1026 configuration.ProcPEGamma /= 2;1027 configuration.ProcPEPsi *= 2;1028 } else {1029 configuration.ProcPEGamma *= configuration.ProcPEPsi;1030 configuration.ProcPEPsi = 1;1031 }1032 cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl;1033 if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) {1034 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown;1035 cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl;1036 } else {1037 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp;1038 cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl;1039 }1040 1005 }; 1041 1006
Note:
See TracChangeset
for help on using the changeset viewer.