Changeset 235bed


Ignore:
Timestamp:
Jan 5, 2010, 9:23:25 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
820a42
Parents:
6b932c7
Message:

Moved saveConfig method from oldmenu to a method inside config class

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/builder.cpp

    r6b932c7 r235bed  
    7878 */
    7979static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\
    80                                    config& configuration, char *&ConfigFileName, oldmenu *main_menu)
     80                                   config& configuration, char *&ConfigFileName)
    8181{
    8282  Vector x,y,z,n;  // coordinates for absolute point in cell volume
     
    879879    } while (argptr < argc);
    880880    if (SaveFlag)
    881       main_menu->SaveConfig(ConfigFileName, &configuration, periode, molecules);
     881      configuration.SaveAll(ConfigFileName, periode, molecules);
    882882  } else {  // no arguments, hence scan the elements db
    883883    if (periode->LoadPeriodentafel(configuration.databasepath))
     
    907907    main_menu = new oldmenu;
    908908    setVerbosity(0);
    909     /* main menu is needed to call actions inside the menu */
    910909    /* structure of ParseCommandLineOptions will be refactored later */
    911     j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName,main_menu);
     910    j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName);
    912911    switch (j){
    913912        case 255:
  • src/config.cpp

    r6b932c7 r235bed  
    17711771};
    17721772
     1773
     1774/** Tries given filename or standard on saving the config file.
     1775 * \param *ConfigFileName name of file
     1776 * \param *periode pointer to periodentafel structure with all the elements
     1777 * \param *molecules list of molecules structure with all the atoms and coordinates
     1778 */
     1779void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules)
     1780{
     1781  char filename[MAXSTRINGSIZE];
     1782  ofstream output;
     1783  molecule *mol = new molecule(periode);
     1784
     1785  if (!strcmp(configpath, GetDefaultPath())) {
     1786    eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
     1787  }
     1788
     1789
     1790  // first save as PDB data
     1791  if (ConfigFileName != NULL)
     1792    strcpy(filename, ConfigFileName);
     1793  else
     1794    strcpy(filename,"main_pcp_linux");
     1795  Log() << Verbose(0) << "Saving as pdb input ";
     1796  if (SavePDB(filename, molecules))
     1797    Log() << Verbose(0) << "done." << endl;
     1798  else
     1799    Log() << Verbose(0) << "failed." << endl;
     1800
     1801  // then save as tremolo data file
     1802  if (ConfigFileName != NULL)
     1803    strcpy(filename, ConfigFileName);
     1804  else
     1805    strcpy(filename,"main_pcp_linux");
     1806  Log() << Verbose(0) << "Saving as tremolo data input ";
     1807  if (SaveTREMOLO(filename, molecules))
     1808    Log() << Verbose(0) << "done." << endl;
     1809  else
     1810    Log() << Verbose(0) << "failed." << endl;
     1811
     1812  // translate each to its center and merge all molecules in MoleculeListClass into this molecule
     1813  int N = molecules->ListOfMolecules.size();
     1814  int *src = new int[N];
     1815  N=0;
     1816  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1817    src[N++] = (*ListRunner)->IndexNr;
     1818    (*ListRunner)->Translate(&(*ListRunner)->Center);
     1819  }
     1820  molecules->SimpleMultiAdd(mol, src, N);
     1821  delete[](src);
     1822
     1823  // ... and translate back
     1824  for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
     1825    (*ListRunner)->Center.Scale(-1.);
     1826    (*ListRunner)->Translate(&(*ListRunner)->Center);
     1827    (*ListRunner)->Center.Scale(-1.);
     1828  }
     1829
     1830  Log() << Verbose(0) << "Storing configuration ... " << endl;
     1831  // get correct valence orbitals
     1832  mol->CalculateOrbitals(*this);
     1833  InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble;
     1834  if (ConfigFileName != NULL) { // test the file name
     1835    strcpy(filename, ConfigFileName);
     1836    output.open(filename, ios::trunc);
     1837  } else if (strlen(configname) != 0) {
     1838    strcpy(filename, configname);
     1839    output.open(configname, ios::trunc);
     1840    } else {
     1841      strcpy(filename, DEFAULTCONFIG);
     1842      output.open(DEFAULTCONFIG, ios::trunc);
     1843    }
     1844  output.close();
     1845  output.clear();
     1846  Log() << Verbose(0) << "Saving of config file ";
     1847  if (Save(filename, periode, mol))
     1848    Log() << Verbose(0) << "successful." << endl;
     1849  else
     1850    Log() << Verbose(0) << "failed." << endl;
     1851
     1852  // and save to xyz file
     1853  if (ConfigFileName != NULL) {
     1854    strcpy(filename, ConfigFileName);
     1855    strcat(filename, ".xyz");
     1856    output.open(filename, ios::trunc);
     1857  }
     1858  else {
     1859    strcpy(filename,"main_pcp_linux");
     1860    strcat(filename, ".xyz");
     1861    output.open(filename, ios::trunc);
     1862  }
     1863  Log() << Verbose(0) << "Saving of XYZ file ";
     1864  if (mol->MDSteps <= 1) {
     1865    if (mol->OutputXYZ(&output))
     1866      Log() << Verbose(0) << "successful." << endl;
     1867    else
     1868      Log() << Verbose(0) << "failed." << endl;
     1869  } else {
     1870    if (mol->OutputTrajectoriesXYZ(&output))
     1871      Log() << Verbose(0) << "successful." << endl;
     1872    else
     1873      Log() << Verbose(0) << "failed." << endl;
     1874  }
     1875  output.close();
     1876  output.clear();
     1877
     1878  // and save as MPQC configuration
     1879  if (ConfigFileName != NULL)
     1880    strcpy(filename, ConfigFileName);
     1881  else
     1882    strcpy(filename,"main_pcp_linux");
     1883  Log() << Verbose(0) << "Saving as mpqc input ";
     1884  if (SaveMPQC(filename, mol))
     1885    Log() << Verbose(0) << "done." << endl;
     1886  else
     1887    Log() << Verbose(0) << "failed." << endl;
     1888
     1889  if (!strcmp(configpath, GetDefaultPath())) {
     1890    eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
     1891  }
     1892
     1893  delete(mol);
     1894};
     1895
    17731896/** Reads parameter from a parsed file.
    17741897 * The file is either parsed for a certain keyword or if null is given for
  • src/config.hpp

    r6b932c7 r235bed  
    146146  bool SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const;
    147147
     148  void SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules);
     149
    148150  void Edit();
    149151  bool GetIsAngstroem() const;
  • src/menu.cpp

    r6b932c7 r235bed  
    11421142  new SeperatorItem(main_menu);
    11431143
    1144   Action *saveConfigAction = new MethodAction(boost::bind(&oldmenu::SaveConfig,this,ConfigFileName, configuration, periode, molecules));
     1144  Action *saveConfigAction = new MethodAction(boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules));
    11451145  new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction);
    11461146
     
    12041204  delete returnAction;
    12051205};
    1206 
    1207 /** Tries given filename or standard on saving the config file.
    1208  * \param *ConfigFileName name of file
    1209  * \param *configuration pointer to configuration structure with all the values
    1210  * \param *periode pointer to periodentafel structure with all the elements
    1211  * \param *molecules list of molecules structure with all the atoms and coordinates
    1212  */
    1213 void oldmenu::SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules)
    1214 {
    1215   char filename[MAXSTRINGSIZE];
    1216   ofstream output;
    1217   molecule *mol = new molecule(periode);
    1218 
    1219   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1220     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1221   }
    1222 
    1223 
    1224   // first save as PDB data
    1225   if (ConfigFileName != NULL)
    1226     strcpy(filename, ConfigFileName);
    1227   else
    1228     strcpy(filename,"main_pcp_linux");
    1229   Log() << Verbose(0) << "Saving as pdb input ";
    1230   if (configuration->SavePDB(filename, molecules))
    1231     Log() << Verbose(0) << "done." << endl;
    1232   else
    1233     Log() << Verbose(0) << "failed." << endl;
    1234 
    1235   // then save as tremolo data file
    1236   if (ConfigFileName != NULL)
    1237     strcpy(filename, ConfigFileName);
    1238   else
    1239     strcpy(filename,"main_pcp_linux");
    1240   Log() << Verbose(0) << "Saving as tremolo data input ";
    1241   if (configuration->SaveTREMOLO(filename, molecules))
    1242     Log() << Verbose(0) << "done." << endl;
    1243   else
    1244     Log() << Verbose(0) << "failed." << endl;
    1245 
    1246   // translate each to its center and merge all molecules in MoleculeListClass into this molecule
    1247   int N = molecules->ListOfMolecules.size();
    1248   int *src = new int[N];
    1249   N=0;
    1250   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1251     src[N++] = (*ListRunner)->IndexNr;
    1252     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1253   }
    1254   molecules->SimpleMultiAdd(mol, src, N);
    1255   delete[](src);
    1256 
    1257   // ... and translate back
    1258   for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) {
    1259     (*ListRunner)->Center.Scale(-1.);
    1260     (*ListRunner)->Translate(&(*ListRunner)->Center);
    1261     (*ListRunner)->Center.Scale(-1.);
    1262   }
    1263 
    1264   Log() << Verbose(0) << "Storing configuration ... " << endl;
    1265   // get correct valence orbitals
    1266   mol->CalculateOrbitals(*configuration);
    1267   configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble;
    1268   if (ConfigFileName != NULL) { // test the file name
    1269     strcpy(filename, ConfigFileName);
    1270     output.open(filename, ios::trunc);
    1271   } else if (strlen(configuration->configname) != 0) {
    1272     strcpy(filename, configuration->configname);
    1273     output.open(configuration->configname, ios::trunc);
    1274     } else {
    1275       strcpy(filename, DEFAULTCONFIG);
    1276       output.open(DEFAULTCONFIG, ios::trunc);
    1277     }
    1278   output.close();
    1279   output.clear();
    1280   Log() << Verbose(0) << "Saving of config file ";
    1281   if (configuration->Save(filename, periode, mol))
    1282     Log() << Verbose(0) << "successful." << endl;
    1283   else
    1284     Log() << Verbose(0) << "failed." << endl;
    1285 
    1286   // and save to xyz file
    1287   if (ConfigFileName != NULL) {
    1288     strcpy(filename, ConfigFileName);
    1289     strcat(filename, ".xyz");
    1290     output.open(filename, ios::trunc);
    1291   }
    1292   else {
    1293     strcpy(filename,"main_pcp_linux");
    1294     strcat(filename, ".xyz");
    1295     output.open(filename, ios::trunc);
    1296   }
    1297   Log() << Verbose(0) << "Saving of XYZ file ";
    1298   if (mol->MDSteps <= 1) {
    1299     if (mol->OutputXYZ(&output))
    1300       Log() << Verbose(0) << "successful." << endl;
    1301     else
    1302       Log() << Verbose(0) << "failed." << endl;
    1303   } else {
    1304     if (mol->OutputTrajectoriesXYZ(&output))
    1305       Log() << Verbose(0) << "successful." << endl;
    1306     else
    1307       Log() << Verbose(0) << "failed." << endl;
    1308   }
    1309   output.close();
    1310   output.clear();
    1311 
    1312   // and save as MPQC configuration
    1313   if (ConfigFileName != NULL)
    1314     strcpy(filename, ConfigFileName);
    1315   else
    1316     strcpy(filename,"main_pcp_linux");
    1317   Log() << Verbose(0) << "Saving as mpqc input ";
    1318   if (configuration->SaveMPQC(filename, mol))
    1319     Log() << Verbose(0) << "done." << endl;
    1320   else
    1321     Log() << Verbose(0) << "failed." << endl;
    1322 
    1323   if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
    1324     eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl;
    1325   }
    1326 
    1327   delete(mol);
    1328 };
  • src/menu.hpp

    r6b932c7 r235bed  
    2424  void notImplementedYet();
    2525  void perform(MoleculeListClass *, config *, periodentafel *, char *);
    26   void SaveConfig(char *, config *, periodentafel *, MoleculeListClass *);
    2726
    2827protected:
Note: See TracChangeset for help on using the changeset viewer.