source: src/builder.cpp@ bcf653

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since bcf653 was bcf653, checked in by Frederik Heber <heber@…>, 15 years ago

Added copyright note to each .cpp file and an extensive one to builder.cpp.

  • Property mode set to 100755
File size: 8.6 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8 /** \file builder.cpp
9 *
10 * date: Jan 1, 2007
11 * author: heber
12 *
13 */
14
15/*! \page Copyright notice
16 *
17 * MoleCuilder - to create and alter molecular systems
18 * Copyright (C) 2010 University Bonn
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 *
34 */
35
36/*! \mainpage MoleCuilder - a molecular set builder
37 *
38 * This introductory shall briefly make acquainted with the program, helping in installing and a first run.
39 *
40 * \section about About the Program
41 *
42 * MoleCuilder is a program, written entirely in C++, that enables the construction of a coordinate set for the
43 * atoms making up an molecule. It allows for both building of simple molecules by adding atom-wise giving bond
44 * angles and distances or absolute coordinates, but also using them as templates. Regions can be specified and
45 * ordered to be filled with a molecule in a certain manner. Greater conglomerations of molecules can be tesselated
46 * and recognized as a region themselves to be subsequently surrounded by other (surface solvated) molecules.
47 * In the end, MoleCuilder allows the construction of arbitrary nano structures, whether they be crystalline or
48 * amorphic in nature.
49 *
50 *
51 * \section install Installation
52 *
53 * Installation should without problems succeed as follows:
54 * -# ./configure (or: mkdir build;mkdir run;cd build; ../configure --bindir=../run)
55 * -# make
56 * -# make install
57 *
58 * Further useful commands are
59 * -# make clean uninstall: deletes .o-files and removes executable from the given binary directory\n
60 * -# make doxygen-doc: Creates these html pages out of the documented source
61 * -# make check: Runs an extensive set of unit tests and a testsuite which also gives a good overview on the set of
62 * functions.
63 *
64 * \section run Running
65 *
66 * The program can be executed by running: ./molecuilder
67 *
68 * MoleCuilder has three interfaces at your disposal:
69 * -# Textmenu: A simple interactive console-based menu, where awaits your choices and inputs in order to set atoms
70 * as you like
71 * -# CommandLineUI: Every command can also be chained up as a sequence of actions on the command line to be executed
72 * with any user interaction.
73 * -# GraphicalUI: A graphical user interface that also display the molecular structure being built and lots of other
74 * informations to ease the construction of bigger geometries.
75 *
76 * The supported output formats right now are:
77 * -# mpqc: Configuration files of the Massively Parallel Quantum Chemistry package (Sandia labs)
78 * -# pcp: Configuration files of the Parallel Car-Parrinello program (Institute for Numerical Simulation)
79 * -# tremolo: Configuration files of TREMOLO (Institute for Numerical Simulation)
80 * -# xyz: the most basic format for the 3d arrangement of atoms consisting of a list of element and 3 coordinates.
81 *
82 */
83
84// include config.h
85#ifdef HAVE_CONFIG_H
86#include <config.h>
87#endif
88
89#include "Helpers/MemDebug.hpp"
90
91#include "bondgraph.hpp"
92#include "CommandLineParser.hpp"
93#include "config.hpp"
94#include "Helpers/Log.hpp"
95#include "molecule.hpp"
96#include "periodentafel.hpp"
97#include "tesselationhelpers.hpp"
98#include "UIElements/UIFactory.hpp"
99#include "UIElements/TextUI/TextUIFactory.hpp"
100#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
101#ifdef USE_GUI_QT
102#include "UIElements/QT4/QTUIFactory.hpp"
103#endif
104#include "UIElements/MainWindow.hpp"
105#include "UIElements/Dialog.hpp"
106#include "Menu/ActionMenuItem.hpp"
107#include "Helpers/Verbose.hpp"
108#include "World.hpp"
109
110#include "Actions/ActionRegistry.hpp"
111#include "Actions/ActionHistory.hpp"
112#include "Actions/MapOfActions.hpp"
113
114#include "Parser/ChangeTracker.hpp"
115#include "Parser/FormatParserStorage.hpp"
116
117#include "UIElements/UIFactory.hpp"
118#include "UIElements/TextUI/TextUIFactory.hpp"
119#include "UIElements/CommandLineUI/CommandLineUIFactory.hpp"
120#include "UIElements/MainWindow.hpp"
121#include "UIElements/Dialog.hpp"
122
123#include "version.h"
124
125
126/********************************************** Main routine **************************************/
127
128void cleanUp(){
129 FormatParserStorage::purgeInstance();
130 ChangeTracker::purgeInstance();
131 World::purgeInstance();
132 logger::purgeInstance();
133 errorLogger::purgeInstance();
134 UIFactory::purgeInstance();
135 MapOfActions::purgeInstance();
136 CommandLineParser::purgeInstance();
137 ActionRegistry::purgeInstance();
138 ActionHistory::purgeInstance();
139#ifdef LOG_OBSERVER
140 cout << observerLog().getLog();
141#endif
142 Memory::getState();
143}
144
145void dumpMemory(){
146 ofstream ost("molecuilder.memdump");
147 Memory::dumpMemory(ost);
148}
149
150int main(int argc, char **argv)
151{
152 // while we are non interactive, we want to abort from asserts
153 ASSERT_DO(Assert::Abort);
154 ASSERT_HOOK(dumpMemory);
155 string line;
156 char **Arguments = NULL;
157 int ArgcSize = 0;
158 int ExitFlag = 0;
159 bool ArgumentsCopied = false;
160 std::string BondGraphFileName("\n");
161
162 // print version check and copyright notice
163 cout << ESPACKVersion << endl;
164 cout << "MoleCuilder comes with ABSOLUTELY NO WARRANTY; for details type" << endl;
165 cout << "`" << argv[0] << " --help-warranty'." << endl;
166 cout << "This is free software, and you are welcome to redistribute it" << endl;
167 cout << "under certain conditions; type `" << argv[0] << " --help-redistribute'" << endl;
168 cout << "for details." << endl;
169
170 setVerbosity(0);
171 // need to init the history before any action is created
172 ActionHistory::init();
173
174 // from this moment on, we need to be sure to deeinitialize in the correct order
175 // this is handled by the cleanup function
176 atexit(cleanUp);
177
178 // Parse command line options and if present create respective UI
179 {
180 // construct bond graph
181 if (World::getInstance().getConfig()->BG == NULL) {
182 World::getInstance().getConfig()->BG = new BondGraph(World::getInstance().getConfig()->GetIsAngstroem());
183 if (World::getInstance().getConfig()->BG->LoadBondLengthTable(BondGraphFileName)) {
184 DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
185 } else {
186 DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
187 }
188 }
189 // handle remaining arguments by CommandLineParser
190 if (argc>1) {
191 MapOfActions::getInstance().AddOptionsToParser();
192 map <std::string, std::string> ShortFormToActionMap = MapOfActions::getInstance().getShortFormToActionMap();
193 CommandLineParser::getInstance().Run(argc,argv, ShortFormToActionMap);
194 DoLog(0) && (Log() << Verbose(0) << "Setting UI to CommandLine." << endl);
195 UIFactory::registerFactory(new CommandLineUIFactory::description());
196 UIFactory::makeUserInterface("CommandLine");
197 } else {
198 // In the interactive mode, we can leave the user the choice in case of error
199 ASSERT_DO(Assert::Ask);
200 #ifdef USE_GUI_QT
201 DoLog(0) && (Log() << Verbose(0) << "Setting UI to QT4." << endl);
202 UIFactory::registerFactory(new QTUIFactory::description());
203 UIFactory::makeUserInterface("QT4");
204 #else
205 DoLog(0) && (Log() << Verbose(0) << "Setting UI to Text." << endl);
206 cout << ESPACKVersion << endl;
207 UIFactory::registerFactory(new TextUIFactory::description());
208 UIFactory::makeUserInterface("Text");
209 #endif
210 }
211 }
212
213 {
214 MainWindow *mainWindow = UIFactory::getInstance().makeMainWindow();
215 mainWindow->display();
216 delete mainWindow;
217 }
218
219 FormatParserStorage::getInstance().SaveAll();
220 ChangeTracker::getInstance().saveStatus();
221
222 // free the new argv
223 if (ArgumentsCopied) {
224 for (int i=0; i<ArgcSize;i++)
225 delete[](Arguments[i]);
226 delete[](Arguments);
227 }
228 //delete[](ConfigFileName);
229
230 ExitFlag = World::getInstance().getExitFlag();
231 return (ExitFlag == 1 ? 0 : ExitFlag);
232}
233
234/********************************************** E N D **************************************************/
Note: See TracBrowser for help on using the repository browser.