| [14de469] | 1 | /** \file element.cpp
 | 
|---|
 | 2 |  * 
 | 
|---|
 | 3 |  * Function implementations for the class element.
 | 
|---|
 | 4 |  * 
 | 
|---|
 | 5 |  */
 | 
|---|
 | 6 | 
 | 
|---|
| [112b09] | 7 | #include "Helpers/MemDebug.hpp"
 | 
|---|
 | 8 | 
 | 
|---|
| [cd4ccc] | 9 | #include <iomanip>
 | 
|---|
 | 10 | #include <fstream>
 | 
|---|
 | 11 | 
 | 
|---|
 | 12 | #include "element.hpp"
 | 
|---|
| [14de469] | 13 | 
 | 
|---|
| [ead4e6] | 14 | using namespace std;
 | 
|---|
 | 15 | 
 | 
|---|
| [14de469] | 16 | /************************************* Functions for class element **********************************/
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | /** Constructor of class element.
 | 
|---|
 | 19 |  */
 | 
|---|
| [d5af3e] | 20 | element::element() :
 | 
|---|
 | 21 |   mass(0),
 | 
|---|
 | 22 |   CovalentRadius(0),
 | 
|---|
 | 23 |   VanDerWaalsRadius(0),
 | 
|---|
 | 24 |         Z(-1),
 | 
|---|
 | 25 |         Valence(0),
 | 
|---|
 | 26 |         NoValenceOrbitals(0)
 | 
|---|
 | 27 | {
 | 
|---|
| [27c6be] | 28 | };
 | 
|---|
| [14de469] | 29 | 
 | 
|---|
| [2a76b0] | 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 | 
 | 
|---|
| [14de469] | 45 | /** Destructor of class element.
 | 
|---|
 | 46 |  */
 | 
|---|
 | 47 | element::~element() {};
 | 
|---|
 | 48 | 
 | 
|---|
| [2a76b0] | 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 | 
 | 
|---|
| [14de469] | 66 | /** Prints element data to \a *out.
 | 
|---|
 | 67 |  * \param *out outstream
 | 
|---|
 | 68 |  */
 | 
|---|
| [ead4e6] | 69 | bool element::Output(ostream * const out) const
 | 
|---|
| [14de469] | 70 | { 
 | 
|---|
| [042f82] | 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;
 | 
|---|
| [14de469] | 77 | };
 | 
|---|
 | 78 | 
 | 
|---|
 | 79 | /** Prints element data to \a *out.
 | 
|---|
 | 80 |  * \param *out outstream
 | 
|---|
| [042f82] | 81 |  * \param No  cardinal number of element
 | 
|---|
| [14de469] | 82 |  * \param NoOfAtoms total number of atom of this element type
 | 
|---|
 | 83 |  */
 | 
|---|
| [ead4e6] | 84 | bool element::Checkout(ostream * const out, const int Number, const int NoOfAtoms) const
 | 
|---|
| [14de469] | 85 | { 
 | 
|---|
| [042f82] | 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;
 | 
|---|
| [14de469] | 91 | };
 | 
|---|
| [ead4e6] | 92 | 
 | 
|---|
 | 93 | atomicNumber_t element::getNumber() const{
 | 
|---|
 | 94 |   return Z;
 | 
|---|
 | 95 | }
 | 
|---|
 | 96 | 
 | 
|---|
| [7e3fc94] | 97 | string &element::getSymbol(){
 | 
|---|
 | 98 |   return symbol;
 | 
|---|
| [ead4e6] | 99 | }
 | 
|---|
| [e345e3] | 100 | 
 | 
|---|
| [7e3fc94] | 101 | const string &element::getSymbol() const{
 | 
|---|
 | 102 |   return symbol;
 | 
|---|
| [ff6a10] | 103 | }
 | 
|---|
 | 104 | 
 | 
|---|
| [7e3fc94] | 105 | std::string &element::getName(){
 | 
|---|
 | 106 |   return name;
 | 
|---|
| [e345e3] | 107 | }
 | 
|---|
 | 108 | 
 | 
|---|
| [7e3fc94] | 109 | const std::string &element::getName() const{
 | 
|---|
 | 110 |   return name;
 | 
|---|
| [ff6a10] | 111 | }
 | 
|---|
 | 112 | 
 | 
|---|
| [e345e3] | 113 | std::ostream &operator<<(std::ostream &ost,const element &elem){
 | 
|---|
 | 114 |   ost << elem.getName() << "(" << elem.getNumber() << ")";
 | 
|---|
 | 115 |   return ost;
 | 
|---|
 | 116 | }
 | 
|---|