source: src/joiner.cpp@ bd6579

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

HUGE REWRITE to allow for adaptive increase of the bond order, first working commit

Lots of code was thrown out:
-BottomUp, TopDown and GetAtomicFragments
-TEFactors are now used as "CreationCounters", i.e. the count how often a fragment as been created (ideal would be only once)
-ReduceToUniqueOnes and stuff all thrown out, since they are out-dated since use of hash table
Other changes:
-CreateListofUniqueFragments renamed to PowerSetGenerator
-PowerSetGenerator goes not over all reachable roots, but one given by calling function FragmentBOSSANOVA
-FragmentBOSSANOVA loops over all possible root sites and hands this over to PowerSetGenerator
-by the virtue of the hash table it is not important anymore whether created keysets are unique or not, as this is recognized in log(n). Hence, the label < label is not important anymore (and not applicable in an adaptive scheme with old, parsed keysets and unknown labels) (THIS IS HOWEVER NOT DONE YET!)
The setup is then as follows:

  1. FragmentMolecule
    1. parses adjacency, keysets and orderatsite files
    2. performs DFS to find connected subgraphs (to leave this in was a design decision: might be useful later)
    3. a RootStack is created for every subgraph (here, later we implement the "update 10 sites with highest energy contribution", and that's why this consciously not done in the following loop)
    4. in a loop over all subgraphs

d1. calls FragmentBOSSANOVA with this RootStack and within the subgraph molecule structure
d2. creates molecule (fragment)s from the returned keysets (StoreFragmentFromKeySet)

  1. combines the generated molecule lists from all subgraphs
  2. saves to disk: fragment configs, adjacency, orderatsite, keyset files
  1. FragmentBOSSANOVA
    1. constructs a complete keyset of the molecule
    2. In a loop over all possible roots from the given rootstack

b1. increases order of root site
b2. calls PowerSetGenerator with this order, the complete keyset and the rootkeynr
b3. for all consecutive lower levels PowerSetGenerator is called with the suborder, the higher order keyset as the restricted one and each site in the set as the root)
b4. these are merged into a fragment list of keysets

  1. All fragment lists (for all orders, i.e. from all destination fields) are merged into one list for return
  1. PowerSetGenerator
    1. initialises UniqueFragments structure
    2. fills edge list via BFS
    3. creates the fragment by calling recursive function SPFragmentGenerator with UniqueFragments structure, 0 as root distance, the edge set, its dimension and the current suborder
    4. Free'ing structure
  2. SPFragmentGenerator (nothing much has changed here)
    1. loops over every possible combination (2dimension of edge set)

a1. inserts current set, if there's still space left

a11. yes: calls SPFragmentGenerator with structure, created new edge list and size respective to root distance+1
a12. no: stores fragment into keyset list by calling InsertFragmentIntoGraph

a2. removes all items added into the snake stack (in UniqueFragments structure) added during level (root distance) and current set

  • 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.