Changeset 30d9e7
- Timestamp:
- Mar 1, 2010, 8:46:40 PM (15 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:
- 8db598
- Parents:
- b74f7d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
rb74f7d r30d9e7 807 807 double *M = ReturnFullMatrixforSymmetric(filler->cell_size); 808 808 double Rotations[NDIM*NDIM]; 809 double *MInverse = InverseMatrix(M); 809 810 Vector AtomTranslations; 810 811 Vector FillerTranslations; 811 812 Vector FillerDistance; 813 Vector Inserter; 812 814 double FillIt = false; 813 815 atom *Walker = NULL; 814 816 bond *Binder = NULL; 815 int i = 0;816 LinkedCell *LCList[List->ListOfMolecules.size()];817 817 double phi[NDIM]; 818 class Tesselation *TesselStruct[List->ListOfMolecules.size()];819 820 i=0; 818 map<molecule *, Tesselation *> TesselStruct; 819 map<molecule *, LinkedCell *> LCList; 820 821 821 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 822 822 Log() << Verbose(1) << "Pre-creating linked cell lists for molecule " << *ListRunner << "." << endl; 823 LCList[ i] = new LinkedCell((*ListRunner), 10.); // get linked cell list823 LCList[(*ListRunner)] = new LinkedCell((*ListRunner), 10.); // get linked cell list 824 824 Log() << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl; 825 TesselStruct[i] = NULL; 826 FindNonConvexBorder((*ListRunner), TesselStruct[i], (const LinkedCell *&)LCList[i], 5., NULL); 827 i++; 825 TesselStruct[(*ListRunner)] = NULL; 826 FindNonConvexBorder((*ListRunner), TesselStruct[(*ListRunner)], (const LinkedCell *&)LCList[(*ListRunner)], 5., NULL); 828 827 } 829 828 … … 846 845 847 846 // go over [0,1]^3 filler grid 848 for (n[0] = 0; n[0] < N[0]; n[0]++)849 for (n[1] = 0; n[1] < N[1]; n[1]++)850 for (n[2] = 0; n[2] < N[2]; n[2]++) {847 for (n[0] = 0; n[0] <= N[0]; n[0]++) 848 for (n[1] = 0; n[1] <= N[1]; n[1]++) 849 for (n[2] = 0; n[2] <= N[2]; n[2]++) { 851 850 // calculate position of current grid vector in untransformed box 852 851 CurrentPosition.Init((double)n[0]/(double)N[0], (double)n[1]/(double)N[1], (double)n[2]/(double)N[2]); 853 852 CurrentPosition.MatrixMultiplication(M); 854 Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "." << endl; 855 // Check whether point is in- or outside 856 FillIt = true; 857 i=0; 858 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 859 // get linked cell list 860 if (TesselStruct[i] == NULL) { 861 eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl; 862 FillIt = false; 863 } else { 864 const double distance = (TesselStruct[i]->GetDistanceSquaredToSurface(CurrentPosition, LCList[i])); 865 FillIt = FillIt && (distance > boundary*boundary) && ((MaxDistance < 0) || (MaxDistance*MaxDistance > distance)); 866 if (FillIt) { 867 Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is outer point." << endl; 853 // create molecule random translation vector ... 854 for (int i=0;i<NDIM;i++) 855 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 856 Log() << Verbose(2) << "INFO: Current Position is " << CurrentPosition << "+" << FillerTranslations << "." << endl; 857 858 // go through all atoms 859 Walker = filler->start; 860 while (Walker->next != filler->end) { 861 Walker = Walker->next; 862 863 // create atomic random translation vector ... 864 for (int i=0;i<NDIM;i++) 865 AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.); 866 867 // ... and rotation matrix 868 if (DoRandomRotation) { 869 for (int i=0;i<NDIM;i++) { 870 phi[i] = rand()/(RAND_MAX/(2.*M_PI)); 871 } 872 873 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 874 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 875 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 876 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 877 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 878 Rotations[7] = sin(phi[1]) ; 879 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 880 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 881 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 882 } 883 884 // ... and put at new position 885 Inserter.CopyVector(&(Walker->x)); 886 if (DoRandomRotation) 887 Inserter.MatrixMultiplication(Rotations); 888 Inserter.AddVector(&AtomTranslations); 889 Inserter.AddVector(&FillerTranslations); 890 Inserter.AddVector(&CurrentPosition); 891 892 // check whether inserter is inside box 893 Inserter.MatrixMultiplication(MInverse); 894 FillIt = true; 895 for (int i=0;i<NDIM;i++) 896 FillIt = FillIt && (Inserter.x[i] >= -MYEPSILON) && ((Inserter.x[i]-1.) <= MYEPSILON); 897 Inserter.MatrixMultiplication(M); 898 899 // Check whether point is in- or outside 900 for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) { 901 // get linked cell list 902 if (TesselStruct[(*ListRunner)] == NULL) { 903 eLog() << Verbose(0) << "TesselStruct of " << (*ListRunner) << " is NULL. Didn't we pre-create it?" << endl; 904 FillIt = false; 868 905 } else { 869 Log() << Verbose(1) << "INFO: Position at " << CurrentPosition << " is inner point, within boundary or outside of MaxDistance." << endl;870 break;906 const double distance = (TesselStruct[(*ListRunner)]->GetDistanceSquaredToSurface(Inserter, LCList[(*ListRunner)])); 907 FillIt = FillIt && (distance > boundary*boundary) && ((MaxDistance < 0) || (MaxDistance*MaxDistance > distance)); 871 908 } 872 i++;873 909 } 874 } 875 876 if (FillIt) { 877 // fill in Filler 878 Log() << Verbose(2) << "Space at " << CurrentPosition << " is unoccupied by any molecule, filling in." << endl; 879 880 // create molecule random translation vector ... 881 for (int i=0;i<NDIM;i++) 882 FillerTranslations.x[i] = RandomMolDisplacement*(rand()/(RAND_MAX/2.) - 1.); 883 Log() << Verbose(2) << "INFO: Translating this filler by " << FillerTranslations << "." << endl; 884 885 // go through all atoms 886 Walker = filler->start; 887 while (Walker->next != filler->end) { 888 Walker = Walker->next; 910 // insert into Filling 911 if (FillIt) { 912 Log() << Verbose(1) << "INFO: Position at " << Inserter << " is outer point." << endl; 889 913 // copy atom ... 890 914 CopyAtoms[Walker->nr] = new atom(Walker); 891 892 // create atomic random translation vector ... 893 for (int i=0;i<NDIM;i++) 894 AtomTranslations.x[i] = RandomAtomDisplacement*(rand()/(RAND_MAX/2.) - 1.); 895 896 // ... and rotation matrix 897 if (DoRandomRotation) { 898 for (int i=0;i<NDIM;i++) { 899 phi[i] = rand()/(RAND_MAX/(2.*M_PI)); 900 } 901 902 Rotations[0] = cos(phi[0]) *cos(phi[2]) + (sin(phi[0])*sin(phi[1])*sin(phi[2])); 903 Rotations[3] = sin(phi[0]) *cos(phi[2]) - (cos(phi[0])*sin(phi[1])*sin(phi[2])); 904 Rotations[6] = cos(phi[1])*sin(phi[2]) ; 905 Rotations[1] = - sin(phi[0])*cos(phi[1]) ; 906 Rotations[4] = cos(phi[0])*cos(phi[1]) ; 907 Rotations[7] = sin(phi[1]) ; 908 Rotations[3] = - cos(phi[0]) *sin(phi[2]) + (sin(phi[0])*sin(phi[1])*cos(phi[2])); 909 Rotations[5] = - sin(phi[0]) *sin(phi[2]) - (cos(phi[0])*sin(phi[1])*cos(phi[2])); 910 Rotations[8] = cos(phi[1])*cos(phi[2]) ; 911 } 912 913 // ... and put at new position 914 if (DoRandomRotation) 915 CopyAtoms[Walker->nr]->x.MatrixMultiplication(Rotations); 916 CopyAtoms[Walker->nr]->x.AddVector(&AtomTranslations); 917 CopyAtoms[Walker->nr]->x.AddVector(&FillerTranslations); 918 CopyAtoms[Walker->nr]->x.AddVector(&CurrentPosition); 919 920 // insert into Filling 921 922 // FIXME: gives completely different results if CopyAtoms[..] used instead of Walker, why??? 915 CopyAtoms[Walker->nr]->x.CopyVector(&Inserter); 916 Filling->AddAtom(CopyAtoms[Walker->nr]); 923 917 Log() << Verbose(4) << "Filling atom " << *Walker << ", translated to " << AtomTranslations << ", at final position is " << (CopyAtoms[Walker->nr]->x) << "." << endl; 924 Filling->AddAtom(CopyAtoms[Walker->nr]); 918 } else { 919 Log() << Verbose(1) << "INFO: Position at " << Inserter << " is inner point, within boundary or outside of MaxDistance." << endl; 920 CopyAtoms[Walker->nr] = NULL; 921 break; 925 922 } 926 923 … … 929 926 while(Binder->next != filler->last) { 930 927 Binder = Binder->next; 931 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 932 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 928 if ((CopyAtoms[Binder->leftatom->nr] != NULL) && (CopyAtoms[Binder->rightatom->nr] != NULL)) { 929 Log() << Verbose(3) << "Adding Bond between " << *CopyAtoms[Binder->leftatom->nr] << " and " << *CopyAtoms[Binder->rightatom->nr]<< "." << endl; 930 Filling->AddBond(CopyAtoms[Binder->leftatom->nr], CopyAtoms[Binder->rightatom->nr], Binder->BondDegree); 931 } 933 932 } 934 } else {935 // leave empty936 Log() << Verbose(2) << "Space at " << CurrentPosition << " is occupied." << endl;937 933 } 938 934 } 939 935 Free(&M); 940 941 // output to file 942 TesselStruct[0]->LastTriangle = NULL; 943 StoreTrianglesinFile(Filling, TesselStruct[0], "Tesselated", ".dat"); 944 945 for (size_t i=0;i<List->ListOfMolecules.size();i++) { 946 delete(LCList[i]); 947 delete(TesselStruct[i]); 948 } 936 Free(&MInverse); 937 949 938 return Filling; 950 939 };
Note:
See TracChangeset
for help on using the changeset viewer.