source: src/Actions/AnalysisAction/PairCorrelationAction.cpp@ 980dd6

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 980dd6 was 623e89, checked in by Frederik Heber <heber@…>, 15 years ago

Compilation took ages because of CommandLineParser.hpp being unnecessarily included in every action.

  • it was actually needed in HelperAction.cpp and copy&pasted itself from there into almost all others.
  • Property mode set to 100644
File size: 6.3 KB
Line 
1/*
2 * PairCorrelationAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
9#include "analysis_correlation.hpp"
10#include "boundary.hpp"
11#include "linkedcell.hpp"
12#include "log.hpp"
13#include "element.hpp"
14#include "molecule.hpp"
15#include "periodentafel.hpp"
16#include "vector.hpp"
17#include "World.hpp"
18
19#include <iostream>
20#include <string>
21
22using namespace std;
23
24#include "UIElements/UIFactory.hpp"
25#include "UIElements/Dialog.hpp"
26#include "Actions/MapOfActions.hpp"
27
28const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
29
30AnalysisPairCorrelationAction::AnalysisPairCorrelationAction() :
31 Action(NAME)
32{}
33
34AnalysisPairCorrelationAction::~AnalysisPairCorrelationAction()
35{}
36
37Action::state_ptr AnalysisPairCorrelationAction::performCall() {
38 Dialog *dialog = UIFactory::getInstance().makeDialog();
39 int ranges[3] = {1, 1, 1};
40 double BinEnd = 0.;
41 double BinStart = 0.;
42 double BinWidth = 0.;
43 molecule *Boundary = NULL;
44 string outputname;
45 string binoutputname;
46 bool periodic;
47 ofstream output;
48 ofstream binoutput;
49 std::vector< element *> elements;
50 string type;
51 Vector Point;
52 BinPairMap *binmap = NULL;
53 MoleculeListClass *molecules = World::getInstance().getMolecules();
54
55 // first dialog: Obtain which type of correlation
56 dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));
57 if(dialog->display()) {
58 delete dialog;
59 } else {
60 delete dialog;
61 return Action::failure;
62 }
63
64 // second dialog: Obtain parameters specific to this type
65 dialog = UIFactory::getInstance().makeDialog();
66 if (type == "P")
67 dialog->queryVector("position", &Point, World::getInstance().getDomain(), false, MapOfActions::getInstance().getDescription("position"));
68 if (type == "S")
69 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
70 dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
71 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
72 dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
73 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
74 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
75 dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
76 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
77
78 if(dialog->display()) {
79 output.open(outputname.c_str());
80 binoutput.open(binoutputname.c_str());
81 PairCorrelationMap *correlationmap = NULL;
82 if (type == "E") {
83 PairCorrelationMap *correlationmap = NULL;
84 if (periodic)
85 correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
86 else
87 correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
88 //OutputCorrelationToSurface(&output, correlationmap);
89 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
90 } else if (type == "P") {
91 cout << "Point to correlate to is " << Point << endl;
92 CorrelationToPointMap *correlationmap = NULL;
93 if (periodic)
94 correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
95 else
96 correlationmap = CorrelationToPoint(molecules, elements, &Point);
97 //OutputCorrelationToSurface(&output, correlationmap);
98 binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
99 } else if (type == "S") {
100 ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
101 const double radius = 4.;
102 double LCWidth = 20.;
103 if (BinEnd > 0) {
104 if (BinEnd > 2.*radius)
105 LCWidth = BinEnd;
106 else
107 LCWidth = 2.*radius;
108 }
109
110 // get the boundary
111 class Tesselation *TesselStruct = NULL;
112 const LinkedCell *LCList = NULL;
113 // find biggest molecule
114 int counter = molecules->ListOfMolecules.size();
115 bool *Actives = new bool[counter];
116 counter = 0;
117 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
118 Actives[counter++] = (*BigFinder)->ActiveFlag;
119 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
120 }
121 LCList = new LinkedCell(Boundary, LCWidth);
122 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
123 CorrelationToSurfaceMap *surfacemap = NULL;
124 if (periodic)
125 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
126 else
127 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
128 OutputCorrelationToSurface(&output, surfacemap);
129 // check whether radius was appropriate
130 {
131 double start; double end;
132 GetMinMax( surfacemap, start, end);
133 if (LCWidth < end)
134 DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
135 }
136 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
137 } else
138 return Action::failure;
139 OutputCorrelation ( &binoutput, binmap );
140 output.close();
141 binoutput.close();
142 delete(binmap);
143 delete(correlationmap);
144 delete dialog;
145 return Action::success;
146 } else {
147 delete dialog;
148 return Action::failure;
149 }
150}
151
152Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
153// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
154
155 return Action::failure;
156// string newName = state->mol->getName();
157// state->mol->setName(state->lastName);
158//
159// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
160}
161
162Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
163 return Action::failure;
164}
165
166bool AnalysisPairCorrelationAction::canUndo() {
167 return false;
168}
169
170bool AnalysisPairCorrelationAction::shouldUndo() {
171 return false;
172}
173
174const string AnalysisPairCorrelationAction::getName() {
175 return NAME;
176}
Note: See TracBrowser for help on using the repository browser.