- Timestamp:
- Jul 10, 2009, 12:48:05 PM (16 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:
- 5466f3
- Parents:
- a37350
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
ra37350 r21c017 1010 1010 // set new box dimensions 1011 1011 *out << Verbose(0) << "Translating to box with these boundaries." << endl; 1012 mol->CenterInBox((ofstream *) &cout, &BoxLengths); 1012 mol->SetBoxDimension(&BoxLengths); 1013 mol->CenterInBox((ofstream *) &cout); 1013 1014 } 1014 1015 // update Box of atoms by boundary -
src/builder.cpp
ra37350 r21c017 308 308 } 309 309 // center 310 mol->CenterInBox((ofstream *)&cout , &x);310 mol->CenterInBox((ofstream *)&cout); 311 311 // update Box of atoms by boundary 312 312 mol->SetBoxDimension(&x); … … 1245 1245 cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl; 1246 1246 cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl; 1247 cout << "\t-b x 1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl;1247 cout << "\t-b xx xy xz yy yz zz\tCenter atoms in domain with given symmetric matrix of (xx,xy,xz,yy,yz,zz)." << endl; 1248 1248 cout << "\t-B <basis>\tSetting basis to store to MPQC config files." << endl; 1249 1249 cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl; … … 1263 1263 cout << "\t-r\t\tConvert file from an old pcp syntax." << endl; 1264 1264 cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl; 1265 cout << "\t-T <file> Store temperatures from the config file in <file>." << endl; 1265 cout << "\t-T x1 x2 x3\tTranslate periodically all atoms by this vector (x1,x2,x3)." << endl; 1266 cout << "\t-S <file> Store temperatures from the config file in <file>." << endl; 1266 1267 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl; 1267 1268 cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl; … … 1486 1487 } 1487 1488 break; 1488 case ' T':1489 case 'S': 1489 1490 ExitFlag = 1; 1490 1491 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1491 1492 ExitFlag = 255; 1492 cerr << "Not enough or invalid arguments given for storing tempature: - T<temperature file>" << endl;1493 cerr << "Not enough or invalid arguments given for storing tempature: -S <temperature file>" << endl; 1493 1494 } else { 1494 1495 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl; … … 1533 1534 } 1534 1535 break; 1536 case 'T': 1537 ExitFlag = 1; 1538 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1539 ExitFlag = 255; 1540 cerr << "Not enough or invalid arguments given for periodic translation: -T <x> <y> <z>" << endl; 1541 } else { 1542 ExitFlag = 1; 1543 SaveFlag = true; 1544 cout << Verbose(1) << "Translating all ions periodically to new origin." << endl; 1545 for (int i=NDIM;i--;) 1546 x.x[i] = atof(argv[argptr+i]); 1547 mol->TranslatePeriodically((const Vector *)&x); 1548 argptr+=3; 1549 } 1550 break; 1535 1551 case 's': 1536 1552 ExitFlag = 1; … … 1562 1578 case 'b': 1563 1579 ExitFlag = 1; 1564 if ((argptr+ 2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) {1580 if ((argptr+5 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 1565 1581 ExitFlag = 255; 1566 cerr << "Not enough or invalid arguments given for centering in box: -b < length_x> <length_y> <length_z>" << endl;1582 cerr << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl; 1567 1583 } else { 1568 1584 SaveFlag = true; 1569 j = -1;1570 1585 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 1571 j=-1; 1572 for (int i=0;i<NDIM;i++) { 1573 j += i+1; 1574 x.x[i] = atof(argv[argptr++]); 1575 mol->cell_size[j] += x.x[i]*2.; 1586 for (int i=0;i<6;i++) { 1587 mol->cell_size[i] = atof(argv[argptr+i]); 1576 1588 } 1577 1589 // center 1578 mol->CenterInBox((ofstream *)&cout, &x); 1579 // update Box of atoms by boundary 1580 mol->SetBoxDimension(&x); 1590 mol->CenterInBox((ofstream *)&cout); 1591 argptr+=6; 1581 1592 } 1582 1593 break; … … 1602 1613 } 1603 1614 mol->Translate((const Vector *)&x); 1615 argptr+=3; 1604 1616 } 1605 1617 break; … … 1610 1622 mol->CenterOrigin((ofstream *)&cout, &x); 1611 1623 mol->SetBoxDimension(&x); 1624 argptr+=0; 1612 1625 break; 1613 1626 case 'r': -
src/molecules.cpp
ra37350 r21c017 629 629 /** Centers the molecule in the box whose lengths are defined by vector \a *BoxLengths. 630 630 * \param *out output stream for debugging 631 * \param *BoxLengths box lengths 632 */ 633 bool molecule::CenterInBox(ofstream *out, Vector *BoxLengths) 631 */ 632 bool molecule::CenterInBox(ofstream *out) 634 633 { 635 634 bool status = true; 636 635 atom *ptr = NULL; 637 Vector *min = new Vector; 638 Vector *max = new Vector; 639 640 // gather min and max for each axis 641 ptr = start->next; // start at first in list 642 if (ptr != end) { //list not empty? 643 for (int i=NDIM;i--;) { 644 max->x[i] = ptr->x.x[i]; 645 min->x[i] = ptr->x.x[i]; 646 } 647 while (ptr->next != end) { // continue with second if present 648 ptr = ptr->next; 649 //ptr->Output(1,1,out); 650 for (int i=NDIM;i--;) { 651 max->x[i] = (max->x[i] < ptr->x.x[i]) ? ptr->x.x[i] : max->x[i]; 652 min->x[i] = (min->x[i] > ptr->x.x[i]) ? ptr->x.x[i] : min->x[i]; 653 } 654 } 655 } 656 // sanity check 657 for(int i=NDIM;i--;) { 658 if (max->x[i] - min->x[i] > BoxLengths->x[i]) 659 status = false; 660 } 661 // warn if check failed 662 if (!status) 663 *out << "WARNING: molecule is bigger than defined box!" << endl; 664 else { // else center in box 665 max->AddVector(min); 666 max->Scale(-1.); 667 max->AddVector(BoxLengths); 668 max->Scale(0.5); 669 Translate(max); 670 } 671 672 // free and exit 673 delete(min); 674 delete(max); 636 Vector x; 637 double *M = ReturnFullMatrixforSymmetric(cell_size); 638 double *Minv = x.InverseMatrix(M); 639 double value; 640 641 // cout << "The box matrix is :" << endl; 642 // for (int i=0;i<NDIM;++i) { 643 // for (int j=0;j<NDIM;++j) 644 // cout << M[i*NDIM+j] << "\t"; 645 // cout << endl; 646 // } 647 // cout << "And its inverse is :" << endl; 648 // for (int i=0;i<NDIM;++i) { 649 // for (int j=0;j<NDIM;++j) 650 // cout << Minv[i*NDIM+j] << "\t"; 651 // cout << endl; 652 // } 653 // go through all atoms 654 ptr = start->next; // start at first in list 655 if (ptr != end) { //list not empty? 656 while (ptr->next != end) { // continue with second if present 657 ptr = ptr->next; 658 //ptr->Output(1,1,out); 659 // multiply its vector with matrix inverse 660 x.CopyVector(&ptr->x); 661 x.MatrixMultiplication(Minv); 662 // truncate to [0,1] for each axis 663 for (int i=0;i<NDIM;i++) { 664 value = floor(x.x[i]); // next lower integer 665 if (x.x[i] >=0) { 666 x.x[i] -= value; 667 } else { 668 x.x[i] += value+1; 669 } 670 } 671 // matrix multiply 672 x.MatrixMultiplication(M); 673 ptr->x.CopyVector(&x); 674 } 675 } 676 delete(M); 677 delete(Minv); 675 678 return status; 676 679 }; … … 836 839 } 837 840 }; 841 842 /** Translate the molecule periodically in the box. 843 * \param trans[] translation vector. 844 */ 845 void molecule::TranslatePeriodically(const Vector *trans) 846 { 847 atom *ptr = NULL; 848 Vector x; 849 double *M = ReturnFullMatrixforSymmetric(cell_size); 850 double *Minv = x.InverseMatrix(M); 851 double value; 852 853 // go through all atoms 854 ptr = start->next; // start at first in list 855 if (ptr != end) { //list not empty? 856 while (ptr->next != end) { // continue with second if present 857 ptr = ptr->next; 858 //ptr->Output(1,1,out); 859 // multiply its vector with matrix inverse 860 x.CopyVector(&ptr->x); 861 x.Translate(trans); 862 x.MatrixMultiplication(Minv); 863 // truncate to [0,1] for each axis 864 for (int i=0;i<NDIM;i++) { 865 value = floor(fabs(x.x[i])); // next lower integer 866 if (x.x[i] >=0) { 867 x.x[i] -= value; 868 } else { 869 x.x[i] += value+1; 870 } 871 } 872 // matrix multiply 873 x.MatrixMultiplication(M); 874 ptr->x.CopyVector(&x); 875 for (int j=0;j<MDSteps;j++) { 876 x.CopyVector(&Trajectories[ptr].R.at(j)); 877 x.Translate(trans); 878 x.MatrixMultiplication(Minv); 879 // truncate to [0,1] for each axis 880 for (int i=0;i<NDIM;i++) { 881 value = floor(x.x[i]); // next lower integer 882 if (x.x[i] >=0) { 883 x.x[i] -= value; 884 } else { 885 x.x[i] += value+1; 886 } 887 } 888 // matrix multiply 889 x.MatrixMultiplication(M); 890 Trajectories[ptr].R.at(j).CopyVector(&x); 891 } 892 } 893 } 894 delete(M); 895 delete(Minv); 896 }; 897 838 898 839 899 /** Mirrors all atoms against a given plane. … … 4130 4190 matrix[0] = symm[0]; 4131 4191 matrix[1] = symm[1]; 4132 matrix[2] = symm[ 3];4192 matrix[2] = symm[2]; 4133 4193 matrix[3] = symm[1]; 4134 matrix[4] = symm[ 2];4194 matrix[4] = symm[3]; 4135 4195 matrix[5] = symm[4]; 4136 matrix[6] = symm[ 3];4196 matrix[6] = symm[2]; 4137 4197 matrix[7] = symm[4]; 4138 4198 matrix[8] = symm[5]; -
src/molecules.hpp
ra37350 r21c017 252 252 void CountElements(); 253 253 void CalculateOrbitals(class config &configuration); 254 bool CenterInBox(ofstream *out , Vector *BoxLengths);254 bool CenterInBox(ofstream *out); 255 255 void CenterEdge(ofstream *out, Vector *max); 256 256 void CenterOrigin(ofstream *out, Vector *max); 257 257 void CenterGravity(ofstream *out, Vector *max); 258 258 void Translate(const Vector *x); 259 void TranslatePeriodically(const Vector *trans); 259 260 void Mirror(const Vector *x); 260 261 void Align(Vector *n); -
src/vector.cpp
ra37350 r21c017 413 413 for (int i=NDIM;i--;) 414 414 x[i] = C.x[i]; 415 }; 416 417 /** Calculate the inverse of a 3x3 matrix. 418 * \param *matrix NDIM_NDIM array 419 */ 420 double * Vector::InverseMatrix(double *A) 421 { 422 double *B = (double *) Malloc(sizeof(double)*NDIM*NDIM, "Vector::InverseMatrix: *B"); 423 double detA = RDET3(A); 424 double detAReci; 425 426 for (int i=0;i<NDIM*NDIM;++i) 427 B[i] = 0.; 428 // calculate the inverse B 429 if (fabs(detA) > MYEPSILON) {; // RDET3(A) yields precisely zero if A irregular 430 detAReci = 1./detA; 431 B[0] = detAReci*RDET2(A[4],A[5],A[7],A[8]); // A_11 432 B[1] = -detAReci*RDET2(A[1],A[2],A[7],A[8]); // A_12 433 B[2] = detAReci*RDET2(A[1],A[2],A[4],A[5]); // A_13 434 B[3] = -detAReci*RDET2(A[3],A[5],A[6],A[8]); // A_21 435 B[4] = detAReci*RDET2(A[0],A[2],A[6],A[8]); // A_22 436 B[5] = -detAReci*RDET2(A[0],A[2],A[3],A[5]); // A_23 437 B[6] = detAReci*RDET2(A[3],A[4],A[6],A[7]); // A_31 438 B[7] = -detAReci*RDET2(A[0],A[1],A[6],A[7]); // A_32 439 B[8] = detAReci*RDET2(A[0],A[1],A[3],A[4]); // A_33 440 } 441 return B; 415 442 }; 416 443 -
src/vector.hpp
ra37350 r21c017 40 40 void Scale(double factor); 41 41 void MatrixMultiplication(double *M); 42 double * InverseMatrix(double *A); 42 43 void InverseMatrixMultiplication(double *M); 43 44 void KeepPeriodic(ofstream *out, double *matrix);
Note:
See TracChangeset
for help on using the changeset viewer.