Changeset 5e0d1f


Ignore:
Timestamp:
Aug 6, 2008, 12:00:18 PM (16 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:
9e5a04d
Parents:
e9b8bb
Message:

config::Save() and config::Load() parse MD steps into and out of molecule::Trajectories. Tested.

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/config.cpp

    re9b8bb r5e0d1f  
    461461  int Z, No[MAX_ELEMENTS];
    462462  int verbose = 0;
     463  int MinSteps = -1;
    463464 
    464465  /* Namen einlesen */
     
    652653        while (ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition, (repetition == 1) ? critical : optional) &&
    653654          ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition, (repetition == 1) ? critical : optional) &&
    654           ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition, (repetition == 1) ? critical : optional))
     655          ParseForParameter(verbose,file, keyword, 0, 3, 1, double_type, &neues->x.x[2], repetition, (repetition == 1) ? critical : optional)) {
     656          // check size of vectors
     657          if (mol->Trajectories[neues].R.size() <= (unsigned int)(repetition-1)) {
     658            cout << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl;
     659            mol->Trajectories[neues].R.resize(repetition+10);
     660            mol->Trajectories[neues].U.resize(repetition+10);
     661            mol->Trajectories[neues].F.resize(repetition+10);
     662          }
     663           
     664          // put into trajectories list
     665          for (int d=0;d<NDIM;d++)
     666            mol->Trajectories[neues].R.at(repetition-1).x[d] = neues->x.x[d];
     667         
     668          // parse velocities if present
     669          if(!ParseForParameter(verbose,file, keyword, 0, 5, 1, double_type, &neues->v.x[0], repetition,optional))
     670            neues->v.x[0] = 0.;
     671          if(!ParseForParameter(verbose,file, keyword, 0, 6, 1, double_type, &neues->v.x[1], repetition,optional))
     672            neues->v.x[1] = 0.;
     673          if(!ParseForParameter(verbose,file, keyword, 0, 7, 1, double_type, &neues->v.x[2], repetition,optional))
     674            neues->v.x[2] = 0.;
     675          for (int d=0;d<NDIM;d++)
     676            mol->Trajectories[neues].U[repetition-1].x[d] = neues->v.x[d];
     677         
     678          // parse forces if present
     679          if(!ParseForParameter(verbose,file, keyword, 0, 8, 1, double_type, &neues->v.x[0], repetition,optional))
     680            neues->v.x[0] = 0.;
     681          if(!ParseForParameter(verbose,file, keyword, 0, 9, 1, double_type, &neues->v.x[1], repetition,optional))
     682            neues->v.x[1] = 0.;
     683          if(!ParseForParameter(verbose,file, keyword, 0, 10, 1, double_type, &neues->v.x[2], repetition,optional))
     684            neues->v.x[2] = 0.;
     685          for (int d=0;d<NDIM;d++)
     686            mol->Trajectories[neues].F[repetition-1].x[d] = neues->v.x[d];
     687         
     688          cout << "Parsed position of step " << (repetition-1) << " ";
     689          for (int d=0;d<NDIM;d++)
     690            cout << mol->Trajectories[neues].R.at(repetition-1).x[d] << "  ";          // next step
     691          cout << endl;
     692         
    655693          repetition++;
     694        }
    656695        repetition--;
    657         //cout << "Found " << repetition << " times of the keyword " << keyword << "." << endl;
     696        cout << "Found " << repetition << " times of the keyword " << keyword << "." << endl;
    658697      }
     698      if ((repetition < MinSteps) || (MinSteps == -1))
     699        MinSteps = repetition;
    659700      ParseForParameter(verbose,file, keyword, 0, 1, 1, double_type, &neues->x.x[0], repetition,critical);
    660701      ParseForParameter(verbose,file, keyword, 0, 2, 1, double_type, &neues->x.x[1], repetition,critical);
     
    667708      if(!ParseForParameter(verbose,file, keyword, (int)FastParsing, 7, 1, double_type, &neues->v.x[2], repetition,optional))
    668709        neues->v.x[2] = 0.;
     710      // here we don't care if forces are present (last in trajectories is always equal to current position)
    669711      neues->type = elementhash[i]; // find element type
    670712      mol->AddAtom(neues);
    671713    }
    672714  }
     715  mol->MDSteps = MinSteps;    // set equal to smallest number of parsed steps
    673716  file->close();
    674717  delete(file);
     
    9721015    *output << endl;
    9731016    result = result && mol->Checkout(output);
    974     result = result && mol->Output(output);
     1017    result = result && mol->OutputTrajectories(output);
    9751018    return result;
    9761019  } else
  • src/molecules.cpp

    re9b8bb r5e0d1f  
    4747  link(first,last);
    4848  // other stuff
     49  MDSteps = 0;
    4950  last_atom = 0;
    5051  elemente = teil;
     
    983984  int i, Ion[2];
    984985  double a, IonMass;
     986  unsigned int size;
    985987
    986988  CountElements();  // make sure ElementsInMolecule is up to date
     
    10441046           
    10451047           
     1048            // check size of vectors
     1049            size = Trajectories[walker].R.size();
     1050            if (size <= (unsigned int)(MDSteps)) {
     1051              cout << "Increasing size for trajectory array of " << *walker << " to " << (size+10) << "." << endl;
     1052              Trajectories[walker].R.resize(size+10);
     1053              Trajectories[walker].U.resize(size+10);
     1054              Trajectories[walker].F.resize(size+10);
     1055            }
    10461056            // add trajectory point
    10471057
     
    12941304bool molecule::Output(ofstream *out)
    12951305{
    1296   element *runner = elemente->start;
     1306  element *runner;
    12971307  atom *walker = NULL;
    12981308  int ElementNo, AtomNo;
     
    13041314    *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
    13051315    ElementNo = 0;
     1316    runner = elemente->start;
    13061317    while (runner->next != elemente->end) { // go through every element
    13071318                runner = runner->next;
     
    13141325          if (walker->type == runner) { // if this atom fits to element
    13151326            AtomNo++;
    1316             walker->Output(ElementNo, AtomNo, out);
     1327            walker->Output(ElementNo, AtomNo, out); // removed due to trajectories
     1328          }
     1329        }
     1330      }
     1331    }
     1332    return true;
     1333  }
     1334};
     1335
     1336/** Prints molecule with all atomic trajectory positions to *out.
     1337 * \param *out output stream
     1338 */
     1339bool molecule::OutputTrajectories(ofstream *out)
     1340{
     1341  element *runner = NULL;
     1342  atom *walker = NULL;
     1343  int ElementNo, AtomNo;
     1344  CountElements();
     1345 
     1346  if (out == NULL) {
     1347    return false;
     1348  } else {
     1349    for (int step = 0; step < MDSteps; step++) {
     1350      if (step == 0) {
     1351        *out << "#Ion_TypeNr._Nr.R[0]    R[1]    R[2]    MoveType (0 MoveIon, 1 FixedIon)" << endl;
     1352      } else {
     1353        *out << "# ====== MD step " << step << " =========" << endl;
     1354      }
     1355      ElementNo = 0;
     1356      runner = elemente->start;
     1357      while (runner->next != elemente->end) { // go through every element
     1358        runner = runner->next;
     1359        if (ElementsInMolecule[runner->Z]) { // if this element got atoms
     1360          ElementNo++;
     1361          AtomNo = 0;
     1362          walker = start;
     1363          while (walker->next != end) { // go through every atom of this element
     1364            walker = walker->next;
     1365            if (walker->type == runner) { // if this atom fits to element
     1366              AtomNo++;
     1367              *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
     1368              *out << Trajectories[walker].R.at(step).x[0] << "\t" << Trajectories[walker].R.at(step).x[1] << "\t" << Trajectories[walker].R.at(step).x[2];
     1369              *out << "\t" << walker->FixedIon;
     1370              if (Trajectories[walker].U.at(step).Norm() > MYEPSILON)
     1371                *out << "\t" << scientific << setprecision(6) << Trajectories[walker].U.at(step).x[0] << "\t" << Trajectories[walker].U.at(step).x[1] << "\t" << Trajectories[walker].U.at(step).x[2] << "\t";
     1372              if (Trajectories[walker].F.at(step).Norm() > MYEPSILON)
     1373                *out << "\t" << scientific << setprecision(6) << Trajectories[walker].F.at(step).x[0] << "\t" << Trajectories[walker].F.at(step).x[1] << "\t" << Trajectories[walker].F.at(step).x[2] << "\t";
     1374              *out << " # Number in molecule " << walker->nr << endl;
     1375            }
    13171376          }
    13181377        }
  • src/molecules.hpp

    re9b8bb r5e0d1f  
    2121#include <deque>
    2222#include <list>
     23#include <vector>
    2324
    2425#include "helpers.hpp"
     
    5152struct Trajectory
    5253{
    53   double R[3];  //!< position vector
    54   double U[3];    //!< velocity vector
    55   double F[3];    //!< last force vector
     54  vector<Vector> R;  //!< position vector
     55  vector<Vector> U;  //!< velocity vector
     56  vector<Vector> F;  //!< last force vector
     57  atom *ptr;         //!< pointer to atom whose trajectory we contain
    5658};
    5759
     
    178180    bond *last;         //!< end of bond list
    179181    bond ***ListOfBondsPerAtom; //!< pointer list for each atom and each bond it has
     182    map<atom *, struct Trajectory> Trajectories; //!< contains old trajectory points
     183    int MDSteps;        //!< The number of MD steps in Trajectories
    180184    int *NumberOfBondsPerAtom;  //!< Number of Bonds each atom has
    181185    int AtomCount;                                      //!< number of atoms, brought up-to-date by CountAtoms()
     
    279283  // Output routines.
    280284  bool Output(ofstream *out);
     285  bool OutputTrajectories(ofstream *out);
    281286  void OutputListOfBonds(ofstream *out) const;
    282287  bool OutputXYZ(ofstream *out) const;
Note: See TracChangeset for help on using the changeset viewer.