Changeset f7c19e for src


Ignore:
Timestamp:
Oct 6, 2011, 9:09:56 AM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
81c980b
Parents:
dc8827
git-author:
Frederik Heber <heber@…> (08/09/11 16:39:43)
git-committer:
Frederik Heber <heber@…> (10/06/11 09:09:56)
Message:

Some fixes to parsing files.

  • MpqcParser::save() does not store all atoms but those given in the parameters.
  • FIX: MoleculeListClass::AddHydrogenCorrection() and FilePresent() check with bad() and eof() whether file is missing or has ended.
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/MpqcParser.cpp

    rdc8827 rf7c19e  
    214214{
    215215  Vector center;
    216   vector<atom *> allatoms = World::getInstance().getAllAtoms();
     216//  vector<atom *> allatoms = World::getInstance().getAllAtoms();
    217217
    218218  // calculate center
    219   for (vector<atom *>::iterator runner = allatoms.begin();runner != allatoms.end(); ++runner)
     219  for (std::vector<atom *>::const_iterator runner = atoms.begin();runner != atoms.end(); ++runner)
    220220    center += (*runner)->getPosition();
    221   center.Scale(1./(double)allatoms.size());
     221  center.Scale(1./(double)atoms.size());
    222222
    223223  // first without hessian
     
    293293    *file << "\t{ atoms geometry } = {" << endl;
    294294    // output of atoms
    295     for (vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
     295    for (std::vector<atom *>::const_iterator AtomRunner = atoms.begin(); AtomRunner != atoms.end(); ++AtomRunner) {
    296296      (*AtomRunner)->OutputMPQCLine(file, &center);
    297297    }
  • src/moleculelist.cpp

    rdc8827 rf7c19e  
    3838#include "linkedcell.hpp"
    3939#include "molecule.hpp"
     40#include "Parser/MpqcParser.hpp"
     41#include "Parser/FormatParserStorage.hpp"
    4042#include "periodentafel.hpp"
    4143#include "tesselation.hpp"
     
    341343    line += FITCONSTANTSUFFIX;
    342344    input.open(line.c_str());
    343     if (input == NULL) {
     345    if (input.fail()) {
    344346      DoeLog(0) && (eLog()<< Verbose(0) << endl << "Unable to open " << line << ", is the directory correct?" << endl);
    345347      performCriticalExit();
     
    615617      // and save as mpqc input file
    616618      stringstream output;
    617       FragmentName = prefix + FragmentNumber + ".conf";
     619      FragmentName = prefix + FragmentNumber + ".conf.in";
    618620      output << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ... ";
    619       if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
     621      std::ofstream outfile(FragmentName.c_str());
     622      std::vector<atom *> atoms;
     623      for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter)
     624        atoms.push_back(*iter);
     625//      atoms.resize((*ListRunner)->getAtomCount());
     626//      std::copy((*ListRunner)->begin(), (*ListRunner)->end(), atoms.begin());
     627      FormatParserStorage::getInstance().getMpqc().save(&outfile, atoms);
     628//      if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))
    620629        output << " done.";
    621       else
    622         output << " failed.";
     630//      else
     631//        output << " failed.";
    623632      LOG(3, output.str());
    624633    }
  • src/parser.cpp

    rdc8827 rf7c19e  
    4545
    4646  input.open(filename, ios::in);
    47   if (input == NULL) {
     47  if (input.fail()) {
    4848    if (!test)
    4949      DoLog(0) && (Log() << Verbose(0) << endl << "FilePresent: Unable to open " << filename << ", is the directory correct?" << endl);
     
    204204  char filename[1023];
    205205
    206   //Log() << Verbose(1) << "Opening " << name << " ... "  << input << endl;
    207   if (input.bad()) {
     206  if (input.fail()) {
    208207    DoeLog(1) && (eLog()<< Verbose(1) << endl << "MatrixContainer::ParseMatrix: Unable to parse istream." << endl);
    209208    //performCriticalExit();
     
    327326  file << name << FRAGMENTPREFIX << KEYSETFILE;
    328327  input.open(file.str().c_str(), ios::in);
    329   if (input == NULL) {
     328  if (input.bad()) {
    330329    DoLog(0) && (Log() << Verbose(0) << endl << "MatrixContainer::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);
    331330    return false;
     
    360359    file << name << FRAGMENTPREFIX << FragmentNumber << prefix << suffix;
    361360    std::ifstream input(file.str().c_str());
     361    DoLog(0) &&( Log() << Verbose(0) << "Opening " << file.str() << " ... " << endl);
    362362    if (!ParseMatrix(input, skiplines, skipcolumns, i)) {
    363363      input.close();
     
    704704  input.open(line.str().c_str(), ios::in);
    705705  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    706   if (input == NULL) {
     706  if (input.fail()) {
    707707    DoLog(0) && (Log() << Verbose(0) << endl << "ForceMatrix::ParseIndices: Unable to open " << line.str() << ", is the directory correct?" << endl);
    708708    return false;
     
    783783    file << name << FRAGMENTPREFIX << KEYSETFILE;
    784784    input.open(file.str().c_str(), ios::in);
    785     if (input == NULL) {
     785    if (input.fail()) {
    786786      DoLog(0) && (Log() << Verbose(0) << endl << "ForceMatrix::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);
    787787      return false;
     
    844844  input.open(line.str().c_str(), ios::in);
    845845  //Log() << Verbose(0) << "Opening " << line.str() << " ... "  << input << endl;
    846   if (input == NULL) {
     846  if (input.fail()) {
    847847    DoLog(0) && (Log() << Verbose(0) << endl << "HessianMatrix::ParseIndices: Unable to open " << line.str() << ", is the directory correct?" << endl);
    848848    return false;
     
    10151015    file << name << FRAGMENTPREFIX << KEYSETFILE;
    10161016    input.open(file.str().c_str(), ios::in);
    1017     if (input == NULL) {
     1017    if (input.fail()) {
    10181018      DoLog(0) && (Log() << Verbose(0) << endl << "HessianMatrix::ParseFragmentMatrix: Unable to open " << file.str() << ", is the directory correct?" << endl);
    10191019      return false;
     
    11011101  file << name << FRAGMENTPREFIX << KEYSETFILE;
    11021102  input.open(file.str().c_str(), ios::in);
    1103   if (input == NULL) {
     1103  if (input.fail()) {
    11041104    DoLog(0) && (Log() << Verbose(0) << endl << "KeySetsContainer::ParseKeySets: Unable to open " << file.str() << ", is the directory correct?" << endl);
    11051105    return false;
Note: See TracChangeset for help on using the changeset viewer.