Changeset d02e07 for src


Ignore:
Timestamp:
Jul 22, 2010, 7:11:35 PM (15 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
75dc28
Parents:
0c9cc3
Message:

Split PairCorrelation into Pair, Point and SurfaceCorrelation.

  • also converted to new createDialog().
Location:
src/Actions
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Actions/AnalysisAction/PairCorrelationAction.cpp

    r0c9cc3 rd02e07  
    3838{}
    3939
     40Dialog* AnalysisPairCorrelationAction::createDialog() {
     41  Dialog *dialog = UIFactory::getInstance().makeDialog();
     42  int ranges[3] = {1, 1, 1};
     43  double BinEnd = 0.;
     44  double BinStart = 0.;
     45  double BinWidth = 0.;
     46  molecule *Boundary = NULL;
     47  string outputname;
     48  string binoutputname;
     49  bool periodic;
     50  ofstream output;
     51  ofstream binoutput;
     52  std::vector< element *> elements;
     53  string type;
     54  Vector Point;
     55  BinPairMap *binmap = NULL;
     56
     57  dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
     58  dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
     59  dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
     60  dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
     61  dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
     62  dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
     63  dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
     64
     65  return dialog;
     66}
     67
    4068Action::state_ptr AnalysisPairCorrelationAction::performCall() {
    41   Dialog *dialog = UIFactory::getInstance().makeDialog();
    4269  int ranges[3] = {1, 1, 1};
    4370  double BinEnd = 0.;
     
    5683  MoleculeListClass *molecules = World::getInstance().getMolecules();
    5784
    58   // first dialog: Obtain which type of correlation
    59   dialog->queryString(NAME, &type, MapOfActions::getInstance().getDescription(NAME));
    60   if(dialog->display()) {
    61     delete dialog;
    62   } else {
    63     delete dialog;
    64     return Action::failure;
    65   }
     85  // obtain information
     86  MapOfActions::getInstance().queryCurrentValue("elements", elements);
     87  MapOfActions::getInstance().queryCurrentValue("bin-start", BinStart);
     88  MapOfActions::getInstance().queryCurrentValue("bin-width", BinWidth);
     89  MapOfActions::getInstance().queryCurrentValue("bin-end", BinEnd);
     90  MapOfActions::getInstance().queryCurrentValue("output-file", outputname);
     91  MapOfActions::getInstance().queryCurrentValue("bin-output-file", binoutputname);
     92  MapOfActions::getInstance().queryCurrentValue("periodic", periodic);
    6693
    67   // second dialog: Obtain parameters specific to this type
    68   dialog = UIFactory::getInstance().makeDialog();
    69   if (type == "P")
    70     dialog->queryVector("position", &Point, false, MapOfActions::getInstance().getDescription("position"));
    71   if (type == "S")
    72     dialog->queryMolecule("molecule-by-id", &Boundary, MapOfActions::getInstance().getDescription("molecule-by-id"));
    73   dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
    74   dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
    75   dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
    76   dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
    77   dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
    78   dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
    79   dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
    80 
    81   if(dialog->display()) {
    82     output.open(outputname.c_str());
    83     binoutput.open(binoutputname.c_str());
    84     if (type == "E") {
    85       PairCorrelationMap *correlationmap = NULL;
    86       if (periodic)
    87         correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
    88       else
    89         correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
    90       OutputPairCorrelation(&output, correlationmap);
    91       binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
    92       OutputCorrelation ( &binoutput, binmap );
    93       delete(binmap);
    94       delete(correlationmap);
    95     } else if (type == "P")  {
    96       cout << "Point to correlate to is  " << Point << endl;
    97       CorrelationToPointMap *correlationmap = NULL;
    98       if (periodic)
    99         correlationmap  = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
    100       else
    101         correlationmap = CorrelationToPoint(molecules, elements, &Point);
    102       OutputCorrelationToPoint(&output, correlationmap);
    103       binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
    104       OutputCorrelation ( &binoutput, binmap );
    105       delete(binmap);
    106       delete(correlationmap);
    107     } else if (type == "S") {
    108       ASSERT(Boundary != NULL, "No molecule specified for SurfaceCorrelation.");
    109       const double radius = 4.;
    110       double LCWidth = 20.;
    111       if (BinEnd > 0) {
    112         if (BinEnd > 2.*radius)
    113           LCWidth = BinEnd;
    114         else
    115           LCWidth = 2.*radius;
    116       }
    117 
    118       // get the boundary
    119       class Tesselation *TesselStruct = NULL;
    120       const LinkedCell *LCList = NULL;
    121       // find biggest molecule
    122       int counter  = molecules->ListOfMolecules.size();
    123       bool *Actives = new bool[counter];
    124       counter = 0;
    125       for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    126         Actives[counter++] = (*BigFinder)->ActiveFlag;
    127         (*BigFinder)->ActiveFlag = (*BigFinder == Boundary) ? false : true;
    128       }
    129       LCList = new LinkedCell(Boundary, LCWidth);
    130       FindNonConvexBorder(Boundary, TesselStruct, LCList, radius, NULL);
    131       CorrelationToSurfaceMap *surfacemap = NULL;
    132       if (periodic)
    133         surfacemap = PeriodicCorrelationToSurface( molecules, elements, TesselStruct, LCList, ranges);
    134       else
    135         surfacemap = CorrelationToSurface( molecules, elements, TesselStruct, LCList);
    136       delete LCList;
    137       OutputCorrelationToSurface(&output, surfacemap);
    138       // re-set ActiveFlag
    139       counter = 0;
    140       for (MoleculeList::iterator BigFinder = molecules->ListOfMolecules.begin(); BigFinder != molecules->ListOfMolecules.end(); BigFinder++) {
    141         (*BigFinder)->ActiveFlag = Actives[counter++];
    142       }
    143       delete[] Actives;
    144       // check whether radius was appropriate
    145       {
    146         double start; double end;
    147         GetMinMax( surfacemap, start, end);
    148         if (LCWidth < end)
    149           DoeLog(1) && (eLog()<< Verbose(1) << "Linked Cell width is smaller than the found range of values! Bins can only be correct up to: " << radius << "." << endl);
    150       }
    151       binmap = BinData( surfacemap, BinWidth, BinStart, BinEnd );
    152       OutputCorrelation ( &binoutput, binmap );
    153       delete TesselStruct;  // surfacemap contains refs to triangles! delete here, not earlier!
    154       delete(binmap);
    155       delete(surfacemap);
    156     } else {
    157       return Action::failure;
    158     }
    159     output.close();
    160     binoutput.close();
    161     delete dialog;
    162     return Action::success;
    163   } else {
    164     delete dialog;
    165     return Action::failure;
    166   }
     94  // execute action
     95  output.open(outputname.c_str());
     96  binoutput.open(binoutputname.c_str());
     97  PairCorrelationMap *correlationmap = NULL;
     98  if (periodic)
     99    correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elements, ranges);
     100  else
     101    correlationmap = PairCorrelation(World::getInstance().getMolecules(), elements);
     102  OutputPairCorrelation(&output, correlationmap);
     103  binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
     104  OutputCorrelation ( &binoutput, binmap );
     105  delete(binmap);
     106  delete(correlationmap);
     107  output.close();
     108  binoutput.close();
     109  return Action::success;
    167110}
    168111
    169112Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
    170 //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
    171 
    172   return Action::failure;
    173 //  string newName = state->mol->getName();
    174 //  state->mol->setName(state->lastName);
    175 //
    176 //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
     113  return Action::success;
    177114}
    178115
    179116Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
    180   return Action::failure;
     117  return Action::success;
    181118}
    182119
    183120bool AnalysisPairCorrelationAction::canUndo() {
    184   return false;
     121  return true;
    185122}
    186123
    187124bool AnalysisPairCorrelationAction::shouldUndo() {
    188   return false;
     125  return true;
    189126}
    190127
  • TabularUnified src/Actions/AnalysisAction/PairCorrelationAction.hpp

    r0c9cc3 rd02e07  
    2121  virtual const std::string getName();
    2222private:
     23  virtual Dialog * createDialog();
    2324  virtual Action::state_ptr performCall();
    2425  virtual Action::state_ptr performUndo(Action::state_ptr);
  • TabularUnified src/Actions/Makefile.am

    r0c9cc3 rd02e07  
    3636  AnalysisAction/MolecularVolumeAction.cpp \
    3737  AnalysisAction/PairCorrelationAction.cpp \
    38   AnalysisAction/PrincipalAxisSystemAction.cpp
     38  AnalysisAction/PointCorrelationAction.cpp \
     39  AnalysisAction/PrincipalAxisSystemAction.cpp \
     40  AnalysisAction/SurfaceCorrelationAction.cpp
    3941ANALYSISACTIONHEADER = \
    4042  AnalysisAction/MolecularVolumeAction.hpp \
    4143  AnalysisAction/PairCorrelationAction.hpp \
    42   AnalysisAction/PrincipalAxisSystemAction.hpp
     44  AnalysisAction/PointCorrelationAction.hpp \
     45  AnalysisAction/PrincipalAxisSystemAction.hpp \
     46  AnalysisAction/SurfaceCorrelationAction.hpp
    4347
    4448ATOMACTIONSOURCE = \
  • TabularUnified src/Actions/MapOfActions.cpp

    r0c9cc3 rd02e07  
    1010using namespace std;
    1111
     12#include "Actions/MapOfActions.hpp"
     13#include "Descriptors/AtomIdDescriptor.hpp"
     14#include "Descriptors/MoleculeIdDescriptor.hpp"
    1215#include "Patterns/Singleton_impl.hpp"
    13 #include "Actions/MapOfActions.hpp"
    1416#include "Helpers/Assert.hpp"
    1517
     
    2123
    2224#include "atom.hpp"
     25#include "Box.hpp"
    2326#include "CommandLineParser.hpp"
    2427#include "element.hpp"
    2528#include "log.hpp"
     29#include "Matrix.hpp"
    2630#include "molecule.hpp"
     31#include "periodentafel.hpp"
     32#include "vector.hpp"
    2733#include "verbose.hpp"
    2834
     
    3036#include "Actions/AnalysisAction/MolecularVolumeAction.hpp"
    3137#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
     38#include "Actions/AnalysisAction/PointCorrelationAction.hpp"
    3239#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
     40#include "Actions/AnalysisAction/SurfaceCorrelationAction.hpp"
    3341#include "Actions/AtomAction/AddAction.hpp"
    3442#include "Actions/AtomAction/ChangeElementAction.hpp"
     
    497505}
    498506
     507void MapOfActions::queryCurrentValue(const char * name, class atom * &_T)
     508{
     509  int atomID = -1;
     510  if (typeid( atom ) == *TypeMap[name])
     511    atomID = lexical_cast<int>(CurrentValue[name].c_str());
     512  else
     513    throw IllegalTypeException(__FILE__,__LINE__);
     514  _T = World::getInstance().getAtom(AtomById(atomID));
     515}
     516
     517void MapOfActions::queryCurrentValue(const char * name, class element * &_T)  {
     518  int Z = -1;
     519  if (typeid( element ) == *TypeMap[name])
     520    Z = lexical_cast<int>(CurrentValue[name].c_str());
     521  else
     522    throw IllegalTypeException(__FILE__,__LINE__);
     523  _T = World::getInstance().getPeriode()->FindElement(Z);
     524}
     525
     526void MapOfActions::queryCurrentValue(const char * name, class molecule * &_T) {
     527  int molID = -1;
     528  if (typeid( molecule ) == *TypeMap[name])
     529    molID = lexical_cast<int>(CurrentValue[name].c_str());
     530  else
     531    throw IllegalTypeException(__FILE__,__LINE__);
     532  _T = World::getInstance().getMolecule(MoleculeById(molID));
     533}
     534
     535void MapOfActions::queryCurrentValue(const char * name, class Box &_T) {
     536  Matrix M;
     537  double tmp;
     538  if (typeid( BoxValue ) == *TypeMap[name]) {
     539    std::istringstream stream(CurrentValue[name]);
     540    stream >> tmp;
     541    M.set(0,0,tmp);
     542    stream >> tmp;
     543    M.set(0,1,tmp);
     544    M.set(1,0,tmp);
     545    stream >> tmp;
     546    M.set(0,2,tmp);
     547    M.set(2,0,tmp);
     548    stream >> tmp;
     549    M.set(1,1,tmp);
     550    stream >> tmp;
     551    M.set(1,2,tmp);
     552    M.set(2,1,tmp);
     553    stream >> tmp;
     554    M.set(2,2,tmp);
     555  } else
     556    throw IllegalTypeException(__FILE__,__LINE__);
     557}
     558
     559void MapOfActions::queryCurrentValue(const char * name, class Vector &_T) {
     560  if (typeid( VectorValue ) == *TypeMap[name]) {
     561    std::istringstream stream(CurrentValue[name]);
     562    stream >> _T[0];
     563    stream >> _T[1];
     564    stream >> _T[2];
     565  } else
     566    throw IllegalTypeException(__FILE__,__LINE__);
     567}
     568
     569void MapOfActions::queryCurrentValue(const char * name, std::vector<element *>&_T)
     570{
     571  int Z = -1;
     572  element *elemental = NULL;
     573  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     574    std::istringstream stream(CurrentValue[name]);
     575    while (!stream.fail()) {
     576      stream >> Z;
     577      elemental = World::getInstance().getPeriode()->FindElement(Z);
     578      if (elemental != NULL)
     579        _T.push_back(elemental);
     580    }
     581  } else
     582    throw IllegalTypeException(__FILE__,__LINE__);
     583}
     584
     585
     586void MapOfActions::setCurrentValue(const char * name, class atom * &_T)
     587{
     588  if (typeid( atom ) == *TypeMap[name]) {
     589    std::ostringstream stream;
     590    stream << _T->getId();
     591    CurrentValue[name] = stream.str();
     592  } else
     593    throw IllegalTypeException(__FILE__,__LINE__);
     594}
     595
     596void MapOfActions::setCurrentValue(const char * name, class element * &_T)
     597{
     598  if (typeid( element ) == *TypeMap[name]) {
     599    std::ostringstream stream;
     600    stream << _T->Z;
     601    CurrentValue[name] = stream.str();
     602  } else
     603    throw IllegalTypeException(__FILE__,__LINE__);
     604}
     605
     606void MapOfActions::setCurrentValue(const char * name, class molecule * &_T)
     607{
     608  if (typeid( molecule ) == *TypeMap[name]) {
     609    std::ostringstream stream;
     610    stream << _T->getId();
     611    CurrentValue[name] = stream.str();
     612  } else
     613    throw IllegalTypeException(__FILE__,__LINE__);
     614}
     615
     616void MapOfActions::setCurrentValue(const char * name, class Box &_T)
     617{
     618  const Matrix &M = _T.getM();
     619  if (typeid( Box ) == *TypeMap[name]) {
     620    std::ostringstream stream;
     621    stream << M.at(0,0) << " ";
     622    stream << M.at(0,1) << " ";
     623    stream << M.at(0,2) << " ";
     624    stream << M.at(1,1) << " ";
     625    stream << M.at(1,2) << " ";
     626    stream << M.at(2,2) << " ";
     627    CurrentValue[name] = stream.str();
     628  } else
     629    throw IllegalTypeException(__FILE__,__LINE__);
     630}
     631
     632void MapOfActions::setCurrentValue(const char * name, class Vector &_T)
     633{
     634  if (typeid( Vector ) == *TypeMap[name]){
     635    std::ostringstream stream;
     636    stream << _T[0] << " ";
     637    stream << _T[1] << " ";
     638    stream << _T[2] << " ";
     639    CurrentValue[name] = stream.str();
     640  } else
     641    throw IllegalTypeException(__FILE__,__LINE__);
     642}
     643
     644void MapOfActions::setCurrentValue(const char * name, std::vector<element *>&_T)
     645{
     646  if (typeid( std::vector<element *> ) == *TypeMap[name]) {
     647    std::ostringstream stream;
     648    for (std::vector<element *>::iterator iter = _T.begin(); iter != _T.end(); ++iter) {
     649      stream << (*iter)->Z;
     650    }
     651    CurrentValue[name] = stream.str();
     652  } else
     653    throw IllegalTypeException(__FILE__,__LINE__);
     654}
     655
     656
    499657
    500658void MapOfActions::populateActions()
     
    502660  new AnalysisMolecularVolumeAction();
    503661  new AnalysisPairCorrelationAction();
     662  new AnalysisPointCorrelationAction();
    504663  new AnalysisPrincipalAxisSystemAction();
     664  new AnalysisSurfaceCorrelationAction();
    505665
    506666  new AtomAddAction();
  • TabularUnified src/Actions/MapOfActions.hpp

    r0c9cc3 rd02e07  
    1414#include <map>
    1515#include <set>
     16#include <vector>
    1617#include <typeinfo>
    1718
     
    2021#include "Exceptions/IllegalTypeException.hpp"
    2122#include "Patterns/Singleton.hpp"
     23
     24class Box;
     25class atom;
     26class element;
     27class molecule;
     28class Vector;
    2229
    2330namespace po = boost::program_options;
     
    154161  void populateActions();
    155162
     163  void queryCurrentValue(const char * name, class atom * &_T);
     164  void queryCurrentValue(const char * name, class element * &_T);
     165  void queryCurrentValue(const char * name, class molecule * &_T);
     166  void queryCurrentValue(const char * name, class Box &_T);
     167  void queryCurrentValue(const char * name, class Vector &_T);
     168  void queryCurrentValue(const char * name, std::vector<element *>&_T);
    156169  template<typename T> void queryCurrentValue(const char * name, T &_T)
    157170  {
     
    162175  }
    163176
     177  void setCurrentValue(const char * name, class atom * &_T);
     178  void setCurrentValue(const char * name, class element * &_T);
     179  void setCurrentValue(const char * name, class molecule * &_T);
     180  void setCurrentValue(const char * name, class Box &_T);
     181  void setCurrentValue(const char * name, class Vector &_T);
     182  void setCurrentValue(const char * name, std::vector<element *>&_T);
    164183  template<class T> void setCurrentValue(const char * name, T &_T)
    165184  {
Note: See TracChangeset for help on using the changeset viewer.