source: src/joiner.cpp@ 6b33de

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 6b33de was cf2de5, checked in by Frederik Heber <heber@…>, 17 years ago

one lousy space added

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