Changes in / [1f1b23:a25aae]
- Files:
-
- 58 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
r1f1b23 ra25aae 3 3 4 4 EXTRA_DIST = autogen.sh 5 6 .PHONY: doc 7 doc: 8 cd doc && make doxygen-docs -
doc/Doxyfile
r1f1b23 ra25aae 125 125 # configuration options related to source browsing 126 126 #--------------------------------------------------------------------------- 127 SOURCE_BROWSER = NO127 SOURCE_BROWSER = YES 128 128 INLINE_SOURCES = NO 129 129 STRIP_CODE_COMMENTS = YES -
src/Makefile.am
r1f1b23 ra25aae 8 8 ANALYSISHEADER = analysis_bonds.hpp analysis_correlation.hpp 9 9 10 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp 11 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp 10 ACTIONSSOURCE = Actions/Action.cpp Actions/MethodAction.cpp Actions/ActionSequence.cpp Actions/MakroAction.cpp Actions/ErrorAction.cpp Actions/small_actions.cpp Actions/ActionRegistry.cpp 11 ACTIONSHEADER = Actions/Action.hpp Actions/MethodAction.hpp Actions/ActionSequence.hpp Actions/MakroAction.hpp Actions/ErrorAction.hpp Actions/small_actions.hpp Actions/ActionRegistry.hpp 12 13 PATTERNSOURCE = Patterns/Observer.cpp 14 PATTERNHEADER = Patterns/Observer.hpp 15 16 VIEWSOURCE = Views/View.cpp Views/StringView.cpp Views/MethodStringView.cpp Views/StreamStringView.cpp 17 VIEWHEADER = Views/View.hpp Views/StringView.hpp Views/MethodStringView.hpp Views/StreamStringView.hpp 18 19 MENUSOURCE = Menu/Menu.cpp Menu/TextMenu.cpp Menu/MenuItem.cpp Menu/SubMenuItem.cpp Menu/ActionMenuItem.cpp Menu/SeperatorItem.cpp Menu/DisplayMenuItem.cpp 20 MENUHEADER = Menu/Menu.hpp Menu/TextMenu.hpp Menu/MenuItem.hpp Menu/SubMenuItem.hpp Menu/ActionMenuItem.hpp Menu/SeperatorItem.hpp Menu/DisplayMenuItem.hpp 21 22 UISOURCE = ${ACTIONSSOURCE} ${VIEWSOURCE} ${MENUSOURCE} UIElements/UIFactory.cpp UIElements/TextUIFactory.cpp UIElements/MainWindow.cpp UIElements/TextWindow.cpp UIElements/Dialog.cpp UIElements/TextDialog.cpp 23 UIHEADER = ${ACTIONSHEADER} ${VIEWHEADER} ${MENUHEADER} UIElements/UIFactory.hpp UIElements/TextUIFactory.hpp UIElements/MainWindow.hpp UIElements/TextWindow.hpp UIElements/Dialog.hpp UIElements/TextDialog.hpp 24 25 SOURCE = ${ANALYSISSOURCE} ${ATOMSOURCE} ${PATTERNSOURCE} ${UISOURCE} bond.cpp bondgraph.cpp boundary.cpp config.cpp element.cpp ellipsoid.cpp errorlogger.cpp graph.cpp helpers.cpp info.cpp leastsquaremin.cpp linkedcell.cpp log.cpp logger.cpp memoryusageobserver.cpp moleculelist.cpp molecule.cpp molecule_dynamics.cpp molecule_fragmentation.cpp molecule_geometry.cpp molecule_graph.cpp molecule_pointcloud.cpp parser.cpp periodentafel.cpp tesselation.cpp tesselationhelpers.cpp vector.cpp verbose.cpp menu.cpp 26 HEADER = ${ANALYSISHEADER} ${ATOMHEADER} ${PATTERNHEADER} ${UIHEADER} bond.hpp bondgraph.hpp boundary.hpp config.hpp defs.hpp element.hpp ellipsoid.hpp errorlogger.hpp graph.hpp helpers.hpp info.hpp leastsquaremin.hpp linkedcell.hpp lists.hpp log.hpp logger.hpp memoryallocator.hpp memoryusageobserver.hpp molecule.hpp molecule_template.hpp parser.hpp periodentafel.hpp stackclass.hpp tesselation.hpp tesselationhelpers.hpp vector.hpp verbose.hpp menu.hpp 12 27 13 28 BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) -
src/builder.cpp
r1f1b23 ra25aae 48 48 49 49 50 #include <boost/bind.hpp> 51 50 52 using namespace std; 51 53 … … 67 69 #include "molecule.hpp" 68 70 #include "periodentafel.hpp" 71 #include "UIElements/UIFactory.hpp" 72 #include "UIElements/MainWindow.hpp" 73 #include "UIElements/Dialog.hpp" 74 #include "Menu/ActionMenuItem.hpp" 75 #include "Actions/ActionRegistry.hpp" 76 #include "Actions/MethodAction.hpp" 77 #include "Actions/small_actions.hpp" 69 78 #include "version.h" 70 79 71 80 /********************************************* Subsubmenu routine ************************************/ 72 81 #if 0 73 82 /** Submenu for adding atoms to the molecule. 74 83 * \param *periode periodentafel … … 258 267 if (i >= 2) { 259 268 first->x.LSQdistance((const Vector **)atoms, i); 260 261 269 first->x.Output(); 262 270 first->type = periode->AskElement(); // give type … … 1155 1163 }; 1156 1164 1157 1158 1165 /********************************************** Test routine **************************************/ 1159 1166 … … 1239 1246 }; 1240 1247 1241 /** Tries given filename or standard on saving the config file. 1242 * \param *ConfigFileName name of file 1243 * \param *configuration pointer to configuration structure with all the values 1244 * \param *periode pointer to periodentafel structure with all the elements 1245 * \param *molecules list of molecules structure with all the atoms and coordinates 1246 */ 1247 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules) 1248 { 1249 char filename[MAXSTRINGSIZE]; 1250 ofstream output; 1251 molecule *mol = new molecule(periode); 1252 mol->SetNameFromFilename(ConfigFileName); 1253 1254 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1255 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1256 } 1257 1258 1259 // first save as PDB data 1260 if (ConfigFileName != NULL) 1261 strcpy(filename, ConfigFileName); 1262 if (output == NULL) 1263 strcpy(filename,"main_pcp_linux"); 1264 Log() << Verbose(0) << "Saving as pdb input "; 1265 if (configuration->SavePDB(filename, molecules)) 1266 Log() << Verbose(0) << "done." << endl; 1267 else 1268 Log() << Verbose(0) << "failed." << endl; 1269 1270 // then save as tremolo data file 1271 if (ConfigFileName != NULL) 1272 strcpy(filename, ConfigFileName); 1273 if (output == NULL) 1274 strcpy(filename,"main_pcp_linux"); 1275 Log() << Verbose(0) << "Saving as tremolo data input "; 1276 if (configuration->SaveTREMOLO(filename, molecules)) 1277 Log() << Verbose(0) << "done." << endl; 1278 else 1279 Log() << Verbose(0) << "failed." << endl; 1280 1281 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1282 int N = molecules->ListOfMolecules.size(); 1283 int *src = new int[N]; 1284 N=0; 1285 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1286 src[N++] = (*ListRunner)->IndexNr; 1287 (*ListRunner)->Translate(&(*ListRunner)->Center); 1288 } 1289 molecules->SimpleMultiAdd(mol, src, N); 1290 delete[](src); 1291 1292 // ... and translate back 1293 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1294 (*ListRunner)->Center.Scale(-1.); 1295 (*ListRunner)->Translate(&(*ListRunner)->Center); 1296 (*ListRunner)->Center.Scale(-1.); 1297 } 1298 1299 Log() << Verbose(0) << "Storing configuration ... " << endl; 1300 // get correct valence orbitals 1301 mol->CalculateOrbitals(*configuration); 1302 configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble; 1303 if (ConfigFileName != NULL) { // test the file name 1304 strcpy(filename, ConfigFileName); 1305 output.open(filename, ios::trunc); 1306 } else if (strlen(configuration->configname) != 0) { 1307 strcpy(filename, configuration->configname); 1308 output.open(configuration->configname, ios::trunc); 1309 } else { 1310 strcpy(filename, DEFAULTCONFIG); 1311 output.open(DEFAULTCONFIG, ios::trunc); 1312 } 1313 output.close(); 1314 output.clear(); 1315 Log() << Verbose(0) << "Saving of config file "; 1316 if (configuration->Save(filename, periode, mol)) 1317 Log() << Verbose(0) << "successful." << endl; 1318 else 1319 Log() << Verbose(0) << "failed." << endl; 1320 1321 // and save to xyz file 1322 if (ConfigFileName != NULL) { 1323 strcpy(filename, ConfigFileName); 1324 strcat(filename, ".xyz"); 1325 output.open(filename, ios::trunc); 1326 } 1327 if (output == NULL) { 1328 strcpy(filename,"main_pcp_linux"); 1329 strcat(filename, ".xyz"); 1330 output.open(filename, ios::trunc); 1331 } 1332 Log() << Verbose(0) << "Saving of XYZ file "; 1333 if (mol->MDSteps <= 1) { 1334 if (mol->OutputXYZ(&output)) 1335 Log() << Verbose(0) << "successful." << endl; 1336 else 1337 Log() << Verbose(0) << "failed." << endl; 1338 } else { 1339 if (mol->OutputTrajectoriesXYZ(&output)) 1340 Log() << Verbose(0) << "successful." << endl; 1341 else 1342 Log() << Verbose(0) << "failed." << endl; 1343 } 1344 output.close(); 1345 output.clear(); 1346 1347 // and save as MPQC configuration 1348 if (ConfigFileName != NULL) 1349 strcpy(filename, ConfigFileName); 1350 if (output == NULL) 1351 strcpy(filename,"main_pcp_linux"); 1352 Log() << Verbose(0) << "Saving as mpqc input "; 1353 if (configuration->SaveMPQC(filename, mol)) 1354 Log() << Verbose(0) << "done." << endl; 1355 else 1356 Log() << Verbose(0) << "failed." << endl; 1357 1358 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1359 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1360 } 1361 1362 delete(mol); 1363 }; 1248 #endif 1364 1249 1365 1250 /** Parses the command line options. … … 1373 1258 * \return exit code (0 - successful, all else - something's wrong) 1374 1259 */ 1375 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, config& configuration, char *&ConfigFileName) 1260 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode,\ 1261 config& configuration, char *&ConfigFileName) 1376 1262 { 1377 1263 Vector x,y,z,n; // coordinates for absolute point in cell volume … … 2241 2127 } while (argptr < argc); 2242 2128 if (SaveFlag) 2243 SaveConfig(ConfigFileName, &configuration, periode, molecules);2129 configuration.SaveAll(ConfigFileName, periode, molecules); 2244 2130 } else { // no arguments, hence scan the elements db 2245 2131 if (periode->LoadPeriodentafel(configuration.databasepath)) … … 2252 2138 }; 2253 2139 2140 /***************************************** Functions used to build all menus **********************/ 2141 2142 void populateEditMoleculesMenu(Menu* editMoleculesMenu,MoleculeListClass *molecules, config *configuration, periodentafel *periode){ 2143 // build the EditMoleculesMenu 2144 Action *createMoleculeAction = new MethodAction("createMoleculeAction",boost::bind(&MoleculeListClass::createNewMolecule,molecules,periode)); 2145 new ActionMenuItem('c',"create new molecule",editMoleculesMenu,createMoleculeAction); 2146 2147 Action *loadMoleculeAction = new MethodAction("loadMoleculeAction",boost::bind(&MoleculeListClass::loadFromXYZ,molecules,periode)); 2148 new ActionMenuItem('l',"load molecule from xyz file",editMoleculesMenu,loadMoleculeAction); 2149 2150 Action *changeFilenameAction = new ChangeMoleculeNameAction(molecules); 2151 new ActionMenuItem('n',"change molecule's name",editMoleculesMenu,changeFilenameAction); 2152 2153 Action *giveFilenameAction = new MethodAction("giveFilenameAction",boost::bind(&MoleculeListClass::setMoleculeFilename,molecules)); 2154 new ActionMenuItem('N',"give molecules filename",editMoleculesMenu,giveFilenameAction); 2155 2156 Action *parseAtomsAction = new MethodAction("parseAtomsAction",boost::bind(&MoleculeListClass::parseXYZIntoMolecule,molecules)); 2157 new ActionMenuItem('p',"parse atoms in xyz file into molecule",editMoleculesMenu,parseAtomsAction); 2158 2159 Action *eraseMoleculeAction = new MethodAction("eraseMoleculeAction",boost::bind(&MoleculeListClass::eraseMolecule,molecules)); 2160 new ActionMenuItem('r',"remove a molecule",editMoleculesMenu,eraseMoleculeAction); 2161 } 2162 2163 2254 2164 /********************************************** Main routine **************************************/ 2255 2165 2256 2166 int main(int argc, char **argv) 2257 2167 { 2258 periodentafel *periode = new periodentafel; // and a period table of all elements 2259 MoleculeListClass *molecules = new MoleculeListClass; // list of all molecules 2260 molecule *mol = NULL; 2261 config *configuration = new config; 2262 char choice; // menu choice char 2263 Vector x,y,z,n; // coordinates for absolute point in cell volume 2264 ifstream test; 2265 ofstream output; 2266 string line; 2267 char *ConfigFileName = NULL; 2268 int j; 2269 2270 cout << ESPACKVersion << endl; 2271 2272 setVerbosity(0); 2273 2274 // =========================== PARSE COMMAND LINE OPTIONS ==================================== 2275 j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName); 2276 switch(j) { 2277 case 255: // something went wrong 2278 case 2: // just for -f option 2279 case 1: // just for -v and -h options 2280 delete(molecules); // also free's all molecules contained 2281 delete(periode); 2282 delete(configuration); 2283 Log() << Verbose(0) << "Maximum of allocated memory: " 2284 << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl; 2285 Log() << Verbose(0) << "Remaining non-freed memory: " 2286 << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl; 2287 MemoryUsageObserver::getInstance()->purgeInstance(); 2288 logger::purgeInstance(); 2289 errorLogger::purgeInstance(); 2290 return (j == 1 ? 0 : j); 2291 default: 2292 break; 2293 } 2294 2295 // General stuff 2296 if (molecules->ListOfMolecules.size() == 0) { 2297 mol = new molecule(periode); 2298 if (mol->cell_size[0] == 0.) { 2299 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl; 2300 for (int i=0;i<6;i++) { 2301 Log() << Verbose(1) << "Cell size" << i << ": "; 2302 cin >> mol->cell_size[i]; 2303 } 2168 periodentafel *periode = new periodentafel; 2169 MoleculeListClass *molecules = new MoleculeListClass; 2170 molecule *mol = NULL; 2171 config *configuration = new config; 2172 Vector x, y, z, n; 2173 ifstream test; 2174 ofstream output; 2175 string line; 2176 char *ConfigFileName = NULL; 2177 int j; 2178 setVerbosity(0); 2179 /* structure of ParseCommandLineOptions will be refactored later */ 2180 j = ParseCommandLineOptions(argc, argv, molecules, periode, *configuration, ConfigFileName); 2181 switch (j){ 2182 case 255: 2183 case 2: 2184 case 1: 2185 delete (molecules); 2186 delete (periode); 2187 delete (configuration); 2188 Log() << Verbose(0) << "Maximum of allocated memory: " << MemoryUsageObserver::getInstance()->getMaximumUsedMemory() << endl; 2189 Log() << Verbose(0) << "Remaining non-freed memory: " << MemoryUsageObserver::getInstance()->getUsedMemorySize() << endl; 2190 MemoryUsageObserver::getInstance()->purgeInstance(); 2191 logger::purgeInstance(); 2192 errorLogger::purgeInstance(); 2193 return (j == 1 ? 0 : j); 2194 default: 2195 break; 2304 2196 } 2305 mol->ActiveFlag = true; 2306 molecules->insert(mol); 2307 } 2308 2309 // =========================== START INTERACTIVE SESSION ==================================== 2310 2311 // now the main construction loop 2312 Log() << Verbose(0) << endl << "Now comes the real construction..." << endl; 2313 do { 2314 Log() << Verbose(0) << endl << endl; 2315 Log() << Verbose(0) << "============Molecule list=======================" << endl; 2316 molecules->Enumerate((ofstream *)&cout); 2317 Log() << Verbose(0) << "============Menu===============================" << endl; 2318 Log() << Verbose(0) << "a - set molecule (in)active" << endl; 2319 Log() << Verbose(0) << "e - edit molecules (load, parse, save)" << endl; 2320 Log() << Verbose(0) << "g - globally manipulate atoms in molecule" << endl; 2321 Log() << Verbose(0) << "M - Merge molecules" << endl; 2322 Log() << Verbose(0) << "m - manipulate atoms" << endl; 2323 Log() << Verbose(0) << "-----------------------------------------------" << endl; 2324 Log() << Verbose(0) << "c - edit the current configuration" << endl; 2325 Log() << Verbose(0) << "-----------------------------------------------" << endl; 2326 Log() << Verbose(0) << "s - save current setup to config file" << endl; 2327 Log() << Verbose(0) << "T - call the current test routine" << endl; 2328 Log() << Verbose(0) << "q - quit" << endl; 2329 Log() << Verbose(0) << "===============================================" << endl; 2330 Log() << Verbose(0) << "Input: "; 2331 cin >> choice; 2332 2333 switch (choice) { 2334 case 'a': // (in)activate molecule 2335 { 2336 Log() << Verbose(0) << "Enter index of molecule: "; 2337 cin >> j; 2338 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 2339 if ((*ListRunner)->IndexNr == j) 2340 (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag; 2197 if(molecules->ListOfMolecules.size() == 0){ 2198 mol = new molecule(periode); 2199 if(mol->cell_size[0] == 0.){ 2200 Log() << Verbose(0) << "enter lower tridiagonal form of basis matrix" << endl << endl; 2201 for(int i = 0;i < 6;i++){ 2202 Log() << Verbose(1) << "Cell size" << i << ": "; 2203 cin >> mol->cell_size[i]; 2204 } 2341 2205 } 2342 break; 2343 2344 case 'c': // edit each field of the configuration 2345 configuration->Edit(); 2346 break; 2347 2348 case 'e': // create molecule 2349 EditMolecules(periode, molecules); 2350 break; 2351 2352 case 'g': // manipulate molecules 2353 ManipulateMolecules(periode, molecules, configuration); 2354 break; 2355 2356 case 'M': // merge molecules 2357 MergeMolecules(periode, molecules); 2358 break; 2359 2360 case 'm': // manipulate atoms 2361 ManipulateAtoms(periode, molecules, configuration); 2362 break; 2363 2364 case 'q': // quit 2365 break; 2366 2367 case 's': // save to config file 2368 SaveConfig(ConfigFileName, configuration, periode, molecules); 2369 break; 2370 2371 case 'T': 2372 testroutine(molecules); 2373 break; 2374 2375 default: 2376 break; 2377 }; 2378 } while (choice != 'q'); 2379 2380 // save element data base 2381 if (periode->StorePeriodentafel(configuration->databasepath)) //ElementsFileName 2382 Log() << Verbose(0) << "Saving of elements.db successful." << endl; 2383 else 2384 Log() << Verbose(0) << "Saving of elements.db failed." << endl; 2385 2386 delete(molecules); // also free's all molecules contained 2387 delete(periode); 2206 2207 mol->ActiveFlag = true; 2208 molecules->insert(mol); 2209 } 2210 2211 { 2212 cout << ESPACKVersion << endl; 2213 2214 setVerbosity(0); 2215 2216 menuPopulaters populaters; 2217 populaters.MakeEditMoleculesMenu = populateEditMoleculesMenu; 2218 2219 UIFactory::makeUserInterface(UIFactory::Text); 2220 MainWindow *mainWindow = UIFactory::get()->makeMainWindow(populaters,molecules, configuration, periode, ConfigFileName); 2221 mainWindow->display(); 2222 delete mainWindow; 2223 } 2224 2225 if(periode->StorePeriodentafel(configuration->databasepath)) 2226 Log() << Verbose(0) << "Saving of elements.db successful." << endl; 2227 2228 else 2229 Log() << Verbose(0) << "Saving of elements.db failed." << endl; 2230 2231 delete (molecules); 2232 delete(periode); 2388 2233 delete(configuration); 2234 2235 2389 2236 2390 2237 Log() << Verbose(0) << "Maximum of allocated memory: " … … 2395 2242 logger::purgeInstance(); 2396 2243 errorLogger::purgeInstance(); 2397 2244 UIFactory::purgeInstance(); 2245 ActionRegistry::purgeRegistry(); 2398 2246 return (0); 2399 2247 } -
src/config.cpp
r1f1b23 ra25aae 1777 1777 }; 1778 1778 1779 1780 /** Tries given filename or standard on saving the config file. 1781 * \param *ConfigFileName name of file 1782 * \param *periode pointer to periodentafel structure with all the elements 1783 * \param *molecules list of molecules structure with all the atoms and coordinates 1784 */ 1785 void config::SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules) 1786 { 1787 char filename[MAXSTRINGSIZE]; 1788 ofstream output; 1789 molecule *mol = new molecule(periode); 1790 mol->SetNameFromFilename(ConfigFileName); 1791 1792 if (!strcmp(configpath, GetDefaultPath())) { 1793 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1794 } 1795 1796 1797 // first save as PDB data 1798 if (ConfigFileName != NULL) 1799 strcpy(filename, ConfigFileName); 1800 if (output == NULL) 1801 strcpy(filename,"main_pcp_linux"); 1802 Log() << Verbose(0) << "Saving as pdb input "; 1803 if (SavePDB(filename, molecules)) 1804 Log() << Verbose(0) << "done." << endl; 1805 else 1806 Log() << Verbose(0) << "failed." << endl; 1807 1808 // then save as tremolo data file 1809 if (ConfigFileName != NULL) 1810 strcpy(filename, ConfigFileName); 1811 if (output == NULL) 1812 strcpy(filename,"main_pcp_linux"); 1813 Log() << Verbose(0) << "Saving as tremolo data input "; 1814 if (SaveTREMOLO(filename, molecules)) 1815 Log() << Verbose(0) << "done." << endl; 1816 else 1817 Log() << Verbose(0) << "failed." << endl; 1818 1819 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1820 int N = molecules->ListOfMolecules.size(); 1821 int *src = new int[N]; 1822 N=0; 1823 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1824 src[N++] = (*ListRunner)->IndexNr; 1825 (*ListRunner)->Translate(&(*ListRunner)->Center); 1826 } 1827 molecules->SimpleMultiAdd(mol, src, N); 1828 delete[](src); 1829 1830 // ... and translate back 1831 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1832 (*ListRunner)->Center.Scale(-1.); 1833 (*ListRunner)->Translate(&(*ListRunner)->Center); 1834 (*ListRunner)->Center.Scale(-1.); 1835 } 1836 1837 Log() << Verbose(0) << "Storing configuration ... " << endl; 1838 // get correct valence orbitals 1839 mol->CalculateOrbitals(*this); 1840 InitMaxMinStopStep = MaxMinStopStep = MaxPsiDouble; 1841 if (ConfigFileName != NULL) { // test the file name 1842 strcpy(filename, ConfigFileName); 1843 output.open(filename, ios::trunc); 1844 } else if (strlen(configname) != 0) { 1845 strcpy(filename, configname); 1846 output.open(configname, ios::trunc); 1847 } else { 1848 strcpy(filename, DEFAULTCONFIG); 1849 output.open(DEFAULTCONFIG, ios::trunc); 1850 } 1851 output.close(); 1852 output.clear(); 1853 Log() << Verbose(0) << "Saving of config file "; 1854 if (Save(filename, periode, mol)) 1855 Log() << Verbose(0) << "successful." << endl; 1856 else 1857 Log() << Verbose(0) << "failed." << endl; 1858 1859 // and save to xyz file 1860 if (ConfigFileName != NULL) { 1861 strcpy(filename, ConfigFileName); 1862 strcat(filename, ".xyz"); 1863 output.open(filename, ios::trunc); 1864 } 1865 if (output == NULL) { 1866 strcpy(filename,"main_pcp_linux"); 1867 strcat(filename, ".xyz"); 1868 output.open(filename, ios::trunc); 1869 } 1870 Log() << Verbose(0) << "Saving of XYZ file "; 1871 if (mol->MDSteps <= 1) { 1872 if (mol->OutputXYZ(&output)) 1873 Log() << Verbose(0) << "successful." << endl; 1874 else 1875 Log() << Verbose(0) << "failed." << endl; 1876 } else { 1877 if (mol->OutputTrajectoriesXYZ(&output)) 1878 Log() << Verbose(0) << "successful." << endl; 1879 else 1880 Log() << Verbose(0) << "failed." << endl; 1881 } 1882 output.close(); 1883 output.clear(); 1884 1885 // and save as MPQC configuration 1886 if (ConfigFileName != NULL) 1887 strcpy(filename, ConfigFileName); 1888 if (output == NULL) 1889 strcpy(filename,"main_pcp_linux"); 1890 Log() << Verbose(0) << "Saving as mpqc input "; 1891 if (SaveMPQC(filename, mol)) 1892 Log() << Verbose(0) << "done." << endl; 1893 else 1894 Log() << Verbose(0) << "failed." << endl; 1895 1896 if (!strcmp(configpath, GetDefaultPath())) { 1897 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1898 } 1899 1900 delete(mol); 1901 }; 1902 1779 1903 /** Reads parameter from a parsed file. 1780 1904 * The file is either parsed for a certain keyword or if null is given for -
src/config.hpp
r1f1b23 ra25aae 146 146 bool SaveTREMOLO(const char * const filename, const MoleculeListClass * const MolList) const; 147 147 148 void SaveAll(char *ConfigFileName, periodentafel *periode, MoleculeListClass *molecules); 149 148 150 void Edit(); 149 151 bool GetIsAngstroem() const; -
src/defs.hpp
r1f1b23 ra25aae 77 77 #define UPDATECOUNT 10 //!< update ten sites per BOSSANOVA interval 78 78 79 #define STD_MENU_LENGTH 60 80 #define STD_MENU_TITLE_SPACER '=' 81 #define STD_SEPERATOR_SPACER '-' 82 79 83 #endif /*DEFS_HPP_*/ -
src/molecule.cpp
r1f1b23 ra25aae 61 61 delete(start); 62 62 }; 63 64 65 // getter and setter 66 const std::string molecule::getName(){ 67 return std::string(name); 68 } 69 70 void molecule::setName(const std::string _name){ 71 START_OBSERVER; 72 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 73 FINISH_OBSERVER; 74 } 63 75 64 76 … … 1083 1095 } 1084 1096 }; 1097 1098 void molecule::flipActiveFlag(){ 1099 ActiveFlag = !ActiveFlag; 1100 } -
src/molecule.hpp
r1f1b23 ra25aae 27 27 #include <vector> 28 28 29 #include <string> 30 29 31 #include "graph.hpp" 30 32 #include "stackclass.hpp" 31 33 #include "tesselation.hpp" 34 #include "Patterns/Observer.hpp" 32 35 33 36 /****************************************** forward declarations *****************************/ … … 80 83 * Class incorporates number of types 81 84 */ 82 class molecule : public PointCloud {85 class molecule : public PointCloud , public Observable { 83 86 public: 84 87 double cell_size[6];//!< cell size … … 99 102 bool ActiveFlag; //!< in a MoleculeListClass used to discern active from inactive molecules 100 103 Vector Center; //!< Center of molecule in a global box 104 int IndexNr; //!< index of molecule in a MoleculeListClass 101 105 char name[MAXSTRINGSIZE]; //!< arbitrary name 102 int IndexNr; //!< index of molecule in a MoleculeListClass 103 106 107 public: 104 108 molecule(const periodentafel * const teil); 105 109 virtual ~molecule(); 110 111 //getter and setter 112 const std::string getName(); 113 void setName(const std::string); 106 114 107 115 // re-definition of virtual functions from PointCloud … … 299 307 bool OutputTemperatureFromTrajectories(ofstream * const output, int startstep, int endstep); 300 308 309 // Manipulation routines 310 void flipActiveFlag(); 311 301 312 private: 302 313 int last_atom; //!< number given to last atom … … 308 319 /** A list of \a molecule classes. 309 320 */ 310 class MoleculeListClass {321 class MoleculeListClass : public Observable { 311 322 public: 312 323 MoleculeList ListOfMolecules; //!< List of the contained molecules … … 327 338 int CountAllAtoms() const; 328 339 340 // Methods moved here from the menus 341 // TODO: more refactoring needed on these methods 342 void flipChosen(); 343 void createNewMolecule(periodentafel *periode); 344 void loadFromXYZ(periodentafel *periode); 345 void setMoleculeFilename(); 346 void parseXYZIntoMolecule(); 347 void eraseMolecule(); 348 349 329 350 // merging of molecules 330 351 bool SimpleMerge(molecule *mol, molecule *srcmol); -
src/moleculelist.cpp
r1f1b23 ra25aae 50 50 void MoleculeListClass::insert(molecule *mol) 51 51 { 52 START_OBSERVER; 52 53 mol->IndexNr = MaxIndex++; 53 54 ListOfMolecules.push_back(mol); 55 mol->signOn(this); 56 FINISH_OBSERVER; 54 57 }; 55 58 … … 144 147 145 148 // header 146 Log() << Verbose(0) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl;147 Log() << Verbose(0) << "-----------------------------------------------" << endl;149 (*out) << "Index\tName\t\tAtoms\tFormula\tCenter\tSize" << endl; 150 (*out) << "-----------------------------------------------" << endl; 148 151 if (ListOfMolecules.size() == 0) 149 Log() << Verbose(0) << "\tNone" << endl;152 (*out) << "\tNone" << endl; 150 153 else { 151 154 Origin.Zero(); … … 164 167 } 165 168 // output Index, Name, number of atoms, chemical formula 166 Log() << Verbose(0) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t";169 (*out) << ((*ListRunner)->ActiveFlag ? "*" : " ") << (*ListRunner)->IndexNr << "\t" << (*ListRunner)->name << "\t\t" << (*ListRunner)->AtomCount << "\t"; 167 170 Elemental = (*ListRunner)->elemente->end; 168 171 while(Elemental->previous != (*ListRunner)->elemente->start) { 169 172 Elemental = Elemental->previous; 170 173 if (Counts[Elemental->Z] != 0) 171 Log() << Verbose(0) << Elemental->symbol << Counts[Elemental->Z];174 (*out) << Elemental->symbol << Counts[Elemental->Z]; 172 175 } 173 176 // Center and size 174 Log() << Verbose(0) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl;177 (*out) << "\t" << (*ListRunner)->Center << "\t" << sqrt(size) << endl; 175 178 } 176 179 } … … 875 878 } 876 879 880 /*********** 881 * Methods Moved here from the menus 882 */ 883 884 void MoleculeListClass::flipChosen() { 885 int j; 886 Log() << Verbose(0) << "Enter index of molecule: "; 887 cin >> j; 888 for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) 889 if ((*ListRunner)->IndexNr == j) 890 (*ListRunner)->ActiveFlag = !(*ListRunner)->ActiveFlag; 891 } 892 893 void MoleculeListClass::createNewMolecule(periodentafel *periode) { 894 START_OBSERVER; 895 molecule *mol = NULL; 896 mol = new molecule(periode); 897 insert(mol); 898 FINISH_OBSERVER; 899 }; 900 901 void MoleculeListClass::loadFromXYZ(periodentafel *periode){ 902 molecule *mol = NULL; 903 Vector center; 904 char filename[MAXSTRINGSIZE]; 905 Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 906 mol = new molecule(periode); 907 do { 908 Log() << Verbose(0) << "Enter file name: "; 909 cin >> filename; 910 } while (!mol->AddXYZFile(filename)); 911 mol->SetNameFromFilename(filename); 912 // center at set box dimensions 913 mol->CenterEdge(¢er); 914 mol->cell_size[0] = center.x[0]; 915 mol->cell_size[1] = 0; 916 mol->cell_size[2] = center.x[1]; 917 mol->cell_size[3] = 0; 918 mol->cell_size[4] = 0; 919 mol->cell_size[5] = center.x[2]; 920 insert(mol); 921 } 922 923 void MoleculeListClass::setMoleculeFilename() { 924 char filename[MAXSTRINGSIZE]; 925 int nr; 926 molecule *mol = NULL; 927 do { 928 Log() << Verbose(0) << "Enter index of molecule: "; 929 cin >> nr; 930 mol = ReturnIndex(nr); 931 } while (mol == NULL); 932 Log() << Verbose(0) << "Enter name: "; 933 cin >> filename; 934 mol->SetNameFromFilename(filename); 935 } 936 937 void MoleculeListClass::parseXYZIntoMolecule(){ 938 char filename[MAXSTRINGSIZE]; 939 int nr; 940 molecule *mol = NULL; 941 mol = NULL; 942 do { 943 Log() << Verbose(0) << "Enter index of molecule: "; 944 cin >> nr; 945 mol = ReturnIndex(nr); 946 } while (mol == NULL); 947 Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl; 948 do { 949 Log() << Verbose(0) << "Enter file name: "; 950 cin >> filename; 951 } while (!mol->AddXYZFile(filename)); 952 mol->SetNameFromFilename(filename); 953 }; 954 955 void MoleculeListClass::eraseMolecule(){ 956 int nr; 957 molecule *mol = NULL; 958 Log() << Verbose(0) << "Enter index of molecule: "; 959 cin >> nr; 960 for(MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) 961 if (nr == (*ListRunner)->IndexNr) { 962 mol = *ListRunner; 963 ListOfMolecules.erase(ListRunner); 964 delete(mol); 965 break; 966 } 967 }; 968 877 969 878 970 /******************************************* Class MoleculeLeafClass ************************************************/ -
src/unittests/Makefile.am
r1f1b23 ra25aae 3 3 AM_LDFLAGS = $(CPPUNIT_LIBS) -ldl 4 4 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 5 6 MENUTESTS = ActionSequenceTest 5 7 6 8 TESTS = \ … … 24 26 Tesselation_BoundaryTriangleUnitTest \ 25 27 Tesselation_InOutsideUnitTest \ 26 VectorUnitTest 28 VectorUnitTest \ 29 ObserverTest \ 30 ${MENUTESTS} 31 27 32 28 check_PROGRAMS = $(TESTS) 33 check_PROGRAMS = $(TESTS) 29 34 noinst_PROGRAMS = $(TESTS) 30 35 … … 89 94 VectorUnitTest_LDADD = ../libmolecuilder.a ../libgslwrapper.a 90 95 96 ActionSequenceTest_SOURCES = ActionSequenceTest.cpp ActionSequenceTest.hpp 97 ActionSequenceTest_LDADD = ../libmolecuilder.a 98 99 ObserverTest_SOURCES = ObserverTest.cpp ObserverTest.hpp 100 ObserverTest_LDADD = ../libmolecuilder.a 91 101 92 102 #AUTOMAKE_OPTIONS = parallel-tests -
src/vector.cpp
r1f1b23 ra25aae 663 663 }; 664 664 665 Vector& Vector::operator=(const Vector& src) { 666 CopyVector(src); 667 return *this; 668 } 669 665 670 /** Prints a 3dim vector. 666 671 * prints no end of line. … … 1076 1081 void Vector::CopyVector(const Vector * const y) 1077 1082 { 1078 for (int i=NDIM;i--;) 1079 this->x[i] = y->x[i]; 1083 // check for self assignment 1084 if(y!=this){ 1085 for (int i=NDIM;i--;) 1086 this->x[i] = y->x[i]; 1087 } 1080 1088 } 1081 1089 … … 1085 1093 void Vector::CopyVector(const Vector &y) 1086 1094 { 1087 for (int i=NDIM;i--;) 1088 this->x[i] = y.x[i]; 1095 // check for self assignment 1096 if(&y!=this) { 1097 for (int i=NDIM;i--;) 1098 this->x[i] = y.x[i]; 1099 } 1089 1100 } 1090 1101 -
src/vector.hpp
r1f1b23 ra25aae 79 79 bool IsInParallelepiped(const Vector &offset, const double * const parallelepiped) const; 80 80 void WrapPeriodically(const double * const M, const double * const Minv); 81 82 Vector& operator=(const Vector &src); 83 81 84 }; 82 85
Note:
See TracChangeset
for help on using the changeset viewer.