Changes in src/config.cpp [49e1ae:46d958]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r49e1ae r46d958 8 8 #include <cstring> 9 9 10 #include "World.hpp" 10 11 #include "atom.hpp" 11 12 #include "bond.hpp" … … 732 733 sprintf(keyword,"%s_%i",name, j+1); 733 734 if (repetition == 0) { 734 neues = new atom();735 neues = World::get()->createAtom(); 735 736 AtomList[i][j] = neues; 736 737 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; … … 811 812 sprintf(keyword,"%s_%i",name, j+1); 812 813 if (repetition == 0) { 813 neues = new atom();814 neues = World::get()->createAtom(); 814 815 AtomList[i][j] = neues; 815 816 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; … … 1287 1288 } 1288 1289 istringstream input2(zeile); 1289 atom *neues = new atom();1290 atom *neues = World::get()->createAtom(); 1290 1291 input2 >> neues->x.x[0]; // x 1291 1292 input2 >> neues->x.x[1]; // y … … 1777 1778 }; 1778 1779 1780 1781 /** Tries given filename or standard on saving the config file. 1782 * \param *ConfigFileName name of file 1783 * \param *periode pointer to periodentafel structure with all the elements 1784 * \param *molecules list of molecules structure with all the atoms and coordinates 1785 */ 1786 void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules) 1787 { 1788 char filename[MAXSTRINGSIZE]; 1789 ofstream output; 1790 molecule *mol = new molecule(periode); 1791 mol->SetNameFromFilename(ConfigFileName); 1792 1793 if (!strcmp(configpath, GetDefaultPath())) { 1794 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1795 } 1796 1797 1798 // first save as PDB data 1799 if (ConfigFileName != NULL) 1800 strcpy(filename, ConfigFileName); 1801 if (output == NULL) 1802 strcpy(filename,"main_pcp_linux"); 1803 Log() << Verbose(0) << "Saving as pdb input "; 1804 if (SavePDB(filename, molecules)) 1805 Log() << Verbose(0) << "done." << endl; 1806 else 1807 Log() << Verbose(0) << "failed." << endl; 1808 1809 // then save as tremolo data file 1810 if (ConfigFileName != NULL) 1811 strcpy(filename, ConfigFileName); 1812 if (output == NULL) 1813 strcpy(filename,"main_pcp_linux"); 1814 Log() << Verbose(0) << "Saving as tremolo data input "; 1815 if (SaveTREMOLO(filename, molecules)) 1816 Log() << Verbose(0) << "done." << endl; 1817 else 1818 Log() << Verbose(0) << "failed." << endl; 1819 1820 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1821 int N = molecules->ListOfMolecules.size(); 1822 int *src = new int[N]; 1823 N=0; 1824 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1825 src[N++] = (*ListRunner)->IndexNr; 1826 (*ListRunner)->Translate(&(*ListRunner)->Center); 1827 } 1828 molecules->SimpleMultiAdd(mol, src, N); 1829 delete[](src); 1830 1831 // ... and translate back 1832 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1833 (*ListRunner)->Center.Scale(-1.); 1834 (*ListRunner)->Translate(&(*ListRunner)->Center); 1835 (*ListRunner)->Center.Scale(-1.); 1836 } 1837 1838 Log() << Verbose(0) << "Storing configuration ... " << endl; 1839 // get correct valence orbitals 1840 mol->CalculateOrbitals(*this); 1841 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble; 1842 if (ConfigFileName != NULL) { // test the file name 1843 strcpy(filename, ConfigFileName); 1844 output.open(filename, ios::trunc); 1845 } else if (strlen(configname) != 0) { 1846 strcpy(filename, configname); 1847 output.open(configname, ios::trunc); 1848 } else { 1849 strcpy(filename, DEFAULTCONFIG); 1850 output.open(DEFAULTCONFIG, ios::trunc); 1851 } 1852 output.close(); 1853 output.clear(); 1854 Log() << Verbose(0) << "Saving of config file "; 1855 if (Save(filename, periode, mol)) 1856 Log() << Verbose(0) << "successful." << endl; 1857 else 1858 Log() << Verbose(0) << "failed." << endl; 1859 1860 // and save to xyz file 1861 if (ConfigFileName != NULL) { 1862 strcpy(filename, ConfigFileName); 1863 strcat(filename, ".xyz"); 1864 output.open(filename, ios::trunc); 1865 } 1866 if (output == NULL) { 1867 strcpy(filename,"main_pcp_linux"); 1868 strcat(filename, ".xyz"); 1869 output.open(filename, ios::trunc); 1870 } 1871 Log() << Verbose(0) << "Saving of XYZ file "; 1872 if (mol->MDSteps <= 1) { 1873 if (mol->OutputXYZ(&output)) 1874 Log() << Verbose(0) << "successful." << endl; 1875 else 1876 Log() << Verbose(0) << "failed." << endl; 1877 } else { 1878 if (mol->OutputTrajectoriesXYZ(&output)) 1879 Log() << Verbose(0) << "successful." << endl; 1880 else 1881 Log() << Verbose(0) << "failed." << endl; 1882 } 1883 output.close(); 1884 output.clear(); 1885 1886 // and save as MPQC configuration 1887 if (ConfigFileName != NULL) 1888 strcpy(filename, ConfigFileName); 1889 if (output == NULL) 1890 strcpy(filename,"main_pcp_linux"); 1891 Log() << Verbose(0) << "Saving as mpqc input "; 1892 if (SaveMPQC(filename, mol)) 1893 Log() << Verbose(0) << "done." << endl; 1894 else 1895 Log() << Verbose(0) << "failed." << endl; 1896 1897 if (!strcmp(configpath, GetDefaultPath())) { 1898 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1899 } 1900 1901 delete(mol); 1902 }; 1903 1779 1904 /** Reads parameter from a parsed file. 1780 1905 * The file is either parsed for a certain keyword or if null is given for
Note:
See TracChangeset
for help on using the changeset viewer.