source: src/Actions/AnalysisAction/PairCorrelationAction.cpp@ 94d131

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 94d131 was 104524, checked in by Frederik Heber <heber@…>, 15 years ago

Changed PairCorrelationAction to incorporate all three cases and handled different parameters needed for each, changed queryElement to list of elements.

PairCorrelationAction:

queryElement:

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