source: src/Actions/AnalysisAction/DipoleAngularCorrelationAction.cpp@ 91f592

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 91f592 was aa6c75, checked in by Frederik Heber <heber@…>, 13 years ago

Removed some unnecessary LinkedCell.hpp include's.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2011 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * DipoleAngularCorrelationAction.cpp
10 *
11 * Created on: Feb 11, 2011
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 "Descriptors/AtomOfMoleculeSelectionDescriptor.hpp"
25#include "Descriptors/MoleculeFormulaDescriptor.hpp"
26#include "Element/element.hpp"
27#include "Element/periodentafel.hpp"
28#include "LinearAlgebra/Vector.hpp"
29#include "molecule.hpp"
30#include "World.hpp"
31#include "WorldTime.hpp"
32
33#include <iostream>
34#include <map>
35#include <string>
36
37#include "Actions/AnalysisAction/DipoleAngularCorrelationAction.hpp"
38
39using namespace MoleCuilder;
40
41// and construct the stuff
42#include "DipoleAngularCorrelationAction.def"
43#include "Action_impl_pre.hpp"
44
45/** =========== define the function ====================== */
46Action::state_ptr AnalysisDipoleAngularCorrelationAction::performCall() {
47 //int ranges[3] = {1, 1, 1};
48 string type;
49
50 // obtain information
51 getParametersfromValueStorage();
52 ASSERT(!params.periodic, "AnalysisDipoleAngularCorrelationAction() - periodic case not implemented.");
53
54 // get selected atoms
55 std::vector<atom*> old_atom_selection = World::getInstance().getSelectedAtoms();
56 std::vector<molecule*> old_molecule_selection = World::getInstance().getSelectedMolecules();
57
58 // get current time step
59 const unsigned int oldtime = WorldTime::getTime();
60
61 // select atoms and obtain zero dipole orientation
62 Formula DipoleFormula(params.DipoleFormula);
63 World::getInstance().setTime(params.timestepzero);
64 World::getInstance().clearMoleculeSelection(); // TODO: This should be done in setTime or where molecules are re-done
65 World::getInstance().selectAllMolecules(MoleculeByFormula(DipoleFormula));
66 std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules();
67 std::map<atomId_t, Vector> ZeroVector = CalculateZeroAngularDipole(molecules);
68
69 // go through each step of common trajectory of all atoms in set
70 World::getInstance().clearAtomSelection();
71 World::getInstance().selectAllAtoms(AtomsByMoleculeSelection());
72 std::vector<atom *> atoms = World::getInstance().getSelectedAtoms();
73 ASSERT(!atoms.empty(),
74 "AnalysisDipoleAngularCorrelationAction::performCall() - "
75 +toString(DipoleFormula)+" selects no atoms.");
76 range<size_t> timesteps = getMaximumTrajectoryBounds(atoms);
77 ASSERT(params.timestepzero < timesteps.first,
78 "AnalysisDipoleAngularCorrelationAction::performCall() - time step zero "
79 +toString(params.timestepzero)+" is beyond trajectory range ("
80 +toString(timesteps.first)+") of some atoms.");
81 for (size_t step = params.timestepzero; step < timesteps.first; ++step) {
82 // calculate dipoles relative to zero orientation
83 DipoleAngularCorrelationMap *correlationmap = NULL;
84 correlationmap = DipoleAngularCorrelation(DipoleFormula, step, ZeroVector, DontResetTime);
85
86 // prepare step string in filename
87 std::stringstream stepstream;
88 stepstream << std::setw(4) << std::setfill('0') << step;
89 const std::string stepname(stepstream.str());
90
91 // output correlation map
92 ofstream output;
93 std::string filename = params.outputname.string()+"."+stepname+".dat";
94 output.open(filename.c_str());
95 OutputCorrelationMap<DipoleAngularCorrelationMap>(&output, correlationmap, OutputDipoleAngularCorrelation_Header, OutputDipoleAngularCorrelation_Value);
96 output.close();
97
98 // bin map
99 BinPairMap *binmap = BinData( correlationmap, params.BinWidth, params.BinStart, params.BinEnd );
100
101 // free correlation map
102 delete(correlationmap);
103
104 // output binned map
105 ofstream binoutput;
106 std::string binfilename = params.binoutputname.string()+"."+stepname+".dat";
107 binoutput.open(binfilename.c_str());
108 OutputCorrelationMap<BinPairMap> ( &binoutput, binmap, OutputCorrelation_Header, OutputCorrelation_Value );
109 binoutput.close();
110
111 // free binned map
112 delete(binmap);
113 }
114
115 // reset to old time step
116 World::getInstance().setTime(oldtime);
117
118 // reset to old selections
119 World::getInstance().clearAtomSelection();
120 BOOST_FOREACH(atom *_atom, old_atom_selection) {
121 World::getInstance().selectAtom(_atom);
122 }
123 World::getInstance().clearMoleculeSelection();
124 BOOST_FOREACH(molecule *_mol, old_molecule_selection) {
125 World::getInstance().selectMolecule(_mol);
126 }
127
128 // exit
129 return Action::success;
130}
131
132Action::state_ptr AnalysisDipoleAngularCorrelationAction::performUndo(Action::state_ptr _state) {
133 return Action::success;
134}
135
136Action::state_ptr AnalysisDipoleAngularCorrelationAction::performRedo(Action::state_ptr _state){
137 return Action::success;
138}
139
140bool AnalysisDipoleAngularCorrelationAction::canUndo() {
141 return true;
142}
143
144bool AnalysisDipoleAngularCorrelationAction::shouldUndo() {
145 return true;
146}
147/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.