Changeset c8165c


Ignore:
Timestamp:
May 8, 2017, 2:01:48 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_goodresults, ForceAnnealing_tocheck
Children:
db0833
Parents:
73faf4 (diff), c1446cd (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'Docu_Python_wait' into Candidate_v1.6.1

Conflicts:

tests/Python/AllActions/options.dat

  • two options introduced at same place, both get in.
Files:
9 added
20 edited

Legend:

Unmodified
Added
Removed
  • doc/userguide/userguide.xml

    r73faf4 rc8165c  
    11771177        <link linkend='geometry'>Geometry</link>.</para>
    11781178        </section>
     1179        <section xml:id="molecule.rotate-around-bond">
     1180          <title xml:id="molecule.rotate-around-bond.title">Rotate around bond </title>
     1181          <para>This rotates parts of a molecule around a given bond, i.e. the
     1182          bond vector becomes the rotation axis but only atoms on the side of
     1183          second atom get rotated. This naturally does not work for bonds in a
     1184          cycle.</para>
     1185          <programlisting>
     1186  ... --rotate-around-bond &quot;90&quot; \
     1187      --bond-side 0\
     1188   </programlisting>
     1189        </section>
    11791190        <section xml:id="molecule.rotate-around-self">
    11801191          <title xml:id="molecule.rotate-around-self.title">Rotate around self </title>
     
    26582669      under the command-line interface and look up the function name via
    26592670      help.</para>
     2671      <para>You can freely mix calls to the pymolecuilder module and other python commands.</para>
     2672      <note>However, be aware that all Actions are executed in another thread,
     2673      i.e. run in parallel. That means that a pymolecuilder command is not
     2674      necessarily finished when python steps on to the next line!</note>
     2675      <para>In order to make python wait for the Actions to finish before
     2676      stepping, there is the special wait() command.</para>
     2677      <programlisting>
     2678         mol.MoleculeLoad("...")
     2679         mol.wait()
     2680      </programlisting>
     2681      <para>This will continue first after the molecule has been fully loaded.
     2682      </para>
     2683      <warning>These wait()s will have no effect if the python script is loaded
     2684      via the "load-session" command inside a User Interface (command-line,
     2685      GUI, ...) as this would cause the queue to wait indefinitely, namely till
     2686      the load-session itself would have finished.</warning>
     2687      <para>Therefore, more complex python scripts need to be called with
     2688      python and a set PYTHONPATH as described above.</para>
    26602689    </section>
    26612690  </chapter>
  • src/Actions/Action.hpp

    r73faf4 rc8165c  
    2929 */
    3030#ifndef STATUS
    31 #define STATUS(msg) pushStatus(msg)
     31#define STATUS(msg) \
     32  pushStatus(msg); \
     33  LOG(0, "STATUS: " << msg)
    3234#endif
    3335
  • src/Actions/GlobalListOfActions.hpp

    r73faf4 rc8165c  
    8888  (MoleculeLoad) \
    8989  (MoleculeRemove) \
     90  (MoleculeRotateAroundBond) \
    9091  (MoleculeRotateAroundSelfByAngle) \
    9192  (MoleculeRotateToPrincipalAxisSystem) \
  • src/Actions/Makefile.am

    r73faf4 rc8165c  
    339339  Actions/MoleculeAction/LoadAction.cpp \
    340340  Actions/MoleculeAction/RemoveAction.cpp \
     341  Actions/MoleculeAction/RotateAroundBondAction.cpp \
    341342  Actions/MoleculeAction/RotateAroundSelfByAngleAction.cpp \
    342343  Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp \
     
    357358  Actions/MoleculeAction/LoadAction.hpp \
    358359  Actions/MoleculeAction/RemoveAction.hpp \
     360  Actions/MoleculeAction/RotateAroundBondAction.hpp \
    359361  Actions/MoleculeAction/RotateAroundSelfByAngleAction.hpp \
    360362  Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.hpp \
     
    375377  Actions/MoleculeAction/LoadAction.def \
    376378  Actions/MoleculeAction/RemoveAction.def \
     379  Actions/MoleculeAction/RotateAroundBondAction.def \
    377380  Actions/MoleculeAction/RotateAroundSelfByAngleAction.def \
    378381  Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def \
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.cpp

    r73faf4 rc8165c  
    3535//#include "CodePatterns/MemDebug.hpp"
    3636
     37#include "CodePatterns/Assert.hpp"
    3738#include "CodePatterns/Log.hpp"
    38 #include "CodePatterns/Verbose.hpp"
     39
     40#include "Actions/UndoRedoHelpers.hpp"
     41#include "Atom/AtomicInfo.hpp"
    3942#include "LinearAlgebra/Line.hpp"
    4043#include "LinearAlgebra/RealSpaceMatrix.hpp"
     
    5861  molecule *mol = NULL;
    5962
     63  std::vector<AtomicInfo> UndoInfo;
    6064  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
    6165    mol = iter->second;
    6266    LOG(0, "Converting to prinicipal axis system.");
    6367
    64     RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
     68    // gather undo information: store position of all atoms of molecule
     69    UndoInfo.reserve(UndoInfo.size()+mol->size());
     70    {
     71      for (molecule::const_iterator iter = const_cast<molecule const *>(mol)->begin();
     72          iter != const_cast<molecule const *>(mol)->end();
     73          ++iter) {
     74        const atom * const Walker = *iter;
     75        UndoInfo.push_back(AtomicInfo(*Walker));
     76      }
     77    }
    6578
     79    // rotate
     80//    RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
    6681    mol->RotateToPrincipalAxisSystem(params.Axis.get());
    6782
    6883    // summing anew for debugging (resulting matrix has to be diagonal!)
    69     InertiaTensor = mol->getInertiaTensor();
     84    RealSpaceMatrix InertiaTensor = mol->getInertiaTensor();
    7085  }
    71   return Action::success;
     86
     87  MoleculeRotateToPrincipalAxisSystemState *UndoState =
     88      new MoleculeRotateToPrincipalAxisSystemState(UndoInfo, params);
     89  return ActionState::ptr(UndoState);
    7290}
    7391
    7492ActionState::ptr MoleculeRotateToPrincipalAxisSystemAction::performUndo(ActionState::ptr _state) {
    75 //  MoleculeRotateToPrincipalAxisSystemState *state = assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
     93  MoleculeRotateToPrincipalAxisSystemState *state =
     94      assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
    7695
    77 //  string newName = state->mol->getName();
    78 //  state->mol->setName(state->lastName);
     96  // set stored old state
     97  SetAtomsFromAtomicInfo(state->undoinfo);
    7998
    80   STATUS("Undo of MoleculeRotateToPrincipalAxisSystemAction not implemented.");
    81   return Action::failure;
     99  return ActionState::ptr(_state);
    82100}
    83101
    84102ActionState::ptr MoleculeRotateToPrincipalAxisSystemAction::performRedo(ActionState::ptr _state){
    85   STATUS("Redo of MoleculeRotateToPrincipalAxisSystemAction not implemented.");
    86   return Action::failure;
     103  MoleculeRotateToPrincipalAxisSystemState *state =
     104      assert_cast<MoleculeRotateToPrincipalAxisSystemState*>(_state.get());
     105
     106  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection();
     107      iter != World::getInstance().endMoleculeSelection(); ++iter) {
     108    molecule * const mol = iter->second;
     109    mol->RotateToPrincipalAxisSystem(state->params.Axis.get());
     110  }
     111
     112  return ActionState::ptr(_state);
    87113}
    88114
  • src/Actions/MoleculeAction/RotateToPrincipalAxisSystemAction.def

    r73faf4 rc8165c  
    77
    88// all includes and forward declarations necessary for non-integral types below
     9#include <vector>
     10
    911#include "Actions/Values.hpp"
     12#include "Atom/AtomicInfo.hpp"
    1013#include "LinearAlgebra/Vector.hpp"
    1114
     
    2326(VectorNotZeroValidator())
    2427
    25 #undef statetypes
    26 #undef statereferences
     28#define statetypes (std::vector<AtomicInfo>)
     29#define statereferences (undoinfo)
    2730
    2831// some defines for all the names, you may use ACTION, STATE and PARAMS
  • src/Actions/PotentialAction/ParsePotentialsAction.cpp

    r73faf4 rc8165c  
    7373        deserialize();
    7474      } catch (SerializerMissingValueException &e) {
    75         if (const std::string *key = boost::get_error_info<SerializerKey>(e))
     75        if (const std::string *key = boost::get_error_info<SerializerKey>(e)) {
    7676          STATUS("Missing value when parsing information for potential "+*key+".");
    77         else
     77        } else
    7878          STATUS("Missing value parsing information for potential with unknown key.");
    7979        return Action::failure;
    8080      } catch (SerializerIllegalKeyException &e) {
    81         if (const std::string *key = boost::get_error_info<SerializerKey>(e))
     81        if (const std::string *key = boost::get_error_info<SerializerKey>(e)) {
    8282          STATUS("Illegal key parsing information for potential "+*key+".");
    83         else
     83        } else {
    8484          STATUS("Illegal key parsing information for potential with unknown key.");
     85        }
    8586        return Action::failure;
    8687      }
  • src/Actions/WorldAction/StepWorldTimeAction.cpp

    r73faf4 rc8165c  
    4747using namespace MoleCuilder;
    4848
    49 // if both are given, we use backwards
    50 static int getSteps(const unsigned int _forward, const unsigned int _backward)
    51 {
    52   int steps = 0;
    53   if (_backward > 0)
    54     steps = -_backward;
    55   else
    56     steps = _forward;
    57 
    58   return steps;
    59 }
    60 
    6149// and construct the stuff
    6250#include "StepWorldTimeAction.def"
     
    6957  WorldStepWorldTimeState *UndoState = new WorldStepWorldTimeState(oldtime, params);
    7058
    71   const int steps = getSteps(params.steps_forward.get(), params.steps_backward.get());
    72 
    73   if ((oldtime + steps) < 0) {
     59  if ((oldtime + params.steps.get()) < 0) {
    7460    ELOG(1, "Cannot step back before time step #0.");
    7561    delete UndoState;
    7662    return Action::failure;
    7763  }
    78   World::getInstance().setTime(oldtime+steps);
     64  World::getInstance().setTime(oldtime+params.steps.get());
    7965  LOG(0, "Current time step is now: " << WorldTime::getTime() << ".");
    8066  return ActionState::ptr(UndoState);
     
    9379  WorldStepWorldTimeState *state = assert_cast<WorldStepWorldTimeState*>(_state.get());
    9480
    95   const int steps = getSteps(
    96       state->params.steps_forward.get(),
    97       state->params.steps_backward.get());
    98 
    99   World::getInstance().setTime(state->oldtime+steps);
     81  World::getInstance().setTime(state->oldtime+state->params.steps.get());
    10082  LOG(0, "Current time step is now: " << WorldTime::getTime() << ".");
    10183
  • src/Actions/WorldAction/StepWorldTimeAction.def

    r73faf4 rc8165c  
    1414// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1515// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    16 #define paramtypes (unsigned int)(unsigned int)
    17 #define paramtokens ("steps-forward")("steps-backward")
    18 #define paramdescriptions ("how many steps to take forward or backward")("how many steps to take forward or backward")
    19 #define paramdefaults (PARAM_DEFAULT(1))(PARAM_DEFAULT(0))
    20 #define paramreferences (steps_forward)(steps_backward)
     16#define paramtypes (int)
     17#define paramtokens ("step-world-time")
     18#define paramdescriptions ("how many steps to take forward (positive) or backward (negative)")
     19#define paramdefaults (PARAM_DEFAULT(1))
     20#define paramreferences (steps)
    2121#define paramvalids \
    22 (DummyValidator< unsigned int >()) \
    23 (DummyValidator< unsigned int >())
     22(DummyValidator< int >())
    2423
    2524#define statetypes (unsigned int)
  • src/Atom/atom.cpp

    r73faf4 rc8165c  
    103103  LOG(4,"atom::UpdateStep() called.");
    104104  // append to position, velocity and force vector
    105   AtomInfo::AppendTrajectoryStep(WorldTime::getTime()+1);
     105  AtomInfo::AppendTrajectoryStep(WorldTime::getTime());
    106106  // append to ListOfBonds vector
    107   BondedParticleInfo::AppendTrajectoryStep(WorldTime::getTime()+1);
     107  BondedParticleInfo::AppendTrajectoryStep(WorldTime::getTime());
    108108}
    109109
  • src/Atom/atom_atominfo.cpp

    r73faf4 rc8165c  
    9191void AtomInfo::AppendTrajectoryStep(const unsigned int _step)
    9292{
    93   ASSERT (WorldTime::getTime() != _step,
    94       "AtomInfo::AppendTrajectoryStep() - cannot append current time step.");
    9593  NOTIFY(TrajectoryChanged);
    9694  AtomicPosition.insert( std::make_pair(_step, zeroVec) );
     
    105103void AtomInfo::removeTrajectoryStep(const unsigned int _step)
    106104{
    107   ASSERT (WorldTime::getTime() != _step,
    108       "AtomInfo::removeTrajectoryStep() - cannot remove current time step.");
    109105  NOTIFY(TrajectoryChanged);
    110106  AtomicPosition.erase(_step);
  • src/Fragmentation/Exporters/HydrogenPool.cpp

    r73faf4 rc8165c  
    9191      +" from pool is already in use.");
    9292  LOG(3, "DEBUG: Leasing " << *Walker << ".");
    93   UpdateSteps(Walker);
    9493  HydrogenInUse.insert( std::make_pair( Walker->getId(), Walker) );
    9594  HydrogenQueue.pop_front();
    9695
    9796  return Walker;
    98 }
    99 
    100 void HydrogenPool::UpdateSteps(atom * _atom) const
    101 {
    102   // make sure we are up to current time step
    103   const size_t CurrentTime = WorldTime::getTime();
    104   for (size_t step = _atom->getTrajectorySize(); step <= CurrentTime; ++step)
    105     _atom->UpdateStep(step);
    10697}
    10798
  • src/Fragmentation/Exporters/HydrogenPool.hpp

    r73faf4 rc8165c  
    7373  void cleanup();
    7474
    75   /** Helper function to make sure \a _atom is up to current time step.
    76    *
    77    * \param _atom atom to bring trajectory size up to speed
    78    */
    79   void UpdateSteps(atom * _atom) const;
    80 
    81 
    8275private:
    8376  //!> typedef for the deque of available hydrogens.
  • src/UIElements/CommandLineUI/CommandLineParser.cpp

    r73faf4 rc8165c  
    3636
    3737#include <boost/filesystem.hpp>
     38#include <boost/lexical_cast.hpp>
     39#include <boost/program_options/option.hpp>
     40#include <boost/program_options/value_semantic.hpp>
    3841#include <boost/program_options.hpp>
    3942#include <fstream>
     
    461464}
    462465
     466/** This is due to the answer by Aleksey Vitebskiy
     467 * in http://stackoverflow.com/questions/4107087/accepting-negative-doubles-with-boostprogram-options
     468 *
     469 */
     470std::vector<po::option> ignore_numbers(std::vector<std::string>& args)
     471{
     472    std::vector<po::option> result;
     473    int pos = 0;
     474    while(!args.empty()) {
     475        const std::string& arg = args[0];
     476        bool isNumber = true;
     477        try {
     478          boost::lexical_cast<double>(arg);
     479        } catch(boost::bad_lexical_cast) {
     480          isNumber = false;
     481        }
     482        if (isNumber) {
     483            result.push_back(po::option());
     484            po::option& opt = result.back();
     485
     486            opt.position_key = pos++;
     487            opt.value.push_back(arg);
     488            opt.original_tokens.push_back(arg);
     489
     490            args.erase(args.begin());
     491        } else {
     492            break;
     493        }
     494    }
     495
     496    return result;
     497}
     498
    463499/** Parses the command line arguments.
    464500 * Calls program_options::store() and program_options::notify()
     
    471507  bool status = true;
    472508  try {
    473     po::store(po::command_line_parser(argc,argv).options(cmdline_options).run(), vm);
     509    po::store(po::command_line_parser(argc,argv).extra_style_parser(&ignore_numbers).options(cmdline_options).run(), vm);
    474510  } catch (std::exception &e) {
    475511    std::cerr << "Something went wrong with parsing the command-line arguments: "
  • src/World.cpp

    r73faf4 rc8165c  
    221221}
    222222
    223 bool areBondsPresent(const unsigned int _step)
     223static bool areBondsPresent(const unsigned int _step)
    224224{
    225225  bool status = false;
     
    234234}
    235235
    236 void copyBondgraph(const unsigned int _srcstep, const unsigned int _deststep)
     236static bool areAtomsPresent(const unsigned int _step)
     237{
     238  bool status = false;
     239
     240  for (World::AtomConstIterator iter = const_cast<const World &>(World::getInstance()).getAtomIter();
     241      (!status) && (iter != const_cast<const World &>(World::getInstance()).atomEnd()); ++iter) {
     242    const atom * const Walker = *iter;
     243    status |= (Walker->getTrajectorySize() >= _step);
     244  }
     245
     246  return status;
     247}
     248
     249static void copyBondgraph(const unsigned int _srcstep, const unsigned int _deststep)
    237250{
    238251  // gather all bonds from _srcstep
     
    259272}
    260273
     274//static void copyAtoms(const unsigned int _srcstep, const unsigned int _deststep)
     275//{
     276//  for (World::AtomIterator iter = World::getInstance().getAtomIter();
     277//      iter != World::getInstance().atomEnd(); ++iter) {
     278//    atom * const Walker = *iter;
     279//    Walker->UpdateStep(_deststep);
     280//    Walker->setPositionAtStep(_deststep, Walker->getPositionAtStep(_srcstep));
     281//    Walker->setAtomicVelocityAtStep(_deststep, Walker->getAtomicVelocityAtStep(_srcstep));
     282//    Walker->setAtomicForceAtStep(_deststep, Walker->getAtomicForceAtStep(_srcstep));
     283//  }
     284//}
     285
    261286void World::setTime(const unsigned int _step)
    262287{
    263288  if (_step != WorldTime::getTime()) {
    264289    const unsigned int oldstep = WorldTime::getTime();
     290
     291//    if (!areAtomsPresent(_step))
     292//      copyAtoms(oldstep, _step);
    265293
    266294    // 1. copy bond graph (such not each addBond causes GUI update)
  • tests/Python/AllActions/options.dat

    r73faf4 rc8165c  
    3333bond-degree     "1"
    3434bond-file       "bond.dat"
     35bondside        "1"
    3536bond-table      "table.dat"
    3637calculate-bounding-box  ""
     
    166167reset   1
    167168reverse "0"
     169rotate-around-bond      "90."
    168170rotate-around-origin    "180."
    169171rotate-around-origin    "20."
     
    233235skiplines       "2"
    234236start-step      "0"
    235 steps-forward   "1"
    236 steps-backward  "0"
    237237steps   "5"
     238step-world-time "1"
    238239store-grids     "0"
    239240store-saturated-fragment        "BondFragment"
  • tests/regression/Makefile.am

    r73faf4 rc8165c  
    140140        $(srcdir)/Molecules/LinearInterpolationofTrajectories/testsuite-molecules-linear-interpolation-of-trajectories.at \
    141141        $(srcdir)/Molecules/Remove/testsuite-molecules-remove.at \
     142        $(srcdir)/Molecules/RotateAroundBond/testsuite-molecules-rotate-around-bond.at \
    142143        $(srcdir)/Molecules/RotateAroundOrigin/testsuite-molecules-rotate-around-origin.at \
    143144        $(srcdir)/Molecules/RotateAroundSelf/testsuite-molecules-rotate-around-self.at \
  • tests/regression/Molecules/RotateToPrincipalAxisSystem/testsuite-molecules-rotate-to-principal-axis-system.at

    r73faf4 rc8165c  
    4949
    5050AT_SETUP([Molecules - Rotate to PAS with Undo])
    51 AT_XFAIL_IF([/bin/true])
    5251AT_KEYWORDS([molecules rotate-to-principal-axis-system undo])
    5352
     
    8079
    8180AT_SETUP([Molecules - Rotate to PAS with Redo])
    82 AT_XFAIL_IF([/bin/true])
    8381AT_KEYWORDS([molecules rotate-to-principal-axis-system redo])
    8482
  • tests/regression/Molecules/testsuite-molecules.at

    r73faf4 rc8165c  
    6060m4_include([Molecules/RotateToPrincipalAxisSystem/testsuite-molecules-rotate-to-principal-axis-system.at])
    6161
     62# rotate around one of its bond
     63m4_include([Molecules/RotateAroundBond/testsuite-molecules-rotate-around-bond.at])
     64
    6265# Rotate around origin
    6366m4_include([Molecules/RotateAroundOrigin/testsuite-molecules-rotate-around-origin.at])
  • tests/regression/WorldTime/StepWorldTime/testsuite-worldtime-step-world-time.at

    r73faf4 rc8165c  
    2121AT_KEYWORDS([worldtime step-world-time set-world-time])
    2222
    23 AT_CHECK([../../molecuilder --step-world-time --steps-forward 1], 0, [stdout], [stderr])
     23AT_CHECK([../../molecuilder --step-world-time 1], 0, [stdout], [stderr])
    2424AT_CHECK([fgrep "Current time step is now: 1" stdout], 0, [ignore], [ignore])
    25 AT_CHECK([../../molecuilder --set-world-time 4 --step-world-time --steps-backward 2], 0, [stdout], [stderr])
     25AT_CHECK([../../molecuilder --set-world-time 4 --step-world-time -2], 0, [stdout], [stderr])
    2626AT_CHECK([fgrep "Current time step is now: 2" stdout], 0, [ignore], [ignore])
    2727# stepping back too far fails
    28 AT_CHECK([../../molecuilder --set-world-time 1 --step-world-time --steps-backward 2], 5, [stdout], [stderr])
     28AT_CHECK([../../molecuilder --set-world-time 1 --step-world-time -2], 5, [stdout], [stderr])
    2929
    3030AT_CLEANUP
     
    3434AT_KEYWORDS([worldtime step-world-time set-world-time undo])
    3535
    36 AT_CHECK([../../molecuilder --set-world-time 2 --step-world-time --steps-backward  1 --undo], 0, [stdout], [stderr])
     36AT_CHECK([../../molecuilder --set-world-time 2 --step-world-time -1 --undo], 0, [stdout], [stderr])
    3737AT_CHECK([fgrep "Current time step is now again: 2" stdout], 0, [ignore], [ignore])
    3838
     
    4242AT_KEYWORDS([worldtime step-world-time set-world-time undo redo])
    4343
    44 AT_CHECK([../../molecuilder --set-world-time 2 --step-world-time --steps-backward 1 --undo --redo], 0, [stdout], [stderr])
     44AT_CHECK([../../molecuilder --set-world-time 2 --step-world-time -1 --undo --redo], 0, [stdout], [stderr])
    4545AT_CHECK([fgrep "Current time step is now: 1" stdout], 0, [ignore], [ignore])
    4646
Note: See TracChangeset for help on using the changeset viewer.