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

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

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

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