| 1 | /* | 
|---|
| 2 | * Project: MoleCuilder | 
|---|
| 3 | * Description: creates and alters molecular systems | 
|---|
| 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
| 6 | */ | 
|---|
| 7 |  | 
|---|
| 8 | /* | 
|---|
| 9 | * DipoleCorrelationAction.cpp | 
|---|
| 10 | * | 
|---|
| 11 | *  Created on: May 9, 2010 | 
|---|
| 12 | *      Author: heber | 
|---|
| 13 | */ | 
|---|
| 14 |  | 
|---|
| 15 | // include config.h | 
|---|
| 16 | #ifdef HAVE_CONFIG_H | 
|---|
| 17 | #include <config.h> | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | #include "CodePatterns/MemDebug.hpp" | 
|---|
| 21 |  | 
|---|
| 22 | #include "Analysis/analysis_correlation.hpp" | 
|---|
| 23 | #include "CodePatterns/Log.hpp" | 
|---|
| 24 | #include "Element/element.hpp" | 
|---|
| 25 | #include "Element/periodentafel.hpp" | 
|---|
| 26 | #include "LinearAlgebra/Vector.hpp" | 
|---|
| 27 | #include "molecule.hpp" | 
|---|
| 28 | #include "World.hpp" | 
|---|
| 29 |  | 
|---|
| 30 | #include <iostream> | 
|---|
| 31 | #include <string> | 
|---|
| 32 |  | 
|---|
| 33 | using namespace MoleCuilder; | 
|---|
| 34 |  | 
|---|
| 35 | #include "Actions/AnalysisAction/DipoleCorrelationAction.hpp" | 
|---|
| 36 |  | 
|---|
| 37 | // and construct the stuff | 
|---|
| 38 | #include "DipoleCorrelationAction.def" | 
|---|
| 39 | #include "Action_impl_pre.hpp" | 
|---|
| 40 |  | 
|---|
| 41 | /** =========== define the function ====================== */ | 
|---|
| 42 | Action::state_ptr AnalysisDipoleCorrelationAction::performCall() { | 
|---|
| 43 | //int ranges[3] = {1, 1, 1}; | 
|---|
| 44 | ofstream output; | 
|---|
| 45 | ofstream binoutput; | 
|---|
| 46 | string type; | 
|---|
| 47 | BinPairMap *binmap = NULL; | 
|---|
| 48 |  | 
|---|
| 49 | // obtain information | 
|---|
| 50 | getParametersfromValueStorage(); | 
|---|
| 51 |  | 
|---|
| 52 | // execute action | 
|---|
| 53 | output.open(params.outputname.string().c_str()); | 
|---|
| 54 | binoutput.open(params.binoutputname.string().c_str()); | 
|---|
| 55 | DipoleCorrelationMap *correlationmap = NULL; | 
|---|
| 56 | std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules(); | 
|---|
| 57 | LOG(0, "STATUS: There are " << molecules.size() << " selected molecules."); | 
|---|
| 58 | ASSERT(!params.periodic, "AnalysisDipoleCorrelationAction() - periodic case not implemented."); | 
|---|
| 59 | correlationmap = DipoleCorrelation(molecules); | 
|---|
| 60 | OutputCorrelationMap<DipoleCorrelationMap>(&output, correlationmap, OutputDipoleCorrelation_Header, OutputDipoleCorrelation_Value); | 
|---|
| 61 | binmap = BinData( correlationmap, params.BinWidth, params.BinStart, params.BinEnd ); | 
|---|
| 62 | OutputCorrelationMap<BinPairMap> ( &binoutput, binmap, OutputCorrelation_Header, OutputCorrelation_Value ); | 
|---|
| 63 | delete(binmap); | 
|---|
| 64 | delete(correlationmap); | 
|---|
| 65 | output.close(); | 
|---|
| 66 | binoutput.close(); | 
|---|
| 67 | return Action::success; | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | Action::state_ptr AnalysisDipoleCorrelationAction::performUndo(Action::state_ptr _state) { | 
|---|
| 71 | return Action::success; | 
|---|
| 72 | } | 
|---|
| 73 |  | 
|---|
| 74 | Action::state_ptr AnalysisDipoleCorrelationAction::performRedo(Action::state_ptr _state){ | 
|---|
| 75 | return Action::success; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | bool AnalysisDipoleCorrelationAction::canUndo() { | 
|---|
| 79 | return true; | 
|---|
| 80 | } | 
|---|
| 81 |  | 
|---|
| 82 | bool AnalysisDipoleCorrelationAction::shouldUndo() { | 
|---|
| 83 | return true; | 
|---|
| 84 | } | 
|---|
| 85 | /** =========== end of function ====================== */ | 
|---|