source: src/Actions/AnalysisAction/SurfaceCorrelationAction.cpp@ 9cd807

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

BUGFIX: SubgraphDissectionAction() does not copy system anymore, has Undo/Redo.

  • This fixes ticket #88.
  • Added Undo/Redo, needed World::changeMoleculeId() for that
  • BUGFIX: performCall() let DepthFirstSearchAnalysis() copy atoms and copied the molecules once more.
  • BUGFIX: performCall() did not reset fathers of copied atoms to point to themselves (BUG with redo arose).
  • TEST: Added Undo/Redo part to Graph/2 (subgraph dissection).
  • TESTFIX: Analysis/4 uses --unselect-molecule-by-formula and id of this molecule is 1 (as system is not copied anymore).
  • 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 std::cout << "There are " << molecules.size() << " selected molecules." << std::endl;
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 // 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 OutputCorrelation ( &binoutput, binmap );
138 delete TesselStruct; // surfacemap contains refs to triangles! delete here, not earlier!
139 delete(binmap);
140 delete(surfacemap);
141 output.close();
142 binoutput.close();
143 return Action::success;
144}
145
146Action::state_ptr AnalysisSurfaceCorrelationAction::performUndo(Action::state_ptr _state) {
147 return Action::success;
148}
149
150Action::state_ptr AnalysisSurfaceCorrelationAction::performRedo(Action::state_ptr _state){
151 return Action::success;
152}
153
154bool AnalysisSurfaceCorrelationAction::canUndo() {
155 return true;
156}
157
158bool AnalysisSurfaceCorrelationAction::shouldUndo() {
159 return true;
160}
161
162const string AnalysisSurfaceCorrelationAction::getName() {
163 return NAME;
164}
Note: See TracBrowser for help on using the repository browser.