Changes in src/config.cpp [a67d19:68f03d]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
ra67d19 r68f03d 8 8 #include <cstring> 9 9 10 #include "World.hpp" 10 11 #include "atom.hpp" 11 12 #include "bond.hpp" … … 500 501 // case 'j': // BoxLength 501 502 // Log() << Verbose(0) << "enter lower triadiagonalo form of basis matrix" << endl << endl; 502 // double * const cell_size = World::get ()->cell_size;503 // double * const cell_size = World::getInstance().getDomain(); 503 504 // for (int i=0;i<6;i++) { 504 505 // Log() << Verbose(0) << "Cell size" << i << ": "; … … 676 677 { 677 678 int MaxTypes = 0; 678 element *elementhash[MAX_ELEMENTS];679 const element *elementhash[MAX_ELEMENTS]; 679 680 char name[MAX_ELEMENTS]; 680 681 char keyword[MAX_ELEMENTS]; … … 734 735 sprintf(keyword,"%s_%i",name, j+1); 735 736 if (repetition == 0) { 736 neues = new atom();737 neues = World::getInstance().createAtom(); 737 738 AtomList[i][j] = neues; 738 739 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; … … 741 742 neues = AtomList[i][j]; 742 743 status = (status && 743 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x .x[0], 1, (repetition == 0) ? critical : optional) &&744 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x .x[1], 1, (repetition == 0) ? critical : optional) &&745 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x .x[2], 1, (repetition == 0) ? critical : optional) &&744 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], 1, (repetition == 0) ? critical : optional) && 745 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], 1, (repetition == 0) ? critical : optional) && 746 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], 1, (repetition == 0) ? critical : optional) && 746 747 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, 1, (repetition == 0) ? critical : optional)); 747 748 if (!status) break; … … 757 758 // put into trajectories list 758 759 for (int d=0;d<NDIM;d++) 759 neues->Trajectory.R.at(repetition) .x[d] = neues->x.x[d];760 neues->Trajectory.R.at(repetition)[d] = neues->x[d]; 760 761 761 762 // parse velocities if present 762 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v .x[0], 1,optional))763 neues->v .x[0] = 0.;764 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v .x[1], 1,optional))765 neues->v .x[1] = 0.;766 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v .x[2], 1,optional))767 neues->v .x[2] = 0.;763 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v[0], 1,optional)) 764 neues->v[0] = 0.; 765 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v[1], 1,optional)) 766 neues->v[1] = 0.; 767 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v[2], 1,optional)) 768 neues->v[2] = 0.; 768 769 for (int d=0;d<NDIM;d++) 769 neues->Trajectory.U.at(repetition) .x[d] = neues->v.x[d];770 neues->Trajectory.U.at(repetition)[d] = neues->v[d]; 770 771 771 772 // parse forces if present … … 777 778 value[2] = 0.; 778 779 for (int d=0;d<NDIM;d++) 779 neues->Trajectory.F.at(repetition) .x[d] = value[d];780 neues->Trajectory.F.at(repetition)[d] = value[d]; 780 781 781 782 // Log() << Verbose(0) << "Parsed position of step " << (repetition) << ": ("; … … 813 814 sprintf(keyword,"%s_%i",name, j+1); 814 815 if (repetition == 0) { 815 neues = new atom();816 neues = World::getInstance().createAtom(); 816 817 AtomList[i][j] = neues; 817 818 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; … … 820 821 neues = AtomList[i][j]; 821 822 // then parse for each atom the coordinates as often as present 822 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x .x[0], repetition,critical);823 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x .x[1], repetition,critical);824 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x .x[2], repetition,critical);823 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &neues->x[0], repetition,critical); 824 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &neues->x[1], repetition,critical); 825 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &neues->x[2], repetition,critical); 825 826 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &neues->FixedIon, repetition,critical); 826 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v .x[0], repetition,optional))827 neues->v .x[0] = 0.;828 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v .x[1], repetition,optional))829 neues->v .x[1] = 0.;830 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v .x[2], repetition,optional))831 neues->v .x[2] = 0.;827 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &neues->v[0], repetition,optional)) 828 neues->v[0] = 0.; 829 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &neues->v[1], repetition,optional)) 830 neues->v[1] = 0.; 831 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &neues->v[2], repetition,optional)) 832 neues->v[2] = 0.; 832 833 // here we don't care if forces are present (last in trajectories is always equal to current position) 833 834 neues->type = elementhash[i]; // find element type … … 852 853 void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList) 853 854 { 854 molecule *mol = new molecule(periode);855 molecule *mol = World::getInstance().createMolecule(); 855 856 ifstream *file = new ifstream(filename); 856 857 if (file == NULL) { … … 967 968 // Unit cell and magnetic field 968 969 ParseForParameter(verbose,FileBuffer, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 969 double * const cell_size = World::get ()->cell_size;970 double * const cell_size = World::getInstance().getDomain(); 970 971 cell_size[0] = BoxLength[0]; 971 972 cell_size[1] = BoxLength[3]; … … 1091 1092 void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList) 1092 1093 { 1093 molecule *mol = new molecule(periode);1094 molecule *mol = World::getInstance().createMolecule(); 1094 1095 ifstream *file = new ifstream(filename); 1095 1096 if (file == NULL) { … … 1109 1110 string zeile; 1110 1111 string dummy; 1111 element *elementhash[128];1112 const element *elementhash[128]; 1112 1113 int Z = -1; 1113 1114 int No = -1; … … 1172 1173 1173 1174 ParseForParameter(verbose,file, "BoxLength", 0, 3, 3, lower_trigrid, BoxLength, 1, critical); /* Lattice->RealBasis */ 1174 double * const cell_size = World::get ()->cell_size;1175 double * const cell_size = World::getInstance().getDomain(); 1175 1176 cell_size[0] = BoxLength[0]; 1176 1177 cell_size[1] = BoxLength[3]; … … 1291 1292 } 1292 1293 istringstream input2(zeile); 1293 atom *neues = new atom();1294 input2 >> neues->x .x[0]; // x1295 input2 >> neues->x .x[1]; // y1296 input2 >> neues->x .x[2]; // z1294 atom *neues = World::getInstance().createAtom(); 1295 input2 >> neues->x[0]; // x 1296 input2 >> neues->x[1]; // y 1297 input2 >> neues->x[2]; // z 1297 1298 input2 >> l; 1298 1299 neues->type = elementhash[No]; // find element type … … 1316 1317 // bring MaxTypes up to date 1317 1318 mol->CountElements(); 1318 const double * const cell_size = World::get ()->cell_size;1319 const double * const cell_size = World::getInstance().getDomain(); 1319 1320 ofstream * const output = new ofstream(filename, ios::out); 1320 1321 if (output != NULL) { … … 1574 1575 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1575 1576 MolNo, /* residue sequence number */ 1576 Walker->node-> x[0], /* position X in Angstroem */1577 Walker->node-> x[1], /* position Y in Angstroem */1578 Walker->node-> x[2], /* position Z in Angstroem */1577 Walker->node->at(0), /* position X in Angstroem */ 1578 Walker->node->at(1), /* position Y in Angstroem */ 1579 Walker->node->at(2), /* position Z in Angstroem */ 1579 1580 (double)Walker->type->Valence, /* occupancy */ 1580 1581 (double)Walker->type->NoValenceOrbitals, /* temperature factor */ … … 1628 1629 'a'+(unsigned char)(AtomNo % 26), /* letter for chain */ 1629 1630 0, /* residue sequence number */ 1630 Walker->node-> x[0], /* position X in Angstroem */1631 Walker->node-> x[1], /* position Y in Angstroem */1632 Walker->node-> x[2], /* position Z in Angstroem */1631 Walker->node->at(0), /* position X in Angstroem */ 1632 Walker->node->at(1), /* position Y in Angstroem */ 1633 Walker->node->at(2), /* position Z in Angstroem */ 1633 1634 (double)Walker->type->Valence, /* occupancy */ 1634 1635 (double)Walker->type->NoValenceOrbitals, /* temperature factor */ … … 1679 1680 Walker = Walker->next; 1680 1681 *output << Walker->nr << "\t"; 1681 *output << Walker-> Name<< "\t";1682 *output << Walker->getName() << "\t"; 1682 1683 *output << mol->name << "\t"; 1683 1684 *output << 0 << "\t"; 1684 *output << Walker->node-> x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2]<< "\t";1685 *output << (double)Walker->type->Valence<< "\t";1685 *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t"; 1686 *output << static_cast<double>(Walker->type->Valence) << "\t"; 1686 1687 *output << Walker->type->symbol << "\t"; 1687 1688 for (BondList::iterator runner = Walker->ListOfBonds.begin(); runner != Walker->ListOfBonds.end(); runner++) … … 1755 1756 Walker = Walker->next; 1756 1757 *output << AtomNo+1 << "\t"; 1757 *output << Walker-> Name<< "\t";1758 *output << Walker->getName() << "\t"; 1758 1759 *output << (*MolWalker)->name << "\t"; 1759 1760 *output << MolCounter+1 << "\t"; 1760 *output << Walker->node-> x[0] << "\t" << Walker->node->x[1] << "\t" << Walker->node->x[2]<< "\t";1761 *output << Walker->node->at(0) << "\t" << Walker->node->at(1) << "\t" << Walker->node->at(2) << "\t"; 1761 1762 *output << (double)Walker->type->Valence << "\t"; 1762 1763 *output << Walker->type->symbol << "\t"; … … 1782 1783 1783 1784 return true; 1785 }; 1786 1787 1788 /** Tries given filename or standard on saving the config file. 1789 * \param *ConfigFileName name of file 1790 * \param *periode pointer to periodentafel structure with all the elements 1791 * \param *molecules list of molecules structure with all the atoms and coordinates 1792 */ 1793 void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules) 1794 { 1795 char filename[MAXSTRINGSIZE]; 1796 ofstream output; 1797 molecule *mol = World::getInstance().createMolecule(); 1798 mol->SetNameFromFilename(ConfigFileName); 1799 1800 if (!strcmp(configpath, GetDefaultPath())) { 1801 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1802 } 1803 1804 1805 // first save as PDB data 1806 if (ConfigFileName != NULL) 1807 strcpy(filename, ConfigFileName); 1808 if (output == NULL) 1809 strcpy(filename,"main_pcp_linux"); 1810 Log() << Verbose(0) << "Saving as pdb input "; 1811 if (SavePDB(filename, molecules)) 1812 Log() << Verbose(0) << "done." << endl; 1813 else 1814 Log() << Verbose(0) << "failed." << endl; 1815 1816 // then save as tremolo data file 1817 if (ConfigFileName != NULL) 1818 strcpy(filename, ConfigFileName); 1819 if (output == NULL) 1820 strcpy(filename,"main_pcp_linux"); 1821 Log() << Verbose(0) << "Saving as tremolo data input "; 1822 if (SaveTREMOLO(filename, molecules)) 1823 Log() << Verbose(0) << "done." << endl; 1824 else 1825 Log() << Verbose(0) << "failed." << endl; 1826 1827 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1828 int N = molecules->ListOfMolecules.size(); 1829 int *src = new int[N]; 1830 N=0; 1831 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1832 src[N++] = (*ListRunner)->IndexNr; 1833 (*ListRunner)->Translate(&(*ListRunner)->Center); 1834 } 1835 molecules->SimpleMultiAdd(mol, src, N); 1836 delete[](src); 1837 1838 // ... and translate back 1839 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1840 (*ListRunner)->Center.Scale(-1.); 1841 (*ListRunner)->Translate(&(*ListRunner)->Center); 1842 (*ListRunner)->Center.Scale(-1.); 1843 } 1844 1845 Log() << Verbose(0) << "Storing configuration ... " << endl; 1846 // get correct valence orbitals 1847 mol->CalculateOrbitals(*this); 1848 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble; 1849 if (ConfigFileName != NULL) { // test the file name 1850 strcpy(filename, ConfigFileName); 1851 output.open(filename, ios::trunc); 1852 } else if (strlen(configname) != 0) { 1853 strcpy(filename, configname); 1854 output.open(configname, ios::trunc); 1855 } else { 1856 strcpy(filename, DEFAULTCONFIG); 1857 output.open(DEFAULTCONFIG, ios::trunc); 1858 } 1859 output.close(); 1860 output.clear(); 1861 Log() << Verbose(0) << "Saving of config file "; 1862 if (Save(filename, periode, mol)) 1863 Log() << Verbose(0) << "successful." << endl; 1864 else 1865 Log() << Verbose(0) << "failed." << endl; 1866 1867 // and save to xyz file 1868 if (ConfigFileName != NULL) { 1869 strcpy(filename, ConfigFileName); 1870 strcat(filename, ".xyz"); 1871 output.open(filename, ios::trunc); 1872 } 1873 if (output == NULL) { 1874 strcpy(filename,"main_pcp_linux"); 1875 strcat(filename, ".xyz"); 1876 output.open(filename, ios::trunc); 1877 } 1878 Log() << Verbose(0) << "Saving of XYZ file "; 1879 if (mol->MDSteps <= 1) { 1880 if (mol->OutputXYZ(&output)) 1881 Log() << Verbose(0) << "successful." << endl; 1882 else 1883 Log() << Verbose(0) << "failed." << endl; 1884 } else { 1885 if (mol->OutputTrajectoriesXYZ(&output)) 1886 Log() << Verbose(0) << "successful." << endl; 1887 else 1888 Log() << Verbose(0) << "failed." << endl; 1889 } 1890 output.close(); 1891 output.clear(); 1892 1893 // and save as MPQC configuration 1894 if (ConfigFileName != NULL) 1895 strcpy(filename, ConfigFileName); 1896 if (output == NULL) 1897 strcpy(filename,"main_pcp_linux"); 1898 Log() << Verbose(0) << "Saving as mpqc input "; 1899 if (SaveMPQC(filename, mol)) 1900 Log() << Verbose(0) << "done." << endl; 1901 else 1902 Log() << Verbose(0) << "failed." << endl; 1903 1904 if (!strcmp(configpath, GetDefaultPath())) { 1905 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1906 } 1907 1908 World::getInstance().destroyMolecule(mol); 1784 1909 }; 1785 1910
Note:
See TracChangeset
for help on using the changeset viewer.