[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[97ebf8] | 8 | /*
|
---|
| 9 | * PairCorrelationAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 9, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[112b09] | 20 | #include "Helpers/MemDebug.hpp"
|
---|
| 21 |
|
---|
[97ebf8] | 22 | #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
|
---|
[0430e3] | 23 | #include "Actions/ActionRegistry.hpp"
|
---|
[97ebf8] | 24 | #include "analysis_correlation.hpp"
|
---|
[104524] | 25 | #include "boundary.hpp"
|
---|
| 26 | #include "linkedcell.hpp"
|
---|
[952f38] | 27 | #include "Helpers/Verbose.hpp"
|
---|
| 28 | #include "Helpers/Log.hpp"
|
---|
[97ebf8] | 29 | #include "element.hpp"
|
---|
[104524] | 30 | #include "molecule.hpp"
|
---|
[97ebf8] | 31 | #include "periodentafel.hpp"
|
---|
[57f243] | 32 | #include "LinearAlgebra/Vector.hpp"
|
---|
[97ebf8] | 33 | #include "World.hpp"
|
---|
| 34 |
|
---|
| 35 | #include <iostream>
|
---|
| 36 | #include <string>
|
---|
| 37 |
|
---|
| 38 | using namespace std;
|
---|
| 39 |
|
---|
| 40 | #include "UIElements/UIFactory.hpp"
|
---|
| 41 | #include "UIElements/Dialog.hpp"
|
---|
[861874] | 42 | #include "Actions/ValueStorage.hpp"
|
---|
[97ebf8] | 43 |
|
---|
| 44 | const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
|
---|
| 45 |
|
---|
| 46 | AnalysisPairCorrelationAction::AnalysisPairCorrelationAction() :
|
---|
| 47 | Action(NAME)
|
---|
| 48 | {}
|
---|
| 49 |
|
---|
| 50 | AnalysisPairCorrelationAction::~AnalysisPairCorrelationAction()
|
---|
| 51 | {}
|
---|
| 52 |
|
---|
[b31cfa] | 53 | void AnalysisPairCorrelation(std::vector< element *> &elements, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
|
---|
| 54 | ValueStorage::getInstance().setCurrentValue("elements", elements);
|
---|
| 55 | ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
|
---|
| 56 | ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
|
---|
| 57 | ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
|
---|
| 58 | ValueStorage::getInstance().setCurrentValue("output-file", outputname);
|
---|
| 59 | ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
|
---|
| 60 | ValueStorage::getInstance().setCurrentValue("periodic", periodic);
|
---|
| 61 | ActionRegistry::getInstance().getActionByName(AnalysisPairCorrelationAction::NAME)->call(Action::NonInteractive);
|
---|
| 62 | };
|
---|
| 63 |
|
---|
| 64 |
|
---|
[047878] | 65 | Dialog* AnalysisPairCorrelationAction::fillDialog(Dialog* dialog) {
|
---|
| 66 | ASSERT(dialog,"No Dialog given when filling action dialog");
|
---|
[104524] | 67 |
|
---|
[e65de8] | 68 | dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
|
---|
[9d33ba] | 69 | dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
|
---|
| 70 | dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
|
---|
| 71 | dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
|
---|
| 72 | dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
|
---|
| 73 | dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
|
---|
| 74 | dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
|
---|
[97ebf8] | 75 |
|
---|
[d02e07] | 76 | return dialog;
|
---|
[97ebf8] | 77 | }
|
---|
| 78 |
|
---|
[d02e07] | 79 | Action::state_ptr AnalysisPairCorrelationAction::performCall() {
|
---|
| 80 | int ranges[3] = {1, 1, 1};
|
---|
| 81 | double BinEnd = 0.;
|
---|
| 82 | double BinStart = 0.;
|
---|
| 83 | double BinWidth = 0.;
|
---|
| 84 | string outputname;
|
---|
| 85 | string binoutputname;
|
---|
| 86 | bool periodic;
|
---|
| 87 | ofstream output;
|
---|
| 88 | ofstream binoutput;
|
---|
[e5c0a1] | 89 | std::vector<const element *> elements;
|
---|
[d02e07] | 90 | string type;
|
---|
| 91 | Vector Point;
|
---|
| 92 | BinPairMap *binmap = NULL;
|
---|
[97ebf8] | 93 |
|
---|
[d02e07] | 94 | // obtain information
|
---|
[9d33ba] | 95 | ValueStorage::getInstance().queryCurrentValue("elements", elements);
|
---|
| 96 | ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
|
---|
| 97 | ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
|
---|
| 98 | ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
|
---|
| 99 | ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
|
---|
| 100 | ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
|
---|
| 101 | ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
|
---|
[d02e07] | 102 |
|
---|
| 103 | // execute action
|
---|
| 104 | output.open(outputname.c_str());
|
---|
| 105 | binoutput.open(binoutputname.c_str());
|
---|
| 106 | PairCorrelationMap *correlationmap = NULL;
|
---|
[e65de8] | 107 | std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
|
---|
[d02e07] | 108 | if (periodic)
|
---|
[e65de8] | 109 | correlationmap = PeriodicPairCorrelation(molecules, elements, ranges);
|
---|
[d02e07] | 110 | else
|
---|
[e65de8] | 111 | correlationmap = PairCorrelation(molecules, elements);
|
---|
[d02e07] | 112 | OutputPairCorrelation(&output, correlationmap);
|
---|
| 113 | binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
|
---|
| 114 | OutputCorrelation ( &binoutput, binmap );
|
---|
| 115 | delete(binmap);
|
---|
| 116 | delete(correlationmap);
|
---|
| 117 | output.close();
|
---|
| 118 | binoutput.close();
|
---|
| 119 | return Action::success;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
|
---|
| 123 | return Action::success;
|
---|
[97ebf8] | 124 | }
|
---|
| 125 |
|
---|
| 126 | Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
|
---|
[d02e07] | 127 | return Action::success;
|
---|
[97ebf8] | 128 | }
|
---|
| 129 |
|
---|
| 130 | bool AnalysisPairCorrelationAction::canUndo() {
|
---|
[d02e07] | 131 | return true;
|
---|
[97ebf8] | 132 | }
|
---|
| 133 |
|
---|
| 134 | bool AnalysisPairCorrelationAction::shouldUndo() {
|
---|
[d02e07] | 135 | return true;
|
---|
[97ebf8] | 136 | }
|
---|
| 137 |
|
---|
| 138 | const string AnalysisPairCorrelationAction::getName() {
|
---|
| 139 | return NAME;
|
---|
| 140 | }
|
---|