[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[bcf653] | 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 |
|
---|
[ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
|
---|
[112b09] | 21 |
|
---|
[9b5a2c] | 22 | #include "Analysis/analysis_correlation.hpp"
|
---|
[ad011c] | 23 | #include "CodePatterns/Verbose.hpp"
|
---|
| 24 | #include "CodePatterns/Log.hpp"
|
---|
[c1a9d6] | 25 | #include "Descriptors/AtomTypeDescriptor.hpp"
|
---|
[3bdb6d] | 26 | #include "Element/element.hpp"
|
---|
[104524] | 27 | #include "molecule.hpp"
|
---|
[3bdb6d] | 28 | #include "Element/periodentafel.hpp"
|
---|
[c1a9d6] | 29 | #include "LinearAlgebra/RealSpaceMatrix.hpp"
|
---|
[57f243] | 30 | #include "LinearAlgebra/Vector.hpp"
|
---|
[97ebf8] | 31 | #include "World.hpp"
|
---|
| 32 |
|
---|
| 33 | #include <iostream>
|
---|
| 34 | #include <string>
|
---|
| 35 |
|
---|
[9ee38b] | 36 | #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
|
---|
[97ebf8] | 37 |
|
---|
[ce7fdc] | 38 | using namespace MoleCuilder;
|
---|
| 39 |
|
---|
[9ee38b] | 40 | // and construct the stuff
|
---|
| 41 | #include "PairCorrelationAction.def"
|
---|
| 42 | #include "Action_impl_pre.hpp"
|
---|
[97ebf8] | 43 |
|
---|
[9ee38b] | 44 | /** =========== define the function ====================== */
|
---|
[d02e07] | 45 | Action::state_ptr AnalysisPairCorrelationAction::performCall() {
|
---|
| 46 | ofstream output;
|
---|
| 47 | ofstream binoutput;
|
---|
| 48 | string type;
|
---|
| 49 | BinPairMap *binmap = NULL;
|
---|
[97ebf8] | 50 |
|
---|
[d02e07] | 51 | // execute action
|
---|
[f10b0c] | 52 | output.open(params.outputname.get().string().c_str());
|
---|
| 53 | binoutput.open(params.binoutputname.get().string().c_str());
|
---|
[d02e07] | 54 | PairCorrelationMap *correlationmap = NULL;
|
---|
[f10b0c] | 55 | ASSERT(params.elements.get().size() == 2,
|
---|
[c1a9d6] | 56 | "AnalysisPairCorrelationAction::performCall() - Exactly two elements are required for pair correlation.");
|
---|
[f10b0c] | 57 | std::vector<const element *>::const_iterator elemiter = params.elements.get().begin();
|
---|
[c1a9d6] | 58 | const World::AtomComposite atoms_first = World::getInstance().getAllAtoms(AtomByType(*(elemiter++)));
|
---|
| 59 | const World::AtomComposite atoms_second = World::getInstance().getAllAtoms(AtomByType(*(elemiter++)));
|
---|
[f10b0c] | 60 | ASSERT(elemiter == params.elements.get().end(),
|
---|
[c1a9d6] | 61 | "AnalysisPairCorrelationAction::performCall() - Exactly two elements are required for pair correlation.");
|
---|
[f10b0c] | 62 | double max_distance = params.BinEnd.get();
|
---|
| 63 | if (params.BinEnd.get() <= 0.) {
|
---|
[c1a9d6] | 64 | // find max distance within box from diagonal
|
---|
[46c832] | 65 | const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
|
---|
| 66 | max_distance = (M * Vector(1.,1.,1.)).NormSquared();
|
---|
[c1a9d6] | 67 | }
|
---|
| 68 | correlationmap = PairCorrelation(atoms_first, atoms_second, max_distance);
|
---|
[92e5cb] | 69 | OutputCorrelationMap<PairCorrelationMap>(&output, correlationmap, OutputPairCorrelation_Header, OutputPairCorrelation_Value);
|
---|
[f10b0c] | 70 | binmap = BinData( correlationmap, params.BinWidth.get(), params.BinStart.get(), params.BinEnd.get() );
|
---|
[92e5cb] | 71 | OutputCorrelationMap<BinPairMap> ( &binoutput, binmap, OutputCorrelation_Header, OutputCorrelation_Value );
|
---|
[d02e07] | 72 | delete(binmap);
|
---|
| 73 | delete(correlationmap);
|
---|
| 74 | output.close();
|
---|
| 75 | binoutput.close();
|
---|
| 76 | return Action::success;
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
|
---|
| 80 | return Action::success;
|
---|
[97ebf8] | 81 | }
|
---|
| 82 |
|
---|
| 83 | Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
|
---|
[d02e07] | 84 | return Action::success;
|
---|
[97ebf8] | 85 | }
|
---|
| 86 |
|
---|
| 87 | bool AnalysisPairCorrelationAction::canUndo() {
|
---|
[d02e07] | 88 | return true;
|
---|
[97ebf8] | 89 | }
|
---|
| 90 |
|
---|
| 91 | bool AnalysisPairCorrelationAction::shouldUndo() {
|
---|
[d02e07] | 92 | return true;
|
---|
[97ebf8] | 93 | }
|
---|
[9ee38b] | 94 | /** =========== end of function ====================== */
|
---|