Changes in src/boundary.cpp [1f91f4:a5028f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r1f91f4 ra5028f 40 40 #include "LinearAlgebra/Plane.hpp" 41 41 #include "LinearAlgebra/RealSpaceMatrix.hpp" 42 #include "RandomNumbers/RandomNumberGeneratorFactory.hpp" 43 #include "RandomNumbers/RandomNumberGenerator.hpp" 42 44 #include "Box.hpp" 43 45 … … 831 833 832 834 // initialize seed of random number generator to current time 833 srand ( time(NULL) ); 835 RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator(); 836 const double rng_min = random.min(); 837 const double rng_max = random.max(); 838 //srand ( time(NULL) ); 834 839 835 840 // go over [0,1]^3 filler grid … … 841 846 // create molecule random translation vector ... 842 847 for (int i=0;i<NDIM;i++) 843 FillerTranslations[i] = RandomMolDisplacement*(rand ()/(RAND_MAX/2.) - 1.);848 FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.); 844 849 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl); 845 850 … … 851 856 if (DoRandomRotation) 852 857 for (int i=0;i<NDIM;i++) 853 phi[i] = (rand ()/RAND_MAX)*(2.*M_PI);858 phi[i] = (random()/(rng_max-rng_min))*(2.*M_PI); 854 859 855 860 for(molecule::const_iterator iter = filler->begin(); iter !=filler->end();++iter){ … … 857 862 // create atomic random translation vector ... 858 863 for (int i=0;i<NDIM;i++) 859 AtomTranslations[i] = RandomAtomDisplacement*(rand ()/(RAND_MAX/2.) - 1.);864 AtomTranslations[i] = RandomAtomDisplacement*(random()/((rng_max-rng_min)/2.) - 1.); 860 865 861 866 // ... and rotation matrix … … 939 944 molecule *&Filling, 940 945 double RandomAtomDisplacement, 941 RealSpaceMatrix &Rotations 946 RealSpaceMatrix &Rotations, 947 RandomNumberGenerator &random 942 948 ) 943 949 { 950 const double rng_min = random.min(); 951 const double rng_max = random.max(); 952 944 953 Vector AtomTranslations; 945 954 for(molecule::iterator miter = Filling->begin(); miter != Filling->end(); ++miter) { … … 949 958 // create atomic random translation vector ... 950 959 for (int i=0;i<NDIM;i++) 951 AtomTranslations[i] = RandomAtomDisplacement*(rand ()/(RAND_MAX/2.) - 1.);960 AtomTranslations[i] = RandomAtomDisplacement*(random()/((rng_max-rng_min)/2.) - 1.); 952 961 (*miter)->setPosition((*miter)->getPosition() + AtomTranslations); 953 962 } … … 1090 1099 1091 1100 // initialize seed of random number generator to current time 1092 srand ( time(NULL) ); 1101 RandomNumberGenerator &random = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator(); 1102 const double rng_min = random.min(); 1103 const double rng_max = random.max(); 1104 //srand ( time(NULL) ); 1093 1105 1094 1106 // go over [0,1]^3 filler grid … … 1099 1111 CurrentPosition = M * Vector((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 1100 1112 // create molecule random translation vector ... 1101 for (int i=0;i<NDIM;i++) 1102 FillerTranslations[i] = RandomMolDisplacement*(rand ()/(RAND_MAX/2.) - 1.);1113 for (int i=0;i<NDIM;i++) // have the random values [-1,1]*RandomMolDisplacement 1114 FillerTranslations[i] = RandomMolDisplacement*(random()/((rng_max-rng_min)/2.) - 1.); 1103 1115 DoLog(2) && (Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl); 1104 1116 … … 1130 1142 // fill! 1131 1143 Filling = filler->CopyMolecule(); 1132 RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations );1144 RandomizeMoleculePositions(Filling, RandomAtomDisplacement, Rotations, random); 1133 1145 // translation 1134 1146 Filling->Translate(&Inserter); … … 1168 1180 else 1169 1181 Rotations.setIdentity(); 1170 RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations );1182 RandomizeMoleculePositions(filler, RandomAtomDisplacement, Rotations, random); 1171 1183 // translation 1172 1184 filler->Translate(&firstInserter);
Note:
See TracChangeset
for help on using the changeset viewer.