source: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp@ 75dc28

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 75dc28 was d02e07, checked in by Frederik Heber <heber@…>, 15 years ago

Split PairCorrelation into Pair, Point and SurfaceCorrelation.

  • also converted to new createDialog().
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 * SurfaceCorrelationAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Helpers/MemDebug.hpp"
9
10#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
11#include "analysis_correlation.hpp"
12#include "boundary.hpp"
13#include "linkedcell.hpp"
14#include "verbose.hpp"
15#include "log.hpp"
16#include "element.hpp"
17#include "molecule.hpp"
18#include "periodentafel.hpp"
19#include "vector.hpp"
20#include "World.hpp"
21
22#include <iostream>
23#include <string>
24
25using namespace std;
26
27#include "UIElements/UIFactory.hpp"
28#include "UIElements/Dialog.hpp"
29#include "Actions/MapOfActions.hpp"
30
31const char AnalysisSurfaceCorrelationAction::NAME[] = "surface-correlation";
32
33AnalysisSurfaceCorrelationAction::AnalysisSurfaceCorrelationAction() :
34 Action(NAME)
35{}
36
37AnalysisSurfaceCorrelationAction::~AnalysisSurfaceCorrelationAction()
38{}
39
40Dialog* AnalysisSurfaceCorrelationAction::createDialog() {
41 Dialog *dialog = UIFactory::getInstance().makeDialog();
42 int ranges[3] = {1, 1, 1};
43 double BinEnd = 0.;
44 double BinStart = 0.;
45 double BinWidth = 0.;
46 molecule *Boundary = NULL;
47 string outputname;
48 string binoutputname;
49 bool periodic;
50 ofstream output;
51 ofstream binoutput;
52 std::vector< element *> elements;
53 string type;
54 Vector Point;
55 BinPairMap *binmap = NULL;
56
57 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
58 dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
59 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
60 dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
61 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
62 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
63 dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
64 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
65
66 return dialog;
67}
68
69Action::state_ptr AnalysisSurfaceCorrelationAction::performCall() {
70 int ranges[3] = {1, 1, 1};
71 double BinEnd = 0.;
72 double BinStart = 0.;
73 double BinWidth = 0.;
74 molecule *Boundary = NULL;
75 string outputname;
76 string binoutputname;
77 bool periodic;
78 ofstream output;
79 ofstream binoutput;
80 std::vector< element *> elements;
81 string type;
82 Vector Point;
83 BinPairMap *binmap = NULL;
84 MoleculeListClass *molecules = World::getInstance().getMolecules();
85
86 // obtain information
87 MapOfActions::getInstance().queryCurrentValue("molecule-by-id", Boundary);
88 MapOfActions::getInstance().queryCurrentValue("elements", elements);
89 MapOfActions::getInstance().queryCurrentValue("bin-start", BinStart);
90 MapOfActions::getInstance().queryCurrentValue("bin-width", BinWidth);
91 MapOfActions::getInstance().queryCurrentValue("bin-end", BinEnd);
92 MapOfActions::getInstance().queryCurrentValue("output-file", outputname);
93 MapOfActions::getInstance().queryCurrentValue("bin-output-file", binoutputname);
94 MapOfActions::getInstance().queryCurrentValue("periodic", periodic);
95
96 // execute action
97 output.open(outputname.c_str());
98 binoutput.open(binoutputname.c_str());
99 ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
100 const double radius = 4.;
101 double LCWidth = 20.;
102 if (BinEnd > 0) {
103 if (BinEnd > 2.*radius)
104 LCWidth = BinEnd;
105 else
106 LCWidth = 2.*radius;
107 }
108
109 // get the boundary
110 class Tesselation *TesselStruct = NULL;
111 const LinkedCell *LCList = NULL;
112 // find biggest molecule
113 int counter = molecules->ListOfMolecules.size();
114 bool *Actives = new bool[counter];
115 counter = 0;
116 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
117 Actives[counter++] = (*BigFinder)->ActiveFlag;
118 (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
119 }
120 LCList = new LinkedCell(Boundary, LCWidth);
121 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
122 CorrelationToSurfaceMap *surfacemap = NULL;
123 if (periodic)
124 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
125 else
126 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
127 delete LCList;
128 OutputCorrelationToSurface(&output, surfacemap);
129 // re-set ActiveFlag
130 counter = 0;
131 for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
132 (*BigFinder)->ActiveFlag = Actives[counter++];
133 }
134 delete[] Actives;
135 // check whether radius was appropriate
136 {
137 double start; double end;
138 GetMinMax( surfacemap, start, end);
139 if (LCWidth < end)
140 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);
141 }
142 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
143 OutputCorrelation ( &binoutput, binmap );
144 delete TesselStruct; // surfacemap contains refs to triangles! delete here, not earlier!
145 delete(binmap);
146 delete(surfacemap);
147 output.close();
148 binoutput.close();
149 return Action::success;
150}
151
152Action::state_ptr AnalysisSurfaceCorrelationAction::performUndo(Action::state_ptr _state) {
153 return Action::success;
154}
155
156Action::state_ptr AnalysisSurfaceCorrelationAction::performRedo(Action::state_ptr _state){
157 return Action::success;
158}
159
160bool AnalysisSurfaceCorrelationAction::canUndo() {
161 return true;
162}
163
164bool AnalysisSurfaceCorrelationAction::shouldUndo() {
165 return true;
166}
167
168const string AnalysisSurfaceCorrelationAction::getName() {
169 return NAME;
170}
Note: See TracBrowser for help on using the repository browser.