source: src/atom.cpp@ d2a294

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
Last change on this file since d2a294 was 6d35e4, checked in by Frederik Heber <heber@…>, 17 years ago

AtomStackClass -> template <typename T> StackClass<T> change in new file stackclass.hpp, other templates to helpers.hpp

StackClass was changed to a template and as template code may only be present in header file was moved to a new
header file stackclass.hpp. New file was added to Makefile.am
Other templates (list management et al) were moved to helpers.hpp as they are more sensibly placed there.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/** \file atom.cpp
2 *
3 * Function implementations for the class atom.
4 *
5 */
6
7#include "molecules.hpp"
8
9/************************************* Functions for class atom *************************************/
10
11/** Constructor of class atom.
12 */
13atom::atom()
14{
15 Name = NULL;
16 previous = NULL;
17 next = NULL;
18 father = this; // generally, father is itself
19 Ancestor = NULL;
20 type = NULL;
21 sort = NULL;
22 FixedIon = 0;
23 nr = -1;
24 GraphNr = -1;
25 ComponentNr = NULL;
26 SeparationVertex = false;
27 LowpointNr = -1;
28 AdaptiveOrder = 0;
29};
30
31/** Destructor of class atom.
32 */
33atom::~atom()
34{
35 Free((void **)&Name, "atom::~atom: *Name");
36 Free((void **)&ComponentNr, "atom::~atom: *ComponentNr");
37};
38
39
40/** Climbs up the father list until NULL, last is returned.
41 * \return true father, i.e. whose father points to itself, NULL if it could not be found or has none (added hydrogen)
42 */
43atom *atom::GetTrueFather()
44{
45 atom *walker = this;
46 do {
47 if (walker == walker->father) // top most father is the one that points on itself
48 break;
49 walker = walker->father;
50 } while (walker != NULL);
51 return walker;
52};
53
54/** Output of a single atom.
55 * \param ElementNo cardinal number of the element
56 * \param AtomNo cardinal number among these atoms of the same element
57 * \param *out stream to output to
58 */
59bool atom::Output(int ElementNo, int AtomNo, ofstream *out) const
60{
61 if (out != NULL) {
62 *out << "Ion_Type" << ElementNo << "_" << AtomNo << "\t" << fixed << setprecision(9) << showpoint;
63 *out << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2];
64 *out << "\t" << FixedIon;
65 if (v.Norm() > MYEPSILON)
66 *out << "\t" << scientific << setprecision(6) << v.x[0] << "\t" << v.x[1] << "\t" << v.x[2] << "\t";
67 *out << " # Number in molecule " << nr << endl;
68 return true;
69 } else
70 return false;
71};
72
73/** Output of a single atom as one lin in xyz file.
74 * \param *out stream to output to
75 */
76bool atom::OutputXYZLine(ofstream *out) const
77{
78 if (out != NULL) {
79 *out << type->symbol << "\t" << x.x[0] << "\t" << x.x[1] << "\t" << x.x[2] << "\t" << endl;
80 return true;
81 } else
82 return false;
83};
84
85ostream & operator << (ostream &ost, atom &a)
86{
87 ost << "[" << a.Name << "|" << &a << "]";
88 return ost;
89};
90
91/** Compares the indices of \a this atom with a given \a ptr.
92 * \param ptr atom to compare index against
93 * \return true - this one's is smaller, false - not
94 */
95bool atom::Compare(atom &ptr)
96{
97 if (nr < ptr.nr)
98 return true;
99 else
100 return false;
101};
102
103bool operator < (atom &a, atom &b)
104{
105 return a.Compare(b);
106};
107
Note: See TracBrowser for help on using the repository browser.