Changes in / [dace6c:e38750]


Ignore:
Files:
46 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AtomAction/AddAction.cpp

    rdace6c re38750  
    5555#include "Action_impl_pre.hpp"
    5656/** =========== define the function ====================== */
     57
     58atom * getNewAtom(const AtomAddAction::AtomAddParameters &_params)
     59{
     60  atom * first = World::getInstance().createAtom();
     61  first->setType(_params.elemental.get());
     62  first->setPosition(_params.position.get());
     63
     64  return first;
     65}
     66
     67std::vector<atomId_t> createAtoms(
     68    const AtomAddAction::AtomAddParameters &_params,
     69    std::vector<molecule *> &_molecules)
     70{
     71  std::vector<atomId_t> ids;
     72  if (!_molecules.empty()) {
     73    if (_molecules.size() == 1) {
     74        atom *first = getNewAtom(_params);
     75        molecule *mol = *_molecules.begin();
     76        LOG(1, "Adding new atom with element " << first->getType()->getName()
     77            << " at " << (first->getPosition()) << " to selected molecule "
     78            << mol->getName()+".");
     79        mol->AddAtom(first);
     80      ids.push_back(first->getId());
     81    }
     82  } else {
     83    atom *first = getNewAtom(_params);
     84    molecule *mol = World::getInstance().createMolecule();
     85    mol->setName("none");
     86    mol->AddAtom(first);
     87    LOG(1, "Adding new atom with element " << first->getType()->getName()
     88        << " at " << (first->getPosition()) << " to new molecule.");
     89    ids.push_back(first->getId());
     90  }
     91
     92  return ids;
     93}
     94
    5795ActionState::ptr AtomAddAction::performCall() {
    5896  // execute action
    59   atom * first = World::getInstance().createAtom();
    60   first->setType(params.elemental.get());
    61   first->setPosition(params.position.get());
    62   LOG(1, "Adding new atom with element " << first->getType()->getName() << " at " << (first->getPosition()) << ".");
    63   // TODO: remove when all of World's atoms are stored.
    64   std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    65   if (!molecules.empty()) {
    66     std::vector<molecule *>::iterator iter = molecules.begin();
    67     (*iter)->AddAtom(first);
    68   }
    69   return ActionState::ptr(new AtomAddState(first->getId(), params));
     97  std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules();
     98  std::vector<atomId_t> ids = createAtoms(params, molecules);
     99
     100  if (molecules.size() > 1)
     101     return Action::failure;
     102  else
     103    return ActionState::ptr(new AtomAddState(ids, params));
    70104}
    71105
     
    73107  AtomAddState *state = assert_cast<AtomAddState*>(_state.get());
    74108
    75   LOG(1, "Removing atom with id " << state->id << ".");
    76   World::getInstance().destroyAtom(state->id);
     109  for (std::vector<atomId_t>::const_iterator iter = state->ids.begin();
     110      iter != state->ids.end(); ++iter) {
     111    LOG(1, "Removing atom with id " << *iter << ".");
     112    World::getInstance().destroyAtom(*iter);
     113  }
    77114
    78115  return ActionState::ptr(_state);
     
    82119  AtomAddState *state = assert_cast<AtomAddState*>(_state.get());
    83120
    84   atom * first = World::getInstance().createAtom();
    85   first->setType(state->params.elemental.get());
    86   first->setPosition(state->params.position.get());
    87   LOG(1, "Re-adding new atom with element " << state->params.elemental.get()->getName() << " at " << state->params.position.get() << ".");
    88   // TODO: remove when all of World's atoms are stored.
    89   std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
    90   if (!molecules.empty()) {
    91     std::vector<molecule *>::iterator iter = molecules.begin();
    92     (*iter)->AddAtom(first);
     121  std::vector<molecule *> molecules = World::getInstance().getSelectedMolecules();
     122  std::vector<atomId_t> newids = createAtoms(params, molecules);
     123
     124  if (newids.size() != state->ids.size()) {
     125    STATUS("Could not recreate all atoms after undo.");
     126    for (std::vector<atomId_t>::const_iterator iter = newids.begin(); iter != newids.end();++iter)
     127      World::getInstance().destroyAtom(*iter);
     128    return Action::failure;
    93129  }
    94   if (first->getId() != state->id)
    95     if (!first->changeId(state->id)) {
    96       STATUS("Could not change atom id "+toString(first->getId())+"->"+toString(state->id)+".");
    97       return Action::failure;
    98     }
    99130
    100   return ActionState::ptr(_state);
     131  std::vector<atomId_t>::const_iterator newiter = newids.begin();
     132  std::vector<atomId_t>::const_iterator olditer = state->ids.begin();
     133  bool status=true;
     134  for (; newiter != newids.end(); ++newiter, ++olditer) {
     135    atom * first = World::getInstance().getAtom(AtomById(*newiter));
     136    ASSERT( first != NULL,
     137        "AtomAddAction::performRedo() - re-created atom not present?");
     138    if (first->getId() != *olditer)
     139      if (!first->changeId(*olditer)) {
     140        STATUS("Could not change atom id "+toString(first->getId())+"->"+toString(*olditer)+".");
     141        // remove all created atoms
     142        for (std::vector<atomId_t>::const_iterator iter = state->ids.begin(); iter != olditer;++iter)
     143          World::getInstance().destroyAtom(*iter);
     144        olditer = state->ids.end();
     145        for (std::vector<atomId_t>::const_iterator iter = newiter; iter != newids.end();++iter)
     146          World::getInstance().destroyAtom(*iter);
     147        status = false;
     148        break;
     149      }
     150  }
     151  ASSERT( olditer == state->ids.end(),
     152      "AtomAddAction::performRedo() - after all unequal amount of ids in new and old?");
     153
     154  if (!status) {
     155    return Action::failure;
     156  } else
     157    return ActionState::ptr(_state);
    101158}
    102159
  • src/Actions/AtomAction/AddAction.def

    rdace6c re38750  
    2727(BoxVectorValidator())
    2828
    29 #define statetypes (const atomId_t)
    30 #define statereferences (id)
     29#define statetypes (std::vector<atomId_t>)
     30#define statereferences (ids)
    3131
    3232// some defines for all the names, you may use ACTION, STATE and PARAMS
  • src/Actions/AtomAction/SaturateAction.cpp

    rdace6c re38750  
    7979    // add the hydrogens
    8080    const Vector AtomsPosition = _atom->getPosition();
    81     double typical_distance = _atom->getType()->getHBondDistance(1);
     81    double typical_distance = _atom->getType()->getHBondDistance(0);
    8282    if (typical_distance == -1.)
    8383      typical_distance = 1.;
  • src/Actions/WorldAction/SetBoundaryConditionsAction.def

    rdace6c re38750  
    1818#define paramtypes (std::vector< std::string >)
    1919#define paramtokens ("set-boundary-conditions")
    20 #define paramdescriptions ("new boundary conditions as list of three strings, e.g. 'wrap wrap ignore'")
     20#define paramdescriptions ("new boundary conditions as list of three strings, e.g. 'Wrap Bounce Ignore'")
    2121#undef paramdefaults
    2222#define paramreferences (newconditions)
  • src/Atom/atom.cpp

    rdace6c re38750  
    264264  // first we move ourselves in the world
    265265  // the world lets us know if that succeeded
     266  atomId_t oldid = id;
    266267  if(world->changeAtomId(id,newId,this)){
    267268    OBSERVE;
    268269    id = newId;
     270    if (mol != NULL)
     271      mol->changeAtomId(oldid, newId);
    269272    NOTIFY(IndexChanged);
    270273    return true;
  • src/Element/element.cpp

    rdace6c re38750  
    6464    color[i] = (unsigned char)0;
    6565  for (size_t i =0; i<3;++i)
    66     HBondDistance[i] = 0.;
    67   for (size_t i =0; i<3;++i)
    68     HBondAngle[i] = 0.;
     66    HBondDistance[i] = -1.;
     67  for (size_t i =0; i<3;++i)
     68    HBondAngle[i] = -1.;
    6969};
    7070
  • src/Element/elements_db.cpp

    rdace6c re38750  
    258258const char *HbonddistanceDB =\
    259259"#atomic number bond distances for single, double and triple bond (-1 no bond)\n\
    260 1       0.74    -1      -1\n\
    261 2       0.77429209      -1      -1\n\
    262 5       1.23    1.19    1.18\n\
    263 6       1.09    1.076   1.06\n\
    264 7       1.04    1.02    1.01\n\
    265 8       0.96    0.957   -1\n\
    266 14      1.48    1.48    1.48\n\
    267 15      1.42    -1      -1\n\
    268 16      1.35    -1      -1\n\
    269 17      1.29    -1      -1\n\
    270 20      1.09    1.09    -1\n\
    271 34      1.47    -1      -1\n\
    272 35      1.44    -1      -1\n\
     2601       0.741283  -1. -1.\n\
     2612       0  -1. -1.\n\
     2623       1.65217  -1. -1.\n\
     2634       1.3455  -1. -1.\n\
     2645       1.1962  1.19 1.18\n\
     2656       1.09234  1.076 1.06\n\
     2667       1.00154  1.02 1.01\n\
     2678       0.941566  0.957 -1.\n\
     2689       0.958865  -1. -1.\n\
     26910      0  -1. -1.\n\
     27011      1.9426  -1. -1.\n\
     27112      1.73705  -1. -1.\n\
     27213      1.60991  -1. -1.\n\
     27314      1.49796  1.48 1.48\n\
     27415      1.39145  -1. -1.\n\
     27516      1.32987  -1. -1.\n\
     27617      1.31403  -1. -1.\n\
     27718      0  -1. -1.\n\
     27819      2.38168  -1. -1.\n\
     27920      2.39602  -1. -1.\n\
     28021      1.69169  -1. -1.\n\
     28122      1.69817  -1. -1.\n\
     28223      1.75022  -1. -1.\n\
     28324      1.79185  -1. -1.\n\
     28425      1.49581  -1. -1.\n\
     28526      1.76215  -1. -1.\n\
     28627      1.4284  -1. -1.\n\
     28728      1.56442  -1. -1.\n\
     28829      2.00512  -1. -1.\n\
     28930      1.55672  -1. -1.\n\
     29031      1.58872  -1. -1.\n\
     29132      1.5484  -1. -1.\n\
     29233      1.47208  -1. -1.\n\
     29334      1.43322  -1. -1.\n\
     29435      1.45079  -1. -1.\n\
     29536      0  -1. -1.\n\
    273296";
    274297
     
    2803037       0       110     106.67\n\
    2813048       0       104.5   -1\n\
     30511  0 -1 -1\n\
    28230614      0       120     109.47\n\
    28330715      0       -1      -1\n\
  • src/Element/unittests/ElementUnitTest.cpp

    rdace6c re38750  
    110110  CPPUNIT_ASSERT_EQUAL( 0, testelement->getNoValenceOrbitals() );
    111111  for (size_t i = 0; i < 3; ++i)
    112     CPPUNIT_ASSERT_EQUAL( 0., testelement->getHBondDistance(i) );
     112    CPPUNIT_ASSERT_EQUAL( -1., testelement->getHBondDistance(i) );
    113113  for (size_t i = 0; i < 3; ++i)
    114     CPPUNIT_ASSERT_EQUAL( 0., testelement->getHBondAngle(i) );
     114    CPPUNIT_ASSERT_EQUAL( -1., testelement->getHBondAngle(i) );
    115115}
    116116
  • src/Fragmentation/Exporters/SaturatedBond.cpp

    rdace6c re38750  
    6464      saturated_atom.getElement().getHBondDistance(saturated_bond.getDegree()-1);
    6565  ASSERT( HydrogenDistance > 0.,
    66       "SaturatedBond::SaturatedBond() - negative bond distance");
     66      "SaturatedBond::SaturatedBond() - negative bond distance for "
     67      +saturated_atom.getElement().getName());
    6768  const double HydrogenAngle =
    6869      saturated_atom.getElement().getHBondAngle(saturated_bond.getDegree()-1);
    6970  ASSERT( HydrogenAngle >= 0.,
    70       "SaturatedBond::SaturatedBond() - negative bond angle");
     71      "SaturatedBond::SaturatedBond() - negative bond angle for "
     72      +saturated_atom.getElement().getName());
    7173  LOG(5, "DEBUG: Hydrogen distance is " << HydrogenDistance
    7274      << ", angle is " << HydrogenAngle);
  • src/Graph/BondGraph.hpp

    rdace6c re38750  
    221221              neighboriter != ListOfNeighbors.end();
    222222              ++neighboriter) {
    223             if ((*neighboriter) > Walker) {  // just to not add bonds from both sides
    224               const atom * const OtherWalker = dynamic_cast<const atom *>(*neighboriter);
    225               ASSERT(OtherWalker != NULL,
    226                   "BondGraph::CreateAdjacency() - TesselPoint "
    227                   +(*neighboriter)->getName()+" that was not an atom retrieved from LinkedList");
     223            const atom * const OtherWalker = dynamic_cast<const atom *>(*neighboriter);
     224            ASSERT(OtherWalker != NULL,
     225                "BondGraph::CreateAdjacency() - TesselPoint "
     226                +(*neighboriter)->getName()+" that was not an atom retrieved from LinkedList");
     227            if (OtherWalker->getId() > Walker->getId()) {  // just to not add bonds from both sides
    228228              LOG(4, "INFO: Current other atom is " << *OtherWalker << ".");
    229229
     
    245245              }
    246246            } else {
    247               LOG(5, "REJECT: Not Adding: Wrong order.");
     247              LOG(4, "REJECT: Not Adding: Wrong order.");
    248248            }
    249249          }
  • src/Parameters/Specifics/Value_element.cpp

    rdace6c re38750  
    3535#include "CodePatterns/MemDebug.hpp"
    3636
     37#include <boost/lexical_cast.hpp>
     38
    3739#include "Value_element.hpp"
    3840
     
    4547static const element * FindElementByString(const std::string &_value)
    4648{
    47   static ConvertTo<atomicNumber_t> converter;
    48   const element * _element =
    49       World::getInstance().getPeriode()->FindElement(converter(_value));
    50   return _element;
     49  const element * elem = NULL;
     50  try {
     51    const int tempvalue = boost::lexical_cast<atomicNumber_t>(_value);
     52    elem = World::getInstance().getPeriode()->FindElement(tempvalue);
     53  } catch( boost::bad_lexical_cast &e) {
     54    elem = World::getInstance().getPeriode()->FindElement(_value);
     55  }
     56  return elem;
    5157}
    5258
  • src/Parameters/Specifics/Value_elements.cpp

    rdace6c re38750  
    5757  for(tokenizer::iterator beg=tok.begin();
    5858      beg != tok.end();++beg) {
    59     const int tempvalue = boost::lexical_cast<atomicNumber_t>(*beg);
    60     const element * _element =
    61         World::getInstance().getPeriode()->FindElement(tempvalue);
    62     ASSERT( _element != NULL,
     59    const element * elem = NULL;
     60    try {
     61      const int tempvalue = boost::lexical_cast<atomicNumber_t>(*beg);
     62      elem = World::getInstance().getPeriode()->FindElement(tempvalue);
     63    } catch( boost::bad_lexical_cast &e) {
     64      elem = World::getInstance().getPeriode()->FindElement(*beg);
     65    }
     66    ASSERT( elem != NULL,
    6367        "FindElementsByString() - cannnot find element "
    64         +toString(tempvalue)+" in periodentafel.");
    65     elements.push_back(_element);
     68        +toString(*beg)+" in periodentafel.");
     69    elements.push_back(elem);
    6670  }
    6771  return elements;
  • src/Parser/MpqcParser.cpp

    rdace6c re38750  
    309309    *file << "% Created by MoleCuilder" << endl;
    310310    *file << "mpqc: (" << endl;
     311    *file << "\tcheckpoint = no" << endl;
    311312    *file << "\tsavestate = " << getParams().getParameter(MpqcParser_Parameters::savestateParam) << endl;
    312313    *file << "\tdo_gradient = " << getParams().getParameter(MpqcParser_Parameters::do_gradientParam) << endl;
     
    374375      ELOG(0, "Unknown level of theory requested for MPQC output file.");
    375376    }
     377    const std::string jobtype = getParams().getParameter(MpqcParser_Parameters::jobtypeParam);
     378    if (jobtype == getParams().getJobtypeName(MpqcParser_Parameters::Optimization)) {
     379      *file << "\t% optimizer object for the molecular geometry" << endl;
     380      *file << "\topt<QNewtonOpt>: (" << endl;
     381      *file << "\t\tfunction = $..:mole" << endl;
     382      *file << "\t\tupdate<BFGSUpdate>: ()" << endl;
     383      *file << "\t\tconvergence<MolEnergyConvergence>: (" << endl;
     384      *file << "\t\t\tcartesian = yes" << endl;
     385      *file << "\t\t\tenergy = $..:..:mole" << endl;
     386      *file << "\t\t)" << endl;
     387      *file << "\t)" << endl;
     388    }
    376389    *file << ")" << endl;
    377390    *file << "molecule<Molecule>: (" << endl;
  • src/Parser/MpqcParser_Parameters.cpp

    rdace6c re38750  
    6969    ParamNames[integrationParam] = "integration";
    7070    ParamNames[theoryParam] = "theory";
     71    ParamNames[jobtypeParam] = "jobtype";
    7172  }
    7273
     
    8788  //InvertMap<TheoryNamesType,TheoryLookupType>(TheoryNames,TheoryLookup);
    8889
     90  // create Jobs parameter
     91  {
     92    ValidJobtypes.clear();
     93    ValidJobtypes.resize(unknownJob);
     94    ValidJobtypes[Default]="Default";
     95    ValidJobtypes[Optimization]="Optimization";
     96    appendParameter(
     97        new Parameter<std::string>(
     98            ParamNames[jobtypeParam],
     99            ValidJobtypes,
     100            ValidJobtypes[Default]));
     101  }
     102
    89103  // create integration parameter
    90104  {
     
    177191}
    178192
     193/** Getter for name of a specific Parameter.
     194 *
     195 * @param param index among enum Jobtype
     196 * @return name of the desired Jobtype
     197 */
     198const std::string &MpqcParser_Parameters::getJobtypeName(const enum Jobtype jobtype) const
     199{
     200  return ValidJobtypes[jobtype];
     201}
     202
    179203/** Getter for the name of specific of IntegrationMethod.
    180204 *
  • src/Parser/MpqcParser_Parameters.hpp

    rdace6c re38750  
    5858    integrationParam,//!< integrationParam, integration method to use in MBPT2 R12
    5959    theoryParam,     //!< theoryParam, level of theory to use
     60    jobtypeParam,    //!< jobtypeParam, job type to use
    6061    unknownParam};   //!< unknownParam, designates an unknown parameter
    6162
     
    6970    MBPT2_R12,  //!< Moeller Plesset Perturbation Theory second order with R12 integral
    7071    unknownTheory //!< designates an unknown theory
     72  };
     73
     74  /** Enumeration of all known jobtypes.
     75   *
     76   */
     77  enum Jobtype {
     78    Default,       //!< standard energy and force calculation
     79    Optimization,       //!< additional optimization of geometry
     80    unknownJob //!< designates an unknown job
    7181  };
    7282
     
    93103  const std::string &getParameterName(const enum Parameters param) const;
    94104  const std::string &getTheoryName(const enum Theory theory) const;
     105  const std::string &getJobtypeName(const enum Jobtype jobtype) const;
    95106  const std::string &getIntegrationMethodName(const enum IntegrationMethod integration) const;
    96107
     
    99110  //!> vector with all available theories in same order as enum Theory.
    100111  std::vector<std::string> ValidTheories;
     112
     113  //!> vector with all available jobtypes in same order as enum Jobs.
     114  std::vector<std::string> ValidJobtypes;
    101115
    102116  //!> vector with all available integration methods in same order as enum IntegrationMethod.
  • src/Parser/unittests/ParserMpqcUnitTest.cpp

    rdace6c re38750  
    6363static string waterMpqc_CLHF ="% Created by MoleCuilder\n\
    6464mpqc: (\n\
     65\tcheckpoint = no\n\
    6566\tsavestate = no\n\
    6667\tdo_gradient = yes\n\
     
    8687static string waterMpqc_CLKS ="% Created by MoleCuilder\n\
    8788mpqc: (\n\
     89\tcheckpoint = no\n\
    8890\tsavestate = no\n\
    8991\tdo_gradient = yes\n\
     
    110112static string waterMpqc_MBPT2 ="% Created by MoleCuilder\n\
    111113mpqc: (\n\
     114\tcheckpoint = no\n\
    112115\tsavestate = no\n\
    113116\tdo_gradient = yes\n\
     
    138141static string waterMpqc_MBPT2_R12 ="% Created by MoleCuilder\n\
    139142mpqc: (\n\
     143\tcheckpoint = no\n\
    140144\tsavestate = no\n\
    141145\tdo_gradient = yes\n\
  • src/UIElements/CommandLineUI/CommandLineParser.cpp

    rdace6c re38750  
    390390//            currentOption->hasDefaultValue() ?
    391391//                  po::value < const element * >()->default_value(boost::lexical_cast<const element *>(currentOption->getDefaultValue().c_str())) :
    392                   po::value < int >(),
     392                  po::value < std::string >(),
    393393                  currentOption->getDescription().c_str())
    394394        ;
     
    399399//            currentOption->hasDefaultValue() ?
    400400//                  po::value < std::vector<const element *> >()->default_value(boost::lexical_cast< std::vector<const element *> >(currentOption->getDefaultValue().c_str())) :
    401                   po::value < std::vector<int> >()->multitoken(),
     401                  po::value < std::vector<std::string> >()->multitoken(),
    402402                  currentOption->getDescription().c_str())
    403403        ;
  • src/UIElements/CommandLineUI/Query/ElementCommandLineQuery.cpp

    rdace6c re38750  
    3636#include "CodePatterns/MemDebug.hpp"
    3737
     38#include <string>
     39
    3840#include "CommandLineUI/Query/CommandLineQuery.hpp"
    3941#include "CommandLineUI/CommandLineParser.hpp"
     
    5456  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    5557  periodentafel *periode = World::getInstance().getPeriode();
    56   int Z = -1;
    5758  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     59    std::string argument("none");
    5860    try {
    59       Z = CommandLineParser::getInstance().vm[getTitle()].as< int >();
     61      argument = CommandLineParser::getInstance().vm[getTitle()].as< std::string >();
     62      try {
     63        int Z = -1;
     64        Z = boost::lexical_cast<int>(argument);
     65        temp = periode->FindElement(Z);
     66      } catch(boost::bad_lexical_cast &e) {
     67        temp = periode->FindElement(argument);
     68      }
    6069    } catch(boost::bad_any_cast &e) {
    61       Z = -1;
    6270      return false;
    6371    }
    64     temp = periode->FindElement(Z);
    6572    ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
    6673    return true;
  • src/UIElements/CommandLineUI/Query/ElementsCommandLineQuery.cpp

    rdace6c re38750  
    3636#include "CodePatterns/MemDebug.hpp"
    3737
     38#include <string>
     39
    3840#include "CommandLineUI/Query/CommandLineQuery.hpp"
    3941#include "CommandLineUI/CommandLineParser.hpp"
     
    5153{}
    5254
     55template <typename T>
     56std::vector<const element *> getElementsFromInput(const std::vector<std::string> &_input)
     57{
     58  periodentafel *periode = World::getInstance().getPeriode();
     59  std::vector<const element *> result;
     60  const element *temp_element;
     61  for (typename std::vector<std::string>::const_iterator ZRunner = _input.begin(); ZRunner != _input.end(); ++ZRunner) {
     62    const T argument = boost::lexical_cast<T>(*ZRunner);
     63    temp_element = periode->FindElement(argument);
     64    ASSERT(temp_element != NULL, "Invalid element specified in ElementCommandLineQuery");
     65    result.push_back(temp_element);
     66  }
     67  return result;
     68}
     69
    5370bool CommandLineDialog::ElementsCommandLineQuery::handle() {
    5471  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    55   periodentafel *periode = World::getInstance().getPeriode();
    56   std::vector<int> AllElements;
    5772  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5873    try {
    59       AllElements = CommandLineParser::getInstance().vm[getTitle()].as< vector<int> >();
     74      std::vector<std::string> AllArguments;
     75      AllArguments = CommandLineParser::getInstance().vm[getTitle()].as< vector<std::string> >();
     76      try {
     77        temp = getElementsFromInput<int>(AllArguments);
     78      } catch(boost::bad_lexical_cast &e) {
     79        try {
     80        temp = getElementsFromInput<std::string>(AllArguments);
     81        } catch(boost::bad_lexical_cast &e) {
     82          return false;
     83        }
     84      }
    6085    } catch(boost::bad_any_cast &e) {
    61       AllElements.clear();
    6286      return false;
    6387    }
    64     const element *temp_element;
    65     for (vector<int>::iterator ZRunner = AllElements.begin(); ZRunner != AllElements.end(); ++ZRunner) {
    66       temp_element = periode->FindElement(*ZRunner);
    67       ASSERT(temp_element != NULL, "Invalid element specified in ElementCommandLineQuery");
    68       temp.push_back(temp_element);
    69     }
    70     return true;
     88    if (temp.empty())
     89      return false;
     90    else
     91      return true;
    7192  }
    7293  return false;
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp

    rdace6c re38750  
    8585const Observable::channels_t GLMoleculeObject_molecule::AtomsChannels(getAtomsChannels());
    8686const Observable::channels_t GLMoleculeObject_molecule::HullChannels(getAllAtomicChangesChannels());
    87 const Observable::channels_t GLMoleculeObject_molecule::BoundingBoxChannels(getAllAtomicChangesChannels());
     87const Observable::channels_t GLMoleculeObject_molecule::BoundingBoxChannels(1, molecule::BoundingBoxChanged);
    8888const Observable::channels_t GLMoleculeObject_molecule::IndexChannels(1, molecule::IndexChanged);
    8989const Observable::channels_t GLMoleculeObject_molecule::NameChannels(1, molecule::MoleculeNameChanged);
     
    403403}
    404404
    405 GLMoleculeObject_molecule::BoundingBoxInfo GLMoleculeObject_molecule::initBoundingBox() const
    406 {
    407   BoundingBoxInfo info;
     405molecule::BoundingBoxInfo GLMoleculeObject_molecule::initBoundingBox() const
     406{
     407  molecule::BoundingBoxInfo info;
    408408  info.position = zeroVec;
    409409  info.radius = 0.;
     
    411411}
    412412
    413 GLMoleculeObject_molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox() const
    414 {
    415   BoundingBoxInfo info = BoundingBox.get();
     413molecule::BoundingBoxInfo GLMoleculeObject_molecule::updateBoundingBox() const
     414{
     415  molecule::BoundingBoxInfo info = BoundingBox.get();
    416416  const molecule * const _molecule = getMolecule(MolIndex.get());
    417417  if (_molecule != NULL) {
     
    472472void GLMoleculeObject_molecule::resetBoundingBox()
    473473{
    474   BoundingBoxInfo info = BoundingBox.get();
     474  molecule::BoundingBoxInfo info = BoundingBox.get();
    475475  setPosition(QVector3D(info.position[0], info.position[1], info.position[2]));
    476476  setScale(info.radius + 0.3); // getBoundingSphere() only sees atoms as points, so make the box a bit bigger
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.hpp

    rdace6c re38750  
    2424#include "GLMoleculeObject_bond.hpp"
    2525
     26#include "molecule.hpp"
     27
    2628class atom;
    2729class bond;
    2830class GLMoleculeObject_atom;
    2931class GLWorldScene;
    30 class molecule;
    3132
    3233class GLMoleculeObject_molecule : public GLMoleculeObject, public Observer
     
    109110  typedef std::set<atomId_t> atoms_t;
    110111
    111   /** Structure for the required information on the bounding box.
    112    *
    113    */
    114   struct BoundingBoxInfo {
    115     //!> position of center
    116     Vector position;
    117     //!> radius of sphere
    118     double radius;
    119   };
    120 
    121   /** Structure for the required information on the tesselation hull.
    122    *
    123    */
    124   struct TesselationHullInfo {
    125   };
    126 
    127   BoundingBoxInfo initBoundingBox() const;
     112  molecule::BoundingBoxInfo initBoundingBox() const;
    128113
    129114  QGeometryData updateTesselationHull() const;
    130   BoundingBoxInfo updateBoundingBox() const;
     115  molecule::BoundingBoxInfo updateBoundingBox() const;
    131116  atoms_t updateAtoms();
    132117  moleculeId_t updateIndex() const;
     
    153138  boost::function<std::string ()> MolNameUpdater;
    154139  boost::function<QGeometryData ()> TesselationHullUpdater;
    155   boost::function<BoundingBoxInfo ()> BoundingBoxUpdater;
     140  boost::function<molecule::BoundingBoxInfo ()> BoundingBoxUpdater;
    156141  boost::function<atoms_t ()> PresentAtomsUpdater;
    157142
     
    163148  Cacheable<QGeometryData> TesselationHull;
    164149  //!> contains newest version of the bounding box on request
    165   ObservedValue<BoundingBoxInfo> BoundingBox;
     150  ObservedValue<molecule::BoundingBoxInfo> BoundingBox;
    166151  //!> contains the current live set of atoms for the molecule
    167152  ObservedValue<atoms_t> PresentAtoms;
  • src/World.cpp

    rdace6c re38750  
    396396  if (isAtomSelected(id))
    397397    selectedAtoms.erase(id);
     398  DeleteAtom(atom);
    398399  atoms.erase(id);
    399   DeleteAtom(atom);
    400400  atomIdPool.releaseId(id);
    401401  // remove molecule if empty
  • src/molecule.cpp

    rdace6c re38750  
    3636
    3737#include <algorithm>
     38#include <boost/assign.hpp>
    3839#include <boost/bind.hpp>
    3940#include <boost/foreach.hpp>
     
    5051#include "CodePatterns/enumeration.hpp"
    5152#include "CodePatterns/Log.hpp"
     53#include "CodePatterns/Observer/Observable.hpp"
    5254#include "CodePatterns/Observer/Notification.hpp"
    5355#include "config.hpp"
     
    6769#include "WorldTime.hpp"
    6870
     71using namespace boost::assign;
     72
     73// static entities
     74static Observable::channels_t getBoundingBoxChannels()
     75{
     76  Observable::channels_t channels;
     77  channels += molecule::AtomInserted, molecule::AtomRemoved, molecule::AtomMoved;
     78  return channels;
     79}
    6980
    7081/************************************* Functions for class molecule *********************************/
     
    8394  BondCount(this,boost::bind(&molecule::doCountBonds,this),"BondCount"),
    8495  atomIdPool(1, 20, 100),
     96  BoundingBoxSweepingAxis(std::vector<AtomDistanceMap_t>(NDIM)),
    8597  _lastchangedatomid(-1),
    8698  last_atom(0)
     
    92104    OurChannel->addChannel(type);
    93105
     106  // cannot initialize in initializer body as then channels have not been setup yet
     107  BoundingBox.reset(
     108      new Cacheable<BoundingBoxInfo>(
     109          this, boost::bind(&molecule::updateBoundingBox, boost::cref(this)), "molecule_BoundingBox", getBoundingBoxChannels()));
     110
    94111  strcpy(name,World::getInstance().getDefaultName().c_str());
    95 };
     112}
    96113
    97114molecule *NewMolecule(){
     
    170187}
    171188
     189bool molecule::changeAtomId(int oldId, int newId)
     190{
     191  OBSERVE;
     192  if ((!atomIds.contains( oldId )) || (atomIds.contains( newId )))
     193    return false;
     194  atomIds.erase( oldId );
     195  atomIds.insert( newId );
     196  // also update BoundingBoxSweepingAxis
     197  for (int i=0;i<NDIM;++i) {
     198    AtomDistanceMap_t::left_iterator iter = BoundingBoxSweepingAxis[i].left.find(oldId);
     199    ASSERT(iter != BoundingBoxSweepingAxis[i].left.end(),
     200        "molecule::changeAtomId() - could not find atom "+toString(oldId)
     201        +" in BoundingBoxSweepingAxis.");
     202    const double component = iter->second;
     203    BoundingBoxSweepingAxis[i].left.erase(iter);
     204    BoundingBoxSweepingAxis[i].left.insert( std::make_pair(newId, component) );
     205  }
     206  return true;
     207}
     208
    172209bool molecule::changeId(moleculeId_t newId){
    173210  // first we move ourselves in the world
     
    227264  atomIds.erase( _atom->getId() );
    228265  {
     266    BoundingBoxInfo oldinfo = updateBoundingBox();
     267    for (int i=0;i<NDIM;++i)
     268      BoundingBoxSweepingAxis[i].left.erase( _atom->getId() );
     269    BoundingBoxInfo newinfo = updateBoundingBox();
     270    if (oldinfo != newinfo)
     271      NOTIFY(BoundingBoxChanged);
     272  }
     273  {
    229274    NOTIFY(AtomNrChanged);
    230275    atomIdPool.releaseId(_atom->getNr());
     
    240285molecule::const_iterator molecule::erase( atom * key )
    241286{
    242   OBSERVE;
    243   {
    244     _lastchangedatomid = key->getId();
    245     NOTIFY(AtomRemoved);
    246   }
    247287  const_iterator iter = const_cast<const molecule &>(*this).find(key);
    248   if (iter != const_cast<const molecule &>(*this).end()){
    249     ++iter;
    250     atomIds.erase( key->getId() );
    251     {
    252       NOTIFY(AtomNrChanged);
    253       atomIdPool.releaseId(key->getNr());
    254       LocalToGlobalId.erase(key->getNr());
    255       key->setNr(-1);
    256     }
    257     NOTIFY(FormulaChanged);
    258     formula-=key->getType();
    259     key->removeFromMolecule();
    260   }
    261   return iter;
     288  if (iter != const_cast<const molecule &>(*this).end())
     289    return erase(iter);
     290  else
     291    return iter;
    262292}
    263293
     
    269299  std::pair<iterator,bool> res = atomIds.insert(key->getId());
    270300  if (res.second) { // push atom if went well
     301    {
     302      BoundingBoxInfo oldinfo = updateBoundingBox();
     303      for (int i=0;i<NDIM;++i)
     304        BoundingBoxSweepingAxis[i].left.insert( std::make_pair(key->getId(), key->getPosition()[i]));
     305      BoundingBoxInfo newinfo = updateBoundingBox();
     306      if (oldinfo != newinfo)
     307        NOTIFY(BoundingBoxChanged);
     308    }
    271309    NOTIFY(AtomNrChanged);
    272310    key->setNr(atomIdPool.getNextId());
     
    10381076}
    10391077
     1078molecule::BoundingBoxInfo molecule::updateBoundingBox() const
     1079{
     1080  BoundingBoxInfo info;
     1081  Vector min = zeroVec;
     1082  Vector max = zeroVec;
     1083  for (int i=0;i<NDIM;++i) {
     1084    if (!BoundingBoxSweepingAxis[i].right.empty()) {
     1085      min[i] = BoundingBoxSweepingAxis[i].right.begin()->first;
     1086      max[i] = BoundingBoxSweepingAxis[i].right.rbegin()->first;
     1087    }
     1088  }
     1089  info.radius = (.5*(max-min)).Norm();
     1090  info.position = .5*(max+min);
     1091  return info;
     1092}
     1093
     1094molecule::BoundingBoxInfo molecule::getBoundingBox() const
     1095{
     1096  return **BoundingBox;
     1097}
     1098
    10401099void molecule::update(Observable *publisher)
    10411100{
     
    10571116        // emit others about one of our atoms moved
    10581117        _lastchangedatomid = _atom->getId();
     1118        // update entry in map
     1119        BoundingBoxInfo oldinfo = updateBoundingBox();
     1120        for (int i=0;i<NDIM;++i) {
     1121          AtomDistanceMap_t::left_iterator iter = BoundingBoxSweepingAxis[i].left.find(_atom->getId());
     1122          ASSERT(iter != BoundingBoxSweepingAxis[i].left.end(),
     1123              "molecule::recieveNotification() - could not find atom "+toString(_atom->getId())
     1124              +" in BoundingBoxSweepingAxis.");
     1125          BoundingBoxSweepingAxis[i].left.erase(iter);
     1126          BoundingBoxSweepingAxis[i].left.insert(
     1127              std::make_pair(_atom->getId(), _atom->getPosition()[i]) );
     1128        }
     1129        BoundingBoxInfo newinfo = updateBoundingBox();
    10591130        OBSERVE;
    10601131        NOTIFY(AtomMoved);
     1132        if (oldinfo != newinfo)
     1133          NOTIFY(BoundingBoxChanged);
    10611134        break;
    10621135      }
  • src/molecule.hpp

    rdace6c re38750  
    2222
    2323#include <string>
     24
     25#include <boost/bimap/bimap.hpp>
     26#include <boost/bimap/unordered_set_of.hpp>
     27#include <boost/bimap/multiset_of.hpp>
     28#include <boost/optional.hpp>
     29#include <boost/shared_ptr.hpp>
    2430
    2531#include "AtomIdSet.hpp"
     
    115121    MoleculeNameChanged,
    116122    IndexChanged,
     123    BoundingBoxChanged,
    117124    AboutToBeRemoved,
    118125    NotificationType_MAX
     
    238245  bool changeAtomNr(int oldNr, int newNr, atom* target=0);
    239246
     247  friend bool atom::changeId(atomId_t newId);
     248  /**
     249   * used when changing an ParticleInfo::Id.
     250   * Note that this number is global (and the molecule uses it to know which atoms belong to it)
     251   *
     252   * @param oldId old Id
     253   * @param newId new Id to set
     254   * @return indicates wether the change could be done or not.
     255   */
     256  bool changeAtomId(int oldId, int newId);
     257
    240258  /** Updates the internal lookup fro local to global indices.
    241259   *
     
    260278
    261279public:
     280
     281  /** Structure for the required information on the bounding box.
     282   *
     283   */
     284  struct BoundingBoxInfo {
     285    //!> position of center
     286    Vector position;
     287    //!> radius of sphere
     288    double radius;
     289
     290    /** Equivalence operator for bounding box.
     291     *
     292     * \return true - both bounding boxes have same position and radius
     293     */
     294    bool operator==(const BoundingBoxInfo &_other) const
     295    {  return (radius == _other.radius) && (position == _other.position); }
     296
     297    /** Inequivalence operator for bounding box.
     298     *
     299     * \return true - bounding boxes have either different positions or different radii or both
     300     */
     301    bool operator!=(const BoundingBoxInfo &_other) const
     302    { return !(*this == _other); }
     303  };
     304
     305private:
     306
     307  /** Returns the current bounding box.
     308   *
     309   * \return Shape with center and extension of box
     310   */
     311  BoundingBoxInfo updateBoundingBox() const;
     312
     313  // stuff for keeping bounding box up-to-date efficiently
     314
     315  //!> Cacheable for the bounding box, ptr such that
     316  boost::shared_ptr< Cacheable<BoundingBoxInfo> > BoundingBox;
     317  /** Bimap storing atomic ids and the component per axis.
     318   *
     319   * We need a bimap in order to have the components sorted and be able to
     320   * access max and min values in linear time and also access the ids in
     321   * constant time in order to update the map, when atoms move, are inserted,
     322   * or removed.
     323   */
     324  typedef boost::bimaps::bimap<
     325          boost::bimaps::unordered_set_of< atomId_t >,
     326          boost::bimaps::multiset_of< double, std::greater<double> >
     327      > AtomDistanceMap_t;
     328  std::vector<AtomDistanceMap_t> BoundingBoxSweepingAxis;
     329
     330public:
     331
     332  /** Returns the current bounding box of this molecule.
     333   *
     334   * \return bounding box info with center and radius
     335   */
     336  BoundingBoxInfo getBoundingBox() const;
    262337
    263338  /** Function to create a bounding spherical shape for the currently associated atoms.
  • tests/regression/Atoms/Add/post/test.in

    rdace6c re38750  
    11% Created by MoleCuilder
    22mpqc: (
     3        checkpoint = no
    34        savestate = no
    45        do_gradient = yes
  • tests/regression/Atoms/Add/post/test.pdb

    rdace6c re38750  
    11REMARK created by molecuilder on Wed Feb  2 18:06:07 2011
    2 ATOM      1 H01 0-   00         10.000  10.000  10.000  0.00  0.00           H 0
     2ATOM      1 H01 0non 01         10.000  10.000  10.000  0.00  0.00           H 0
    33END
  • tests/regression/Atoms/Remove/post/test.in

    rdace6c re38750  
    11% Created by MoleCuilder
    22mpqc: (
     3        checkpoint = no
    34        savestate = no
    45        do_gradient = yes
  • tests/regression/Atoms/Saturate/post/saturated_carbon.xyz

    rdace6c re38750  
    115
    2         Created by molecuilder on Wed Jan 28 20:57:11 2015, time step 0
     2        Created by molecuilder on Wed Sep 30 19:50:39 2015, time step 0
    33C       10      10      10
    4 H       11.076  10      10
    5 H       9.64133 11.0145 10
    6 H       9.64133 9.49277 10.8786
    7 H       9.64133 9.49277 9.12145
     4H       11.0923 10      10
     5H       9.63589 11.0299 10
     6H       9.63589 9.48507 10.8919
     7H       9.63589 9.48507 9.10811
  • tests/regression/Atoms/Saturate/post/saturated_nitrogen.xyz

    rdace6c re38750  
    114
    2         Created by molecuilder on Wed Jan 28 21:41:39 2015, time step 0
     2        Created by molecuilder on Wed Sep 30 19:50:40 2015, time step 0
    33N       10      10      10
    4 H       11.02   10      10
    5 H       9.49    10.866  10
    6 H       9.49    9.13397 10
     4H       11.0015 10      10
     5H       9.49923 10.866  10
     6H       9.49923 9.13397 10
  • tests/regression/Parser/Mpqc/post/doublewater.in

    rdace6c re38750  
    11% Created by MoleCuilder
    22mpqc: (
     3        checkpoint = no
    34        savestate = no
    45        do_gradient = yes
  • tests/regression/Parser/Mpqc/post/empty.in

    rdace6c re38750  
    11% Created by MoleCuilder
    22mpqc: (
     3        checkpoint = no
    34        savestate = no
    45        do_gradient = yes
  • tests/regression/Parser/Mpqc/post/test.in

    rdace6c re38750  
    11% Created by MoleCuilder
    22mpqc: (
     3        checkpoint = no
    34        savestate = no
    45        do_gradient = yes
  • tests/regression/Parser/Mpqc/post/testCLHF.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/post/testCLKS.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/post/testMBPT2.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/post/testMBPT2_R12.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testCLHF.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testCLHF_n.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testCLHF_n_ascend_ids.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testCLHF_n_mixed_ids.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testCLKS.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testMBPT2.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/testMBPT2_R12.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/Mpqc/pre/water.in

    rdace6c re38750  
    11% Created by MoleCuilder
    22mpqc: (
     3        checkpoint = no
    34        savestate = no
    45        do_gradient = yes
  • tests/regression/Parser/SetParameters/Mpqc/post/testCLHF.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
  • tests/regression/Parser/SetParameters/Mpqc/pre/testCLHF.in

    rdace6c re38750  
    11mpqc: (
     2        checkpoint = no
    23        savestate = no
    34        do_gradient = yes
Note: See TracChangeset for help on using the changeset viewer.