source: src/Actions/AnalysisAction/PairCorrelationToSurfaceAction.cpp@ 97ebf8

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

Added all commands defined in ParseCommandLineOptions() as Actions.

  • Actions are not yet used, except verbose, version and help.
  • Files are present and included in Makefile.am
  • not unit tests written so far
  • no action has been tested so far (except for MapOfActions)
  • structure introduced to to transition from ParseCommandLineOptions to actions.
  • program name and config file are fixed arguments.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * PairCorrelationToSurfaceAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Actions/AnalysisAction/PairCorrelationToSurfaceAction.hpp"
9#include "CommandLineParser.hpp"
10#include "analysis_correlation.hpp"
11#include "boundary.hpp"
12#include "element.hpp"
13#include "linkedcell.hpp"
14#include "log.hpp"
15#include "molecule.hpp"
16#include "verbose.hpp"
17#include "World.hpp"
18
19#include <iostream>
20#include <string>
21
22using namespace std;
23
24#include "UIElements/UIFactory.hpp"
25#include "UIElements/Dialog.hpp"
26#include "Actions/MapOfActions.hpp"
27
28const char AnalysisPairCorrelationToSurfaceAction::NAME[] = "pair-correlation-surface";
29
30AnalysisPairCorrelationToSurfaceAction::AnalysisPairCorrelationToSurfaceAction() :
31 Action(NAME)
32{}
33
34AnalysisPairCorrelationToSurfaceAction::~AnalysisPairCorrelationToSurfaceAction()
35{}
36
37Action::state_ptr AnalysisPairCorrelationToSurfaceAction::performCall() {
38 Dialog *dialog = UIFactory::getInstance().makeDialog();
39 double BinStart = 0.;
40 double BinWidth = 0.;
41 double BinEnd = 0.;
42 string outputname;
43 string binoutputname;
44 bool periodic;
45 ofstream output;
46 ofstream binoutput;
47 int ranges[3] = {1, 1, 1};
48 const element *elemental = NULL;
49 molecule *Boundary = NULL;
50
51 dialog->queryElement("elements", &elemental, MapOfActions::getInstance().getDescription("element"));
52 dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
53 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
54 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
55 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
56 dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
57 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
58
59 if(dialog->display()) {
60 output.open(outputname.c_str());
61 binoutput.open(binoutputname.c_str());
62 const double radius = 4.;
63 double LCWidth = 20.;
64 if (BinEnd > 0) {
65 if (BinEnd > 2.*radius)
66 LCWidth = BinEnd;
67 else
68 LCWidth = 2.*radius;
69 }
70 class MoleculeListClass *molecules = World::getInstance().getMolecules();
71 class Tesselation *TesselStruct = NULL;
72 const LinkedCell *LCList = NULL;
73 LCList = new LinkedCell(Boundary, LCWidth);
74 FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
75 CorrelationToSurfaceMap *surfacemap = NULL;
76 if (periodic)
77 surfacemap = PeriodicCorrelationToSurface( molecules, elemental, TesselStruct, LCList, ranges);
78 else
79 surfacemap = CorrelationToSurface( molecules, elemental, TesselStruct, LCList);
80 OutputCorrelationToSurface(&output, surfacemap);
81 // check whether radius was appropriate
82 {
83 double start; double end;
84 GetMinMax( surfacemap, start, end);
85 if (LCWidth < end)
86 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);
87 }
88 BinPairMap *binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
89 OutputCorrelation ( &binoutput, binmap );
90 output.close();
91 binoutput.close();
92 delete(LCList);
93 delete(TesselStruct);
94 delete(binmap);
95 delete(surfacemap);
96 delete dialog;
97 return Action::success;
98 } else {
99 delete dialog;
100 return Action::failure;
101 }
102}
103
104Action::state_ptr AnalysisPairCorrelationToSurfaceAction::performUndo(Action::state_ptr _state) {
105// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
106
107 return Action::failure;
108// string newName = state->mol->getName();
109// state->mol->setName(state->lastName);
110//
111// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
112}
113
114Action::state_ptr AnalysisPairCorrelationToSurfaceAction::performRedo(Action::state_ptr _state){
115 return Action::failure;
116}
117
118bool AnalysisPairCorrelationToSurfaceAction::canUndo() {
119 return false;
120}
121
122bool AnalysisPairCorrelationToSurfaceAction::shouldUndo() {
123 return false;
124}
125
126const string AnalysisPairCorrelationToSurfaceAction::getName() {
127 return NAME;
128}
Note: See TracBrowser for help on using the repository browser.