| 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 |   // execute action
 | 
|---|
| 50 |   output.open(params.outputname.get().string().c_str());
 | 
|---|
| 51 |   binoutput.open(params.binoutputname.get().string().c_str());
 | 
|---|
| 52 |   DipoleCorrelationMap *correlationmap = NULL;
 | 
|---|
| 53 |   std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
 | 
|---|
| 54 |   LOG(0, "STATUS: There are " << molecules.size() << " selected molecules.");
 | 
|---|
| 55 |   ASSERT(!params.periodic.get(), "AnalysisDipoleCorrelationAction() - periodic case not implemented.");
 | 
|---|
| 56 |   correlationmap = DipoleCorrelation(molecules);
 | 
|---|
| 57 |   OutputCorrelationMap<DipoleCorrelationMap>(&output, correlationmap, OutputDipoleCorrelation_Header, OutputDipoleCorrelation_Value);
 | 
|---|
| 58 |   binmap = BinData( correlationmap, params.BinWidth.get(), params.BinStart.get(), params.BinEnd.get() );
 | 
|---|
| 59 |   OutputCorrelationMap<BinPairMap> ( &binoutput, binmap, OutputCorrelation_Header, OutputCorrelation_Value );
 | 
|---|
| 60 |   delete(binmap);
 | 
|---|
| 61 |   delete(correlationmap);
 | 
|---|
| 62 |   output.close();
 | 
|---|
| 63 |   binoutput.close();
 | 
|---|
| 64 |   return Action::success;
 | 
|---|
| 65 | }
 | 
|---|
| 66 | 
 | 
|---|
| 67 | Action::state_ptr AnalysisDipoleCorrelationAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| 68 |   return Action::success;
 | 
|---|
| 69 | }
 | 
|---|
| 70 | 
 | 
|---|
| 71 | Action::state_ptr AnalysisDipoleCorrelationAction::performRedo(Action::state_ptr _state){
 | 
|---|
| 72 |   return Action::success;
 | 
|---|
| 73 | }
 | 
|---|
| 74 | 
 | 
|---|
| 75 | bool AnalysisDipoleCorrelationAction::canUndo() {
 | 
|---|
| 76 |   return true;
 | 
|---|
| 77 | }
 | 
|---|
| 78 | 
 | 
|---|
| 79 | bool AnalysisDipoleCorrelationAction::shouldUndo() {
 | 
|---|
| 80 |   return true;
 | 
|---|
| 81 | }
 | 
|---|
| 82 | /** =========== end of function ====================== */
 | 
|---|