source: src/joiner.cpp@ eeec8f

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 eeec8f was eeec8f, checked in by Frederik Heber <heber@…>, 16 years ago

HessianMatrix implemented fully, but not yet working, probably due to wrong matrix generation in script file (convertHessian.py)

HessianMatrix::IsSymmetric was though to be needed, but is NOT. As we regard full matrices, we don't need to add onto mirrored indices as well
Joiner and Analyzer have seen some small changes and bugfixes: NoHessian was not also always looked at when needed and so on

  • Property mode set to 100644
File size: 9.6 KB
Line 
1/** \file joiner.cpp
2 *
3 * Takes evaluated fragments (energy and forces) and by reading the factors files determines total energy
4 * and each force for the whole molecule.
5 *
6 */
7
8//============================ INCLUDES ===========================
9
10#include "datacreator.hpp"
11#include "helpers.hpp"
12#include "parser.hpp"
13#include "periodentafel.hpp"
14
15//============================== MAIN =============================
16
17int main(int argc, char **argv)
18{
19 periodentafel *periode = NULL; // and a period table of all elements
20 EnergyMatrix Energy;
21 EnergyMatrix EnergyFragments;
22
23 EnergyMatrix Hcorrection;
24 EnergyMatrix HcorrectionFragments;
25
26 ForceMatrix Force;
27 ForceMatrix ForceFragments;
28
29 HessianMatrix Hessian;
30 HessianMatrix HessianFragments;
31
32 ForceMatrix Shielding;
33 ForceMatrix ShieldingPAS;
34 ForceMatrix ShieldingFragments;
35 ForceMatrix ShieldingPASFragments;
36 KeySetsContainer KeySet;
37 stringstream prefix;
38 char *dir = NULL;
39 bool NoHCorrection = false;
40 bool NoHessian = false;
41
42 cout << "Joiner" << endl;
43 cout << "======" << endl;
44
45 // Get the command line options
46 if (argc < 3) {
47 cout << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl;
48 cout << "<inputdir>\ttherein the output of a molecuilder fragmentation is expected, each fragment with a subdir containing an energy.all and a forces.all file." << endl;
49 cout << "<prefix>\tprefix of energy and forces file." << endl;
50 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
51 return 1;
52 } else {
53 dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir");
54 strcpy(dir, "/");
55 strcat(dir, argv[2]);
56 }
57 if (argc > 3) {
58 periode = new periodentafel;
59 periode->LoadPeriodentafel(argv[3]);
60 }
61
62 // Test the given directory
63 if (!TestParams(argc, argv))
64 return 1;
65
66 // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
67
68 // ------------- Parse through all Fragment subdirs --------
69 if (!Energy.ParseFragmentMatrix(argv[1], dir, EnergySuffix, 0,0)) return 1;
70 if (!Hcorrection.ParseFragmentMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0)) {
71 NoHCorrection = true;
72 cout << "No HCorrection matrices found, skipping these." << endl;
73 }
74 if (!Force.ParseFragmentMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1;
75 if (!Hessian.ParseFragmentMatrix(argv[1], dir, HessianSuffix, 0,0)) {
76 NoHessian = true;
77 cout << "No hessian matrices found, skipping these." << endl;
78 }
79 if (periode != NULL) { // also look for PAS values
80 if (!Shielding.ParseFragmentMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1;
81 if (!ShieldingPAS.ParseFragmentMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1;
82 }
83
84 // ---------- Parse the TE Factors into an array -----------------
85 if (!Energy.InitialiseIndices()) return 1;
86 if (!NoHCorrection)
87 Hcorrection.InitialiseIndices();
88
89 // ---------- Parse the Force indices into an array ---------------
90 if (!Force.ParseIndices(argv[1])) return 1;
91
92 // ---------- Parse the Hessian (=force) indices into an array ---------------
93 if (!NoHessian)
94 if (!Hessian.InitialiseIndices((class MatrixContainer *)&Force)) return 1;
95
96 // ---------- Parse the shielding indices into an array ---------------
97 if (periode != NULL) { // also look for PAS values
98 if(!Shielding.ParseIndices(argv[1])) return 1;
99 if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
100 }
101
102 // ---------- Parse the KeySets into an array ---------------
103 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
104
105 if (!KeySet.ParseManyBodyTerms()) return 1;
106 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1;
107 if (!NoHCorrection)
108 HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter);
109 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
110 if (!NoHessian)
111 if (!HessianFragments.AllocateMatrix(Hessian.Header, Hessian.MatrixCounter, Hessian.RowCounter, Hessian.ColumnCounter)) return 1;
112 if (periode != NULL) { // also look for PAS values
113 if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
114 if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
115 }
116
117 // ----------- Resetting last matrices (where full QM values are stored right now)
118 if(!Energy.SetLastMatrix(0., 0)) return 1;
119 if(!Force.SetLastMatrix(0., 2)) return 1;
120 if (!NoHessian)
121 if (!Hessian.SetLastMatrix(0., 0)) return 1;
122 if (periode != NULL) { // also look for PAS values
123 if(!Shielding.SetLastMatrix(0., 2)) return 1;
124 if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1;
125 }
126
127 // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++
128
129 // --------- sum up and write for each order----------------
130 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
131 // --------- sum up energy --------------------
132 cout << "Summing energy of order " << BondOrder+1 << " ..." << endl;
133 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
134 if (!NoHCorrection) {
135 HcorrectionFragments.SumSubManyBodyTerms(Hcorrection, KeySet, BondOrder);
136 if (!Energy.SumSubEnergy(EnergyFragments, &HcorrectionFragments, KeySet, BondOrder, 1.)) return 1;
137 Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.);
138 } else
139 if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1;
140 // --------- sum up Forces --------------------
141 cout << "Summing forces of order " << BondOrder+1 << " ..." << endl;
142 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
143 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1;
144 // --------- sum up Hessian --------------------
145 if (!NoHessian) {
146 cout << "Summing Hessian of order " << BondOrder+1 << " ..." << endl;
147 if (!HessianFragments.SumSubManyBodyTerms(Hessian, KeySet, BondOrder)) return 1;
148 if (!Hessian.SumSubHessians(HessianFragments, KeySet, BondOrder, 1.)) return 1;
149 }
150 if (periode != NULL) { // also look for PAS values
151 cout << "Summing shieldings of order " << BondOrder+1 << " ..." << endl;
152 if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1;
153 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1;
154 if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1;
155 if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder, 1.)) return 1;
156 }
157
158 // --------- write the energy and forces file --------------------
159 prefix.str(" ");
160 prefix << dir << OrderSuffix << (BondOrder+1);
161 cout << "Writing files " << argv[1] << prefix.str() << ". ..." << endl;
162 // energy
163 if (!Energy.WriteLastMatrix(argv[1], (prefix.str()).c_str(), EnergySuffix)) return 1;
164 // forces
165 if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1;
166 // hessian
167 if (!NoHessian)
168 if (!Hessian.WriteLastMatrix(argv[1], (prefix.str()).c_str(), HessianSuffix)) return 1;
169 // shieldings
170 if (periode != NULL) { // also look for PAS values
171 if (!Shielding.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingSuffix)) return 1;
172 if (!ShieldingPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingPASSuffix)) return 1;
173 }
174 }
175 // fragments
176 prefix.str(" ");
177 prefix << dir << EnergyFragmentSuffix;
178 if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
179 if (!NoHCorrection) {
180 prefix.str(" ");
181 prefix << dir << HcorrectionFragmentSuffix;
182 if (!HcorrectionFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
183 }
184 prefix.str(" ");
185 prefix << dir << ForceFragmentSuffix;
186 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
187 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1;
188 if (!NoHessian) {
189 prefix.str(" ");
190 prefix << dir << HessianFragmentSuffix;
191 if (!HessianFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
192 }
193 if (periode != NULL) { // also look for PAS values
194 prefix.str(" ");
195 prefix << dir << ShieldingFragmentSuffix;
196 if (!ShieldingFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
197 prefix.str(" ");
198 prefix << dir << ShieldingPASFragmentSuffix;
199 if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
200 }
201
202 // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds
203 if (!Energy.WriteLastMatrix(argv[1], dir, EnergyFragmentSuffix)) return 1;
204 if (!NoHCorrection) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix);
205 if (!Force.WriteLastMatrix(argv[1], dir, ForceFragmentSuffix)) return 1;
206 if (!NoHessian)
207 if (!Hessian.WriteLastMatrix(argv[1], dir, HessianFragmentSuffix)) return 1;
208 if (periode != NULL) { // also look for PAS values
209 if (!Shielding.WriteLastMatrix(argv[1], dir, ShieldingFragmentSuffix)) return 1;
210 if (!ShieldingPAS.WriteLastMatrix(argv[1], dir, ShieldingPASFragmentSuffix)) return 1;
211 }
212
213 // exit
214 delete(periode);
215 Free((void **)&dir, "main: *dir");
216 cout << "done." << endl;
217 return 0;
218};
219
220//============================ END ===========================
Note: See TracBrowser for help on using the repository browser.