Skip to content
Snippets Groups Projects
Configuration.cpp 51.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • cmaffeo2's avatar
    cmaffeo2 committed
    			if (uniqueID) {
    				// Add the particle to the end of the array, then sort it. 
    				indices[numPartsFromFile] = key;
    				partsFromFile[numPartsFromFile++] = line;
    				std::sort(indices, indices + numPartsFromFile);
    				std::sort(partsFromFile, partsFromFile + numPartsFromFile, compare());		
    			}
    		}
    	}
    }
    
    void Configuration::readBonds() {
    	// Open the file
    	FILE* inp = fopen(bondFile.val(), "r");
    	char line[256];
    
    	// If the particle file cannot be found, exit the program
    	if (inp == NULL) {
    		printf("WARNING: Could not open `%s'.\n", bondFile.val());
    		printf("         This simulation will not use particle bonds.\n");
    		return;
    	}
    
    	// Our particle array has a starting capacity of 256
    	// We will expand this later if we need to.
    	int capacity = 256;
    	numBonds = 0;
    	bonds = new Bond[capacity];
    
    	// Get and process all lines of input
    	while (fgets(line, 256, inp) != NULL) {
    		
    		// Lines in the particle file that begin with # are comments
    		if (line[0] == '#') continue;
    		      
    		String s(line);
    		int numTokens = s.tokenCount();
    		      
    		// Break the line down into pieces (tokens) so we can process them individually
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    
    		// Legitimate BOND input lines have 4 tokens: 
    		// BOND | OPERATION_FLAG | INDEX1 | INDEX2 | FILENAME 
    		// A line without exactly five tokens should be discarded.
    		if (numTokens != 5) {
    			printf("WARNING: Invalid bond file line: %s\n", line);
    			continue;
    		}
    
    		String op = tokenList[1];
    		int ind1 = atoi(tokenList[2].val());
    		int ind2 = atoi(tokenList[3].val());
    		String file_name = tokenList[4];
    
    
    		if (ind1 == ind2) {
    			printf("WARNING: Invalid bond file line: %s\n", line);
    			continue;
    		}
    
    cmaffeo2's avatar
    cmaffeo2 committed
    		
    		// If we don't have enough room in our bond array, we need to expand it.
    		if (numBonds >= capacity) {
    			// Temporary pointer to the old array
    			Bond* temp = bonds;	
    
    			// Double the capacity
    			capacity *= 2;
    
    			// Create pointer to new array which is twice the size of the old one
    			bonds = new Bond[capacity];
    		
    			// Copy the old values into the new array
    			for (int j = 0; j < numBonds; j++)
    				bonds[j] = temp[j];
    
    			// delete the old array
    			delete[] temp;
    		}
    		// Add the bond to the bond array
    		// We must add it twice: Once for (ind1, ind2) and once for (ind2, ind1)
    
    		
    		// RBTODO: add ind1/2 to exclusion list here iff op == REPLACE
    		/*if (op == Bond::REPLACE)
    		if( (int)(op) == 1)
    		{
    			printf("WARNING: Bond exclusions not implemented\n");
    			continue;
    		}*/
    
    
    cmaffeo2's avatar
    cmaffeo2 committed
    		Bond* b = new Bond(op, ind1, ind2, file_name);
    		bonds[numBonds++] = *b;
    		b = new Bond(op, ind2, ind1, file_name);
    		bonds[numBonds++] = *b;
    		delete[] tokenList;
    	}	
    	// Call compareBondIndex with qsort to sort the bonds by BOTH ind1 AND ind2
    	std::sort(bonds, bonds + numBonds, compare());
    
    	/* Each particle may have a varying number of bonds
    	 * bondMap is an array with one element for each particle
    	 * which keeps track of where a particle's bonds are stored
    	 * in the bonds array.
    	 * bondMap[i].x is the index in the bonds array where the ith particle's bonds begin
    	 * bondMap[i].y is the index in the bonds array where the ith particle's bonds end
    	 */
    
    	bondMap = new int2[num];
    	for (int i = 0; i < num; i++) {	
    
    cmaffeo2's avatar
    cmaffeo2 committed
    		bondMap[i].x = -1;
    		bondMap[i].y = -1;
    	}
    	int currPart = -1;
    	int lastPart = -1;
    	for (int i = 0; i < numBonds; i++) {
    		if (bonds[i].ind1 != currPart) {
    			currPart = bonds[i].ind1;
    			bondMap[currPart].x = i;
    			if (lastPart >= 0) bondMap[lastPart].y = i;
    			lastPart = currPart;
    		}
    	}
    	if (bondMap[lastPart].x > 0)
    		bondMap[lastPart].y = numBonds;
    }
    
    void Configuration::readExcludes()
    {
    	// Open the file
    	FILE* inp = fopen(excludeFile.val(), "r");
    	char line[256];
    
    	// If the exclusion file cannot be found, exit the program
    	if (inp == NULL) {
    		printf("WARNING: Could not open `%s'.\n", excludeFile.val());
    		printf("This simulation will not use exclusions.\n");
    		return;
    	}
    
    	// Our particle array has a starting capacity of 256
    	// We will expand this later if we need to.
    	excludeCapacity = 256;
    	numExcludes = 0;
    	excludes = new Exclude[excludeCapacity];
    
    	// Get and process all lines of input
    	while (fgets(line, 256, inp) != NULL) {
    		// Lines in the particle file that begin with # are comments
    		if (line[0] == '#') continue;
    		      
    		String s(line);
    		int numTokens = s.tokenCount();
    		      
    		// Break the line down into pieces (tokens) so we can process them individually
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    
    		// Legitimate EXCLUDE input lines have 3 tokens: 
    		// BOND | INDEX1 | INDEX2
    		// A line without exactly three tokens should be discarded.
    		if (numTokens != 3) {
    			printf("WARNING: Invalid exclude file line: %s\n", line);
    			continue;
    		}
    		int ind1 = atoi(tokenList[1].val());
    		int ind2 = atoi(tokenList[2].val());
    
    		if (ind1 >= num || ind2 >= num) 
    
    cmaffeo2's avatar
    cmaffeo2 committed
    			continue;
    		
    		// If we don't have enough room in our bond array, we need to expand it.
    		if (numExcludes >= excludeCapacity) {
    			// Temporary pointer to the old array
    			Exclude* temp = excludes;	
    
    			// Double the capacity
    			excludeCapacity *= 2;
    
    			// Create pointer to new array which is twice the size of the old one
    			excludes = new Exclude[excludeCapacity];
    		
    			// Copy the old values into the new array
    			for (int j = 0; j < numExcludes; j++)
    				excludes[j] = temp[j];
    
    			// delete the old array
    			delete[] temp;
    		}
    		// Add the bond to the exclude array
    		// We must add it twice: Once for (ind1, ind2) and once for (ind2, ind1)
    		Exclude ex(ind1, ind2);
    		excludes[numExcludes++] = ex;
    		Exclude ex2(ind2, ind1);
    		excludes[numExcludes++] = ex2;
    		delete[] tokenList;
    	}	
    	// Call compareExcludeIndex with qsort to sort the excludes by BOTH ind1 AND ind2
    	std::sort(excludes, excludes + numExcludes, compare());
    
    	/* Each particle may have a varying number of excludes
    	 * excludeMap is an array with one element for each particle
    	 * which keeps track of where a particle's excludes are stored
    	 * in the excludes array.
    	 * excludeMap[i].x is the index in the excludes array where the ith particle's excludes begin
    	 * excludeMap[i].y is the index in the excludes array where the ith particle's excludes end
    	 */
    
    	excludeMap = new int2[num];
    	for (int i = 0; i < num; i++) {	
    
    cmaffeo2's avatar
    cmaffeo2 committed
    		excludeMap[i].x = -1;
    		excludeMap[i].y = -1;
    	}
    	int currPart = -1;
    	int lastPart = -1;
    	for (int i = 0; i < numExcludes; i++) {
    		if (excludes[i].ind1 != currPart) {
    			currPart = excludes[i].ind1;
    
    cmaffeo2's avatar
    cmaffeo2 committed
    				excludeMap[currPart].x = i;
    				if (lastPart >= 0)
    					excludeMap[lastPart].y = i;
    				lastPart = currPart;
    			}
    		}
    	}
    }
    
    void Configuration::readAngles() {
    	FILE* inp = fopen(angleFile.val(), "r");
    	char line[256];
    	int capacity = 256;
    	numAngles = 0;
    	angles = new Angle[capacity];
    
    	// If the angle file cannot be found, exit the program
    	if (inp == NULL) {
    		printf("WARNING: Could not open `%s'.\n", angleFile.val());
    		printf("This simulation will not use angles.\n");
    		return;
    	}
    
    	while(fgets(line, 256, inp)) {
    		if (line[0] == '#') continue;
    		String s(line);
    		int numTokens = s.tokenCount();
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    		
    		// Legitimate ANGLE inputs have 5 tokens
    		// ANGLE | INDEX1 | INDEX2 | INDEX3 | FILENAME
    		// Any angle input line without exactly 5 tokens should be discarded
    		if (numTokens != 5) {
    			printf("WARNING: Invalid angle input line: %s\n", line);
    			continue;
    		}		
    		
    		// Discard any empty line
    		if (tokenList == NULL) 
    			continue;
    		
    		int ind1 = atoi(tokenList[1].val());
    		int ind2 = atoi(tokenList[2].val());
    		int ind3 = atoi(tokenList[3].val());
    		String file_name = tokenList[4];
    		//printf("file_name %s\n", file_name.val());
    
    		if (ind1 >= num or ind2 >= num or ind3 >= num)
    
    cmaffeo2's avatar
    cmaffeo2 committed
    			continue;
    
    		if (numAngles >= capacity) {
    			Angle* temp = angles;
    			capacity *= 2;
    			angles = new Angle[capacity];
    			for (int i = 0; i < numAngles; i++)
    				angles[i] = temp[i];
    			delete[] temp;
    		}
    
    		Angle a(ind1, ind2, ind3, file_name);
    		angles[numAngles++] = a;
    		delete[] tokenList;
    	}
    	std::sort(angles, angles + numAngles, compare());	
    
    
    	// for(int i = 0; i < numAngles; i++)
    	// 	angles[i].print();
    
    cmaffeo2's avatar
    cmaffeo2 committed
    }
    
    void Configuration::readDihedrals() {
    	FILE* inp = fopen(dihedralFile.val(), "r");
    	char line[256];
    	int capacity = 256;
    	numDihedrals = 0;
    	dihedrals = new Dihedral[capacity];
    
    	// If the dihedral file cannot be found, exit the program
    	if (inp == NULL) {
    		printf("WARNING: Could not open `%s'.\n", dihedralFile.val());
    		printf("This simulation will not use dihedrals.\n");
    		return;
    	}
    
    	while(fgets(line, 256, inp)) {
    		if (line[0] == '#') continue;
    		String s(line);
    		int numTokens = s.tokenCount();
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    		
    		// Legitimate DIHEDRAL inputs have 6 tokens
    		// DIHEDRAL | INDEX1 | INDEX2 | INDEX3 | INDEX4 | FILENAME
    		// Any angle input line without exactly 6 tokens should be discarded
    		if (numTokens != 6) {
    			printf("WARNING: Invalid dihedral input line: %s\n", line);
    			continue;
    		}		
    		
    		// Discard any empty line
    		if (tokenList == NULL) 
    			continue;
    		
    		int ind1 = atoi(tokenList[1].val());
    		int ind2 = atoi(tokenList[2].val());
    		int ind3 = atoi(tokenList[3].val());
    		int ind4 = atoi(tokenList[4].val());
    		String file_name = tokenList[5];
    		//printf("file_name %s\n", file_name.val());
    
    		if (ind1 >= num or ind2 >= num
    				or ind3 >= num or ind4 >= num)
    
    cmaffeo2's avatar
    cmaffeo2 committed
    			continue;
    
    		if (numDihedrals >= capacity) {
    			Dihedral* temp = dihedrals;
    			capacity *= 2;
    			dihedrals = new Dihedral[capacity];
    			for (int i = 0; i < numDihedrals; ++i)
    				dihedrals[i] = temp[i];
    			delete[] temp;
    		}
    
    		Dihedral d(ind1, ind2, ind3, ind4, file_name);
    		dihedrals[numDihedrals++] = d;
    		delete[] tokenList;
    	}
    	std::sort(dihedrals, dihedrals + numDihedrals, compare());	
    
    
    	// for(int i = 0; i < numDihedrals; i++)
    	// 	dihedrals[i].print();
    
    cmaffeo2's avatar
    cmaffeo2 committed
    1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713
    }
    
    void Configuration::populate() {
    	int pn = 0;
    	int p = 0;
    
    	for (int i = 0; i < num; i++) {
    		for (int s = 0; s < simNum; ++s)
    			type[i + s*num] = p;
    		serial[i] = currSerial++;
    		if (++pn >= part[p].num) {
    			p++;
    			pn = 0;
    		}
    	}
    }
    
    bool Configuration::readBondFile(const String& value, int currBond) {
    	int numTokens = value.tokenCount();
    	if (numTokens != 1) {
    		printf("ERROR: Invalid tabulatedBondFile: %s, numTokens = %d\n", value.val(), numTokens);
    		return false;
    	}
    
    	String* tokenList = new String[numTokens];
    	value.tokenize(tokenList);
    	if (tokenList == NULL) {
    		printf("ERROR: Invalid tabulatedBondFile: %s; tokenList is NULL\n", value.val());
    		return false;
    	}
    
    	bondTableFile[currBond] = tokenList[0];
    
    	printf("Tabulated Bond Potential: %s\n", bondTableFile[currBond].val() );
    
    	return true;
    }
    
    bool Configuration::readAngleFile(const String& value, int currAngle) {
    	int numTokens = value.tokenCount();
    	if (numTokens != 1) {
    		printf("ERROR: Invalid tabulatedAngleFile: %s, numTokens = %d\n", value.val(), numTokens);
    		return false;
    	}
    
    	String* tokenList = new String[numTokens];
    	value.tokenize(tokenList);
    	if (tokenList == NULL) {
    		printf("ERROR: Invalid tabulatedAngleFile: %s; tokenList is NULL\n", value.val());
    		return false;
    	}
    
    	angleTableFile[currAngle] = tokenList[0];
    
    	printf("Tabulated Angle Potential: %s\n", angleTableFile[currAngle].val() );
    
    	return true;
    }
    
    bool Configuration::readDihedralFile(const String& value, int currDihedral) {
    	int numTokens = value.tokenCount();
    	if (numTokens != 1) {
    		printf("ERROR: Invalid tabulatedDihedralFile: %s, numTokens = %d\n", value.val(), numTokens);
    		return false;
    	}
    
    	String* tokenList = new String[numTokens];
    	value.tokenize(tokenList);
    	if (tokenList == NULL) {
    		printf("ERROR: Invalid tabulatedDihedralFile: %s; tokenList is NULL\n", value.val());
    		return false;
    	}
    
    	dihedralTableFile[currDihedral] = tokenList[0];
    
    	printf("Tabulated Dihedral Potential: %s\n", dihedralTableFile[currDihedral].val() );
    
    	return true;
    }
    
    void Configuration::loadRestart(const char* file_name) {
    	char line[STRLEN];
    	FILE* inp = fopen(file_name, "r");
    
    	if (inp == NULL) {
    		printf("GrandBrownTown:loadRestart File `%s' does not exist\n", file_name);
    		exit(-1);
    	}
    
    	int count = 0;
    	while (fgets(line, STRLEN, inp) != NULL) {
    		// Ignore comments.
    		int len = strlen(line);
    		if (line[0] == '#') continue;
    		if (len < 2) continue;
    
    		String s(line);
    		int numTokens = s.tokenCount();
    		if (numTokens != 4) {
    			printf("GrandBrownTown:loadRestart Invalid coordinate file line: %s\n", line);
    			fclose(inp);	
    			exit(-1);
    		}
    
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    		if (tokenList == NULL) {
    			printf("GrandBrownTown:loadRestart Invalid coordinate file line: %s\n", line);
    			fclose(inp);
    			exit(-1);
    		}
    
    		int typ = atoi(tokenList[0]);
    		float x = (float) strtod(tokenList[1],NULL);
    		float y = (float) strtod(tokenList[2],NULL);
    		float z = (float) strtod(tokenList[3],NULL);
    
    		pos[count] = Vector3(x,y,z);
    		type[count] = typ;
    		serial[count] = currSerial;
    		currSerial++;
    		if (typ < 0 || typ >= numParts) {
    			printf("GrandBrownTown:countRestart Invalid particle type: %d\n", typ);
    			fclose(inp);
    			exit(-1);
    		}
    
    		count++;
    		delete[] tokenList;
    	}
    
    	fclose(inp);    
    }
    
    bool Configuration::loadCoordinates(const char* file_name) {
    	char line[STRLEN];
    	FILE* inp = fopen(file_name, "r");
    
    	if (inp == NULL) return false;
    
    	int count = 0;
    	while (fgets(line, STRLEN, inp) != NULL) {
    		// Ignore comments.
    		int len = strlen(line);
    		if (line[0] == '#') continue;
    		if (len < 2) continue;
    
    		String s(line);
    		int numTokens = s.tokenCount();
    		if (numTokens != 3) {
    			printf("ERROR: Invalid coordinate file line: %s\n", line);
    			fclose(inp);	
    			return false;
    		}
    
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    		if (tokenList == NULL) {
    			printf("ERROR: Invalid coordinate file line: %s\n", line);
    			fclose(inp);
    			return false;
    		}
    
    		if (count >= num) {
    			printf("WARNING: Too many coordinates in coordinate file %s.\n", file_name);
    			fclose(inp);
    			return true;
    		}
    
    		float x = (float) strtod(tokenList[0],NULL);
    		float y = (float) strtod(tokenList[1],NULL);
    		float z = (float) strtod(tokenList[2],NULL);
    		pos[count] = Vector3(x,y,z);
    		count++;
    
    		delete[] tokenList;
    	}
    	fclose(inp);
    
    	if (count < num) {
    		printf("ERROR: Too few coordinates in coordinate file.\n");
    		return false;
    	}
    	return true;
    }
    
    // Count the number of atoms in the restart file.
    int Configuration::countRestart(const char* file_name) {
    	char line[STRLEN];
    	FILE* inp = fopen(file_name, "r");
    
    	if (inp == NULL) {
    		printf("ERROR: countRestart File `%s' does not exist\n", file_name);
    		exit(-1);
    	}
    
    	int count = 0;
    	while (fgets(line, STRLEN, inp) != NULL) {
    		int len = strlen(line);
    		// Ignore comments.
    		if (line[0] == '#') continue;
    		if (len < 2) continue;
    
    		String s(line);
    		int numTokens = s.tokenCount();
    		if (numTokens != 4) {
    			printf("ERROR: countRestart Invalid coordinate file line: %s\n", line);
    			fclose(inp);	
    			exit(-1);
    		}
    
    		String* tokenList = new String[numTokens];
    		s.tokenize(tokenList);
    		if (tokenList == NULL) {
    			printf("ERROR: countRestart Invalid coordinate file line: %s\n", line);
    			fclose(inp);
    			exit(-1);
    		}
    
    		int typ = atoi(tokenList[0]);
    		// float x = strtod(tokenList[1],NULL);
    		// float y = strtod(tokenList[2],NULL);
    		// float z = strtod(tokenList[3],NULL);
    		if (typ < 0 || typ >= numParts) {
    			printf("ERROR: countRestart Invalid particle type: %d\n", typ);
    			fclose(inp);
    			exit(-1);
    		}
    
    		count++;
    		delete[] tokenList;
    	}
    
    	fclose(inp);    
    	return count;
    }
    
    bool Configuration::readTableFile(const String& value, int currTab) {
    	int numTokens = value.tokenCount('@');
    	if (numTokens != 3) {
    		printf("ERROR: Invalid tabulatedFile: %s\n", value.val());
    		return false;
    	}
    
    	String* tokenList = new String[numTokens];
    	value.tokenize(tokenList, '@');
    	if (tokenList == NULL) {
    		printf("ERROR: Invalid tabulatedFile: %s\n", value.val());
    		return false;
    	}
    
    	partTableIndex0[currTab] = atoi(tokenList[0]);
    	partTableIndex1[currTab] = atoi(tokenList[1]);
    	partTableFile[currTab] = tokenList[2];
    
    	printf("tabulatedPotential: %d %d %s\n", partTableIndex0[currTab],
    			partTableIndex1[currTab], partTableFile[currTab].val() );
    	delete[] tokenList;
    	return true;
    }
    
    void Configuration::getDebugForce() {
    	// Allow the user to choose which force computation to use
    	printf("\n");
    	printf("(1) ComputeFull [Default]          (2) ComputeSoftcoreFull\n");
    	printf("(3) ComputeElecFull                (4) Compute (Decomposed)\n");
    	printf("(5) ComputeTabulated (Decomposed)  (6) ComputeTabulatedFull\n");
    
    	printf("WARNING: ");
    	if (tabulatedPotential) {
    		if (fullLongRange) printf("(6) was specified by config file\n");
    		else printf("(5) was specified by config file\n");
    	} else {
    		if (fullLongRange != 0) printf("(%d) was specified by config file\n", fullLongRange);
    		else printf("(4) was specified by config file\n");
    	}
    
    	char buffer[256];
    	int choice;
    	while (true) {
    		printf("Choose a force computation (1 - 6): ");
    		fgets(buffer, 256, stdin);
    		bool good = sscanf(buffer, "%d", &choice) && (choice >= 1 && choice <= 6);
    		if (good)
    			break;
    	}
    	switch(choice) {
    		case 1:
    			tabulatedPotential = 0;
    			fullLongRange = 1;
    			break;
    		case 2:
    			tabulatedPotential = 0;
    			fullLongRange = 2;
    			break;
    		case 3:
    			tabulatedPotential = 0;
    			fullLongRange = 3;
    			break;
    		case 4:
    			tabulatedPotential = 0;
    			fullLongRange = 0;
    			break;
    		case 5:
    			tabulatedPotential = 1;
    			fullLongRange = 0;
    			break;
    		case 6:
    			tabulatedPotential = 1;
    			fullLongRange = 1;
    			break;
    		default:
    			tabulatedPotential = 0;
    			fullLongRange = 1;
    			break;
    	}
    	printf("\n");
    }
    
    //////////////////////////
    // Comparison operators //
    //////////////////////////
    bool Configuration::compare::operator()(const String& lhs, const String& rhs) {
    	String* list_lhs = new String[lhs.tokenCount()];
    	String* list_rhs = new String[rhs.tokenCount()];
    	lhs.tokenize(list_lhs);
    	rhs.tokenize(list_rhs);
    	int key_lhs = atoi(list_lhs[1].val());
    	int key_rhs = atoi(list_rhs[1].val());
    	delete[] list_lhs;
    	delete[] list_rhs;
    	return key_lhs < key_rhs;
    }
    
    bool Configuration::compare::operator()(const Bond& lhs, const Bond& rhs) {
    	int diff = lhs.ind1 - rhs.ind1;
    	if (diff != 0)
    		return lhs.ind1 < rhs.ind1;
    	return lhs.ind2 < rhs.ind2;
    }
    
    bool Configuration::compare::operator()(const Exclude& lhs, const Exclude& rhs) {
    	int diff = lhs.ind1 - rhs.ind1;
    	if (diff != 0)
    		return lhs.ind1 < rhs.ind1;
    	return lhs.ind2 < rhs.ind2;
    }
    
    bool Configuration::compare::operator()(const Angle& lhs, const Angle& rhs) {
    	int diff = lhs.ind1 - rhs.ind1;
    	if (diff != 0)
    		return lhs.ind1 < rhs.ind1;
    	diff = lhs.ind2 - rhs.ind2;
    	if (diff != 0)
    		return lhs.ind2 < rhs.ind2;
    	return lhs.ind3 < rhs.ind3;
    }
    
    bool Configuration::compare::operator()(const Dihedral& lhs, const Dihedral& rhs) {
    	int diff = lhs.ind1 - rhs.ind1;
    	if (diff != 0) 
    		return lhs.ind1 < rhs.ind1;
    	diff = lhs.ind2 - rhs.ind2;
    	if (diff != 0) 
    		return lhs.ind2 < rhs.ind2;
    	diff = lhs.ind3 - rhs.ind3;
    	if (diff != 0) 
    		return lhs.ind3 < rhs.ind3;
    	return lhs.ind4 < rhs.ind4;
    }