Changeset d74077 for src/atom.cpp


Ignore:
Timestamp:
Jul 31, 2010, 3:23:10 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:
8f4df1
Parents:
5fbaeb
Message:

Member variable Vector and element of class atom are now private.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/atom.cpp

    r5fbaeb rd74077  
    2727atom::atom() :
    2828  father(this), sort(&nr), mol(0)
    29 {
    30   node = &x;  // TesselPoint::x can only be referenced from here
    31 };
     29{};
    3230
    3331/** Constructor of class atom.
     
    3634    ParticleInfo(pointer),father(pointer), sort(&nr)
    3735{
    38   type = pointer->type;  // copy element of atom
    39   x = pointer->x; // copy coordination
    40   v = pointer->v; // copy velocity
     36  setType(pointer->getType());  // copy element of atom
     37  setPosition(pointer->getPosition()); // copy coordination
     38  AtomicVelocity = pointer->AtomicVelocity; // copy velocity
    4139  FixedIon = pointer->FixedIon;
    42   node = &x;
    4340  mol = 0;
    4441};
     
    4845  res->father = this;
    4946  res->sort = &res->nr;
    50   res->type = type;
    51   res->x = this->x;
    52   res->v = this->v;
     47  res->setType(getType());
     48  res->setPosition(this->getPosition());
     49  res->AtomicVelocity = this->AtomicVelocity;
    5350  res->FixedIon = FixedIon;
    54   res->node = &x;
    5551  res->mol = 0;
    5652  World::getInstance().registerAtom(res);
     
    116112bool atom::IsInShape(const Shape& shape) const
    117113{
    118   return shape.isInside(*node);
     114  return shape.isInside(getPosition());
    119115};
    120116
     
    141137  if (out != NULL) {
    142138    *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t"  << fixed << setprecision(9) << showpoint;
    143     *out << x[0] << "\t" << x[1] << "\t" << x[2];
     139    *out << at(0) << "\t" << at(1) << "\t" << at(2);
    144140    *out << "\t" << FixedIon;
    145     if (v.Norm() > MYEPSILON)
    146       *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
     141    if (AtomicVelocity.Norm() > MYEPSILON)
     142      *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t";
    147143    if (comment != NULL)
    148144      *out << " # " << comment << endl;
     
    163159bool atom::OutputArrayIndexed(ostream * const out, const int *ElementNo, int *AtomNo, const char *comment) const
    164160{
    165   AtomNo[type->Z]++;  // increment number
    166   if (out != NULL) {
    167     *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
    168     *out << x[0] << "\t" << x[1] << "\t" << x[2];
     161  AtomNo[getType()->Z]++;  // increment number
     162  if (out != NULL) {
     163    *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t"  << fixed << setprecision(9) << showpoint;
     164    *out << at(0) << "\t" << at(1) << "\t" << at(2);
    169165    *out << "\t" << FixedIon;
    170     if (v.Norm() > MYEPSILON)
    171       *out << "\t" << scientific << setprecision(6) << v[0] << "\t" << v[1] << "\t" << v[2] << "\t";
     166    if (AtomicVelocity.Norm() > MYEPSILON)
     167      *out << "\t" << scientific << setprecision(6) << AtomicVelocity[0] << "\t" << AtomicVelocity[1] << "\t" << AtomicVelocity[2] << "\t";
    172168    if (comment != NULL)
    173169      *out << " # " << comment << endl;
     
    186182{
    187183  if (out != NULL) {
    188     *out << type->symbol << "\t" << x[0] << "\t" << x[1] << "\t" << x[2] << "\t" << endl;
     184    *out << getType()->symbol << "\t" << at(0) << "\t" << at(1) << "\t" << at(2) << "\t" << endl;
    189185    return true;
    190186  } else
     
    201197bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const
    202198{
    203   AtomNo[type->Z]++;
    204   if (out != NULL) {
    205     *out << "Ion_Type" << ElementNo[type->Z] << "_" << AtomNo[type->Z] << "\t"  << fixed << setprecision(9) << showpoint;
     199  AtomNo[getType()->Z]++;
     200  if (out != NULL) {
     201    *out << "Ion_Type" << ElementNo[getType()->Z] << "_" << AtomNo[getType()->Z] << "\t"  << fixed << setprecision(9) << showpoint;
    206202    *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
    207203    *out << "\t" << FixedIon;
     
    224220{
    225221  if (out != NULL) {
    226     *out << type->symbol << "\t";
     222    *out << getType()->symbol << "\t";
    227223    *out << Trajectory.R.at(step)[0] << "\t";
    228224    *out << Trajectory.R.at(step)[1] << "\t";
     
    240236void atom::OutputMPQCLine(ostream * const out, const Vector *center, int *AtomNo = NULL) const
    241237{
    242   *out << "\t\t" << type->symbol << " [ " << x[0]-center->at(0) << "\t" << x[1]-center->at(1) << "\t" << x[2]-center->at(2) << " ]" << endl;
     238  Vector recentered(getPosition());
     239  recentered -= *center;
     240  *out << "\t\t" << getType()->symbol << " [ " << recentered[0] << "\t" << recentered[1] << "\t" << recentered[2] << " ]" << endl;
    243241  if (AtomNo != NULL)
    244242    *AtomNo++;
     
    263261double atom::DistanceSquaredToVector(const Vector &origin) const
    264262{
    265   return origin.DistanceSquared(x);
     263  return DistanceSquared(origin);
    266264};
    267265
     
    272270double atom::DistanceToVector(const Vector &origin) const
    273271{
    274   return origin.distance(x);
     272  return distance(origin);
    275273};
    276274
     
    287285};
    288286
     287std::ostream & atom::operator << (std::ostream &ost) const
     288{
     289  ParticleInfo::operator<<(ost);
     290  ost << "," << getPosition();
     291  return ost;
     292}
     293
     294std::ostream & operator << (std::ostream &ost, const atom &a)
     295{
     296  a.ParticleInfo::operator<<(ost);
     297  ost << "," << a.getPosition();
     298  return ost;
     299}
    289300
    290301bool operator < (atom &a, atom &b)
Note: See TracChangeset for help on using the changeset viewer.