source: src/joiner.cpp@ 1b62f3

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 1b62f3 was 68cb0f, checked in by Frederik Heber <heber@…>, 17 years ago

introduced shieldings to analyzer and joiner

both now handle pcp.sigma_all...csv files just as pcp.forces.all. Therefore the data format in pcp/perturbed.c was adapted a bit, as we need a header.
periodentafel.hpp got periodentafel and element class from molecules.hpp

  • Property mode set to 100644
File size: 7.0 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 ForceMatrix Force;
22 EnergyMatrix EnergyFragments;
23 ForceMatrix ForceFragments;
24 ForceMatrix Shielding;
25 ForceMatrix ShieldingPAS;
26 ForceMatrix ShieldingFragments;
27 ForceMatrix ShieldingPASFragments;
28 KeySetsContainer KeySet;
29 stringstream prefix;
30
31 cout << "Joiner" << endl;
32 cout << "======" << endl;
33
34 // Get the command line options
35 if (argc < 3) {
36 cout << "Usage: " << argv[0] << " <inputdir> <prefix> [elementsdb]" << endl;
37 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;
38 cout << "<prefix>\tprefix of energy and forces file." << endl;
39 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl;
40 return 1;
41 }
42 if (argc > 3) {
43 periode = new periodentafel;
44 periode->LoadPeriodentafel(argv[3]);
45 }
46
47 // Test the given directory
48 if (!TestParams(argc, argv))
49 return 1;
50
51 // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
52
53 // ------------- Parse through all Fragment subdirs --------
54 if (!Energy.ParseMatrix(argv[1], argv[2], EnergySuffix, 0,0)) return 1;
55 if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix, 0,0)) return 1;
56 if (periode != NULL) { // also look for PAS values
57 if (!Shielding.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1;
58 if (!ShieldingPAS.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1;
59 }
60
61 // ---------- Parse the TE Factors into an array -----------------
62 if (!Energy.ParseIndices()) return 1;
63
64 // ---------- Parse the Force indices into an array ---------------
65 if (!Force.ParseIndices(argv[1])) return 1;
66
67 // ---------- Parse the shielding indices into an array ---------------
68 if (periode != NULL) { // also look for PAS values
69 if(!Shielding.ParseIndices(argv[1])) return 1;
70 if(!ShieldingPAS.ParseIndices(argv[1])) return 1;
71 }
72
73 // ---------- Parse the KeySets into an array ---------------
74 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
75
76 if (!KeySet.ParseManyBodyTerms()) return 1;
77 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1;
78 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
79 if (periode != NULL) { // also look for PAS values
80 if (!ShieldingFragments.AllocateMatrix(Shielding.Header, Shielding.MatrixCounter, Shielding.RowCounter, Shielding.ColumnCounter)) return 1;
81 if (!ShieldingPASFragments.AllocateMatrix(ShieldingPAS.Header, ShieldingPAS.MatrixCounter, ShieldingPAS.RowCounter, ShieldingPAS.ColumnCounter)) return 1;
82 }
83
84 // ----------- Resetting last matrices (where full QM values are stored right now)
85 if(!Energy.SetLastMatrix(0., 0)) return 1;
86 if(!Force.SetLastMatrix(0., 2)) return 1;
87 if (periode != NULL) { // also look for PAS values
88 if(!Shielding.SetLastMatrix(0., 0)) return 1;
89 if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1;
90 }
91
92 // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++
93
94 // --------- sum up and write for each order----------------
95 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
96 // --------- sum up energy --------------------
97 cout << "Summing energy of order " << BondOrder+1 << " ..." << endl;
98 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
99 if (!Energy.SumSubEnergy(EnergyFragments, KeySet, BondOrder)) return 1;
100 // --------- sum up Forces --------------------
101 cout << "Summing forces of order " << BondOrder+1 << " ..." << endl;
102 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
103 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder)) return 1;
104 if (periode != NULL) { // also look for PAS values
105 cout << "Summing shieldings of order " << BondOrder+1 << " ..." << endl;
106 if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1;
107 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder)) return 1;
108 if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1;
109 if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder)) return 1;
110 }
111
112 // --------- write the energy and forces file --------------------
113 prefix.str(" ");
114 prefix << argv[2] << OrderSuffix << (BondOrder+1);
115 cout << "Writing files " << argv[1] << prefix.str() << ". ..." << endl;
116 // energy
117 if (!Energy.WriteLastMatrix(argv[1], (prefix.str()).c_str(), EnergySuffix)) return 1;
118 // forces
119 if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1;
120 // shieldings
121 if (periode != NULL) { // also look for PAS values
122 if (!Shielding.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingSuffix)) return 1;
123 if (!ShieldingPAS.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ShieldingPASSuffix)) return 1;
124 }
125 }
126 // fragments
127 prefix.str(" ");
128 prefix << argv[2] << EnergyFragmentSuffix;
129 if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
130 prefix.str(" ");
131 prefix << argv[2] << ForceFragmentSuffix;
132 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
133 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1;
134 if (periode != NULL) { // also look for PAS values
135 prefix.str(" ");
136 prefix << argv[2] << ShieldingFragmentSuffix;
137 if (!ShieldingFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
138 prefix.str(" ");
139 prefix << argv[2] << ShieldingPASFragmentSuffix;
140 if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
141 }
142
143 // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds
144 if (!Energy.WriteLastMatrix(argv[1], argv[2], EnergyFragmentSuffix)) return 1;
145 if (!Force.WriteLastMatrix(argv[1], argv[2], ForceFragmentSuffix)) return 1;
146 if (periode != NULL) { // also look for PAS values
147 if (!Shielding.WriteLastMatrix(argv[1], argv[2], ShieldingFragmentSuffix)) return 1;
148 if (!ShieldingPAS.WriteLastMatrix(argv[1], argv[2], ShieldingPASFragmentSuffix)) return 1;
149 }
150
151 // exit
152 delete(periode);
153 cout << "done." << endl;
154 return 0;
155};
156
157//============================ END ===========================
Note: See TracBrowser for help on using the repository browser.