| 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 |
|
|---|
| 8 | /** \file element.cpp
|
|---|
| 9 | *
|
|---|
| 10 | * Function implementations for the class element.
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | // include config.h
|
|---|
| 15 | #ifdef HAVE_CONFIG_H
|
|---|
| 16 | #include <config.h>
|
|---|
| 17 | #endif
|
|---|
| 18 |
|
|---|
| 19 | #include "Helpers/MemDebug.hpp"
|
|---|
| 20 |
|
|---|
| 21 | #include <iomanip>
|
|---|
| 22 | #include <fstream>
|
|---|
| 23 |
|
|---|
| 24 | #include "element.hpp"
|
|---|
| 25 |
|
|---|
| 26 | using namespace std;
|
|---|
| 27 |
|
|---|
| 28 | /************************************* Functions for class element **********************************/
|
|---|
| 29 |
|
|---|
| 30 | /** Constructor of class element.
|
|---|
| 31 | */
|
|---|
| 32 | element::element() :
|
|---|
| 33 | mass(0),
|
|---|
| 34 | CovalentRadius(0),
|
|---|
| 35 | VanDerWaalsRadius(0),
|
|---|
| 36 | Z(-1),
|
|---|
| 37 | Valence(0),
|
|---|
| 38 | NoValenceOrbitals(0)
|
|---|
| 39 | {
|
|---|
| 40 | };
|
|---|
| 41 |
|
|---|
| 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 | {
|
|---|
| 52 | period = src.period;
|
|---|
| 53 | group = src.group;
|
|---|
| 54 | block = src.block;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | /** Destructor of class element.
|
|---|
| 58 | */
|
|---|
| 59 | element::~element() {};
|
|---|
| 60 |
|
|---|
| 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;
|
|---|
| 71 | period = src.period;
|
|---|
| 72 | group = src.group;
|
|---|
| 73 | block = src.block;
|
|---|
| 74 | }
|
|---|
| 75 | return *this;
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | /** Prints element data to \a *out.
|
|---|
| 79 | * \param *out outstream
|
|---|
| 80 | */
|
|---|
| 81 | bool element::Output(ostream * const out) const
|
|---|
| 82 | {
|
|---|
| 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;
|
|---|
| 89 | };
|
|---|
| 90 |
|
|---|
| 91 | /** Prints element data to \a *out.
|
|---|
| 92 | * \param *out outstream
|
|---|
| 93 | * \param No cardinal number of element
|
|---|
| 94 | * \param NoOfAtoms total number of atom of this element type
|
|---|
| 95 | */
|
|---|
| 96 | bool element::Checkout(ostream * const out, const int Number, const int NoOfAtoms) const
|
|---|
| 97 | {
|
|---|
| 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;
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 | atomicNumber_t element::getNumber() const{
|
|---|
| 106 | return Z;
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | string &element::getSymbol(){
|
|---|
| 110 | return symbol;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | const string &element::getSymbol() const{
|
|---|
| 114 | return symbol;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | std::string &element::getName(){
|
|---|
| 118 | return name;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | const std::string &element::getName() const{
|
|---|
| 122 | return name;
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | std::ostream &operator<<(std::ostream &ost,const element &elem){
|
|---|
| 126 | ost << elem.getName() << "(" << elem.getNumber() << ")";
|
|---|
| 127 | return ost;
|
|---|
| 128 | }
|
|---|