Ignore:
Timestamp:
Jun 13, 2008, 9:18:57 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
0779a9
Parents:
41c2f1
Message:

Final touches for Create Clusters in water

repetition in CreateClustersinWater(), some stuff thrown out in VolumeOfConvexEnvelope (loop to throw out some more points, which does not happen if we take any appearing in at least one BoundaryPoints), some variable declarations shifted to the start of a function, BoundaryPoints are given to functions and if NULL is created by calling GetBoundaryPoints() and free'd subsequently.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/builder.cpp

    r41c2f1 r3f0c46  
    758758            cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl;
    759759            cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
     760            cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    760761            cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
    761762            cout << "\t-f <dist> <order>\tFragments the molecule in BOSSANOVA manner and stores config files in same dir as config." << endl;
     
    768769            cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
    769770            cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
     771            cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
    770772            cout << "\t-v/-V\t\tGives version information." << endl;
    771773            cout << "Note: config files must not begin with '-' !" << endl;
     
    983985              ExitFlag = 1;
    984986              cout << Verbose(0) << "Evaluating volume of the convex envelope.";
    985 //              tmp = atof(argv[argptr++]);
    986 //              if (tmp < 1.0) {
    987 //                cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;
    988 //                tmp = 1.3;
    989 //              }
    990987              VolumeOfConvexEnvelope((ofstream *)&cout, &configuration, NULL, mol);
     988              break;
     989            case 'u':
     990              {
     991                double tmp;
     992                ExitFlag = 1;
     993                cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
     994                tmp = atof(argv[argptr++]);
     995                if (tmp < 1.0) {
     996                  cerr << Verbose(0) << "Density must be greater than 1.0g/cm^3 !" << endl;
     997                  tmp = 1.3;
     998                }
     999//                for(int i=0;i<NDIM;i++) {
     1000//                  repetition[i] = atoi(argv[argptr++]);
     1001//                  if (repetition[i] < 1)
     1002//                    cerr << Verbose(0) << "ERROR: repetition value must be greater 1!" << endl;
     1003//                  repetition[i] = 1;
     1004//                }
     1005                PrepareClustersinWater((ofstream *)&cout, &configuration, mol, tmp);
     1006              }
     1007              break;
     1008            case 'd':
     1009              for (int axis = 1; axis <= NDIM; axis++) {
     1010                int faktor = atoi(argv[argptr++]);
     1011                int count;
     1012                element ** Elements;
     1013                vector ** Vectors;
     1014                if (faktor < 1) {
     1015                  cerr << Verbose(0) << "ERROR: Repetition faktor mus be greater than 1!" << endl;
     1016                  faktor = 1;
     1017                }
     1018                mol->CountAtoms((ofstream *)&cout);  // recount atoms
     1019                if (mol->AtomCount != 0) {  // if there is more than none
     1020                  count = mol->AtomCount;   // is changed becausing of adding, thus has to be stored away beforehand
     1021                  Elements = new element *[count];
     1022                  Vectors = new vector *[count];
     1023                  j = 0;
     1024                  first = mol->start;
     1025                  while (first->next != mol->end) {  // make a list of all atoms with coordinates and element
     1026                    first = first->next;
     1027                    Elements[j] = first->type;
     1028                    Vectors[j] = &first->x;
     1029                    j++;
     1030                  }
     1031                  if (count != j)
     1032                    cout << Verbose(0) << "ERROR: AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
     1033                  x.Zero();
     1034                  y.Zero();
     1035                  y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
     1036                  for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
     1037                    x.AddVector(&y); // per factor one cell width further
     1038                    for (int k=count;k--;) { // go through every atom of the original cell
     1039                      first = new atom(); // create a new body
     1040                      first->x.CopyVector(Vectors[k]);  // use coordinate of original atom
     1041                      first->x.AddVector(&x);      // translate the coordinates
     1042                      first->type = Elements[k];  // insert original element
     1043                      mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
     1044                    }
     1045                  }
     1046                  // free memory
     1047                  delete[](Elements);
     1048                  delete[](Vectors);
     1049                  // correct cell size
     1050                  if (axis < 0) { // if sign was negative, we have to translate everything
     1051                    x.Zero();
     1052                    x.AddVector(&y);
     1053                    x.Scale(-(faktor-1));
     1054                    mol->Translate(&x);
     1055                  }
     1056                  mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     1057                }
     1058              }
    9911059              break;
    9921060            default:   // no match? Step on
Note: See TracChangeset for help on using the changeset viewer.