-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatom.cpp
More file actions
112 lines (93 loc) · 1.57 KB
/
Copy pathatom.cpp
File metadata and controls
112 lines (93 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <iostream>
#include "atom.h"
#include "periodic.h"
Atom::Atom(std::string nm, int zn=0, double q=0.0, double xx=0.0,
double yy=0.0, double zz=0.0, double mm=0.0)
{
Znuc=zn;
M=mm;
name=nm;
xo=xx; yo=yy; zo=zz;
chg=q;
}
Atom::Atom(std::string nm, int zn=0, double xx=0.0,
double yy=0.0, double zz=0.0)
{
Znuc=zn;
M=periodic::mass(zn);
name=nm;
xo=xx; yo=yy; zo=zz;
chg=0.0;
}
Atom::Atom(std::string nm, int zn=0)
{
Znuc=zn;
M=periodic::mass(zn);
name=nm;
xo=0.0; yo=0.0; zo=0.0;
chg=0.0;
}
Atom::~Atom()
{
}
std::ostream& operator << (std::ostream& s, Atom & atom)
{
s << "#ATOM: ";
s << atom.name << "\n" << "Z = " << atom.Znuc << "\tM = " << atom.M;
s << "\tq = " << atom.chg << std::endl;
s << "(" << atom.xo << ", " << atom.yo << ", " << atom.zo << ")";
s << std::endl;
return s;
}
double Atom::charge() const
{
return chg;
}
void Atom::set_charge(double q)
{
chg=q;
}
void Atom::move_to(double x, double y, double z)
{
xo=x; yo=y; zo=z;
}
void Atom::move_by(double dx, double dy, double dz)
{
xo+=dx; yo+=dy; zo+=dz;
}
void Atom::position(double& x, double& y, double& z) const
{
x=xo; y=yo; z=zo;
}
void Atom::set_Z(int zn)
{
Znuc=zn;
}
int Atom::Z() const
{
return Znuc;
}
void Atom::set_mass(double mm)
{
M=mm;
}
double Atom::mass() const
{
return M;
}
std::string Atom::label() const
{
return name;
}
void Atom::set_label(std::string nm)
{
name=nm;
}
double distance2(const Atom& a1, const Atom& a2)
{
double d=0.0;
d+=((a1.xo-a2.xo)*(a1.xo-a2.xo));
d+=((a1.yo-a2.yo)*(a1.yo-a2.yo));
d+=((a1.zo-a2.zo)*(a1.zo-a2.zo));
return d;
}