Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/moleculelist.cpp

    • Property mode changed from 100755 to 100644
    r2746be redcda5  
    378378 * \param *configuration standard configuration to attach atoms in fragment molecule to.
    379379 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config
     380 * \param DoPeriodic true - call ScanForPeriodicCorrection, false - don't
     381 * \param DoCentering true - call molecule::CenterEdge(), false - don't
    380382 * \return true - success (each file was written), false - something went wrong.
    381383 */
    382 bool MoleculeListClass::OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex)
     384bool MoleculeListClass::OutputConfigForListOfFragments(ofstream *out, const char *fragmentprefix, config *configuration, int *SortIndex, bool DoPeriodic, bool DoCentering)
    383385{
    384386  ofstream outputFragment;
     
    393395  int FragmentCounter = 0;
    394396  ofstream output;
    395   string basis("3-21G");
    396397 
    397398  // store the fragments as config and as xyz
     
    405406
    406407    // correct periodic
    407     //ListOfMolecules[i]->ScanForPeriodicCorrection(out);
     408    if (DoPeriodic)
     409      ListOfMolecules[i]->ScanForPeriodicCorrection(out);
    408410
    409411    // output xyz file
    410412    FragmentNumber = FixedDigitNumber(NumberOfMolecules, FragmentCounter++);
    411     sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
     413    sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, fragmentprefix, FragmentNumber);
    412414    outputFragment.open(FragmentName, ios::out);
    413     *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as XYZ ...";
     415    *out << Verbose(2) << "Saving " << fragmentprefix << " No. " << FragmentNumber << "/" << FragmentCounter-1 << " as XYZ ...";
    414416    if ((intermediateResult = ListOfMolecules[i]->OutputXYZ(&outputFragment)))
    415417      *out << " done." << endl;
     
    430432   
    431433    // center on edge
    432     ListOfMolecules[i]->CenterEdge(out, &BoxDimension);
    433     ListOfMolecules[i]->SetBoxDimension(&BoxDimension);  // update Box of atoms by boundary
    434     int j = -1;
    435     for (int k=0;k<NDIM;k++) {
    436       j += k+1;
    437       BoxDimension.x[k] = 2.5* (configuration->GetIsAngstroem() ? 1. : 1./AtomicLengthToAngstroem);
    438       ListOfMolecules[i]->cell_size[j] += BoxDimension.x[k]*2.;
    439     }
    440     ListOfMolecules[i]->Translate(&BoxDimension);
     434    if (DoCentering) {
     435      ListOfMolecules[i]->CenterEdge(out, &BoxDimension);
     436      ListOfMolecules[i]->SetBoxDimension(&BoxDimension);  // update Box of atoms by boundary
     437      int j = -1;
     438      for (int k=0;k<NDIM;k++) {
     439        j += k+1;
     440        BoxDimension.x[k] = 2.5* (configuration->GetIsAngstroem() ? 1. : 1./AtomicLengthToAngstroem);
     441        ListOfMolecules[i]->cell_size[j] += BoxDimension.x[k]*2.;
     442      }
     443      ListOfMolecules[i]->Translate(&BoxDimension);
     444    }
    441445
    442446    // also calculate necessary orbitals
     
    446450    // change path in config
    447451    //strcpy(PathBackup, configuration->configpath);
    448     sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber);
     452    sprintf(FragmentName, "%s/%s%s/", PathBackup, fragmentprefix, FragmentNumber);
    449453    configuration->SetDefaultPath(FragmentName);
    450454   
    451455    // and save as config
    452     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    453     *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as config ...";
    454     if ((intermediateResult = configuration->Save(FragmentName, ListOfMolecules[i]->elemente, ListOfMolecules[i])))
     456    sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, fragmentprefix, FragmentNumber);
     457    outputFragment.open(FragmentName, ios::out);
     458    *out << Verbose(2) << "Saving " << fragmentprefix << " No. " << FragmentNumber << "/" << FragmentCounter-1 << " as config ...";
     459    if ((intermediateResult = configuration->Save(&outputFragment, ListOfMolecules[i]->elemente, ListOfMolecules[i])))
    455460      *out << " done." << endl;
    456461    else
    457462      *out << " failed." << endl;
    458     result = result && intermediateResult;
    459463
    460464    // restore old config
    461465    configuration->SetDefaultPath(PathBackup);
    462466
     467    result = result && intermediateResult;
     468    outputFragment.close();
     469    outputFragment.clear();
    463470
    464471    // and save as mpqc input file
    465     sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber);
    466     *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as mpqc input ...";
    467     if ((intermediateResult = configuration->SaveMPQC(FragmentName, ListOfMolecules[i])))
     472    sprintf(FragmentName, "%s/%s%s.in", configuration->configpath, fragmentprefix, FragmentNumber);
     473    outputFragment.open(FragmentName, ios::out);
     474    *out << Verbose(2) << "Saving " << fragmentprefix << " No. " << FragmentNumber << "/" << FragmentCounter-1 << " as mpqc input ...";
     475    if ((intermediateResult = configuration->SaveMPQC(&outputFragment, ListOfMolecules[i])))
    468476      *out << " done." << endl;
    469477    else
     
    471479       
    472480    result = result && intermediateResult;
    473     //outputFragment.close();
    474     //outputFragment.clear();
     481    outputFragment.close();
     482    outputFragment.clear();
    475483    delete(FragmentNumber);
    476484    //Free((void **)&FragmentNumber, "MoleculeListClass::OutputConfigForListOfFragments: *FragmentNumber");
Note: See TracChangeset for help on using the changeset viewer.