Changeset 8f4df1 for src/molecule.cpp


Ignore:
Timestamp:
Aug 7, 2010, 12:07:04 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, Candidate_v1.7.0, 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:
2d292d
Parents:
8d6d31 (diff), d74077 (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 'AtomicPositionEncapsulation' into stable

Conflicts:

src/Actions/AtomAction/ChangeElementAction.cpp
src/Actions/WorldAction/RemoveSphereOfAtomsAction.cpp
src/Makefile.am
src/UIElements/TextUI/TextDialog.cpp
src/analysis_correlation.hpp
src/atom.cpp
src/atom_atominfo.hpp
src/bond.cpp
src/boundary.cpp
src/molecule_geometry.cpp
src/tesselation.cpp
src/tesselationhelpers.cpp
src/triangleintersectionlist.cpp
src/unittests/Makefile.am

  • fixed #includes due to moves to Helpers and LinearAlgebra
  • moved VectorInterface.* and vector_ops.* to LinearAlgebra
  • no more direct access of atom::node, remapped to set/getPosition()
  • no more direct access to atom::type, remapped to set/getType() (also in atom due to derivation and atominfo::AtomicElement is private not protected).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r8d6d31 r8f4df1  
    157157  atomIds.erase( atom->getId() );
    158158  atoms.remove( atom );
    159   formula-=atom->type;
     159  formula-=atom->getType();
    160160  atom->removeFromMolecule();
    161161  return iter;
     
    169169    atomIds.erase( key->getId() );
    170170    atoms.remove( key );
    171     formula-=key->type;
     171    formula-=key->getType();
    172172    key->removeFromMolecule();
    173173  }
     
    191191  if (res.second) { // push atom if went well
    192192    atoms.push_back(key);
    193     formula+=key->type;
     193    formula+=key->getType();
    194194    return pair<iterator,bool>(molecule::iterator(--end()),res.second);
    195195  } else {
     
    212212  if (pointer != NULL) {
    213213    pointer->sort = &pointer->nr;
    214     if (pointer->type != NULL) {
    215       formula += pointer->type;
    216       if (pointer->type->Z != 1)
     214    if (pointer->getType() != NULL) {
     215      formula += pointer->getType();
     216      if (pointer->getType()->Z != 1)
    217217        NoNonHydrogen++;
    218218      if(pointer->getName() == "Unknown"){
    219219        stringstream sstr;
    220         sstr << pointer->type->symbol << pointer->nr+1;
     220        sstr << pointer->getType()->symbol << pointer->nr+1;
    221221        pointer->setName(sstr.str());
    222222      }
     
    239239  if (pointer != NULL) {
    240240    atom *walker = pointer->clone();
    241     formula += walker->type;
     241    formula += walker->getType();
    242242    walker->setName(pointer->getName());
    243243    walker->nr = last_atom++;  // increase number within molecule
    244244    insert(walker);
    245     if ((pointer->type != NULL) && (pointer->type->Z != 1))
     245    if ((pointer->getType() != NULL) && (pointer->getType()->Z != 1))
    246246      NoNonHydrogen++;
    247247    retval=walker;
     
    301301//  Log() << Verbose(3) << "Begin of AddHydrogenReplacementAtom." << endl;
    302302  // create vector in direction of bond
    303   InBondvector = TopReplacement->x - TopOrigin->x;
     303  InBondvector = TopReplacement->getPosition() - TopOrigin->getPosition();
    304304  bondlength = InBondvector.Norm();
    305305
     
    313313    Orthovector1.Zero();
    314314    for (int i=NDIM;i--;) {
    315       l = TopReplacement->x[i] - TopOrigin->x[i];
     315      l = TopReplacement->at(i) - TopOrigin->at(i);
    316316      if (fabs(l) > BondDistance) { // is component greater than bond distance
    317317        Orthovector1[i] = (l < 0) ? -1. : +1.;
     
    328328  InBondvector.Normalize();
    329329  // get typical bond length and store as scale factor for later
    330   ASSERT(TopOrigin->type != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
    331   BondRescale = TopOrigin->type->HBondDistance[TopBond->BondDegree-1];
     330  ASSERT(TopOrigin->getType() != NULL, "AddHydrogenReplacementAtom: element of TopOrigin is not given.");
     331  BondRescale = TopOrigin->getType()->HBondDistance[TopBond->BondDegree-1];
    332332  if (BondRescale == -1) {
    333333    DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond distance in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     
    343343    case 1:
    344344      FirstOtherAtom = World::getInstance().createAtom();    // new atom
    345       FirstOtherAtom->type = elemente->FindElement(1);  // element is Hydrogen
    346       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     345      FirstOtherAtom->setType(1);  // element is Hydrogen
     346      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    347347      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    348       if (TopReplacement->type->Z == 1) { // neither rescale nor replace if it's already hydrogen
     348      if (TopReplacement->getType()->Z == 1) { // neither rescale nor replace if it's already hydrogen
    349349        FirstOtherAtom->father = TopReplacement;
    350350        BondRescale = bondlength;
     
    353353      }
    354354      InBondvector *= BondRescale;   // rescale the distance vector to Hydrogen bond length
    355       FirstOtherAtom->x = TopOrigin->x; // set coordination to origin ...
    356       FirstOtherAtom->x += InBondvector;  // ... and add distance vector to replacement atom
     355      FirstOtherAtom->setPosition(TopOrigin->getPosition() + InBondvector); // set coordination to origin and add distance vector to replacement atom
    357356      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
    358357//      Log() << Verbose(4) << "Added " << *FirstOtherAtom << " at: ";
     
    387386        // determine the plane of these two with the *origin
    388387        try {
    389           Orthovector1 =Plane(TopOrigin->x, FirstOtherAtom->x, SecondOtherAtom->x).getNormal();
     388          Orthovector1 =Plane(TopOrigin->getPosition(), FirstOtherAtom->getPosition(), SecondOtherAtom->getPosition()).getNormal();
    390389        }
    391390        catch(LinearDependenceException &excp){
     
    408407      FirstOtherAtom = World::getInstance().createAtom();
    409408      SecondOtherAtom = World::getInstance().createAtom();
    410       FirstOtherAtom->type = elemente->FindElement(1);
    411       SecondOtherAtom->type = elemente->FindElement(1);
    412       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     409      FirstOtherAtom->setType(1);
     410      SecondOtherAtom->setType(1);
     411      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    413412      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    414       SecondOtherAtom->v = TopReplacement->v; // copy velocity
     413      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    415414      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    416415      FirstOtherAtom->father = NULL;  // we are just an added hydrogen with no father
    417416      SecondOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
    418       bondangle = TopOrigin->type->HBondAngle[1];
     417      bondangle = TopOrigin->getType()->HBondAngle[1];
    419418      if (bondangle == -1) {
    420419        DoeLog(1) && (eLog()<< Verbose(1) << "There is no typical hydrogen bond angle in replacing bond (" << TopOrigin->getName() << "<->" << TopReplacement->getName() << ") of degree " << TopBond->BondDegree << "!" << endl);
     
    430429//      Log() << Verbose(0) << endl;
    431430//      Log() << Verbose(3) << "Half the bond angle is " << bondangle << ", sin and cos of it: " << sin(bondangle) << ", " << cos(bondangle) << endl;
    432       FirstOtherAtom->x.Zero();
    433       SecondOtherAtom->x.Zero();
     431      FirstOtherAtom->Zero();
     432      SecondOtherAtom->Zero();
    434433      for(int i=NDIM;i--;) { // rotate by half the bond angle in both directions (InBondvector is bondangle = 0 direction)
    435         FirstOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle));
    436         SecondOtherAtom->x[i] = InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle));
    437       }
    438       FirstOtherAtom->x *= BondRescale;  // rescale by correct BondDistance
    439       SecondOtherAtom->x *= BondRescale;
     434        FirstOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (sin(bondangle)));
     435        SecondOtherAtom->set(i, InBondvector[i] * cos(bondangle) + Orthovector1[i] * (-sin(bondangle)));
     436      }
     437      FirstOtherAtom->Scale(BondRescale);  // rescale by correct BondDistance
     438      SecondOtherAtom->Scale(BondRescale);
    440439      //Log() << Verbose(3) << "ReScaleCheck: " << FirstOtherAtom->x.Norm() << " and " << SecondOtherAtom->x.Norm() << "." << endl;
    441       for(int i=NDIM;i--;) { // and make relative to origin atom
    442         FirstOtherAtom->x[i] += TopOrigin->x[i];
    443         SecondOtherAtom->x[i] += TopOrigin->x[i];
    444       }
     440      *FirstOtherAtom += TopOrigin->getPosition();
     441      *SecondOtherAtom += TopOrigin->getPosition();
    445442      // ... and add to molecule
    446443      AllWentWell = AllWentWell && AddAtom(FirstOtherAtom);
     
    464461      SecondOtherAtom = World::getInstance().createAtom();
    465462      ThirdOtherAtom = World::getInstance().createAtom();
    466       FirstOtherAtom->type = elemente->FindElement(1);
    467       SecondOtherAtom->type = elemente->FindElement(1);
    468       ThirdOtherAtom->type = elemente->FindElement(1);
    469       FirstOtherAtom->v = TopReplacement->v; // copy velocity
     463      FirstOtherAtom->setType(1);
     464      SecondOtherAtom->setType(1);
     465      ThirdOtherAtom->setType(1);
     466      FirstOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    470467      FirstOtherAtom->FixedIon = TopReplacement->FixedIon;
    471       SecondOtherAtom->v = TopReplacement->v; // copy velocity
     468      SecondOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    472469      SecondOtherAtom->FixedIon = TopReplacement->FixedIon;
    473       ThirdOtherAtom->v = TopReplacement->v; // copy velocity
     470      ThirdOtherAtom->AtomicVelocity = TopReplacement->AtomicVelocity; // copy velocity
    474471      ThirdOtherAtom->FixedIon = TopReplacement->FixedIon;
    475472      FirstOtherAtom->father = NULL;  //  we are just an added hydrogen with no father
     
    494491
    495492      // create correct coordination for the three atoms
    496       alpha = (TopOrigin->type->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
     493      alpha = (TopOrigin->getType()->HBondAngle[2])/180.*M_PI/2.;  // retrieve triple bond angle from database
    497494      l = BondRescale;        // desired bond length
    498495      b = 2.*l*sin(alpha);    // base length of isosceles triangle
     
    505502      factors[1] = f;
    506503      factors[2] = 0.;
    507       FirstOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     504      FirstOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    508505      factors[1] = -0.5*f;
    509506      factors[2] = g;
    510       SecondOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     507      SecondOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    511508      factors[2] = -g;
    512       ThirdOtherAtom->x.LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
     509      ThirdOtherAtom->LinearCombinationOfVectors(InBondvector, Orthovector1, Orthovector2, factors);
    513510
    514511      // rescale each to correct BondDistance
     
    518515
    519516      // and relative to *origin atom
    520       FirstOtherAtom->x += TopOrigin->x;
    521       SecondOtherAtom->x += TopOrigin->x;
    522       ThirdOtherAtom->x += TopOrigin->x;
     517      *FirstOtherAtom += TopOrigin->getPosition();
     518      *SecondOtherAtom += TopOrigin->getPosition();
     519      *ThirdOtherAtom += TopOrigin->getPosition();
    523520
    524521      // ... and add to molecule
     
    596593    *item >> x[1];
    597594    *item >> x[2];
    598     Walker->type = elemente->FindElement(shorthand);
    599     if (Walker->type == NULL) {
     595    Walker->setType(elemente->FindElement(shorthand));
     596    if (Walker->getType() == NULL) {
    600597      DoeLog(1) && (eLog()<< Verbose(1) << "Could not parse the element at line: '" << line << "', setting to H.");
    601       Walker->type = elemente->FindElement(1);
     598      Walker->setType(1);
    602599    }
    603600    if (Walker->Trajectory.R.size() <= (unsigned int)MDSteps) {
     
    606603      Walker->Trajectory.F.resize(MDSteps+10);
    607604    }
     605    Walker->setPosition(Vector(x));
    608606    for(j=NDIM;j--;) {
    609       Walker->x[j] = x[j];
    610607      Walker->Trajectory.R.at(MDSteps-1)[j] = x[j];
    611608      Walker->Trajectory.U.at(MDSteps-1)[j] = 0;
     
    702699  atom1->RegisterBond(Binder);
    703700  atom2->RegisterBond(Binder);
    704   if ((atom1->type != NULL) && (atom1->type->Z != 1) && (atom2->type != NULL) && (atom2->type->Z != 1))
     701  if ((atom1->getType() != NULL) && (atom1->getType()->Z != 1) && (atom2->getType() != NULL) && (atom2->getType()->Z != 1))
    705702    NoNonBonds++;
    706703
     
    776773  ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom().");
    777774  OBSERVE;
    778   formula-=pointer->type;
     775  formula-=pointer->getType();
    779776  RemoveBonds(pointer);
    780777  erase(pointer);
     
    790787  if (pointer == NULL)
    791788    return false;
    792   formula-=pointer->type;
     789  formula-=pointer->getType();
    793790  erase(pointer);
    794791  return true;
     
    972969  for (molecule::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter) {
    973970    (*iter)->nr = i;   // update number in molecule (for easier referencing in FragmentMolecule lateron)
    974     if ((*iter)->type->Z != 1) // count non-hydrogen atoms whilst at it
     971    if ((*iter)->getType()->Z != 1) // count non-hydrogen atoms whilst at it
    975972      NoNonHydrogen++;
    976973    stringstream sstr;
    977     sstr << (*iter)->type->symbol << (*iter)->nr+1;
     974    sstr << (*iter)->getType()->symbol << (*iter)->nr+1;
    978975    (*iter)->setName(sstr.str());
    979976    DoLog(3) && (Log() << Verbose(3) << "Naming atom nr. " << (*iter)->nr << " " << (*iter)->getName() << "." << endl);
Note: See TracChangeset for help on using the changeset viewer.