| 1 | /** \file element.cpp
|
|---|
| 2 | *
|
|---|
| 3 | * Function implementations for the class element.
|
|---|
| 4 | *
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | // include config.h
|
|---|
| 8 | #ifdef HAVE_CONFIG_H
|
|---|
| 9 | #include <config.h>
|
|---|
| 10 | #endif
|
|---|
| 11 |
|
|---|
| 12 | #include "Helpers/MemDebug.hpp"
|
|---|
| 13 |
|
|---|
| 14 | #include <iomanip>
|
|---|
| 15 | #include <fstream>
|
|---|
| 16 |
|
|---|
| 17 | #include "element.hpp"
|
|---|
| 18 |
|
|---|
| 19 | using namespace std;
|
|---|
| 20 |
|
|---|
| 21 | /************************************* Functions for class element **********************************/
|
|---|
| 22 |
|
|---|
| 23 | /** Constructor of class element.
|
|---|
| 24 | */
|
|---|
| 25 | element::element() :
|
|---|
| 26 | mass(0),
|
|---|
| 27 | CovalentRadius(0),
|
|---|
| 28 | VanDerWaalsRadius(0),
|
|---|
| 29 | Z(-1),
|
|---|
| 30 | Valence(0),
|
|---|
| 31 | NoValenceOrbitals(0)
|
|---|
| 32 | {
|
|---|
| 33 | };
|
|---|
| 34 |
|
|---|
| 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 |
|
|---|
| 50 | /** Destructor of class element.
|
|---|
| 51 | */
|
|---|
| 52 | element::~element() {};
|
|---|
| 53 |
|
|---|
| 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 |
|
|---|
| 71 | /** Prints element data to \a *out.
|
|---|
| 72 | * \param *out outstream
|
|---|
| 73 | */
|
|---|
| 74 | bool element::Output(ostream * const out) const
|
|---|
| 75 | {
|
|---|
| 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;
|
|---|
| 82 | };
|
|---|
| 83 |
|
|---|
| 84 | /** Prints element data to \a *out.
|
|---|
| 85 | * \param *out outstream
|
|---|
| 86 | * \param No cardinal number of element
|
|---|
| 87 | * \param NoOfAtoms total number of atom of this element type
|
|---|
| 88 | */
|
|---|
| 89 | bool element::Checkout(ostream * const out, const int Number, const int NoOfAtoms) const
|
|---|
| 90 | {
|
|---|
| 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;
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | atomicNumber_t element::getNumber() const{
|
|---|
| 99 | return Z;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | string &element::getSymbol(){
|
|---|
| 103 | return symbol;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | const string &element::getSymbol() const{
|
|---|
| 107 | return symbol;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | std::string &element::getName(){
|
|---|
| 111 | return name;
|
|---|
| 112 | }
|
|---|
| 113 |
|
|---|
| 114 | const std::string &element::getName() const{
|
|---|
| 115 | return name;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | std::ostream &operator<<(std::ostream &ost,const element &elem){
|
|---|
| 119 | ost << elem.getName() << "(" << elem.getNumber() << ")";
|
|---|
| 120 | return ost;
|
|---|
| 121 | }
|
|---|