source: src/joiner.cpp@ d2a294

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 d2a294 was 2459b1, checked in by Frederik Heber <heber@…>, 17 years ago

ForcesFile and TEFactors are _needed_, reincorporated. UniqueFragments structure is now in BOSSANOVA

ForcesFile is again written, as we need it for the hydrogen not coming saturation (forces!)
TEFactors are back, as despite my notion they are needed in the evaluation
UniqueFragments structure is shifted from PowerSetGenerator to FragmentBOSSANOVA. Actually only for the labels - however, the if was changed to test the real indices (which are also always the same, which is better for adaptive runs) - but might be more useful there still.
analyzer and joiner again parse indices.

  • Property mode set to 100644
File size: 5.1 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 "helpers.hpp"
11#include "parser.hpp"
12
13//============================== MAIN =============================
14
15int main(int argc, char **argv)
16{
17 EnergyMatrix Energy;
18 ForceMatrix Force;
19 EnergyMatrix EnergyFragments;
20 ForceMatrix ForceFragments;
21 KeySetsContainer KeySet;
22 stringstream prefix;
23
24 cout << "Joiner" << endl;
25 cout << "======" << endl;
26
27 // Get the command line options
28 if (argc < 3) {
29 cout << "Usage: " << argv[0] << " <inputdir> <prefix>" << endl;
30 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;
31 cout << "<prefix>\tprefix of energy and forces file." << endl;
32 return 1;
33 }
34
35 // Test the given directory
36 if (!TestParams(argc, argv))
37 return 1;
38
39 // +++++++++++++++++ PARSING +++++++++++++++++++++++++++++++
40
41 // ------------- Parse through all Fragment subdirs --------
42 if (!Energy.ParseMatrix(argv[1], argv[2], EnergySuffix,0,0)) return 1;
43 //if (!ParseSubEnergies(argv[1], argv[2], EnergySuffix, data.EnergyHeader, data.Energies, data.EnergyIndices, data.LevelCounter, data.ColumnCounter, data.FragmentCounter)) return 1;
44 if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix, 0,0)) return 1;
45 //if (!ParseSubForces(argv[1], argv[2], ForcesSuffix, data.ForcesHeader, data.Forces, data.AtomCounter, data.Column2Counter, data.FragmentCounter)) return 1;
46
47 // ---------- Parse the TE Factors into an array -----------------
48 if (!Energy.ParseIndices()) return 1;
49
50 // ---------- Parse the Force indices into an array ---------------
51 if (!Force.ParseIndices(argv[1])) return 1;
52 //if (!ParseForceIndices(argv[1], data.ForcesIndices, data.AtomCounter, data.FragmentCounter)) return 1;
53
54 // ---------- Parse the KeySets into an array ---------------
55 if (!KeySet.ParseKeySets(argv[1], Force.RowCounter, Force.MatrixCounter)) return 1;
56 //if (!ParseKeySets(argv[1], data.KeySets, data.AtomCounter, data.FragmentCounter)) return 1;
57
58 if (!KeySet.ParseManyBodyTerms()) return 1;
59 //if (!ParseManyBodyTerms(data.Order, data.OrderSet, data.FragmentsPerOrder, data.KeySets, data.AtomCounter, data.FragmentCounter)) return 1;
60 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1;
61 //if (!ParseSubEnergies(argv[1], argv[2], EnergyFragmentSuffix, data.EnergyHeader, data.EnergyFragments, data.EnergyFragmentIndices, data.LevelFragmentCounter, data.ColumnFragmentCounter, data.FragmentCounter)) return 1;
62 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1;
63 //if (!ParseSubForces(argv[1], argv[2], ForceFragmentSuffix, data.ForcesHeader, data.ForceFragments, data.AtomCounter, data.Column2Counter, data.FragmentCounter)) return 1;
64
65 // ----------- Resetting last matrices (where full QM values are stored right now)
66 if(!Energy.SetLastMatrix(0., 0)) return 1;
67 if(!Force.SetLastMatrix(0., 2)) return 1;
68
69 // +++++++++++++++++ SUMMING +++++++++++++++++++++++++++++++
70
71 // --------- sum up and write for each order----------------
72 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
73 // --------- sum up energy --------------------
74 cout << "Summing energy of order " << BondOrder+1 << " ..." << endl;
75 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1;
76 if (!Energy.SumSubEnergy(EnergyFragments, KeySet, BondOrder)) return 1;
77 // --------- sum up Forces --------------------
78 cout << "Summing forces of order " << BondOrder+1 << " ..." << endl;
79 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1;
80 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder)) return 1;
81
82 // --------- write the energy and forces file --------------------
83 prefix.str(" ");
84 prefix << argv[2] << OrderSuffix << (BondOrder+1);
85 cout << "Writing files " << argv[1] << prefix.str() << ". ..." << endl;
86 // energy
87 if (!Energy.WriteLastMatrix(argv[1], (prefix.str()).c_str(), EnergySuffix)) return 1;
88 // forces
89 if (!Force.WriteLastMatrix(argv[1], (prefix.str()).c_str(), ForcesSuffix)) return 1;
90 }
91 // fragments
92 prefix.str(" ");
93 prefix << argv[2] << EnergyFragmentSuffix;
94 if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
95 prefix.str(" ");
96 prefix << argv[2] << ForceFragmentSuffix;
97 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1;
98
99 // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds
100 if (!Energy.WriteLastMatrix(argv[1], argv[2], EnergyFragmentSuffix)) return 1;
101 if (!Force.WriteLastMatrix(argv[1], argv[2], ForceFragmentSuffix)) return 1;
102
103 // exit
104 cout << "done." << endl;
105 return 0;
106};
107
108//============================ END ===========================
Note: See TracBrowser for help on using the repository browser.