source: src/Fragmentation/Summation/SetValues/Fragment.hpp@ 9eb71b3

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes
Last change on this file since 9eb71b3 was 6829d2, checked in by Frederik Heber <heber@…>, 8 years ago

MPQCData additionally stores the atomic number per nuclei.

  • in case of DoSampleValenceOnly the charge does not represent the atomic number and moreover it is no longer unique. However, we need this unique association for fitting potentials to the fragment results.
  • TESTFIX: set all tests to XFAIL that parse either fragmentation results or homologies.
  • TESTFIX: needed to adapt HomologyContainerUnitTest which uses FragmentStub.
  • TESTFIX: needed to adapt FragmentUnitTest.
  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[c74fdb]1/*
2 * Fragment.hpp
3 *
4 * Created on: Aug 8, 2012
5 * Author: heber
6 */
7
8#ifndef FRAGMENT_HPP_
9#define FRAGMENT_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
[a576eb]17#include <boost/serialization/export.hpp>
18#include <boost/serialization/vector.hpp>
19#include <boost/serialization/utility.hpp>
20
[184943]21#include <iosfwd>
[c74fdb]22#include <vector>
23
[f3bc5f]24class FragmentTest;
25
[c74fdb]26class Fragment {
[184943]27 //!> grant ostream operator access
28 friend std::ostream & operator<<(std::ostream &ost, const Fragment &f);
[f3bc5f]29 //!> grant unit test access
30 friend class FragmentTest;
[c74fdb]31public:
[f3bc5f]32 typedef std::vector<double> position_t;
33 typedef std::vector< position_t > positions_t;
[4a77be7]34 typedef double charge_t;
35 typedef std::vector< charge_t > charges_t;
[6829d2]36 typedef unsigned int atomicNumber_t; // typedef is copied
37 typedef std::vector< atomicNumber_t > atomicnumbers_t;
38 typedef std::pair< position_t, std::pair<atomicNumber_t, charge_t> > nucleus_t;
[c74fdb]39 typedef std::vector< nucleus_t > nuclei_t;
40
41 /** Default constructor of class Fragment.
42 *
43 */
44 Fragment();
45
46 /** Default constructor of class Fragment.
47 *
48 */
49 Fragment(const nuclei_t &_nuclei) :
50 nuclei(_nuclei)
51 {}
52
53 /** Constructor of class Fragment.
54 *
55 * @param _positions given positions
[6829d2]56 * @param _atomicnumbers given atomic numbers
[c74fdb]57 * @param _charges given charges
58 */
[6829d2]59 Fragment(
60 const positions_t &_positions,
61 const atomicnumbers_t &_atomicnumbers,
62 const charges_t &_charges);
[c74fdb]63
64 /** Adding another fragment onto this one.
65 *
66 * \note The operation is area-conserving, i.e. the new area is the sum of
67 * both areas.
68 *
69 * @param other other fragment
70 * @return ref to this instance
71 */
72 Fragment& operator+=(const Fragment &other);
73
74 /** Assignment operator.
75 *
76 * @param other other fragment to make ourselves equal to
77 * @return ref to this instance
78 */
79 Fragment& operator=(const Fragment &other);
80
81 /** Subtracting another fragment from this one.
82 *
83 * @param other other fragment
84 * @return ref to this instance
85 */
86 Fragment& operator-=(const Fragment &other);
87
[184943]88 /** Getter for all stored positions.
89 *
90 * @return vector of positions
91 */
92 positions_t getPositions() const;
93
[6829d2]94 /** Getter for all stored atomic numbers.
95 *
96 * @return vector of atomic numbers
97 */
98 atomicnumbers_t getAtomicNumbers() const;
99
[184943]100 /** Getter for all stored charges.
101 *
102 * @return vector of charges
103 */
104 charges_t getCharges() const;
105
[f3bc5f]106 /** Equality operator.
107 *
108 * @param other other instance to check against
109 * @return true - both are equal, false - some nucleus_t differ
110 */
111 bool operator==(const Fragment& other) const;
112
113 bool operator!=(const Fragment& other) const
114 {
115 return (!(*this == other));
116 }
117
118 /** Creates type nucleus_t from given \a position and \a charge.
119 *
120 * @param position position of nucleus to create
[6829d2]121 * @param atomicnumber atomic number of nucleus to create
[f3bc5f]122 * @param charge charge of nucleus to create
123 * @return nucleus with given \a position and \a charge
124 */
[6829d2]125 static nucleus_t createNucleus(
126 const position_t &position,
127 const atomicNumber_t &atomicnumber,
128 const double charge);
[f3bc5f]129
130 /** Helper function to check whether two positions are equal.
131 *
132 * @param a first position
133 * @param b second position
134 * @return a equals b within numerical precision
135 */
136 static bool isPositionEqual(const position_t &a, const position_t &b);
137
[c74fdb]138private:
[f3bc5f]139 /** Helper function that checks whether this nuclei \b position is present.
[c74fdb]140 *
141 * This operation is \f${\cal O}(n)\f$
142 *
143 * @param n nuclei to check
144 * @return true - is contained, false - is not contained
145 */
146 bool containsNuclei(const nucleus_t &n) const;
147
[f3bc5f]148 /** Seeks through all nuclei and removes one with matching \b position if found.
[c74fdb]149 *
150 * @param n nuclei to remove
151 */
152 void removeNuclei(const nucleus_t &n);
153
154private:
155 nuclei_t nuclei;
[a576eb]156
157private:
158 friend class boost::serialization::access;
159 // serialization
160 template <typename Archive>
161 void serialize(Archive& ar, const unsigned int version)
162 {
163 ar & nuclei;
164 }
[c74fdb]165};
166
[a576eb]167// we need to give this class a unique key for serialization
168BOOST_CLASS_EXPORT_KEY(Fragment)
169
[f3bc5f]170/** Equality operator for two nuclei.
171 *
172 * @param a first nuclei
173 * @param b second nuclei
174 * @return true - both have same position and charge, false - either charge or position is different
175 */
176bool operator==(const Fragment::nucleus_t &a, const Fragment::nucleus_t &b);
177
178std::ostream & operator<<(std::ostream &ost, const Fragment::nucleus_t &n);
179
[184943]180std::ostream & operator<<(std::ostream &ost, const Fragment &f);
181
[c74fdb]182template<typename T> T ZeroInstance();
183template<> Fragment ZeroInstance<Fragment>();
184
185#endif /* FRAGMENT_HPP_ */
Note: See TracBrowser for help on using the repository browser.