Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    rcbc5fb r49e1ae  
    88#include <cstring>
    99
    10 #include "World.hpp"
    1110#include "atom.hpp"
    1211#include "bond.hpp"
     
    733732            sprintf(keyword,"%s_%i",name, j+1);
    734733            if (repetition == 0) {
    735               neues = World::get()->createAtom();
     734              neues = new atom();
    736735              AtomList[i][j] = neues;
    737736              LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
     
    812811          sprintf(keyword,"%s_%i",name, j+1);
    813812          if (repetition == 0) {
    814             neues = World::get()->createAtom();
     813            neues = new atom();
    815814            AtomList[i][j] = neues;
    816815            LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues;
     
    851850void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
    852851{
    853   molecule *mol = World::get()->createMolecule();
     852  molecule *mol = new molecule(periode);
    854853  ifstream *file = new ifstream(filename);
    855854  if (file == NULL) {
     
    10891088void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList)
    10901089{
    1091   molecule *mol = World::get()->createMolecule();
     1090  molecule *mol = new molecule(periode);
    10921091  ifstream *file = new ifstream(filename);
    10931092  if (file == NULL) {
     
    12881287        }
    12891288        istringstream input2(zeile);
    1290         atom *neues = World::get()->createAtom();
     1289        atom *neues = new atom();
    12911290        input2 >> neues->x.x[0]; // x
    12921291        input2 >> neues->x.x[1]; // y
     
    17781777};
    17791778
    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 = World::get()->createMolecule();
    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   World::get()->destroyMolecule(mol);
    1902 };
    1903 
    19041779/** Reads parameter from a parsed file.
    19051780 * 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.