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