Changes in src/builder.cpp [375b458:042f82]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/builder.cpp
r375b458 r042f82 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); … … 436 436 static void RemoveAtoms(molecule *mol) 437 437 { 438 atom *first, *second , *third;438 atom *first, *second; 439 439 int axis; 440 440 double tmp1, tmp2; … … 459 459 break; 460 460 case 'b': 461 third = mol->AskAtom("Enter number of atom as reference point: ");461 second = mol->AskAtom("Enter number of atom as reference point: "); 462 462 cout << Verbose(0) << "Enter radius: "; 463 463 cin >> tmp1; 464 464 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 ... 470 468 mol->RemoveAtom(first); 471 469 } … … 474 472 cout << Verbose(0) << "Which axis is it: "; 475 473 cin >> axis; 476 cout << Verbose(0) << "L owerboundary: ";474 cout << Verbose(0) << "Left inward boundary: "; 477 475 cin >> tmp1; 478 cout << Verbose(0) << " Upperboundary: ";476 cout << Verbose(0) << "Right inward boundary: "; 479 477 cin >> tmp2; 480 478 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 ... 487 482 mol->RemoveAtom(first); 488 }489 483 } 490 484 break; … … 634 628 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 635 629 { 636 atom *first, *second, *third, *fourth; 637 Vector **atoms; 630 atom *first, *second; 638 631 molecule *mol = NULL; 639 632 Vector x,y,z,n; // coordinates for absolute point in cell volume 640 633 double *factor; // unit factor if desired 641 double a,b,c;642 634 double bond, min_bond; 643 635 char choice; // menu choice char … … 749 741 static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 750 742 { 751 atom *first, *second, *third, *fourth; 752 Vector **atoms; 743 atom *first = NULL; 753 744 Vector x,y,z,n; // coordinates for absolute point in cell volume 754 double a,b,c;755 745 int j, axis, count, faktor; 756 746 char choice; // menu choice char 757 bool valid;758 747 molecule *mol = NULL; 759 748 element **Elements; … … 906 895 { 907 896 char choice; // menu choice char 908 bool valid;909 897 Vector Center; 910 898 int nr, count; 911 899 molecule *mol = NULL; 912 char *molname = NULL;913 int length;914 900 char filename[MAXSTRINGSIZE]; 915 901 … … 1014 1000 { 1015 1001 char choice; // menu choice char 1016 bool valid;1017 1002 1018 1003 cout << Verbose(0) << "===========MERGE MOLECULES=====================" << endl; … … 1223 1208 * \return exit code (0 - successful, all else - something's wrong) 1224 1209 */ 1225 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName , char *&PathToDatabases)1210 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName) 1226 1211 { 1227 1212 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 1238 1223 clock_t start,end; 1239 1224 int argptr; 1240 PathToDatabases = LocalPath;1225 strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1); 1241 1226 1242 1227 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place … … 1260 1245 cout << "\t-a Z x1 x2 x3\tAdd new atom of element Z at coordinates (x1,x2,x3)." << endl; 1261 1246 cout << "\t-A <source>\tCreate adjacency list from bonds parsed from 'dbond'-style file." <<endl; 1262 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; 1263 1248 cout << "\t-B <basis>\tSetting basis to store to MPQC config files." << endl; 1264 1249 cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl; … … 1272 1257 cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl; 1273 1258 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; 1275 1260 cout << "\t-o <out>\tGet volume of the convex envelope (and store to tecplot file)." << endl; 1276 1261 cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl; 1277 1262 cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl; 1278 1263 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;1280 1264 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; 1282 1267 cout << "\t-s x1 x2 x3\tScale all atom coordinates by this vector (x1,x2,x3)." << endl; 1283 1268 cout << "\t-u rho\tsuspend in water solution and output necessary cell lengths, average density rho and repetition." << endl; … … 1301 1286 } else { 1302 1287 cout << "Using " << argv[argptr] << " as elements database." << endl; 1303 PathToDatabases = argv[argptr];1288 strncpy (configuration.databasepath, argv[argptr], MAXSTRINGSIZE-1); 1304 1289 argptr+=1; 1305 1290 } … … 1318 1303 1319 1304 // 2. Parse the element database 1320 if (periode->LoadPeriodentafel( PathToDatabases)) {1305 if (periode->LoadPeriodentafel(configuration.databasepath)) { 1321 1306 cout << Verbose(0) << "Element list loaded successfully." << endl; 1322 1307 //periode->Output((ofstream *)&cout); … … 1492 1477 } else { 1493 1478 class Tesselation T; 1494 int N = 15;1495 int number = 100;1496 1479 string filename(argv[argptr+1]); 1497 1480 filename.append(".csv"); 1498 1481 cout << Verbose(0) << "Evaluating non-convex envelope."; 1499 1482 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.); 1501 1484 Find_non_convex_border((ofstream *)&cout, mol, &T, &LCList, argv[argptr+1], atof(argv[argptr])); 1502 1485 //FindDistributionOfEllipsoids((ofstream *)&cout, &T, &LCList, N, number, filename.c_str()); … … 1504 1487 } 1505 1488 break; 1506 case ' T':1489 case 'S': 1507 1490 ExitFlag = 1; 1508 1491 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1509 1492 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; 1511 1494 } else { 1512 1495 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl; … … 1536 1519 } 1537 1520 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;1563 1521 case 't': 1564 1522 ExitFlag = 1; … … 1573 1531 x.x[i] = atof(argv[argptr+i]); 1574 1532 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); 1575 1548 argptr+=3; 1576 1549 } … … 1605 1578 case 'b': 1606 1579 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])) ) { 1608 1581 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; 1610 1583 } else { 1611 1584 SaveFlag = true; 1612 j = -1;1613 1585 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]); 1619 1588 } 1620 1589 // 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; 1624 1592 } 1625 1593 break; … … 1645 1613 } 1646 1614 mol->Translate((const Vector *)&x); 1615 argptr+=3; 1647 1616 } 1648 1617 break; … … 1653 1622 mol->CenterOrigin((ofstream *)&cout, &x); 1654 1623 mol->SetBoxDimension(&x); 1624 argptr+=0; 1655 1625 break; 1656 1626 case 'r': … … 1808 1778 if (SaveFlag) 1809 1779 SaveConfig(ConfigFileName, &configuration, periode, molecules); 1810 if ((ExitFlag >= 1)) {1811 delete(mol);1812 delete(periode);1813 return (ExitFlag);1814 }1815 1780 } else { // no arguments, hence scan the elements db 1816 if (periode->LoadPeriodentafel( PathToDatabases))1781 if (periode->LoadPeriodentafel(configuration.databasepath)) 1817 1782 cout << Verbose(0) << "Element list loaded successfully." << endl; 1818 1783 else … … 1820 1785 configuration.RetrieveConfigPathAndName("main_pcp_linux"); 1821 1786 } 1822 return( 0);1787 return(ExitFlag); 1823 1788 }; 1824 1789 … … 1831 1796 molecule *mol = NULL; 1832 1797 config configuration; 1833 double tmp1;1834 atom *first, *second;1835 1798 char choice; // menu choice char 1836 1799 Vector x,y,z,n; // coordinates for absolute point in cell volume 1837 bool valid; // flag if input was valid or not1838 1800 ifstream test; 1839 1801 ofstream output; 1840 1802 string line; 1841 1803 char *ConfigFileName = NULL; 1842 char *ElementsFileName = NULL; 1843 int Z; 1844 int j, axis, count, faktor; 1804 int j, count; 1845 1805 1846 1806 // =========================== 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 } 1850 1822 1851 1823 // General stuff … … 1936 1908 1937 1909 // save element data base 1938 if (periode->StorePeriodentafel( ElementsFileName)) //ElementsFileName1910 if (periode->StorePeriodentafel(configuration.databasepath)) //ElementsFileName 1939 1911 cout << Verbose(0) << "Saving of elements.db successful." << endl; 1940 1912 else 1941 1913 cout << Verbose(0) << "Saving of elements.db failed." << endl; 1942 1914 1943 delete(molecules); 1915 delete(molecules); // also free's all molecules contained 1944 1916 delete(periode); 1945 1917 return (0);
Note:
See TracChangeset
for help on using the changeset viewer.