Changes in / [04488a:ce4487]
- Files:
-
- 14 deleted
- 65 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/ActionRegistry.cpp
r04488a rce4487 19 19 using namespace std; 20 20 21 /** Constructor for class ActionRegistry.22 */23 21 ActionRegistry::ActionRegistry() 24 22 { 25 23 } 26 24 27 /** Destructor for class ActionRegistry.28 */29 25 ActionRegistry::~ActionRegistry() 30 26 { … … 36 32 } 37 33 38 /** Returns pointer to an action named by \a name.39 * \param name name of action40 * \return pointer to Action41 */42 34 Action* ActionRegistry::getActionByName(const std::string name){ 43 35 map<const string,Action*>::iterator iter; … … 47 39 } 48 40 49 /** States whether action is present or not.50 * \note This iss needed as ActionRegistry::getActionByName() ASSERT()s that action is in map.51 * \param name name of action52 * \return true - Action present, false - Action absent53 */54 41 bool ActionRegistry::isActionByNamePresent(const std::string name){ 55 42 map<const string,Action*>::iterator iter; … … 58 45 } 59 46 60 /** Registers an Action with the ActionRegistry.61 * \param *action pointer to Action.62 */63 47 void ActionRegistry::registerAction(Action* action){ 64 48 pair<map<const string,Action*>::iterator,bool> ret; 65 //cout << "Trying to register action with name " << action->getName() << "." << endl;66 49 ret = actionMap.insert(pair<const string,Action*>(action->getName(),action)); 67 50 ASSERT(ret.second,"Two actions with the same name added to registry"); 68 51 } 69 52 70 /** Unregisters an Action.71 * \param *action pointer to Action.72 */73 53 void ActionRegistry::unregisterAction(Action* action){ 74 //cout << "Unregistering action with name " << action->getName() << "." << endl;75 54 actionMap.erase(action->getName()); 76 55 } 77 56 78 /** Returns an iterator pointing to the start of the map of Action's.79 * \return begin iterator80 */81 57 std::map<const std::string,Action*>::iterator ActionRegistry::getBeginIter() 82 58 { … … 84 60 } 85 61 86 /** Returns an iterator pointing to the end of the map of Action's.87 * \return end iterator88 */89 62 std::map<const std::string,Action*>::iterator ActionRegistry::getEndIter() 90 63 { … … 92 65 } 93 66 94 /** Returns a const iterator pointing to the start of the map of Action's.95 * \return constant begin iterator96 */97 std::map<const std::string,Action*>::const_iterator ActionRegistry::getBeginIter() const98 {99 return actionMap.begin();100 }101 102 /** Returns a const iterator pointing to the end of the map of Action's.103 * \return constant end iterator104 */105 std::map<const std::string,Action*>::const_iterator ActionRegistry::getEndIter() const106 {107 return actionMap.end();108 }109 110 /** Prints the contents of the ActionRegistry \a &m to \a &ost.111 * \param &ost output stream112 * \param &m reference to ActionRegistry113 * \return reference to the above out stream for concatenation114 */115 ostream& operator<<(ostream& ost, const ActionRegistry& m)116 {117 ost << "ActionRegistry contains:" << endl;118 for (std::map<const std::string,Action*>::const_iterator iter = m.getBeginIter(); iter != m.getEndIter(); ++iter) {119 ost << "\t" << iter->first << " with pointer " << iter->second << endl;120 }121 return ost;122 };123 124 125 126 67 CONSTRUCT_SINGLETON(ActionRegistry) -
src/Actions/ActionRegistry.hpp
r04488a rce4487 9 9 #define ACTIONREGISTRY_HPP_ 10 10 11 #include <iostream>12 11 #include <string> 13 12 #include <map> … … 27 26 28 27 std::map<const std::string,Action*>::iterator getBeginIter(); 29 std::map<const std::string,Action*>::const_iterator getBeginIter() const;30 28 std::map<const std::string,Action*>::iterator getEndIter(); 31 std::map<const std::string,Action*>::const_iterator getEndIter() const;32 29 33 30 private: … … 39 36 }; 40 37 41 std::ostream& operator<<(std::ostream& ost, const ActionRegistry& m);42 43 38 #endif /* ACTIONREGISTRY_HPP_ */ -
src/Actions/CmdAction/BondLengthTableAction.cpp
r04488a rce4487 9 9 10 10 #include "Actions/CmdAction/BondLengthTableAction.hpp" 11 #include "bondgraph.hpp"12 11 #include "config.hpp" 13 12 #include "log.hpp" -
src/Actions/FragmentationAction/DepthFirstSearchAction.cpp
r04488a rce4487 10 10 #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp"13 12 #include "config.hpp" 14 13 #include "log.hpp" -
src/Actions/FragmentationAction/FragmentationAction.cpp
r04488a rce4487 10 10 #include "Actions/FragmentationAction/FragmentationAction.hpp" 11 11 #include "atom.hpp" 12 #include "bondgraph.hpp"13 12 #include "config.hpp" 14 13 #include "log.hpp" … … 42 41 double distance = -1.; 43 42 int order = 0; 44 std::string path;45 43 config *configuration = World::getInstance().getConfig(); 46 44 int ExitFlag = 0; 47 45 48 46 cout << "pre-dialog"<< endl; 49 dialog->queryString(NAME, &path, MapOfActions::getInstance().getDescription(NAME)); 50 dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id")); 47 dialog->queryMolecule(NAME, &mol, MapOfActions::getInstance().getDescription(NAME)); 51 48 dialog->queryDouble("distance", &distance, MapOfActions::getInstance().getDescription("distance")); 52 49 dialog->queryInt("order", &order, MapOfActions::getInstance().getDescription("order")); … … 61 58 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 62 59 if (mol->hasBondStructure()) { 63 ExitFlag = mol->FragmentMolecule(order, path);60 ExitFlag = mol->FragmentMolecule(order, configuration); 64 61 } 65 62 World::getInstance().setExitFlag(ExitFlag); -
src/Actions/Makefile.am
r04488a rce4487 120 120 WorldAction/CenterOnEdgeAction.cpp \ 121 121 WorldAction/ChangeBoxAction.cpp \ 122 WorldAction/InputAction.cpp \123 WorldAction/OutputAction.cpp \124 122 WorldAction/RemoveSphereOfAtomsAction.cpp \ 125 123 WorldAction/RepeatBoxAction.cpp \ … … 133 131 WorldAction/CenterOnEdgeAction.hpp \ 134 132 WorldAction/ChangeBoxAction.hpp \ 135 WorldAction/InputAction.hpp \136 WorldAction/OutputAction.hpp \137 133 WorldAction/RemoveSphereOfAtomsAction.hpp \ 138 134 WorldAction/RepeatBoxAction.hpp \ -
src/Actions/MapOfActions.cpp
r04488a rce4487 83 83 DescriptionMap["fragment-mol"] = "create for a given molecule into fragments up to given order"; 84 84 DescriptionMap["help"] = "Give this help screen"; 85 DescriptionMap["input"] = "specify input files";86 85 DescriptionMap["linear-interpolate"] = "linear interpolation in discrete steps between start and end position of a molecule"; 87 86 DescriptionMap["nonconvex-envelope"] = "create the non-convex envelope for a molecule"; 88 87 DescriptionMap["molecular-volume"] = "calculate the volume of a given molecule"; 89 DescriptionMap["output"] = "specify output formats";90 88 DescriptionMap["pair-correlation"] = "pair correlation analysis between two elements, element and point or element and surface"; 91 89 DescriptionMap["parse-xyz"] = "parse xyz file into World"; … … 187 185 TypeMap["fastparsing"] = Boolean; 188 186 TypeMap["fill-molecule"] = String; 189 TypeMap["fragment-mol"] = String;187 TypeMap["fragment-mol"] = Molecule; 190 188 TypeMap["input"] = String; 191 189 TypeMap["linear-interpolate"] = String; 192 190 TypeMap["molecular-volume"] = Molecule; 193 191 TypeMap["nonconvex-envelope"] = Molecule; 194 TypeMap["output"] = String;195 192 TypeMap["parse-xyz"] = String; 196 193 TypeMap["pair-correlation"] = String; … … 265 262 generic.insert("fragment-mol"); 266 263 generic.insert("help"); 267 generic.insert("input"); 268 generic.insert("linear-interpolate"); 264 generic.insert("linear-interpolate"); 269 265 // generic.insert("molecular-volume"); 270 266 generic.insert("nonconvex-envelope"); 271 generic.insert("output");272 267 generic.insert("pair-correlation"); 273 generic.insert("parse-xyz");268 // generic.insert("parse-xyz"); 274 269 // generic.insert("principal-axis-system"); 275 270 generic.insert("remove-atom"); -
src/Actions/MoleculeAction/FillWithMoleculeAction.cpp
r04488a rce4487 102 102 World::getInstance().getMolecules()->insert(Filling); 103 103 } 104 for (molecule::iterator iter = filler->begin(); !filler->empty(); iter = filler->begin()) {105 atom *Walker = *iter;106 filler->erase(iter);107 World::getInstance().destroyAtom(Walker);108 }109 104 World::getInstance().destroyMolecule(filler); 110 105 -
src/Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.cpp
r04488a rce4487 69 69 if (IdMapping) 70 70 DoLog(1) && (Log() << Verbose(1) << "Using Identity for the permutation map." << endl); 71 if (!mol->LinearInterpolationBetweenConfiguration(start, end, filename, *(World::getInstance().getConfig()), IdMapping)) 72 DoLog(2) && (Log() << Verbose(2) << "Could not store " << filename << " files." << endl); 71 char outputname[MAXSTRINGSIZE]; 72 strcpy(outputname, filename.c_str()); 73 // TODO: LinearInterpolationBetweenConfiguration should use stream, not the filename directly! (better for unit test) 74 if (!mol->LinearInterpolationBetweenConfiguration(start, end, outputname, *(World::getInstance().getConfig()), IdMapping)) 75 DoLog(2) && (Log() << Verbose(2) << "Could not store " << outputname << " files." << endl); 73 76 else 74 77 DoLog(2) && (Log() << Verbose(2) << "Steps created and " << filename << " files stored." << endl); -
src/Actions/MoleculeAction/SaveAdjacencyAction.cpp
r04488a rce4487 65 65 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 66 // TODO: sollte stream nicht filename benutzen, besser fuer unit test 67 mol->StoreAdjacencyToFile(filename); 67 char outputname[MAXSTRINGSIZE]; 68 strcpy(outputname, filename.c_str()); 69 mol->StoreAdjacencyToFile(NULL, outputname); 68 70 delete dialog; 69 71 return Action::success; -
src/Actions/MoleculeAction/SaveBondsAction.cpp
r04488a rce4487 64 64 DoLog(0) && (Log() << Verbose(0) << "Storing bonds to path " << filename << "." << endl); 65 65 World::getInstance().getConfig()->BG->ConstructBondGraph(mol); 66 // TODO: sollte stream, nicht filenamen direkt nutzen, besser fuer unit tests 67 mol->StoreBondsToFile(filename); 66 // TODO: sollte stream, nicht filenamen direkt nutzen, beser fuer unit tests 67 char outputname[MAXSTRINGSIZE]; 68 strcpy(outputname, filename.c_str()); 69 mol->StoreBondsToFile(NULL, outputname); 68 70 delete dialog; 69 71 return Action::success; -
src/Actions/ParserAction/LoadXyzAction.cpp
r04488a rce4487 8 8 #include "Helpers/MemDebug.hpp" 9 9 10 using namespace std;11 12 10 #include "Actions/ParserAction/LoadXyzAction.hpp" 13 11 #include "Parser/XyzParser.hpp" 14 12 15 13 #include <iostream> 16 #include <set>17 14 #include <string> 18 #include <vector>19 15 16 using namespace std; 20 17 21 18 #include "UIElements/UIFactory.hpp" … … 24 21 25 22 #include "atom.hpp" 26 #include "log.hpp"27 23 #include "molecule.hpp" 28 #include "verbose.hpp"29 #include "World.hpp"30 24 31 25 /****** ParserLoadXyzAction *****/ … … 43 37 //}; 44 38 45 const char ParserLoadXyzAction::NAME[] = " parse-xyz";39 const char ParserLoadXyzAction::NAME[] = "LoadXyz"; 46 40 47 41 ParserLoadXyzAction::ParserLoadXyzAction() : … … 54 48 Action::state_ptr ParserLoadXyzAction::performCall() { 55 49 string filename; 50 XyzParser parser; 56 51 Dialog *dialog = UIFactory::getInstance().makeDialog(); 57 52 58 dialog->queryString( NAME,&filename, NAME);53 dialog->queryString("filename",&filename, "Filename of the xyz file"); 59 54 60 55 if(dialog->display()) { 61 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);62 56 // parse xyz file 63 57 ifstream input; 64 58 input.open(filename.c_str()); 65 if (!input.fail()) { 66 // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include 67 set <atom*> UniqueList; 68 { 69 vector<atom *> ListBefore = World::getInstance().getAllAtoms(); 70 for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner) 71 UniqueList.insert(*runner); 72 } 73 XyzParser parser; // briefly instantiate a parser which is removed at end of focus 59 if (!input.fail()) 74 60 parser.load(&input); 75 {76 vector<atom *> ListAfter = World::getInstance().getAllAtoms();77 pair< set<atom *>::iterator, bool > Inserter;78 if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed79 MoleculeListClass *molecules = World::getInstance().getMolecules();80 molecule *mol= NULL;81 if (molecules->ListOfMolecules.empty()) {82 mol = World::getInstance().createMolecule();83 molecules->insert(mol);84 } else {85 mol = *(molecules->ListOfMolecules.begin());86 }87 for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {88 Inserter = UniqueList.insert(*runner);89 if (Inserter.second) { // if not present, then new (just parsed) atom, add ...90 cout << "Adding new atom " << **runner << " to new mol." << endl;91 mol->AddAtom(*runner);92 }93 }94 mol->doCountAtoms();95 } else {96 cout << "No atoms parsed?" << endl;97 }98 }99 } else {100 DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);101 }102 61 input.close(); 103 62 } -
src/CommandLineParser.cpp
r04488a rce4487 56 56 { 57 57 // go through all arguments 58 cout << Verbose(1) << "By default putting input into the sequence." << endl;59 // TODO: This may be bad, because const string "input" is destroyed at end of function60 SequenceOfActions.push_back("input");61 58 for (int i=1;i<argc;i++) { 62 59 (cout << Verbose(1) << "Checking on " << argv[i] << endl); -
src/Descriptors/AtomDescriptor.cpp
r04488a rce4487 12 12 13 13 #include "World.hpp" 14 14 15 #include "atom.hpp" 15 16 16 17 #include <boost/bind.hpp> 17 18 #include <cassert> 18 19 #include <iostream> 19 20 -
src/Descriptors/MoleculeDescriptor.cpp
r04488a rce4487 16 16 17 17 #include <boost/bind.hpp> 18 #include <cassert> 18 19 #include <iostream> 19 20 -
src/Helpers/MemDebug.cpp
r04488a rce4487 6 6 */ 7 7 8 #ifndef ND EBUG8 #ifndef NDBEGUG 9 9 #ifndef NO_MEMDEBUG 10 10 -
src/Legacy/oldmenu.cpp
r04488a rce4487 609 609 { 610 610 int Order1; 611 std::string path;612 611 clock_t start, end; 613 612 … … 615 614 Log() << Verbose(0) << "What's the desired bond order: "; 616 615 cin >> Order1; 617 DoLog(0) && (Log() << Verbose(0) << "What's the output path and prefix [e.g. /home/foo/BondFragment]: ");618 cin >> path;619 616 if (mol->hasBondStructure()) { 620 617 start = clock(); 621 mol->FragmentMolecule(Order1, path);618 mol->FragmentMolecule(Order1, configuration); 622 619 end = clock(); 623 620 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl; -
src/Makefile.am
r04488a rce4487 63 63 64 64 ACTIONSHEADER = \ 65 ${ANALYSISACTIONHEADER} \ 66 ${ATOMACTIONHEADER} \ 67 ${CMDACTIONHEADER} \ 68 ${FRAGMENTATIONACTIONHEADER} \ 69 ${MOLECULEACTIONHEADER} \ 70 ${PARSERACTIONHEADER} \ 71 ${TESSELATIONACTIONHEADER} \ 72 ${WORLDACTIONHEADER} \ 65 73 Actions/Action.hpp \ 66 74 Actions/ActionHistory.hpp \ … … 80 88 Parser/ChangeTracker.cpp \ 81 89 Parser/FormatParser.cpp \ 82 Parser/FormatParserStorage.cpp \83 Parser/MpqcParser.cpp \84 Parser/PcpParser.cpp \85 90 Parser/TremoloParser.cpp \ 86 91 Parser/XyzParser.cpp 87 88 92 PARSERHEADER = \ 89 93 Parser/ChangeTracker.hpp \ 90 94 Parser/FormatParser.hpp \ 91 Parser/FormatParserStorage.hpp \92 Parser/MpqcParser.hpp \93 Parser/PcpParser.hpp \94 95 Parser/TremoloParser.hpp \ 95 96 Parser/XyzParser.hpp … … 182 183 CommandLineParser.cpp \ 183 184 config.cpp \ 184 ConfigFileBuffer.cpp \185 185 element.cpp \ 186 186 elements_db.cpp \ … … 208 208 tesselation.cpp \ 209 209 tesselationhelpers.cpp \ 210 ThermoStatContainer.cpp \211 210 triangleintersectionlist.cpp \ 212 211 vector.cpp \ … … 229 228 CommandLineParser.hpp \ 230 229 config.hpp \ 231 ConfigFileBuffer.hpp \232 230 defs.hpp \ 233 231 element.hpp \ … … 252 250 tesselation.hpp \ 253 251 tesselationhelpers.hpp \ 254 ThermoStatContainer.hpp \255 252 triangleintersectionlist.hpp \ 256 253 verbose.hpp \ … … 268 265 INCLUDES = -I$(top_srcdir)/src/unittests -I$(top_srcdir)/src/Actions -I$(top_srcdir)/src/UIElements 269 266 270 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a libparser.a 271 bin_PROGRAMS = molecuilder molecuildergui joiner analyzer 272 267 noinst_LIBRARIES = libmolecuilder.a libgslwrapper.a libmenu.a 268 bin_PROGRAMS = molecuilder molecuildergui joiner analyzer 273 269 molecuilderdir = ${bindir} 274 270 … … 276 272 277 273 libmenu_a_SOURCES = ${UISOURCE} ${UIHEADER} 278 libparser_a_SOURCES = ${PARSERSOURCE} ${PARSERHEADER} 274 279 275 libgslwrapper_a_SOURCES = ${LINALGSOURCE} ${LINALGHEADER} 280 276 … … 286 282 molecuilder_SOURCES = ${LEGACYSOURCE} builder.cpp 287 283 molecuilder_SOURCES += $(srcdir)/version.c 288 molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a lib parser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}284 molecuilder_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 289 285 290 286 #Stuff for building the GUI using QT … … 293 289 molecuildergui_CXXFLAGS = ${QT_CXXFLAGS} ${GLU_CXXFLAGS} -DUSE_GUI_QT 294 290 molecuildergui_LDFLAGS = $(BOOST_LIB) ${QT_LDFLAGS} ${GLU_LDFLAGS} 295 molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a lib parser.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} ${GUI_LIBS}291 molecuildergui_LDADD = UIElements/libMolecuilderUI.a Actions/libMolecuilderActions.a libmolecuilder.a libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} ${GUI_LIBS} 296 292 297 293 joiner_SOURCES = joiner.cpp datacreator.cpp parser.cpp datacreator.hpp helpers.hpp parser.hpp periodentafel.hpp -
src/Parser/ChangeTracker.cpp
r04488a rce4487 7 7 8 8 #include "Helpers/MemDebug.hpp" 9 #include "Parser/ChangeTracker.hpp"10 #include "Patterns/Singleton_impl.hpp"11 9 10 #include "ChangeTracker.hpp" 11 12 ChangeTracker* ChangeTracker::instance = NULL; 12 13 13 14 /** … … 26 27 ChangeTracker::~ChangeTracker() { 27 28 World::getInstance().signOff(this); 29 } 30 31 /** 32 * Returns the change tracker instance. 33 * 34 * \return this 35 */ 36 ChangeTracker* ChangeTracker::get() { 37 if (instance == NULL) { 38 instance = new ChangeTracker(); 39 } 40 41 return instance; 42 } 43 44 /** 45 * Destroys the change tracker instance. Be careful, the change tracker is a 46 * singleton and destruction might lead to a loss of consistency. 47 */ 48 void ChangeTracker::destroy() { 49 delete instance; 50 instance = NULL; 28 51 } 29 52 … … 53 76 } 54 77 } 55 56 CONSTRUCT_SINGLETON(ChangeTracker) -
src/Parser/ChangeTracker.hpp
r04488a rce4487 18 18 * changes to it. 19 19 */ 20 class ChangeTracker : public Singleton<ChangeTracker>, public Observable { 21 friend class Singleton<ChangeTracker>; 20 class ChangeTracker : public Observable { 22 21 public: 23 22 void saveStatus(); … … 32 31 bool isConsistent; 33 32 static ChangeTracker* instance; 34 35 // private constructor and destructor due to singleton36 33 ChangeTracker(); 37 34 ~ChangeTracker(); -
src/Parser/FormatParser.cpp
r04488a rce4487 19 19 Observer("FormatParser") 20 20 { 21 ChangeTracker::get Instance().signOn(this);21 ChangeTracker::get()->signOn(this); 22 22 saveStream = NULL; 23 23 } … … 27 27 */ 28 28 FormatParser::~FormatParser() { 29 ChangeTracker::get Instance().signOff(this);29 ChangeTracker::get()->signOff(this); 30 30 } 31 31 -
src/Parser/TremoloParser.cpp
r04488a rce4487 49 49 knownKeys["GrpTypeNo"] = TremoloKey::GrpTypeNo; 50 50 knownKeys["torsion"] = TremoloKey::torsion; 51 52 // default behavior: use all possible keys on output53 for (std::map<std::string, TremoloKey::atomDataKey>::iterator iter = knownKeys.begin(); iter != knownKeys.end(); ++iter)54 usedFields.push_back(iter->first);55 51 } 56 52 … … 197 193 198 194 lineStream << line.substr(offset); 199 usedFields.clear();200 195 while (lineStream.good()) { 201 196 lineStream >> keyword; -
src/Parser/TremoloParser.hpp
r04488a rce4487 10 10 11 11 #include <string> 12 #include " Parser/FormatParser.hpp"12 #include "FormatParser.hpp" 13 13 14 14 /** -
src/Parser/XyzParser.cpp
r04488a rce4487 27 27 */ 28 28 XyzParser::~XyzParser() { 29 delete(&comment); 29 30 } 30 31 … … 57 58 */ 58 59 void XyzParser::save(ostream* file) { 59 if (comment == "") {60 time_t now = time((time_t *)NULL); // Get the system time and put it into 'now' as 'calender time'61 comment = "\tCreated by molecuilder on ";62 // ctime ends in \n\0, we have to cut away the newline63 std::string time(ctime(&now));64 size_t pos = time.find('\n');65 if (pos != 0)66 comment += time.substr(0,pos);67 else68 comment += time;69 }70 60 *file << World::getInstance().numAtoms() << endl << comment << endl; 71 61 72 62 vector<atom*> atoms = World::getInstance().getAllAtoms(); 73 63 for(vector<atom*>::iterator it = atoms.begin(); it != atoms.end(); it++) { 74 *file << noshowpoint<< (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl;64 *file << fixed << (*it)->getType()->symbol << "\t" << (*it)->x[0] << "\t" << (*it)->x[1] << "\t" << (*it)->x[2] << endl; 75 65 } 76 66 } -
src/Parser/XyzParser.hpp
r04488a rce4487 10 10 11 11 #include <string> 12 #include " Parser/FormatParser.hpp"12 #include "FormatParser.hpp" 13 13 14 14 /** -
src/Patterns/Singleton.hpp
r04488a rce4487 9 9 #define SINGLETON_HPP_ 10 10 11 #include <cassert> 11 12 #include <boost/thread.hpp> 12 13 13 #include "Helpers/Assert.hpp"14 14 #include "defs.hpp" 15 15 … … 181 181 182 182 inline static void set(creator_T*&,creator_T*){ 183 ASSERT(0,"Cannot set the Instance for a singleton of this type");183 assert(0 && "Cannot set the Instance for a singleton of this type"); 184 184 } 185 185 }; … … 191 191 struct creator_t<creator_T,false>{ 192 192 inline static creator_T* make(){ 193 ASSERT(0, "Cannot create a singleton of this type directly"); 194 return 0; 193 assert(0 && "Cannot create a singleton of this type directly"); 195 194 } 196 195 inline static void set(ptr_t& dest,creator_T* src){ -
src/Patterns/Singleton_impl.hpp
r04488a rce4487 72 72 template <class T,bool _may_create> 73 73 void Singleton<T,_may_create>::setInstance(T* newInstance){ 74 ASSERT(!theInstance.get(),"Trying to set the instance of an already created singleton");74 assert(!theInstance.get() && "Trying to set the instance of an already created singleton"); 75 75 boost::recursive_mutex::scoped_lock guard(instanceLock); 76 76 theInstance.reset(newInstance); … … 83 83 template <class T, bool _may_create> 84 84 Singleton<T,_may_create>::Singleton(const Singleton<T,_may_create>&){ 85 ASSERT(0,"Copy constructor of singleton template called");85 assert(0 && "Copy constructor of singleton template called"); 86 86 } 87 87 -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
r04488a rce4487 47 47 #include "Actions/WorldAction/CenterOnEdgeAction.hpp" 48 48 #include "Actions/WorldAction/ChangeBoxAction.hpp" 49 #include "Actions/WorldAction/InputAction.hpp"50 #include "Actions/WorldAction/OutputAction.hpp"51 49 #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp" 52 50 #include "Actions/WorldAction/RepeatBoxAction.hpp" … … 83 81 84 82 void CommandLineWindow::display() { 85 //cout << ActionRegistry::getInstance();86 87 83 // go through all possible actions 88 84 for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) { 89 cout << "Checking presence of " << *CommandRunner << ": "; 90 if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner)) { 91 cout << "calling " << *CommandRunner << endl; 85 cout << "Checking presence of " << *CommandRunner << endl; 86 if (ActionRegistry::getInstance().isActionByNamePresent(*CommandRunner)) 92 87 ActionRegistry::getInstance().getActionByName(*CommandRunner)->call(); 93 } else {94 cout << "absent." << endl;95 }96 88 } 97 89 } … … 160 152 new WorldCenterOnEdgeAction(); 161 153 new WorldChangeBoxAction(); 162 new WorldInputAction();163 new WorldOutputAction();164 154 new WorldRemoveSphereOfAtomsAction(); 165 155 new WorldRepeatBoxAction(); -
src/UIElements/Dialog.cpp
r04488a rce4487 7 7 8 8 #include "Helpers/MemDebug.hpp" 9 10 #include <cassert> 9 11 10 12 #include "Dialog.hpp" -
src/World.cpp
r04488a rce4487 14 14 #include "molecule.hpp" 15 15 #include "periodentafel.hpp" 16 #include "ThermoStatContainer.hpp"17 16 #include "Descriptors/AtomDescriptor.hpp" 18 17 #include "Descriptors/AtomDescriptor_impl.hpp" … … 21 20 #include "Descriptors/SelectiveIterator_impl.hpp" 22 21 #include "Actions/ManipulateAtomsProcess.hpp" 23 #include "Helpers/Assert.hpp"24 22 25 23 #include "Patterns/Singleton_impl.hpp" … … 92 90 }; 93 91 94 class ThermoStatContainer * World::getThermostats()95 {96 return Thermostats;97 }98 99 100 92 int World::getExitFlag() { 101 93 return ExitFlag; … … 113 105 molecule *mol = NULL; 114 106 mol = NewMolecule(); 115 ASSERT(!molecules.count(currMoleculeId),"currMoleculeId did not specify an unused ID");107 assert(!molecules.count(currMoleculeId)); 116 108 mol->setId(currMoleculeId++); 117 109 // store the molecule by ID … … 129 121 OBSERVE; 130 122 molecule *mol = molecules[id]; 131 ASSERT(mol,"Molecule id that was meant to be destroyed did not exist");123 assert(mol); 132 124 DeleteMolecule(mol); 133 125 molecules.erase(id); … … 165 157 OBSERVE; 166 158 atom *atom = atoms[id]; 167 ASSERT(atom,"Atom ID that was meant to be destroyed did not exist");159 assert(atom); 168 160 DeleteAtom(atom); 169 161 atoms.erase(id); … … 177 169 if(!target){ 178 170 target = atoms[oldId]; 179 ASSERT(target,"Atom with that ID not found");171 assert(target && "Atom with that ID not found"); 180 172 return target->changeId(newId); 181 173 } … … 289 281 periode(new periodentafel), 290 282 configuration(new config), 291 Thermostats(new ThermoStatContainer),292 283 ExitFlag(0), 293 284 atoms(), … … 315 306 delete periode; 316 307 delete configuration; 317 delete Thermostats;318 308 MoleculeSet::iterator molIter; 319 309 for(molIter=molecules.begin();molIter!=molecules.end();++molIter){ -
src/World.hpp
r04488a rce4487 30 30 31 31 // forward declarations 32 class config; 33 class periodentafel; 34 class MoleculeListClass; 32 35 class atom; 36 class molecule; 33 37 class AtomDescriptor; 34 38 class AtomDescriptor_impl; 35 template<typename T> class AtomsCalculation;36 class config;37 class ManipulateAtomsProcess;38 class molecule;39 39 class MoleculeDescriptor; 40 40 class MoleculeDescriptor_impl; 41 class M oleculeListClass;42 class periodentafel; 43 class ThermoStatContainer;41 class ManipulateAtomsProcess; 42 template<typename T> 43 class AtomsCalculation; 44 44 45 45 /****************************************** forward declarations *****************************/ … … 142 142 void setDefaultName(std::string name); 143 143 144 /**145 * get pointer to World's ThermoStatContainer146 */147 ThermoStatContainer * getThermostats();148 149 144 /* 150 145 * get the ExitFlag … … 259 254 static double *cell_size; 260 255 std::string defaultName; 261 class ThermoStatContainer *Thermostats;262 256 int ExitFlag; 263 257 public: -
src/atom.cpp
r04488a rce4487 159 159 * \return true - \a *out present, false - \a *out is NULL 160 160 */ 161 bool atom::OutputArrayIndexed(o stream * const out, const int *ElementNo, int *AtomNo, const char *comment) const161 bool atom::OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment) const 162 162 { 163 163 AtomNo[type->Z]++; // increment number … … 236 236 * \param *AtomNo pointer to atom counter that is increased by one 237 237 */ 238 void atom::OutputMPQCLine(o stream * const out, const Vector *center, int *AtomNo = NULL) const238 void atom::OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo = NULL) const 239 239 { 240 240 *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl; -
src/atom.hpp
r04488a rce4487 51 51 52 52 bool OutputIndexed(ofstream * const out, const int ElementNo, const int AtomNo, const char *comment = NULL) const; 53 bool OutputArrayIndexed(o stream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const;53 bool OutputArrayIndexed(ofstream * const out, const int *ElementNo, int *AtomNo, const char *comment = NULL) const; 54 54 bool OutputXYZLine(ofstream *out) const; 55 55 bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const; 56 56 bool OutputTrajectoryXYZ(ofstream * const out, const int step) const; 57 void OutputMPQCLine(o stream * const out, const Vector *center, int *AtomNo) const;57 void OutputMPQCLine(ofstream * const out, const Vector *center, int *AtomNo) const; 58 58 59 59 void InitComponentNr(); -
src/atom_trajectoryparticle.cpp
r04488a rce4487 15 15 #include "log.hpp" 16 16 #include "parser.hpp" 17 #include "ThermoStatContainer.hpp"18 17 #include "verbose.hpp" 19 18 … … 198 197 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration) 199 198 { 200 double sigma = sqrt(configuration->T hermostats->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)199 double sigma = sqrt(configuration->TargetTemp/type->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime) 201 200 Vector &U = Trajectory.U.at(Step); 202 201 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 203 202 // throw a dice to determine whether it gets hit by a heat bath particle 204 if (((((rand()/(double)RAND_MAX))*configuration->T hermostats->TempFrequency) < 1.)) {203 if (((((rand()/(double)RAND_MAX))*configuration->TempFrequency) < 1.)) { 205 204 DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> "); 206 205 // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis … … 226 225 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 227 226 for (int d=0; d<NDIM; d++) { 228 U[d] *= sqrt(1+(configuration->Deltat/configuration->T hermostats->TempFrequency)*(ScaleTempFactor-1));227 U[d] *= sqrt(1+(configuration->Deltat/configuration->TempFrequency)*(ScaleTempFactor-1)); 229 228 *ekin += 0.5*type->mass * U[d]*U[d]; 230 229 } … … 256 255 if (FixedIon == 0) { // even FixedIon moves, only not by other's forces 257 256 for (int d=0; d<NDIM; d++) { 258 U[d] += configuration->Deltat/type->mass * (configuration-> Thermostats->alpha * (U[d] * type->mass));257 U[d] += configuration->Deltat/type->mass * (configuration->alpha * (U[d] * type->mass)); 259 258 *ekin += (0.5*type->mass) * U[d]*U[d]; 260 259 } -
src/builder.cpp
r04488a rce4487 1 1 /** \file builder.cpp 2 2 * 3 * date: Jan 1, 2007 4 * author: heber 3 * By stating absolute positions or binding angles and distances atomic positions of a molecule can be constructed. 4 * The output is the complete configuration file for PCP for direct use. 5 * Features: 6 * -# Atomic data is retrieved from a file, if not found requested and stored there for later re-use 7 * -# step-by-step construction of the molecule beginning either at a centre of with a certain atom 5 8 * 6 9 */ 7 10 8 /*! \mainpage Mole Cuilder - a molecular set builder11 /*! \mainpage Molecuilder - a molecular set builder 9 12 * 10 * This introductory shall briefly make a cquainted with the program, helping in installing and a first run.13 * This introductory shall briefly make aquainted with the program, helping in installing and a first run. 11 14 * 12 15 * \section about About the Program 13 16 * 14 * MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the 15 * atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond 16 * angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and 17 * ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated 18 * and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules. 19 * In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or 20 * amorphic in nature. 17 * Molecuilder is a short program, written in C++, that enables the construction of a coordinate set for the 18 * atoms making up an molecule by the successive statement of binding angles and distances and referencing to 19 * already constructed atoms. 21 20 * 21 * A configuration file may be written that is compatible to the format used by PCP - a parallel Car-Parrinello 22 * molecular dynamics implementation. 22 23 * 23 24 * \section install Installation … … 31 32 * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n 32 33 * -# make doxygen-doc: Creates these html pages out of the documented source 33 * -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of34 * functions.35 34 * 36 35 * \section run Running … … 38 37 * The program can be executed by running: ./molecuilder 39 38 * 40 * MoleCuilder has three interfaces at your disposal: 41 * -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms 42 * as you like 43 * -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed 44 * with any user interaction. 45 * -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other 46 * informations to ease the construction of bigger geometries. 39 * Note, that it uses a database, called "elements.db", in the executable's directory. If the file is not found, 40 * it is created and any given data on elements of the periodic table will be stored therein and re-used on 41 * later re-execution. 47 42 * 48 * The supported output formats right now are: 49 * -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs) 50 * -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation) 51 * -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation) 52 * -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates. 43 * \section ref References 44 * 45 * For the special configuration file format, see the documentation of pcp. 53 46 * 54 47 */ … … 56 49 #include "Helpers/MemDebug.hpp" 57 50 51 #include <boost/bind.hpp> 52 53 using namespace std; 54 55 #include <cstring> 56 #include <cstdlib> 57 58 #include "analysis_bonds.hpp" 59 #include "analysis_correlation.hpp" 60 #include "atom.hpp" 61 #include "bond.hpp" 58 62 #include "bondgraph.hpp" 63 #include "boundary.hpp" 59 64 #include "CommandLineParser.hpp" 60 65 #include "config.hpp" 66 #include "element.hpp" 67 #include "ellipsoid.hpp" 68 #include "helpers.hpp" 69 #include "leastsquaremin.hpp" 70 #include "linkedcell.hpp" 61 71 #include "log.hpp" 62 72 #include "memoryusageobserver.hpp" … … 72 82 #include "UIElements/Dialog.hpp" 73 83 #include "Menu/ActionMenuItem.hpp" 74 #include "verbose.hpp"75 #include "World.hpp"76 77 84 #include "Actions/ActionRegistry.hpp" 78 85 #include "Actions/ActionHistory.hpp" 79 86 #include "Actions/MapOfActions.hpp" 80 81 #include "Parser/ChangeTracker.hpp" 82 #include "Parser/FormatParserStorage.hpp" 83 84 #include "UIElements/UIFactory.hpp" 85 #include "UIElements/TextUI/TextUIFactory.hpp" 86 #include "UIElements/CommandLineUI/CommandLineUIFactory.hpp" 87 #include "UIElements/MainWindow.hpp" 88 #include "UIElements/Dialog.hpp" 89 87 #include "Actions/MethodAction.hpp" 88 #include "Actions/MoleculeAction/ChangeNameAction.hpp" 89 #include "World.hpp" 90 90 #include "version.h" 91 91 #include "World.hpp" 92 93 94 /********************************************* Subsubmenu routine ************************************/ 95 #if 0 96 /** Submenu for adding atoms to the molecule. 97 * \param *periode periodentafel 98 * \param *molecule molecules with atoms 99 */ 100 static void AddAtoms(periodentafel *periode, molecule *mol) 101 { 102 atom *first, *second, *third, *fourth; 103 Vector **atoms; 104 Vector x,y,z,n; // coordinates for absolute point in cell volume 105 double a,b,c; 106 char choice; // menu choice char 107 bool valid; 108 109 cout << Verbose(0) << "===========ADD ATOM============================" << endl; 110 cout << Verbose(0) << " a - state absolute coordinates of atom" << endl; 111 cout << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl; 112 cout << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl; 113 cout << Verbose(0) << " d - state two atoms, two angles and a distance" << endl; 114 cout << Verbose(0) << " e - least square distance position to a set of atoms" << endl; 115 cout << Verbose(0) << "all else - go back" << endl; 116 cout << Verbose(0) << "===============================================" << endl; 117 cout << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl; 118 cout << Verbose(0) << "INPUT: "; 119 cin >> choice; 120 121 switch (choice) { 122 default: 123 DoeLog(2) && (eLog()<< Verbose(2) << "Not a valid choice." << endl); 124 break; 125 case 'a': // absolute coordinates of atom 126 cout << Verbose(0) << "Enter absolute coordinates." << endl; 127 first = new atom; 128 first->x.AskPosition(World::getInstance().getDomain(), false); 129 first->type = periode->AskElement(); // give type 130 mol->AddAtom(first); // add to molecule 131 break; 132 133 case 'b': // relative coordinates of atom wrt to reference point 134 first = new atom; 135 valid = true; 136 do { 137 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl); 138 cout << Verbose(0) << "Enter reference coordinates." << endl; 139 x.AskPosition(World::getInstance().getDomain(), true); 140 cout << Verbose(0) << "Enter relative coordinates." << endl; 141 first->x.AskPosition(World::getInstance().getDomain(), false); 142 first->x.AddVector((const Vector *)&x); 143 cout << Verbose(0) << "\n"; 144 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 145 first->type = periode->AskElement(); // give type 146 mol->AddAtom(first); // add to molecule 147 break; 148 149 case 'c': // relative coordinates of atom wrt to already placed atom 150 first = new atom; 151 valid = true; 152 do { 153 if (!valid) DoeLog(2) && (eLog()<< Verbose(2) << "Resulting position out of cell." << endl); 154 second = mol->AskAtom("Enter atom number: "); 155 DoLog(0) && (Log() << Verbose(0) << "Enter relative coordinates." << endl); 156 first->x.AskPosition(World::getInstance().getDomain(), false); 157 for (int i=NDIM;i--;) { 158 first->x.x[i] += second->x.x[i]; 159 } 160 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 161 first->type = periode->AskElement(); // give type 162 mol->AddAtom(first); // add to molecule 163 break; 164 165 case 'd': // two atoms, two angles and a distance 166 first = new atom; 167 valid = true; 168 do { 169 if (!valid) { 170 DoeLog(2) && (eLog()<< Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl); 171 } 172 cout << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl; 173 second = mol->AskAtom("Enter central atom: "); 174 third = mol->AskAtom("Enter second atom (specifying the axis for first angle): "); 175 fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): "); 176 a = ask_value("Enter distance between central (first) and new atom: "); 177 b = ask_value("Enter angle between new, first and second atom (degrees): "); 178 b *= M_PI/180.; 179 bound(&b, 0., 2.*M_PI); 180 c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): "); 181 c *= M_PI/180.; 182 bound(&c, -M_PI, M_PI); 183 cout << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl; 184 /* 185 second->Output(1,1,(ofstream *)&cout); 186 third->Output(1,2,(ofstream *)&cout); 187 fourth->Output(1,3,(ofstream *)&cout); 188 n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x); 189 x.Copyvector(&second->x); 190 x.SubtractVector(&third->x); 191 x.Copyvector(&fourth->x); 192 x.SubtractVector(&third->x); 193 194 if (!z.SolveSystem(&x,&y,&n, b, c, a)) { 195 coutg() << Verbose(0) << "Failure solving self-dependent linear system!" << endl; 196 continue; 197 } 198 DoLog(0) && (Log() << Verbose(0) << "resulting relative coordinates: "); 199 z.Output(); 200 DoLog(0) && (Log() << Verbose(0) << endl); 201 */ 202 // calc axis vector 203 x.CopyVector(&second->x); 204 x.SubtractVector(&third->x); 205 x.Normalize(); 206 Log() << Verbose(0) << "x: ", 207 x.Output(); 208 DoLog(0) && (Log() << Verbose(0) << endl); 209 z.MakeNormalVector(&second->x,&third->x,&fourth->x); 210 Log() << Verbose(0) << "z: ", 211 z.Output(); 212 DoLog(0) && (Log() << Verbose(0) << endl); 213 y.MakeNormalVector(&x,&z); 214 Log() << Verbose(0) << "y: ", 215 y.Output(); 216 DoLog(0) && (Log() << Verbose(0) << endl); 217 218 // rotate vector around first angle 219 first->x.CopyVector(&x); 220 first->x.RotateVector(&z,b - M_PI); 221 Log() << Verbose(0) << "Rotated vector: ", 222 first->x.Output(); 223 DoLog(0) && (Log() << Verbose(0) << endl); 224 // remove the projection onto the rotation plane of the second angle 225 n.CopyVector(&y); 226 n.Scale(first->x.ScalarProduct(&y)); 227 Log() << Verbose(0) << "N1: ", 228 n.Output(); 229 DoLog(0) && (Log() << Verbose(0) << endl); 230 first->x.SubtractVector(&n); 231 Log() << Verbose(0) << "Subtracted vector: ", 232 first->x.Output(); 233 DoLog(0) && (Log() << Verbose(0) << endl); 234 n.CopyVector(&z); 235 n.Scale(first->x.ScalarProduct(&z)); 236 Log() << Verbose(0) << "N2: ", 237 n.Output(); 238 DoLog(0) && (Log() << Verbose(0) << endl); 239 first->x.SubtractVector(&n); 240 Log() << Verbose(0) << "2nd subtracted vector: ", 241 first->x.Output(); 242 DoLog(0) && (Log() << Verbose(0) << endl); 243 244 // rotate another vector around second angle 245 n.CopyVector(&y); 246 n.RotateVector(&x,c - M_PI); 247 Log() << Verbose(0) << "2nd Rotated vector: ", 248 n.Output(); 249 DoLog(0) && (Log() << Verbose(0) << endl); 250 251 // add the two linear independent vectors 252 first->x.AddVector(&n); 253 first->x.Normalize(); 254 first->x.Scale(a); 255 first->x.AddVector(&second->x); 256 257 DoLog(0) && (Log() << Verbose(0) << "resulting coordinates: "); 258 first->x.Output(); 259 DoLog(0) && (Log() << Verbose(0) << endl); 260 } while (!(valid = mol->CheckBounds((const Vector *)&first->x))); 261 first->type = periode->AskElement(); // give type 262 mol->AddAtom(first); // add to molecule 263 break; 264 265 case 'e': // least square distance position to a set of atoms 266 first = new atom; 267 atoms = new (Vector*[128]); 268 valid = true; 269 for(int i=128;i--;) 270 atoms[i] = NULL; 271 int i=0, j=0; 272 cout << Verbose(0) << "Now we need at least three molecules.\n"; 273 do { 274 cout << Verbose(0) << "Enter " << i+1 << "th atom: "; 275 cin >> j; 276 if (j != -1) { 277 second = mol->FindAtom(j); 278 atoms[i++] = &(second->x); 279 } 280 } while ((j != -1) && (i<128)); 281 if (i >= 2) { 282 first->x.LSQdistance((const Vector **)atoms, i); 283 first->x.Output(); 284 first->type = periode->AskElement(); // give type 285 mol->AddAtom(first); // add to molecule 286 } else { 287 delete first; 288 cout << Verbose(0) << "Please enter at least two vectors!\n"; 289 } 290 break; 291 }; 292 }; 293 294 /** Submenu for centering the atoms in the molecule. 295 * \param *mol molecule with all the atoms 296 */ 297 static void CenterAtoms(molecule *mol) 298 { 299 Vector x, y, helper; 300 char choice; // menu choice char 301 302 cout << Verbose(0) << "===========CENTER ATOMS=========================" << endl; 303 cout << Verbose(0) << " a - on origin" << endl; 304 cout << Verbose(0) << " b - on center of gravity" << endl; 305 cout << Verbose(0) << " c - within box with additional boundary" << endl; 306 cout << Verbose(0) << " d - within given simulation box" << endl; 307 cout << Verbose(0) << "all else - go back" << endl; 308 cout << Verbose(0) << "===============================================" << endl; 309 cout << Verbose(0) << "INPUT: "; 310 cin >> choice; 311 312 switch (choice) { 313 default: 314 cout << Verbose(0) << "Not a valid choice." << endl; 315 break; 316 case 'a': 317 cout << Verbose(0) << "Centering atoms in config file on origin." << endl; 318 mol->CenterOrigin(); 319 break; 320 case 'b': 321 cout << Verbose(0) << "Centering atoms in config file on center of gravity." << endl; 322 mol->CenterPeriodic(); 323 break; 324 case 'c': 325 cout << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl; 326 for (int i=0;i<NDIM;i++) { 327 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 328 cin >> y.x[i]; 329 } 330 mol->CenterEdge(&x); // make every coordinate positive 331 mol->Center.AddVector(&y); // translate by boundary 332 helper.CopyVector(&y); 333 helper.Scale(2.); 334 helper.AddVector(&x); 335 mol->SetBoxDimension(&helper); // update Box of atoms by boundary 336 break; 337 case 'd': 338 cout << Verbose(1) << "Centering atoms in config file within given simulation box." << endl; 339 for (int i=0;i<NDIM;i++) { 340 cout << Verbose(0) << "Enter axis " << i << " boundary: "; 341 cin >> x.x[i]; 342 } 343 // update Box of atoms by boundary 344 mol->SetBoxDimension(&x); 345 // center 346 mol->CenterInBox(); 347 break; 348 } 349 }; 350 351 /** Submenu for aligning the atoms in the molecule. 352 * \param *periode periodentafel 353 * \param *mol molecule with all the atoms 354 */ 355 static void AlignAtoms(periodentafel *periode, molecule *mol) 356 { 357 atom *first, *second, *third; 358 Vector x,n; 359 char choice; // menu choice char 360 361 cout << Verbose(0) << "===========ALIGN ATOMS=========================" << endl; 362 cout << Verbose(0) << " a - state three atoms defining align plane" << endl; 363 cout << Verbose(0) << " b - state alignment vector" << endl; 364 cout << Verbose(0) << " c - state two atoms in alignment direction" << endl; 365 cout << Verbose(0) << " d - align automatically by least square fit" << endl; 366 cout << Verbose(0) << "all else - go back" << endl; 367 cout << Verbose(0) << "===============================================" << endl; 368 cout << Verbose(0) << "INPUT: "; 369 cin >> choice; 370 371 switch (choice) { 372 default: 373 case 'a': // three atoms defining mirror plane 374 first = mol->AskAtom("Enter first atom: "); 375 second = mol->AskAtom("Enter second atom: "); 376 third = mol->AskAtom("Enter third atom: "); 377 378 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x); 379 break; 380 case 'b': // normal vector of mirror plane 381 cout << Verbose(0) << "Enter normal vector of mirror plane." << endl; 382 n.AskPosition(World::getInstance().getDomain(),0); 383 n.Normalize(); 384 break; 385 case 'c': // three atoms defining mirror plane 386 first = mol->AskAtom("Enter first atom: "); 387 second = mol->AskAtom("Enter second atom: "); 388 389 n.CopyVector((const Vector *)&first->x); 390 n.SubtractVector((const Vector *)&second->x); 391 n.Normalize(); 392 break; 393 case 'd': 394 char shorthand[4]; 395 Vector a; 396 struct lsq_params param; 397 do { 398 fprintf(stdout, "Enter the element of atoms to be chosen: "); 399 fscanf(stdin, "%3s", shorthand); 400 } while ((param.type = periode->FindElement(shorthand)) == NULL); 401 cout << Verbose(0) << "Element is " << param.type->name << endl; 402 mol->GetAlignvector(¶m); 403 for (int i=NDIM;i--;) { 404 x.x[i] = gsl_vector_get(param.x,i); 405 n.x[i] = gsl_vector_get(param.x,i+NDIM); 406 } 407 gsl_vector_free(param.x); 408 cout << Verbose(0) << "Offset vector: "; 409 x.Output(); 410 DoLog(0) && (Log() << Verbose(0) << endl); 411 n.Normalize(); 412 break; 413 }; 414 DoLog(0) && (Log() << Verbose(0) << "Alignment vector: "); 415 n.Output(); 416 DoLog(0) && (Log() << Verbose(0) << endl); 417 mol->Align(&n); 418 }; 419 420 /** Submenu for mirroring the atoms in the molecule. 421 * \param *mol molecule with all the atoms 422 */ 423 static void MirrorAtoms(molecule *mol) 424 { 425 atom *first, *second, *third; 426 Vector n; 427 char choice; // menu choice char 428 429 DoLog(0) && (Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl); 430 DoLog(0) && (Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl); 431 DoLog(0) && (Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl); 432 DoLog(0) && (Log() << Verbose(0) << " c - state two atoms in normal direction" << endl); 433 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 434 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 435 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 436 cin >> choice; 437 438 switch (choice) { 439 default: 440 case 'a': // three atoms defining mirror plane 441 first = mol->AskAtom("Enter first atom: "); 442 second = mol->AskAtom("Enter second atom: "); 443 third = mol->AskAtom("Enter third atom: "); 444 445 n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x); 446 break; 447 case 'b': // normal vector of mirror plane 448 DoLog(0) && (Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl); 449 n.AskPosition(World::getInstance().getDomain(),0); 450 n.Normalize(); 451 break; 452 case 'c': // three atoms defining mirror plane 453 first = mol->AskAtom("Enter first atom: "); 454 second = mol->AskAtom("Enter second atom: "); 455 456 n.CopyVector((const Vector *)&first->x); 457 n.SubtractVector((const Vector *)&second->x); 458 n.Normalize(); 459 break; 460 }; 461 DoLog(0) && (Log() << Verbose(0) << "Normal vector: "); 462 n.Output(); 463 DoLog(0) && (Log() << Verbose(0) << endl); 464 mol->Mirror((const Vector *)&n); 465 }; 466 467 /** Submenu for removing the atoms from the molecule. 468 * \param *mol molecule with all the atoms 469 */ 470 static void RemoveAtoms(molecule *mol) 471 { 472 atom *first, *second; 473 int axis; 474 double tmp1, tmp2; 475 char choice; // menu choice char 476 477 DoLog(0) && (Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl); 478 DoLog(0) && (Log() << Verbose(0) << " a - state atom for removal by number" << endl); 479 DoLog(0) && (Log() << Verbose(0) << " b - keep only in radius around atom" << endl); 480 DoLog(0) && (Log() << Verbose(0) << " c - remove this with one axis greater value" << endl); 481 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 482 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 483 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 484 cin >> choice; 485 486 switch (choice) { 487 default: 488 case 'a': 489 if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: "))) 490 DoLog(1) && (Log() << Verbose(1) << "Atom removed." << endl); 491 else 492 DoLog(1) && (Log() << Verbose(1) << "Atom not found." << endl); 493 break; 494 case 'b': 495 second = mol->AskAtom("Enter number of atom as reference point: "); 496 DoLog(0) && (Log() << Verbose(0) << "Enter radius: "); 497 cin >> tmp1; 498 first = mol->start; 499 second = first->next; 500 while(second != mol->end) { 501 first = second; 502 second = first->next; 503 if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ... 504 mol->RemoveAtom(first); 505 } 506 break; 507 case 'c': 508 DoLog(0) && (Log() << Verbose(0) << "Which axis is it: "); 509 cin >> axis; 510 DoLog(0) && (Log() << Verbose(0) << "Lower boundary: "); 511 cin >> tmp1; 512 DoLog(0) && (Log() << Verbose(0) << "Upper boundary: "); 513 cin >> tmp2; 514 first = mol->start; 515 second = first->next; 516 while(second != mol->end) { 517 first = second; 518 second = first->next; 519 if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ... 520 //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl; 521 mol->RemoveAtom(first); 522 } 523 } 524 break; 525 }; 526 //mol->Output(); 527 choice = 'r'; 528 }; 529 530 /** Submenu for measuring out the atoms in the molecule. 531 * \param *periode periodentafel 532 * \param *mol molecule with all the atoms 533 */ 534 static void MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration) 535 { 536 atom *first, *second, *third; 537 Vector x,y; 538 double min[256], tmp1, tmp2, tmp3; 539 int Z; 540 char choice; // menu choice char 541 542 DoLog(0) && (Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl); 543 DoLog(0) && (Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl); 544 DoLog(0) && (Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl); 545 DoLog(0) && (Log() << Verbose(0) << " c - calculate bond angle" << endl); 546 DoLog(0) && (Log() << Verbose(0) << " d - calculate principal axis of the system" << endl); 547 DoLog(0) && (Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl); 548 DoLog(0) && (Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl); 549 DoLog(0) && (Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl); 550 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 551 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 552 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 553 cin >> choice; 554 555 switch(choice) { 556 default: 557 DoLog(1) && (Log() << Verbose(1) << "Not a valid choice." << endl); 558 break; 559 case 'a': 560 first = mol->AskAtom("Enter first atom: "); 561 for (int i=MAX_ELEMENTS;i--;) 562 min[i] = 0.; 563 564 second = mol->start; 565 while ((second->next != mol->end)) { 566 second = second->next; // advance 567 Z = second->type->Z; 568 tmp1 = 0.; 569 if (first != second) { 570 x.CopyVector((const Vector *)&first->x); 571 x.SubtractVector((const Vector *)&second->x); 572 tmp1 = x.Norm(); 573 } 574 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1; 575 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl; 576 } 577 for (int i=MAX_ELEMENTS;i--;) 578 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl; 579 break; 580 581 case 'b': 582 first = mol->AskAtom("Enter first atom: "); 583 second = mol->AskAtom("Enter second atom: "); 584 for (int i=NDIM;i--;) 585 min[i] = 0.; 586 x.CopyVector((const Vector *)&first->x); 587 x.SubtractVector((const Vector *)&second->x); 588 tmp1 = x.Norm(); 589 DoLog(1) && (Log() << Verbose(1) << "Distance vector is "); 590 x.Output(); 591 DoLog(0) && (Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl); 592 break; 593 594 case 'c': 595 DoLog(0) && (Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl); 596 first = mol->AskAtom("Enter first atom: "); 597 second = mol->AskAtom("Enter central atom: "); 598 third = mol->AskAtom("Enter last atom: "); 599 tmp1 = tmp2 = tmp3 = 0.; 600 x.CopyVector((const Vector *)&first->x); 601 x.SubtractVector((const Vector *)&second->x); 602 y.CopyVector((const Vector *)&third->x); 603 y.SubtractVector((const Vector *)&second->x); 604 DoLog(0) && (Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "); 605 DoLog(0) && (Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl); 606 break; 607 case 'd': 608 DoLog(0) && (Log() << Verbose(0) << "Evaluating prinicipal axis." << endl); 609 DoLog(0) && (Log() << Verbose(0) << "Shall we rotate? [0/1]: "); 610 cin >> Z; 611 if ((Z >=0) && (Z <=1)) 612 mol->PrincipalAxisSystem((bool)Z); 613 else 614 mol->PrincipalAxisSystem(false); 615 break; 616 case 'e': 617 { 618 DoLog(0) && (Log() << Verbose(0) << "Evaluating volume of the convex envelope."); 619 class Tesselation *TesselStruct = NULL; 620 const LinkedCell *LCList = NULL; 621 LCList = new LinkedCell(mol, 10.); 622 FindConvexBorder(mol, TesselStruct, LCList, NULL); 623 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration); 624 DoLog(0) && (Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl);\ 625 delete(LCList); 626 delete(TesselStruct); 627 } 628 break; 629 case 'f': 630 mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps); 631 break; 632 case 'g': 633 { 634 char filename[255]; 635 DoLog(0) && (Log() << Verbose(0) << "Please enter filename: " << endl); 636 cin >> filename; 637 DoLog(1) && (Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl); 638 ofstream *output = new ofstream(filename, ios::trunc); 639 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps)) 640 DoLog(2) && (Log() << Verbose(2) << "File could not be written." << endl); 641 else 642 DoLog(2) && (Log() << Verbose(2) << "File stored." << endl); 643 output->close(); 644 delete(output); 645 } 646 break; 647 } 648 }; 649 650 /** Submenu for measuring out the atoms in the molecule. 651 * \param *mol molecule with all the atoms 652 * \param *configuration configuration structure for the to be written config files of all fragments 653 */ 654 static void FragmentAtoms(molecule *mol, config *configuration) 655 { 656 int Order1; 657 clock_t start, end; 658 659 DoLog(0) && (Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl); 660 DoLog(0) && (Log() << Verbose(0) << "What's the desired bond order: "); 661 cin >> Order1; 662 if (mol->first->next != mol->last) { // there are bonds 663 start = clock(); 664 mol->FragmentMolecule(Order1, configuration); 665 end = clock(); 666 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 667 } else 668 DoLog(0) && (Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl); 669 }; 670 671 /********************************************** Submenu routine **************************************/ 672 673 /** Submenu for manipulating atoms. 674 * \param *periode periodentafel 675 * \param *molecules list of molecules whose atoms are to be manipulated 676 */ 677 static void ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 678 { 679 atom *first, *second, *third; 680 molecule *mol = NULL; 681 Vector x,y,z,n; // coordinates for absolute point in cell volume 682 double *factor; // unit factor if desired 683 double bond, minBond; 684 char choice; // menu choice char 685 bool valid; 686 687 DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl); 688 DoLog(0) && (Log() << Verbose(0) << "a - add an atom" << endl); 689 DoLog(0) && (Log() << Verbose(0) << "r - remove an atom" << endl); 690 DoLog(0) && (Log() << Verbose(0) << "b - scale a bond between atoms" << endl); 691 DoLog(0) && (Log() << Verbose(0) << "t - turn an atom round another bond" << endl); 692 DoLog(0) && (Log() << Verbose(0) << "u - change an atoms element" << endl); 693 DoLog(0) && (Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl); 694 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 695 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 696 if (molecules->NumberOfActiveMolecules() > 1) 697 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl); 698 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 699 cin >> choice; 700 701 switch (choice) { 702 default: 703 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 704 break; 705 706 case 'a': // add atom 707 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 708 if ((*ListRunner)->ActiveFlag) { 709 mol = *ListRunner; 710 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 711 AddAtoms(periode, mol); 712 } 713 break; 714 715 case 'b': // scale a bond 716 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 717 if ((*ListRunner)->ActiveFlag) { 718 mol = *ListRunner; 719 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 720 DoLog(0) && (Log() << Verbose(0) << "Scaling bond length between two atoms." << endl); 721 first = mol->AskAtom("Enter first (fixed) atom: "); 722 second = mol->AskAtom("Enter second (shifting) atom: "); 723 minBond = 0.; 724 for (int i=NDIM;i--;) 725 minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]); 726 minBond = sqrt(minBond); 727 DoLog(0) && (Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl); 728 DoLog(0) && (Log() << Verbose(0) << "Enter new bond length [a.u.]: "); 729 cin >> bond; 730 for (int i=NDIM;i--;) { 731 second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond); 732 } 733 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: "; 734 //second->Output(second->type->No, 1); 735 } 736 break; 737 738 case 'c': // unit scaling of the metric 739 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 740 if ((*ListRunner)->ActiveFlag) { 741 mol = *ListRunner; 742 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 743 DoLog(0) && (Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl); 744 DoLog(0) && (Log() << Verbose(0) << "Enter three factors: "); 745 factor = new double[NDIM]; 746 cin >> factor[0]; 747 cin >> factor[1]; 748 cin >> factor[2]; 749 valid = true; 750 mol->Scale((const double ** const)&factor); 751 delete[](factor); 752 } 753 break; 754 755 case 'l': // measure distances or angles 756 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 757 if ((*ListRunner)->ActiveFlag) { 758 mol = *ListRunner; 759 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 760 MeasureAtoms(periode, mol, configuration); 761 } 762 break; 763 764 case 'r': // remove atom 765 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 766 if ((*ListRunner)->ActiveFlag) { 767 mol = *ListRunner; 768 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 769 RemoveAtoms(mol); 770 } 771 break; 772 773 case 't': // turn/rotate atom 774 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 775 if ((*ListRunner)->ActiveFlag) { 776 mol = *ListRunner; 777 DoLog(0) && (Log() << Verbose(0) << "Turning atom around another bond - first is atom to turn, second (central) and third specify bond" << endl); 778 first = mol->AskAtom("Enter turning atom: "); 779 second = mol->AskAtom("Enter central atom: "); 780 third = mol->AskAtom("Enter bond atom: "); 781 cout << Verbose(0) << "Enter new angle in degrees: "; 782 double tmp = 0.; 783 cin >> tmp; 784 // calculate old angle 785 x.CopyVector((const Vector *)&first->x); 786 x.SubtractVector((const Vector *)&second->x); 787 y.CopyVector((const Vector *)&third->x); 788 y.SubtractVector((const Vector *)&second->x); 789 double alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.); 790 cout << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 791 cout << Verbose(0) << alpha << " degrees" << endl; 792 // rotate 793 z.MakeNormalVector(&x,&y); 794 x.RotateVector(&z,(alpha-tmp)*M_PI/180.); 795 x.AddVector(&second->x); 796 first->x.CopyVector(&x); 797 // check new angle 798 x.CopyVector((const Vector *)&first->x); 799 x.SubtractVector((const Vector *)&second->x); 800 alpha = (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.); 801 cout << Verbose(0) << "new Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": "; 802 cout << Verbose(0) << alpha << " degrees" << endl; 803 } 804 break; 805 806 case 'u': // change an atom's element 807 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 808 if ((*ListRunner)->ActiveFlag) { 809 int Z; 810 mol = *ListRunner; 811 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 812 first = NULL; 813 do { 814 DoLog(0) && (Log() << Verbose(0) << "Change the element of which atom: "); 815 cin >> Z; 816 } while ((first = mol->FindAtom(Z)) == NULL); 817 DoLog(0) && (Log() << Verbose(0) << "New element by atomic number Z: "); 818 cin >> Z; 819 first->type = periode->FindElement(Z); 820 DoLog(0) && (Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl); 821 } 822 break; 823 } 824 }; 825 826 /** Submenu for manipulating molecules. 827 * \param *periode periodentafel 828 * \param *molecules list of molecule to manipulate 829 */ 830 static void ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration) 831 { 832 atom *first = NULL; 833 Vector x,y,z,n; // coordinates for absolute point in cell volume 834 int j, axis, count, faktor; 835 char choice; // menu choice char 836 molecule *mol = NULL; 837 element **Elements; 838 Vector **vectors; 839 MoleculeLeafClass *Subgraphs = NULL; 840 841 DoLog(0) && (Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl); 842 DoLog(0) && (Log() << Verbose(0) << "c - scale by unit transformation" << endl); 843 DoLog(0) && (Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl); 844 DoLog(0) && (Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl); 845 DoLog(0) && (Log() << Verbose(0) << "g - center atoms in box" << endl); 846 DoLog(0) && (Log() << Verbose(0) << "i - realign molecule" << endl); 847 DoLog(0) && (Log() << Verbose(0) << "m - mirror all molecules" << endl); 848 DoLog(0) && (Log() << Verbose(0) << "o - create connection matrix" << endl); 849 DoLog(0) && (Log() << Verbose(0) << "t - translate molecule by vector" << endl); 850 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 851 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 852 if (molecules->NumberOfActiveMolecules() > 1) 853 DoeLog(2) && (eLog()<< Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl); 854 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 855 cin >> choice; 856 857 switch (choice) { 858 default: 859 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 860 break; 861 862 case 'd': // duplicate the periodic cell along a given axis, given times 863 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 864 if ((*ListRunner)->ActiveFlag) { 865 mol = *ListRunner; 866 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 867 DoLog(0) && (Log() << Verbose(0) << "State the axis [(+-)123]: "); 868 cin >> axis; 869 DoLog(0) && (Log() << Verbose(0) << "State the factor: "); 870 cin >> faktor; 871 872 mol->CountAtoms(); // recount atoms 873 if (mol->getAtomCount() != 0) { // if there is more than none 874 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand 875 Elements = new element *[count]; 876 vectors = new Vector *[count]; 877 j = 0; 878 first = mol->start; 879 while (first->next != mol->end) { // make a list of all atoms with coordinates and element 880 first = first->next; 881 Elements[j] = first->type; 882 vectors[j] = &first->x; 883 j++; 884 } 885 if (count != j) 886 DoeLog(1) && (eLog()<< Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl); 887 x.Zero(); 888 y.Zero(); 889 y.x[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude 890 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times 891 x.AddVector(&y); // per factor one cell width further 892 for (int k=count;k--;) { // go through every atom of the original cell 893 first = new atom(); // create a new body 894 first->x.CopyVector(vectors[k]); // use coordinate of original atom 895 first->x.AddVector(&x); // translate the coordinates 896 first->type = Elements[k]; // insert original element 897 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...) 898 } 899 } 900 if (mol->first->next != mol->last) // if connect matrix is present already, redo it 901 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 902 // free memory 903 delete[](Elements); 904 delete[](vectors); 905 // correct cell size 906 if (axis < 0) { // if sign was negative, we have to translate everything 907 x.Zero(); 908 x.AddVector(&y); 909 x.Scale(-(faktor-1)); 910 mol->Translate(&x); 911 } 912 World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor; 913 } 914 } 915 break; 916 917 case 'f': 918 FragmentAtoms(mol, configuration); 919 break; 920 921 case 'g': // center the atoms 922 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 923 if ((*ListRunner)->ActiveFlag) { 924 mol = *ListRunner; 925 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 926 CenterAtoms(mol); 927 } 928 break; 929 930 case 'i': // align all atoms 931 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 932 if ((*ListRunner)->ActiveFlag) { 933 mol = *ListRunner; 934 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 935 AlignAtoms(periode, mol); 936 } 937 break; 938 939 case 'm': // mirror atoms along a given axis 940 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 941 if ((*ListRunner)->ActiveFlag) { 942 mol = *ListRunner; 943 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 944 MirrorAtoms(mol); 945 } 946 break; 947 948 case 'o': // create the connection matrix 949 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 950 if ((*ListRunner)->ActiveFlag) { 951 mol = *ListRunner; 952 double bonddistance; 953 clock_t start,end; 954 DoLog(0) && (Log() << Verbose(0) << "What's the maximum bond distance: "); 955 cin >> bonddistance; 956 start = clock(); 957 mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 958 end = clock(); 959 DoLog(0) && (Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl); 960 } 961 break; 962 963 case 't': // translate all atoms 964 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 965 if ((*ListRunner)->ActiveFlag) { 966 mol = *ListRunner; 967 DoLog(0) && (Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl); 968 DoLog(0) && (Log() << Verbose(0) << "Enter translation vector." << endl); 969 x.AskPosition(World::getInstance().getDomain(),0); 970 mol->Center.AddVector((const Vector *)&x); 971 } 972 break; 973 } 974 // Free all 975 if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed 976 while (Subgraphs->next != NULL) { 977 Subgraphs = Subgraphs->next; 978 delete(Subgraphs->previous); 979 } 980 delete(Subgraphs); 981 } 982 }; 983 984 985 /** Submenu for creating new molecules. 986 * \param *periode periodentafel 987 * \param *molecules list of molecules to add to 988 */ 989 static void EditMolecules(periodentafel *periode, MoleculeListClass *molecules) 990 { 991 char choice; // menu choice char 992 Vector center; 993 int nr, count; 994 molecule *mol = NULL; 995 996 DoLog(0) && (Log() << Verbose(0) << "==========EDIT MOLECULES=====================" << endl); 997 DoLog(0) && (Log() << Verbose(0) << "c - create new molecule" << endl); 998 DoLog(0) && (Log() << Verbose(0) << "l - load molecule from xyz file" << endl); 999 DoLog(0) && (Log() << Verbose(0) << "n - change molecule's name" << endl); 1000 DoLog(0) && (Log() << Verbose(0) << "N - give molecules filename" << endl); 1001 DoLog(0) && (Log() << Verbose(0) << "p - parse atoms in xyz file into molecule" << endl); 1002 DoLog(0) && (Log() << Verbose(0) << "r - remove a molecule" << endl); 1003 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 1004 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 1005 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 1006 cin >> choice; 1007 1008 switch (choice) { 1009 default: 1010 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 1011 break; 1012 case 'c': 1013 mol = World::getInstance().createMolecule(); 1014 molecules->insert(mol); 1015 break; 1016 1017 case 'l': // load from XYZ file 1018 { 1019 char filename[MAXSTRINGSIZE]; 1020 DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl); 1021 mol = World::getInstance().createMolecule(); 1022 do { 1023 DoLog(0) && (Log() << Verbose(0) << "Enter file name: "); 1024 cin >> filename; 1025 } while (!mol->AddXYZFile(filename)); 1026 mol->SetNameFromFilename(filename); 1027 // center at set box dimensions 1028 mol->CenterEdge(¢er); 1029 double * const cell_size = World::getInstance().getDomain(); 1030 cell_size[0] = center.x[0]; 1031 cell_size[1] = 0; 1032 cell_size[2] = center.x[1]; 1033 cell_size[3] = 0; 1034 cell_size[4] = 0; 1035 cell_size[5] = center.x[2]; 1036 molecules->insert(mol); 1037 } 1038 break; 1039 1040 case 'n': 1041 { 1042 char filename[MAXSTRINGSIZE]; 1043 do { 1044 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 1045 cin >> nr; 1046 mol = molecules->ReturnIndex(nr); 1047 } while (mol == NULL); 1048 DoLog(0) && (Log() << Verbose(0) << "Enter name: "); 1049 cin >> filename; 1050 strcpy(mol->name, filename); 1051 } 1052 break; 1053 1054 case 'N': 1055 { 1056 char filename[MAXSTRINGSIZE]; 1057 do { 1058 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 1059 cin >> nr; 1060 mol = molecules->ReturnIndex(nr); 1061 } while (mol == NULL); 1062 DoLog(0) && (Log() << Verbose(0) << "Enter name: "); 1063 cin >> filename; 1064 mol->SetNameFromFilename(filename); 1065 } 1066 break; 1067 1068 case 'p': // parse XYZ file 1069 { 1070 char filename[MAXSTRINGSIZE]; 1071 mol = NULL; 1072 do { 1073 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 1074 cin >> nr; 1075 mol = molecules->ReturnIndex(nr); 1076 } while (mol == NULL); 1077 DoLog(0) && (Log() << Verbose(0) << "Format should be XYZ with: ShorthandOfElement\tX\tY\tZ" << endl); 1078 do { 1079 DoLog(0) && (Log() << Verbose(0) << "Enter file name: "); 1080 cin >> filename; 1081 } while (!mol->AddXYZFile(filename)); 1082 mol->SetNameFromFilename(filename); 1083 } 1084 break; 1085 1086 case 'r': 1087 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule: "); 1088 cin >> nr; 1089 count = 1; 1090 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1091 if (nr == (*ListRunner)->IndexNr) { 1092 mol = *ListRunner; 1093 molecules->ListOfMolecules.erase(ListRunner); 1094 delete(mol); 1095 break; 1096 } 1097 break; 1098 } 1099 }; 1100 1101 1102 /** Submenu for merging molecules. 1103 * \param *periode periodentafel 1104 * \param *molecules list of molecules to add to 1105 */ 1106 static void MergeMolecules(periodentafel *periode, MoleculeListClass *molecules) 1107 { 1108 char choice; // menu choice char 1109 1110 DoLog(0) && (Log() << Verbose(0) << "===========MERGE MOLECULES=====================" << endl); 1111 DoLog(0) && (Log() << Verbose(0) << "a - simple add of one molecule to another" << endl); 1112 DoLog(0) && (Log() << Verbose(0) << "b - count the number of bonds of two elements" << endl); 1113 DoLog(0) && (Log() << Verbose(0) << "B - count the number of bonds of three elements " << endl); 1114 DoLog(0) && (Log() << Verbose(0) << "e - embedding merge of two molecules" << endl); 1115 DoLog(0) && (Log() << Verbose(0) << "h - count the number of hydrogen bonds" << endl); 1116 DoLog(0) && (Log() << Verbose(0) << "b - count the number of hydrogen bonds" << endl); 1117 DoLog(0) && (Log() << Verbose(0) << "m - multi-merge of all molecules" << endl); 1118 DoLog(0) && (Log() << Verbose(0) << "s - scatter merge of two molecules" << endl); 1119 DoLog(0) && (Log() << Verbose(0) << "t - simple merge of two molecules" << endl); 1120 DoLog(0) && (Log() << Verbose(0) << "all else - go back" << endl); 1121 DoLog(0) && (Log() << Verbose(0) << "===============================================" << endl); 1122 DoLog(0) && (Log() << Verbose(0) << "INPUT: "); 1123 cin >> choice; 1124 1125 switch (choice) { 1126 default: 1127 DoLog(0) && (Log() << Verbose(0) << "Not a valid choice." << endl); 1128 break; 1129 1130 case 'a': 1131 { 1132 int src, dest; 1133 molecule *srcmol = NULL, *destmol = NULL; 1134 { 1135 do { 1136 DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: "); 1137 cin >> dest; 1138 destmol = molecules->ReturnIndex(dest); 1139 } while ((destmol == NULL) && (dest != -1)); 1140 do { 1141 DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to add from: "); 1142 cin >> src; 1143 srcmol = molecules->ReturnIndex(src); 1144 } while ((srcmol == NULL) && (src != -1)); 1145 if ((src != -1) && (dest != -1)) 1146 molecules->SimpleAdd(srcmol, destmol); 1147 } 1148 } 1149 break; 1150 1151 case 'b': 1152 { 1153 const int nr = 2; 1154 char *names[nr] = {"first", "second"}; 1155 int Z[nr]; 1156 element *elements[nr]; 1157 for (int i=0;i<nr;i++) { 1158 Z[i] = 0; 1159 do { 1160 cout << "Enter " << names[i] << " element: "; 1161 cin >> Z[i]; 1162 } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS)); 1163 elements[i] = periode->FindElement(Z[i]); 1164 } 1165 const int count = CountBondsOfTwo(molecules, elements[0], elements[1]); 1166 cout << endl << "There are " << count << " "; 1167 for (int i=0;i<nr;i++) { 1168 if (i==0) 1169 cout << elements[i]->symbol; 1170 else 1171 cout << "-" << elements[i]->symbol; 1172 } 1173 cout << " bonds." << endl; 1174 } 1175 break; 1176 1177 case 'B': 1178 { 1179 const int nr = 3; 1180 char *names[nr] = {"first", "second", "third"}; 1181 int Z[nr]; 1182 element *elements[nr]; 1183 for (int i=0;i<nr;i++) { 1184 Z[i] = 0; 1185 do { 1186 cout << "Enter " << names[i] << " element: "; 1187 cin >> Z[i]; 1188 } while ((Z[i] <= 0) && (Z[i] > MAX_ELEMENTS)); 1189 elements[i] = periode->FindElement(Z[i]); 1190 } 1191 const int count = CountBondsOfThree(molecules, elements[0], elements[1], elements[2]); 1192 cout << endl << "There are " << count << " "; 1193 for (int i=0;i<nr;i++) { 1194 if (i==0) 1195 cout << elements[i]->symbol; 1196 else 1197 cout << "-" << elements[i]->symbol; 1198 } 1199 cout << " bonds." << endl; 1200 } 1201 break; 1202 1203 case 'e': 1204 { 1205 int src, dest; 1206 molecule *srcmol = NULL, *destmol = NULL; 1207 do { 1208 DoLog(0) && (Log() << Verbose(0) << "Enter index of matrix molecule (the variable one): "); 1209 cin >> src; 1210 srcmol = molecules->ReturnIndex(src); 1211 } while ((srcmol == NULL) && (src != -1)); 1212 do { 1213 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into (the fixed one): "); 1214 cin >> dest; 1215 destmol = molecules->ReturnIndex(dest); 1216 } while ((destmol == NULL) && (dest != -1)); 1217 if ((src != -1) && (dest != -1)) 1218 molecules->EmbedMerge(destmol, srcmol); 1219 } 1220 break; 1221 1222 case 'h': 1223 { 1224 int Z; 1225 cout << "Please enter interface element: "; 1226 cin >> Z; 1227 element * const InterfaceElement = periode->FindElement(Z); 1228 cout << endl << "There are " << CountHydrogenBridgeBonds(molecules, InterfaceElement) << " hydrogen bridges with connections to " << (InterfaceElement != 0 ? InterfaceElement->name : "None") << "." << endl; 1229 } 1230 break; 1231 1232 case 'm': 1233 { 1234 int nr; 1235 molecule *mol = NULL; 1236 do { 1237 DoLog(0) && (Log() << Verbose(0) << "Enter index of molecule to merge into: "); 1238 cin >> nr; 1239 mol = molecules->ReturnIndex(nr); 1240 } while ((mol == NULL) && (nr != -1)); 1241 if (nr != -1) { 1242 int N = molecules->ListOfMolecules.size()-1; 1243 int *src = new int(N); 1244 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1245 if ((*ListRunner)->IndexNr != nr) 1246 src[N++] = (*ListRunner)->IndexNr; 1247 molecules->SimpleMultiMerge(mol, src, N); 1248 delete[](src); 1249 } 1250 } 1251 break; 1252 1253 case 's': 1254 DoLog(0) && (Log() << Verbose(0) << "Not implemented yet." << endl); 1255 break; 1256 1257 case 't': 1258 { 1259 int src, dest; 1260 molecule *srcmol = NULL, *destmol = NULL; 1261 { 1262 do { 1263 DoLog(0) && (Log() << Verbose(0) << "Enter index of destination molecule: "); 1264 cin >> dest; 1265 destmol = molecules->ReturnIndex(dest); 1266 } while ((destmol == NULL) && (dest != -1)); 1267 do { 1268 DoLog(0) && (Log() << Verbose(0) << "Enter index of source molecule to merge into: "); 1269 cin >> src; 1270 srcmol = molecules->ReturnIndex(src); 1271 } while ((srcmol == NULL) && (src != -1)); 1272 if ((src != -1) && (dest != -1)) 1273 molecules->SimpleMerge(srcmol, destmol); 1274 } 1275 } 1276 break; 1277 } 1278 }; 1279 1280 /********************************************** Test routine **************************************/ 1281 1282 /** Is called always as option 'T' in the menu. 1283 * \param *molecules list of molecules 1284 */ 1285 static void testroutine(MoleculeListClass *molecules) 1286 { 1287 // the current test routine checks the functionality of the KeySet&Graph concept: 1288 // We want to have a multiindex (the KeySet) describing a unique subgraph 1289 int i, comp, counter=0; 1290 1291 // create a clone 1292 molecule *mol = NULL; 1293 if (molecules->ListOfMolecules.size() != 0) // clone 1294 mol = (molecules->ListOfMolecules.front())->CopyMolecule(); 1295 else { 1296 DoeLog(0) && (eLog()<< Verbose(0) << "I don't have anything to test on ... "); 1297 performCriticalExit(); 1298 return; 1299 } 1300 atom *Walker = mol->start; 1301 1302 // generate some KeySets 1303 DoLog(0) && (Log() << Verbose(0) << "Generating KeySets." << endl); 1304 KeySet TestSets[mol->getAtomCount()+1]; 1305 i=1; 1306 while (Walker->next != mol->end) { 1307 Walker = Walker->next; 1308 for (int j=0;j<i;j++) { 1309 TestSets[j].insert(Walker->nr); 1310 } 1311 i++; 1312 } 1313 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl); 1314 KeySetTestPair test; 1315 test = TestSets[mol->getAtomCount()-1].insert(Walker->nr); 1316 if (test.second) { 1317 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); 1318 } else { 1319 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl); 1320 } 1321 TestSets[mol->getAtomCount()].insert(mol->end->previous->nr); 1322 TestSets[mol->getAtomCount()].insert(mol->end->previous->previous->previous->nr); 1323 1324 // constructing Graph structure 1325 DoLog(0) && (Log() << Verbose(0) << "Generating Subgraph class." << endl); 1326 Graph Subgraphs; 1327 1328 // insert KeySets into Subgraphs 1329 DoLog(0) && (Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl); 1330 for (int j=0;j<mol->getAtomCount();j++) { 1331 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1332 } 1333 DoLog(0) && (Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl); 1334 GraphTestPair test2; 1335 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.))); 1336 if (test2.second) { 1337 DoLog(1) && (Log() << Verbose(1) << "Insertion worked?!" << endl); 1338 } else { 1339 DoLog(1) && (Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl); 1340 } 1341 1342 // show graphs 1343 DoLog(0) && (Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl); 1344 Graph::iterator A = Subgraphs.begin(); 1345 while (A != Subgraphs.end()) { 1346 DoLog(0) && (Log() << Verbose(0) << (*A).second.first << ": "); 1347 KeySet::iterator key = (*A).first.begin(); 1348 comp = -1; 1349 while (key != (*A).first.end()) { 1350 if ((*key) > comp) 1351 DoLog(0) && (Log() << Verbose(0) << (*key) << " "); 1352 else 1353 DoLog(0) && (Log() << Verbose(0) << (*key) << "! "); 1354 comp = (*key); 1355 key++; 1356 } 1357 DoLog(0) && (Log() << Verbose(0) << endl); 1358 A++; 1359 } 1360 delete(mol); 1361 }; 1362 1363 1364 /** Tries given filename or standard on saving the config file. 1365 * \param *ConfigFileName name of file 1366 * \param *configuration pointer to configuration structure with all the values 1367 * \param *periode pointer to periodentafel structure with all the elements 1368 * \param *molecules list of molecules structure with all the atoms and coordinates 1369 */ 1370 static void SaveConfig(char *ConfigFileName, config *configuration, periodentafel *periode, MoleculeListClass *molecules) 1371 { 1372 char filename[MAXSTRINGSIZE]; 1373 ofstream output; 1374 molecule *mol = World::getInstance().createMolecule(); 1375 mol->SetNameFromFilename(ConfigFileName); 1376 1377 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1378 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl); 1379 } 1380 1381 1382 // first save as PDB data 1383 if (ConfigFileName != NULL) 1384 strcpy(filename, ConfigFileName); 1385 if (output == NULL) 1386 strcpy(filename,"main_pcp_linux"); 1387 DoLog(0) && (Log() << Verbose(0) << "Saving as pdb input "); 1388 if (configuration->SavePDB(filename, molecules)) 1389 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 1390 else 1391 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1392 1393 // then save as tremolo data file 1394 if (ConfigFileName != NULL) 1395 strcpy(filename, ConfigFileName); 1396 if (output == NULL) 1397 strcpy(filename,"main_pcp_linux"); 1398 DoLog(0) && (Log() << Verbose(0) << "Saving as tremolo data input "); 1399 if (configuration->SaveTREMOLO(filename, molecules)) 1400 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 1401 else 1402 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1403 1404 // translate each to its center and merge all molecules in MoleculeListClass into this molecule 1405 int N = molecules->ListOfMolecules.size(); 1406 int *src = new int[N]; 1407 N=0; 1408 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1409 src[N++] = (*ListRunner)->IndexNr; 1410 (*ListRunner)->Translate(&(*ListRunner)->Center); 1411 } 1412 molecules->SimpleMultiAdd(mol, src, N); 1413 delete[](src); 1414 1415 // ... and translate back 1416 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) { 1417 (*ListRunner)->Center.Scale(-1.); 1418 (*ListRunner)->Translate(&(*ListRunner)->Center); 1419 (*ListRunner)->Center.Scale(-1.); 1420 } 1421 1422 DoLog(0) && (Log() << Verbose(0) << "Storing configuration ... " << endl); 1423 // get correct valence orbitals 1424 mol->CalculateOrbitals(*configuration); 1425 configuration->InitMaxMinStopStep = configuration->MaxMinStopStep = configuration->MaxPsiDouble; 1426 if (ConfigFileName != NULL) { // test the file name 1427 strcpy(filename, ConfigFileName); 1428 output.open(filename, ios::trunc); 1429 } else if (strlen(configuration->configname) != 0) { 1430 strcpy(filename, configuration->configname); 1431 output.open(configuration->configname, ios::trunc); 1432 } else { 1433 strcpy(filename, DEFAULTCONFIG); 1434 output.open(DEFAULTCONFIG, ios::trunc); 1435 } 1436 output.close(); 1437 output.clear(); 1438 DoLog(0) && (Log() << Verbose(0) << "Saving of config file "); 1439 if (configuration->Save(filename, periode, mol)) 1440 DoLog(0) && (Log() << Verbose(0) << "successful." << endl); 1441 else 1442 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1443 1444 // and save to xyz file 1445 if (ConfigFileName != NULL) { 1446 strcpy(filename, ConfigFileName); 1447 strcat(filename, ".xyz"); 1448 output.open(filename, ios::trunc); 1449 } 1450 if (output == NULL) { 1451 strcpy(filename,"main_pcp_linux"); 1452 strcat(filename, ".xyz"); 1453 output.open(filename, ios::trunc); 1454 } 1455 DoLog(0) && (Log() << Verbose(0) << "Saving of XYZ file "); 1456 if (mol->MDSteps <= 1) { 1457 if (mol->OutputXYZ(&output)) 1458 DoLog(0) && (Log() << Verbose(0) << "successful." << endl); 1459 else 1460 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1461 } else { 1462 if (mol->OutputTrajectoriesXYZ(&output)) 1463 DoLog(0) && (Log() << Verbose(0) << "successful." << endl); 1464 else 1465 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1466 } 1467 output.close(); 1468 output.clear(); 1469 1470 // and save as MPQC configuration 1471 if (ConfigFileName != NULL) 1472 strcpy(filename, ConfigFileName); 1473 if (output == NULL) 1474 strcpy(filename,"main_pcp_linux"); 1475 DoLog(0) && (Log() << Verbose(0) << "Saving as mpqc input "); 1476 if (configuration->SaveMPQC(filename, mol)) 1477 DoLog(0) && (Log() << Verbose(0) << "done." << endl); 1478 else 1479 DoLog(0) && (Log() << Verbose(0) << "failed." << endl); 1480 1481 if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) { 1482 DoeLog(2) && (eLog()<< Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl); 1483 } 1484 1485 World::getInstance().destroyMolecule(mol); 1486 }; 1487 1488 #endif 1489 1490 /** Parses the command line options. 1491 * Note that this function is from now on transitional. All commands that are not passed 1492 * here are handled by CommandLineParser and the actions of CommandLineUIFactory. 1493 * \param argc argument count 1494 * \param **argv arguments array 1495 * \param *molecules list of molecules structure 1496 * \param *periode elements structure 1497 * \param configuration config file structure 1498 * \param *ConfigFileName pointer to config file name in **argv 1499 * \param *PathToDatabases pointer to db's path in **argv 1500 * \param &ArgcList list of arguments that we do not parse here 1501 * \return exit code (0 - successful, all else - something's wrong) 1502 */ 1503 static int ParseCommandLineOptions(int argc, char **argv, MoleculeListClass *&molecules, periodentafel *&periode, 1504 config& configuration, char **ConfigFileName, set<int> &ArgcList) 1505 { 1506 Vector x,y,z,n; // coordinates for absolute point in cell volume 1507 ifstream test; 1508 ofstream output; 1509 string line; 1510 bool SaveFlag = false; 1511 int ExitFlag = 0; 1512 int j; 1513 double volume = 0.; 1514 enum ConfigStatus configPresent = absent; 1515 int argptr; 1516 molecule *mol = NULL; 1517 string BondGraphFileName("\n"); 1518 1519 if (argc > 1) { // config file specified as option 1520 // 1. : Parse options that just set variables or print help 1521 argptr = 1; 1522 do { 1523 if (argv[argptr][0] == '-') { 1524 DoLog(0) && (Log() << Verbose(0) << "Recognized command line argument: " << argv[argptr][1] << ".\n"); 1525 argptr++; 1526 switch(argv[argptr-1][1]) { 1527 case 'h': 1528 case 'H': 1529 case '?': 1530 ArgcList.insert(argptr-1); 1531 return(1); 1532 break; 1533 case 'v': 1534 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1535 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying verbosity: -v <level>" << endl); 1536 performCriticalExit(); 1537 } else { 1538 setVerbosity(atoi(argv[argptr])); 1539 ArgcList.insert(argptr-1); 1540 ArgcList.insert(argptr); 1541 argptr++; 1542 } 1543 break; 1544 case 'V': 1545 ArgcList.insert(argptr-1); 1546 return(1); 1547 break; 1548 case 'B': 1549 if (ExitFlag == 0) ExitFlag = 1; 1550 if ((argptr+5 >= argc)) { 1551 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for setting Box: -B <xx> <<xy> <<xz> <yy> <yz> <zz>" << endl); 1552 performCriticalExit(); 1553 } else { 1554 ArgcList.insert(argptr-1); 1555 ArgcList.insert(argptr); 1556 ArgcList.insert(argptr+1); 1557 ArgcList.insert(argptr+2); 1558 ArgcList.insert(argptr+3); 1559 ArgcList.insert(argptr+4); 1560 ArgcList.insert(argptr+5); 1561 argptr+=6; 1562 } 1563 break; 1564 case 'e': 1565 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1566 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying element db: -e <db file>" << endl); 1567 performCriticalExit(); 1568 } else { 1569 ArgcList.insert(argptr-1); 1570 ArgcList.insert(argptr); 1571 argptr+=1; 1572 } 1573 break; 1574 case 'g': 1575 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1576 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for specifying bond length table: -g <table file>" << endl); 1577 performCriticalExit(); 1578 } else { 1579 ArgcList.insert(argptr-1); 1580 ArgcList.insert(argptr); 1581 argptr+=1; 1582 } 1583 break; 1584 case 'M': 1585 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1586 ExitFlag = 255; 1587 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting MPQC basis: -M <basis name>" << endl); 1588 performCriticalExit(); 1589 } else { 1590 ArgcList.insert(argptr-1); 1591 ArgcList.insert(argptr); 1592 argptr+=1; 1593 } 1594 break; 1595 case 'n': 1596 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1597 ExitFlag = 255; 1598 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting fast-parsing: -n <0/1>" << endl); 1599 performCriticalExit(); 1600 } else { 1601 ArgcList.insert(argptr-1); 1602 ArgcList.insert(argptr); 1603 argptr+=1; 1604 } 1605 break; 1606 case 'X': 1607 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1608 ExitFlag = 255; 1609 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for setting default molecule name: -X <name>" << endl); 1610 performCriticalExit(); 1611 } else { 1612 ArgcList.insert(argptr-1); 1613 ArgcList.insert(argptr); 1614 argptr+=1; 1615 } 1616 break; 1617 default: // no match? Step on 1618 argptr++; 1619 break; 1620 } 1621 } else 1622 argptr++; 1623 } while (argptr < argc); 1624 1625 // 3b. Find config file name and parse if possible, also BondGraphFileName 1626 if (argv[1][0] != '-') { 1627 // simply create a new molecule, wherein the config file is loaded and the manipulation takes place 1628 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl); 1629 test.open(argv[1], ios::in); 1630 if (test == NULL) { 1631 //return (1); 1632 output.open(argv[1], ios::out); 1633 if (output == NULL) { 1634 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << argv[1] << " not found." << endl); 1635 configPresent = absent; 1636 } else { 1637 DoLog(0) && (Log() << Verbose(0) << "Empty configuration file." << endl); 1638 strcpy(*ConfigFileName, argv[1]); 1639 configPresent = empty; 1640 output.close(); 1641 } 1642 } else { 1643 test.close(); 1644 strcpy(*ConfigFileName, argv[1]); 1645 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... "); 1646 switch (configuration.TestSyntax(*ConfigFileName, periode)) { 1647 case 1: 1648 DoLog(0) && (Log() << Verbose(0) << "new syntax." << endl); 1649 configuration.Load(*ConfigFileName, BondGraphFileName, periode, molecules); 1650 configPresent = present; 1651 break; 1652 case 0: 1653 DoLog(0) && (Log() << Verbose(0) << "old syntax." << endl); 1654 configuration.LoadOld(*ConfigFileName, BondGraphFileName, periode, molecules); 1655 configPresent = present; 1656 break; 1657 default: 1658 DoLog(0) && (Log() << Verbose(0) << "Unknown syntax or empty, yet present file." << endl); 1659 configPresent = empty; 1660 } 1661 } 1662 } else 1663 configPresent = absent; 1664 // set mol to first active molecule 1665 if (molecules->ListOfMolecules.size() != 0) { 1666 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++) 1667 if ((*ListRunner)->ActiveFlag) { 1668 mol = *ListRunner; 1669 break; 1670 } 1671 } 1672 if (mol == NULL) { 1673 mol = World::getInstance().createMolecule(); 1674 mol->ActiveFlag = true; 1675 if (*ConfigFileName != NULL) 1676 mol->SetNameFromFilename(*ConfigFileName); 1677 molecules->insert(mol); 1678 } 1679 1680 // 4. parse again through options, now for those depending on elements db and config presence 1681 argptr = 1; 1682 do { 1683 DoLog(0) && (Log() << Verbose(0) << "Current Command line argument: " << argv[argptr] << "." << endl); 1684 if (argv[argptr][0] == '-') { 1685 argptr++; 1686 if ((configPresent == present) || (configPresent == empty)) { 1687 switch(argv[argptr-1][1]) { 1688 case 'p': 1689 if (ExitFlag == 0) ExitFlag = 1; 1690 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1691 ExitFlag = 255; 1692 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for parsing: -p <xyz file>" << endl); 1693 performCriticalExit(); 1694 } else { 1695 SaveFlag = true; 1696 DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl); 1697 if (!mol->AddXYZFile(argv[argptr])) 1698 DoLog(2) && (Log() << Verbose(2) << "File not found." << endl); 1699 else { 1700 DoLog(2) && (Log() << Verbose(2) << "File found and parsed." << endl); 1701 configPresent = present; 1702 } 1703 } 1704 break; 1705 case 'a': 1706 if (ExitFlag == 0) ExitFlag = 1; 1707 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) { 1708 ExitFlag = 255; 1709 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough arguments for adding atom: -a <Z> --position <x> <y> <z>" << endl); 1710 performCriticalExit(); 1711 } else { 1712 ArgcList.insert(argptr-1); 1713 ArgcList.insert(argptr); 1714 ArgcList.insert(argptr+1); 1715 ArgcList.insert(argptr+2); 1716 ArgcList.insert(argptr+3); 1717 ArgcList.insert(argptr+4); 1718 argptr+=5; 1719 } 1720 break; 1721 default: // no match? Don't step on (this is done in next switch's default) 1722 break; 1723 } 1724 } 1725 if (configPresent == present) { 1726 switch(argv[argptr-1][1]) { 1727 case 'D': 1728 if (ExitFlag == 0) ExitFlag = 1; 1729 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1730 ExitFlag = 255; 1731 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for depth-first-search analysis: -D <max. bond distance>" << endl); 1732 performCriticalExit(); 1733 } else { 1734 ArgcList.insert(argptr-1); 1735 ArgcList.insert(argptr); 1736 argptr+=1; 1737 } 1738 break; 1739 case 'I': 1740 DoLog(1) && (Log() << Verbose(1) << "Dissecting molecular system into a set of disconnected subgraphs ... " << endl); 1741 ArgcList.insert(argptr-1); 1742 argptr+=0; 1743 break; 1744 case 'C': 1745 { 1746 if (ExitFlag == 0) ExitFlag = 1; 1747 if ((argptr+11 >= argc)) { 1748 ExitFlag = 255; 1749 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for pair correlation analysis: -C[p] <type: E/P/S> [more params] <output> <bin output> <BinStart> <BinEnd>" << endl); 1750 performCriticalExit(); 1751 } else { 1752 switch(argv[argptr][0]) { 1753 case 'E': 1754 ArgcList.insert(argptr-1); 1755 ArgcList.insert(argptr); 1756 ArgcList.insert(argptr+1); 1757 ArgcList.insert(argptr+2); 1758 ArgcList.insert(argptr+3); 1759 ArgcList.insert(argptr+4); 1760 ArgcList.insert(argptr+5); 1761 ArgcList.insert(argptr+6); 1762 ArgcList.insert(argptr+7); 1763 ArgcList.insert(argptr+8); 1764 ArgcList.insert(argptr+9); 1765 ArgcList.insert(argptr+10); 1766 ArgcList.insert(argptr+11); 1767 argptr+=12; 1768 break; 1769 1770 case 'P': 1771 ArgcList.insert(argptr-1); 1772 ArgcList.insert(argptr); 1773 ArgcList.insert(argptr+1); 1774 ArgcList.insert(argptr+2); 1775 ArgcList.insert(argptr+3); 1776 ArgcList.insert(argptr+4); 1777 ArgcList.insert(argptr+5); 1778 ArgcList.insert(argptr+6); 1779 ArgcList.insert(argptr+7); 1780 ArgcList.insert(argptr+8); 1781 ArgcList.insert(argptr+9); 1782 ArgcList.insert(argptr+10); 1783 ArgcList.insert(argptr+11); 1784 ArgcList.insert(argptr+12); 1785 ArgcList.insert(argptr+13); 1786 ArgcList.insert(argptr+14); 1787 argptr+=15; 1788 break; 1789 1790 case 'S': 1791 ArgcList.insert(argptr-1); 1792 ArgcList.insert(argptr); 1793 ArgcList.insert(argptr+1); 1794 ArgcList.insert(argptr+2); 1795 ArgcList.insert(argptr+3); 1796 ArgcList.insert(argptr+4); 1797 ArgcList.insert(argptr+5); 1798 ArgcList.insert(argptr+6); 1799 ArgcList.insert(argptr+7); 1800 ArgcList.insert(argptr+8); 1801 ArgcList.insert(argptr+9); 1802 ArgcList.insert(argptr+10); 1803 ArgcList.insert(argptr+11); 1804 ArgcList.insert(argptr+12); 1805 ArgcList.insert(argptr+13); 1806 ArgcList.insert(argptr+14); 1807 argptr+=15; 1808 break; 1809 1810 default: 1811 ExitFlag = 255; 1812 DoeLog(0) && (eLog()<< Verbose(0) << "Invalid type given for pair correlation analysis: -C <type: E/P/S> [more params] <output> <bin output>" << endl); 1813 performCriticalExit(); 1814 break; 1815 } 1816 } 1817 break; 1818 } 1819 case 'E': 1820 if (ExitFlag == 0) ExitFlag = 1; 1821 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr]))) { 1822 ExitFlag = 255; 1823 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for changing element: -E <atom nr.> --element <Z>" << endl); 1824 performCriticalExit(); 1825 } else { 1826 ArgcList.insert(argptr-1); 1827 ArgcList.insert(argptr); 1828 ArgcList.insert(argptr+1); 1829 ArgcList.insert(argptr+2); 1830 argptr+=3; 1831 } 1832 break; 1833 case 'F': 1834 if (ExitFlag == 0) ExitFlag = 1; 1835 if ((argptr+12 >= argc) || (argv[argptr][0] == '-')) { 1836 ExitFlag = 255; 1837 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for filling with molecule: -F <filler xyz file> --MaxDistance <distance or -1> --distances <x> <y> <z> --lengths <surface> <randatm> <randmol> --DoRotate <0/1>" << endl); 1838 performCriticalExit(); 1839 } else { 1840 ArgcList.insert(argptr-1); 1841 ArgcList.insert(argptr); 1842 ArgcList.insert(argptr+1); 1843 ArgcList.insert(argptr+2); 1844 ArgcList.insert(argptr+3); 1845 ArgcList.insert(argptr+4); 1846 ArgcList.insert(argptr+5); 1847 ArgcList.insert(argptr+6); 1848 ArgcList.insert(argptr+7); 1849 ArgcList.insert(argptr+8); 1850 ArgcList.insert(argptr+9); 1851 ArgcList.insert(argptr+10); 1852 ArgcList.insert(argptr+11); 1853 ArgcList.insert(argptr+12); 1854 argptr+=13; 1855 } 1856 break; 1857 case 'A': 1858 if (ExitFlag == 0) ExitFlag = 1; 1859 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1860 ExitFlag =255; 1861 DoeLog(0) && (eLog()<< Verbose(0) << "Missing source file for bonds in molecule: -A <bond sourcefile> --molecule-by-id <molecule_id>" << endl); 1862 performCriticalExit(); 1863 } else { 1864 ArgcList.insert(argptr-1); 1865 ArgcList.insert(argptr); 1866 ArgcList.insert(argptr+1); 1867 ArgcList.insert(argptr+2); 1868 argptr+=3; 1869 } 1870 break; 1871 1872 case 'J': 1873 if (ExitFlag == 0) ExitFlag = 1; 1874 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1875 ExitFlag =255; 1876 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of adjacency file: -J <path> --molecule-by-id <molecule_id>" << endl); 1877 performCriticalExit(); 1878 } else { 1879 ArgcList.insert(argptr-1); 1880 ArgcList.insert(argptr); 1881 ArgcList.insert(argptr+1); 1882 ArgcList.insert(argptr+2); 1883 argptr+=3; 1884 } 1885 break; 1886 1887 case 'j': 1888 if (ExitFlag == 0) ExitFlag = 1; 1889 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1890 ExitFlag =255; 1891 DoeLog(0) && (eLog()<< Verbose(0) << "Missing path of bonds file: -j <path> --molecule-by-id <molecule_id>" << endl); 1892 performCriticalExit(); 1893 } else { 1894 ArgcList.insert(argptr-1); 1895 ArgcList.insert(argptr); 1896 ArgcList.insert(argptr+1); 1897 ArgcList.insert(argptr+2); 1898 argptr+=3; 1899 } 1900 break; 1901 1902 case 'N': 1903 if (ExitFlag == 0) ExitFlag = 1; 1904 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){ 1905 ExitFlag = 255; 1906 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for non-convex envelope: -N <molecule_id> --sphere-radius <radius> --nonconvex-file <output prefix>" << endl); 1907 performCriticalExit(); 1908 } else { 1909 ArgcList.insert(argptr-1); 1910 ArgcList.insert(argptr); 1911 ArgcList.insert(argptr+1); 1912 ArgcList.insert(argptr+2); 1913 ArgcList.insert(argptr+3); 1914 ArgcList.insert(argptr+4); 1915 argptr+=5; 1916 } 1917 break; 1918 case 'S': 1919 if (ExitFlag == 0) ExitFlag = 1; 1920 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1921 ExitFlag = 255; 1922 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for storing tempature: -S <temperature file> --molecule-by-id 0" << endl); 1923 performCriticalExit(); 1924 } else { 1925 ArgcList.insert(argptr-1); 1926 ArgcList.insert(argptr); 1927 ArgcList.insert(argptr+1); 1928 ArgcList.insert(argptr+2); 1929 argptr+=3; 1930 } 1931 break; 1932 case 'L': 1933 if (ExitFlag == 0) ExitFlag = 1; 1934 if ((argptr+8 >= argc) || (argv[argptr][0] == '-')) { 1935 ExitFlag = 255; 1936 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for linear interpolation: -L <prefix> --start-step <step0> --end-step <step1> --molecule-by-id 0 --id-mapping <0/1>" << endl); 1937 performCriticalExit(); 1938 } else { 1939 ArgcList.insert(argptr-1); 1940 ArgcList.insert(argptr); 1941 ArgcList.insert(argptr+1); 1942 ArgcList.insert(argptr+2); 1943 ArgcList.insert(argptr+3); 1944 ArgcList.insert(argptr+4); 1945 ArgcList.insert(argptr+5); 1946 ArgcList.insert(argptr+6); 1947 ArgcList.insert(argptr+7); 1948 ArgcList.insert(argptr+8); 1949 argptr+=9; 1950 } 1951 break; 1952 case 'P': 1953 if (ExitFlag == 0) ExitFlag = 1; 1954 if ((argptr+2 >= argc) || (argv[argptr][0] == '-')) { 1955 ExitFlag = 255; 1956 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for parsing and integrating forces: -P <forces file> --molecule-by-id <molecule_id>" << endl); 1957 performCriticalExit(); 1958 } else { 1959 ArgcList.insert(argptr-1); 1960 ArgcList.insert(argptr); 1961 ArgcList.insert(argptr+1); 1962 ArgcList.insert(argptr+2); 1963 argptr+=3; 1964 } 1965 break; 1966 case 'R': 1967 if (ExitFlag == 0) ExitFlag = 1; 1968 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')) { 1969 ExitFlag = 255; 1970 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -R <distance> --position <x> <y> <z>" << endl); 1971 performCriticalExit(); 1972 } else { 1973 ArgcList.insert(argptr-1); 1974 ArgcList.insert(argptr); 1975 ArgcList.insert(argptr+1); 1976 ArgcList.insert(argptr+2); 1977 ArgcList.insert(argptr+3); 1978 ArgcList.insert(argptr+4); 1979 argptr+=5; 1980 } 1981 break; 1982 case 't': 1983 if (ExitFlag == 0) ExitFlag = 1; 1984 if ((argptr+4 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 1985 ExitFlag = 255; 1986 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for translation: -t <x> <y> <z> --molecule-by-id <molecule_id> --periodic <0/1>" << endl); 1987 performCriticalExit(); 1988 } else { 1989 ArgcList.insert(argptr-1); 1990 ArgcList.insert(argptr); 1991 ArgcList.insert(argptr+1); 1992 ArgcList.insert(argptr+2); 1993 ArgcList.insert(argptr+3); 1994 ArgcList.insert(argptr+4); 1995 ArgcList.insert(argptr+5); 1996 ArgcList.insert(argptr+6); 1997 argptr+=7; 1998 } 1999 break; 2000 case 's': 2001 if (ExitFlag == 0) ExitFlag = 1; 2002 if ((argptr+2 >= argc) || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2003 ExitFlag = 255; 2004 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for scaling: -s <factor_x> [factor_y] [factor_z]" << endl); 2005 performCriticalExit(); 2006 } else { 2007 ArgcList.insert(argptr-1); 2008 ArgcList.insert(argptr); 2009 ArgcList.insert(argptr+1); 2010 ArgcList.insert(argptr+2); 2011 argptr+=3; 2012 } 2013 break; 2014 case 'b': 2015 if (ExitFlag == 0) ExitFlag = 1; 2016 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 2017 ExitFlag = 255; 2018 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering in box: -b <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 2019 performCriticalExit(); 2020 } else { 2021 ArgcList.insert(argptr-1); 2022 ArgcList.insert(argptr); 2023 ArgcList.insert(argptr+1); 2024 ArgcList.insert(argptr+2); 2025 ArgcList.insert(argptr+3); 2026 ArgcList.insert(argptr+4); 2027 ArgcList.insert(argptr+5); 2028 argptr+=6; 2029 } 2030 break; 2031 case 'B': 2032 if (ExitFlag == 0) ExitFlag = 1; 2033 if ((argptr+5 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) || (!IsValidNumber(argv[argptr+3])) || (!IsValidNumber(argv[argptr+4])) || (!IsValidNumber(argv[argptr+5])) ) { 2034 ExitFlag = 255; 2035 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for bounding in box: -B <xx> <xy> <xz> <yy> <yz> <zz>" << endl); 2036 performCriticalExit(); 2037 } else { 2038 ArgcList.insert(argptr-1); 2039 ArgcList.insert(argptr); 2040 ArgcList.insert(argptr+1); 2041 ArgcList.insert(argptr+2); 2042 ArgcList.insert(argptr+3); 2043 ArgcList.insert(argptr+4); 2044 ArgcList.insert(argptr+5); 2045 argptr+=6; 2046 } 2047 break; 2048 case 'c': 2049 if (ExitFlag == 0) ExitFlag = 1; 2050 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2051 ExitFlag = 255; 2052 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for centering with boundary: -c <boundary_x> <boundary_y> <boundary_z>" << endl); 2053 performCriticalExit(); 2054 } else { 2055 ArgcList.insert(argptr-1); 2056 ArgcList.insert(argptr); 2057 ArgcList.insert(argptr+1); 2058 ArgcList.insert(argptr+2); 2059 argptr+=3; 2060 } 2061 break; 2062 case 'O': 2063 if (ExitFlag == 0) ExitFlag = 1; 2064 ArgcList.insert(argptr-1); 2065 argptr+=0; 2066 break; 2067 case 'r': 2068 if (ExitFlag == 0) ExitFlag = 1; 2069 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr]))) { 2070 ExitFlag = 255; 2071 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for removing atoms: -r <id>" << endl); 2072 performCriticalExit(); 2073 } else { 2074 ArgcList.insert(argptr-1); 2075 ArgcList.insert(argptr); 2076 argptr+=1; 2077 } 2078 break; 2079 case 'f': 2080 if (ExitFlag == 0) ExitFlag = 1; 2081 if ((argptr+1 >= argc) || (argv[argptr][0] == '-')) { 2082 ExitFlag = 255; 2083 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments for fragmentation: -f <max. bond distance> <bond order>" << endl); 2084 performCriticalExit(); 2085 } else { 2086 ArgcList.insert(argptr-1); 2087 ArgcList.insert(argptr); 2088 ArgcList.insert(argptr+1); 2089 ArgcList.insert(argptr+2); 2090 ArgcList.insert(argptr+3); 2091 ArgcList.insert(argptr+4); 2092 argptr+=5; 2093 } 2094 break; 2095 case 'm': 2096 if (ExitFlag == 0) ExitFlag = 1; 2097 j = atoi(argv[argptr++]); 2098 if ((j<0) || (j>1)) { 2099 DoeLog(1) && (eLog()<< Verbose(1) << "Argument of '-m' should be either 0 for no-rotate or 1 for rotate." << endl); 2100 j = 0; 2101 } 2102 if (j) { 2103 SaveFlag = true; 2104 DoLog(0) && (Log() << Verbose(0) << "Converting to prinicipal axis system." << endl); 2105 mol->PrincipalAxisSystem((bool)j); 2106 } else 2107 ArgcList.insert(argptr-1); 2108 argptr+=0; 2109 break; 2110 case 'o': 2111 if (ExitFlag == 0) ExitFlag = 1; 2112 if ((argptr+4 >= argc) || (argv[argptr][0] == '-')){ 2113 ExitFlag = 255; 2114 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for convex envelope: -o <molecule_id> --output-file <output file> --output-file <binned output file>" << endl); 2115 performCriticalExit(); 2116 } else { 2117 ArgcList.insert(argptr-1); 2118 ArgcList.insert(argptr); 2119 ArgcList.insert(argptr+1); 2120 ArgcList.insert(argptr+2); 2121 ArgcList.insert(argptr+3); 2122 ArgcList.insert(argptr+4); 2123 argptr+=5; 2124 } 2125 break; 2126 case 'U': 2127 if (ExitFlag == 0) ExitFlag = 1; 2128 if ((argptr+1 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) ) { 2129 ExitFlag = 255; 2130 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension with specified volume: -U <volume> <density>" << endl); 2131 performCriticalExit(); 2132 } else { 2133 volume = atof(argv[argptr++]); 2134 DoLog(0) && (Log() << Verbose(0) << "Using " << volume << " angstrom^3 as the volume instead of convex envelope one's." << endl); 2135 } 2136 case 'u': 2137 if (ExitFlag == 0) ExitFlag = 1; 2138 if ((argptr >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) ) { 2139 if (volume != -1) 2140 ExitFlag = 255; 2141 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for suspension: -u <density>" << endl); 2142 performCriticalExit(); 2143 } else { 2144 ArgcList.insert(argptr-1); 2145 ArgcList.insert(argptr); 2146 argptr+=1; 2147 } 2148 break; 2149 case 'd': 2150 if (ExitFlag == 0) ExitFlag = 1; 2151 if ((argptr+2 >= argc) || (argv[argptr][0] == '-') || (!IsValidNumber(argv[argptr])) || (!IsValidNumber(argv[argptr+1])) || (!IsValidNumber(argv[argptr+2])) ) { 2152 ExitFlag = 255; 2153 DoeLog(0) && (eLog()<< Verbose(0) << "Not enough or invalid arguments given for repeating cells: -d <repeat_x> <repeat_y> <repeat_z>" << endl); 2154 performCriticalExit(); 2155 } else { 2156 ArgcList.insert(argptr-1); 2157 ArgcList.insert(argptr); 2158 ArgcList.insert(argptr+1); 2159 ArgcList.insert(argptr+2); 2160 argptr+=3; 2161 } 2162 break; 2163 default: // no match? Step on 2164 if ((argptr < argc) && (argv[argptr][0] != '-')) // if it started with a '-' we've already made a step! 2165 argptr++; 2166 break; 2167 } 2168 } 2169 } else argptr++; 2170 } while (argptr < argc); 2171 if (SaveFlag) 2172 configuration.SaveAll(*ConfigFileName, periode, molecules); 2173 } else { // no arguments, hence scan the elements db 2174 if (periode->LoadPeriodentafel(configuration.databasepath)) 2175 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 2176 else 2177 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 2178 configuration.RetrieveConfigPathAndName("main_pcp_linux"); 2179 } 2180 return(ExitFlag); 2181 }; 92 2182 93 2183 /********************************************** Main routine **************************************/ 94 2184 95 2185 void cleanUp(){ 96 FormatParserStorage::purgeInstance();97 ChangeTracker::purgeInstance();98 2186 World::purgeInstance(); 99 2187 logger::purgeInstance(); … … 112 2200 int main(int argc, char **argv) 113 2201 { 114 // while we are non interactive, we want to abort from asserts 115 //ASSERT_DO(Assert::Abort); 116 string line; 117 char **Arguments = NULL; 118 int ArgcSize = 0; 119 int ExitFlag = 0; 120 bool ArgumentsCopied = false; 121 std::string BondGraphFileName("\n"); 122 FormatParserStorage::getInstance().addMpqc(); 123 FormatParserStorage::getInstance().addPcp(); 124 FormatParserStorage::getInstance().addXyz(); 125 126 // print version check whether arguments are present at all 127 cout << ESPACKVersion << endl; 128 if (argc < 2) { 129 cout << "Obtain help with " << argv[0] << " -h." << endl; 130 cleanUp(); 131 Memory::getState(); 132 return(1); 133 } 134 135 136 setVerbosity(0); 137 // need to init the history before any action is created 138 ActionHistory::init(); 139 140 // In the interactive mode, we can leave the user the choice in case of error 141 ASSERT_DO(Assert::Ask); 142 143 // from this moment on, we need to be sure to deeinitialize in the correct order 144 // this is handled by the cleanup function 145 atexit(cleanUp); 146 147 // Parse command line options and if present create respective UI 148 { 149 // construct bond graph 150 if (World::getInstance().getConfig()->BG == NULL) { 151 World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem()); 152 if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) { 153 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl); 2202 // while we are non interactive, we want to abort from asserts 2203 //ASSERT_DO(Assert::Abort); 2204 Vector x, y, z, n; 2205 ifstream test; 2206 ofstream output; 2207 string line; 2208 char **Arguments = NULL; 2209 int ArgcSize = 0; 2210 int ExitFlag = 0; 2211 bool ArgumentsCopied = false; 2212 char *ConfigFileName = new char[MAXSTRINGSIZE]; 2213 2214 // print version check whether arguments are present at all 2215 cout << ESPACKVersion << endl; 2216 if (argc < 2) { 2217 cout << "Obtain help with " << argv[0] << " -h." << endl; 2218 cleanUp(); 2219 Memory::getState(); 2220 return(1); 2221 } 2222 2223 2224 setVerbosity(0); 2225 // need to init the history before any action is created 2226 ActionHistory::init(); 2227 2228 // In the interactive mode, we can leave the user the choice in case of error 2229 ASSERT_DO(Assert::Ask); 2230 2231 // from this moment on, we need to be sure to deeinitialize in the correct order 2232 // this is handled by the cleanup function 2233 atexit(cleanUp); 2234 2235 // Parse command line options and if present create respective UI 2236 { 2237 set<int> ArgcList; 2238 ArgcList.insert(0); // push back program! 2239 ArgcList.insert(1); // push back config file name 2240 // handle arguments by ParseCommandLineOptions() 2241 ExitFlag = ParseCommandLineOptions(argc,argv,World::getInstance().getMolecules(),World::getInstance().getPeriode(),*World::getInstance().getConfig(), &ConfigFileName, ArgcList); 2242 World::getInstance().setExitFlag(ExitFlag); 2243 // copy all remaining arguments to a new argv 2244 Arguments = new char *[ArgcList.size()]; 2245 cout << "The following arguments are handled by CommandLineParser: "; 2246 for (set<int>::iterator ArgcRunner = ArgcList.begin(); ArgcRunner != ArgcList.end(); ++ArgcRunner) { 2247 Arguments[ArgcSize] = new char[strlen(argv[*ArgcRunner])+2]; 2248 strcpy(Arguments[ArgcSize], argv[*ArgcRunner]); 2249 cout << " " << argv[*ArgcRunner]; 2250 ArgcSize++; 2251 } 2252 cout << endl; 2253 ArgumentsCopied = true; 2254 // handle remaining arguments by CommandLineParser 2255 MapOfActions::getInstance().AddOptionsToParser(); 2256 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap(); 2257 CommandLineParser::getInstance().Run(ArgcSize,Arguments, ShortFormToActionMap); 2258 if (!CommandLineParser::getInstance().isEmpty()) { 2259 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl); 2260 UIFactory::registerFactory(new CommandLineUIFactory::description()); 2261 UIFactory::makeUserInterface("CommandLine"); 154 2262 } else { 155 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); 2263 #ifdef USE_GUI_QT 2264 DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl); 2265 UIFactory::registerFactory(new QTUIFactory::description()); 2266 UIFactory::makeUserInterface("QT4"); 2267 #else 2268 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl); 2269 cout << ESPACKVersion << endl; 2270 UIFactory::registerFactory(new TextUIFactory::description()); 2271 UIFactory::makeUserInterface("Text"); 2272 #endif 156 2273 } 157 2274 } 158 // handle remaining arguments by CommandLineParser 159 MapOfActions::getInstance().AddOptionsToParser(); 160 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap(); 161 CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap); 162 if (!CommandLineParser::getInstance().isEmpty()) { 163 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl); 164 UIFactory::registerFactory(new CommandLineUIFactory::description()); 165 UIFactory::makeUserInterface("CommandLine"); 166 } else { 167 #ifdef USE_GUI_QT 168 DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl); 169 UIFactory::registerFactory(new QTUIFactory::description()); 170 UIFactory::makeUserInterface("QT4"); 171 #else 172 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl); 173 cout << ESPACKVersion << endl; 174 UIFactory::registerFactory(new TextUIFactory::description()); 175 UIFactory::makeUserInterface("Text"); 176 #endif 2275 2276 { 2277 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(); 2278 mainWindow->display(); 2279 delete mainWindow; 177 2280 } 178 } 179 180 { 181 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow(); 182 mainWindow->display(); 183 delete mainWindow; 184 } 185 186 FormatParserStorage::getInstance().SaveAll(); 187 ChangeTracker::getInstance().saveStatus(); 2281 2282 Log() << Verbose(0) << "Saving to " << ConfigFileName << "." << endl; 2283 World::getInstance().getConfig()->SaveAll(ConfigFileName, World::getInstance().getPeriode(), World::getInstance().getMolecules()); 188 2284 189 2285 // free the new argv … … 193 2289 delete[](Arguments); 194 2290 } 195 //delete[](ConfigFileName);2291 delete[](ConfigFileName); 196 2292 197 2293 ExitFlag = World::getInstance().getExitFlag(); -
src/config.cpp
r04488a rce4487 10 10 #include <cstring> 11 11 12 #include "World.hpp" 12 13 #include "atom.hpp" 13 14 #include "bond.hpp" 14 #include "bondgraph.hpp"15 15 #include "config.hpp" 16 #include "ConfigFileBuffer.hpp"17 16 #include "element.hpp" 18 17 #include "helpers.hpp" … … 24 23 #include "molecule.hpp" 25 24 #include "periodentafel.hpp" 26 #include "ThermoStatContainer.hpp"27 25 #include "World.hpp" 28 26 27 /******************************** Functions for class ConfigFileBuffer **********************/ 28 29 /** Structure containing compare function for Ion_Type sorting. 30 */ 31 struct IonTypeCompare { 32 bool operator()(const char* s1, const char *s2) const { 33 char number1[8]; 34 char number2[8]; 35 const char *dummy1, *dummy2; 36 //Log() << Verbose(0) << s1 << " " << s2 << endl; 37 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" 38 dummy2 = strchr(dummy1, '_'); 39 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 40 number1[dummy2-dummy1]='\0'; 41 dummy1 = strchr(s2, '_')+sizeof(char)*5; // go just after "Ion_Type" 42 dummy2 = strchr(dummy1, '_'); 43 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 44 number2[dummy2-dummy1]='\0'; 45 if (atoi(number1) != atoi(number2)) 46 return (atoi(number1) < atoi(number2)); 47 else { 48 dummy1 = strchr(s1, '_')+sizeof(char); 49 dummy1 = strchr(dummy1, '_')+sizeof(char); 50 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 51 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 52 number1[dummy2-dummy1]='\0'; 53 dummy1 = strchr(s2, '_')+sizeof(char); 54 dummy1 = strchr(dummy1, '_')+sizeof(char); 55 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 56 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 57 number2[dummy2-dummy1]='\0'; 58 return (atoi(number1) < atoi(number2)); 59 } 60 } 61 }; 62 63 /** Constructor for ConfigFileBuffer class. 64 */ 65 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 66 { 67 }; 68 69 /** Constructor for ConfigFileBuffer class with filename to be parsed. 70 * \param *filename file name 71 */ 72 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 73 { 74 ifstream *file = NULL; 75 char line[MAXSTRINGSIZE]; 76 77 // prescan number of lines 78 file= new ifstream(filename); 79 if (file == NULL) { 80 DoeLog(1) && (eLog()<< Verbose(1) << "config file " << filename << " missing!" << endl); 81 return; 82 } 83 NoLines = 0; // we're overcounting by one 84 long file_position = file->tellg(); // mark current position 85 do { 86 file->getline(line, 256); 87 NoLines++; 88 } while (!file->eof()); 89 file->clear(); 90 file->seekg(file_position, ios::beg); 91 DoLog(1) && (Log() << Verbose(1) << NoLines-1 << " lines were recognized." << endl); 92 93 // allocate buffer's 1st dimension 94 if (buffer != NULL) { 95 DoeLog(1) && (eLog()<< Verbose(1) << "FileBuffer->buffer is not NULL!" << endl); 96 return; 97 } else 98 buffer = new char *[NoLines]; 99 100 // scan each line and put into buffer 101 int lines=0; 102 int i; 103 do { 104 buffer[lines] = new char[MAXSTRINGSIZE]; 105 file->getline(buffer[lines], MAXSTRINGSIZE-1); 106 i = strlen(buffer[lines]); 107 buffer[lines][i] = '\n'; 108 buffer[lines][i+1] = '\0'; 109 lines++; 110 } while((!file->eof()) && (lines < NoLines)); 111 DoLog(1) && (Log() << Verbose(1) << lines-1 << " lines were read into the buffer." << endl); 112 113 // close and exit 114 file->close(); 115 file->clear(); 116 delete(file); 117 } 118 119 /** Destructor for ConfigFileBuffer class. 120 */ 121 ConfigFileBuffer::~ConfigFileBuffer() 122 { 123 for(int i=0;i<NoLines;++i) 124 delete[](buffer[i]); 125 delete[](buffer); 126 delete[](LineMapping); 127 } 128 129 130 /** Create trivial mapping. 131 */ 132 void ConfigFileBuffer::InitMapping() 133 { 134 LineMapping = new int[NoLines]; 135 for (int i=0;i<NoLines;i++) 136 LineMapping[i] = i; 137 } 138 139 /** Creates a mapping for the \a *FileBuffer's lines containing the Ion_Type keyword such that they are sorted. 140 * \a *map on return contains a list of NoAtom entries such that going through the list, yields indices to the 141 * lines in \a *FileBuffer in a sorted manner of the Ion_Type?_? keywords. We assume that ConfigFileBuffer::CurrentLine 142 * points to first Ion_Type entry. 143 * \param *FileBuffer pointer to buffer structure 144 * \param NoAtoms of subsequent lines to look at 145 */ 146 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 147 { 148 map<const char *, int, IonTypeCompare> IonTypeLineMap; 149 if (LineMapping == NULL) { 150 DoeLog(0) && (eLog()<< Verbose(0) << "map pointer is NULL: " << LineMapping << endl); 151 performCriticalExit(); 152 return; 153 } 154 155 // put all into hashed map 156 for (int i=0; i<NoAtoms; ++i) { 157 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i)); 158 } 159 160 // fill map 161 int nr=0; 162 for (map<const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) { 163 if (CurrentLine+nr < NoLines) 164 LineMapping[CurrentLine+(nr++)] = runner->second; 165 else { 166 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoAtoms is wrong: We are past the end of the file!" << endl); 167 performCriticalExit(); 168 } 169 } 170 } 171 29 172 /************************************* Functions for class config ***************************/ 30 173 31 174 /** Constructor for config file class. 32 175 */ 33 config::config() : BG(NULL), Thermostats(0), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), 34 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 176 config::config() : BG(NULL), PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 177 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL), 178 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 35 179 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 36 180 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), … … 42 186 pseudopotpath = new char[MAXSTRINGSIZE]; 43 187 databasepath = new char[MAXSTRINGSIZE]; 188 configpath = new char[MAXSTRINGSIZE]; 44 189 configname = new char[MAXSTRINGSIZE]; 45 Thermostats = new ThermoStatContainer();46 190 strcpy(mainname,"pcp"); 47 191 strcpy(defaultpath,"not specified"); 48 192 strcpy(pseudopotpath,"not specified"); 193 configpath[0]='\0'; 49 194 configname[0]='\0'; 50 195 basis = "3-21G"; 196 197 InitThermostats(); 51 198 }; 52 199 … … 59 206 delete[](pseudopotpath); 60 207 delete[](databasepath); 208 delete[](configpath); 61 209 delete[](configname); 62 if (Thermostats != NULL) 63 delete(Thermostats); 210 delete[](ThermostatImplemented); 211 for (int j=0;j<MaxThermostats;j++) 212 delete[](ThermostatNames[j]); 213 delete[](ThermostatNames); 64 214 65 215 if (BG != NULL) 66 216 delete(BG); 67 217 }; 218 219 /** Initialises variables in class config for Thermostats. 220 */ 221 void config::InitThermostats() 222 { 223 ThermostatImplemented = new int[MaxThermostats]; 224 ThermostatNames = new char *[MaxThermostats]; 225 for (int j=0;j<MaxThermostats;j++) 226 ThermostatNames[j] = new char[12]; 227 228 strcpy(ThermostatNames[0],"None"); 229 ThermostatImplemented[0] = 1; 230 strcpy(ThermostatNames[1],"Woodcock"); 231 ThermostatImplemented[1] = 1; 232 strcpy(ThermostatNames[2],"Gaussian"); 233 ThermostatImplemented[2] = 1; 234 strcpy(ThermostatNames[3],"Langevin"); 235 ThermostatImplemented[3] = 1; 236 strcpy(ThermostatNames[4],"Berendsen"); 237 ThermostatImplemented[4] = 1; 238 strcpy(ThermostatNames[5],"NoseHoover"); 239 ThermostatImplemented[5] = 1; 240 }; 241 242 /** Readin of Thermostat related values from parameter file. 243 * \param *fb file buffer containing the config file 244 */ 245 void config::ParseThermostats(class ConfigFileBuffer * const fb) 246 { 247 char * const thermo = new char[12]; 248 const int verbose = 0; 249 250 // read desired Thermostat from file along with needed additional parameters 251 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) { 252 if (strcmp(thermo, ThermostatNames[0]) == 0) { // None 253 if (ThermostatImplemented[0] == 1) { 254 Thermostat = None; 255 } else { 256 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 257 Thermostat = None; 258 } 259 } else if (strcmp(thermo, ThermostatNames[1]) == 0) { // Woodcock 260 if (ThermostatImplemented[1] == 1) { 261 Thermostat = Woodcock; 262 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read scaling frequency 263 } else { 264 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 265 Thermostat = None; 266 } 267 } else if (strcmp(thermo, ThermostatNames[2]) == 0) { // Gaussian 268 if (ThermostatImplemented[2] == 1) { 269 Thermostat = Gaussian; 270 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &ScaleTempStep, 1, critical); // read collision rate 271 } else { 272 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 273 Thermostat = None; 274 } 275 } else if (strcmp(thermo, ThermostatNames[3]) == 0) { // Langevin 276 if (ThermostatImplemented[3] == 1) { 277 Thermostat = Langevin; 278 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read gamma 279 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &alpha, 1, optional)) { 280 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << alpha << "." << endl); 281 } else { 282 alpha = 1.; 283 } 284 } else { 285 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 286 Thermostat = None; 287 } 288 } else if (strcmp(thermo, ThermostatNames[4]) == 0) { // Berendsen 289 if (ThermostatImplemented[4] == 1) { 290 Thermostat = Berendsen; 291 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &TempFrequency, 1, critical); // read \tau_T 292 } else { 293 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 294 Thermostat = None; 295 } 296 } else if (strcmp(thermo, ThermostatNames[5]) == 0) { // Nose-Hoover 297 if (ThermostatImplemented[5] == 1) { 298 Thermostat = NoseHoover; 299 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &HooverMass, 1, critical); // read Hoovermass 300 alpha = 0.; 301 } else { 302 DoLog(1) && (Log() << Verbose(1) << "Warning: " << ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl); 303 Thermostat = None; 304 } 305 } else { 306 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl); 307 Thermostat = None; 308 } 309 } else { 310 if ((MaxOuterStep > 0) && (TargetTemp != 0)) 311 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl); 312 Thermostat = None; 313 } 314 delete[](thermo); 315 }; 316 68 317 69 318 /** Displays menu for editing each entry of the config file. … … 380 629 }; 381 630 631 /** Retrieves the path in the given config file name. 632 * \param filename config file string 633 */ 634 void config::RetrieveConfigPathAndName(const string filename) 635 { 636 char *ptr = NULL; 637 char *buffer = new char[MAXSTRINGSIZE]; 638 strncpy(buffer, filename.c_str(), MAXSTRINGSIZE); 639 int last = -1; 640 for(last=MAXSTRINGSIZE;last--;) { 641 if (buffer[last] == '/') 642 break; 643 } 644 if (last == -1) { // no path in front, set to local directory. 645 strcpy(configpath, "./"); 646 ptr = buffer; 647 } else { 648 strncpy(configpath, buffer, last+1); 649 ptr = &buffer[last+1]; 650 if (last < 254) 651 configpath[last+1]='\0'; 652 } 653 strcpy(configname, ptr); 654 DoLog(0) && (Log() << Verbose(0) << "Found configpath: " << configpath << ", dir slash was found at " << last << ", config name is " << configname << "." << endl); 655 delete[](buffer); 656 }; 657 658 /** Initializes ConfigFileBuffer from a file. 659 * \param *file input file stream being the opened config file 660 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL 661 */ 662 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer) 663 { 664 if (FileBuffer != NULL) { 665 DoeLog(2) && (eLog()<< Verbose(2) << "deleting present FileBuffer in PrepareFileBuffer()." << endl); 666 delete(FileBuffer); 667 } 668 FileBuffer = new ConfigFileBuffer(filename); 669 670 FileBuffer->InitMapping(); 671 }; 672 382 673 /** Loads a molecule from a ConfigFileBuffer. 383 674 * \param *mol molecule to load … … 573 864 file->close(); 574 865 delete(file); 866 RetrieveConfigPathAndName(filename); 575 867 576 868 // ParseParameterFile 577 class ConfigFileBuffer *FileBuffer = new ConfigFileBuffer(filename); 869 struct ConfigFileBuffer *FileBuffer = NULL; 870 PrepareFileBuffer(filename,FileBuffer); 578 871 579 872 /* Oeffne Hauptparameterdatei */ … … 584 877 int verbose = 0; 585 878 586 //TODO: This is actually sensible?: if (MaxOuterStep > 0)587 879 ParseThermostats(FileBuffer); 588 880 … … 649 941 ParseForParameter(verbose,FileBuffer,"OutVisStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 650 942 ParseForParameter(verbose,FileBuffer,"OutSrcStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 651 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &( Thermostats->TargetTemp), 1, optional);943 ParseForParameter(verbose,FileBuffer,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 652 944 //ParseForParameter(verbose,FileBuffer,"Thermostat", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 653 945 if (!ParseForParameter(verbose,FileBuffer,"EpsWannier", 0, 1, 1, double_type, &(config::EpsWannier), 1, optional)) … … 809 1101 return; 810 1102 } 1103 RetrieveConfigPathAndName(filename); 811 1104 // ParseParameters 812 1105 … … 857 1150 ParseForParameter(verbose,file,"VisOuterStep", 0, 1, 1, int_type, &(config::OutVisStep), 1, optional); 858 1151 ParseForParameter(verbose,file,"VisSrcOuterStep", 0, 1, 1, int_type, &(config::OutSrcStep), 1, optional); 859 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &( Thermostats->TargetTemp), 1, optional);860 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &( Thermostats->ScaleTempStep), 1, optional);1152 ParseForParameter(verbose,file,"TargetTemp", 0, 1, 1, double_type, &(config::TargetTemp), 1, optional); 1153 ParseForParameter(verbose,file,"ScaleTempStep", 0, 1, 1, int_type, &(config::ScaleTempStep), 1, optional); 861 1154 config::EpsWannier = 1e-8; 862 1155 … … 1046 1339 *output << "DoFullCurrent\t" << config::DoFullCurrent << "\t# Do full perturbation" << endl; 1047 1340 *output << "DoConstrainedMD\t" << config::DoConstrainedMD << "\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD" << endl; 1048 *output << "Thermostat\t" << Thermostat s->ThermostatNames[Thermostats->Thermostat] << "\t";1049 switch(Thermostat s->Thermostat) {1341 *output << "Thermostat\t" << ThermostatNames[Thermostat] << "\t"; 1342 switch(Thermostat) { 1050 1343 default: 1051 1344 case None: 1052 1345 break; 1053 1346 case Woodcock: 1054 *output << Thermostats->ScaleTempStep;1347 *output << ScaleTempStep; 1055 1348 break; 1056 1349 case Gaussian: 1057 *output << Thermostats->ScaleTempStep;1350 *output << ScaleTempStep; 1058 1351 break; 1059 1352 case Langevin: 1060 *output << T hermostats->TempFrequency << "\t" << Thermostats->alpha;1353 *output << TempFrequency << "\t" << alpha; 1061 1354 break; 1062 1355 case Berendsen: 1063 *output << T hermostats->TempFrequency;1356 *output << TempFrequency; 1064 1357 break; 1065 1358 case NoseHoover: 1066 *output << Thermostats->HooverMass;1359 *output << HooverMass; 1067 1360 break; 1068 1361 }; … … 1079 1372 *output << "OutVisStep\t" << config::OutVisStep << "\t# Output visual data every ...th step" << endl; 1080 1373 *output << "OutSrcStep\t" << config::OutSrcStep << "\t# Output \"restart\" data every ..th step" << endl; 1081 *output << "TargetTemp\t" << Thermostats->TargetTemp << "\t# Target temperature" << endl;1374 *output << "TargetTemp\t" << config::TargetTemp << "\t# Target temperature" << endl; 1082 1375 *output << "MaxPsiStep\t" << config::MaxPsiStep << "\t# number of Minimisation steps per state (0 - default)" << endl; 1083 1376 *output << "EpsWannier\t" << config::EpsWannier << "\t# tolerance value for spread minimisation of orbitals" << endl; … … 1190 1483 // output of atoms 1191 1484 AtomNo = 0; 1192 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const)output, (const Vector *)center, &AtomNo );1485 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1193 1486 delete(center); 1194 1487 *output << "\t}" << endl; … … 1232 1525 // output of atoms 1233 1526 AtomNo = 0; 1234 mol->ActOnAllAtoms( &atom::OutputMPQCLine, (ostream * const)output, (const Vector *)center, &AtomNo );1527 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1235 1528 delete(center); 1236 1529 *output << "\t}" << endl; … … 1493 1786 molecule *mol = NULL; 1494 1787 1788 if (!strcmp(configpath, GetDefaultPath())) { 1789 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1790 } 1791 1792 1495 1793 // first save as PDB data 1496 1794 if (ConfigFileName != NULL) … … 1529 1827 mol->doCountAtoms(); 1530 1828 mol->CountElements(); 1531 //mol->CalculateOrbitals(*this);1829 mol->CalculateOrbitals(*this); 1532 1830 delete[](src); 1533 1831 } else { … … 1535 1833 mol = *(molecules->ListOfMolecules.begin()); 1536 1834 mol->doCountAtoms(); 1537 //mol->CalculateOrbitals(*this);1835 mol->CalculateOrbitals(*this); 1538 1836 } else { 1539 1837 DoeLog(1) && (eLog() << Verbose(1) << "There are no molecules to save!" << endl); … … 1597 1895 else 1598 1896 Log() << Verbose(0) << "\t... failed." << endl; 1897 1898 if (!strcmp(configpath, GetDefaultPath())) { 1899 eLog() << Verbose(2) << "config is found under different path then stated in config file::defaultpath!" << endl; 1900 } 1599 1901 1600 1902 // don't destroy molecule as it contains all our atoms … … 2044 2346 return (found); // true if found, false if not 2045 2347 } 2046 2047 /** Reading of Thermostat related values from parameter file.2048 * \param *fb file buffer containing the config file2049 */2050 void config::ParseThermostats(class ConfigFileBuffer * const fb)2051 {2052 char * const thermo = new char[12];2053 const int verbose = 0;2054 2055 // read desired Thermostat from file along with needed additional parameters2056 if (ParseForParameter(verbose,fb,"Thermostat", 0, 1, 1, string_type, thermo, 1, optional)) {2057 if (strcmp(thermo, Thermostats->ThermostatNames[0]) == 0) { // None2058 if (Thermostats->ThermostatImplemented[0] == 1) {2059 Thermostats->Thermostat = None;2060 } else {2061 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2062 Thermostats->Thermostat = None;2063 }2064 } else if (strcmp(thermo, Thermostats->ThermostatNames[1]) == 0) { // Woodcock2065 if (Thermostats->ThermostatImplemented[1] == 1) {2066 Thermostats->Thermostat = Woodcock;2067 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read scaling frequency2068 } else {2069 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2070 Thermostats->Thermostat = None;2071 }2072 } else if (strcmp(thermo, Thermostats->ThermostatNames[2]) == 0) { // Gaussian2073 if (Thermostats->ThermostatImplemented[2] == 1) {2074 Thermostats->Thermostat = Gaussian;2075 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, int_type, &Thermostats->ScaleTempStep, 1, critical); // read collision rate2076 } else {2077 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2078 Thermostats->Thermostat = None;2079 }2080 } else if (strcmp(thermo, Thermostats->ThermostatNames[3]) == 0) { // Langevin2081 if (Thermostats->ThermostatImplemented[3] == 1) {2082 Thermostats->Thermostat = Langevin;2083 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read gamma2084 if (ParseForParameter(verbose,fb,"Thermostat", 0, 3, 1, double_type, &Thermostats->alpha, 1, optional)) {2085 DoLog(2) && (Log() << Verbose(2) << "Extended Stochastic Thermostat detected with interpolation coefficient " << Thermostats->alpha << "." << endl);2086 } else {2087 Thermostats->alpha = 1.;2088 }2089 } else {2090 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2091 Thermostats->Thermostat = None;2092 }2093 } else if (strcmp(thermo, Thermostats->ThermostatNames[4]) == 0) { // Berendsen2094 if (Thermostats->ThermostatImplemented[4] == 1) {2095 Thermostats->Thermostat = Berendsen;2096 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->TempFrequency, 1, critical); // read \tau_T2097 } else {2098 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2099 Thermostats->Thermostat = None;2100 }2101 } else if (strcmp(thermo, Thermostats->ThermostatNames[5]) == 0) { // Nose-Hoover2102 if (Thermostats->ThermostatImplemented[5] == 1) {2103 Thermostats->Thermostat = NoseHoover;2104 ParseForParameter(verbose,fb,"Thermostat", 0, 2, 1, double_type, &Thermostats->HooverMass, 1, critical); // read Hoovermass2105 Thermostats->alpha = 0.;2106 } else {2107 DoLog(1) && (Log() << Verbose(1) << "Warning: " << Thermostats->ThermostatNames[0] << " thermostat not implemented, falling back to None." << endl);2108 Thermostats->Thermostat = None;2109 }2110 } else {2111 DoLog(1) && (Log() << Verbose(1) << " Warning: thermostat name was not understood!" << endl);2112 Thermostats->Thermostat = None;2113 }2114 } else {2115 if ((Thermostats->TargetTemp != 0))2116 DoLog(2) && (Log() << Verbose(2) << "No thermostat chosen despite finite temperature MD, falling back to None." << endl);2117 Thermostats->Thermostat = None;2118 }2119 delete[](thermo);2120 };2121 -
src/config.hpp
r04488a rce4487 20 20 #include <string> 21 21 22 #include "bondgraph.hpp" 23 22 24 /****************************************** forward declarations *****************************/ 23 25 24 class BondGraph;25 class ConfigFileBuffer;26 26 class molecule; 27 27 class MoleculeListClass; 28 28 class periodentafel; 29 class ThermoStatContainer;30 29 31 30 /********************************************** declarations *******************************/ 31 32 class ConfigFileBuffer { 33 public: 34 char **buffer; 35 int *LineMapping; 36 int CurrentLine; 37 int NoLines; 38 39 ConfigFileBuffer(); 40 ConfigFileBuffer(const char * const filename); 41 ~ConfigFileBuffer(); 42 43 void InitMapping(); 44 void MapIonTypesInBuffer(const int NoAtoms); 45 }; 32 46 33 47 /** The config file. … … 37 51 public: 38 52 class BondGraph *BG; 39 class ThermoStatContainer *Thermostats;40 53 41 54 int PsiType; … … 47 60 int ProcPEGamma; 48 61 int ProcPEPsi; 62 char *configpath; 49 63 char *configname; 50 64 bool FastParsing; … … 56 70 int DoConstrainedMD; 57 71 int MaxOuterStep; 72 int Thermostat; 73 int *ThermostatImplemented; 74 char **ThermostatNames; 75 double TempFrequency; 76 double alpha; 77 double HooverMass; 78 double TargetTemp; 79 int ScaleTempStep; 58 80 59 81 private: … … 116 138 void Load(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList); 117 139 void LoadOld(const char * const filename, const string &BondGraphFileName, const periodentafel * const periode, MoleculeListClass * const &MolList); 140 void RetrieveConfigPathAndName(const string filename); 118 141 bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const; 119 142 bool SaveMPQC(const char * const filename, const molecule * const mol) const; … … 129 152 char *GetDefaultPath() const; 130 153 void SetDefaultPath(const char * const path); 154 void InitThermostats(); 131 155 void ParseThermostats(class ConfigFileBuffer * const fb); 132 156 }; -
src/molecule.cpp
r04488a rce4487 79 79 void molecule::setName(const std::string _name){ 80 80 OBSERVE; 81 cout << "Set name of molecule " << getId() << " to " << _name << endl;82 81 strncpy(name,_name.c_str(),MAXSTRINGSIZE); 83 82 } … … 155 154 molecule::const_iterator molecule::erase( atom * key ) 156 155 { 156 cout << "trying to erase atom" << endl; 157 157 molecule::const_iterator iter = find(key); 158 158 if (iter != end()){ … … 740 740 else 741 741 length = strlen(molname) - strlen(endname); 742 cout << "Set name of molecule " << getId() << " to " << molname << endl;743 742 strncpy(name, molname, length); 744 743 name[length]='\0'; … … 882 881 ElementNo[i] = current++; 883 882 } 884 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const)output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );883 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 885 884 return true; 886 885 } … … 1005 1004 for(int i=MAX_ELEMENTS;i--;) 1006 1005 ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0); 1006 }; 1007 1008 1009 /** Counts necessary number of valence electrons and returns number and SpinType. 1010 * \param configuration containing everything 1011 */ 1012 void molecule::CalculateOrbitals(class config &configuration) 1013 { 1014 configuration.MaxPsiDouble = configuration.PsiMaxNoDown = configuration.PsiMaxNoUp = configuration.PsiType = 0; 1015 for(int i=MAX_ELEMENTS;i--;) { 1016 if (ElementsInMolecule[i] != 0) { 1017 //Log() << Verbose(0) << "CalculateOrbitals: " << elemente->FindElement(i)->name << " has a valence of " << (int)elemente->FindElement(i)->Valence << " and there are " << ElementsInMolecule[i] << " of it." << endl; 1018 configuration.MaxPsiDouble += ElementsInMolecule[i]*((int)elemente->FindElement(i)->Valence); 1019 } 1020 } 1021 configuration.PsiMaxNoDown = configuration.MaxPsiDouble/2 + (configuration.MaxPsiDouble % 2); 1022 configuration.PsiMaxNoUp = configuration.MaxPsiDouble/2; 1023 configuration.MaxPsiDouble /= 2; 1024 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1; 1025 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) { 1026 configuration.ProcPEGamma /= 2; 1027 configuration.ProcPEPsi *= 2; 1028 } else { 1029 configuration.ProcPEGamma *= configuration.ProcPEPsi; 1030 configuration.ProcPEPsi = 1; 1031 } 1032 cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl; 1033 if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) { 1034 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown; 1035 cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl; 1036 } else { 1037 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp; 1038 cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl; 1039 } 1007 1040 }; 1008 1041 -
src/molecule.hpp
r04488a rce4487 80 80 double *PenaltyConstants; //!< penalty constant in front of each term 81 81 }; 82 83 #define MaxThermostats 6 //!< maximum number of thermostat entries in Ions#ThermostatNames and Ions#ThermostatImplemented 84 enum thermostats { None, Woodcock, Gaussian, Langevin, Berendsen, NoseHoover }; //!< Thermostat names for output 85 82 86 83 87 /** The complete molecule. … … 261 265 /// Count and change present atoms' coordination. 262 266 void CountElements(); 267 void CalculateOrbitals(class config &configuration); 263 268 bool CenterInBox(); 264 269 bool BoundInBox(); … … 287 292 double MinimiseConstrainedPotential(atom **&permutation, int startstep, int endstep, bool IsAngstroem); 288 293 void EvaluateConstrainedForces(int startstep, int endstep, atom **PermutationMap, ForceMatrix *Force); 289 bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity);294 bool LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity); 290 295 291 296 bool CheckBounds(const Vector *x) const; … … 319 324 320 325 /// Fragment molecule by two different approaches: 321 int FragmentMolecule(int Order, std::string &prefix);322 bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::string path = "");323 bool StoreBondsToFile( std::string &filename, std::string path = "");324 bool StoreAdjacencyToFile( std::string &filename, std::string path = "");325 bool CheckAdjacencyFileAgainstMolecule( std::string &path, atom **ListOfAtoms);326 bool ParseOrderAtSiteFromFile( std::string &path);327 bool StoreOrderAtSiteFile( std::string &path);328 bool StoreForcesFile(MoleculeListClass *BondFragments, std::string &path, int *SortIndex);326 int FragmentMolecule(int Order, config *configuration); 327 bool CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path = NULL); 328 bool StoreBondsToFile(char *path, char *filename); 329 bool StoreAdjacencyToFile(char *path, char *filename); 330 bool CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms); 331 bool ParseOrderAtSiteFromFile(char *path); 332 bool StoreOrderAtSiteFile(char *path); 333 bool StoreForcesFile(MoleculeListClass *BondFragments, char *path, int *SortIndex); 329 334 bool CreateMappingLabelsToConfigSequence(int *&SortIndex); 330 335 bool CreateFatherLookupTable(atom **&LookupTable, int count = 0); … … 375 380 ~MoleculeListClass(); 376 381 377 bool AddHydrogenCorrection( std::string &path);378 bool StoreForcesFile( std::string &path, int *SortIndex);382 bool AddHydrogenCorrection(char *path); 383 bool StoreForcesFile(char *path, int *SortIndex); 379 384 void insert(molecule *mol); 380 385 void erase(molecule *mol); 381 386 molecule * ReturnIndex(int index); 382 bool OutputConfigForListOfFragments( std::string &prefix, int *SortIndex);387 bool OutputConfigForListOfFragments(config *configuration, int *SortIndex); 383 388 int NumberOfActiveMolecules(); 384 389 void Enumerate(ostream *out); -
src/molecule_dynamics.cpp
r04488a rce4487 18 18 #include "parser.hpp" 19 19 #include "Plane.hpp" 20 #include "ThermoStatContainer.hpp"21 20 22 21 /************************************* Functions for class molecule *********************************/ … … 473 472 * \param startstep stating initial configuration in molecule::Trajectories 474 473 * \param endstep stating final configuration in molecule::Trajectories 475 * \param &prefix path and prefix476 474 * \param &config configuration structure 477 475 * \param MapByIdentity if true we just use the identity to map atoms in start config to end config, if not we find mapping by \sa MinimiseConstrainedPotential() 478 476 * \return true - success in writing step files, false - error writing files or only one step in molecule::Trajectories 479 477 */ 480 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, std::string &prefix, config &configuration, bool MapByIdentity)478 bool molecule::LinearInterpolationBetweenConfiguration(int startstep, int endstep, const char *prefix, config &configuration, bool MapByIdentity) 481 479 { 482 480 molecule *mol = NULL; … … 526 524 for (int i=getAtomCount(); i--; ) 527 525 SortIndex[i] = i; 528 529 status = MoleculePerStep->OutputConfigForListOfFragments(prefix, SortIndex); 526 status = MoleculePerStep->OutputConfigForListOfFragments(&configuration, SortIndex); 530 527 delete[](SortIndex); 531 528 … … 646 643 647 644 // calculate scale configuration 648 ScaleTempFactor = configuration.T hermostats->TargetTemp/ActualTemp;645 ScaleTempFactor = configuration.TargetTemp/ActualTemp; 649 646 650 647 // differentating between the various thermostats … … 654 651 break; 655 652 case Woodcock: 656 if ((configuration. Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {653 if ((configuration.ScaleTempStep > 0) && ((MDSteps-1) % configuration.ScaleTempStep == 0)) { 657 654 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl); 658 655 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin ); … … 687 684 delta_alpha = 0.; 688 685 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha ); 689 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.T hermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);690 configuration. Thermostats->alpha += delta_alpha*configuration.Deltat;691 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration. Thermostats->alpha << "." << endl);686 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.TargetTemp)/(configuration.HooverMass*Units2Electronmass); 687 configuration.alpha += delta_alpha*configuration.Deltat; 688 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.alpha << "." << endl); 692 689 // apply updated alpha as additional force 693 690 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration ); -
src/molecule_fragmentation.cpp
r04488a rce4487 82 82 * -# Scans TEFactors file and sets the TEFactor of each key set in the temporary graph accordingly 83 83 * Finally, the temporary graph is inserted into the given \a FragmentList for return. 84 * \param &path path to file 84 * \param *out output stream for debugging 85 * \param *path path to file 85 86 * \param *FragmentList empty, filled on return 86 87 * \return true - parsing successfully, false - failure on parsing (FragmentList will be NULL) 87 88 */ 88 bool ParseKeySetFile( std::string &path, Graph *&FragmentList)89 bool ParseKeySetFile(char *path, Graph *&FragmentList) 89 90 { 90 91 bool status = true; … … 93 94 GraphTestPair testGraphInsert; 94 95 int NumberOfFragments = 0; 95 string filename;96 char filename[MAXSTRINGSIZE]; 96 97 97 98 if (FragmentList == NULL) { // check list pointer … … 101 102 // 1st pass: open file and read 102 103 DoLog(1) && (Log() << Verbose(1) << "Parsing the KeySet file ... " << endl); 103 filename = path + KEYSETFILE;104 InputFile.open(filename .c_str());105 if (InputFile .good()) {104 sprintf(filename, "%s/%s%s", path, FRAGMENTPREFIX, KEYSETFILE); 105 InputFile.open(filename); 106 if (InputFile != NULL) { 106 107 // each line represents a new fragment 107 108 char buffer[MAXSTRINGSIZE]; … … 180 181 181 182 /** Stores key sets to file. 183 * \param *out output stream for debugging 182 184 * \param KeySetList Graph with Keysets 183 * \param &path path to file185 * \param *path path to file 184 186 * \return true - file written successfully, false - writing failed 185 187 */ 186 bool StoreKeySetFile(Graph &KeySetList, std::string &path) 187 { 188 bool StoreKeySetFile(Graph &KeySetList, char *path) 189 { 190 ofstream output; 188 191 bool status = true; 189 string line = path + KEYSETFILE; 190 ofstream output(line.c_str()); 192 string line; 191 193 192 194 // open KeySet file 195 line = path; 196 line.append("/"); 197 line += FRAGMENTPREFIX; 198 line += KEYSETFILE; 199 output.open(line.c_str(), ios::out); 193 200 DoLog(1) && (Log() << Verbose(1) << "Saving key sets of the total graph ... "); 194 if(output .good()) {201 if(output != NULL) { 195 202 for(Graph::iterator runner = KeySetList.begin(); runner != KeySetList.end(); runner++) { 196 203 for (KeySet::iterator sprinter = (*runner).first.begin();sprinter != (*runner).first.end(); sprinter++) { … … 295 302 296 303 /** Scans the adaptive order file and insert (index, value) into map. 297 * \param &path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 304 * \param *out output stream for debugging 305 * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 298 306 * \param &IndexedKeySetList list to find key set for a given index \a No 299 307 * \return adaptive criteria list from file 300 308 */ 301 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap( std::string &path, map<int,KeySet> &IndexKeySetList)309 map<int, pair<double,int> > * ScanAdaptiveFileIntoMap(char *path, map<int,KeySet> &IndexKeySetList) 302 310 { 303 311 map<int, pair<double,int> > *AdaptiveCriteriaList = new map<int, pair<double,int> >; … … 305 313 double Value = 0.; 306 314 char buffer[MAXSTRINGSIZE]; 307 string filename = path + ENERGYPERFRAGMENT; 308 ifstream InputFile(filename.c_str()); 309 310 if (InputFile.fail()) { 311 DoeLog(1) && (eLog() << Verbose(1) << "Cannot find file " << filename << "." << endl); 312 return AdaptiveCriteriaList; 313 } 315 sprintf(buffer, "%s/%s%s.dat", path, FRAGMENTPREFIX, ENERGYPERFRAGMENT); 316 ifstream InputFile(buffer, ios::in); 314 317 315 318 if (CountLinesinFile(InputFile) > 0) { … … 416 419 417 420 /** Checks whether the OrderAtSite is still below \a Order at some site. 421 * \param *out output stream for debugging 418 422 * \param *AtomMask defines true/false per global Atom::nr to mask in/out each nuclear site, used to activate given number of site to increment order adaptively 419 423 * \param *GlobalKeySetList list of keysets with global ids (valid in "this" molecule) needed for adaptive increase 420 424 * \param Order desired Order if positive, desired exponent in threshold criteria if negative (0 is single-step) 421 425 * \param *MinimumRingSize array of max. possible order to avoid loops 422 * \param path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative)426 * \param *path path to ENERGYPERFRAGMENT file (may be NULL if Order is non-negative) 423 427 * \return true - needs further fragmentation, false - does not need fragmentation 424 428 */ 425 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, std::stringpath)429 bool molecule::CheckOrderAtSite(bool *AtomMask, Graph *GlobalKeySetList, int Order, int *MinimumRingSize, char *path) 426 430 { 427 431 bool status = false; … … 581 585 * of vertex indices: Global always means the index in "this" molecule, whereas local refers to the molecule or 582 586 * subgraph in the MoleculeListClass. 587 * \param *out output stream for debugging 583 588 * \param Order up to how many neighbouring bonds a fragment contains in BondOrderScheme::BottumUp scheme 584 * \param &prefix path and prefix of the bond order configs to be written589 * \param *configuration configuration for writing config files for each fragment 585 590 * \return 1 - continue, 2 - stop (no fragmentation occured) 586 591 */ 587 int molecule::FragmentMolecule(int Order, std::string &prefix)592 int molecule::FragmentMolecule(int Order, config *configuration) 588 593 { 589 594 MoleculeListClass *BondFragments = NULL; … … 619 624 620 625 // === compare it with adjacency file === 621 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule( prefix, ListOfAtoms);626 FragmentationToDo = FragmentationToDo && CheckAdjacencyFileAgainstMolecule(configuration->configpath, ListOfAtoms); 622 627 delete[](ListOfAtoms); 623 628 … … 653 658 654 659 // ===== 3. if structure still valid, parse key set file and others ===== 655 FragmentationToDo = FragmentationToDo && ParseKeySetFile( prefix, ParsedFragmentList);660 FragmentationToDo = FragmentationToDo && ParseKeySetFile(configuration->configpath, ParsedFragmentList); 656 661 657 662 // ===== 4. check globally whether there's something to do actually (first adaptivity check) 658 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile( prefix);663 FragmentationToDo = FragmentationToDo && ParseOrderAtSiteFromFile(configuration->configpath); 659 664 660 665 // =================================== Begin of FRAGMENTATION =============================== … … 667 672 AtomMask[getAtomCount()] = false; 668 673 FragmentationToDo = false; // if CheckOrderAtSite just ones recommends fragmentation, we will save fragments afterwards 669 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, prefix))) {674 while ((CheckOrder = CheckOrderAtSite(AtomMask, ParsedFragmentList, Order, MinimumRingSize, configuration->configpath))) { 670 675 FragmentationToDo = FragmentationToDo || CheckOrder; 671 676 AtomMask[getAtomCount()] = true; // last plus one entry is used as marker that we have been through this loop once already in CheckOrderAtSite() … … 722 727 KeySet test = (*runner).first; 723 728 DoLog(0) && (Log() << Verbose(0) << "Fragment No." << (*runner).second.first << " with TEFactor " << (*runner).second.second << "." << endl); 724 BondFragments->insert(StoreFragmentFromKeySet(test, World::getInstance().getConfig()));729 BondFragments->insert(StoreFragmentFromKeySet(test, configuration)); 725 730 k++; 726 731 } … … 734 739 735 740 DoLog(1) && (Log() << Verbose(1) << "Writing " << BondFragments->ListOfMolecules.size() << " possible bond fragmentation configs" << endl); 736 if (BondFragments->OutputConfigForListOfFragments( prefix, SortIndex))741 if (BondFragments->OutputConfigForListOfFragments(configuration, SortIndex)) 737 742 DoLog(1) && (Log() << Verbose(1) << "All configs written." << endl); 738 743 else … … 740 745 741 746 // store force index reference file 742 BondFragments->StoreForcesFile( prefix, SortIndex);747 BondFragments->StoreForcesFile(configuration->configpath, SortIndex); 743 748 744 749 // store keysets file 745 StoreKeySetFile(TotalGraph, prefix);750 StoreKeySetFile(TotalGraph, configuration->configpath); 746 751 747 752 { 748 753 // store Adjacency file 749 std::string filename = prefix + ADJACENCYFILE; 750 StoreAdjacencyToFile(filename); 754 char filename[MAXSTRINGSIZE]; 755 strcpy(filename, FRAGMENTPREFIX); 756 strcat(filename, ADJACENCYFILE); 757 StoreAdjacencyToFile(configuration->configpath, filename); 751 758 } 752 759 753 760 // store Hydrogen saturation correction file 754 BondFragments->AddHydrogenCorrection( prefix);761 BondFragments->AddHydrogenCorrection(configuration->configpath); 755 762 756 763 // store adaptive orders into file 757 StoreOrderAtSiteFile( prefix);764 StoreOrderAtSiteFile(configuration->configpath); 758 765 759 766 // restore orbital and Stop values 760 //CalculateOrbitals(*configuration);767 CalculateOrbitals(*configuration); 761 768 762 769 // free memory for bond part … … 775 782 /** Stores pairs (Atom::nr, Atom::AdaptiveOrder) into file. 776 783 * Atoms not present in the file get "-1". 777 * \param &path path to file ORDERATSITEFILE 784 * \param *out output stream for debugging 785 * \param *path path to file ORDERATSITEFILE 778 786 * \return true - file writable, false - not writable 779 787 */ 780 bool molecule::StoreOrderAtSiteFile( std::string &path)781 { 782 string line;788 bool molecule::StoreOrderAtSiteFile(char *path) 789 { 790 stringstream line; 783 791 ofstream file; 784 792 785 line = path +ORDERATSITEFILE;786 file.open(line. c_str());793 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 794 file.open(line.str().c_str()); 787 795 DoLog(1) && (Log() << Verbose(1) << "Writing OrderAtSite " << ORDERATSITEFILE << " ... " << endl); 788 if (file .good()) {796 if (file != NULL) { 789 797 ActOnAllAtoms( &atom::OutputOrder, &file ); 790 798 file.close(); … … 792 800 return true; 793 801 } else { 794 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line << "." << endl);802 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 795 803 return false; 796 804 } … … 799 807 /** Parses pairs(Atom::nr, Atom::AdaptiveOrder) from file and stores in molecule's Atom's. 800 808 * Atoms not present in the file get "0". 801 * \param &path path to file ORDERATSITEFILEe 809 * \param *out output stream for debugging 810 * \param *path path to file ORDERATSITEFILEe 802 811 * \return true - file found and scanned, false - file not found 803 812 * \sa ParseKeySetFile() and CheckAdjacencyFileAgainstMolecule() as this is meant to be used in conjunction with the two 804 813 */ 805 bool molecule::ParseOrderAtSiteFromFile( std::string &path)814 bool molecule::ParseOrderAtSiteFromFile(char *path) 806 815 { 807 816 unsigned char *OrderArray = new unsigned char[getAtomCount()]; … … 809 818 bool status; 810 819 int AtomNr, value; 811 string line;820 stringstream line; 812 821 ifstream file; 813 822 … … 818 827 819 828 DoLog(1) && (Log() << Verbose(1) << "Begin of ParseOrderAtSiteFromFile" << endl); 820 line = path +ORDERATSITEFILE;821 file.open(line. c_str());822 if (file .good()) {829 line << path << "/" << FRAGMENTPREFIX << ORDERATSITEFILE; 830 file.open(line.str().c_str()); 831 if (file != NULL) { 823 832 while (!file.eof()) { // parse from file 824 833 AtomNr = -1; … … 841 850 status = true; 842 851 } else { 843 DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line << "." << endl);852 DoLog(1) && (Log() << Verbose(1) << "\t ... failed to open file " << line.str() << "." << endl); 844 853 status = false; 845 854 } -
src/molecule_graph.cpp
r04488a rce4487 12 12 #include "bondgraph.hpp" 13 13 #include "config.hpp" 14 #include "defs.hpp"15 14 #include "element.hpp" 16 15 #include "helpers.hpp" … … 1025 1024 /** Storing the bond structure of a molecule to file. 1026 1025 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line. 1027 * \param &filename name offile1028 * \param path path to file, defaults to empty1026 * \param *path path to file 1027 * \param *filename name of file 1029 1028 * \return true - file written successfully, false - writing failed 1030 1029 */ 1031 bool molecule::StoreAdjacencyToFile( std::string &filename, std::string path)1030 bool molecule::StoreAdjacencyToFile(char *path, char *filename) 1032 1031 { 1033 1032 ofstream AdjacencyFile; 1034 string line;1033 stringstream line; 1035 1034 bool status = true; 1036 1035 1037 if (path != "")1038 line = path + "/" +filename;1036 if (path != NULL) 1037 line << path << "/" << filename; 1039 1038 else 1040 line =filename;1041 AdjacencyFile.open(line. c_str(), ios::out);1039 line << filename; 1040 AdjacencyFile.open(line.str().c_str(), ios::out); 1042 1041 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1043 if (AdjacencyFile .good()) {1042 if (AdjacencyFile != NULL) { 1044 1043 AdjacencyFile << "m\tn" << endl; 1045 1044 ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile); … … 1047 1046 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1048 1047 } else { 1049 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);1048 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl); 1050 1049 status = false; 1051 1050 } … … 1057 1056 /** Storing the bond structure of a molecule to file. 1058 1057 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line. 1059 * \param &filename name offile1060 * \param path path to file, defaults to empty1058 * \param *path path to file 1059 * \param *filename name of file 1061 1060 * \return true - file written successfully, false - writing failed 1062 1061 */ 1063 bool molecule::StoreBondsToFile( std::string &filename, std::string path)1062 bool molecule::StoreBondsToFile(char *path, char *filename) 1064 1063 { 1065 1064 ofstream BondFile; 1066 string line;1065 stringstream line; 1067 1066 bool status = true; 1068 1067 1069 if (path != "")1070 line = path + "/" +filename;1068 if (path != NULL) 1069 line << path << "/" << filename; 1071 1070 else 1072 line =filename;1073 BondFile.open(line. c_str(), ios::out);1071 line << filename; 1072 BondFile.open(line.str().c_str(), ios::out); 1074 1073 DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl); 1075 if (BondFile .good()) {1074 if (BondFile != NULL) { 1076 1075 BondFile << "m\tn" << endl; 1077 1076 ActOnAllAtoms(&atom::OutputBonds, &BondFile); … … 1079 1078 DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl); 1080 1079 } else { 1081 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);1080 DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl); 1082 1081 status = false; 1083 1082 } … … 1087 1086 ; 1088 1087 1089 bool CheckAdjacencyFileAgainstMolecule_Init( std::string &path, ifstream &File, int *&CurrentBonds)1090 { 1091 string filename;1092 filename = path +ADJACENCYFILE;1093 File.open(filename. c_str(), ios::out);1088 bool CheckAdjacencyFileAgainstMolecule_Init(char *path, ifstream &File, int *&CurrentBonds) 1089 { 1090 stringstream filename; 1091 filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE; 1092 File.open(filename.str().c_str(), ios::out); 1094 1093 DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl); 1095 if (File .fail())1094 if (File == NULL) 1096 1095 return false; 1097 1096 … … 1147 1146 * \return true - structure is equal, false - not equivalence 1148 1147 */ 1149 bool molecule::CheckAdjacencyFileAgainstMolecule( std::string &path, atom **ListOfAtoms)1148 bool molecule::CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms) 1150 1149 { 1151 1150 ifstream File; -
src/moleculelist.cpp
r04488a rce4487 12 12 #include "atom.hpp" 13 13 #include "bond.hpp" 14 #include "bondgraph.hpp"15 14 #include "boundary.hpp" 16 15 #include "config.hpp" … … 380 379 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse 381 380 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance. 382 * \param &path path to file 383 */ 384 bool MoleculeListClass::AddHydrogenCorrection(std::string &path) 381 * \param *out output stream for debugging 382 * \param *path path to file 383 */ 384 bool MoleculeListClass::AddHydrogenCorrection(char *path) 385 385 { 386 386 bond *Binder = NULL; … … 400 400 // 0a. find dimension of matrices with constants 401 401 line = path; 402 line.append("/"); 403 line += FRAGMENTPREFIX; 402 404 line += "1"; 403 405 line += FITCONSTANTSUFFIX; 404 406 input.open(line.c_str()); 405 if (input .fail()) {407 if (input == NULL) { 406 408 DoLog(1) && (Log() << Verbose(1) << endl << "Unable to open " << line << ", is the directory correct?" << endl); 407 409 return false; … … 567 569 568 570 /** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config. 569 * \param &path path to file 571 * \param *out output stream for debugging 572 * \param *path path to file 570 573 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config 571 574 * \return true - file written successfully, false - writing failed 572 575 */ 573 bool MoleculeListClass::StoreForcesFile(std::string &path, int *SortIndex) 576 bool MoleculeListClass::StoreForcesFile(char *path, 577 int *SortIndex) 574 578 { 575 579 bool status = true; 576 string filename(path); 577 filename += FORCESFILE; 578 ofstream ForcesFile(filename.c_str()); 580 ofstream ForcesFile; 581 stringstream line; 579 582 periodentafel *periode=World::getInstance().getPeriode(); 580 583 581 584 // open file for the force factors 582 585 DoLog(1) && (Log() << Verbose(1) << "Saving force factors ... "); 583 if (!ForcesFile.fail()) { 586 line << path << "/" << FRAGMENTPREFIX << FORCESFILE; 587 ForcesFile.open(line.str().c_str(), ios::out); 588 if (ForcesFile != NULL) { 584 589 //Log() << Verbose(1) << "Final AtomicForcesList: "; 585 590 //output << prefix << "Forces" << endl; … … 606 611 } else { 607 612 status = false; 608 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << filename<< "." << endl);613 DoLog(1) && (Log() << Verbose(1) << "failed to open file " << line.str() << "." << endl); 609 614 } 610 615 ForcesFile.close(); … … 615 620 /** Writes a config file for each molecule in the given \a **FragmentList. 616 621 * \param *out output stream for debugging 617 * \param &prefix path and prefix to the fragment config files622 * \param *configuration standard configuration to attach atoms in fragment molecule to. 618 623 * \param *SortIndex Index to map from the BFS labeling to the sequence how of Ion_Type in the config 619 624 * \return true - success (each file was written), false - something went wrong. 620 625 */ 621 bool MoleculeListClass::OutputConfigForListOfFragments( std::string &prefix, int *SortIndex)626 bool MoleculeListClass::OutputConfigForListOfFragments(config *configuration, int *SortIndex) 622 627 { 623 628 ofstream outputFragment; 624 std::string FragmentName;629 char FragmentName[MAXSTRINGSIZE]; 625 630 char PathBackup[MAXSTRINGSIZE]; 626 631 bool result = true; … … 640 645 for (MoleculeList::iterator ListRunner = ListOfMolecules.begin(); ListRunner != ListOfMolecules.end(); ListRunner++) { 641 646 // save default path as it is changed for each fragment 642 path = World::getInstance().getConfig()->GetDefaultPath();647 path = configuration->GetDefaultPath(); 643 648 if (path != NULL) 644 649 strcpy(PathBackup, path); … … 653 658 // output xyz file 654 659 FragmentNumber = FixedDigitNumber(ListOfMolecules.size(), FragmentCounter++); 655 FragmentName = prefix + FragmentNumber + ".conf.xyz";656 outputFragment.open(FragmentName .c_str(), ios::out);660 sprintf(FragmentName, "%s/%s%s.conf.xyz", configuration->configpath, FRAGMENTPREFIX, FragmentNumber); 661 outputFragment.open(FragmentName, ios::out); 657 662 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as XYZ ..."); 658 663 if ((intermediateResult = (*ListRunner)->OutputXYZ(&outputFragment))) … … 677 682 for (int k = 0; k < NDIM; k++) { 678 683 j += k + 1; 679 BoxDimension[k] = 2.5 * ( World::getInstance().getConfig()->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem);684 BoxDimension[k] = 2.5 * (configuration->GetIsAngstroem() ? 1. : 1. / AtomicLengthToAngstroem); 680 685 cell_size[j] = BoxDimension[k] * 2.; 681 686 } … … 684 689 // also calculate necessary orbitals 685 690 (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment 686 //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig);691 (*ListRunner)->CalculateOrbitals(*configuration); 687 692 688 693 // change path in config 689 FragmentName = PathBackup; 690 FragmentName += "/"; 691 FragmentName += FRAGMENTPREFIX; 692 FragmentName += FragmentNumber; 693 FragmentName += "/"; 694 World::getInstance().getConfig()->SetDefaultPath(FragmentName.c_str()); 694 //strcpy(PathBackup, configuration->configpath); 695 sprintf(FragmentName, "%s/%s%s/", PathBackup, FRAGMENTPREFIX, FragmentNumber); 696 configuration->SetDefaultPath(FragmentName); 695 697 696 698 // and save as config 697 FragmentName = prefix + FragmentNumber + ".conf";699 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber); 698 700 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as config ..."); 699 if ((intermediateResult = World::getInstance().getConfig()->Save(FragmentName.c_str(), (*ListRunner)->elemente, (*ListRunner))))701 if ((intermediateResult = configuration->Save(FragmentName, (*ListRunner)->elemente, (*ListRunner)))) 700 702 DoLog(0) && (Log() << Verbose(0) << " done." << endl); 701 703 else … … 704 706 705 707 // restore old config 706 World::getInstance().getConfig()->SetDefaultPath(PathBackup);708 configuration->SetDefaultPath(PathBackup); 707 709 708 710 // and save as mpqc input file 709 FragmentName = prefix + FragmentNumber + ".conf";711 sprintf(FragmentName, "%s/%s%s.conf", configuration->configpath, FRAGMENTPREFIX, FragmentNumber); 710 712 DoLog(2) && (Log() << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter - 1 << " as mpqc input ..."); 711 if ((intermediateResult = World::getInstance().getConfig()->SaveMPQC(FragmentName.c_str(), (*ListRunner))))713 if ((intermediateResult = configuration->SaveMPQC(FragmentName, (*ListRunner)))) 712 714 DoLog(2) && (Log() << Verbose(2) << " done." << endl); 713 715 else … … 765 767 766 768 // 1. dissect the molecule into connected subgraphs 767 if (configuration->BG != NULL) { 768 if (!configuration->BG->ConstructBondGraph(mol)) { 769 World::getInstance().destroyMolecule(mol); 770 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 771 return; 772 } 773 } else { 774 DoeLog(1) && (eLog()<< Verbose(1) << "There is no BondGraph class present to create bonds." << endl); 769 if (!configuration->BG->ConstructBondGraph(mol)) { 770 World::getInstance().destroyMolecule(mol); 771 DoeLog(1) && (eLog()<< Verbose(1) << "There are no bonds." << endl); 775 772 return; 776 773 } -
src/periodentafel.cpp
r04488a rce4487 32 32 periodentafel::periodentafel() 33 33 { 34 { 35 stringstream input(elementsDB,ios_base::in); 36 bool status = LoadElementsDatabase(&input); 37 ASSERT(status, "General element initialization failed"); 38 } 39 { 40 stringstream input(valenceDB,ios_base::in); 41 bool status = LoadValenceDatabase(&input); 42 ASSERT(status, "Valence entry of element initialization failed"); 43 } 44 { 45 stringstream input(orbitalsDB,ios_base::in); 46 bool status = LoadOrbitalsDatabase(&input); 47 ASSERT(status, "Orbitals entry of element initialization failed"); 48 } 49 { 50 stringstream input(HbondangleDB,ios_base::in); 51 bool status = LoadHBondAngleDatabase(&input); 52 ASSERT(status, "HBond angle entry of element initialization failed"); 53 } 54 { 55 stringstream input(HbonddistanceDB,ios_base::in); 56 bool status = LoadHBondLengthsDatabase(&input); 57 ASSERT(status, "HBond distance entry of element initialization failed"); 58 } 34 bool status = true; 35 status = LoadElementsDatabase(new stringstream(elementsDB,ios_base::in)); 36 ASSERT(status, "General element initialization failed"); 37 status = LoadValenceDatabase(new stringstream(valenceDB,ios_base::in)); 38 ASSERT(status, "Valence entry of element initialization failed"); 39 status = LoadOrbitalsDatabase(new stringstream(orbitalsDB,ios_base::in)); 40 ASSERT(status, "Orbitals entry of element initialization failed"); 41 status = LoadHBondAngleDatabase(new stringstream(HbondangleDB,ios_base::in)); 42 ASSERT(status, "HBond angle entry of element initialization failed"); 43 status = LoadHBondLengthsDatabase(new stringstream(HbonddistanceDB,ios_base::in)); 44 ASSERT(status, "HBond distance entry of element initialization failed"); 59 45 }; 60 46 … … 347 333 ASSERT(Elemental != NULL, "element should be present but is not??"); 348 334 *Elemental = *neues; 349 delete(neues);350 neues = Elemental;351 335 } else { 352 336 InserterTest = elements.insert(pair <atomicNumber_t,element*> (neues->getNumber(), neues)); -
src/tesselation.cpp
r04488a rce4487 9 9 10 10 #include <fstream> 11 #include <assert.h> 11 12 12 13 #include "helpers.hpp" … … 23 24 #include "Plane.hpp" 24 25 #include "Exceptions/LinearDependenceException.hpp" 26 #include "Helpers/Assert.hpp" 27 25 28 #include "Helpers/Assert.hpp" 26 29 … … 2524 2527 baseline = Runner->second; 2525 2528 if (baseline->pointlist.empty()) { 2526 ASSERT((baseline->BaseLine->triangles.size() == 1),"Open line without exactly one attached triangle");2529 assert((baseline->BaseLine->triangles.size() == 1) && ("Open line without exactly one attached triangle")); 2527 2530 T = (((baseline->BaseLine->triangles.begin()))->second); 2528 2531 DoLog(1) && (Log() << Verbose(1) << "Finding best candidate for open line " << *baseline->BaseLine << " of triangle " << *T << endl); -
src/unittests/LinkedCellUnitTest.cpp
r04488a rce4487 264 264 Vector tester; 265 265 LinkedCell::LinkedNodes *ListOfPoints = NULL; 266 atom *Walker = NULL; 266 267 size_t size = 0; 267 268 … … 325 326 Vector tester; 326 327 LinkedCell::LinkedNodes *ListOfPoints = NULL; 328 atom *Walker = NULL; 327 329 size_t size = 0; 328 330 -
src/unittests/Makefile.am
r04488a rce4487 52 52 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 53 53 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 54 PARSERLIBS = ../libparser.a ${ALLLIBS}55 54 56 55 TESTSOURCES = \ … … 202 201 203 202 ParserUnitTest_SOURCES = UnitTestMain.cpp ParserUnitTest.cpp ParserUnitTest.hpp 204 ParserUnitTest_LDADD = ${ PARSERLIBS}203 ParserUnitTest_LDADD = ${ALLLIBS} 205 204 206 205 periodentafelTest_SOURCES = UnitTestMain.cpp periodentafelTest.cpp periodentafelTest.hpp … … 211 210 212 211 SingletonTest_SOURCES = UnitTestMain.cpp SingletonTest.cpp SingletonTest.hpp 213 SingletonTest_LDADD = $ {ALLLIBS} $(BOOST_LIB) ${BOOST_THREAD_LIB}212 SingletonTest_LDADD = $(BOOST_LIB) ${BOOST_THREAD_LIB} 214 213 215 214 StackClassUnitTest_SOURCES = UnitTestMain.cpp stackclassunittest.cpp stackclassunittest.hpp -
src/unittests/ObserverTest.cpp
r04488a rce4487 382 382 // make this Observable its own subject. NEVER DO THIS IN ACTUAL CODE 383 383 simpleObservable1->signOn(simpleObservable1); 384 #ifndef NDEBUG385 384 CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure); 386 #else387 simpleObservable1->changeMethod();388 #endif389 385 390 386 // more complex test … … 392 388 simpleObservable1->signOn(simpleObservable2); 393 389 simpleObservable2->signOn(simpleObservable1); 394 #ifndef NDEBUG395 390 CPPUNIT_ASSERT_THROW(simpleObservable1->changeMethod(),Assert::AssertionFailure); 396 #else397 simpleObservable1->changeMethod();398 #endif399 400 401 391 simpleObservable1->signOff(simpleObservable2); 402 392 simpleObservable2->signOff(simpleObservable1); -
src/unittests/ParserUnitTest.cpp
r04488a rce4487 12 12 #include <cppunit/ui/text/TestRunner.h> 13 13 14 #include "Parser/MpqcParser.hpp" 15 #include "Parser/PcpParser.hpp" 14 #include "Parser/XyzParser.hpp" 16 15 #include "Parser/TremoloParser.hpp" 17 #include "Parser/XyzParser.hpp"18 16 #include "World.hpp" 19 17 #include "atom.hpp" … … 31 29 CPPUNIT_TEST_SUITE_REGISTRATION( ParserUnitTest ); 32 30 33 static string waterPcp = "# ParallelCarParinello - main configuration file - created with molecuilder\n\34 \n\35 mainname\tpcp\t# programm name (for runtime files)\n\36 defaultpath\not specified\t# where to put files during runtime\n\37 pseudopotpath\not specified\t# where to find pseudopotentials\n\38 \n\39 ProcPEGamma\t8\t# for parallel computing: share constants\n\40 ProcPEPsi\t1\t# for parallel computing: share wave functions\n\41 DoOutVis\t0\t# Output data for OpenDX\n\42 DoOutMes\t1\t# Output data for measurements\n\43 DoOutOrbitals\t0\t# Output all Orbitals\n\44 DoOutCurr\t0\t# Ouput current density for OpenDx\n\45 DoOutNICS\t0\t# Output Nucleus independent current shieldings\n\46 DoPerturbation\t0\t# Do perturbation calculate and determine susceptibility and shielding\n\47 DoFullCurrent\t0\t# Do full perturbation\n\48 DoConstrainedMD\t0\t# Do perform a constrained (>0, relating to current MD step) instead of unconstrained (0) MD\n\49 Thermostat\tBerendsen\t2.5\t# Which Thermostat and its parameters to use in MD case.\n\50 CommonWannier\t0\t# Put virtual centers at indivual orbits, all common, merged by variance, to grid point, to cell center\n\51 SawtoothStart\t0.01\t# Absolute value for smooth transition at cell border \n\52 VectorPlane\t0\t# Cut plane axis (x, y or z: 0,1,2) for two-dim current vector plot\n\53 VectorCut\t0\t# Cut plane axis value\n\54 AddGramSch\t1\t# Additional GramSchmidtOrtogonalization to be safe\n\55 Seed\t1\t# initial value for random seed for Psi coefficients\n\56 \n\57 MaxOuterStep\t0\t# number of MolecularDynamics/Structure optimization steps\n\58 Deltat\t0.01\t# time per MD step\n\59 OutVisStep\t10\t# Output visual data every ...th step\n\60 OutSrcStep\t5\t# Output \"restart\" data every ..th step\n\61 TargetTemp\t0.000950045\t# Target temperature\n\62 MaxPsiStep\t3\t# number of Minimisation steps per state (0 - default)\n\63 EpsWannier\t1e-07\t# tolerance value for spread minimisation of orbitals\n\64 # Values specifying when to stop\n\65 MaxMinStep\t100\t# Maximum number of steps\n\66 RelEpsTotalE\t1e-07\t# relative change in total energy\n\67 RelEpsKineticE\t1e-05\t# relative change in kinetic energy\n\68 MaxMinStopStep\t2\t# check every ..th steps\n\69 MaxMinGapStopStep\t1\t# check every ..th steps\n\70 \n\71 # Values specifying when to stop for INIT, otherwise same as above\n\72 MaxInitMinStep\t100\t# Maximum number of steps\n\73 InitRelEpsTotalE\t1e-05\t# relative change in total energy\n\74 InitRelEpsKineticE\t0.0001\t# relative change in kinetic energy\n\75 InitMaxMinStopStep\t2\t# check every ..th steps\n\76 InitMaxMinGapStopStep\t1\t# check every ..th steps\n\77 \n\78 BoxLength\t# (Length of a unit cell)\n\79 20\n\80 0\t20\n\81 0\t0\t20\n\82 \n\83 ECut\t128\t# energy cutoff for discretization in Hartrees\n\84 MaxLevel\t5\t# number of different levels in the code, >=2\n\85 Level0Factor\t2\t# factor by which node number increases from S to 0 level\n\86 RiemannTensor\t0\t# (Use metric)\n\87 PsiType\t0\t# 0 - doubly occupied, 1 - SpinUp,SpinDown\n\88 MaxPsiDouble\t2\t# here: specifying both maximum number of SpinUp- and -Down-states\n\89 PsiMaxNoUp\t2\t# here: specifying maximum number of SpinUp-states\n\90 PsiMaxNoDown\t2\t# here: specifying maximum number of SpinDown-states\n\91 AddPsis\t0\t# Additional unoccupied Psis for bandgap determination\n\92 \n\93 RCut\t20\t# R-cut for the ewald summation\n\94 StructOpt\t0\t# Do structure optimization beforehand\n\95 IsAngstroem\t1\t# 0 - Bohr, 1 - Angstroem\n\96 RelativeCoord\t0\t# whether ion coordinates are relative (1) or absolute (0)\n\97 MaxTypes\t2\t# maximum number of different ion types\n\98 \n\99 # Ion type data (PP = PseudoPotential, Z = atomic number)\n\100 #Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol\n\101 Ion_Type1\t2\t1\t1.0\t3\t3\t1.008\tHydrogen\tH\n\102 Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\103 #Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\104 Ion_Type2_1\t0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\105 Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\106 Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n";107 static string waterMpqc ="% Created by MoleCuilder\n\108 mpqc: (\n\109 \tsavestate = no\n\110 \tdo_gradient = yes\n\111 \tmole<MBPT2>: (\n\112 \t\tmaxiter = 200\n\113 \t\tbasis = $:basis\n\114 \t\tmolecule = $:molecule\n\115 \t\treference<CLHF>: (\n\116 \t\t\tbasis = $:basis\n\117 \t\t\tmolecule = $:molecule\n\118 \t\t)\n\119 \t)\n\120 )\n\121 molecule<Molecule>: (\n\122 \tunit = angstrom\n\123 \t{ atoms geometry } = {\n\124 \t\tO [ -0.505735\t0\t0 ]\n\125 \t\tH [ 0.252867\t0\t0.504284 ]\n\126 \t\tH [ 0.252867\t0\t-0.504284 ]\n\127 \t}\n\128 )\n\129 basis<GaussianBasisSet>: (\n\130 \tname = \"3-21G\"\n\131 \tmolecule = $:molecule\n\132 )\n";133 static string waterXyz = "3\nH2O: water molecule\nO\t0\t0\t0\nH\t0.758602\t0\t0.504284\nH\t0.758602\t0\t-0.504284\n";134 static string Tremolo_Atomdata1 = "# ATOMDATA\tId\tname\tType\tx=3\n";135 static string Tremolo_Atomdata2 = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n";136 static string Tremolo_invalidkey = "#\n#ATOMDATA Id name foo Type x=3\n\n\n";137 static string Tremolo_velocity = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n";138 static string Tremolo_neighbours = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n";139 static string Tremolo_improper = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";140 static string Tremolo_torsion = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n";141 static string Tremolo_full = "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n";142 31 143 32 void ParserUnitTest::setUp() { 144 33 World::getInstance(); 145 146 // we need hydrogens and oxygens in the following tests147 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);148 CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(8) != NULL);149 34 } 150 35 151 36 void ParserUnitTest::tearDown() { 152 ChangeTracker::purgeInstance();153 37 World::purgeInstance(); 154 38 } … … 159 43 cout << "Testing the XYZ parser." << endl; 160 44 XyzParser* testParser = new XyzParser(); 45 string waterXyz = "3\nH2O: water molecule\nO\t0.000000\t0.000000\t0.000000\nH\t0.758602\t0.000000\t0.504284\nH\t0.758602\t0.000000\t-0.504284\n"; 161 46 stringstream input; 162 47 input << waterXyz; … … 177 62 TremoloParser* testParser = new TremoloParser(); 178 63 stringstream input, output; 64 string waterTremolo; 179 65 180 66 // Atomdata beginning with "# ATOMDATA" 181 input << Tremolo_Atomdata1; 67 waterTremolo = "# ATOMDATA\tId\tname\tType\tx=3\n"; 68 input << waterTremolo; 182 69 testParser->load(&input); 183 70 testParser->save(&output); 184 CPPUNIT_ASSERT( Tremolo_Atomdata1== output.str());71 CPPUNIT_ASSERT(waterTremolo == output.str()); 185 72 input.clear(); 186 73 output.clear(); 187 74 188 75 // Atomdata beginning with "#ATOMDATA" 189 input << Tremolo_Atomdata2; 76 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 77 input << waterTremolo; 190 78 testParser->load(&input); 191 79 testParser->save(&output); … … 195 83 196 84 // Invalid key in Atomdata line 197 input << Tremolo_invalidkey; 85 waterTremolo = "#\n#ATOMDATA Id name foo Type x=3\n\n\n"; 86 input << waterTremolo; 198 87 testParser->load(&input); 199 88 //TODO: proove invalidity … … 204 93 TremoloParser* testParser = new TremoloParser(); 205 94 stringstream input; 95 string waterTremolo; 206 96 207 97 // One simple data line 208 input << Tremolo_Atomdata2; 98 waterTremolo = "#\n#ATOMDATA Id name Type x=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 99 input << waterTremolo; 209 100 testParser->load(&input); 210 101 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->x[0] == 3.0); … … 215 106 TremoloParser* testParser = new TremoloParser(); 216 107 stringstream input; 108 string waterTremolo; 217 109 218 110 // One simple data line 219 input << Tremolo_velocity; 111 waterTremolo = "#\n#ATOMDATA Id name Type u=3\n1 hydrogen H 3.0 4.5 0.1\n\n"; 112 input << waterTremolo; 220 113 testParser->load(&input); 221 114 CPPUNIT_ASSERT(World::getInstance().getAtom(AtomByType(1))->v[0] == 3.0); … … 226 119 TremoloParser* testParser = new TremoloParser(); 227 120 stringstream input; 121 string waterTremolo; 228 122 229 123 // Neighbor data 230 input << Tremolo_neighbours; 124 waterTremolo = "#\n#ATOMDATA Id Type neighbors=2\n1 H 3 0\n2 H 3 0\n3 O 1 2\n"; 125 input << waterTremolo; 231 126 testParser->load(&input); 232 127 … … 240 135 TremoloParser* testParser = new TremoloParser(); 241 136 stringstream input, output; 137 string waterTremolo; 242 138 243 139 // Neighbor data 244 input << Tremolo_improper; 140 waterTremolo = "#\n#ATOMDATA Id Type imprData\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 141 input << waterTremolo; 245 142 testParser->load(&input); 246 143 testParser->save(&output); … … 254 151 TremoloParser* testParser = new TremoloParser(); 255 152 stringstream input, output; 153 string waterTremolo; 256 154 257 155 // Neighbor data 258 input << Tremolo_torsion; 156 waterTremolo = "#\n#ATOMDATA Id Type torsion\n8 H 9-10\n9 H 10-8,8-10\n10 O -\n"; 157 input << waterTremolo; 259 158 testParser->load(&input); 260 159 testParser->save(&output); … … 274 173 testParser->setFieldsForSave("x=3 u=3 F stress Id neighbors=5 imprData GroupMeasureTypeNo Type extType name resName chainID resSeq occupancy tempFactor segID Charge charge GrpTypeNo torsion"); 275 174 testParser->save(&output); 276 CPPUNIT_ASSERT(output.str() == Tremolo_full);175 CPPUNIT_ASSERT(output.str() == "# ATOMDATA\tx=3\tu=3\tF\tstress\tId\tneighbors=5\timprData\tGroupMeasureTypeNo\tType\textType\tname\tresName\tchainID\tresSeq\toccupancy\ttempFactor\tsegID\tCharge\tcharge\tGrpTypeNo\ttorsion\n0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t-\t0\tH\t-\t-\t-\t0\t0\t0\t0\t0\t0\t0\t0\t-\t\n"); 277 176 278 177 cout << "testing the tremolo parser is done" << endl; 279 178 } 280 281 void ParserUnitTest::readwritePcpTest() {282 stringstream input(waterPcp);283 PcpParser* testParser = new PcpParser();284 testParser->load(&input);285 input.clear();286 287 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());288 289 string newWaterPcp = "";290 stringstream output;291 testParser->save(&output);292 293 input << output;294 PcpParser* testParser2 = new PcpParser();295 testParser2->load(&input);296 297 CPPUNIT_ASSERT_EQUAL(6, World::getInstance().numAtoms());298 299 CPPUNIT_ASSERT(*testParser == *testParser2);300 }301 302 void ParserUnitTest::writeMpqcTest() {303 // build up water molecule304 atom *Walker = NULL;305 Walker = World::getInstance().createAtom();306 Walker->type = World::getInstance().getPeriode()->FindElement(8);307 Walker->x = Vector(0,0,0);308 Walker = World::getInstance().createAtom();309 Walker->type = World::getInstance().getPeriode()->FindElement(1);310 Walker->x = Vector(0.758602,0,0.504284);311 Walker = World::getInstance().createAtom();312 Walker->type = World::getInstance().getPeriode()->FindElement(1);313 Walker->x = Vector(0.758602,0,-0.504284);314 CPPUNIT_ASSERT_EQUAL(3, World::getInstance().numAtoms());315 316 // create two stringstreams, one stored, one created317 stringstream input(waterMpqc);318 MpqcParser* testParser = new MpqcParser();319 stringstream output;320 testParser->save(&output);321 322 // compare both configs323 string first = input.str();324 string second = output.str();325 CPPUNIT_ASSERT(first == second);326 } -
src/unittests/ParserUnitTest.hpp
r04488a rce4487 22 22 CPPUNIT_TEST ( readAndWriteTremoloTorsionInformationTest ); 23 23 CPPUNIT_TEST ( writeTremoloTest ); 24 CPPUNIT_TEST ( readwritePcpTest );25 CPPUNIT_TEST ( writeMpqcTest );26 24 CPPUNIT_TEST_SUITE_END(); 27 25 … … 38 36 void readAndWriteTremoloTorsionInformationTest(); 39 37 void writeTremoloTest(); 40 void readwritePcpTest();41 void writeMpqcTest();42 38 }; 43 39 -
src/unittests/manipulateAtomsTest.cpp
r04488a rce4487 87 87 static void operation(atom* _atom){ 88 88 AtomStub *atom = dynamic_cast<AtomStub*>(_atom); 89 CPPUNIT_ASSERT(atom);89 assert(atom); 90 90 atom->doSomething(); 91 91 } … … 100 100 AtomStub *atom; 101 101 atom = dynamic_cast<AtomStub*>(*iter); 102 CPPUNIT_ASSERT(atom);102 assert(atom); 103 103 CPPUNIT_ASSERT(atom->manipulated); 104 104 } … … 114 114 AtomStub *atom; 115 115 atom = dynamic_cast<AtomStub*>(*iter); 116 CPPUNIT_ASSERT(atom);116 assert(atom); 117 117 if(atom->getId()!=(int)ATOM_COUNT/2) 118 118 CPPUNIT_ASSERT(atom->manipulated); -
tests/regression/Domain/6/post/test-x.conf.xyz
r04488a rce4487 1 1 22 2 2 Created by molecuilder on Mon May 31 19:07:16 2010 3 H 9.78209 2.64589 2.64589 4 C 27.2836 3.27519 3.53589 5 C 28.5328 4.15859 3.53589 6 C 29.7821 3.27519 3.53589 7 H 27.2836 2.64589 4.42589 8 H 9.78209 2.64589 4.42589 9 H 10.672 3.90454 3.53589 10 H 8.53279 4.78789 2.64589 11 H 27.2836 2.64589 2.64589 12 H 26.3936 3.90454 3.53589 13 H 28.5328 4.78789 4.42589 14 H 28.5328 4.78789 2.64589 15 H 30.672 3.90454 3.53589 16 H 29.7821 2.64589 4.42589 17 H 29.7821 2.64589 2.64589 18 H 8.53279 4.78789 4.42589 19 H 6.39363 3.90454 3.53589 20 H 7.28359 2.64589 2.64589 21 H 7.28359 2.64589 4.42589 22 C 9.78209 3.27519 3.53589 23 C 8.53279 4.15859 3.53589 24 C 7.28359 3.27519 3.53589 3 H 9.78209 2.64589 2.64589 4 C 27.2836 3.27519 3.53589 5 C 28.5328 4.15859 3.53589 6 C 29.7821 3.27519 3.53589 7 H 27.2836 2.64589 4.42589 8 H 9.78209 2.64589 4.42589 9 H 10.672 3.90454 3.53589 10 H 8.53279 4.78789 2.64589 11 H 27.2836 2.64589 2.64589 12 H 26.3936 3.90454 3.53589 13 H 28.5328 4.78789 4.42589 14 H 28.5328 4.78789 2.64589 15 H 30.672 3.90454 3.53589 16 H 29.7821 2.64589 4.42589 17 H 29.7821 2.64589 2.64589 18 H 8.53279 4.78789 4.42589 19 H 6.39363 3.90454 3.53589 20 H 7.28359 2.64589 2.64589 21 H 7.28359 2.64589 4.42589 22 C 9.78209 3.27519 3.53589 23 C 8.53279 4.15859 3.53589 24 C 7.28359 3.27519 3.53589 -
tests/regression/Domain/6/post/test-y.conf.xyz
r04488a rce4487 1 1 22 2 2 Created by molecuilder on Mon May 31 19:07:16 2010 3 H 9.78209 2.64589 2.64589 4 C 7.28359 23.2752 3.53589 5 C 8.53279 24.1586 3.53589 6 C 9.78209 23.2752 3.53589 7 H 7.28359 22.6459 4.42589 8 H 9.78209 2.64589 4.42589 9 H 10.672 3.90454 3.53589 10 H 8.53279 4.78789 2.64589 11 H 7.28359 22.6459 2.64589 12 H 6.39363 23.9045 3.53589 13 H 8.53279 24.7879 4.42589 14 H 8.53279 24.7879 2.64589 15 H 10.672 23.9045 3.53589 16 H 9.78209 22.6459 4.42589 17 H 9.78209 22.6459 2.64589 18 H 8.53279 4.78789 4.42589 19 H 6.39363 3.90454 3.53589 20 H 7.28359 2.64589 2.64589 21 H 7.28359 2.64589 4.42589 22 C 9.78209 3.27519 3.53589 23 C 8.53279 4.15859 3.53589 24 C 7.28359 3.27519 3.53589 3 H 9.78209 2.64589 2.64589 4 C 7.28359 23.2752 3.53589 5 C 8.53279 24.1586 3.53589 6 C 9.78209 23.2752 3.53589 7 H 7.28359 22.6459 4.42589 8 H 9.78209 2.64589 4.42589 9 H 10.672 3.90454 3.53589 10 H 8.53279 4.78789 2.64589 11 H 7.28359 22.6459 2.64589 12 H 6.39363 23.9045 3.53589 13 H 8.53279 24.7879 4.42589 14 H 8.53279 24.7879 2.64589 15 H 10.672 23.9045 3.53589 16 H 9.78209 22.6459 4.42589 17 H 9.78209 22.6459 2.64589 18 H 8.53279 4.78789 4.42589 19 H 6.39363 3.90454 3.53589 20 H 7.28359 2.64589 2.64589 21 H 7.28359 2.64589 4.42589 22 C 9.78209 3.27519 3.53589 23 C 8.53279 4.15859 3.53589 24 C 7.28359 3.27519 3.53589 -
tests/regression/Domain/6/post/test-z.conf.xyz
r04488a rce4487 1 1 22 2 2 Created by molecuilder on Mon May 31 19:07:16 2010 3 H 9.78209 2.64589 2.64589 4 C 7.28359 3.27519 23.5359 5 C 8.53279 4.15859 23.5359 6 C 9.78209 3.27519 23.5359 7 H 7.28359 2.64589 24.4259 8 H 9.78209 2.64589 4.42589 9 H 10.672 3.90454 3.53589 10 H 8.53279 4.78789 2.64589 11 H 7.28359 2.64589 22.6459 12 H 6.39363 3.90454 23.5359 13 H 8.53279 4.78789 24.4259 14 H 8.53279 4.78789 22.6459 15 H 10.672 3.90454 23.5359 16 H 9.78209 2.64589 24.4259 17 H 9.78209 2.64589 22.6459 18 H 8.53279 4.78789 4.42589 19 H 6.39363 3.90454 3.53589 20 H 7.28359 2.64589 2.64589 21 H 7.28359 2.64589 4.42589 22 C 9.78209 3.27519 3.53589 23 C 8.53279 4.15859 3.53589 24 C 7.28359 3.27519 3.53589 3 H 9.78209 2.64589 2.64589 4 C 7.28359 3.27519 23.5359 5 C 8.53279 4.15859 23.5359 6 C 9.78209 3.27519 23.5359 7 H 7.28359 2.64589 24.4259 8 H 9.78209 2.64589 4.42589 9 H 10.672 3.90454 3.53589 10 H 8.53279 4.78789 2.64589 11 H 7.28359 2.64589 22.6459 12 H 6.39363 3.90454 23.5359 13 H 8.53279 4.78789 24.4259 14 H 8.53279 4.78789 22.6459 15 H 10.672 3.90454 23.5359 16 H 9.78209 2.64589 24.4259 17 H 9.78209 2.64589 22.6459 18 H 8.53279 4.78789 4.42589 19 H 6.39363 3.90454 3.53589 20 H 7.28359 2.64589 2.64589 21 H 7.28359 2.64589 4.42589 22 C 9.78209 3.27519 3.53589 23 C 8.53279 4.15859 3.53589 24 C 7.28359 3.27519 3.53589 -
tests/regression/Domain/6/post/test.conf.xyz
r04488a rce4487 1 1 11 2 2 Created by molecuilder on Mon May 31 19:21:12 2010 3 H 9.78209 2.64589 2.64589 4 H 9.78209 2.64589 4.42589 5 H 10.672 3.90454 3.53589 6 H 8.53279 4.78789 2.64589 7 H 8.53279 4.78789 4.42589 8 H 6.39363 3.90454 3.53589 9 H 7.28359 2.64589 2.64589 10 H 7.28359 2.64589 4.42589 11 C 9.78209 3.27519 3.53589 12 C 8.53279 4.15859 3.53589 13 C 7.28359 3.27519 3.53589 3 H 9.78209 2.64589 2.64589 4 H 9.78209 2.64589 4.42589 5 H 10.672 3.90454 3.53589 6 H 8.53279 4.78789 2.64589 7 H 8.53279 4.78789 4.42589 8 H 6.39363 3.90454 3.53589 9 H 7.28359 2.64589 2.64589 10 H 7.28359 2.64589 4.42589 11 C 9.78209 3.27519 3.53589 12 C 8.53279 4.15859 3.53589 13 C 7.28359 3.27519 3.53589 -
tests/regression/Filling/1/post/test.conf
r04488a rce4487 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 680 # check every ..th steps37 MaxMinStopStep 1350 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 680 # check every ..th steps44 InitMaxMinStopStep 1350 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 55 55 RiemannTensor 0 # (Use metric) 56 56 PsiType 0 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 680 # here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 680 # here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 680 # here: specifying maximum number of SpinDown-states57 MaxPsiDouble 1350 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 1350 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 1350 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/2/post/test.conf.xyz
r04488a rce4487 1 1 1 2 2 Created by molecuilder on Tue Oct 6 18:34:23 2009 3 H 10 10 10 3 H 10 10 10 -
tests/regression/Simple_configuration/3/post/test.conf.xyz
r04488a rce4487 1 1 1 2 2 Created by molecuilder on Tue Oct 6 18:34:23 2009 3 H 10 10 10 3 H 10 10 10 -
tests/regression/Simple_configuration/4/post/test.conf
r04488a rce4487 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 2# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 2# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 54 54 Level0Factor 2 # factor by which node number increases from S to 0 level 55 55 RiemannTensor 0 # (Use metric) 56 PsiType 0# 0 - doubly occupied, 1 - SpinUp,SpinDown57 MaxPsiDouble 2# here: specifying both maximum number of SpinUp- and -Down-states58 PsiMaxNoUp 2# here: specifying maximum number of SpinUp-states59 PsiMaxNoDown 2# here: specifying maximum number of SpinDown-states56 PsiType 1 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/4/post/test.conf.xyz
r04488a rce4487 1 1 1 2 2 Created by molecuilder on Tue Oct 6 18:31:23 2009 3 C 10 10 10 3 C 10 10 10 -
tests/regression/Simple_configuration/5/post/test.conf
r04488a rce4487 35 35 RelEpsTotalE 1e-07 # relative change in total energy 36 36 RelEpsKineticE 1e-05 # relative change in kinetic energy 37 MaxMinStopStep 0# check every ..th steps37 MaxMinStopStep 1 # check every ..th steps 38 38 MaxMinGapStopStep 1 # check every ..th steps 39 39 … … 42 42 InitRelEpsTotalE 1e-05 # relative change in total energy 43 43 InitRelEpsKineticE 0.0001 # relative change in kinetic energy 44 InitMaxMinStopStep 0# check every ..th steps44 InitMaxMinStopStep 1 # check every ..th steps 45 45 InitMaxMinGapStopStep 1 # check every ..th steps 46 46 … … 54 54 Level0Factor 2 # factor by which node number increases from S to 0 level 55 55 RiemannTensor 0 # (Use metric) 56 PsiType 0# 0 - doubly occupied, 1 - SpinUp,SpinDown56 PsiType 1 # 0 - doubly occupied, 1 - SpinUp,SpinDown 57 57 MaxPsiDouble 0 # here: specifying both maximum number of SpinUp- and -Down-states 58 58 PsiMaxNoUp 0 # here: specifying maximum number of SpinUp-states 59 PsiMaxNoDown 0# here: specifying maximum number of SpinDown-states59 PsiMaxNoDown 1 # here: specifying maximum number of SpinDown-states 60 60 AddPsis 0 # Additional unoccupied Psis for bandgap determination 61 61 -
tests/regression/Simple_configuration/8/post/test.conf.xyz
r04488a rce4487 1 1 144 2 2 Created by molecuilder on Mon May 31 18:50:20 2010 3 H 9.78209 2.64589 2.64589 4 H 9.78209 2.64589 4.42589 5 H 10.672 3.90454 3.53589 6 H 8.53279 4.78789 2.64589 7 H 8.53279 4.78789 4.42589 8 H 6.39363 3.90454 3.53589 9 H 7.28359 2.64589 2.64589 10 H 7.28359 2.64589 4.42589 11 H 0.758602 2.85714 3.86571 12 H 0.758602 2.85714 2.85714 13 H 0.758602 2.85714 5.71429 14 H 0.758602 5.71429 3.86571 15 H 0.758602 5.71429 2.85714 16 H 3.61574 0 1.00857 17 H 3.61574 0 0 18 H 3.61574 0 3.86571 19 H 3.61574 0 2.85714 20 H 3.61574 0 6.72285 21 H 3.61574 0 5.71429 22 H 3.61574 2.85714 1.00857 23 H 3.61574 2.85714 0 24 H 3.61574 2.85714 3.86571 25 H 3.61574 2.85714 2.85714 26 H 3.61574 2.85714 6.72285 27 H 3.61574 2.85714 5.71429 28 H 3.61574 2.85714 8.57143 29 H 3.61574 5.71429 1.00857 30 H 3.61574 5.71429 0 31 H 3.61574 5.71429 3.86571 32 H 3.61574 5.71429 2.85714 33 H 3.61574 5.71429 6.72285 34 H 3.61574 5.71429 5.71429 35 H 3.61574 5.71429 8.57143 36 H 3.61574 8.57143 1.00857 37 H 3.61574 8.57143 3.86571 38 H 3.61574 8.57143 2.85714 39 H 3.61574 8.57143 5.71429 40 H 6.47289 0 1.00857 41 H 6.47289 0 0 42 H 6.47289 0 3.86571 43 H 6.47289 0 2.85714 44 H 6.47289 0 6.72285 45 H 6.47289 0 5.71429 46 H 6.47289 0 9.58 47 H 6.47289 0 8.57143 48 H 6.47289 2.85714 0 49 H 6.47289 2.85714 6.72285 50 H 6.47289 2.85714 9.58 51 H 6.47289 2.85714 8.57143 52 H 6.47289 5.71429 1.00857 53 H 6.47289 5.71429 0 54 H 6.47289 5.71429 6.72285 55 H 6.47289 5.71429 5.71429 56 H 6.47289 5.71429 9.58 57 H 6.47289 5.71429 8.57143 58 H 6.47289 8.57143 1.00857 59 H 6.47289 8.57143 0 60 H 6.47289 8.57143 3.86571 61 H 6.47289 8.57143 2.85714 62 H 6.47289 8.57143 6.72285 63 H 6.47289 8.57143 5.71429 64 H 9.33003 0 1.00857 65 H 9.33003 0 0 66 H 9.33003 0 3.86571 67 H 9.33003 0 2.85714 68 H 9.33003 0 6.72285 69 H 9.33003 0 5.71429 70 H 9.33003 0 8.57143 71 H 9.33003 2.85714 0 72 H 9.33003 2.85714 6.72285 73 H 9.33003 2.85714 9.58 74 H 9.33003 2.85714 8.57143 75 H 9.33003 5.71429 0 76 H 9.33003 5.71429 6.72285 77 H 9.33003 5.71429 9.58 78 H 9.33003 5.71429 8.57143 79 H 9.33003 8.57143 1.00857 80 H 9.33003 8.57143 0 81 H 9.33003 8.57143 3.86571 82 H 9.33003 8.57143 2.85714 83 H 9.33003 8.57143 6.72285 84 H 9.33003 8.57143 5.71429 85 H 12.1872 0 1.00857 86 H 12.1872 0 0 87 H 12.1872 0 3.86571 88 H 12.1872 0 2.85714 89 H 12.1872 0 6.72285 90 H 12.1872 0 5.71429 91 H 12.1872 2.85714 1.00857 92 H 12.1872 2.85714 0 93 H 12.1872 2.85714 6.72285 94 H 12.1872 2.85714 5.71429 95 H 12.1872 5.71429 1.00857 96 H 12.1872 5.71429 0 97 H 12.1872 5.71429 3.86571 98 H 12.1872 5.71429 2.85714 99 H 12.1872 5.71429 6.72285 100 H 12.1872 5.71429 5.71429 101 C 9.78209 3.27519 3.53589 102 C 8.53279 4.15859 3.53589 103 C 7.28359 3.27519 3.53589 104 O 2.85714 0 0.504284 105 O 2.85714 0 3.36143 106 O 2.85714 0 6.21857 107 O 2.85714 2.85714 0.504284 108 O 2.85714 2.85714 3.36143 109 O 2.85714 2.85714 6.21857 110 O 2.85714 5.71429 0.504284 111 O 2.85714 5.71429 3.36143 112 O 2.85714 5.71429 6.21857 113 O 2.85714 8.57143 3.36143 114 O 5.71429 0 0.504284 115 O 5.71429 0 3.36143 116 O 5.71429 0 6.21857 117 O 5.71429 0 9.07571 118 O 5.71429 2.85714 0.504284 119 O 5.71429 2.85714 6.21857 120 O 5.71429 2.85714 9.07571 121 O 5.71429 5.71429 0.504284 122 O 5.71429 5.71429 6.21857 123 O 5.71429 5.71429 9.07571 124 O 5.71429 8.57143 0.504284 125 O 5.71429 8.57143 3.36143 126 O 5.71429 8.57143 6.21857 127 O 8.57143 0 0.504284 128 O 8.57143 0 3.36143 129 O 8.57143 0 6.21857 130 O 8.57143 0 9.07571 131 O 8.57143 2.85714 0.504284 132 O 8.57143 2.85714 9.07571 133 O 8.57143 5.71429 0.504284 134 O 8.57143 5.71429 9.07571 135 O 8.57143 8.57143 0.504284 136 O 8.57143 8.57143 3.36143 137 O 8.57143 8.57143 6.21857 138 O 11.4286 0 0.504284 139 O 11.4286 0 3.36143 140 O 11.4286 0 6.21857 141 O 11.4286 2.85714 0.504284 142 O 11.4286 2.85714 6.21857 143 O 11.4286 2.85714 9.07571 144 O 11.4286 5.71429 0.504284 145 O 11.4286 5.71429 6.21857 146 O 11.4286 8.57143 3.36143 3 H 9.78209 2.64589 2.64589 4 H 9.78209 2.64589 4.42589 5 H 10.672 3.90454 3.53589 6 H 8.53279 4.78789 2.64589 7 H 8.53279 4.78789 4.42589 8 H 6.39363 3.90454 3.53589 9 H 7.28359 2.64589 2.64589 10 H 7.28359 2.64589 4.42589 11 H 0.758602 2.85714 3.86571 12 H 0.758602 2.85714 2.85714 13 H 0.758602 2.85714 5.71429 14 H 0.758602 5.71429 3.86571 15 H 0.758602 5.71429 2.85714 16 H 3.61574 0 1.00857 17 H 3.61574 0 0 18 H 3.61574 0 3.86571 19 H 3.61574 0 2.85714 20 H 3.61574 0 6.72285 21 H 3.61574 0 5.71429 22 H 3.61574 2.85714 1.00857 23 H 3.61574 2.85714 0 24 H 3.61574 2.85714 3.86571 25 H 3.61574 2.85714 2.85714 26 H 3.61574 2.85714 6.72285 27 H 3.61574 2.85714 5.71429 28 H 3.61574 2.85714 8.57143 29 H 3.61574 5.71429 1.00857 30 H 3.61574 5.71429 0 31 H 3.61574 5.71429 3.86571 32 H 3.61574 5.71429 2.85714 33 H 3.61574 5.71429 6.72285 34 H 3.61574 5.71429 5.71429 35 H 3.61574 5.71429 8.57143 36 H 3.61574 8.57143 1.00857 37 H 3.61574 8.57143 3.86571 38 H 3.61574 8.57143 2.85714 39 H 3.61574 8.57143 5.71429 40 H 6.47289 0 1.00857 41 H 6.47289 0 0 42 H 6.47289 0 3.86571 43 H 6.47289 0 2.85714 44 H 6.47289 0 6.72285 45 H 6.47289 0 5.71429 46 H 6.47289 0 9.58 47 H 6.47289 0 8.57143 48 H 6.47289 2.85714 0 49 H 6.47289 2.85714 6.72285 50 H 6.47289 2.85714 9.58 51 H 6.47289 2.85714 8.57143 52 H 6.47289 5.71429 1.00857 53 H 6.47289 5.71429 0 54 H 6.47289 5.71429 6.72285 55 H 6.47289 5.71429 5.71429 56 H 6.47289 5.71429 9.58 57 H 6.47289 5.71429 8.57143 58 H 6.47289 8.57143 1.00857 59 H 6.47289 8.57143 0 60 H 6.47289 8.57143 3.86571 61 H 6.47289 8.57143 2.85714 62 H 6.47289 8.57143 6.72285 63 H 6.47289 8.57143 5.71429 64 H 9.33003 0 1.00857 65 H 9.33003 0 0 66 H 9.33003 0 3.86571 67 H 9.33003 0 2.85714 68 H 9.33003 0 6.72285 69 H 9.33003 0 5.71429 70 H 9.33003 0 8.57143 71 H 9.33003 2.85714 0 72 H 9.33003 2.85714 6.72285 73 H 9.33003 2.85714 9.58 74 H 9.33003 2.85714 8.57143 75 H 9.33003 5.71429 0 76 H 9.33003 5.71429 6.72285 77 H 9.33003 5.71429 9.58 78 H 9.33003 5.71429 8.57143 79 H 9.33003 8.57143 1.00857 80 H 9.33003 8.57143 0 81 H 9.33003 8.57143 3.86571 82 H 9.33003 8.57143 2.85714 83 H 9.33003 8.57143 6.72285 84 H 9.33003 8.57143 5.71429 85 H 12.1872 0 1.00857 86 H 12.1872 0 0 87 H 12.1872 0 3.86571 88 H 12.1872 0 2.85714 89 H 12.1872 0 6.72285 90 H 12.1872 0 5.71429 91 H 12.1872 2.85714 1.00857 92 H 12.1872 2.85714 0 93 H 12.1872 2.85714 6.72285 94 H 12.1872 2.85714 5.71429 95 H 12.1872 5.71429 1.00857 96 H 12.1872 5.71429 0 97 H 12.1872 5.71429 3.86571 98 H 12.1872 5.71429 2.85714 99 H 12.1872 5.71429 6.72285 100 H 12.1872 5.71429 5.71429 101 C 9.78209 3.27519 3.53589 102 C 8.53279 4.15859 3.53589 103 C 7.28359 3.27519 3.53589 104 O 2.85714 0 0.504284 105 O 2.85714 0 3.36143 106 O 2.85714 0 6.21857 107 O 2.85714 2.85714 0.504284 108 O 2.85714 2.85714 3.36143 109 O 2.85714 2.85714 6.21857 110 O 2.85714 5.71429 0.504284 111 O 2.85714 5.71429 3.36143 112 O 2.85714 5.71429 6.21857 113 O 2.85714 8.57143 3.36143 114 O 5.71429 0 0.504284 115 O 5.71429 0 3.36143 116 O 5.71429 0 6.21857 117 O 5.71429 0 9.07571 118 O 5.71429 2.85714 0.504284 119 O 5.71429 2.85714 6.21857 120 O 5.71429 2.85714 9.07571 121 O 5.71429 5.71429 0.504284 122 O 5.71429 5.71429 6.21857 123 O 5.71429 5.71429 9.07571 124 O 5.71429 8.57143 0.504284 125 O 5.71429 8.57143 3.36143 126 O 5.71429 8.57143 6.21857 127 O 8.57143 0 0.504284 128 O 8.57143 0 3.36143 129 O 8.57143 0 6.21857 130 O 8.57143 0 9.07571 131 O 8.57143 2.85714 0.504284 132 O 8.57143 2.85714 9.07571 133 O 8.57143 5.71429 0.504284 134 O 8.57143 5.71429 9.07571 135 O 8.57143 8.57143 0.504284 136 O 8.57143 8.57143 3.36143 137 O 8.57143 8.57143 6.21857 138 O 11.4286 0 0.504284 139 O 11.4286 0 3.36143 140 O 11.4286 0 6.21857 141 O 11.4286 2.85714 0.504284 142 O 11.4286 2.85714 6.21857 143 O 11.4286 2.85714 9.07571 144 O 11.4286 5.71429 0.504284 145 O 11.4286 5.71429 6.21857 146 O 11.4286 8.57143 3.36143 -
tests/regression/testsuite-fragmentation.at
r04488a rce4487 12 12 AT_SETUP([Fragmentation - Fragmentation]) 13 13 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/2/pre/test.conf .], 0) 14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id0 --distance 1.55 --order 2], 0, [ignore], [ignore])14 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0 --distance 1.55 --order 2], 0, [ignore], [ignore]) 15 15 AT_CHECK([ls -l BondFragment*.conf | wc -l], 0, [5 16 16 ], [ignore]) … … 21 21 AT_SETUP([Fragmentation - BROKEN: Fragmentation is at MaxOrder]) 22 22 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Fragmentation/3/pre/test.conf .], 0) 23 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id0 --distance 1.55 --order 2], 0, [ignore], [ignore])24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f ./BondFragment --molecule-by-id0 --distance 1.55 --order 2], [ignore], [ignore], [ignore])23 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0 --distance 1.55 --order 2], 0, [ignore], [ignore]) 24 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -v 1 -f 0 --distance 1.55 --order 2], [ignore], [ignore], [ignore]) 25 25 AT_CLEANUP -
tests/regression/testsuite-simple_configuration.at
r04488a rce4487 52 52 AT_SETUP([Simple configuration - invalid commands on empty configs]) 53 53 AT_KEYWORDS([configuration]) 54 AT_CHECK([../../molecuilder empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 54 AT_CHECK([../../molecuilder empty.conf -e ${abs_top_srcdir}/src/ -t -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 55 AT_CHECK([fgrep -c "Not enough" stderr], 0, [1 56 ], [ignore]) 55 57 AT_CLEANUP 56 58 … … 59 61 AT_KEYWORDS([configuration]) 60 62 AT_CHECK([/bin/cp -f ${abs_top_srcdir}/${AUTOTEST_PATH}/Simple_configuration/7/pre/test.conf .], 0) 61 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t], 134, [ignore], [stderr]) 62 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 63 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 64 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 134, [ignore], [stderr]) 65 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 134, [ignore], [stderr]) 66 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 134, [ignore], [stderr]) 67 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 134, [ignore], [stderr]) 68 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 134, [ignore], [stderr]) 69 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -T -u], 134, [ignore], [stderr]) 70 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -u], 134, [ignore], [stderr]) 63 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -t], 255, [ignore], [stderr]) 64 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 65 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -s -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 66 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 67 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 68 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 69 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -E -c -b -a -U -T -u], 255, [ignore], [stderr]) 70 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 71 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -c -b -a -U -T -u], 255, [ignore], [stderr]) 72 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 73 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -b -a -U -T -u], 255, [ignore], [stderr]) 74 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 75 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -a -U -T -u], 255, [ignore], [stderr]) 76 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 77 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -U -T -u], 255, [ignore], [stderr]) 78 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 79 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -T -u], 255, [ignore], [stderr]) 80 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 81 AT_CHECK([../../molecuilder test.conf -e ${abs_top_srcdir}/src/ -u], 255, [ignore], [stderr]) 82 AT_CHECK([fgrep -c "CRITICAL: Not enough" stderr], 0, [ignore], [ignore]) 71 83 AT_CLEANUP 72 84 -
tests/regression/testsuite-standard_options.at
r04488a rce4487 18 18 AT_SETUP([Standard Options - no element database]) 19 19 AT_KEYWORDS([options]) 20 AT_CHECK([../../molecuilder -e], 134, [ignore], [stderr]) 20 AT_CHECK([../../molecuilder -e], 255, [ignore], [stderr]) 21 AT_CHECK([fgrep "Not enough or invalid arguments" stderr], 0, [ignore], [ignore]) 21 22 AT_CLEANUP 22 23
Note:
See TracChangeset
for help on using the changeset viewer.