Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    r375b458 r042f82  
    308308      }
    309309      // center
    310       mol->CenterInBox((ofstream *)&cout, &x);
     310      mol->CenterInBox((ofstream *)&cout);
    311311      // update Box of atoms by boundary
    312312      mol->SetBoxDimension(&x);
     
    436436static void RemoveAtoms(molecule *mol)
    437437{
    438   atom *first, *second, *third;
     438  atom *first, *second;
    439439  int axis;
    440440  double tmp1, tmp2;
     
    459459      break;
    460460    case 'b':
    461       third = mol->AskAtom("Enter number of atom as reference point: ");
     461      second = mol->AskAtom("Enter number of atom as reference point: ");
    462462      cout << Verbose(0) << "Enter radius: ";
    463463      cin >> tmp1;
    464464      first = mol->start;
    465       second = first->next;
    466       while(second != mol->end) {
    467         first = second;
    468         second = first->next;
    469         if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
     465      while(first->next != mol->end) {
     466        first = first->next;
     467        if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
    470468          mol->RemoveAtom(first);
    471469      }
     
    474472      cout << Verbose(0) << "Which axis is it: ";
    475473      cin >> axis;
    476       cout << Verbose(0) << "Lower boundary: ";
     474      cout << Verbose(0) << "Left inward boundary: ";
    477475      cin >> tmp1;
    478       cout << Verbose(0) << "Upper boundary: ";
     476      cout << Verbose(0) << "Right inward boundary: ";
    479477      cin >> tmp2;
    480478      first = mol->start;
    481       second = first->next;
    482       while(second != mol->end) {
    483         first = second;
    484         second = first->next;
    485         if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
    486           //cout << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     479      while(first->next != mol->end) {
     480        first = first->next;
     481        if ((first->x.x[axis] > tmp2) || (first->x.x[axis] < tmp1)) // out of boundary ...
    487482          mol->RemoveAtom(first);
    488         }
    489483      }
    490484      break;
     
    634628static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    635629{
    636   atom *first, *second, *third, *fourth;
    637   Vector **atoms;
     630  atom *first, *second;
    638631  molecule *mol = NULL;
    639632  Vector x,y,z,n; // coordinates for absolute point in cell volume
    640633  double *factor; // unit factor if desired
    641   double a,b,c;
    642634  double bond, min_bond;
    643635  char choice;  // menu choice char
     
    749741static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
    750742{
    751   atom *first, *second, *third, *fourth;
    752   Vector **atoms;
     743  atom *first = NULL;
    753744  Vector x,y,z,n; // coordinates for absolute point in cell volume
    754   double a,b,c;
    755745  int j, axis, count, faktor;
    756746  char choice;  // menu choice char
    757   bool valid;
    758747  molecule *mol = NULL;
    759748  element **Elements;
     
    906895{
    907896  char choice;  // menu choice char
    908   bool valid;
    909897  Vector Center;
    910898  int nr, count;
    911899  molecule *mol = NULL;
    912   char *molname = NULL;
    913   int length;
    914900  char filename[MAXSTRINGSIZE];
    915901
     
    10141000{
    10151001  char choice;  // menu choice char
    1016   bool valid;
    10171002
    10181003  cout << Verbose(0) << "===========MERGE MOLECULES=====================" << endl;
     
    12231208 * \return exit code (0 - successful, all else - something's wrong)
    12241209 */
    1225 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName, char *&PathToDatabases)
     1210static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName)
    12261211{
    12271212  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    12381223  clock_t start,end;
    12391224  int argptr;
    1240   PathToDatabases = LocalPath;
     1225  strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
    12411226
    12421227  // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
     
    12601245            cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl;
    12611246            cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl;
    1262             cout << "\t-b x1 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;
    12631248            cout << "\t-B <basis>\tSetting basis to store to MPQC config files." << endl;
    12641249            cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
     
    12721257            cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
    12731258            cout << "\t-n\tFast parsing (i.e. no trajectories are looked for)." << endl;
    1274             cout << "\t-N <radius> <file>\tGet non-convex-envelope." << endl;
     1259            cout << "\t-N\tGet non-convex-envelope." << endl;
    12751260            cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl;
    12761261            cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
    12771262            cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
    12781263            cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
    1279             cout << "\t-R\t\tRemove all atoms out of sphere around a given one." << endl;
    12801264            cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
    1281             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;
    12821267            cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl;
    12831268            cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl;
     
    13011286            } else {
    13021287              cout << "Using " << argv[argptr] << " as elements database." << endl;
    1303               PathToDatabases = argv[argptr];
     1288              strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1);
    13041289              argptr+=1;
    13051290            }
     
    13181303
    13191304    // 2. Parse the element database
    1320     if (periode->LoadPeriodentafel(PathToDatabases)) {
     1305    if (periode->LoadPeriodentafel(configuration.databasepath)) {
    13211306      cout << Verbose(0) << "Element list loaded successfully." << endl;
    13221307      //periode->Output((ofstream *)&cout);
     
    14921477              } else {
    14931478                class Tesselation T;
    1494                 int N = 15;
    1495                 int number = 100;
    14961479                string filename(argv[argptr+1]);
    14971480                filename.append(".csv");
    14981481                cout << Verbose(0) << "Evaluating non-convex envelope.";
    14991482                cout << Verbose(1) << "Using rolling ball of radius " << atof(argv[argptr]) << " and storing tecplot data in " << argv[argptr+1] << "." << endl;
    1500                 LinkedCell LCList(mol, atof(argv[argptr]));    // \NOTE not twice the radius??
     1483                LinkedCell LCList(mol, atof(argv[argptr])*2.);
    15011484                Find_non_convex_border((ofstream *)&cout, mol, &T, &LCList, argv[argptr+1], atof(argv[argptr]));
    15021485                //FindDistributionOfEllipsoids((ofstream *)&cout, &T, &LCList, N, number, filename.c_str());
     
    15041487              }
    15051488              break;
    1506             case 'T':
     1489            case 'S':
    15071490              ExitFlag = 1;
    15081491              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    15091492                ExitFlag = 255;
    1510                 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;
    15111494              } else {
    15121495                cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
     
    15361519              }
    15371520              break;
    1538             case 'R':
    1539               ExitFlag = 1;
    1540               if ((argptr+1 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])))  {
    1541                 ExitFlag = 255;
    1542                 cerr << "Not enough or invalid arguments given for removing atoms: -R <id> <distance>" << endl;
    1543               } else {
    1544                 SaveFlag = true;
    1545                 cout << Verbose(1) << "Removing atoms around " << argv[argptr] << " with radius " << argv[argptr+1] << "." << endl;
    1546                 double tmp1 = atof(argv[argptr+1]);
    1547                 atom *third = mol->FindAtom(atoi(argv[argptr]));
    1548                 atom *first = mol->start;
    1549                 if ((third != NULL) && (first != mol->end)) {
    1550                   atom *second = first->next;
    1551                   while(second != mol->end) {
    1552                     first = second;
    1553                     second = first->next;
    1554                     if (first->x.DistanceSquared((const Vector *)&third->x) > tmp1*tmp1) // distance to first above radius ...
    1555                       mol->RemoveAtom(first);
    1556                   }
    1557                 } else {
    1558                   cerr << "Removal failed due to missing atoms on molecule or wrong id." << endl;
    1559                 }
    1560                 argptr+=2;
    1561               }
    1562               break;
    15631521            case 't':
    15641522              ExitFlag = 1;
     
    15731531                  x.x[i] = atof(argv[argptr+i]);
    15741532                mol->Translate((const Vector *)&x);
     1533                argptr+=3;
     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);
    15751548                argptr+=3;
    15761549              }
     
    16051578            case 'b':
    16061579              ExitFlag = 1;
    1607               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])) ) {
    16081581                ExitFlag = 255;
    1609                 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;
    16101583              } else {
    16111584                SaveFlag = true;
    1612                 j = -1;
    16131585                cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
    1614                 j=-1;
    1615                 for (int i=0;i<NDIM;i++) {
    1616                   j += i+1;
    1617                   x.x[i] = atof(argv[argptr++]);
    1618                   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]);
    16191588                }
    16201589                // center
    1621                 mol->CenterInBox((ofstream *)&cout, &x);
    1622                 // update Box of atoms by boundary
    1623                 mol->SetBoxDimension(&x);
     1590                mol->CenterInBox((ofstream *)&cout);
     1591                argptr+=6;
    16241592              }
    16251593              break;
     
    16451613                }
    16461614                mol->Translate((const Vector *)&x);
     1615                argptr+=3;
    16471616              }
    16481617              break;
     
    16531622              mol->CenterOrigin((ofstream *)&cout, &x);
    16541623              mol->SetBoxDimension(&x);
     1624              argptr+=0;
    16551625              break;
    16561626            case 'r':
     
    18081778    if (SaveFlag)
    18091779      SaveConfig(ConfigFileName, &configuration, periode, molecules);
    1810     if ((ExitFlag >= 1)) {
    1811       delete(mol);
    1812       delete(periode);
    1813       return (ExitFlag);
    1814     }
    18151780  } else {  // no arguments, hence scan the elements db
    1816     if (periode->LoadPeriodentafel(PathToDatabases))
     1781    if (periode->LoadPeriodentafel(configuration.databasepath))
    18171782      cout << Verbose(0) << "Element list loaded successfully." << endl;
    18181783    else
     
    18201785    configuration.RetrieveConfigPathAndName("main_pcp_linux");
    18211786  }
    1822   return(0);
     1787  return(ExitFlag);
    18231788};
    18241789
     
    18311796  molecule *mol = NULL;
    18321797  config configuration;
    1833   double tmp1;
    1834   atom *first, *second;
    18351798  char choice;  // menu choice char
    18361799  Vector x,y,z,n;  // coordinates for absolute point in cell volume
    1837   bool valid; // flag if input was valid or not
    18381800  ifstream test;
    18391801  ofstream output;
    18401802  string line;
    18411803  char *ConfigFileName = NULL;
    1842   char *ElementsFileName = NULL;
    1843   int Z;
    1844   int j, axis, count, faktor;
     1804  int j, count;
    18451805
    18461806  // =========================== PARSE COMMAND LINE OPTIONS ====================================
    1847   j = ParseCommandLineOptions(argc, argv, molecules, periode, configuration, ConfigFileName, ElementsFileName);
    1848   if (j == 1) return 0; // just for -v and -h options
    1849   if (j) return j;  // something went wrong
     1807  j = ParseCommandLineOptions(argc, argv, molecules, periode, configuration, ConfigFileName);
     1808  switch(j) {
     1809    case 0:  // something went wrong
     1810      delete(molecules); // also free's all molecules contained
     1811      delete(periode);
     1812      return j;
     1813      break;
     1814    case 1:  // just for -v and -h options
     1815      delete(molecules); // also free's all molecules contained
     1816      delete(periode);
     1817      return 0;
     1818      break;
     1819    default:
     1820      break;
     1821  }
    18501822
    18511823  // General stuff
     
    19361908
    19371909  // save element data base
    1938   if (periode->StorePeriodentafel(ElementsFileName)) //ElementsFileName
     1910  if (periode->StorePeriodentafel(configuration.databasepath)) //ElementsFileName
    19391911    cout << Verbose(0) << "Saving of elements.db successful." << endl;
    19401912  else
    19411913    cout << Verbose(0) << "Saving of elements.db failed." << endl;
    19421914
    1943   delete(molecules);
     1915  delete(molecules); // also free's all molecules contained
    19441916  delete(periode);
    19451917  return (0);
Note: See TracChangeset for help on using the changeset viewer.