1 | /** \file element.cpp
|
---|
2 | *
|
---|
3 | * Function implementations for the class element.
|
---|
4 | *
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "Helpers/MemDebug.hpp"
|
---|
8 |
|
---|
9 | #include <iomanip>
|
---|
10 | #include <fstream>
|
---|
11 |
|
---|
12 | #include "element.hpp"
|
---|
13 |
|
---|
14 | using namespace std;
|
---|
15 |
|
---|
16 | /************************************* Functions for class element **********************************/
|
---|
17 |
|
---|
18 | /** Constructor of class element.
|
---|
19 | */
|
---|
20 | element::element() :
|
---|
21 | mass(0),
|
---|
22 | CovalentRadius(0),
|
---|
23 | VanDerWaalsRadius(0),
|
---|
24 | Z(-1),
|
---|
25 | Valence(0),
|
---|
26 | NoValenceOrbitals(0)
|
---|
27 | {
|
---|
28 | };
|
---|
29 |
|
---|
30 | element::element(const element &src) :
|
---|
31 | mass(src.mass),
|
---|
32 | CovalentRadius(src.CovalentRadius),
|
---|
33 | VanDerWaalsRadius(src.VanDerWaalsRadius),
|
---|
34 | Z(src.Z),
|
---|
35 | Valence(src.Valence),
|
---|
36 | NoValenceOrbitals(src.NoValenceOrbitals),
|
---|
37 | name(src.name),
|
---|
38 | symbol(src.symbol)
|
---|
39 | {
|
---|
40 | strncpy(period,src.period,strfield_length+1);
|
---|
41 | strncpy(group,src.group,strfield_length+1);
|
---|
42 | strncpy(block,src.block,strfield_length+1);
|
---|
43 | }
|
---|
44 |
|
---|
45 | /** Destructor of class element.
|
---|
46 | */
|
---|
47 | element::~element() {};
|
---|
48 |
|
---|
49 | element &element::operator=(const element &src){
|
---|
50 | if(this!=&src){
|
---|
51 | mass=src.mass;
|
---|
52 | CovalentRadius=src.CovalentRadius;
|
---|
53 | VanDerWaalsRadius=src.VanDerWaalsRadius;
|
---|
54 | Z=src.Z;
|
---|
55 | Valence=src.Valence;
|
---|
56 | NoValenceOrbitals=src.NoValenceOrbitals;
|
---|
57 | name=src.name;
|
---|
58 | symbol=src.symbol;
|
---|
59 | strncpy(period,src.period,strfield_length+1);
|
---|
60 | strncpy(group,src.group,strfield_length+1);
|
---|
61 | strncpy(block,src.block,strfield_length+1);
|
---|
62 | }
|
---|
63 | return *this;
|
---|
64 | }
|
---|
65 |
|
---|
66 | /** Prints element data to \a *out.
|
---|
67 | * \param *out outstream
|
---|
68 | */
|
---|
69 | bool element::Output(ostream * const out) const
|
---|
70 | {
|
---|
71 | if (out != NULL) {
|
---|
72 | *out << name << "\t" << symbol << "\t" << period << "\t" << group << "\t" << block << "\t" << Z << "\t" << mass << "\t" << CovalentRadius << "\t" << VanDerWaalsRadius << endl;
|
---|
73 | //*out << Z << "\t" << fixed << setprecision(11) << showpoint << mass << "g/mol\t" << name << "\t" << symbol << "\t" << endl;
|
---|
74 | return true;
|
---|
75 | } else
|
---|
76 | return false;
|
---|
77 | };
|
---|
78 |
|
---|
79 | /** Prints element data to \a *out.
|
---|
80 | * \param *out outstream
|
---|
81 | * \param No cardinal number of element
|
---|
82 | * \param NoOfAtoms total number of atom of this element type
|
---|
83 | */
|
---|
84 | bool element::Checkout(ostream * const out, const int Number, const int NoOfAtoms) const
|
---|
85 | {
|
---|
86 | if (out != NULL) {
|
---|
87 | *out << "Ion_Type" << Number << "\t" << NoOfAtoms << "\t" << Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << mass << "\t" << name << "\t" << symbol <<endl;
|
---|
88 | return true;
|
---|
89 | } else
|
---|
90 | return false;
|
---|
91 | };
|
---|
92 |
|
---|
93 | atomicNumber_t element::getNumber() const{
|
---|
94 | return Z;
|
---|
95 | }
|
---|
96 |
|
---|
97 | string &element::getSymbol(){
|
---|
98 | return symbol;
|
---|
99 | }
|
---|
100 |
|
---|
101 | const string &element::getSymbol() const{
|
---|
102 | return symbol;
|
---|
103 | }
|
---|
104 |
|
---|
105 | std::string &element::getName(){
|
---|
106 | return name;
|
---|
107 | }
|
---|
108 |
|
---|
109 | const std::string &element::getName() const{
|
---|
110 | return name;
|
---|
111 | }
|
---|
112 |
|
---|
113 | std::ostream &operator<<(std::ostream &ost,const element &elem){
|
---|
114 | ost << elem.getName() << "(" << elem.getNumber() << ")";
|
---|
115 | return ost;
|
---|
116 | }
|
---|