MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
atom.h
1//
2// atom.h
3//
4// Copyright (C) 2013 Drew Lewis
5//
6// Author: Drew Lewis <drew90@vt.edu>
7// Maintainer: Drew Lewis and Edward Valeev
8//
9// This file is part of the SC Toolkit.
10//
11// The SC Toolkit is free software; you can redistribute it and/or modify
12// it under the terms of the GNU Library General Public License as published by
13// the Free Software Foundation; either version 2, or (at your option)
14// any later version.
15//
16// The SC Toolkit is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Library General Public License for more details.
20//
21// You should have received a copy of the GNU Library General Public License
22// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24//
25// The U.S. Government is granted a limited license as per AL 91-7.
26//
27
28#ifndef _chemisty_molecule_atom_h
29#define _chemisty_molecule_atom_h
30
31#include <string>
32#include <util/state/stateio.h>
33#ifdef MPQC_NEW_FEATURES
34#include <util/misc/xml.h>
35#endif
36
37namespace sc {
38
41
47 class Atom
48#ifdef MPQC_NEW_FEATURES
49 : public XMLWritable
50#endif
51 {
52
53 private:
55 double r_[3];
56 int Z_;
57
58 bool have_charge_;
59 bool have_fragment_;
60
61 // optional prameters.
62 double charge_;
63 int fragment_;
64 double mass_;
65 std::string label_;
66
67 public:
85 Atom(int Z, double x, double y, double z, const std::string &label,
86 double mass = 0, int have_charge = 0, double charge = 0,
87 int have_fragment = 0, int fragment = 0)
88 : Z_(Z), have_charge_(have_charge), have_fragment_(have_fragment),
89 charge_(charge), fragment_(fragment), mass_(mass), label_(label)
90 {
91 r_[0] = x;
92 r_[1] = y;
93 r_[2] = z;
94 }
95
99 Atom(int Z, double x, double y, double z, const char *label = 0,
100 double mass = 0, int have_charge = 0, double charge = 0,
101 int have_fragment = 0, int fragment = 0)
102 : Z_(Z), have_charge_(have_charge), have_fragment_(have_fragment),
103 charge_(charge), fragment_(fragment), mass_(mass), label_(label ? label : "")
104 {
105 r_[0] = x;
106 r_[1] = y;
107 r_[2] = z;
108 }
109
110
117 Atom() : Z_(-1), have_charge_(true), have_fragment_(true),
118 charge_(-1), fragment_(-1), mass_(-1), label_()
119 { r_[0] = -1; r_[1] = -1; r_[2] = -1; }
120
121 Atom(const Atom &other) :
122 Z_(other.Z_),
123 have_charge_(other.have_charge_),
124 have_fragment_(other.have_fragment_),
125 charge_(other.charge_),
126 fragment_(other.fragment_),
127 mass_(other.mass_),
128 label_(other.label_)
129 {
130 r_[0] = other.r_[0];
131 r_[1] = other.r_[1];
132 r_[2] = other.r_[2];
133 }
134
136 double& r(int xyz){return r_[xyz];}
137 const double& r(int xyz) const {return r_[xyz];}
138
140 double* r(){return r_;}
141 const double* r() const {return r_;}
142
144 int Z() const {return Z_;}
145 double mass() const {return mass_;}
146 bool have_charge() const {return have_charge_;}
147 double charge() const {return charge_;}
148 bool have_fragment() const {return have_fragment_;}
149 int fragment() const {return fragment_;}
150 const std::string& label() const {return label_;}
151
152 // Made friend for direct access for sc::SavableState
153 friend void FromStateIn(Atom &a, StateIn &so, int &count);
154
155#ifdef MPQC_NEW_FEATURES
156 virtual boost::property_tree::ptree& write_xml(boost::property_tree::ptree& parent, const XMLWriter& writer);
157#endif
158 };
159
161 void ToStateOut(const Atom &a, StateOut &so, int &count);
162
164 void FromStateIn(Atom &a, StateIn &si, int &count);
165
167 bool operator==(const Atom& a, const Atom& b);
168
170 inline bool operator!=(const Atom& a, const Atom& b) { return not (a == b); }
171
173 // end of addtogroup ChemistryMolecule
174
175}
176
177
178#endif /* _chemistry_molecule_atom_h */
Atom represents an atom in a Molecule.
Definition atom.h:51
int Z() const
Returns atomic number.
Definition atom.h:144
double & r(int xyz)
Returns a reference to the x,y, or z coordinate.
Definition atom.h:136
Atom()
Default constructor supplied so that Atom will work with sc::SavableState.
Definition atom.h:117
friend void FromStateIn(Atom &a, StateIn &so, int &count)
reads Atom from sc::StateIn
double * r()
Returns a pointer to the coordinate array.
Definition atom.h:140
Atom(int Z, double x, double y, double z, const char *label=0, double mass=0, int have_charge=0, double charge=0, int have_fragment=0, int fragment=0)
Constructs an atom object that takes a c style char * array.
Definition atom.h:99
Atom(int Z, double x, double y, double z, const std::string &label, double mass=0, int have_charge=0, double charge=0, int have_fragment=0, int fragment=0)
Creates an atom for use in the sc::Molecule class.
Definition atom.h:85
Restores fundamental and user-defined types from images created with StateOut.
Definition statein.h:79
Serializes fundamental and user-defined types.
Definition stateout.h:71
Definition xml.h:44
Definition xmlwriter.h:223
SpinCase1 other(SpinCase1 S)
given 1-spin return the other 1-spin
void FromStateIn(Atom &a, StateIn &si, int &count)
reads Atom from sc::StateIn
bool operator==(const Atom &a, const Atom &b)
bool operator!=(const Atom &a, const Atom &b)
Definition atom.h:170
void ToStateOut(const Atom &a, StateOut &so, int &count)
writes Atom to sc::StateOut
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:28 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.