source: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp@ e41c48

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

Merge branch 'StructureRefactoring' into stable

Conflicts:

src/Actions/AtomAction/AddAction.cpp
src/Actions/AtomAction/ChangeElementAction.cpp
src/Parser/XyzParser.cpp
src/analysis_correlation.cpp
src/atom.cpp
src/config.cpp
src/molecule.cpp

  • AtomInfo::element were privatized in stable and element::symbol, ::name in StructureRefactoring (overlapped in various lines).
  • 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 "Actions/ActionRegistry.hpp"
12#include "analysis_correlation.hpp"
13#include "boundary.hpp"
14#include "linkedcell.hpp"
15#include "Helpers/Verbose.hpp"
16#include "Helpers/Log.hpp"
17#include "element.hpp"
18#include "molecule.hpp"
19#include "periodentafel.hpp"
20#include "tesselation.hpp"
21#include "LinearAlgebra/Vector.hpp"
22#include "World.hpp"
23
24#include <iostream>
25#include <string>
26
27using namespace std;
28
29#include "UIElements/UIFactory.hpp"
30#include "UIElements/Dialog.hpp"
31#include "Actions/ValueStorage.hpp"
32
33const char AnalysisSurfaceCorrelationAction::NAME[] = "surface-correlation";
34
35AnalysisSurfaceCorrelationAction::AnalysisSurfaceCorrelationAction() :
36 Action(NAME)
37{}
38
39AnalysisSurfaceCorrelationAction::~AnalysisSurfaceCorrelationAction()
40{}
41
42void AnalysisSurfaceCorrelation(std::vector< element *> &elements, molecule *mol, double BinStart, double BinWidth, double BinEnd, std::string &outputname, std::string &binoutputname, bool periodic) {
43 ValueStorage::getInstance().setCurrentValue("elements", elements);
44 ValueStorage::getInstance().setCurrentValue("molecule-by-id", mol);
45 ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
46 ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
47 ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
48 ValueStorage::getInstance().setCurrentValue("output-file", outputname);
49 ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
50 ValueStorage::getInstance().setCurrentValue("periodic", periodic);
51 ActionRegistry::getInstance().getActionByName(AnalysisSurfaceCorrelationAction::NAME)->call(Action::NonInteractive);
52};
53
54
55Dialog* AnalysisSurfaceCorrelationAction::fillDialog(Dialog *dialog) {
56 ASSERT(dialog,"No Dialog given when filling action dialog");
57
58 dialog->queryMolecule("molecule-by-id", ValueStorage::getInstance().getDescription("molecule-by-id"));
59 dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
60 dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
61 dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
62 dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
63 dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
64 dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
65 dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
66
67 return dialog;
68}
69
70Action::state_ptr AnalysisSurfaceCorrelationAction::performCall() {
71 int ranges[3] = {1, 1, 1};
72 double BinEnd = 0.;
73 double BinStart = 0.;
74 double BinWidth = 0.;
75 molecule *Boundary = NULL;
76 string outputname;
77 string binoutputname;
78 bool periodic;
79 ofstream output;
80 ofstream binoutput;
81 std::vector<const element *> elements;
82 string type;
83 Vector Point;
84 BinPairMap *binmap = NULL;
85
86 // obtain information
87 ValueStorage::getInstance().queryCurrentValue("molecule-by-id", Boundary);
88 ValueStorage::getInstance().queryCurrentValue("elements", elements);
89 ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
90 ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
91 ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
92 ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
93 ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
94 ValueStorage::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 std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
114 LCList = new LinkedCell(Boundary, LCWidth);
115 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
116 CorrelationToSurfaceMap *surfacemap = NULL;
117 if (periodic)
118 surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
119 else
120 surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
121 delete LCList;
122 OutputCorrelationToSurface(&output, surfacemap);
123 // check whether radius was appropriate
124 {
125 double start; double end;
126 GetMinMax( surfacemap, start, end);
127 if (LCWidth < end)
128 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);
129 }
130 binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
131 OutputCorrelation ( &binoutput, binmap );
132 delete TesselStruct; // surfacemap contains refs to triangles! delete here, not earlier!
133 delete(binmap);
134 delete(surfacemap);
135 output.close();
136 binoutput.close();
137 return Action::success;
138}
139
140Action::state_ptr AnalysisSurfaceCorrelationAction::performUndo(Action::state_ptr _state) {
141 return Action::success;
142}
143
144Action::state_ptr AnalysisSurfaceCorrelationAction::performRedo(Action::state_ptr _state){
145 return Action::success;
146}
147
148bool AnalysisSurfaceCorrelationAction::canUndo() {
149 return true;
150}
151
152bool AnalysisSurfaceCorrelationAction::shouldUndo() {
153 return true;
154}
155
156const string AnalysisSurfaceCorrelationAction::getName() {
157 return NAME;
158}
Note: See TracBrowser for help on using the repository browser.