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