Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    rcd7b0f r235bed  
    140140void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms)
    141141{
    142   map<const char *, int, IonTypeCompare> IonTypeLineMap;
     142  map<const char *, int, IonTypeCompare> LineList;
    143143  if (LineMapping == NULL) {
    144144    eLog() << Verbose(0) << "map pointer is NULL: " << LineMapping << endl;
     
    149149  // put all into hashed map
    150150  for (int i=0; i<NoAtoms; ++i) {
    151     IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
     151    LineList.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i));
    152152  }
    153153
    154154  // fill map
    155155  int nr=0;
    156   for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {
     156  for (map<const char *, int, IonTypeCompare>::iterator runner = LineList.begin(); runner != LineList.end(); ++runner) {
    157157    if (CurrentLine+nr < NoLines)
    158158      LineMapping[CurrentLine+(nr++)] = runner->second;
     
    10561056
    10571057  // 2. parse the bond graph file if given
    1058   if (BG == NULL) {
    1059     BG = new BondGraph(IsAngstroem);
    1060     if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1061       Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
    1062     } else {
    1063       eLog() << Verbose(1) << "Bond length table loading failed." << endl;
    1064     }
     1058  BG = new BondGraph(IsAngstroem);
     1059  if (BG->LoadBondLengthTable(BondGraphFileName)) {
     1060    Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1061  } else {
     1062    eLog() << Verbose(1) << "Bond length table loading failed." << endl;
    10651063  }
    10661064
    10671065  // 3. parse the molecule in
    10681066  LoadMolecule(mol, FileBuffer, periode, FastParsing);
    1069   mol->SetNameFromFilename(filename);
    10701067  mol->ActiveFlag = true;
    1071   MolList->insert(mol);
    10721068
    10731069  // 4. dissect the molecule into connected subgraphs
    1074   // don't do this here ...
    1075   //MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
    1076   //delete(mol);
    1077 
     1070  MolList->DissectMoleculeIntoConnectedSubgraphs(mol,this);
     1071
     1072  delete(mol);
    10781073  delete(FileBuffer);
    10791074};
     
    17761771};
    17771772
     1773
     1774/** Tries given filename or standard on saving the config file.
     1775 * \param *ConfigFileName name of file
     1776 * \param *periode pointer to periodentafel structure with all the elements
     1777 * \param *molecules list of molecules structure with all the atoms and coordinates
     1778 */
     1779void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules)
     1780{
     1781  char filename[MAXSTRINGSIZE];
     1782  ofstream output;
     1783  molecule *mol = new molecule(periode);
     1784
     1785  if (!strcmp(configpath, GetDefaultPath())) {
     1786    eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
     1787  }
     1788
     1789
     1790  // first save as PDB data
     1791  if (ConfigFileName != NULL)
     1792    strcpy(filename, ConfigFileName);
     1793  else
     1794    strcpy(filename,"main_pcp_linux");
     1795  Log() << Verbose(0) << "Saving as pdb input ";
     1796  if (SavePDB(filename, molecules))
     1797    Log() << Verbose(0) << "done." << endl;
     1798  else
     1799    Log() << Verbose(0) << "failed." << endl;
     1800
     1801  // then save as tremolo data file
     1802  if (ConfigFileName != NULL)
     1803    strcpy(filename, ConfigFileName);
     1804  else
     1805    strcpy(filename,"main_pcp_linux");
     1806  Log() << Verbose(0) << "Saving as tremolo data input ";
     1807  if (SaveTREMOLO(filename, molecules))
     1808    Log() << Verbose(0) << "done." << endl;
     1809  else
     1810    Log() << Verbose(0) << "failed." << endl;
     1811
     1812  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     1813  int N = molecules->ListOfMolecules.size();
     1814  int *src = new int[N];
     1815  N=0;
     1816  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1817    src[N++] = (*ListRunner)->IndexNr;
     1818    (*ListRunner)->Translate(&(*ListRunner)->Center);
     1819  }
     1820  molecules->SimpleMultiAdd(mol, src, N);
     1821  delete[](src);
     1822
     1823  // ... and translate back
     1824  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1825    (*ListRunner)->Center.Scale(-1.);
     1826    (*ListRunner)->Translate(&(*ListRunner)->Center);
     1827    (*ListRunner)->Center.Scale(-1.);
     1828  }
     1829
     1830  Log() << Verbose(0) << "Storing configuration ... " << endl;
     1831  // get correct valence orbitals
     1832  mol->CalculateOrbitals(*this);
     1833  InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;
     1834  if (ConfigFileName != NULL) { // test the file name
     1835    strcpy(filename, ConfigFileName);
     1836    output.open(filename, ios::trunc);
     1837  } else if (strlen(configname) != 0) {
     1838    strcpy(filename, configname);
     1839    output.open(configname, ios::trunc);
     1840    } else {
     1841      strcpy(filename, DEFAULTCONFIG);
     1842      output.open(DEFAULTCONFIG, ios::trunc);
     1843    }
     1844  output.close();
     1845  output.clear();
     1846  Log() << Verbose(0) << "Saving of config file ";
     1847  if (Save(filename, periode, mol))
     1848    Log() << Verbose(0) << "successful." << endl;
     1849  else
     1850    Log() << Verbose(0) << "failed." << endl;
     1851
     1852  // and save to xyz file
     1853  if (ConfigFileName != NULL) {
     1854    strcpy(filename, ConfigFileName);
     1855    strcat(filename, ".xyz");
     1856    output.open(filename, ios::trunc);
     1857  }
     1858  else {
     1859    strcpy(filename,"main_pcp_linux");
     1860    strcat(filename, ".xyz");
     1861    output.open(filename, ios::trunc);
     1862  }
     1863  Log() << Verbose(0) << "Saving of XYZ file ";
     1864  if (mol->MDSteps <= 1) {
     1865    if (mol->OutputXYZ(&output))
     1866      Log() << Verbose(0) << "successful." << endl;
     1867    else
     1868      Log() << Verbose(0) << "failed." << endl;
     1869  } else {
     1870    if (mol->OutputTrajectoriesXYZ(&output))
     1871      Log() << Verbose(0) << "successful." << endl;
     1872    else
     1873      Log() << Verbose(0) << "failed." << endl;
     1874  }
     1875  output.close();
     1876  output.clear();
     1877
     1878  // and save as MPQC configuration
     1879  if (ConfigFileName != NULL)
     1880    strcpy(filename, ConfigFileName);
     1881  else
     1882    strcpy(filename,"main_pcp_linux");
     1883  Log() << Verbose(0) << "Saving as mpqc input ";
     1884  if (SaveMPQC(filename, mol))
     1885    Log() << Verbose(0) << "done." << endl;
     1886  else
     1887    Log() << Verbose(0) << "failed." << endl;
     1888
     1889  if (!strcmp(configpath, GetDefaultPath())) {
     1890    eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
     1891  }
     1892
     1893  delete(mol);
     1894};
     1895
    17781896/** Reads parameter from a parsed file.
    17791897 * 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.