| [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 |  | 
|---|
| [83f176] | 24 | #include "Helpers/Assert.hpp" | 
|---|
| [cd4ccc] | 25 | #include "element.hpp" | 
|---|
| [14de469] | 26 |  | 
|---|
| [ead4e6] | 27 | using namespace std; | 
|---|
|  | 28 |  | 
|---|
| [14de469] | 29 | /************************************* Functions for class element **********************************/ | 
|---|
|  | 30 |  | 
|---|
|  | 31 | /** Constructor of class element. | 
|---|
|  | 32 | */ | 
|---|
| [d5af3e] | 33 | element::element() : | 
|---|
|  | 34 | mass(0), | 
|---|
|  | 35 | CovalentRadius(0), | 
|---|
|  | 36 | VanDerWaalsRadius(0), | 
|---|
|  | 37 | Z(-1), | 
|---|
|  | 38 | Valence(0), | 
|---|
|  | 39 | NoValenceOrbitals(0) | 
|---|
|  | 40 | { | 
|---|
| [27c6be] | 41 | }; | 
|---|
| [14de469] | 42 |  | 
|---|
| [2a76b0] | 43 | element::element(const element &src) : | 
|---|
|  | 44 | mass(src.mass), | 
|---|
|  | 45 | CovalentRadius(src.CovalentRadius), | 
|---|
|  | 46 | VanDerWaalsRadius(src.VanDerWaalsRadius), | 
|---|
|  | 47 | Z(src.Z), | 
|---|
|  | 48 | Valence(src.Valence), | 
|---|
|  | 49 | NoValenceOrbitals(src.NoValenceOrbitals), | 
|---|
|  | 50 | name(src.name), | 
|---|
|  | 51 | symbol(src.symbol) | 
|---|
|  | 52 | { | 
|---|
| [ae959a] | 53 | period = src.period; | 
|---|
|  | 54 | group = src.group; | 
|---|
|  | 55 | block = src.block; | 
|---|
| [2a76b0] | 56 | } | 
|---|
|  | 57 |  | 
|---|
| [14de469] | 58 | /** Destructor of class element. | 
|---|
|  | 59 | */ | 
|---|
|  | 60 | element::~element() {}; | 
|---|
|  | 61 |  | 
|---|
| [2a76b0] | 62 | element &element::operator=(const element &src){ | 
|---|
|  | 63 | if(this!=&src){ | 
|---|
|  | 64 | mass=src.mass; | 
|---|
|  | 65 | CovalentRadius=src.CovalentRadius; | 
|---|
|  | 66 | VanDerWaalsRadius=src.VanDerWaalsRadius; | 
|---|
|  | 67 | Z=src.Z; | 
|---|
|  | 68 | Valence=src.Valence; | 
|---|
|  | 69 | NoValenceOrbitals=src.NoValenceOrbitals; | 
|---|
|  | 70 | name=src.name; | 
|---|
|  | 71 | symbol=src.symbol; | 
|---|
| [ae959a] | 72 | period = src.period; | 
|---|
|  | 73 | group = src.group; | 
|---|
|  | 74 | block = src.block; | 
|---|
| [2a76b0] | 75 | } | 
|---|
|  | 76 | return *this; | 
|---|
|  | 77 | } | 
|---|
|  | 78 |  | 
|---|
| [14de469] | 79 | /** Prints element data to \a *out. | 
|---|
|  | 80 | * \param *out outstream | 
|---|
|  | 81 | */ | 
|---|
| [ead4e6] | 82 | bool element::Output(ostream * const out) const | 
|---|
| [14de469] | 83 | { | 
|---|
| [042f82] | 84 | if (out != NULL) { | 
|---|
|  | 85 | *out << name << "\t" << symbol << "\t" << period << "\t" << group << "\t" << block << "\t" << Z << "\t" << mass << "\t" << CovalentRadius << "\t" << VanDerWaalsRadius << endl; | 
|---|
|  | 86 | //*out << Z << "\t"  << fixed << setprecision(11) << showpoint << mass << "g/mol\t" << name << "\t" << symbol << "\t" << endl; | 
|---|
|  | 87 | return true; | 
|---|
|  | 88 | } else | 
|---|
|  | 89 | return false; | 
|---|
| [14de469] | 90 | }; | 
|---|
|  | 91 |  | 
|---|
|  | 92 | /** Prints element data to \a *out. | 
|---|
|  | 93 | * \param *out outstream | 
|---|
| [042f82] | 94 | * \param No  cardinal number of element | 
|---|
| [14de469] | 95 | * \param NoOfAtoms total number of atom of this element type | 
|---|
|  | 96 | */ | 
|---|
| [ead4e6] | 97 | bool element::Checkout(ostream * const out, const int Number, const int NoOfAtoms) const | 
|---|
| [14de469] | 98 | { | 
|---|
| [042f82] | 99 | if (out != NULL) { | 
|---|
|  | 100 | *out << "Ion_Type" << Number << "\t" << NoOfAtoms << "\t" << Z << "\t1.0\t3\t3\t" << fixed << setprecision(11) << showpoint << mass << "\t" << name << "\t" << symbol <<endl; | 
|---|
|  | 101 | return true; | 
|---|
|  | 102 | } else | 
|---|
|  | 103 | return false; | 
|---|
| [14de469] | 104 | }; | 
|---|
| [ead4e6] | 105 |  | 
|---|
|  | 106 | atomicNumber_t element::getNumber() const{ | 
|---|
|  | 107 | return Z; | 
|---|
|  | 108 | } | 
|---|
| [83f176] | 109 |  | 
|---|
|  | 110 | double element::getMass() const | 
|---|
|  | 111 | { | 
|---|
|  | 112 | return mass; | 
|---|
|  | 113 | } | 
|---|
|  | 114 |  | 
|---|
|  | 115 | double element::getCovalentRadius() const | 
|---|
|  | 116 | { | 
|---|
|  | 117 | return CovalentRadius; | 
|---|
|  | 118 | } | 
|---|
|  | 119 |  | 
|---|
|  | 120 | double element::getVanDerWaalsRadius() const | 
|---|
|  | 121 | { | 
|---|
|  | 122 | return VanDerWaalsRadius; | 
|---|
|  | 123 | } | 
|---|
|  | 124 |  | 
|---|
|  | 125 | int element::getAtomicNumber() const | 
|---|
|  | 126 | { | 
|---|
|  | 127 | return Z; | 
|---|
|  | 128 | } | 
|---|
|  | 129 |  | 
|---|
|  | 130 | double element::getValence() const | 
|---|
|  | 131 | { | 
|---|
|  | 132 | return Valence; | 
|---|
|  | 133 | } | 
|---|
|  | 134 |  | 
|---|
|  | 135 | int element::getNoValenceOrbitals() const | 
|---|
|  | 136 | { | 
|---|
|  | 137 | return NoValenceOrbitals; | 
|---|
|  | 138 | } | 
|---|
|  | 139 |  | 
|---|
|  | 140 | double element::getHBondDistance(const int i) const | 
|---|
|  | 141 | { | 
|---|
|  | 142 | ASSERT((i>=0) && (i<3), "Access to element::HBondDistance out of bounds."); | 
|---|
|  | 143 | return HBondDistance[i]; | 
|---|
|  | 144 | } | 
|---|
|  | 145 |  | 
|---|
|  | 146 | double element::getHBondAngle(const int i) const | 
|---|
|  | 147 | { | 
|---|
|  | 148 | ASSERT((i>=0) && (i<3), "Access to element::HBondAngle out of bounds."); | 
|---|
|  | 149 | return HBondAngle[i]; | 
|---|
|  | 150 | } | 
|---|
|  | 151 |  | 
|---|
| [7e3fc94] | 152 | string &element::getSymbol(){ | 
|---|
|  | 153 | return symbol; | 
|---|
| [ead4e6] | 154 | } | 
|---|
| [e345e3] | 155 |  | 
|---|
| [7e3fc94] | 156 | const string &element::getSymbol() const{ | 
|---|
|  | 157 | return symbol; | 
|---|
| [ff6a10] | 158 | } | 
|---|
| [83f176] | 159 |  | 
|---|
|  | 160 | void element::setSymbol(const std::string &temp) | 
|---|
|  | 161 | { | 
|---|
|  | 162 | symbol = temp; | 
|---|
|  | 163 | } | 
|---|
| [ff6a10] | 164 |  | 
|---|
| [7e3fc94] | 165 | std::string &element::getName(){ | 
|---|
|  | 166 | return name; | 
|---|
| [e345e3] | 167 | } | 
|---|
|  | 168 |  | 
|---|
| [7e3fc94] | 169 | const std::string &element::getName() const{ | 
|---|
|  | 170 | return name; | 
|---|
| [ff6a10] | 171 | } | 
|---|
| [83f176] | 172 |  | 
|---|
|  | 173 | void element::setName(const std::string &temp) | 
|---|
|  | 174 | { | 
|---|
|  | 175 | name = temp; | 
|---|
|  | 176 | } | 
|---|
| [ff6a10] | 177 |  | 
|---|
| [e345e3] | 178 | std::ostream &operator<<(std::ostream &ost,const element &elem){ | 
|---|
|  | 179 | ost << elem.getName() << "(" << elem.getNumber() << ")"; | 
|---|
|  | 180 | return ost; | 
|---|
|  | 181 | } | 
|---|