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