Ignore:
Timestamp:
Aug 18, 2008, 8:57:58 AM (17 years ago)
Author:
Frederik Heber <heber@…>
Children:
04c868
Parents:
e6971b
Message:

Adaptivity fixes, MD by VerletForceIntegration introduced, MD molecule::Trajectories, atom Max::Order, no more recursive going down the fragmentation level

MD
==
molecule::Trajectories is now a map to a struct trajectory list of all the MD steps.
struct Trajectory contains STL vectors of coordinates, velocities and forces. Both are needed for the new VerletForceIntegration.
Parsing of coordinates, velocities and forces from the config file was completely rewritten:

  • in the FastParsing case, we just scan for IonType1_1 to find the last step, set the file pointer there and scan all remaining ones
  • in the other case, we create the atoms in the first step and put them in a hash for lookup on later steps and read in sequentially (with file pointer moving on).
  • This is a lot faster than the old variant.

VerletForceIntegration() implemented in a working manner with force smoothing (mean of actual and last one).
OutputTrajectoriesXYZ() now concatenates the single MD steps into one xyz file, so that the animation can be viewed with e.g. jmol or vmd
config:Deltat is now public (lazy me) and set to 1 instead of 0 initially, also Deltat is parsed accordingly (if not present, defaults to 1)
MatrixContainer::ParseMatrix from parser.cpp is used during VerletForceIntegration() to parse the forces file. Consequently, we have included parser.* in the Makefile.am.
Fix: MoleculeListClass::OutputConfigForListOfFragments() stores config file under config::configpath, before it backup'd the path twice to PathBackup.

Adaptivity
==========
Adaptivity (CheckOrderAtSite()) had compared not absolute, but real values which caused sign problems and faulty behaviour.
Adapatvity (CheckOrderAtSite()) had included atoms by Order (desired one) not by FragOrder (current one) into the list of candidates, which caused faulty behaviour.
CheckOrderAtSite() did single stepping wrong as the mask bit (last in AtomMask) was checked for true not false! Also bit was not set to false initially in FragmentMolecule().
Adaptivity: FragmentMolecule now returns 1 - continue, 2 - don't ... to tell whether we still have to continue with the adaptive cycle (is given as return value from molecuilder)
introduced atom::MaxOrder
StoreOrderAtSiteFile() now also stores the MaxOrder and ParseOrderAtSiteFromFile() parses it back into atom class

Removed Fragmentation Recursion
===============================
As we switched in the prelude of the adaptivity to a monotonous increase from order 1 to the desired one, we don't need to recursively go down each level from a given current bond order, as all these fragments have already been created on the lower orders. Consequently, FragmentBOSSANOVA does not contain NumLevels or alike anymore. This simplified the code a bit, but probably is not yet completely done. (but is working, checked on heptan).
SPFragmentGenerator() does not need Labels anymore, global ones are used for checks. Consequently, PowerSetGenerator() and FragmentSearch structure don't initialise/contain them anymore. We always compare against ...->GetTrueFather()->nr.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/builder.cpp

    re6971b r644ba1  
    703703    output.open(filename, ios::trunc);
    704704  }
    705   if (mol->OutputXYZ(&output))
    706     cout << Verbose(0) << "Saving of XYZ file successful." << endl;
    707   else
    708     cout << Verbose(0) << "Saving of XYZ file failed." << endl;
     705  if (mol->MDSteps <= 1) {
     706    if (mol->OutputXYZ(&output))
     707      cout << Verbose(0) << "Saving of XYZ file successful." << endl;
     708    else
     709      cout << Verbose(0) << "Saving of XYZ file failed." << endl;
     710  } else {
     711    if (mol->OutputTrajectoriesXYZ(&output))
     712      cout << Verbose(0) << "Saving of XYZ file successful." << endl;
     713    else
     714      cout << Verbose(0) << "Saving of XYZ file failed." << endl;
     715  }
    709716  output.close();
    710717  output.clear();
     
    733740  string line;
    734741  atom *first;
    735   int ExitFlag = 0;
     742  bool SaveFlag = false;
     743  int ExitFlag = 1;
    736744  int j;
    737745  double volume = 0.;
     
    758766            cout << "\t-b x1 x2 x3\tCenter atoms in domain with given edge lengths of (x1,x2,x3)." << endl;
    759767            cout << "\t-c x1 x2 x3\tCenter atoms in domain with a minimum distance to boundary of (x1,x2,x3)." << endl;
     768            cout << "\t-D <bond distance>\tDepth-First-Search Analysis of the molecule, giving cycles and tree/back edges." << endl;
    760769            cout << "\t-O\tCenter atoms in origin." << endl;
    761770            cout << "\t-d x1 x2 x3\tDuplicate cell along each axis by given factor." << endl;
    762771            cout << "\t-e <file>\tSets the databases path to be parsed (default: ./)." << endl;
    763             cout << "\t-f/F <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config." << endl;
     772            cout << "\t-f/F <dist> <order>\tFragments the molecule in BOSSANOVA manner (with/out rings compressed) and stores config files in same dir as config (return code 0 - fragmented, 2 - no fragmentation necessary)." << endl;
    764773            cout << "\t-h/-H/-?\tGive this help screen." << endl;
    765774            cout << "\t-m <0/1>\tCalculate (0)/ Align in(1) PAS with greatest EV along z axis." << endl;
     
    767776            cout << "\t-o\tGet volume of the convex envelope (and store to tecplot file)." << endl;
    768777            cout << "\t-p <file>\tParse given xyz file and create raw config file from it." << endl;
    769             cout << "\t-P <file> <delta_t>\tParse given forces file and append as an MD step with width delta_t to config file via Verlet." << endl;
     778            cout << "\t-P <file>\tParse given forces file and append as an MD step to config file via Verlet." << endl;
    770779            cout << "\t-r\t\tConvert file from an old pcp syntax." << endl;
    771780            cout << "\t-t x1 x2 x3\tTranslate all atoms by this vector (x1,x2,x3)." << endl;
     
    860869          switch(argv[argptr-1][1]) {
    861870            case 'p':
    862               ExitFlag = 1;
     871              SaveFlag = true;
    863872              cout << Verbose(1) << "Parsing xyz file for new atoms." << endl;
    864873              if (!mol->AddXYZFile(argv[argptr]))
     
    875884        if (config_present == present) {
    876885          switch(argv[argptr-1][1]) {
     886            case 'D':
     887              {
     888                cout << Verbose(1) << "Depth-First-Search Analysis." << endl;
     889                MoleculeLeafClass *Subgraphs = NULL;      // list of subgraphs from DFS analysis
     890                int *MinimumRingSize = NULL;
     891                mol->CreateAdjacencyList((ofstream *)&cout, atof(argv[argptr++]), configuration.GetIsAngstroem());
     892                mol->CreateListOfBondsPerAtom((ofstream *)&cout);
     893                Subgraphs = mol->DepthFirstSearchAnalysis((ofstream *)&cout, MinimumRingSize);
     894                delete[](MinimumRingSize);
     895                if (Subgraphs != NULL) {
     896                  while (Subgraphs->next != NULL) {
     897                    Subgraphs = Subgraphs->next;
     898                    delete(Subgraphs->previous);
     899                  }
     900                  delete(Subgraphs);
     901                }
     902              }
     903              argptr+=1;
     904              break;
    877905            case 'P':
    878               ExitFlag = 1;
     906              SaveFlag = true;
    879907              cout << Verbose(1) << "Parsing forces file and Verlet integrating." << endl;
    880               if (!mol->VerletForceIntegration(argv[argptr], atof(argv[argptr+1])))
     908              if (!mol->VerletForceIntegration(argv[argptr], configuration.Deltat, configuration.GetIsAngstroem()))
    881909                cout << Verbose(2) << "File not found." << endl;
    882910              else
    883911                cout << Verbose(2) << "File found and parsed." << endl;
    884               argptr+=2;
     912              argptr+=1;
    885913              break;
    886914            case 't':
    887               ExitFlag = 1;
     915              SaveFlag = true;
    888916              cout << Verbose(1) << "Translating all ions to new origin." << endl;
    889917              for (int i=NDIM;i--;)
     
    893921              break;
    894922            case 'a':
    895               ExitFlag = 1;
     923              SaveFlag = true;
    896924              cout << Verbose(1) << "Adding new atom with element " << argv[argptr] << " at (" << argv[argptr+1] << "," << argv[argptr+2] << "," << argv[argptr+3] << "), ";
    897925              first = new atom;
     
    908936              break;
    909937            case 's':
    910               ExitFlag = 1;
     938              SaveFlag = true;
    911939              j = -1;
    912940              cout << Verbose(1) << "Scaling all ion positions by factor." << endl;
     
    929957              break;
    930958            case 'b':
    931               ExitFlag = 1;
     959              SaveFlag = true;
    932960              j = -1;
    933961              cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
     
    944972              break;
    945973            case 'c':
    946               ExitFlag = 1;
     974              SaveFlag = true;
    947975              j = -1;
    948976              cout << Verbose(1) << "Centering atoms in config file within given additional boundary." << endl;
     
    961989              break;
    962990            case 'O':
    963               ExitFlag = 1;
     991              SaveFlag = true;
    964992              cout << Verbose(1) << "Centering atoms in origin." << endl;
    965993              mol->CenterOrigin((ofstream *)&cout, &x);
     
    967995              break;
    968996            case 'r':
    969               ExitFlag = 1;
     997              SaveFlag = true;
    970998              cout << Verbose(1) << "Converting config file from supposed old to new syntax." << endl;
    971999              break;
    9721000            case 'F':
    9731001            case 'f':
    974               if (ExitFlag ==0) ExitFlag = 2;  // only set if not already by other command line switch
    9751002              cout << "Fragmenting molecule with bond distance " << argv[argptr] << " angstroem, order of " << argv[argptr+1] << "." << endl;
    9761003              if (argc >= argptr+2) {
     
    9801007                cout << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
    9811008                if (mol->first->next != mol->last) {
    982                   mol->FragmentMolecule((ofstream *)&cout, atoi(argv[argptr]), &configuration);
     1009                  ExitFlag = mol->FragmentMolecule((ofstream *)&cout, atoi(argv[argptr]), &configuration);
    9831010                }
    9841011                end = clock();
     
    9901017              break;
    9911018            case 'm':
    992               ExitFlag = 1;
    9931019              j = atoi(argv[argptr++]);
    9941020              if ((j<0) || (j>1)) {
     
    9961022                j = 0;
    9971023              }
    998               if (j)
     1024              if (j) {
     1025                SaveFlag = true;
    9991026                cout << Verbose(0) << "Converting to prinicipal axis system." << endl;
    1000               else
     1027              } else
    10011028                cout << Verbose(0) << "Evaluating prinicipal axis." << endl;
    10021029              mol->PrincipalAxisSystem((ofstream *)&cout, (bool)j);
    10031030              break;
    10041031            case 'o':
    1005               ExitFlag = 1;
     1032              SaveFlag = true;
    10061033              cout << Verbose(0) << "Evaluating volume of the convex envelope.";
    10071034              VolumeOfConvexEnvelope((ofstream *)&cout, &configuration, NULL, mol);
     
    10131040              {
    10141041                double density;
    1015                 ExitFlag = 1;
     1042                SaveFlag = true;
    10161043                cout << Verbose(0) << "Evaluating necessary cell volume for a cluster suspended in water.";
    10171044                density = atof(argv[argptr++]);
     
    10301057              break;
    10311058            case 'd':
     1059              SaveFlag = true;
    10321060              for (int axis = 1; axis <= NDIM; axis++) {
    10331061                int faktor = atoi(argv[argptr++]);
     
    10891117      } else argptr++;
    10901118    } while (argptr < argc);
    1091     if (ExitFlag == 1) // 1 means save and exit
     1119    if (SaveFlag)
    10921120      SaveConfig(ConfigFileName, &configuration, periode, mol);
    1093     if (ExitFlag >= 1) { // 2 means just exit
     1121    if ((ExitFlag >= 1)) {
    10941122      delete(mol);
    10951123      delete(periode);
    1096       return (1);
     1124      return (ExitFlag);
    10971125    }
    10981126  } else {  // no arguments, hence scan the elements db
Note: See TracChangeset for help on using the changeset viewer.