Changeset a5028f for src/boundary.cpp
- Timestamp:
- Feb 3, 2011, 9:59:58 AM (14 years ago)
- Branches:
- 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
- Children:
- 5817ef
- Parents:
- 63839f
- git-author:
- Frederik Heber <heber@…> (01/07/11 15:38:52)
- git-committer:
- Frederik Heber <heber@…> (02/03/11 09:59:58)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r63839f 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.