| [208237b] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [0aa122] | 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| [94d5ac6] | 5 | * | 
|---|
|  | 6 | * | 
|---|
|  | 7 | *   This file is part of MoleCuilder. | 
|---|
|  | 8 | * | 
|---|
|  | 9 | *    MoleCuilder is free software: you can redistribute it and/or modify | 
|---|
|  | 10 | *    it under the terms of the GNU General Public License as published by | 
|---|
|  | 11 | *    the Free Software Foundation, either version 2 of the License, or | 
|---|
|  | 12 | *    (at your option) any later version. | 
|---|
|  | 13 | * | 
|---|
|  | 14 | *    MoleCuilder is distributed in the hope that it will be useful, | 
|---|
|  | 15 | *    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 16 | *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 17 | *    GNU General Public License for more details. | 
|---|
|  | 18 | * | 
|---|
|  | 19 | *    You should have received a copy of the GNU General Public License | 
|---|
|  | 20 | *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>. | 
|---|
| [208237b] | 21 | */ | 
|---|
|  | 22 |  | 
|---|
|  | 23 | /* | 
|---|
|  | 24 | * DipoleCorrelationAction.cpp | 
|---|
|  | 25 | * | 
|---|
|  | 26 | *  Created on: May 9, 2010 | 
|---|
|  | 27 | *      Author: heber | 
|---|
|  | 28 | */ | 
|---|
|  | 29 |  | 
|---|
|  | 30 | // include config.h | 
|---|
|  | 31 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 32 | #include <config.h> | 
|---|
|  | 33 | #endif | 
|---|
|  | 34 |  | 
|---|
| [9eb71b3] | 35 | //#include "CodePatterns/MemDebug.hpp" | 
|---|
| [208237b] | 36 |  | 
|---|
|  | 37 | #include "Analysis/analysis_correlation.hpp" | 
|---|
|  | 38 | #include "CodePatterns/Log.hpp" | 
|---|
|  | 39 | #include "Element/element.hpp" | 
|---|
|  | 40 | #include "Element/periodentafel.hpp" | 
|---|
|  | 41 | #include "LinearAlgebra/Vector.hpp" | 
|---|
|  | 42 | #include "molecule.hpp" | 
|---|
|  | 43 | #include "World.hpp" | 
|---|
|  | 44 |  | 
|---|
|  | 45 | #include <iostream> | 
|---|
|  | 46 | #include <string> | 
|---|
|  | 47 |  | 
|---|
|  | 48 | using namespace MoleCuilder; | 
|---|
|  | 49 |  | 
|---|
|  | 50 | #include "Actions/AnalysisAction/DipoleCorrelationAction.hpp" | 
|---|
|  | 51 |  | 
|---|
|  | 52 | // and construct the stuff | 
|---|
|  | 53 | #include "DipoleCorrelationAction.def" | 
|---|
|  | 54 | #include "Action_impl_pre.hpp" | 
|---|
|  | 55 |  | 
|---|
|  | 56 | /** =========== define the function ====================== */ | 
|---|
| [b5b01e] | 57 | ActionState::ptr AnalysisDipoleCorrelationAction::performCall() { | 
|---|
| [208237b] | 58 | //int ranges[3] = {1, 1, 1}; | 
|---|
|  | 59 | ofstream output; | 
|---|
|  | 60 | ofstream binoutput; | 
|---|
|  | 61 | string type; | 
|---|
|  | 62 | BinPairMap *binmap = NULL; | 
|---|
|  | 63 |  | 
|---|
|  | 64 | // execute action | 
|---|
| [f10b0c] | 65 | output.open(params.outputname.get().string().c_str()); | 
|---|
|  | 66 | binoutput.open(params.binoutputname.get().string().c_str()); | 
|---|
| [208237b] | 67 | DipoleCorrelationMap *correlationmap = NULL; | 
|---|
| [99db9b] | 68 | const std::vector<const molecule*> molecules = | 
|---|
|  | 69 | const_cast<const World &>(World::getInstance()).getSelectedMolecules(); | 
|---|
| [26b4d62] | 70 | STATUS("There are "+toString(molecules.size())+" selected molecules."); | 
|---|
| [f10b0c] | 71 | ASSERT(!params.periodic.get(), "AnalysisDipoleCorrelationAction() - periodic case not implemented."); | 
|---|
| [208237b] | 72 | correlationmap = DipoleCorrelation(molecules); | 
|---|
|  | 73 | OutputCorrelationMap<DipoleCorrelationMap>(&output, correlationmap, OutputDipoleCorrelation_Header, OutputDipoleCorrelation_Value); | 
|---|
| [f10b0c] | 74 | binmap = BinData( correlationmap, params.BinWidth.get(), params.BinStart.get(), params.BinEnd.get() ); | 
|---|
| [208237b] | 75 | OutputCorrelationMap<BinPairMap> ( &binoutput, binmap, OutputCorrelation_Header, OutputCorrelation_Value ); | 
|---|
| [7ee21d] | 76 | delete binmap; | 
|---|
|  | 77 | delete correlationmap; | 
|---|
| [208237b] | 78 | output.close(); | 
|---|
|  | 79 | binoutput.close(); | 
|---|
|  | 80 | return Action::success; | 
|---|
|  | 81 | } | 
|---|
|  | 82 |  | 
|---|
| [b5b01e] | 83 | ActionState::ptr AnalysisDipoleCorrelationAction::performUndo(ActionState::ptr _state) { | 
|---|
| [208237b] | 84 | return Action::success; | 
|---|
|  | 85 | } | 
|---|
|  | 86 |  | 
|---|
| [b5b01e] | 87 | ActionState::ptr AnalysisDipoleCorrelationAction::performRedo(ActionState::ptr _state){ | 
|---|
| [208237b] | 88 | return Action::success; | 
|---|
|  | 89 | } | 
|---|
|  | 90 |  | 
|---|
|  | 91 | bool AnalysisDipoleCorrelationAction::canUndo() { | 
|---|
|  | 92 | return true; | 
|---|
|  | 93 | } | 
|---|
|  | 94 |  | 
|---|
|  | 95 | bool AnalysisDipoleCorrelationAction::shouldUndo() { | 
|---|
|  | 96 | return true; | 
|---|
|  | 97 | } | 
|---|
|  | 98 | /** =========== end of function ====================== */ | 
|---|