Changeset 34e0013 for src


Ignore:
Timestamp:
Oct 30, 2009, 4:09:29 PM (15 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:
fa649a
Parents:
b21a64
Message:

BondGraph is initialized within config::Load(), as it has to happen after parsing options and before loading molecule. And various fixes.

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/bondgraph.cpp

    rb21a64 r34e0013  
    3232
    3333/** Parses the bond lengths in a given file and puts them int a matrix form.
    34  * Allocates \a MatrixContainer and uses MatrixContainer::ParseMatrix().
     34 * Allocates \a MatrixContainer for BondGraph::BondLengthMatrix, using MatrixContainer::ParseMatrix(),
     35 * but only if parsing is successfull. Otherwise variable is left as NULL.
    3536 * \param *out output stream for debugging
    3637 * \param filename file with bond lengths to parse
     
    4041{
    4142  bool status = true;
     43  MatrixContainer *TempContainer = NULL;
    4244
    4345  // allocate MatrixContainer
     
    4648    delete(BondLengthMatrix);
    4749  }
    48   BondLengthMatrix = new MatrixContainer;
     50  TempContainer = new MatrixContainer;
    4951
    5052  // parse in matrix
    51   BondLengthMatrix->ParseMatrix(filename.c_str(), 0, 1, 0);
     53  status = TempContainer->ParseMatrix(filename.c_str(), 0, 1, 0);
    5254
    5355  // find greatest distance
    5456  max_distance=0;
    55   for(int i=0;i<BondLengthMatrix->RowCounter[0];i++)
    56     for(int j=i;j<BondLengthMatrix->ColumnCounter[0];j++)
    57       if (BondLengthMatrix->Matrix[0][i][j] > max_distance)
    58         max_distance = BondLengthMatrix->Matrix[0][i][j];
     57  if (status) {
     58    for(int i=0;i<TempContainer->RowCounter[0];i++)
     59      for(int j=i;j<TempContainer->ColumnCounter[0];j++)
     60        if (TempContainer->Matrix[0][i][j] > max_distance)
     61          max_distance = TempContainer->Matrix[0][i][j];
     62  }
    5963
     64  if (status) // set to not NULL only if matrix was parsed
     65    BondLengthMatrix = TempContainer;
     66  else {
     67    BondLengthMatrix = NULL;
     68    delete(TempContainer);
     69  }
    6070  return status;
    6171};
     
    7080  bool status = true;
    7181
    72   if (BondLengthMatrix == NULL)
    73    return false;
    74   mol->CreateAdjacencyList(out, max_distance, IsAngstroem, &BondGraph::BondLengthMatrixMinMaxDistance, this);
     82  if (mol->start->next == mol->end) // only construct if molecule is not empty
     83    return false;
     84
     85  if (BondLengthMatrix == NULL) // no bond length matrix parsed?
     86    mol->CreateAdjacencyList(out, max_distance, IsAngstroem, &BondGraph::CovalentMinMaxDistance, this);
     87  else
     88    mol->CreateAdjacencyList(out, max_distance, IsAngstroem, &BondGraph::BondLengthMatrixMinMaxDistance, this);
    7589
    7690  return status;
     
    8498double BondGraph::GetBondLength(int firstZ, int secondZ)
    8599{
    86   return (BondLengthMatrix->Matrix[0][firstZ][secondZ]);
     100  if (BondLengthMatrix == NULL)
     101    return( -1. );
     102  else
     103    return (BondLengthMatrix->Matrix[0][firstZ][secondZ]);
    87104};
    88105
     
    113130void BondGraph::BondLengthMatrixMinMaxDistance(BondedParticle * const Walker, BondedParticle * const OtherWalker, double &MinDistance, double &MaxDistance, bool IsAngstroem)
    114131{
    115   if (BondLengthMatrix->Matrix == NULL) {// safety measure if no matrix has been parsed yet
     132  if (BondLengthMatrix == NULL) {// safety measure if no matrix has been parsed yet
    116133    cerr << Verbose(1) << "WARNING:  BondLengthMatrixMinMaxDistance() called without having parsed the bond length matrix yet!" << endl;
    117134    CovalentMinMaxDistance(Walker, OtherWalker, MinDistance, MaxDistance, IsAngstroem);
  • src/builder.cpp

    rb21a64 r34e0013  
    14511451      return 1;
    14521452    }
    1453     // 3b. Find config file name and parse if possible
     1453    // 3b. Find config file name and parse if possible, also BondGraphFileName
    14541454    if (argv[1][0] != '-') {
    14551455      // simply create a new molecule, wherein the config file is loaded and the manipulation takes place
     
    14791479          case 1:
    14801480            cout << "new syntax." << endl;
    1481             configuration.Load(ConfigFileName, periode, mol);
     1481            configuration.Load(ConfigFileName, BondGraphFileName, periode, mol);
    14821482            configPresent = present;
    14831483            break;
    14841484          case 0:
    14851485            cout << "old syntax." << endl;
    1486             configuration.LoadOld(ConfigFileName, periode, mol);
     1486            configuration.LoadOld(ConfigFileName, BondGraphFileName, periode, mol);
    14871487            configPresent = present;
    14881488            break;
     
    14941494    } else
    14951495      configPresent = absent;
    1496     // 3c. parse the bond graph file if given
    1497     configuration.BG = new BondGraph(configuration.GetIsAngstroem());
    1498     if (configuration.BG->LoadBondLengthTable((ofstream *)&cout, BondGraphFileName)) {
    1499       cout << Verbose(0) << "Bond length table loaded successfully." << endl;
    1500     } else {
    1501       cout << Verbose(0) << "Bond length table loading failed." << endl;
    1502       return 1;
    1503     }
    15041496    // 4. parse again through options, now for those depending on elements db and config presence
    15051497    argptr = 1;
  • src/config.cpp

    rb21a64 r34e0013  
    831831/** Initializes config file structure by loading elements from a give file.
    832832 * \param *file input file stream being the opened config file
     833 * \param BondGraphFileName file name of the bond length table file, if string is left blank, no table is parsed.
    833834 * \param *periode pointer to a periodentafel class with all elements
    834835 * \param *mol pointer to molecule containing all atoms of the molecule
    835836 */
    836 void config::Load(const char * const filename, const periodentafel * const periode, molecule * const &mol)
     837void config::Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, molecule * const &mol)
    837838{
    838839  ifstream *file = new ifstream(filename);
     
    860861  /* Namen einlesen */
    861862
     863  // 1. parse in options
    862864  ParseForParameter(verbose,FileBuffer, "mainname", 0, 1, 1, string_type, (config::mainname), 1, critical);
    863865  ParseForParameter(verbose,FileBuffer, "defaultpath", 0, 1, 1, string_type, (config::defaultpath), 1, critical);
     
    10401042    config::StructOpt = 0;
    10411043
     1044  // 2. parse the bond graph file if given
     1045  BG = new BondGraph(IsAngstroem);
     1046  if (BG->LoadBondLengthTable((ofstream *)&cout, BondGraphFileName)) {
     1047    cout << Verbose(0) << "Bond length table loaded successfully." << endl;
     1048  } else {
     1049    cout << Verbose(0) << "Bond length table loading failed." << endl;
     1050  }
     1051
     1052  // 3. parse the molecule in
    10421053  LoadMolecule(mol, FileBuffer, periode, FastParsing);
     1054
     1055  // 4. dissect the molecule into connected subgraphs
     1056  BG->ConstructBondGraph((ofstream *)&cout, mol);
    10431057
    10441058  delete(FileBuffer);
     
    10471061/** Initializes config file structure by loading elements from a give file with old pcp syntax.
    10481062 * \param *file input file stream being the opened config file with old pcp syntax
     1063 * \param BondGraphFileName file name of the bond length table file, if string is left blank, no table is parsed.
    10491064 * \param *periode pointer to a periodentafel class with all elements
    10501065 * \param *mol pointer to molecule containing all atoms of the molecule
    10511066 */
    1052 void config::LoadOld(const char * const filename, const periodentafel * const periode, molecule * const &mol)
     1067void config::LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, molecule * const &mol)
    10531068{
    10541069  ifstream *file = new ifstream(filename);
     
    12071222  config::StructOpt = 0;
    12081223
     1224
     1225  // 2. parse the bond graph file if given
     1226  BG = new BondGraph(IsAngstroem);
     1227  if (BG->LoadBondLengthTable((ofstream *)&cout, BondGraphFileName)) {
     1228    cout << Verbose(0) << "Bond length table loaded successfully." << endl;
     1229  } else {
     1230    cout << Verbose(0) << "Bond length table loading failed." << endl;
     1231  }
     1232
    12091233  // Routine from builder.cpp
    1210 
    12111234
    12121235  for (i=MAX_ELEMENTS;i--;)
  • src/config.hpp

    rb21a64 r34e0013  
    135135
    136136  int TestSyntax(const char * const filename, const periodentafel * const periode, const molecule * const mol) const;
    137   void Load(const char * const filename, const periodentafel * const periode, molecule * const &mol);
    138   void LoadOld(const char * const filename, const periodentafel * const periode, molecule * const &mol);
     137  void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, molecule * const &mol);
     138  void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, molecule * const &mol);
    139139  void RetrieveConfigPathAndName(const string filename);
    140140  bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const;
  • src/molecule_graph.cpp

    rb21a64 r34e0013  
    122122  *out << Verbose(1) << "AtomCount " << AtomCount << "." << endl;
    123123
    124   if (AtomCount != 0) {
     124  if ((AtomCount > 1) && (bonddistance > 1.)) {
    125125    LC = new LinkedCell(this, bonddistance);
    126126
Note: See TracChangeset for help on using the changeset viewer.